@agoric/inter-protocol 0.16.2-dev-7cc5def.0 → 0.16.2-u11.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 (176) hide show
  1. package/CHANGELOG.md +1041 -0
  2. package/bundles/bundle-auctioneer-js-meta.json +722 -0
  3. package/bundles/bundle-auctioneer.js +1 -0
  4. package/bundles/bundle-econCommitteeCharter-js-meta.json +222 -242
  5. package/bundles/bundle-econCommitteeCharter.js +1 -1
  6. package/bundles/bundle-feeDistributor-js-meta.json +458 -0
  7. package/bundles/bundle-feeDistributor.js +1 -0
  8. package/bundles/bundle-fluxAggregatorKit-js-meta.json +327 -343
  9. package/bundles/bundle-fluxAggregatorKit.js +1 -1
  10. package/bundles/bundle-psm-js-meta.json +308 -328
  11. package/bundles/bundle-psm.js +1 -1
  12. package/bundles/bundle-reserve-js-meta.json +662 -0
  13. package/bundles/bundle-reserve.js +1 -0
  14. package/bundles/bundle-scaledPriceAuthority-js-meta.json +542 -0
  15. package/bundles/bundle-scaledPriceAuthority.js +1 -0
  16. package/bundles/bundle-vaultFactory-js-meta.json +790 -0
  17. package/bundles/bundle-vaultFactory.js +1 -0
  18. package/package.json +31 -31
  19. package/scripts/add-collateral-core.js +112 -0
  20. package/scripts/build-bundles.js +21 -5
  21. package/scripts/deploy-contracts.js +100 -0
  22. package/scripts/init-core.js +198 -0
  23. package/scripts/invite-committee-core.js +42 -0
  24. package/scripts/manual-price-feed.js +117 -0
  25. package/scripts/price-feed-core.js +104 -0
  26. package/scripts/start-local-chain.sh +84 -0
  27. package/src/auction/auctionBook.js +56 -68
  28. package/src/auction/auctioneer.js +44 -56
  29. package/src/auction/offerBook.js +11 -12
  30. package/src/auction/params.js +5 -3
  31. package/src/auction/scheduleMath.js +13 -13
  32. package/src/auction/scheduler.js +32 -22
  33. package/src/auction/sortedOffers.js +7 -8
  34. package/src/auction/util.js +4 -4
  35. package/src/clientSupport.js +96 -152
  36. package/src/contractSupport.js +5 -5
  37. package/src/econCommitteeCharter.js +15 -16
  38. package/src/feeDistributor.js +33 -34
  39. package/src/interest.js +14 -20
  40. package/src/price/fluxAggregatorContract.js +45 -51
  41. package/src/price/fluxAggregatorKit.js +32 -47
  42. package/src/price/priceOracleKit.js +13 -11
  43. package/src/price/roundsManager.js +64 -52
  44. package/src/proposals/addAssetToVault.js +3 -15
  45. package/src/proposals/committee-proposal.js +9 -5
  46. package/src/proposals/core-proposal.js +7 -7
  47. package/src/proposals/econ-behaviors.js +32 -57
  48. package/src/proposals/price-feed-proposal.js +26 -59
  49. package/src/proposals/startEconCommittee.js +1 -1
  50. package/src/proposals/startPSM.js +22 -32
  51. package/src/proposals/utils.js +7 -26
  52. package/src/psm/psm.js +63 -69
  53. package/src/reserve/assetReserve.js +18 -27
  54. package/src/reserve/assetReserveKit.js +22 -14
  55. package/src/typeGuards.js +13 -0
  56. package/src/vaultFactory/liquidation.js +17 -30
  57. package/src/vaultFactory/math.js +9 -8
  58. package/src/vaultFactory/orderedVaultStore.js +9 -6
  59. package/src/vaultFactory/params.js +18 -24
  60. package/src/vaultFactory/prioritizedVaults.js +2 -2
  61. package/src/vaultFactory/proceeds.js +18 -24
  62. package/src/vaultFactory/storeUtils.js +12 -8
  63. package/src/vaultFactory/types.js +28 -38
  64. package/src/vaultFactory/vault.js +89 -88
  65. package/src/vaultFactory/vaultDirector.js +41 -33
  66. package/src/vaultFactory/vaultFactory.js +26 -33
  67. package/src/vaultFactory/vaultHolder.js +13 -8
  68. package/src/vaultFactory/vaultKit.js +2 -3
  69. package/src/vaultFactory/vaultManager.js +120 -138
  70. package/src/auction/auctionBook.d.ts +0 -83
  71. package/src/auction/auctionBook.d.ts.map +0 -1
  72. package/src/auction/auctioneer.d.ts +0 -75
  73. package/src/auction/auctioneer.d.ts.map +0 -1
  74. package/src/auction/offerBook.d.ts +0 -72
  75. package/src/auction/offerBook.d.ts.map +0 -1
  76. package/src/auction/params.d.ts +0 -142
  77. package/src/auction/params.d.ts.map +0 -1
  78. package/src/auction/scheduleMath.d.ts +0 -4
  79. package/src/auction/scheduleMath.d.ts.map +0 -1
  80. package/src/auction/scheduler.d.ts +0 -49
  81. package/src/auction/scheduler.d.ts.map +0 -1
  82. package/src/auction/sortedOffers.d.ts +0 -8
  83. package/src/auction/sortedOffers.d.ts.map +0 -1
  84. package/src/auction/util.d.ts +0 -30
  85. package/src/auction/util.d.ts.map +0 -1
  86. package/src/clientSupport.d.ts +0 -167
  87. package/src/clientSupport.d.ts.map +0 -1
  88. package/src/collectFees.d.ts +0 -2
  89. package/src/collectFees.d.ts.map +0 -1
  90. package/src/contractSupport.d.ts +0 -33
  91. package/src/contractSupport.d.ts.map +0 -1
  92. package/src/econCommitteeCharter.d.ts +0 -41
  93. package/src/econCommitteeCharter.d.ts.map +0 -1
  94. package/src/feeDistributor.d.ts +0 -212
  95. package/src/feeDistributor.d.ts.map +0 -1
  96. package/src/index.d.ts +0 -2
  97. package/src/index.d.ts.map +0 -1
  98. package/src/interest-math.d.ts +0 -3
  99. package/src/interest-math.d.ts.map +0 -1
  100. package/src/interest.d.ts +0 -29
  101. package/src/interest.d.ts.map +0 -1
  102. package/src/price/fluxAggregatorContract.d.ts +0 -112
  103. package/src/price/fluxAggregatorContract.d.ts.map +0 -1
  104. package/src/price/fluxAggregatorKit.d.ts +0 -155
  105. package/src/price/fluxAggregatorKit.d.ts.map +0 -1
  106. package/src/price/priceOracleKit.d.ts +0 -52
  107. package/src/price/priceOracleKit.d.ts.map +0 -1
  108. package/src/price/roundsManager.d.ts +0 -330
  109. package/src/price/roundsManager.d.ts.map +0 -1
  110. package/src/proposals/addAssetToVault.d.ts +0 -155
  111. package/src/proposals/addAssetToVault.d.ts.map +0 -1
  112. package/src/proposals/committee-proposal.d.ts +0 -121
  113. package/src/proposals/committee-proposal.d.ts.map +0 -1
  114. package/src/proposals/core-proposal.d.ts +0 -149
  115. package/src/proposals/core-proposal.d.ts.map +0 -1
  116. package/src/proposals/econ-behaviors.d.ts +0 -201
  117. package/src/proposals/econ-behaviors.d.ts.map +0 -1
  118. package/src/proposals/price-feed-proposal.d.ts +0 -83
  119. package/src/proposals/price-feed-proposal.d.ts.map +0 -1
  120. package/src/proposals/startEconCommittee.d.ts +0 -34
  121. package/src/proposals/startEconCommittee.d.ts.map +0 -1
  122. package/src/proposals/startPSM.d.ts +0 -61
  123. package/src/proposals/startPSM.d.ts.map +0 -1
  124. package/src/proposals/utils.d.ts +0 -15
  125. package/src/proposals/utils.d.ts.map +0 -1
  126. package/src/provisionPool.d.ts +0 -165
  127. package/src/provisionPool.d.ts.map +0 -1
  128. package/src/provisionPool.js +0 -119
  129. package/src/provisionPoolKit.d.ts +0 -379
  130. package/src/provisionPoolKit.d.ts.map +0 -1
  131. package/src/provisionPoolKit.js +0 -461
  132. package/src/psm/psm.d.ts +0 -178
  133. package/src/psm/psm.d.ts.map +0 -1
  134. package/src/psm/types.d.ts +0 -2
  135. package/src/psm/types.d.ts.map +0 -1
  136. package/src/reserve/assetReserve.d.ts +0 -44
  137. package/src/reserve/assetReserve.d.ts.map +0 -1
  138. package/src/reserve/assetReserveKit.d.ts +0 -114
  139. package/src/reserve/assetReserveKit.d.ts.map +0 -1
  140. package/src/reserve/params.d.ts +0 -10
  141. package/src/reserve/params.d.ts.map +0 -1
  142. package/src/tokens.d.ts +0 -3
  143. package/src/tokens.d.ts.map +0 -1
  144. package/src/tokens.js +0 -5
  145. package/src/vaultFactory/burn.d.ts +0 -2
  146. package/src/vaultFactory/burn.d.ts.map +0 -1
  147. package/src/vaultFactory/liquidation.d.ts +0 -24
  148. package/src/vaultFactory/liquidation.d.ts.map +0 -1
  149. package/src/vaultFactory/math.d.ts +0 -10
  150. package/src/vaultFactory/math.d.ts.map +0 -1
  151. package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
  152. package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
  153. package/src/vaultFactory/params.d.ts +0 -159
  154. package/src/vaultFactory/params.d.ts.map +0 -1
  155. package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
  156. package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
  157. package/src/vaultFactory/proceeds.d.ts +0 -34
  158. package/src/vaultFactory/proceeds.d.ts.map +0 -1
  159. package/src/vaultFactory/storeUtils.d.ts +0 -25
  160. package/src/vaultFactory/storeUtils.d.ts.map +0 -1
  161. package/src/vaultFactory/type-imports.d.ts +0 -2
  162. package/src/vaultFactory/type-imports.d.ts.map +0 -1
  163. package/src/vaultFactory/types.d.ts +0 -137
  164. package/src/vaultFactory/types.d.ts.map +0 -1
  165. package/src/vaultFactory/vault.d.ts +0 -529
  166. package/src/vaultFactory/vault.d.ts.map +0 -1
  167. package/src/vaultFactory/vaultDirector.d.ts +0 -560
  168. package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
  169. package/src/vaultFactory/vaultFactory.d.ts +0 -162
  170. package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
  171. package/src/vaultFactory/vaultHolder.d.ts +0 -201
  172. package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
  173. package/src/vaultFactory/vaultKit.d.ts +0 -32
  174. package/src/vaultFactory/vaultKit.d.ts.map +0 -1
  175. package/src/vaultFactory/vaultManager.d.ts +0 -554
  176. package/src/vaultFactory/vaultManager.d.ts.map +0 -1
@@ -2,20 +2,18 @@
2
2
  /**
3
3
  * @file Vault Manager object manages vault-based debts for a collateral type.
4
4
  *
5
- * The responsibilities include:
5
+ * The responsibilities include:
6
+ * - opening a new vault backed by the collateral
7
+ * - publishing metrics on the vault economy for that collateral
8
+ * - charging interest on all active vaults
9
+ * - liquidating active vaults that have exceeded the debt ratio
6
10
  *
7
- * - opening a new vault backed by the collateral
8
- * - publishing metrics on the vault economy for that collateral
9
- * - charging interest on all active vaults
10
- * - liquidating active vaults that have exceeded the debt ratio
11
+ * Once a vault is settled (liquidated or closed) it can still be used, traded,
12
+ * etc. but is no longer the concern of the manager. It can't be liquidated,
13
+ * have interest charged, or be counted in the metrics.
11
14
  *
12
- * Once a vault is settled (liquidated or closed) it can still be used, traded,
13
- * etc. but is no longer the concern of the manager. It can't be liquidated,
14
- * have interest charged, or be counted in the metrics.
15
- *
16
- * Undercollateralized vaults can have their assets sent to the auctioneer to be
17
- * liquidated. If the auction is unsuccessful, the liquidation may be
18
- * reverted.
15
+ * Undercollateralized vaults can have their assets sent to the auctioneer to be
16
+ * liquidated. If the auction is unsuccessful, the liquidation may be reverted.
19
17
  */
20
18
  import '@agoric/zoe/exported.js';
21
19
 
@@ -75,102 +73,93 @@ const trace = makeTracer('VM');
75
73
  // Metrics naming scheme: nouns are present values; past-participles are accumulative.
76
74
  /**
77
75
  * @typedef {object} MetricsNotification
78
- * @property {Ratio | null} lockedQuote priceQuote that will be used for
79
- * liquidation. Non-null from priceLock time until liquidation has taken
80
- * place.
81
- * @property {number} numActiveVaults present count of vaults
82
- * @property {number} numLiquidatingVaults present count of liquidating vaults
83
- * @property {Amount<'nat'>} totalCollateral present sum of collateral across
84
- * all vaults
85
- * @property {Amount<'nat'>} totalDebt present sum of debt across all vaults
86
- * @property {Amount<'nat'>} retainedCollateral collateral held as a result of
87
- * not returning excess refunds to owners of vaults liquidated with
88
- * shortfalls
89
- * @property {Amount<'nat'>} liquidatingCollateral present sum of collateral in
90
- * vaults sent for liquidation
91
- * @property {Amount<'nat'>} liquidatingDebt present sum of debt in vaults sent
92
- * for liquidation
93
- * @property {Amount<'nat'>} totalCollateralSold running sum of collateral sold
94
- * in liquidation
95
- * @property {Amount<'nat'>} totalOverageReceived running sum of overages,
96
- * central received greater than debt
97
- * @property {Amount<'nat'>} totalProceedsReceived running sum of minted
98
- * received from liquidation
99
- * @property {Amount<'nat'>} totalShortfallReceived running sum of shortfalls,
100
- * minted received less than debt
101
- * @property {number} numLiquidationsCompleted running count of liquidated
102
- * vaults
103
- * @property {number} numLiquidationsAborted running count of vault liquidations
104
- * that were reverted.
76
+ *
77
+ * @property {Ratio | null} lockedQuote priceQuote that will be used for liquidation.
78
+ * Non-null from priceLock time until liquidation has taken place.
79
+ * @property {number} numActiveVaults present count of vaults
80
+ * @property {number} numLiquidatingVaults present count of liquidating vaults
81
+ * @property {Amount<'nat'>} totalCollateral present sum of collateral across all vaults
82
+ * @property {Amount<'nat'>} totalDebt present sum of debt across all vaults
83
+ * @property {Amount<'nat'>} retainedCollateral collateral held as a result of not returning excess refunds
84
+ * to owners of vaults liquidated with shortfalls
85
+ * @property {Amount<'nat'>} liquidatingCollateral present sum of collateral in vaults sent for liquidation
86
+ * @property {Amount<'nat'>} liquidatingDebt present sum of debt in vaults sent for liquidation
87
+ *
88
+ * @property {Amount<'nat'>} totalCollateralSold running sum of collateral sold in liquidation
89
+ * @property {Amount<'nat'>} totalOverageReceived running sum of overages, central received greater than debt
90
+ * @property {Amount<'nat'>} totalProceedsReceived running sum of minted received from liquidation
91
+ * @property {Amount<'nat'>} totalShortfallReceived running sum of shortfalls, minted received less than debt
92
+ * @property {number} numLiquidationsCompleted running count of liquidated vaults
93
+ * @property {number} numLiquidationsAborted running count of vault liquidations that were reverted.
105
94
  */
106
95
 
107
96
  /**
108
97
  * @typedef {{
109
- * compoundedInterest: Ratio;
110
- * interestRate: Ratio;
111
- * latestInterestUpdate: Timestamp;
98
+ * compoundedInterest: Ratio,
99
+ * interestRate: Ratio,
100
+ * latestInterestUpdate: Timestamp,
112
101
  * }} AssetState
113
102
  *
114
103
  * @typedef {{
115
- * getChargingPeriod: () => RelativeTime;
116
- * getRecordingPeriod: () => RelativeTime;
117
- * getDebtLimit: () => Amount<'nat'>;
118
- * getInterestRate: () => Ratio;
119
- * getLiquidationPadding: () => Ratio;
120
- * getLiquidationMargin: () => Ratio;
121
- * getLiquidationPenalty: () => Ratio;
122
- * getMintFee: () => Ratio;
123
- * getMinInitialDebt: () => Amount<'nat'>;
104
+ * getChargingPeriod: () => RelativeTime,
105
+ * getRecordingPeriod: () => RelativeTime,
106
+ * getDebtLimit: () => Amount<'nat'>,
107
+ * getInterestRate: () => Ratio,
108
+ * getLiquidationPadding: () => Ratio,
109
+ * getLiquidationMargin: () => Ratio,
110
+ * getLiquidationPenalty: () => Ratio,
111
+ * getMintFee: () => Ratio,
112
+ * getMinInitialDebt: () => Amount<'nat'>,
124
113
  * }} GovernedParamGetters
125
114
  */
126
115
 
127
116
  /**
128
117
  * @typedef {Readonly<{
129
- * debtMint: ZCFMint<'nat'>;
130
- * collateralBrand: Brand<'nat'>;
131
- * collateralUnit: Amount<'nat'>;
132
- * descriptionScope: string;
133
- * startTimeStamp: Timestamp;
134
- * storageNode: StorageNode;
118
+ * debtMint: ZCFMint<'nat'>,
119
+ * collateralBrand: Brand<'nat'>,
120
+ * collateralUnit: Amount<'nat'>,
121
+ * descriptionScope: string,
122
+ * startTimeStamp: Timestamp,
123
+ * storageNode: StorageNode,
135
124
  * }>} HeldParams
136
125
  */
137
126
 
138
127
  /**
139
128
  * @typedef {{
140
- * assetTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<AssetState>;
141
- * debtBrand: Brand<'nat'>;
142
- * liquidatingVaults: SetStore<Vault>;
143
- * metricsTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<MetricsNotification>;
144
- * poolIncrementSeat: ZCFSeat;
145
- * retainedCollateralSeat: ZCFSeat;
146
- * unsettledVaults: MapStore<string, Vault>;
129
+ * assetTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<AssetState>,
130
+ * debtBrand: Brand<'nat'>,
131
+ * liquidatingVaults: SetStore<Vault>,
132
+ * metricsTopicKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<MetricsNotification>,
133
+ * poolIncrementSeat: ZCFSeat,
134
+ * retainedCollateralSeat: ZCFSeat,
135
+ * unsettledVaults: MapStore<string, Vault>,
147
136
  * }} ImmutableState
148
137
  */
149
138
 
150
139
  /**
151
140
  * @typedef {{
152
- * compoundedInterest: Ratio;
153
- * latestInterestUpdate: Timestamp;
154
- * numLiquidationsCompleted: number;
155
- * numLiquidationsAborted: number;
156
- * totalCollateral: Amount<'nat'>;
157
- * totalCollateralSold: Amount<'nat'>;
158
- * totalDebt: Amount<'nat'>;
159
- * liquidatingCollateral: Amount<'nat'>;
160
- * liquidatingDebt: Amount<'nat'>;
161
- * totalOverageReceived: Amount<'nat'>;
162
- * totalProceedsReceived: Amount<'nat'>;
163
- * totalShortfallReceived: Amount<'nat'>;
164
- * vaultCounter: number;
165
- * lockedQuote: PriceQuote | undefined;
141
+ * compoundedInterest: Ratio,
142
+ * latestInterestUpdate: Timestamp,
143
+ * numLiquidationsCompleted: number,
144
+ * numLiquidationsAborted: number,
145
+ * totalCollateral: Amount<'nat'>,
146
+ * totalCollateralSold: Amount<'nat'>,
147
+ * totalDebt: Amount<'nat'>,
148
+ * liquidatingCollateral: Amount<'nat'>,
149
+ * liquidatingDebt: Amount<'nat'>,
150
+ * totalOverageReceived: Amount<'nat'>,
151
+ * totalProceedsReceived: Amount<'nat'>,
152
+ * totalShortfallReceived: Amount<'nat'>,
153
+ * vaultCounter: number,
154
+ * lockedQuote: PriceQuote | undefined,
166
155
  * }} MutableState
167
156
  */
168
157
 
169
158
  /**
170
159
  * @type {(brand: Brand) => {
171
- * prioritizedVaults: ReturnType<typeof makePrioritizedVaults>;
172
- * storedQuotesNotifier: import('@agoric/notifier').StoredNotifier<PriceQuote>;
173
- * storedCollateralQuote: PriceQuote;
160
+ * prioritizedVaults: ReturnType<typeof makePrioritizedVaults>,
161
+ * storedQuotesNotifier: import('@agoric/notifier').StoredNotifier<PriceQuote>,
162
+ * storedCollateralQuote: PriceQuote,
174
163
  * }}
175
164
  */
176
165
  // any b/c will be filled after start()
@@ -179,11 +168,11 @@ const collateralEphemera = makeEphemeraProvider(() => /** @type {any} */ ({}));
179
168
  /**
180
169
  * @param {import('@agoric/ertp').Baggage} baggage
181
170
  * @param {{
182
- * zcf: import('./vaultFactory.js').VaultFactoryZCF;
183
- * marshaller: ERef<Marshaller>;
184
- * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
185
- * makeERecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeERecorderKit;
186
- * factoryPowers: import('./vaultDirector.js').FactoryPowersFacet;
171
+ * zcf: import('./vaultFactory.js').VaultFactoryZCF,
172
+ * marshaller: ERef<Marshaller>,
173
+ * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit,
174
+ * makeERecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeERecorderKit,
175
+ * factoryPowers: import('./vaultDirector.js').FactoryPowersFacet,
187
176
  * }} powers
188
177
  */
189
178
  export const prepareVaultManagerKit = (
@@ -214,9 +203,8 @@ export const prepareVaultManagerKit = (
214
203
  poolIncrementSeat: zcf.makeEmptySeatKit().zcfSeat,
215
204
 
216
205
  /**
217
- * Vaults that have been sent for liquidation. When we get proceeds (or
218
- * lack thereof) back from the liquidator, we will allocate them among the
219
- * vaults.
206
+ * Vaults that have been sent for liquidation. When we get proceeds (or lack
207
+ * thereof) back from the liquidator, we will allocate them among the vaults.
220
208
  *
221
209
  * @type {SetStore<Vault>}
222
210
  */
@@ -351,7 +339,9 @@ export const prepareVaultManagerKit = (
351
339
 
352
340
  // Some of these could go in closures but are kept on a facet anticipating future durability options.
353
341
  helper: {
354
- /** Start non-durable processes (or restart if needed after vat restart) */
342
+ /**
343
+ * Start non-durable processes (or restart if needed after vat restart)
344
+ */
355
345
  start() {
356
346
  const { state, facets } = this;
357
347
  trace(state.collateralBrand, 'helper.start()', state.vaultCounter);
@@ -410,7 +400,7 @@ export const prepareVaultManagerKit = (
410
400
  // throw. See https://github.com/Agoric/agoric-sdk/issues/4317
411
401
  void observeNotifier(quoteNotifier, {
412
402
  updateState(value) {
413
- trace('storing new quote', value.quoteAmount.value);
403
+ trace('vaultManager got new collateral quote', value);
414
404
  ephemera.storedCollateralQuote = value;
415
405
  },
416
406
  fail(reason) {
@@ -419,7 +409,9 @@ export const prepareVaultManagerKit = (
419
409
  });
420
410
  trace('helper.start() done');
421
411
  },
422
- /** @param {Timestamp} updateTime */
412
+ /**
413
+ * @param {Timestamp} updateTime
414
+ */
423
415
  async chargeAllVaults(updateTime) {
424
416
  const { state, facets } = this;
425
417
  const { collateralBrand, debtMint, poolIncrementSeat } = state;
@@ -523,6 +515,7 @@ export const prepareVaultManagerKit = (
523
515
  state.liquidatingDebt = AmountMath.add(state.liquidatingDebt, debt);
524
516
  },
525
517
  /**
518
+ *
526
519
  * @param {Amount<'nat'>} debt
527
520
  * @param {Amount<'nat'>} collateral
528
521
  * @param {Amount<'nat'>} overage
@@ -605,18 +598,14 @@ export const prepareVaultManagerKit = (
605
598
  },
606
599
 
607
600
  /**
608
- * This is designed to tolerate an incomplete plan, in case
609
- * calculateDistributionPlan encounters an error during its calculation.
610
- * We don't have a way to induce such errors in CI so we've done so
611
- * manually in dev and verified this function recovers as expected.
601
+ * This is designed to tolerate an incomplete plan, in case calculateDistributionPlan encounters
602
+ * an error during its calculation. We don't have a way to induce such errors in CI so we've
603
+ * done so manually in dev and verified this function recovers as expected.
612
604
  *
613
605
  * @param {AmountKeywordRecord} proceeds
614
606
  * @param {Amount<'nat'>} totalDebt
615
607
  * @param {Pick<PriceQuote, 'quoteAmount'>} oraclePriceAtStart
616
- * @param {MapStore<
617
- * Vault,
618
- * { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
619
- * >} vaultData
608
+ * @param {MapStore<Vault, { collateralAmount: Amount<'nat'>, debtAmount: Amount<'nat'>}>} vaultData
620
609
  * @param {Amount<'nat'>} totalCollateral
621
610
  */
622
611
  planProceedsDistribution(
@@ -672,14 +661,13 @@ export const prepareVaultManagerKit = (
672
661
  },
673
662
 
674
663
  /**
675
- * This is designed to tolerate an incomplete plan, in case
676
- * calculateDistributionPlan encounters an error during its calculation.
677
- * We don't have a way to induce such errors in CI so we've done so
678
- * manually in dev and verified this function recovers as expected.
664
+ * This is designed to tolerate an incomplete plan, in case calculateDistributionPlan encounters
665
+ * an error during its calculation. We don't have a way to induce such errors in CI so we've
666
+ * done so manually in dev and verified this function recovers as expected.
679
667
  *
680
668
  * @param {object} obj
681
669
  * @param {import('./proceeds.js').DistributionPlan} obj.plan
682
- * @param {Vault[]} obj.vaultsInPlan
670
+ * @param {Array<Vault>} obj.vaultsInPlan
683
671
  * @param {ZCFSeat} obj.liqSeat
684
672
  * @param {Amount<'nat'>} obj.totalCollateral
685
673
  * @param {Amount<'nat'>} obj.totalDebt
@@ -699,7 +687,7 @@ export const prepareVaultManagerKit = (
699
687
  if (plan.transfersToVault.length > 0) {
700
688
  const transfers = plan.transfersToVault.map(
701
689
  ([vaultIndex, amounts]) =>
702
- /** @type {TransferPart} */ ([
690
+ /** @type {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart} */ ([
703
691
  liqSeat,
704
692
  vaultsInPlan[vaultIndex].getVaultSeat(),
705
693
  amounts,
@@ -852,7 +840,9 @@ export const prepareVaultManagerKit = (
852
840
  const { descriptionScope } = this.state;
853
841
  return `${descriptionScope}: ${base}`;
854
842
  },
855
- /** coefficient on existing debt to calculate new debt */
843
+ /**
844
+ * coefficient on existing debt to calculate new debt
845
+ */
856
846
  getCompoundedInterest() {
857
847
  return this.state.compoundedInterest;
858
848
  },
@@ -862,8 +852,7 @@ export const prepareVaultManagerKit = (
862
852
  * @param {NormalizedDebt} oldDebtNormalized
863
853
  * @param {Amount<'nat'>} oldCollateral
864
854
  * @param {VaultId} vaultId
865
- * @param {import('./vault.js').VaultPhase} vaultPhase at the end of
866
- * whatever change updated balances
855
+ * @param {import('./vault.js').VaultPhase} vaultPhase at the end of whatever change updated balances
867
856
  * @param {Vault} vault
868
857
  * @returns {void}
869
858
  */
@@ -948,7 +937,9 @@ export const prepareVaultManagerKit = (
948
937
  return factoryPowers.getGovernedParams(collateralBrand);
949
938
  },
950
939
 
951
- /** @param {ZCFSeat} seat */
940
+ /**
941
+ * @param {ZCFSeat} seat
942
+ */
952
943
  async makeVaultKit(seat) {
953
944
  const {
954
945
  state,
@@ -972,6 +963,7 @@ export const prepareVaultManagerKit = (
972
963
 
973
964
  try {
974
965
  // TODO `await` is allowed until the above ordering is fixed
966
+ // eslint-disable-next-line @jessie.js/no-nested-await
975
967
  const vaultKit = await vault.initVaultKit(seat, vaultStorageNode);
976
968
  // initVaultKit calls back to handleBalanceChange() which will add the
977
969
  // vault to prioritizedVaults
@@ -1045,16 +1037,18 @@ export const prepareVaultManagerKit = (
1045
1037
  if (!storedCollateralQuote)
1046
1038
  throw Fail`lockOraclePrices called before a collateral quote was available`;
1047
1039
  trace(
1048
- `lockOraclePrices`,
1040
+ `lockPrice`,
1049
1041
  getAmountIn(storedCollateralQuote),
1050
1042
  getAmountOut(storedCollateralQuote),
1051
1043
  );
1052
1044
 
1053
1045
  state.lockedQuote = storedCollateralQuote;
1054
- void facets.helper.writeMetrics();
1046
+ facets.helper.writeMetrics();
1055
1047
  return storedCollateralQuote;
1056
1048
  },
1057
- /** @param {ERef<AuctioneerPublicFacet>} auctionPF */
1049
+ /**
1050
+ * @param {AuctioneerPublicFacet} auctionPF
1051
+ */
1058
1052
  async liquidateVaults(auctionPF) {
1059
1053
  const { state, facets } = this;
1060
1054
  const { self, helper } = facets;
@@ -1067,19 +1061,11 @@ export const prepareVaultManagerKit = (
1067
1061
  } = state;
1068
1062
  trace(collateralBrand, 'considering liquidation');
1069
1063
 
1070
- if (!lockedQuote) {
1071
- // By design, the first cycle of auction may call this before a quote is locked
1072
- // because the schedule is global at the vaultDirector level, and if a manager
1073
- // starts after the price lock time there's nothing to be done.
1074
- // NB: this message should not log repeatedly.
1075
- console.error(
1076
- 'Skipping liquidation because no quote is locked yet (may happen with new manager)',
1077
- );
1078
- return;
1079
- }
1080
-
1081
1064
  const { prioritizedVaults } = collateralEphemera(collateralBrand);
1082
- prioritizedVaults || Fail`prioritizedVaults missing from ephemera`;
1065
+ assert(factoryPowers && prioritizedVaults && zcf);
1066
+ lockedQuote ||
1067
+ Fail`Must have locked a quote before liquidating vaults.`;
1068
+ assert(lockedQuote); // redundant with previous line
1083
1069
 
1084
1070
  const liqMargin = self.getGovernedParams().getLiquidationMargin();
1085
1071
 
@@ -1101,7 +1087,6 @@ export const prepareVaultManagerKit = (
1101
1087
  state.lockedQuote = undefined;
1102
1088
 
1103
1089
  if (vaultData.getSize() === 0) {
1104
- void helper.writeMetrics();
1105
1090
  return;
1106
1091
  }
1107
1092
  trace(
@@ -1165,7 +1150,7 @@ export const prepareVaultManagerKit = (
1165
1150
  liquidatingVaults.delete(vault);
1166
1151
  }
1167
1152
 
1168
- void helper.writeMetrics();
1153
+ await facets.helper.writeMetrics();
1169
1154
  },
1170
1155
  },
1171
1156
  },
@@ -1189,12 +1174,7 @@ export const prepareVaultManagerKit = (
1189
1174
  },
1190
1175
  );
1191
1176
 
1192
- /**
1193
- * @param {Omit<
1194
- * Parameters<typeof makeVaultManagerKitInternal>[0],
1195
- * 'metricsStorageNode'
1196
- * >} externalParams
1197
- */
1177
+ /** @param {Omit<Parameters<typeof makeVaultManagerKitInternal>[0], 'metricsStorageNode'>} externalParams */
1198
1178
  const makeVaultManagerKit = async externalParams => {
1199
1179
  const metricsStorageNode = await E(
1200
1180
  externalParams.storageNode,
@@ -1207,13 +1187,15 @@ export const prepareVaultManagerKit = (
1207
1187
  return makeVaultManagerKit;
1208
1188
  };
1209
1189
 
1210
- /** @typedef {Awaited<ReturnType<ReturnType<typeof prepareVaultManagerKit>>>} VaultManagerKit */
1211
1190
  /**
1212
- * @typedef {VaultManagerKit['self']} VaultManager Each VaultManager manages a
1213
- * single collateral type.
1191
+ * @typedef {Awaited<ReturnType<ReturnType<typeof prepareVaultManagerKit>>>} VaultManagerKit
1192
+ */
1193
+ /**
1194
+ * @typedef {VaultManagerKit['self']} VaultManager
1195
+ * Each VaultManager manages a single collateral type.
1214
1196
  *
1215
- * It manages some number of outstanding debt positions, each called a Vault,
1216
- * for which the collateral is provided in exchange for borrowed Minted.
1197
+ * It manages some number of outstanding debt positions, each called a Vault,
1198
+ * for which the collateral is provided in exchange for borrowed Minted.
1217
1199
  */
1218
1200
  /** @typedef {VaultManagerKit['collateral']} CollateralManager */
1219
1201
 
@@ -1,83 +0,0 @@
1
- export function makeOfferSpecShape(bidBrand: Brand<'nat'>, collateralBrand: Brand<'nat'>): any;
2
- export function prepareAuctionBook(baggage: Baggage, zcf: ZCF, makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit): (bidBrand: Brand<"nat">, collateralBrand: Brand<"nat">, pAuthority: PriceAuthority, node: StorageNode) => {
3
- /**
4
- * @param {Amount<'nat'>} assetAmount
5
- * @param {ZCFSeat} sourceSeat
6
- * @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
7
- * would like to raise. The auction is requested to not sell more
8
- * collateral than required to raise that much. The auctioneer might
9
- * sell more if there is more than one supplier of collateral, and
10
- * they request inconsistent limits.
11
- */
12
- addAssets(assetAmount: Amount<'nat'>, sourceSeat: ZCFSeat, proceedsGoal?: Amount<"nat"> | undefined): void;
13
- /** @type {(reduction: Ratio) => void} */
14
- settleAtNewRate(reduction: Ratio): void;
15
- getCurrentPrice(): Ratio | null;
16
- hasOrders(): boolean;
17
- captureOraclePriceForRound(): void;
18
- setStartingRate(rate: any): void;
19
- /**
20
- * @param {OfferSpec} offerSpec
21
- * @param {ZCFSeat} seat
22
- * @param {boolean} trySettle
23
- */
24
- addOffer(offerSpec: OfferSpec, seat: ZCFSeat, trySettle: boolean): void;
25
- getSeats(): {
26
- collateralSeat: ZCFSeat;
27
- bidHoldingSeat: ZCFSeat;
28
- };
29
- exitAllSeats(): void;
30
- endAuction(): void;
31
- getDataUpdates(): Subscriber<BookDataNotification>;
32
- getPublicTopics(): {
33
- bookData: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<BookDataNotification>;
34
- };
35
- };
36
- export type OfferSpec = {
37
- maxBuy: Amount<'nat'>;
38
- } & {
39
- exitAfterBuy?: boolean;
40
- } & ({
41
- offerPrice: Ratio;
42
- } | {
43
- offerBidScaling: Ratio;
44
- });
45
- export type Baggage = import('@agoric/vat-data').Baggage;
46
- export type BookDataNotification = {
47
- /**
48
- * identifies the priceAuthority and price
49
- */
50
- startPrice: Ratio | null;
51
- /**
52
- * the price at the current auction
53
- * tier
54
- */
55
- currentPriceLevel: Ratio | null;
56
- /**
57
- * The proceeds the sellers
58
- * were targeting to raise
59
- */
60
- startProceedsGoal: Amount<'nat'> | null;
61
- /**
62
- * The remainder of the
63
- * proceeds the sellers were targeting to raise
64
- */
65
- remainingProceedsGoal: Amount<'nat'> | null;
66
- /**
67
- * The proceeds raised so
68
- * far in the auction
69
- */
70
- proceedsRaised: Amount<'nat'> | undefined;
71
- /**
72
- * How much collateral was available
73
- * for sale at the start. (If more is deposited later, it'll be added in.)
74
- */
75
- startCollateral: Amount<'nat'>;
76
- /**
77
- * The amount of collateral
78
- * remaining
79
- */
80
- collateralAvailable: Amount<'nat'> | null;
81
- };
82
- export type AuctionBook = ReturnType<ReturnType<typeof prepareAuctionBook>>;
83
- //# sourceMappingURL=auctionBook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auctionBook.d.ts","sourceRoot":"","sources":["auctionBook.js"],"names":[],"mappings":"AAyEO,6CAHI,MAAM,KAAK,CAAC,mBACZ,MAAM,KAAK,CAAC,OAiBtB;AA0BM,4CAJI,OAAO,OACP,GAAG,mBACH,OAAO,6CAA6C,EAAE,eAAe;IAwWxE;;;;;;;;OAQG;2BAPQ,OAAO,KAAK,CAAC,cACb,OAAO;IA6ElB,yCAAyC;+BAAlB,KAAK,GAAK,IAAI;;;;;IAmGrC;;;;OAIG;wBAHQ,SAAS,QACT,OAAO,aACP,OAAO;;;;;;;;;;;EAsHzB;wBA3sBY;IACZ,MAAU,EAAE,OAAO,KAAK,CAAC,CAAC;CACvB,GAAG;IACN,YAAgB,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,CACE;IACR,UAAoB,EAAE,KAAK,CAAC;CACnB,GACD;IACR,eAAyB,EAAE,KAAK,CAAC;CACxB,CACJ;sBAuBQ,OAAO,kBAAkB,EAAE,OAAO;;;;;gBAIlC,KAAK,GAAG,IAAI;;;;;uBACZ,KAAK,GAAG,IAAI;;;;;uBAEZ,OAAO,KAAK,CAAC,GAAG,IAAI;;;;;2BAEpB,OAAO,KAAK,CAAC,GAAG,IAAI;;;;;oBAEpB,OAAO,KAAK,CAAC,GAAG,SAAS;;;;;qBAEzB,OAAO,KAAK,CAAC;;;;;yBAEb,OAAO,KAAK,CAAC,GAAG,IAAI;;0BA6pBpB,WAAW,WAAW,yBAAyB,CAAC,CAAC"}
@@ -1,75 +0,0 @@
1
- export function distributeProportionalSharesWithLimits(unsoldCollateral: Amount<'nat'>, proceeds: Amount<'nat'>, deposits: {
2
- seat: ZCFSeat;
3
- amount: Amount<'nat'>;
4
- goal: Amount<'nat'>;
5
- }[], collateralSeat: ZCFSeat, bidHoldingSeat: ZCFSeat, collateralKeyword: string, reserveSeat: ZCFSeat, brand: Brand): TransferPart[];
6
- export function start(zcf: ZCF<GovernanceTerms<{
7
- Electorate: "invitation";
8
- StartFrequency: "relativeTime";
9
- ClockStep: "relativeTime";
10
- StartingRate: "nat";
11
- LowestRate: "nat";
12
- DiscountStep: "nat";
13
- AuctionStartDelay: "relativeTime";
14
- PriceLockPeriod: "relativeTime";
15
- }> & {
16
- timerService: import('@agoric/time/src/types').TimerService;
17
- reservePublicFacet: AssetReservePublicFacet;
18
- priceAuthority: PriceAuthority;
19
- }>, privateArgs: {
20
- initialPoserInvitation: Invitation;
21
- storageNode: StorageNode;
22
- marshaller: Marshaller;
23
- }, baggage: Baggage): Promise<{
24
- publicFacet: GovernedPublicFacet<{
25
- getElectorate: () => Amount<"set">;
26
- getStartFrequency: () => import("@agoric/time/src/types").RelativeTime;
27
- getClockStep: () => import("@agoric/time/src/types").RelativeTime;
28
- getStartingRate: () => bigint;
29
- getLowestRate: () => bigint;
30
- getDiscountStep: () => bigint;
31
- getAuctionStartDelay: () => import("@agoric/time/src/types").RelativeTime;
32
- getPriceLockPeriod: () => import("@agoric/time/src/types").RelativeTime;
33
- /** @param {Brand<'nat'>} collateralBrand */
34
- makeBidInvitation(collateralBrand: Brand<'nat'>): Promise<Invitation<R, A>>;
35
- getSchedules(): {
36
- liveAuctionSchedule: import("./scheduler.js").Schedule | null;
37
- nextAuctionSchedule: import("./scheduler.js").Schedule | null;
38
- };
39
- getScheduleUpdates(): Subscriber<import("./scheduler.js").ScheduleNotification>;
40
- getBookDataUpdates(brand: any): Subscriber<import("./auctionBook.js").BookDataNotification>;
41
- getPublicTopics(brand: any): {
42
- bookData: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./auctionBook.js").BookDataNotification>;
43
- } | {
44
- schedule: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./scheduler.js").ScheduleNotification>;
45
- };
46
- makeDepositInvitation: () => Promise<Invitation<R, A>>;
47
- }>;
48
- creatorFacet: GovernedCreatorFacet<{
49
- /**
50
- * @param {Issuer} issuer
51
- * @param {Keyword} kwd
52
- */
53
- addBrand(issuer: Issuer, kwd: Keyword): Promise<void>;
54
- /** @returns {Promise<import('./scheduler.js').FullSchedule>} */
55
- getSchedule(): Promise<import('./scheduler.js').FullSchedule>;
56
- } & import("@endo/eventual-send").RemotableBrand<{}, {
57
- /**
58
- * @param {Issuer} issuer
59
- * @param {Keyword} kwd
60
- */
61
- addBrand(issuer: Issuer, kwd: Keyword): Promise<void>;
62
- /** @returns {Promise<import('./scheduler.js').FullSchedule>} */
63
- getSchedule(): Promise<import('./scheduler.js').FullSchedule>;
64
- }>>;
65
- }>;
66
- /** @typedef {ContractOf<typeof start>} AuctioneerContract */
67
- /** @typedef {AuctioneerContract['publicFacet']} AuctioneerPublicFacet */
68
- /** @typedef {AuctioneerContract['creatorFacet']} AuctioneerCreatorFacet */
69
- export const AuctionPFShape: any;
70
- export type Baggage = import('@agoric/vat-data').Baggage;
71
- export type AuctioneerContract = ContractOf<typeof start>;
72
- export type AuctioneerPublicFacet = AuctioneerContract['publicFacet'];
73
- export type AuctioneerCreatorFacet = AuctioneerContract['creatorFacet'];
74
- import { auctioneerParamTypes } from './params.js';
75
- //# sourceMappingURL=auctioneer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auctioneer.d.ts","sourceRoot":"","sources":["auctioneer.js"],"names":[],"mappings":"AA8KO,yEAXI,OAAO,KAAK,CAAC,YACb,OAAO,KAAK,CAAC,YACb;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC;IAAC,IAAI,EAAE,OAAO,KAAK,CAAC,CAAA;CAAE,EAAE,kBAC/D,OAAO,kBACP,OAAO,qBAEP,MAAM,eAEN,OAAO,SACP,KAAK,kBAgNf;AAiBM;;;;;;;;;;kBAZc,OAAO,wBAAwB,EAAE,YAAY;wBACvC,uBAAuB;oBAC3B,cAAc;iBAG1B;IACV,sBAA0B,EAAE,UAAU,CAAC;IACvC,WAAe,EAAE,WAAW,CAAC;IAC7B,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;;;;;;QAyOZ,4CAA4C;2CAAhC,MAAM,KAAK,CAAC;;;;;;;;;;;;;;;QA+DxB;;;WAGG;yBAFQ,MAAM,OACN,OAAO;QAwBlB,gEAAgE;uBAAlD,QAAQ,OAAO,gBAAgB,EAAE,YAAY,CAAC;;QA1B5D;;;WAGG;yBAFQ,MAAM,OACN,OAAO;QAwBlB,gEAAgE;uBAAlD,QAAQ,OAAO,gBAAgB,EAAE,YAAY,CAAC;;GAQjE;AAED,6DAA6D;AAC7D,yEAAyE;AACzE,2EAA2E;AAE3E,iCAAkE;sBAtrBpD,OAAO,kBAAkB,EAAE,OAAO;iCAkrBlC,WAAW,YAAY,CAAC;oCACxB,kBAAkB,CAAC,aAAa,CAAC;qCACjC,kBAAkB,CAAC,cAAc,CAAC;qCAxrBX,aAAa"}