@agoric/inter-protocol 0.16.1 → 0.16.2-calypso-dev-84eb287.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +6 -6
  2. package/package.json +41 -36
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +135 -103
  7. package/src/auction/auctioneer.d.ts +69 -0
  8. package/src/auction/auctioneer.d.ts.map +1 -0
  9. package/src/auction/auctioneer.js +63 -49
  10. package/src/auction/offerBook.d.ts +45 -0
  11. package/src/auction/offerBook.d.ts.map +1 -0
  12. package/src/auction/offerBook.js +13 -12
  13. package/src/auction/params.d.ts +144 -0
  14. package/src/auction/params.d.ts.map +1 -0
  15. package/src/auction/params.js +10 -9
  16. package/src/auction/scheduleMath.d.ts +5 -0
  17. package/src/auction/scheduleMath.d.ts.map +1 -0
  18. package/src/auction/scheduleMath.js +17 -15
  19. package/src/auction/scheduler.d.ts +49 -0
  20. package/src/auction/scheduler.d.ts.map +1 -0
  21. package/src/auction/scheduler.js +51 -43
  22. package/src/auction/sortedOffers.d.ts +8 -0
  23. package/src/auction/sortedOffers.d.ts.map +1 -0
  24. package/src/auction/sortedOffers.js +9 -7
  25. package/src/auction/util.d.ts +32 -0
  26. package/src/auction/util.d.ts.map +1 -0
  27. package/src/auction/util.js +6 -4
  28. package/src/clientSupport.d.ts +167 -0
  29. package/src/clientSupport.d.ts.map +1 -0
  30. package/src/clientSupport.js +154 -96
  31. package/src/collectFees.d.ts +2 -0
  32. package/src/collectFees.d.ts.map +1 -0
  33. package/src/contractSupport.d.ts +28 -0
  34. package/src/contractSupport.d.ts.map +1 -0
  35. package/src/contractSupport.js +14 -12
  36. package/src/econCommitteeCharter.d.ts +39 -0
  37. package/src/econCommitteeCharter.d.ts.map +1 -0
  38. package/src/econCommitteeCharter.js +21 -20
  39. package/src/feeDistributor.d.ts +224 -0
  40. package/src/feeDistributor.d.ts.map +1 -0
  41. package/src/feeDistributor.js +37 -33
  42. package/src/index.d.ts +2 -0
  43. package/src/index.d.ts.map +1 -0
  44. package/src/index.js +1 -0
  45. package/src/interest-math.d.ts +3 -0
  46. package/src/interest-math.d.ts.map +1 -0
  47. package/src/interest.d.ts +28 -0
  48. package/src/interest.d.ts.map +1 -0
  49. package/src/interest.js +21 -16
  50. package/src/price/README.md +13 -0
  51. package/src/price/fluxAggregatorContract.d.ts +70 -0
  52. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  53. package/src/price/fluxAggregatorContract.js +62 -55
  54. package/src/price/fluxAggregatorKit.d.ts +103 -0
  55. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  56. package/src/price/fluxAggregatorKit.js +50 -37
  57. package/src/price/priceOracleKit.d.ts +38 -0
  58. package/src/price/priceOracleKit.d.ts.map +1 -0
  59. package/src/price/priceOracleKit.js +11 -13
  60. package/src/price/roundsManager.d.ts +204 -0
  61. package/src/price/roundsManager.d.ts.map +1 -0
  62. package/src/price/roundsManager.js +79 -82
  63. package/src/proposals/README.md +2 -3
  64. package/src/proposals/add-auction.d.ts +69 -0
  65. package/src/proposals/add-auction.d.ts.map +1 -0
  66. package/src/proposals/add-auction.js +180 -0
  67. package/src/proposals/addAssetToVault.d.ts +160 -0
  68. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  69. package/src/proposals/addAssetToVault.js +172 -38
  70. package/src/proposals/committee-proposal.d.ts +113 -0
  71. package/src/proposals/committee-proposal.d.ts.map +1 -0
  72. package/src/proposals/committee-proposal.js +25 -31
  73. package/src/proposals/core-proposal.d.ts +149 -0
  74. package/src/proposals/core-proposal.d.ts.map +1 -0
  75. package/src/proposals/core-proposal.js +9 -11
  76. package/src/proposals/econ-behaviors.d.ts +539 -0
  77. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  78. package/src/proposals/econ-behaviors.js +64 -45
  79. package/src/proposals/price-feed-proposal.d.ts +84 -0
  80. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  81. package/src/proposals/price-feed-proposal.js +108 -51
  82. package/src/proposals/startEconCommittee.d.ts +34 -0
  83. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  84. package/src/proposals/startEconCommittee.js +2 -2
  85. package/src/proposals/startPSM.d.ts +59 -0
  86. package/src/proposals/startPSM.d.ts.map +1 -0
  87. package/src/proposals/startPSM.js +38 -27
  88. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  89. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  90. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  91. package/src/proposals/upgrade-vaults.d.ts +35 -0
  92. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  93. package/src/proposals/upgrade-vaults.js +235 -0
  94. package/src/proposals/utils.d.ts +17 -0
  95. package/src/proposals/utils.d.ts.map +1 -0
  96. package/src/proposals/utils.js +34 -7
  97. package/src/provisionPool.d.ts +167 -0
  98. package/src/provisionPool.d.ts.map +1 -0
  99. package/src/provisionPool.js +122 -0
  100. package/src/provisionPoolKit.d.ts +367 -0
  101. package/src/provisionPoolKit.d.ts.map +1 -0
  102. package/src/provisionPoolKit.js +522 -0
  103. package/src/psm/psm.d.ts +122 -0
  104. package/src/psm/psm.d.ts.map +1 -0
  105. package/src/psm/psm.js +73 -69
  106. package/src/psm/types-ambient.d.ts +2 -0
  107. package/src/psm/types-ambient.d.ts.map +1 -0
  108. package/src/psm/types-ambient.js +3 -0
  109. package/src/reserve/assetReserve.d.ts +47 -0
  110. package/src/reserve/assetReserve.d.ts.map +1 -0
  111. package/src/reserve/assetReserve.js +28 -19
  112. package/src/reserve/assetReserveKit.d.ts +74 -0
  113. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  114. package/src/reserve/assetReserveKit.js +18 -24
  115. package/src/reserve/params.d.ts +10 -0
  116. package/src/reserve/params.d.ts.map +1 -0
  117. package/src/tokens.d.ts +3 -0
  118. package/src/tokens.d.ts.map +1 -0
  119. package/src/tokens.js +5 -0
  120. package/src/vaultFactory/burn.d.ts +2 -0
  121. package/src/vaultFactory/burn.d.ts.map +1 -0
  122. package/src/vaultFactory/burn.js +1 -1
  123. package/src/vaultFactory/liquidation.d.ts +23 -0
  124. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  125. package/src/vaultFactory/liquidation.js +36 -22
  126. package/src/vaultFactory/math.d.ts +11 -0
  127. package/src/vaultFactory/math.d.ts.map +1 -0
  128. package/src/vaultFactory/math.js +10 -9
  129. package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
  130. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  131. package/src/vaultFactory/orderedVaultStore.js +8 -11
  132. package/src/vaultFactory/params.d.ts +140 -0
  133. package/src/vaultFactory/params.d.ts.map +1 -0
  134. package/src/vaultFactory/params.js +52 -24
  135. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  136. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  137. package/src/vaultFactory/prioritizedVaults.js +4 -4
  138. package/src/vaultFactory/proceeds.d.ts +35 -0
  139. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  140. package/src/vaultFactory/proceeds.js +26 -18
  141. package/src/vaultFactory/storeUtils.d.ts +25 -0
  142. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  143. package/src/vaultFactory/storeUtils.js +10 -12
  144. package/src/vaultFactory/types-ambient.d.ts +137 -0
  145. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  146. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  147. package/src/vaultFactory/vault.d.ts +332 -0
  148. package/src/vaultFactory/vault.d.ts.map +1 -0
  149. package/src/vaultFactory/vault.js +99 -93
  150. package/src/vaultFactory/vaultDirector.d.ts +340 -0
  151. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  152. package/src/vaultFactory/vaultDirector.js +63 -50
  153. package/src/vaultFactory/vaultFactory.d.ts +201 -0
  154. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  155. package/src/vaultFactory/vaultFactory.js +49 -32
  156. package/src/vaultFactory/vaultHolder.d.ts +126 -0
  157. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  158. package/src/vaultFactory/vaultHolder.js +10 -14
  159. package/src/vaultFactory/vaultKit.d.ts +32 -0
  160. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  161. package/src/vaultFactory/vaultKit.js +5 -4
  162. package/src/vaultFactory/vaultManager.d.ts +674 -0
  163. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  164. package/src/vaultFactory/vaultManager.js +249 -151
  165. package/CHANGELOG.md +0 -1033
  166. package/bundles/bundle-auctioneer-js-meta.json +0 -722
  167. package/bundles/bundle-auctioneer.js +0 -1
  168. package/bundles/bundle-econCommitteeCharter-js-meta.json +0 -514
  169. package/bundles/bundle-econCommitteeCharter.js +0 -1
  170. package/bundles/bundle-feeDistributor-js-meta.json +0 -458
  171. package/bundles/bundle-feeDistributor.js +0 -1
  172. package/bundles/bundle-fluxAggregatorKit-js-meta.json +0 -674
  173. package/bundles/bundle-fluxAggregatorKit.js +0 -1
  174. package/bundles/bundle-psm-js-meta.json +0 -666
  175. package/bundles/bundle-psm.js +0 -1
  176. package/bundles/bundle-reserve-js-meta.json +0 -662
  177. package/bundles/bundle-reserve.js +0 -1
  178. package/bundles/bundle-scaledPriceAuthority-js-meta.json +0 -542
  179. package/bundles/bundle-scaledPriceAuthority.js +0 -1
  180. package/bundles/bundle-vaultFactory-js-meta.json +0 -790
  181. package/bundles/bundle-vaultFactory.js +0 -1
  182. package/exported.js +0 -2
  183. package/scripts/add-collateral-core.js +0 -112
  184. package/scripts/deploy-contracts.js +0 -100
  185. package/scripts/init-core.js +0 -198
  186. package/scripts/invite-committee-core.js +0 -42
  187. package/scripts/manual-price-feed.js +0 -117
  188. package/scripts/price-feed-core.js +0 -104
  189. package/scripts/start-local-chain.sh +0 -84
  190. package/src/psm/types.js +0 -3
  191. package/src/typeGuards.js +0 -13
  192. package/src/vaultFactory/type-imports.js +0 -4
@@ -1,22 +1,21 @@
1
1
  // @jessie-check
2
2
 
3
3
  /**
4
- * @typedef {import('./vault').VaultNotification} VaultNotification
5
- * @typedef {import('./vault').Vault} Vault
6
- * @typedef {import('./vaultKit').VaultKit} VaultKit
7
- * @typedef {import('./vaultManager').VaultManager} VaultManager
8
- * @typedef {import('./vaultManager').CollateralManager} CollateralManager
9
- * @typedef {import('../reserve/assetReserve.js').AssetReserveLimitedCreatorFacet} AssetReserveCreatorFacet
10
- * @typedef {import('../reserve/assetReserve.js').AssetReservePublicFacet} AssetReservePublicFacet
11
- * @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
12
4
  * @typedef {import('./vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
13
- *
14
- * @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
15
- * @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
5
+ * @import {VaultNotification} from './vault.js'
6
+ * @import {Vault} from './vault.js'
7
+ * @import {VaultKit} from './vaultKit.js'
8
+ * @import {VaultManager} from './vaultManager.js'
9
+ * @import {CollateralManager} from './vaultManager.js'
10
+ * @import {AssetReserveLimitedCreatorFacet} from '../reserve/assetReserve.js'
11
+ * @import {AssetReservePublicFacet} from '../reserve/assetReserve.js'
12
+ * @import {AuctioneerPublicFacet} from '../auction/auctioneer.js'
13
+ * @import {Timestamp} from '@agoric/time'
14
+ * @import {RelativeTime} from '@agoric/time'
16
15
  */
17
16
 
18
17
  /**
19
- * @typedef {object} AutoswapLocal
18
+ * @typedef {object} AutoswapLocal
20
19
  * @property {(amount: Amount, brand: Brand) => Amount} getInputPrice
21
20
  * @property {() => Invitation} makeSwapInvitation
22
21
  */
@@ -24,13 +23,16 @@
24
23
  /**
25
24
  * @typedef {object} VaultManagerParamValues
26
25
  * @property {Ratio} liquidationMargin - margin below which collateral will be
27
- * liquidated to satisfy the debt.
28
- * @property {Ratio} liquidationPenalty - penalty charged upon liquidation as proportion of debt
29
- * @property {Ratio} interestRate - annual interest rate charged on debt positions
30
- * @property {Ratio} mintFee - The fee (in BasisPoints) charged when creating
31
- * or increasing a debt position.
26
+ * liquidated to satisfy the debt.
27
+ * @property {Ratio} liquidationPenalty - penalty charged upon liquidation as
28
+ * proportion of debt
29
+ * @property {Ratio} interestRate - annual interest rate charged on debt
30
+ * positions
31
+ * @property {Ratio} mintFee - The fee (in BasisPoints) charged when creating or
32
+ * increasing a debt position.
32
33
  * @property {Amount<'nat'>} debtLimit
33
- * @property {Ratio} [liquidationPadding] - vault must maintain this in order to remove collateral or add debt
34
+ * @property {Ratio} [liquidationPadding] - vault must maintain this in order to
35
+ * remove collateral or add debt
34
36
  */
35
37
 
36
38
  /**
@@ -42,32 +44,29 @@
42
44
  */
43
45
 
44
46
  /**
45
- * @typedef {object} VaultFactoryCreatorFacet
47
+ * @typedef {object} VaultFactoryCreatorFacet
46
48
  * @property {AddVaultType} addVaultType
47
49
  * @property {() => Allocation} getRewardAllocation
48
50
  * @property {() => Promise<Invitation<string, never>>} makeCollectFeesInvitation
49
- * @property {() => import('@agoric/time/src/types').TimerWaker} makeLiquidationWaker
50
- * @property {() => import('@agoric/time/src/types').TimerWaker} makePriceLockWaker
51
+ * @property {() => import('@agoric/time').TimerWaker} makeLiquidationWaker
52
+ * @property {() => import('@agoric/time').TimerWaker} makePriceLockWaker
51
53
  */
52
54
 
53
55
  /**
54
- * @callback MintAndTransfer
55
- * Mint new debt `toMint` and transfer the `fee` portion to the vaultFactory's reward
56
- * pool. Then reallocate over all the seat arguments and the rewardPoolSeat. Update
57
- * the `totalDebt` if the reallocate succeeds.
56
+ * @callback MintAndTransfer Mint new debt `toMint` and transfer the `fee`
57
+ * portion to the vaultFactory's reward pool. Then reallocate over all the
58
+ * seat arguments and the rewardPoolSeat. Update the `totalDebt` if the
59
+ * reallocate succeeds.
58
60
  * @param {ZCFSeat} mintReceiver
59
61
  * @param {Amount<'nat'>} toMint
60
62
  * @param {Amount<'nat'>} fee
61
- * @param {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} transfers
63
+ * @param {TransferPart[]} transfers
62
64
  * @returns {void}
63
65
  */
64
66
 
65
67
  /**
66
- * @callback BurnDebt
67
- *
68
- * Burn debt tokens off a seat and update
69
- * the `totalDebt` if the reallocate succeeds.
70
- *
68
+ * @callback BurnDebt Burn debt tokens off a seat and update the `totalDebt` if
69
+ * the reallocate succeeds.
71
70
  * @param {Amount} toBurn
72
71
  * @param {ZCFSeat} fromSeat
73
72
  * @returns {void}
@@ -77,17 +76,16 @@
77
76
  * @typedef {object} GetVaultParams
78
77
  * @property {() => Ratio} getLiquidationMargin
79
78
  * @property {() => Ratio} getMintFee
80
- * @property {() => Promise<PriceQuote>} getCollateralQuote
81
- * @property {() => Ratio} getInterestRate - The annual interest rate on a debt position
79
+ * @property {() => Promise<import('@agoric/zoe/tools/types.js').PriceQuote>} getCollateralQuote
80
+ * @property {() => Ratio} getInterestRate - The annual interest rate on a debt
81
+ * position
82
82
  * @property {() => RelativeTime} getChargingPeriod - The period (in seconds) at
83
83
  * which interest is charged to the debt position.
84
84
  * @property {() => RelativeTime} getRecordingPeriod - The period (in seconds)
85
85
  * at which interest is recorded to the debt position.
86
86
  */
87
87
 
88
- /**
89
- * @typedef {string} VaultId
90
- */
88
+ /** @typedef {string} VaultId */
91
89
 
92
90
  /**
93
91
  * @typedef {object} InterestTiming
@@ -104,7 +102,9 @@
104
102
 
105
103
  /**
106
104
  * @typedef {object} Liquidator
107
- * @property {() => Promise<Invitation<void, { debt: Amount<'nat'>; penaltyRate: Ratio; }>>} makeLiquidateInvitation
105
+ * @property {() => Promise<
106
+ * Invitation<void, { debt: Amount<'nat'>; penaltyRate: Ratio }>
107
+ * >} makeLiquidateInvitation
108
108
  */
109
109
 
110
110
  /**
@@ -124,11 +124,11 @@
124
124
  /**
125
125
  * @typedef {object} CalculatorKit
126
126
  * @property {Calculate} calculate calculate new debt for charging periods up to
127
- * the present.
127
+ * the present.
128
128
  * @property {Calculate} calculateReportingPeriod calculate new debt for
129
- * reporting periods up to the present. If some charging periods have elapsed
130
- * that don't constitute whole reporting periods, the time is not updated past
131
- * them and interest is not accumulated for them.
129
+ * reporting periods up to the present. If some charging periods have elapsed
130
+ * that don't constitute whole reporting periods, the time is not updated past
131
+ * them and interest is not accumulated for them.
132
132
  */
133
133
 
134
- /** @typedef {{key: 'governedParams' | {collateralBrand: Brand}}} VaultFactoryParamPath */
134
+ /** @typedef {{ key: 'governedParams' | { collateralBrand: Brand } }} VaultFactoryParamPath */
@@ -0,0 +1,332 @@
1
+ export namespace Phase {
2
+ let ACTIVE: "active";
3
+ let LIQUIDATING: "liquidating";
4
+ let CLOSED: "closed";
5
+ let LIQUIDATED: "liquidated";
6
+ let TRANSFER: "transfer";
7
+ }
8
+ /**
9
+ * @typedef {Phase[keyof typeof Phase]} HolderPhase
10
+ *
11
+ * @typedef {object} VaultNotification
12
+ * @property {Amount<'nat'>} locked Amount of Collateral locked
13
+ * @property {{ debt: Amount<'nat'>; interest: Ratio }} debtSnapshot 'debt' at
14
+ * the point the compounded interest was 'interest'
15
+ * @property {HolderPhase} vaultState
16
+ */
17
+ /**
18
+ * @typedef {object} VaultManager
19
+ * @property {() => Subscriber<import('./vaultManager.js').AssetState>} getAssetSubscriber
20
+ * @property {(collateralAmount: Amount) => Amount<'nat'>} maxDebtFor
21
+ * @property {() => Brand<'nat'>} getCollateralBrand
22
+ * @property {(base: string) => string} scopeDescription
23
+ * @property {() => Brand<'nat'>} getDebtBrand
24
+ * @property {MintAndTransfer} mintAndTransfer
25
+ * @property {(amount: Amount, seat: ZCFSeat) => void} burn
26
+ * @property {() => Ratio} getCompoundedInterest
27
+ * @property {(
28
+ * oldDebt: import('./storeUtils.js').NormalizedDebt,
29
+ * oldCollateral: Amount<'nat'>,
30
+ * vaultId: VaultId,
31
+ * vaultPhase: VaultPhase,
32
+ * vault: Vault,
33
+ * ) => void} handleBalanceChange
34
+ * @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
35
+ */
36
+ /**
37
+ * @typedef {Readonly<{
38
+ * idInManager: VaultId;
39
+ * manager: VaultManager;
40
+ * storageNode: StorageNode;
41
+ * vaultSeat: ZCFSeat;
42
+ * }>} ImmutableState
43
+ */
44
+ /**
45
+ * Snapshot is of the debt and compounded interest when the principal was last
46
+ * changed.
47
+ *
48
+ * @typedef {{
49
+ * interestSnapshot: Ratio;
50
+ * phase: VaultPhase;
51
+ * debtSnapshot: Amount<'nat'>;
52
+ * outerUpdater:
53
+ * | import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification>
54
+ * | null;
55
+ * }} MutableState
56
+ */
57
+ export const VaultI: import("@endo/patterns").InterfaceGuard<{
58
+ getCollateralAmount: import("@endo/patterns").MethodGuard;
59
+ getCurrentDebt: import("@endo/patterns").MethodGuard;
60
+ getNormalizedDebt: import("@endo/patterns").MethodGuard;
61
+ getVaultSeat: import("@endo/patterns").MethodGuard;
62
+ initVaultKit: import("@endo/patterns").MethodGuard;
63
+ liquidated: import("@endo/patterns").MethodGuard;
64
+ liquidating: import("@endo/patterns").MethodGuard;
65
+ makeAdjustBalancesInvitation: import("@endo/patterns").MethodGuard;
66
+ makeCloseInvitation: import("@endo/patterns").MethodGuard;
67
+ makeTransferInvitation: import("@endo/patterns").MethodGuard;
68
+ abortLiquidation: import("@endo/patterns").MethodGuard;
69
+ }>;
70
+ export function prepareVault(baggage: import("@agoric/swingset-liveslots").Baggage, makeRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorderKit, zcf: ZCF): (manager: VaultManager, idInManager: string, storageNode: globalThis.StorageNode) => import("@endo/exo").GuardedKit<{
71
+ helper: {
72
+ collateralBrand(): Brand<"nat">;
73
+ debtBrand(): Brand<"nat">;
74
+ emptyCollateral(): import("@agoric/ertp/src/types.js").NatAmount;
75
+ emptyDebt(): import("@agoric/ertp/src/types.js").NatAmount;
76
+ /**
77
+ * @typedef {{
78
+ * give: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
79
+ * want: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
80
+ * }} FullProposal
81
+ */
82
+ /**
83
+ * @param {ProposalRecord} partial
84
+ * @returns {FullProposal}
85
+ */
86
+ fullProposal(partial: ProposalRecord): {
87
+ give: {
88
+ Collateral: Amount<"nat">;
89
+ Minted: Amount<"nat">;
90
+ };
91
+ want: {
92
+ Collateral: Amount<"nat">;
93
+ Minted: Amount<"nat">;
94
+ };
95
+ };
96
+ /** @param {VaultPhase} newPhase */
97
+ assignPhase(newPhase: VaultPhase): void;
98
+ assertActive(): void;
99
+ assertCloseable(): void;
100
+ /**
101
+ * Called whenever the debt is paid or created through a transaction,
102
+ * but not for interest accrual.
103
+ *
104
+ * @param {Amount<'nat'>} newDebt - principal and all accrued interest
105
+ */
106
+ updateDebtSnapshot(newDebt: Amount<"nat">): void;
107
+ /**
108
+ * Update the debt balance and propagate upwards to maintain aggregate
109
+ * debt and liquidation order.
110
+ *
111
+ * @param {NormalizedDebt} oldDebtNormalized - prior principal and all
112
+ * accrued interest, normalized to the launch of the vaultManager
113
+ * @param {Amount<'nat'>} oldCollateral - actual collateral
114
+ * @param {Amount<'nat'>} newDebtActual - actual principal and all
115
+ * accrued interest
116
+ */
117
+ updateDebtAccounting(oldDebtNormalized: NormalizedDebt, oldCollateral: Amount<"nat">, newDebtActual: Amount<"nat">): void;
118
+ /**
119
+ * @param {ZCFSeat} seat
120
+ * @returns {Amount<'nat'>}
121
+ */
122
+ getCollateralAllocated(seat: ZCFSeat): Amount<"nat">;
123
+ /**
124
+ * @param {ZCFSeat} seat
125
+ * @returns {Amount<'nat'>}
126
+ */
127
+ getMintedAllocated(seat: ZCFSeat): Amount<"nat">;
128
+ assertVaultHoldsNoMinted(): void;
129
+ /**
130
+ * @param {Amount<'nat'>} collateralAmount
131
+ * @param {Amount<'nat'>} proposedDebt
132
+ */
133
+ assertSufficientCollateral(collateralAmount: Amount<"nat">, proposedDebt: Amount<"nat">): void;
134
+ /** @param {HolderPhase} newPhase */
135
+ getStateSnapshot(newPhase: HolderPhase): {
136
+ debtSnapshot: {
137
+ debt: import("@agoric/ertp/src/types.js").NatAmount;
138
+ interest: Ratio;
139
+ };
140
+ locked: import("@agoric/ertp/src/types.js").NatAmount;
141
+ vaultState: HolderPhase;
142
+ };
143
+ /** call this whenever anything changes! */
144
+ updateUiState(): void;
145
+ /** @param {ZCFSeat} seat */
146
+ closeHook(seat: ZCFSeat): Promise<string>;
147
+ /**
148
+ * Calculate the fee, the amount to mint and the resulting debt. The
149
+ * give and the want together reflect a delta, where typically one is
150
+ * zero because they come from the gave/want of an offer proposal. If
151
+ * the `want` is zero, the `fee` will also be zero, so the simple math
152
+ * works.
153
+ *
154
+ * @param {Amount<'nat'>} currentDebt
155
+ * @param {Amount<'nat'>} giveAmount
156
+ * @param {Amount<'nat'>} wantAmount
157
+ */
158
+ debtFee(currentDebt: Amount<"nat">, giveAmount: Amount<"nat">, wantAmount: Amount<"nat">): {
159
+ newDebt: import("@agoric/ertp/src/types.js").NatAmount;
160
+ toMint: import("@agoric/ertp/src/types.js").NatAmount;
161
+ fee: import("@agoric/ertp/src/types.js").NatAmount;
162
+ surplus: import("@agoric/ertp/src/types.js").NatAmount;
163
+ };
164
+ /**
165
+ * Adjust principal and collateral (atomically for offer safety)
166
+ *
167
+ * @param {ZCFSeat} clientSeat
168
+ * @returns {string} success message
169
+ */
170
+ adjustBalancesHook(clientSeat: ZCFSeat): string;
171
+ /**
172
+ * @param {ZCFSeat} clientSeat
173
+ * @param {FullProposal} fp
174
+ * @param {ReturnType<typeof calculateDebtCosts>} costs
175
+ * @param {object} accounting
176
+ * @param {NormalizedDebt} accounting.normalizedDebtPre
177
+ * @param {Amount<'nat'>} accounting.collateralPre
178
+ * @returns {string} success message
179
+ */
180
+ commitBalanceAdjustment(clientSeat: ZCFSeat, fp: {
181
+ give: {
182
+ Collateral: Amount<"nat">;
183
+ Minted: Amount<"nat">;
184
+ };
185
+ want: {
186
+ Collateral: Amount<"nat">;
187
+ Minted: Amount<"nat">;
188
+ };
189
+ }, { newDebt, fee, surplus, toMint }: ReturnType<typeof calculateDebtCosts>, { normalizedDebtPre, collateralPre }: {
190
+ normalizedDebtPre: NormalizedDebt;
191
+ collateralPre: Amount<"nat">;
192
+ }): string;
193
+ /**
194
+ * @param {ZCFSeat} seat
195
+ * @returns {VaultKit}
196
+ */
197
+ makeTransferInvitationHook(seat: ZCFSeat): VaultKit;
198
+ };
199
+ self: {
200
+ getVaultSeat(): ZCFSeat;
201
+ /**
202
+ * @param {ZCFSeat} seat
203
+ * @param {StorageNode} storageNode
204
+ */
205
+ initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
206
+ publicSubscribers: {
207
+ vault: {
208
+ description: string;
209
+ subscriber: globalThis.Subscriber<VaultNotification>;
210
+ storagePath: Promise<string>;
211
+ };
212
+ };
213
+ invitationMakers: import("@endo/exo").Guarded<{
214
+ AdjustBalances(): Promise<Invitation<string, undefined>>;
215
+ CloseVault(): Promise<Invitation<string, undefined>>;
216
+ TransferVault(): Promise<Invitation<any, undefined>>;
217
+ }>;
218
+ vault: import("@endo/exo").Guarded<{
219
+ getPublicTopics(): {
220
+ vault: {
221
+ description: string;
222
+ subscriber: globalThis.Subscriber<VaultNotification>;
223
+ storagePath: Promise<string>;
224
+ };
225
+ };
226
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
227
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
228
+ makeTransferInvitation(): Promise<Invitation<any, undefined>>;
229
+ getCollateralAmount(): import("@agoric/ertp/src/types.js").NatAmount;
230
+ getCurrentDebt(): import("@agoric/ertp/src/types.js").NatAmount;
231
+ getNormalizedDebt(): NormalizedDebt;
232
+ }>;
233
+ vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
234
+ }>;
235
+ /** Called by manager at start of liquidation. */
236
+ liquidating(): void;
237
+ /**
238
+ * Called by manager at end of liquidation, at which point all debts
239
+ * have been covered.
240
+ */
241
+ liquidated(): void;
242
+ /**
243
+ * Called by vaultManager when the auction wasn't able to sell the
244
+ * collateral. The liquidation fee was charged against the collateral,
245
+ * but the debt will be restored and the vault will be active again.
246
+ * Liquidation.md has details on the liquidation approach.
247
+ */
248
+ abortLiquidation(): string;
249
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
250
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
251
+ /** @returns {Promise<Invitation<VaultKit>>} */
252
+ makeTransferInvitation(): Promise<Invitation<VaultKit>>;
253
+ /** @returns {Amount<'nat'>} */
254
+ getCollateralAmount(): Amount<"nat">;
255
+ /**
256
+ * The actual current debt, including accrued interest.
257
+ *
258
+ * This looks like a simple getter but it does a lot of the heavy
259
+ * lifting for interest accrual. Rather than updating all records when
260
+ * interest accrues, the vault manager updates just its rolling
261
+ * compounded interest. Here we calculate what the current debt is given
262
+ * what's recorded in this vault and what interest has compounded since
263
+ * this vault record was written.
264
+ *
265
+ * @returns {Amount<'nat'>}
266
+ * @see getNormalizedDebt
267
+ */
268
+ getCurrentDebt(): Amount<"nat">;
269
+ /**
270
+ * The normalization puts all debts on a common time-independent scale
271
+ * since the launch of this vault manager. This allows the manager to
272
+ * order vaults by their debt-to-collateral ratios without having to
273
+ * mutate the debts as the interest accrues.
274
+ *
275
+ * @returns {import('./storeUtils.js').NormalizedDebt} as if the vault
276
+ * was open at the launch of this manager, before any interest
277
+ * accrued
278
+ * @see getActualDebAmount
279
+ */
280
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
281
+ };
282
+ }>;
283
+ export type VaultPhase = "closed" | "active" | "liquidated" | "liquidating";
284
+ export type HolderPhase = "closed" | "transfer" | "active" | "liquidated" | "liquidating";
285
+ export type VaultNotification = {
286
+ /**
287
+ * Amount of Collateral locked
288
+ */
289
+ locked: Amount<"nat">;
290
+ /**
291
+ * 'debt' at
292
+ * the point the compounded interest was 'interest'
293
+ */
294
+ debtSnapshot: {
295
+ debt: Amount<"nat">;
296
+ interest: Ratio;
297
+ };
298
+ vaultState: HolderPhase;
299
+ };
300
+ export type VaultManager = {
301
+ getAssetSubscriber: () => Subscriber<import("./vaultManager.js").AssetState>;
302
+ maxDebtFor: (collateralAmount: Amount) => Amount<"nat">;
303
+ getCollateralBrand: () => Brand<"nat">;
304
+ scopeDescription: (base: string) => string;
305
+ getDebtBrand: () => Brand<"nat">;
306
+ mintAndTransfer: MintAndTransfer;
307
+ burn: (amount: Amount, seat: ZCFSeat) => void;
308
+ getCompoundedInterest: () => Ratio;
309
+ handleBalanceChange: (oldDebt: import("./storeUtils.js").NormalizedDebt, oldCollateral: Amount<"nat">, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void;
310
+ getGovernedParams: () => import("./vaultManager.js").GovernedParamGetters;
311
+ };
312
+ export type ImmutableState = Readonly<{
313
+ idInManager: VaultId;
314
+ manager: VaultManager;
315
+ storageNode: StorageNode;
316
+ vaultSeat: ZCFSeat;
317
+ }>;
318
+ /**
319
+ * Snapshot is of the debt and compounded interest when the principal was last
320
+ * changed.
321
+ */
322
+ export type MutableState = {
323
+ interestSnapshot: Ratio;
324
+ phase: VaultPhase;
325
+ debtSnapshot: Amount<"nat">;
326
+ outerUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification> | null;
327
+ };
328
+ export type Vault = ReturnType<ReturnType<typeof prepareVault>>["self"];
329
+ import type { Brand } from '@agoric/ertp/src/types.js';
330
+ import type { NormalizedDebt } from './storeUtils.js';
331
+ import { calculateDebtCosts } from './math.js';
332
+ //# sourceMappingURL=vault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["vault.js"],"names":[],"mappings":";;;;;;;AA2EA;;;;;;;;GAQG;AAGH;;;;;;;;;;;;;;;;;;GA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