@agoric/inter-protocol 0.16.2-other-dev-1f26562.0 → 0.16.2-other-dev-3eb1a1d.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 (191) hide show
  1. package/README.md +6 -6
  2. package/package.json +42 -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 +156 -150
  7. package/src/auction/auctionMath.d.ts +17 -0
  8. package/src/auction/auctionMath.d.ts.map +1 -0
  9. package/src/auction/auctionMath.js +81 -0
  10. package/src/auction/auctioneer.d.ts +69 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +70 -59
  13. package/src/auction/offerBook.d.ts +45 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +13 -12
  16. package/src/auction/params.d.ts +144 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +10 -9
  19. package/src/auction/scheduleMath.d.ts +5 -0
  20. package/src/auction/scheduleMath.d.ts.map +1 -0
  21. package/src/auction/scheduleMath.js +18 -16
  22. package/src/auction/scheduler.d.ts +50 -0
  23. package/src/auction/scheduler.d.ts.map +1 -0
  24. package/src/auction/scheduler.js +53 -47
  25. package/src/auction/sortedOffers.d.ts +8 -0
  26. package/src/auction/sortedOffers.d.ts.map +1 -0
  27. package/src/auction/sortedOffers.js +10 -9
  28. package/src/auction/util.d.ts +30 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +9 -6
  31. package/src/clientSupport.d.ts +167 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +155 -97
  34. package/src/collectFees.d.ts +2 -0
  35. package/src/collectFees.d.ts.map +1 -0
  36. package/src/contractSupport.d.ts +28 -0
  37. package/src/contractSupport.d.ts.map +1 -0
  38. package/src/contractSupport.js +19 -13
  39. package/src/econCommitteeCharter.d.ts +40 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +21 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +37 -33
  45. package/src/index.d.ts +2 -0
  46. package/src/index.d.ts.map +1 -0
  47. package/src/index.js +1 -0
  48. package/src/interest-math.d.ts +3 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest.d.ts +28 -0
  51. package/src/interest.d.ts.map +1 -0
  52. package/src/interest.js +23 -18
  53. package/src/price/README.md +13 -0
  54. package/src/price/fluxAggregatorContract.d.ts +71 -0
  55. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  56. package/src/price/fluxAggregatorContract.js +64 -55
  57. package/src/price/fluxAggregatorKit.d.ts +103 -0
  58. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  59. package/src/price/fluxAggregatorKit.js +52 -40
  60. package/src/price/priceOracleKit.d.ts +38 -0
  61. package/src/price/priceOracleKit.d.ts.map +1 -0
  62. package/src/price/priceOracleKit.js +12 -14
  63. package/src/price/roundsManager.d.ts +204 -0
  64. package/src/price/roundsManager.d.ts.map +1 -0
  65. package/src/price/roundsManager.js +131 -85
  66. package/src/proposals/README.md +2 -3
  67. package/src/proposals/add-auction.d.ts +109 -0
  68. package/src/proposals/add-auction.d.ts.map +1 -0
  69. package/src/proposals/add-auction.js +256 -0
  70. package/src/proposals/addAssetToVault.d.ts +173 -0
  71. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  72. package/src/proposals/addAssetToVault.js +192 -40
  73. package/src/proposals/committee-proposal.d.ts +113 -0
  74. package/src/proposals/committee-proposal.d.ts.map +1 -0
  75. package/src/proposals/committee-proposal.js +25 -31
  76. package/src/proposals/core-proposal.d.ts +149 -0
  77. package/src/proposals/core-proposal.d.ts.map +1 -0
  78. package/src/proposals/core-proposal.js +9 -11
  79. package/src/proposals/deploy-price-feeds.d.ts +76 -0
  80. package/src/proposals/deploy-price-feeds.d.ts.map +1 -0
  81. package/src/proposals/deploy-price-feeds.js +316 -0
  82. package/src/proposals/econ-behaviors.d.ts +541 -0
  83. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  84. package/src/proposals/econ-behaviors.js +64 -45
  85. package/src/proposals/price-feed-proposal.d.ts +84 -0
  86. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  87. package/src/proposals/price-feed-proposal.js +109 -51
  88. package/src/proposals/replace-fee-distributor.d.ts +48 -0
  89. package/src/proposals/replace-fee-distributor.d.ts.map +1 -0
  90. package/src/proposals/replace-fee-distributor.js +195 -0
  91. package/src/proposals/replace-scaledPriceAuthorities.d.ts +30 -0
  92. package/src/proposals/replace-scaledPriceAuthorities.d.ts.map +1 -0
  93. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  94. package/src/proposals/replaceElectorate.d.ts +55 -0
  95. package/src/proposals/replaceElectorate.d.ts.map +1 -0
  96. package/src/proposals/replaceElectorate.js +521 -0
  97. package/src/proposals/startEconCommittee.d.ts +34 -0
  98. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  99. package/src/proposals/startEconCommittee.js +2 -2
  100. package/src/proposals/startPSM.d.ts +59 -0
  101. package/src/proposals/startPSM.d.ts.map +1 -0
  102. package/src/proposals/startPSM.js +44 -29
  103. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  104. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  105. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  106. package/src/proposals/upgrade-vaults.d.ts +41 -0
  107. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  108. package/src/proposals/upgrade-vaults.js +202 -0
  109. package/src/proposals/utils.d.ts +19 -0
  110. package/src/proposals/utils.d.ts.map +1 -0
  111. package/src/proposals/utils.js +43 -9
  112. package/src/provisionPool.d.ts +163 -0
  113. package/src/provisionPool.d.ts.map +1 -0
  114. package/src/provisionPool.js +122 -0
  115. package/src/provisionPoolKit.d.ts +359 -0
  116. package/src/provisionPoolKit.d.ts.map +1 -0
  117. package/src/provisionPoolKit.js +522 -0
  118. package/src/psm/psm.d.ts +125 -0
  119. package/src/psm/psm.d.ts.map +1 -0
  120. package/src/psm/psm.js +80 -79
  121. package/src/psm/types-ambient.d.ts +2 -0
  122. package/src/psm/types-ambient.d.ts.map +1 -0
  123. package/src/psm/types-ambient.js +3 -0
  124. package/src/reserve/assetReserve.d.ts +47 -0
  125. package/src/reserve/assetReserve.d.ts.map +1 -0
  126. package/src/reserve/assetReserve.js +28 -19
  127. package/src/reserve/assetReserveKit.d.ts +74 -0
  128. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  129. package/src/reserve/assetReserveKit.js +24 -30
  130. package/src/reserve/params.d.ts +10 -0
  131. package/src/reserve/params.d.ts.map +1 -0
  132. package/src/tokens.d.ts +3 -0
  133. package/src/tokens.d.ts.map +1 -0
  134. package/src/tokens.js +5 -0
  135. package/src/vaultFactory/burn.d.ts +2 -0
  136. package/src/vaultFactory/burn.d.ts.map +1 -0
  137. package/src/vaultFactory/burn.js +1 -1
  138. package/src/vaultFactory/liquidation.d.ts +23 -0
  139. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  140. package/src/vaultFactory/liquidation.js +37 -24
  141. package/src/vaultFactory/math.d.ts +11 -0
  142. package/src/vaultFactory/math.d.ts.map +1 -0
  143. package/src/vaultFactory/math.js +10 -9
  144. package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
  145. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  146. package/src/vaultFactory/orderedVaultStore.js +8 -11
  147. package/src/vaultFactory/params.d.ts +140 -0
  148. package/src/vaultFactory/params.d.ts.map +1 -0
  149. package/src/vaultFactory/params.js +52 -24
  150. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  151. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  152. package/src/vaultFactory/prioritizedVaults.js +4 -4
  153. package/src/vaultFactory/proceeds.d.ts +35 -0
  154. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  155. package/src/vaultFactory/proceeds.js +26 -18
  156. package/src/vaultFactory/storeUtils.d.ts +25 -0
  157. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  158. package/src/vaultFactory/storeUtils.js +10 -12
  159. package/src/vaultFactory/types-ambient.d.ts +137 -0
  160. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  161. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  162. package/src/vaultFactory/vault.d.ts +343 -0
  163. package/src/vaultFactory/vault.d.ts.map +1 -0
  164. package/src/vaultFactory/vault.js +105 -99
  165. package/src/vaultFactory/vaultDirector.d.ts +341 -0
  166. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  167. package/src/vaultFactory/vaultDirector.js +86 -64
  168. package/src/vaultFactory/vaultFactory.d.ts +202 -0
  169. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  170. package/src/vaultFactory/vaultFactory.js +52 -33
  171. package/src/vaultFactory/vaultHolder.d.ts +126 -0
  172. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  173. package/src/vaultFactory/vaultHolder.js +11 -16
  174. package/src/vaultFactory/vaultKit.d.ts +32 -0
  175. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  176. package/src/vaultFactory/vaultKit.js +5 -4
  177. package/src/vaultFactory/vaultManager.d.ts +674 -0
  178. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  179. package/src/vaultFactory/vaultManager.js +257 -158
  180. package/CHANGELOG.md +0 -1041
  181. package/exported.js +0 -2
  182. package/scripts/add-collateral-core.js +0 -112
  183. package/scripts/deploy-contracts.js +0 -100
  184. package/scripts/init-core.js +0 -198
  185. package/scripts/invite-committee-core.js +0 -42
  186. package/scripts/manual-price-feed.js +0 -117
  187. package/scripts/price-feed-core.js +0 -104
  188. package/scripts/start-local-chain.sh +0 -84
  189. package/src/psm/types.js +0 -3
  190. package/src/typeGuards.js +0 -13
  191. 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,343 @@
1
+ /**
2
+ * Constants for vault phase.
3
+ *
4
+ * - ACTIVE - vault is in use and can be changed
5
+ * - LIQUIDATING - vault is being liquidated by the vault manager, and cannot be
6
+ * changed by the user. If liquidation fails, vaults may remain in this state.
7
+ * An upgrade to the contract might be able to recover them.
8
+ * - TRANSFER - vault is able to be transferred (payments and debits frozen until
9
+ * it has a new owner)
10
+ * - CLOSED - vault was closed by the user and all assets have been paid out
11
+ * - LIQUIDATED - vault was closed by the manager, with remaining assets paid to
12
+ * owner
13
+ */
14
+ export type Phase = (typeof Phase)[keyof typeof Phase];
15
+ export namespace Phase {
16
+ let ACTIVE: "active";
17
+ let LIQUIDATING: "liquidating";
18
+ let CLOSED: "closed";
19
+ let LIQUIDATED: "liquidated";
20
+ let TRANSFER: "transfer";
21
+ }
22
+ /**
23
+ * @typedef {object} VaultNotification
24
+ * @property {Amount<'nat'>} locked Amount of Collateral locked
25
+ * @property {{ debt: Amount<'nat'>; interest: Ratio }} debtSnapshot 'debt' at
26
+ * the point the compounded interest was 'interest'
27
+ * @property {Phase} vaultState
28
+ */
29
+ /**
30
+ * @typedef {object} VaultManager
31
+ * @property {() => Subscriber<import('./vaultManager.js').AssetState>} getAssetSubscriber
32
+ * @property {(collateralAmount: Amount) => Amount<'nat'>} maxDebtFor
33
+ * @property {() => Brand<'nat'>} getCollateralBrand
34
+ * @property {(base: string) => string} scopeDescription
35
+ * @property {() => Brand<'nat'>} getDebtBrand
36
+ * @property {MintAndTransfer} mintAndTransfer
37
+ * @property {(amount: Amount, seat: ZCFSeat) => void} burn
38
+ * @property {() => Ratio} getCompoundedInterest
39
+ * @property {(
40
+ * oldDebt: import('./storeUtils.js').NormalizedDebt,
41
+ * oldCollateral: Amount<'nat'>,
42
+ * vaultId: VaultId,
43
+ * vaultPhase: VaultPhase,
44
+ * vault: Vault,
45
+ * ) => void} handleBalanceChange
46
+ * @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
47
+ */
48
+ /**
49
+ * @typedef {Readonly<{
50
+ * idInManager: VaultId;
51
+ * manager: VaultManager;
52
+ * storageNode: StorageNode;
53
+ * vaultSeat: ZCFSeat;
54
+ * }>} ImmutableState
55
+ */
56
+ /**
57
+ * Snapshot is of the debt and compounded interest when the principal was last
58
+ * changed.
59
+ *
60
+ * @typedef {{
61
+ * interestSnapshot: Ratio;
62
+ * phase: VaultPhase;
63
+ * debtSnapshot: Amount<'nat'>;
64
+ * outerUpdater:
65
+ * | import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification>
66
+ * | null;
67
+ * }} MutableState
68
+ */
69
+ export const VaultI: import("@endo/patterns").InterfaceGuard<{
70
+ getCollateralAmount: import("@endo/patterns").MethodGuard;
71
+ getCurrentDebt: import("@endo/patterns").MethodGuard;
72
+ getNormalizedDebt: import("@endo/patterns").MethodGuard;
73
+ getVaultSeat: import("@endo/patterns").MethodGuard;
74
+ initVaultKit: import("@endo/patterns").MethodGuard;
75
+ liquidated: import("@endo/patterns").MethodGuard;
76
+ liquidating: import("@endo/patterns").MethodGuard;
77
+ makeAdjustBalancesInvitation: import("@endo/patterns").MethodGuard;
78
+ makeCloseInvitation: import("@endo/patterns").MethodGuard;
79
+ makeTransferInvitation: import("@endo/patterns").MethodGuard;
80
+ abortLiquidation: import("@endo/patterns").MethodGuard;
81
+ }>;
82
+ 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<{
83
+ helper: {
84
+ collateralBrand(): Brand<"nat">;
85
+ debtBrand(): Brand<"nat">;
86
+ emptyCollateral(): import("@agoric/ertp").NatAmount;
87
+ emptyDebt(): import("@agoric/ertp").NatAmount;
88
+ /**
89
+ * @typedef {{
90
+ * give: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
91
+ * want: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
92
+ * }} FullProposal
93
+ */
94
+ /**
95
+ * @param {ProposalRecord} partial
96
+ * @returns {FullProposal}
97
+ */
98
+ fullProposal(partial: ProposalRecord): {
99
+ give: {
100
+ Collateral: Amount<"nat">;
101
+ Minted: Amount<"nat">;
102
+ };
103
+ want: {
104
+ Collateral: Amount<"nat">;
105
+ Minted: Amount<"nat">;
106
+ };
107
+ };
108
+ /** @param {VaultPhase} newPhase */
109
+ assignPhase(newPhase: VaultPhase): void;
110
+ assertActive(): void;
111
+ assertCloseable(): void;
112
+ /**
113
+ * Called whenever the debt is paid or created through a transaction,
114
+ * but not for interest accrual.
115
+ *
116
+ * @param {Amount<'nat'>} newDebt - principal and all accrued interest
117
+ */
118
+ updateDebtSnapshot(newDebt: Amount<"nat">): void;
119
+ /**
120
+ * Update the debt balance and propagate upwards to maintain aggregate
121
+ * debt and liquidation order.
122
+ *
123
+ * @param {NormalizedDebt} oldDebtNormalized - prior principal and all
124
+ * accrued interest, normalized to the launch of the vaultManager
125
+ * @param {Amount<'nat'>} oldCollateral - actual collateral
126
+ * @param {Amount<'nat'>} newDebtActual - actual principal and all
127
+ * accrued interest
128
+ */
129
+ updateDebtAccounting(oldDebtNormalized: NormalizedDebt, oldCollateral: Amount<"nat">, newDebtActual: Amount<"nat">): void;
130
+ /**
131
+ * @param {ZCFSeat} seat
132
+ * @returns {Amount<'nat'>}
133
+ */
134
+ getCollateralAllocated(seat: ZCFSeat): Amount<"nat">;
135
+ /**
136
+ * @param {ZCFSeat} seat
137
+ * @returns {Amount<'nat'>}
138
+ */
139
+ getMintedAllocated(seat: ZCFSeat): Amount<"nat">;
140
+ assertVaultHoldsNoMinted(): void;
141
+ /**
142
+ * @param {Amount<'nat'>} collateralAmount
143
+ * @param {Amount<'nat'>} proposedDebt
144
+ */
145
+ assertSufficientCollateral(collateralAmount: Amount<"nat">, proposedDebt: Amount<"nat">): void;
146
+ /** @param {Phase} newPhase */
147
+ getStateSnapshot(newPhase: Phase): {
148
+ debtSnapshot: {
149
+ debt: import("@agoric/ertp").NatAmount;
150
+ interest: Ratio;
151
+ };
152
+ locked: import("@agoric/ertp").NatAmount;
153
+ vaultState: Phase;
154
+ };
155
+ /** call this whenever anything changes! */
156
+ updateUiState(): void;
157
+ /** @param {ZCFSeat} seat */
158
+ closeHook(seat: ZCFSeat): Promise<string>;
159
+ /**
160
+ * Calculate the fee, the amount to mint and the resulting debt. The
161
+ * give and the want together reflect a delta, where typically one is
162
+ * zero because they come from the gave/want of an offer proposal. If
163
+ * the `want` is zero, the `fee` will also be zero, so the simple math
164
+ * works.
165
+ *
166
+ * @param {Amount<'nat'>} currentDebt
167
+ * @param {Amount<'nat'>} giveAmount
168
+ * @param {Amount<'nat'>} wantAmount
169
+ */
170
+ debtFee(currentDebt: Amount<"nat">, giveAmount: Amount<"nat">, wantAmount: Amount<"nat">): {
171
+ newDebt: import("@agoric/ertp").NatAmount;
172
+ toMint: import("@agoric/ertp").NatAmount;
173
+ fee: import("@agoric/ertp").NatAmount;
174
+ surplus: import("@agoric/ertp").NatAmount;
175
+ };
176
+ /**
177
+ * Adjust principal and collateral (atomically for offer safety)
178
+ *
179
+ * @param {ZCFSeat} clientSeat
180
+ * @returns {string} success message
181
+ */
182
+ adjustBalancesHook(clientSeat: ZCFSeat): string;
183
+ /**
184
+ * @param {ZCFSeat} clientSeat
185
+ * @param {FullProposal} fp
186
+ * @param {ReturnType<typeof calculateDebtCosts>} costs
187
+ * @param {object} accounting
188
+ * @param {NormalizedDebt} accounting.normalizedDebtPre
189
+ * @param {Amount<'nat'>} accounting.collateralPre
190
+ * @returns {string} success message
191
+ */
192
+ commitBalanceAdjustment(clientSeat: ZCFSeat, fp: {
193
+ give: {
194
+ Collateral: Amount<"nat">;
195
+ Minted: Amount<"nat">;
196
+ };
197
+ want: {
198
+ Collateral: Amount<"nat">;
199
+ Minted: Amount<"nat">;
200
+ };
201
+ }, { newDebt, fee, surplus, toMint }: ReturnType<typeof calculateDebtCosts>, { normalizedDebtPre, collateralPre }: {
202
+ normalizedDebtPre: NormalizedDebt;
203
+ collateralPre: Amount<"nat">;
204
+ }): string;
205
+ /**
206
+ * @param {ZCFSeat} seat
207
+ * @returns {VaultKit}
208
+ */
209
+ makeTransferInvitationHook(seat: ZCFSeat): VaultKit;
210
+ };
211
+ self: {
212
+ getVaultSeat(): ZCFSeat;
213
+ /**
214
+ * @param {ZCFSeat} seat
215
+ * @param {StorageNode} storageNode
216
+ */
217
+ initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
218
+ publicSubscribers: {
219
+ vault: {
220
+ description: string;
221
+ subscriber: globalThis.Subscriber<VaultNotification>;
222
+ storagePath: Promise<string>;
223
+ };
224
+ };
225
+ invitationMakers: import("@endo/exo").Guarded<{
226
+ AdjustBalances(): Promise<Invitation<string, undefined>>;
227
+ CloseVault(): Promise<Invitation<string, undefined>>;
228
+ TransferVault(): Promise<Invitation<any, undefined>>;
229
+ }>;
230
+ vault: import("@endo/exo").Guarded<{
231
+ getPublicTopics(): {
232
+ vault: {
233
+ description: string;
234
+ subscriber: globalThis.Subscriber<VaultNotification>;
235
+ storagePath: Promise<string>;
236
+ };
237
+ };
238
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
239
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
240
+ makeTransferInvitation(): Promise<Invitation<any, undefined>>;
241
+ getCollateralAmount(): import("@agoric/ertp").NatAmount;
242
+ getCurrentDebt(): import("@agoric/ertp").NatAmount;
243
+ getNormalizedDebt(): NormalizedDebt;
244
+ }>;
245
+ vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
246
+ }>;
247
+ /** Called by manager at start of liquidation. */
248
+ liquidating(): void;
249
+ /**
250
+ * Called by manager at end of liquidation, at which point all debts
251
+ * have been covered.
252
+ */
253
+ liquidated(): void;
254
+ /**
255
+ * Called by vaultManager when the auction wasn't able to sell the
256
+ * collateral. The liquidation fee was charged against the collateral,
257
+ * but the debt will be restored and the vault will be active again.
258
+ * Liquidation.md has details on the liquidation approach.
259
+ */
260
+ abortLiquidation(): string;
261
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
262
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
263
+ /** @returns {Promise<Invitation<VaultKit>>} */
264
+ makeTransferInvitation(): Promise<Invitation<VaultKit>>;
265
+ /** @returns {Amount<'nat'>} */
266
+ getCollateralAmount(): Amount<"nat">;
267
+ /**
268
+ * The actual current debt, including accrued interest.
269
+ *
270
+ * This looks like a simple getter but it does a lot of the heavy
271
+ * lifting for interest accrual. Rather than updating all records when
272
+ * interest accrues, the vault manager updates just its rolling
273
+ * compounded interest. Here we calculate what the current debt is given
274
+ * what's recorded in this vault and what interest has compounded since
275
+ * this vault record was written.
276
+ *
277
+ * @returns {Amount<'nat'>}
278
+ * @see getNormalizedDebt
279
+ */
280
+ getCurrentDebt(): Amount<"nat">;
281
+ /**
282
+ * The normalization puts all debts on a common time-independent scale
283
+ * since the launch of this vault manager. This allows the manager to
284
+ * order vaults by their debt-to-collateral ratios without having to
285
+ * mutate the debts as the interest accrues.
286
+ *
287
+ * @returns {import('./storeUtils.js').NormalizedDebt} as if the vault
288
+ * was open at the launch of this manager, before any interest
289
+ * accrued
290
+ * @see getActualDebAmount
291
+ */
292
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
293
+ };
294
+ }>;
295
+ export type VaultPhase = Exclude<Phase, "transfer">;
296
+ export type VaultNotification = {
297
+ /**
298
+ * Amount of Collateral locked
299
+ */
300
+ locked: Amount<"nat">;
301
+ /**
302
+ * 'debt' at
303
+ * the point the compounded interest was 'interest'
304
+ */
305
+ debtSnapshot: {
306
+ debt: Amount<"nat">;
307
+ interest: Ratio;
308
+ };
309
+ vaultState: Phase;
310
+ };
311
+ export type VaultManager = {
312
+ getAssetSubscriber: () => Subscriber<import("./vaultManager.js").AssetState>;
313
+ maxDebtFor: (collateralAmount: Amount) => Amount<"nat">;
314
+ getCollateralBrand: () => Brand<"nat">;
315
+ scopeDescription: (base: string) => string;
316
+ getDebtBrand: () => Brand<"nat">;
317
+ mintAndTransfer: MintAndTransfer;
318
+ burn: (amount: Amount, seat: ZCFSeat) => void;
319
+ getCompoundedInterest: () => Ratio;
320
+ handleBalanceChange: (oldDebt: import("./storeUtils.js").NormalizedDebt, oldCollateral: Amount<"nat">, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void;
321
+ getGovernedParams: () => import("./vaultManager.js").GovernedParamGetters;
322
+ };
323
+ export type ImmutableState = Readonly<{
324
+ idInManager: VaultId;
325
+ manager: VaultManager;
326
+ storageNode: StorageNode;
327
+ vaultSeat: ZCFSeat;
328
+ }>;
329
+ /**
330
+ * Snapshot is of the debt and compounded interest when the principal was last
331
+ * changed.
332
+ */
333
+ export type MutableState = {
334
+ interestSnapshot: Ratio;
335
+ phase: VaultPhase;
336
+ debtSnapshot: Amount<"nat">;
337
+ outerUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification> | null;
338
+ };
339
+ export type Vault = ReturnType<ReturnType<typeof prepareVault>>["self"];
340
+ import type { Brand } from '@agoric/ertp/src/types.js';
341
+ import type { NormalizedDebt } from './storeUtils.js';
342
+ import { calculateDebtCosts } from './math.js';
343
+ //# sourceMappingURL=v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