@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-fbe72e7.0.fbe72e7

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 (166) hide show
  1. package/README.md +6 -6
  2. package/package.json +46 -39
  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 +182 -151
  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 +70 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +72 -59
  13. package/src/auction/offerBook.d.ts +46 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +17 -12
  16. package/src/auction/params.d.ts +145 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +11 -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 +31 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +12 -6
  31. package/src/clientSupport.d.ts +168 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +161 -98
  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 +43 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +25 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +41 -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 +4 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest-math.js +5 -1
  51. package/src/interest.d.ts +30 -0
  52. package/src/interest.d.ts.map +1 -0
  53. package/src/interest.js +25 -23
  54. package/src/price/README.md +14 -1
  55. package/src/price/fluxAggregatorContract.d.ts +71 -0
  56. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  57. package/src/price/fluxAggregatorContract.js +64 -55
  58. package/src/price/fluxAggregatorKit.d.ts +104 -0
  59. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  60. package/src/price/fluxAggregatorKit.js +55 -42
  61. package/src/price/priceOracleKit.d.ts +39 -0
  62. package/src/price/priceOracleKit.d.ts.map +1 -0
  63. package/src/price/priceOracleKit.js +17 -15
  64. package/src/price/roundsManager.d.ts +204 -0
  65. package/src/price/roundsManager.d.ts.map +1 -0
  66. package/src/price/roundsManager.js +132 -85
  67. package/src/proposals/README.md +2 -3
  68. package/src/proposals/add-auction.js +285 -0
  69. package/src/proposals/addAssetToVault.js +192 -40
  70. package/src/proposals/committee-proposal.js +25 -31
  71. package/src/proposals/core-proposal.js +9 -11
  72. package/src/proposals/deploy-price-feeds.js +341 -0
  73. package/src/proposals/econ-behaviors.js +84 -49
  74. package/src/proposals/price-feed-proposal.js +109 -51
  75. package/src/proposals/replace-fee-distributor.js +198 -0
  76. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  77. package/src/proposals/replaceElectorate.js +610 -0
  78. package/src/proposals/startEconCommittee.js +2 -2
  79. package/src/proposals/startPSM.js +44 -29
  80. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  81. package/src/proposals/upgrade-vaults.js +207 -0
  82. package/src/proposals/utils.d.ts +21 -0
  83. package/src/proposals/utils.d.ts.map +1 -0
  84. package/src/proposals/utils.js +66 -9
  85. package/src/proposals/withdraw-reserve-proposal.js +63 -0
  86. package/src/provisionPool.d.ts +69 -0
  87. package/src/provisionPool.d.ts.map +1 -0
  88. package/src/provisionPool.js +138 -0
  89. package/src/provisionPoolKit.d.ts +129 -0
  90. package/src/provisionPoolKit.d.ts.map +1 -0
  91. package/src/provisionPoolKit.js +608 -0
  92. package/src/psm/psm.d.ts +133 -0
  93. package/src/psm/psm.d.ts.map +1 -0
  94. package/src/psm/psm.js +85 -79
  95. package/src/psm/types-ambient.d.ts +2 -0
  96. package/src/psm/types-ambient.d.ts.map +1 -0
  97. package/src/psm/types-ambient.js +3 -0
  98. package/src/reserve/assetReserve.d.ts +58 -0
  99. package/src/reserve/assetReserve.d.ts.map +1 -0
  100. package/src/reserve/assetReserve.js +42 -34
  101. package/src/reserve/assetReserveKit.d.ts +103 -0
  102. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  103. package/src/reserve/assetReserveKit.js +134 -32
  104. package/src/reserve/params.d.ts +16 -0
  105. package/src/reserve/params.d.ts.map +1 -0
  106. package/src/reserve/params.js +8 -2
  107. package/src/tokens.d.ts +3 -0
  108. package/src/tokens.d.ts.map +1 -0
  109. package/src/tokens.js +5 -0
  110. package/src/vaultFactory/burn.d.ts +2 -0
  111. package/src/vaultFactory/burn.d.ts.map +1 -0
  112. package/src/vaultFactory/burn.js +1 -1
  113. package/src/vaultFactory/liquidation.d.ts +25 -0
  114. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  115. package/src/vaultFactory/liquidation.js +37 -24
  116. package/src/vaultFactory/math.d.ts +11 -0
  117. package/src/vaultFactory/math.d.ts.map +1 -0
  118. package/src/vaultFactory/math.js +11 -10
  119. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  120. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  121. package/src/vaultFactory/orderedVaultStore.js +9 -10
  122. package/src/vaultFactory/params.d.ts +143 -0
  123. package/src/vaultFactory/params.d.ts.map +1 -0
  124. package/src/vaultFactory/params.js +56 -25
  125. package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
  126. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  127. package/src/vaultFactory/prioritizedVaults.js +7 -4
  128. package/src/vaultFactory/proceeds.d.ts +35 -0
  129. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  130. package/src/vaultFactory/proceeds.js +26 -18
  131. package/src/vaultFactory/storeUtils.d.ts +25 -0
  132. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  133. package/src/vaultFactory/storeUtils.js +10 -12
  134. package/src/vaultFactory/types-ambient.d.ts +137 -0
  135. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  136. package/src/vaultFactory/{types.js → types-ambient.js} +47 -44
  137. package/src/vaultFactory/vault.d.ts +344 -0
  138. package/src/vaultFactory/vault.d.ts.map +1 -0
  139. package/src/vaultFactory/vault.js +107 -100
  140. package/src/vaultFactory/vaultDirector.d.ts +347 -0
  141. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  142. package/src/vaultFactory/vaultDirector.js +94 -64
  143. package/src/vaultFactory/vaultFactory.d.ts +250 -0
  144. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  145. package/src/vaultFactory/vaultFactory.js +56 -33
  146. package/src/vaultFactory/vaultHolder.d.ts +170 -0
  147. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  148. package/src/vaultFactory/vaultHolder.js +14 -15
  149. package/src/vaultFactory/vaultKit.d.ts +33 -0
  150. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultKit.js +9 -4
  152. package/src/vaultFactory/vaultManager.d.ts +676 -0
  153. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultManager.js +286 -167
  155. package/CHANGELOG.md +0 -1041
  156. package/exported.js +0 -2
  157. package/scripts/add-collateral-core.js +0 -112
  158. package/scripts/deploy-contracts.js +0 -100
  159. package/scripts/init-core.js +0 -198
  160. package/scripts/invite-committee-core.js +0 -42
  161. package/scripts/manual-price-feed.js +0 -117
  162. package/scripts/price-feed-core.js +0 -104
  163. package/scripts/start-local-chain.sh +0 -84
  164. package/src/psm/types.js +0 -3
  165. package/src/typeGuards.js +0 -13
  166. package/src/vaultFactory/type-imports.js +0 -4
@@ -1,5 +1,7 @@
1
+ import { q, Fail } from '@endo/errors';
1
2
  import { AmountMath, AmountShape } from '@agoric/ertp';
2
- import { makeTracer, StorageNodeShape } from '@agoric/internal';
3
+ import { StorageNodeShape, makeTracer } from '@agoric/internal';
4
+ import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
3
5
  import { M, prepareExoClassKit } from '@agoric/vat-data';
4
6
  import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js';
5
7
  import { SeatShape } from '@agoric/zoe/src/typeGuards.js';
@@ -9,44 +11,50 @@ import {
9
11
  makeNatAmountShape,
10
12
  } from '../contractSupport.js';
11
13
  import { calculateCurrentDebt, reverseInterest } from '../interest-math.js';
12
- import { UnguardedHelperI } from '../typeGuards.js';
13
- import { prepareVaultKit } from './vaultKit.js';
14
-
15
- import '@agoric/zoe/exported.js';
16
14
  import { calculateDebtCosts } from './math.js';
17
-
18
- const { quote: q, Fail } = assert;
15
+ import { prepareVaultKit } from './vaultKit.js';
19
16
 
20
17
  const trace = makeTracer('Vault', true);
21
18
 
22
- /** @typedef {import('./storeUtils.js').NormalizedDebt} NormalizedDebt */
19
+ /**
20
+ * @import {EReturn} from '@endo/far';
21
+ * @import {Brand} from '@agoric/ertp/src/types.js';
22
+ * @import {NormalizedDebt} from './storeUtils.js';
23
+ */
23
24
 
24
25
  /**
25
- * @file This has most of the logic for a Vault, to borrow Minted against collateral.
26
+ * @file This has most of the logic for a Vault, to borrow Minted against
27
+ * collateral.
28
+ *
29
+ * The logic here is for Vault which is the majority of logic of vaults but the
30
+ * user view is the `vault` value contained in VaultKit.
26
31
  *
27
- * The logic here is for Vault which is the majority of logic of vaults but
28
- * the user view is the `vault` value contained in VaultKit.
32
+ * A note on naming convention:
29
33
  *
30
- * A note on naming convention:
31
- * - `Pre` is used as a postfix for any mutable value retrieved *before* an
32
- * `await`, to flag values that must used very carefully after the `await`
33
- * - `new` is a prefix for values that describe the result of executing a
34
- * transaction; e.g., `debt` is the value before the txn, and `newDebt`
35
- * will be value if the txn completes.
36
- * - the absence of one of these implies the opposite, so `newDebt` is the
37
- * future value fo `debt`, as computed based on values after any `await`
34
+ * - `Pre` is used as a postfix for any mutable value retrieved _before_ an
35
+ * `await`, to flag values that must used very carefully after the
36
+ * `await`
37
+ * - `new` is a prefix for values that describe the result of executing a
38
+ * transaction; e.g., `debt` is the value before the txn, and `newDebt`
39
+ * will be value if the txn completes.
40
+ * - the absence of one of these implies the opposite, so `newDebt` is the future
41
+ * value fo `debt`, as computed based on values after any `await`
38
42
  */
39
43
 
40
44
  /**
41
45
  * Constants for vault phase.
42
46
  *
43
- * ACTIVE - vault is in use and can be changed
44
- * LIQUIDATING - vault is being liquidated by the vault manager, and cannot be changed by the user.
45
- * If liquidation fails, vaults may remain in this state. An upgrade to the contract
46
- * might be able to recover them.
47
- * TRANSFER - vault is able to be transferred (payments and debits frozen until it has a new owner)
48
- * CLOSED - vault was closed by the user and all assets have been paid out
49
- * LIQUIDATED - vault was closed by the manager, with remaining assets paid to owner
47
+ * - ACTIVE - vault is in use and can be changed
48
+ * - LIQUIDATING - vault is being liquidated by the vault manager, and cannot be
49
+ * changed by the user. If liquidation fails, vaults may remain in this state.
50
+ * An upgrade to the contract might be able to recover them.
51
+ * - TRANSFER - vault is able to be transferred (payments and debits frozen until
52
+ * it has a new owner)
53
+ * - CLOSED - vault was closed by the user and all assets have been paid out
54
+ * - LIQUIDATED - vault was closed by the manager, with remaining assets paid to
55
+ * owner
56
+ *
57
+ * @enum {(typeof Phase)[keyof typeof Phase]}
50
58
  */
51
59
  export const Phase = /** @type {const} */ ({
52
60
  ACTIVE: 'active',
@@ -55,10 +63,11 @@ export const Phase = /** @type {const} */ ({
55
63
  LIQUIDATED: 'liquidated',
56
64
  TRANSFER: 'transfer',
57
65
  });
66
+ harden(Phase);
58
67
 
59
68
  /**
60
- * @typedef {Phase[keyof Omit<typeof Phase, 'TRANSFER'>]} VaultPhase
61
- * @type {{[K in VaultPhase]: Array<VaultPhase>}}
69
+ * @typedef {Exclude<Phase, 'transfer'>} VaultPhase
70
+ * @type {{ [K in VaultPhase]: VaultPhase[] }}
62
71
  */
63
72
  const validTransitions = {
64
73
  [Phase.ACTIVE]: [Phase.LIQUIDATING, Phase.CLOSED],
@@ -68,46 +77,54 @@ const validTransitions = {
68
77
  };
69
78
 
70
79
  /**
71
- * @typedef {Phase[keyof typeof Phase]} HolderPhase
72
- *
73
80
  * @typedef {object} VaultNotification
74
81
  * @property {Amount<'nat'>} locked Amount of Collateral locked
75
- * @property {{debt: Amount<'nat'>, interest: Ratio}} debtSnapshot 'debt' at the point the compounded interest was 'interest'
76
- * @property {HolderPhase} vaultState
82
+ * @property {{ debt: Amount<'nat'>; interest: Ratio }} debtSnapshot 'debt' at
83
+ * the point the compounded interest was 'interest'
84
+ * @property {Phase} vaultState
77
85
  */
78
86
 
79
87
  // XXX masks typedef from types.js, but using that causes circular def problems
80
88
  /**
81
89
  * @typedef {object} VaultManager
82
- * @property {() => Subscriber<import('./vaultManager').AssetState>} getAssetSubscriber
90
+ * @property {() => Subscriber<import('./vaultManager.js').AssetState>} getAssetSubscriber
83
91
  * @property {(collateralAmount: Amount) => Amount<'nat'>} maxDebtFor
84
- * @property {() => Brand} getCollateralBrand
92
+ * @property {() => Brand<'nat'>} getCollateralBrand
85
93
  * @property {(base: string) => string} scopeDescription
86
94
  * @property {() => Brand<'nat'>} getDebtBrand
87
95
  * @property {MintAndTransfer} mintAndTransfer
88
96
  * @property {(amount: Amount, seat: ZCFSeat) => void} burn
89
97
  * @property {() => Ratio} getCompoundedInterest
90
- * @property {(oldDebt: import('./storeUtils.js').NormalizedDebt, oldCollateral: Amount<'nat'>, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void} handleBalanceChange
98
+ * @property {(
99
+ * oldDebt: import('./storeUtils.js').NormalizedDebt,
100
+ * oldCollateral: Amount<'nat'>,
101
+ * vaultId: VaultId,
102
+ * vaultPhase: VaultPhase,
103
+ * vault: Vault,
104
+ * ) => void} handleBalanceChange
91
105
  * @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
92
106
  */
93
107
 
94
108
  /**
95
109
  * @typedef {Readonly<{
96
- * idInManager: VaultId,
97
- * manager: VaultManager,
98
- * storageNode: StorageNode,
99
- * vaultSeat: ZCFSeat,
110
+ * idInManager: VaultId;
111
+ * manager: VaultManager;
112
+ * storageNode: StorageNode;
113
+ * vaultSeat: ZCFSeat;
100
114
  * }>} ImmutableState
101
115
  */
102
116
 
103
117
  /**
104
- * Snapshot is of the debt and compounded interest when the principal was last changed.
118
+ * Snapshot is of the debt and compounded interest when the principal was last
119
+ * changed.
105
120
  *
106
121
  * @typedef {{
107
- * interestSnapshot: Ratio,
108
- * phase: VaultPhase,
109
- * debtSnapshot: Amount<'nat'>,
110
- * outerUpdater: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification> | null,
122
+ * interestSnapshot: Ratio;
123
+ * phase: VaultPhase;
124
+ * debtSnapshot: Amount<'nat'>;
125
+ * outerUpdater:
126
+ * | import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification>
127
+ * | null;
111
128
  * }} MutableState
112
129
  */
113
130
 
@@ -137,7 +154,7 @@ const VaultStateShape = harden({
137
154
  });
138
155
 
139
156
  /**
140
- * @param {import('@agoric/ertp').Baggage} baggage
157
+ * @param {import('@agoric/swingset-liveslots').Baggage} baggage
141
158
  * @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit} makeRecorderKit
142
159
  * @param {ZCF} zcf
143
160
  */
@@ -195,7 +212,10 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
195
212
  return AmountMath.makeEmpty(this.facets.helper.debtBrand());
196
213
  },
197
214
  /**
198
- * @typedef {{ give: { Collateral: Amount<'nat'>, Minted: Amount<'nat'> }, want: { Collateral: Amount<'nat'>, Minted: Amount<'nat'> } }} FullProposal
215
+ * @typedef {{
216
+ * give: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
217
+ * want: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
218
+ * }} FullProposal
199
219
  */
200
220
  /**
201
221
  * @param {ProposalRecord} partial
@@ -220,9 +240,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
220
240
  //#endregion
221
241
 
222
242
  //#region Phase logic
223
- /**
224
- * @param {VaultPhase} newPhase
225
- */
243
+ /** @param {VaultPhase} newPhase */
226
244
  assignPhase(newPhase) {
227
245
  const { state } = this;
228
246
 
@@ -261,12 +279,14 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
261
279
  },
262
280
 
263
281
  /**
264
- * Update the debt balance and propagate upwards to
265
- * maintain aggregate debt and liquidation order.
282
+ * Update the debt balance and propagate upwards to maintain aggregate
283
+ * debt and liquidation order.
266
284
  *
267
- * @param {NormalizedDebt} oldDebtNormalized - prior principal and all accrued interest, normalized to the launch of the vaultManager
285
+ * @param {NormalizedDebt} oldDebtNormalized - prior principal and all
286
+ * accrued interest, normalized to the launch of the vaultManager
268
287
  * @param {Amount<'nat'>} oldCollateral - actual collateral
269
- * @param {Amount<'nat'>} newDebtActual - actual principal and all accrued interest
288
+ * @param {Amount<'nat'>} newDebtActual - actual principal and all
289
+ * accrued interest
270
290
  */
271
291
  updateDebtAccounting(oldDebtNormalized, oldCollateral, newDebtActual) {
272
292
  const { state, facets } = this;
@@ -283,8 +303,8 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
283
303
  },
284
304
 
285
305
  /**
286
- *
287
306
  * @param {ZCFSeat} seat
307
+ * @returns {Amount<'nat'>}
288
308
  */
289
309
  getCollateralAllocated(seat) {
290
310
  return seat.getAmountAllocated(
@@ -292,6 +312,10 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
292
312
  this.facets.helper.collateralBrand(),
293
313
  );
294
314
  },
315
+ /**
316
+ * @param {ZCFSeat} seat
317
+ * @returns {Amount<'nat'>}
318
+ */
295
319
  getMintedAllocated(seat) {
296
320
  return seat.getAmountAllocated(
297
321
  'Minted',
@@ -307,7 +331,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
307
331
  },
308
332
 
309
333
  /**
310
- *
311
334
  * @param {Amount<'nat'>} collateralAmount
312
335
  * @param {Amount<'nat'>} proposedDebt
313
336
  */
@@ -320,10 +343,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
320
343
  )} for ${q(collateralAmount)} collateral`;
321
344
  },
322
345
 
323
- /**
324
- *
325
- * @param {HolderPhase} newPhase
326
- */
346
+ /** @param {Phase} newPhase */
327
347
  getStateSnapshot(newPhase) {
328
348
  const { state, facets } = this;
329
349
 
@@ -338,9 +358,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
338
358
  });
339
359
  },
340
360
 
341
- /**
342
- * call this whenever anything changes!
343
- */
361
+ /** call this whenever anything changes! */
344
362
  updateUiState() {
345
363
  const { state, facets } = this;
346
364
  const { outerUpdater } = state;
@@ -368,9 +386,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
368
386
  }
369
387
  },
370
388
 
371
- /**
372
- * @param {ZCFSeat} seat
373
- */
389
+ /** @param {ZCFSeat} seat */
374
390
  async closeHook(seat) {
375
391
  const { state, facets } = this;
376
392
 
@@ -440,11 +456,11 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
440
456
  },
441
457
 
442
458
  /**
443
- * Calculate the fee, the amount to mint and the resulting debt.
444
- * The give and the want together reflect a delta, where typically
445
- * one is zero because they come from the gave/want of an offer
446
- * proposal. If the `want` is zero, the `fee` will also be zero,
447
- * so the simple math works.
459
+ * Calculate the fee, the amount to mint and the resulting debt. The
460
+ * give and the want together reflect a delta, where typically one is
461
+ * zero because they come from the gave/want of an offer proposal. If
462
+ * the `want` is zero, the `fee` will also be zero, so the simple math
463
+ * works.
448
464
  *
449
465
  * @param {Amount<'nat'>} currentDebt
450
466
  * @param {Amount<'nat'>} giveAmount
@@ -522,7 +538,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
522
538
  },
523
539
 
524
540
  /**
525
- *
526
541
  * @param {ZCFSeat} clientSeat
527
542
  * @param {FullProposal} fp
528
543
  * @param {ReturnType<typeof calculateDebtCosts>} costs
@@ -543,7 +558,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
543
558
 
544
559
  const giveMintedTaken = AmountMath.subtract(fp.give.Minted, surplus);
545
560
 
546
- /** @type {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} */
561
+ /** @type {TransferPart[]} */
547
562
  const transfers = harden([
548
563
  [clientSeat, vaultSeat, { Collateral: fp.give.Collateral }],
549
564
  [vaultSeat, clientSeat, { Collateral: fp.want.Collateral }],
@@ -568,7 +583,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
568
583
  },
569
584
 
570
585
  /**
571
- *
572
586
  * @param {ZCFSeat} seat
573
587
  * @returns {VaultKit}
574
588
  */
@@ -579,7 +593,6 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
579
593
  helper.assertCloseable();
580
594
  seat.exit();
581
595
 
582
- // eslint-disable-next-line no-use-before-define
583
596
  const vaultKit = makeVaultKit(self, state.storageNode);
584
597
  state.outerUpdater = vaultKit.vaultUpdater;
585
598
  helper.updateUiState();
@@ -669,9 +682,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
669
682
  return vaultKit;
670
683
  },
671
684
 
672
- /**
673
- * Called by manager at start of liquidation.
674
- */
685
+ /** Called by manager at start of liquidation. */
675
686
  liquidating() {
676
687
  const { facets } = this;
677
688
 
@@ -681,8 +692,8 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
681
692
  },
682
693
 
683
694
  /**
684
- * Called by manager at end of liquidation, at which point all debts have been
685
- * covered.
695
+ * Called by manager at end of liquidation, at which point all debts
696
+ * have been covered.
686
697
  */
687
698
  liquidated() {
688
699
  const { facets } = this;
@@ -774,9 +785,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
774
785
  );
775
786
  },
776
787
 
777
- /**
778
- * @returns {Promise<Invitation>}
779
- */
788
+ /** @returns {Promise<Invitation<VaultKit>>} */
780
789
  makeTransferInvitation() {
781
790
  const { state, facets } = this;
782
791
  const { outerUpdater } = state;
@@ -808,10 +817,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
808
817
 
809
818
  // for status/debugging
810
819
 
811
- /**
812
- *
813
- * @returns {Amount<'nat'>}
814
- */
820
+ /** @returns {Amount<'nat'>} */
815
821
  getCollateralAmount() {
816
822
  const { state, facets } = this;
817
823
  const { vaultSeat } = state;
@@ -825,15 +831,15 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
825
831
  /**
826
832
  * The actual current debt, including accrued interest.
827
833
  *
828
- * This looks like a simple getter but it does a lot of the heavy lifting for
829
- * interest accrual. Rather than updating all records when interest accrues,
830
- * the vault manager updates just its rolling compounded interest. Here we
831
- * calculate what the current debt is given what's recorded in this vault and
832
- * what interest has compounded since this vault record was written.
833
- *
834
- * @see getNormalizedDebt
834
+ * This looks like a simple getter but it does a lot of the heavy
835
+ * lifting for interest accrual. Rather than updating all records when
836
+ * interest accrues, the vault manager updates just its rolling
837
+ * compounded interest. Here we calculate what the current debt is given
838
+ * what's recorded in this vault and what interest has compounded since
839
+ * this vault record was written.
835
840
  *
836
841
  * @returns {Amount<'nat'>}
842
+ * @see getNormalizedDebt
837
843
  */
838
844
  getCurrentDebt() {
839
845
  const { state } = this;
@@ -845,14 +851,15 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
845
851
  },
846
852
 
847
853
  /**
848
- * The normalization puts all debts on a common time-independent scale since
849
- * the launch of this vault manager. This allows the manager to order vaults
850
- * by their debt-to-collateral ratios without having to mutate the debts as
851
- * the interest accrues.
854
+ * The normalization puts all debts on a common time-independent scale
855
+ * since the launch of this vault manager. This allows the manager to
856
+ * order vaults by their debt-to-collateral ratios without having to
857
+ * mutate the debts as the interest accrues.
852
858
  *
859
+ * @returns {import('./storeUtils.js').NormalizedDebt} as if the vault
860
+ * was open at the launch of this manager, before any interest
861
+ * accrued
853
862
  * @see getActualDebAmount
854
- *
855
- * @returns {import('./storeUtils.js').NormalizedDebt} as if the vault was open at the launch of this manager, before any interest accrued
856
863
  */
857
864
  getNormalizedDebt() {
858
865
  const { state } = this;
@@ -868,4 +875,4 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
868
875
  return maker;
869
876
  };
870
877
 
871
- /** @typedef {ReturnType<ReturnType<typeof prepareVault>>['self']} Vault */
878
+ /** @typedef {EReturn<EReturn<typeof prepareVault>>['self']} Vault */