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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +6 -6
  2. package/package.json +41 -36
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +135 -103
  7. package/src/auction/auctioneer.d.ts +69 -0
  8. package/src/auction/auctioneer.d.ts.map +1 -0
  9. package/src/auction/auctioneer.js +63 -49
  10. package/src/auction/offerBook.d.ts +45 -0
  11. package/src/auction/offerBook.d.ts.map +1 -0
  12. package/src/auction/offerBook.js +13 -12
  13. package/src/auction/params.d.ts +144 -0
  14. package/src/auction/params.d.ts.map +1 -0
  15. package/src/auction/params.js +10 -9
  16. package/src/auction/scheduleMath.d.ts +5 -0
  17. package/src/auction/scheduleMath.d.ts.map +1 -0
  18. package/src/auction/scheduleMath.js +17 -15
  19. package/src/auction/scheduler.d.ts +49 -0
  20. package/src/auction/scheduler.d.ts.map +1 -0
  21. package/src/auction/scheduler.js +51 -43
  22. package/src/auction/sortedOffers.d.ts +8 -0
  23. package/src/auction/sortedOffers.d.ts.map +1 -0
  24. package/src/auction/sortedOffers.js +9 -7
  25. package/src/auction/util.d.ts +32 -0
  26. package/src/auction/util.d.ts.map +1 -0
  27. package/src/auction/util.js +6 -4
  28. package/src/clientSupport.d.ts +167 -0
  29. package/src/clientSupport.d.ts.map +1 -0
  30. package/src/clientSupport.js +154 -96
  31. package/src/collectFees.d.ts +2 -0
  32. package/src/collectFees.d.ts.map +1 -0
  33. package/src/contractSupport.d.ts +28 -0
  34. package/src/contractSupport.d.ts.map +1 -0
  35. package/src/contractSupport.js +14 -12
  36. package/src/econCommitteeCharter.d.ts +39 -0
  37. package/src/econCommitteeCharter.d.ts.map +1 -0
  38. package/src/econCommitteeCharter.js +21 -20
  39. package/src/feeDistributor.d.ts +224 -0
  40. package/src/feeDistributor.d.ts.map +1 -0
  41. package/src/feeDistributor.js +37 -33
  42. package/src/index.d.ts +2 -0
  43. package/src/index.d.ts.map +1 -0
  44. package/src/index.js +1 -0
  45. package/src/interest-math.d.ts +3 -0
  46. package/src/interest-math.d.ts.map +1 -0
  47. package/src/interest.d.ts +28 -0
  48. package/src/interest.d.ts.map +1 -0
  49. package/src/interest.js +21 -16
  50. package/src/price/README.md +13 -0
  51. package/src/price/fluxAggregatorContract.d.ts +70 -0
  52. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  53. package/src/price/fluxAggregatorContract.js +62 -55
  54. package/src/price/fluxAggregatorKit.d.ts +103 -0
  55. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  56. package/src/price/fluxAggregatorKit.js +50 -37
  57. package/src/price/priceOracleKit.d.ts +38 -0
  58. package/src/price/priceOracleKit.d.ts.map +1 -0
  59. package/src/price/priceOracleKit.js +11 -13
  60. package/src/price/roundsManager.d.ts +204 -0
  61. package/src/price/roundsManager.d.ts.map +1 -0
  62. package/src/price/roundsManager.js +79 -82
  63. package/src/proposals/README.md +2 -3
  64. package/src/proposals/add-auction.d.ts +69 -0
  65. package/src/proposals/add-auction.d.ts.map +1 -0
  66. package/src/proposals/add-auction.js +180 -0
  67. package/src/proposals/addAssetToVault.d.ts +160 -0
  68. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  69. package/src/proposals/addAssetToVault.js +172 -38
  70. package/src/proposals/committee-proposal.d.ts +113 -0
  71. package/src/proposals/committee-proposal.d.ts.map +1 -0
  72. package/src/proposals/committee-proposal.js +25 -31
  73. package/src/proposals/core-proposal.d.ts +149 -0
  74. package/src/proposals/core-proposal.d.ts.map +1 -0
  75. package/src/proposals/core-proposal.js +9 -11
  76. package/src/proposals/econ-behaviors.d.ts +539 -0
  77. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  78. package/src/proposals/econ-behaviors.js +64 -45
  79. package/src/proposals/price-feed-proposal.d.ts +84 -0
  80. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  81. package/src/proposals/price-feed-proposal.js +108 -51
  82. package/src/proposals/startEconCommittee.d.ts +34 -0
  83. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  84. package/src/proposals/startEconCommittee.js +2 -2
  85. package/src/proposals/startPSM.d.ts +59 -0
  86. package/src/proposals/startPSM.d.ts.map +1 -0
  87. package/src/proposals/startPSM.js +38 -27
  88. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  89. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  90. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  91. package/src/proposals/upgrade-vaults.d.ts +35 -0
  92. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  93. package/src/proposals/upgrade-vaults.js +235 -0
  94. package/src/proposals/utils.d.ts +17 -0
  95. package/src/proposals/utils.d.ts.map +1 -0
  96. package/src/proposals/utils.js +34 -7
  97. package/src/provisionPool.d.ts +167 -0
  98. package/src/provisionPool.d.ts.map +1 -0
  99. package/src/provisionPool.js +122 -0
  100. package/src/provisionPoolKit.d.ts +367 -0
  101. package/src/provisionPoolKit.d.ts.map +1 -0
  102. package/src/provisionPoolKit.js +522 -0
  103. package/src/psm/psm.d.ts +122 -0
  104. package/src/psm/psm.d.ts.map +1 -0
  105. package/src/psm/psm.js +73 -69
  106. package/src/psm/types-ambient.d.ts +2 -0
  107. package/src/psm/types-ambient.d.ts.map +1 -0
  108. package/src/psm/types-ambient.js +3 -0
  109. package/src/reserve/assetReserve.d.ts +47 -0
  110. package/src/reserve/assetReserve.d.ts.map +1 -0
  111. package/src/reserve/assetReserve.js +28 -19
  112. package/src/reserve/assetReserveKit.d.ts +74 -0
  113. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  114. package/src/reserve/assetReserveKit.js +18 -24
  115. package/src/reserve/params.d.ts +10 -0
  116. package/src/reserve/params.d.ts.map +1 -0
  117. package/src/tokens.d.ts +3 -0
  118. package/src/tokens.d.ts.map +1 -0
  119. package/src/tokens.js +5 -0
  120. package/src/vaultFactory/burn.d.ts +2 -0
  121. package/src/vaultFactory/burn.d.ts.map +1 -0
  122. package/src/vaultFactory/burn.js +1 -1
  123. package/src/vaultFactory/liquidation.d.ts +23 -0
  124. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  125. package/src/vaultFactory/liquidation.js +36 -22
  126. package/src/vaultFactory/math.d.ts +11 -0
  127. package/src/vaultFactory/math.d.ts.map +1 -0
  128. package/src/vaultFactory/math.js +10 -9
  129. package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
  130. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  131. package/src/vaultFactory/orderedVaultStore.js +8 -11
  132. package/src/vaultFactory/params.d.ts +140 -0
  133. package/src/vaultFactory/params.d.ts.map +1 -0
  134. package/src/vaultFactory/params.js +52 -24
  135. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  136. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  137. package/src/vaultFactory/prioritizedVaults.js +4 -4
  138. package/src/vaultFactory/proceeds.d.ts +35 -0
  139. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  140. package/src/vaultFactory/proceeds.js +26 -18
  141. package/src/vaultFactory/storeUtils.d.ts +25 -0
  142. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  143. package/src/vaultFactory/storeUtils.js +10 -12
  144. package/src/vaultFactory/types-ambient.d.ts +137 -0
  145. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  146. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  147. package/src/vaultFactory/vault.d.ts +332 -0
  148. package/src/vaultFactory/vault.d.ts.map +1 -0
  149. package/src/vaultFactory/vault.js +99 -93
  150. package/src/vaultFactory/vaultDirector.d.ts +340 -0
  151. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  152. package/src/vaultFactory/vaultDirector.js +63 -50
  153. package/src/vaultFactory/vaultFactory.d.ts +201 -0
  154. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  155. package/src/vaultFactory/vaultFactory.js +49 -32
  156. package/src/vaultFactory/vaultHolder.d.ts +126 -0
  157. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  158. package/src/vaultFactory/vaultHolder.js +10 -14
  159. package/src/vaultFactory/vaultKit.d.ts +32 -0
  160. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  161. package/src/vaultFactory/vaultKit.js +5 -4
  162. package/src/vaultFactory/vaultManager.d.ts +674 -0
  163. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  164. package/src/vaultFactory/vaultManager.js +249 -151
  165. package/CHANGELOG.md +0 -1033
  166. package/bundles/bundle-auctioneer-js-meta.json +0 -722
  167. package/bundles/bundle-auctioneer.js +0 -1
  168. package/bundles/bundle-econCommitteeCharter-js-meta.json +0 -514
  169. package/bundles/bundle-econCommitteeCharter.js +0 -1
  170. package/bundles/bundle-feeDistributor-js-meta.json +0 -458
  171. package/bundles/bundle-feeDistributor.js +0 -1
  172. package/bundles/bundle-fluxAggregatorKit-js-meta.json +0 -674
  173. package/bundles/bundle-fluxAggregatorKit.js +0 -1
  174. package/bundles/bundle-psm-js-meta.json +0 -666
  175. package/bundles/bundle-psm.js +0 -1
  176. package/bundles/bundle-reserve-js-meta.json +0 -662
  177. package/bundles/bundle-reserve.js +0 -1
  178. package/bundles/bundle-scaledPriceAuthority-js-meta.json +0 -542
  179. package/bundles/bundle-scaledPriceAuthority.js +0 -1
  180. package/bundles/bundle-vaultFactory-js-meta.json +0 -790
  181. package/bundles/bundle-vaultFactory.js +0 -1
  182. package/exported.js +0 -2
  183. package/scripts/add-collateral-core.js +0 -112
  184. package/scripts/deploy-contracts.js +0 -100
  185. package/scripts/init-core.js +0 -198
  186. package/scripts/invite-committee-core.js +0 -42
  187. package/scripts/manual-price-feed.js +0 -117
  188. package/scripts/price-feed-core.js +0 -104
  189. package/scripts/start-local-chain.sh +0 -84
  190. package/src/psm/types.js +0 -3
  191. package/src/typeGuards.js +0 -13
  192. package/src/vaultFactory/type-imports.js +0 -4
@@ -13,16 +13,18 @@ import { makeCancelTokenMaker } from '../auction/util.js';
13
13
 
14
14
  const trace = makeTracer('LIQ');
15
15
 
16
- /** @typedef {import('@agoric/time/src/types').TimerService} TimerService */
17
- /** @typedef {import('@agoric/time/src/types').TimerWaker} TimerWaker */
18
- /** @typedef {import('@agoric/time/src/types').CancelToken} CancelToken */
19
- /** @typedef {import('@agoric/time/src/types').RelativeTimeRecord} RelativeTimeRecord */
16
+ /** @import {TimerService} from '@agoric/time' */
17
+ /** @import {TimerWaker} from '@agoric/time' */
18
+ /** @import {CancelToken} from '@agoric/time' */
19
+ /** @import {RelativeTimeRecord} from '@agoric/time' */
20
+ /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
20
21
 
21
22
  const makeCancelToken = makeCancelTokenMaker('liq');
22
23
 
23
24
  /**
24
25
  * This will normally be set. If the schedule goes sideways, we'll unschedule
25
- * all events and unset it. When auction params are changed, we'll restart the schedule
26
+ * all events and unset it. When auction params are changed, we'll restart the
27
+ * schedule
26
28
  *
27
29
  * @type {object | undefined}
28
30
  */
@@ -47,15 +49,16 @@ const cancelWakeups = timer => {
47
49
  };
48
50
 
49
51
  /**
50
- * Schedule wakeups for the *next* auction round.
52
+ * Schedule wakeups for the _next_ auction round.
51
53
  *
52
- * In practice, there are these cases to handle (with N as "live" and N+1 is "next"):
54
+ * In practice, there are these cases to handle (with N as "live" and N+1 is
55
+ * "next"):
53
56
  *
54
- * | when (now within the range) | what |
55
- * | -------------------------------- | --------------------------------------- |
56
- * | [start N, nominalStart N+1] | good: schedule normally the three wakers|
57
- * | (nominalStart N+1, endTime N+1] | recover: skip round N+1 and schedule N+2|
58
- * | (endTime N+1, ∞) | give up: wait for repair by governance |
57
+ * | when (now within the range) | what |
58
+ * | ------------------------------- | ---------------------------------------- |
59
+ * | [start N, nominalStart N+1] | good: schedule normally the three wakers |
60
+ * | (nominalStart N+1, endTime N+1] | recover: skip round N+1 and schedule N+2 |
61
+ * | (endTime N+1, ∞) | give up: wait for repair by governance |
59
62
  *
60
63
  * @param {object} opts
61
64
  * @param {ERef<TimerService>} opts.timer
@@ -63,7 +66,7 @@ const cancelWakeups = timer => {
63
66
  * @param {TimerWaker} opts.liquidationWaker
64
67
  * @param {TimerWaker} opts.reschedulerWaker
65
68
  * @param {import('../auction/scheduler.js').Schedule} opts.nextAuctionSchedule
66
- * @param {import('@agoric/time/src/types').TimestampRecord} opts.now
69
+ * @param {import('@agoric/time').TimestampRecord} opts.now
67
70
  * @param {ParamStateRecord} opts.params
68
71
  * @returns {void}
69
72
  */
@@ -132,7 +135,7 @@ const setWakeups = ({
132
135
  };
133
136
 
134
137
  /**
135
- * Schedule wakeups for the *next* auction round.
138
+ * Schedule wakeups for the _next_ auction round.
136
139
  *
137
140
  * Called by vaultDirector's resetWakeupsForNextAuction at start() and every
138
141
  * time there's a "reschedule" wakeup.
@@ -185,7 +188,7 @@ harden(setWakeupsForNextAuction);
185
188
  /**
186
189
  * @param {Amount<'nat'>} debt
187
190
  * @param {Amount<'nat'>} minted
188
- * @returns {{ overage: Amount<'nat'>, shortfall: Amount<'nat'>}}
191
+ * @returns {{ overage: Amount<'nat'>; shortfall: Amount<'nat'> }}
189
192
  */
190
193
  export const liquidationResults = (debt, minted) => {
191
194
  if (AmountMath.isEmpty(minted)) {
@@ -240,15 +243,21 @@ export const watchForGovernanceChange = (
240
243
  * @param {PriceQuote} collateralizationDetails.quote
241
244
  * @param {Ratio} collateralizationDetails.interest
242
245
  * @param {Ratio} collateralizationDetails.margin
243
- * @param {ReturnType<typeof import('./prioritizedVaults.js').makePrioritizedVaults>} prioritizedVaults
246
+ * @param {ReturnType<
247
+ * typeof import('./prioritizedVaults.js').makePrioritizedVaults
248
+ * >} prioritizedVaults
244
249
  * @param {SetStore<Vault>} liquidatingVaults
245
250
  * @param {Brand<'nat'>} debtBrand
246
251
  * @param {Brand<'nat'>} collateralBrand
247
252
  * @returns {{
248
- * vaultData: MapStore<Vault, { collateralAmount: Amount<'nat'>, debtAmount: Amount<'nat'>}>,
249
- * totalDebt: Amount<'nat'>,
250
- * totalCollateral: Amount<'nat'>,
251
- * liqSeat: ZCFSeat}}
253
+ * vaultData: MapStore<
254
+ * Vault,
255
+ * { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
256
+ * >;
257
+ * totalDebt: Amount<'nat'>;
258
+ * totalCollateral: Amount<'nat'>;
259
+ * liqSeat: ZCFSeat;
260
+ * }}
252
261
  */
253
262
  export const getLiquidatableVaults = (
254
263
  zcf,
@@ -261,13 +270,18 @@ export const getLiquidatableVaults = (
261
270
  const vaultsToLiquidate = prioritizedVaults.removeVaultsBelow(
262
271
  collateralizationDetails,
263
272
  );
264
- /** @type {MapStore<Vault, { collateralAmount: Amount<'nat'>, debtAmount: Amount<'nat'>}>} */
273
+ /**
274
+ * @type {MapStore<
275
+ * Vault,
276
+ * { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
277
+ * >}
278
+ */
265
279
  const vaultData = makeScalarMapStore();
266
280
 
267
281
  const { zcfSeat: liqSeat } = zcf.makeEmptySeatKit();
268
282
  let totalDebt = AmountMath.makeEmpty(debtBrand);
269
283
  let totalCollateral = AmountMath.makeEmpty(collateralBrand);
270
- /** @type {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} */
284
+ /** @type {TransferPart[]} */
271
285
  const transfers = [];
272
286
 
273
287
  for (const vault of vaultsToLiquidate.values()) {
@@ -0,0 +1,11 @@
1
+ export function calculateMinimumCollateralization(liquidationMargin: Ratio, liquidationPadding: Ratio): Ratio;
2
+ export function minimumPrice(quoteA: PriceQuote, quoteB?: PriceQuote | undefined): Ratio;
3
+ export function maxDebtForVault(quoteAmount: PriceQuote, liquidationMargin: Ratio, liquidationPadding: Ratio): Amount<"nat">;
4
+ export function calculateDebtCosts(currentDebt: Amount<"nat">, give: Amount<"nat">, want: Amount<"nat">, debtFee: Ratio): {
5
+ newDebt: import("@agoric/ertp/src/types.js").NatAmount;
6
+ toMint: import("@agoric/ertp/src/types.js").NatAmount;
7
+ fee: import("@agoric/ertp/src/types.js").NatAmount;
8
+ surplus: import("@agoric/ertp/src/types.js").NatAmount;
9
+ };
10
+ import type { PriceQuote } from '@agoric/zoe/tools/types.js';
11
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["math.js"],"names":[],"mappings":"AA4BO,qEAJI,KAAK,sBACL,KAAK,GACH,KAAK,CAKmC;AAS9C,qCAJI,UAAU,oCAER,KAAK,CAajB;AAYM,6CALI,UAAU,qBACV,KAAK,sBACL,KAAK,GACH,MAAM,CAAC,KAAK,CAAC,CAczB;AAaM,gDALI,MAAM,CAAC,KAAK,CAAC,QACb,MAAM,CAAC,KAAK,CAAC,QACb,MAAM,CAAC,KAAK,CAAC,WACb,KAAK;;;;;EASf;gCA7E6F,4BAA4B"}
@@ -1,8 +1,8 @@
1
1
  // @jessie-check
2
2
 
3
3
  /**
4
- * @file calculations specific to the Vault Factory contract
5
- * See also ../interest-math.js
4
+ * @file calculations specific to the Vault Factory contract See also
5
+ * ../interest-math.js
6
6
  */
7
7
 
8
8
  import { AmountMath } from '@agoric/ertp';
@@ -16,9 +16,11 @@ import {
16
16
  import { priceFrom } from '../auction/util.js';
17
17
  import { addSubtract } from '../contractSupport.js';
18
18
 
19
+ /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
20
+
19
21
  /**
20
- * Calculate the minimum collateralization given the liquidation margin and the "padding"
21
- * from that liquidation threshold.
22
+ * Calculate the minimum collateralization given the liquidation margin and the
23
+ * "padding" from that liquidation threshold.
22
24
  *
23
25
  * @param {Ratio} liquidationMargin
24
26
  * @param {Ratio} liquidationPadding
@@ -74,11 +76,10 @@ export const maxDebtForVault = (
74
76
  };
75
77
 
76
78
  /**
77
- * Calculate the fee, the amount to mint and the resulting debt.
78
- * The give and the want together reflect a delta, where typically
79
- * one is zero because they come from the gave/want of an offer
80
- * proposal. If the `want` is zero, the `fee` will also be zero,
81
- * so the simple math works.
79
+ * Calculate the fee, the amount to mint and the resulting debt. The give and
80
+ * the want together reflect a delta, where typically one is zero because they
81
+ * come from the gave/want of an offer proposal. If the `want` is zero, the
82
+ * `fee` will also be zero, so the simple math works.
82
83
  *
83
84
  * @param {Amount<'nat'>} currentDebt
84
85
  * @param {Amount<'nat'>} give excess of currentDebt is returned in 'surplus'
@@ -0,0 +1,93 @@
1
+ export function makeOrderedVaultStore(store: MapStore<string, Vault>): {
2
+ addVault: (vaultId: string, vault: Vault) => string;
3
+ removeByKey: (key: string) => Vault;
4
+ has: (key: string) => boolean;
5
+ keys: (keyPatt?: globalThis.Pattern, valuePatt?: globalThis.Pattern) => Iterable<string>;
6
+ entries: (keyPatt?: globalThis.Pattern, valuePatt?: globalThis.Pattern) => Iterable<[string, import("@endo/exo").Guarded<{
7
+ getVaultSeat(): ZCFSeat;
8
+ initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
9
+ publicSubscribers: {
10
+ vault: {
11
+ description: string;
12
+ subscriber: globalThis.Subscriber<VaultNotification>;
13
+ storagePath: Promise<string>;
14
+ };
15
+ };
16
+ invitationMakers: import("@endo/exo").Guarded<{
17
+ AdjustBalances(): Promise<Invitation<string, undefined>>;
18
+ CloseVault(): Promise<Invitation<string, undefined>>;
19
+ TransferVault(): Promise<Invitation<any, undefined>>;
20
+ }>;
21
+ vault: import("@endo/exo").Guarded<{
22
+ getPublicTopics(): {
23
+ vault: {
24
+ description: string;
25
+ subscriber: globalThis.Subscriber<VaultNotification>;
26
+ storagePath: Promise<string>;
27
+ };
28
+ };
29
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
30
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
31
+ makeTransferInvitation(): Promise<Invitation<any, undefined>>;
32
+ getCollateralAmount(): import("@agoric/ertp/src/types.js").NatAmount;
33
+ getCurrentDebt(): import("@agoric/ertp/src/types.js").NatAmount;
34
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
35
+ }>;
36
+ vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
37
+ }>;
38
+ liquidating(): void;
39
+ liquidated(): void;
40
+ abortLiquidation(): string;
41
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
42
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
43
+ makeTransferInvitation(): Promise<Invitation<VaultKit>>;
44
+ getCollateralAmount(): Amount<"nat">;
45
+ getCurrentDebt(): Amount<"nat">;
46
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
47
+ }>]>;
48
+ getSize: (keyPatt?: globalThis.Pattern, valuePatt?: globalThis.Pattern) => number;
49
+ values: (keyPatt?: globalThis.Pattern, valuePatt?: globalThis.Pattern) => Iterable<import("@endo/exo").Guarded<{
50
+ getVaultSeat(): ZCFSeat;
51
+ initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
52
+ publicSubscribers: {
53
+ vault: {
54
+ description: string;
55
+ subscriber: globalThis.Subscriber<VaultNotification>;
56
+ storagePath: Promise<string>;
57
+ };
58
+ };
59
+ invitationMakers: import("@endo/exo").Guarded<{
60
+ AdjustBalances(): Promise<Invitation<string, undefined>>;
61
+ CloseVault(): Promise<Invitation<string, undefined>>;
62
+ TransferVault(): Promise<Invitation<any, undefined>>;
63
+ }>;
64
+ vault: import("@endo/exo").Guarded<{
65
+ getPublicTopics(): {
66
+ vault: {
67
+ description: string;
68
+ subscriber: globalThis.Subscriber<VaultNotification>;
69
+ storagePath: Promise<string>;
70
+ };
71
+ };
72
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
73
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
74
+ makeTransferInvitation(): Promise<Invitation<any, undefined>>;
75
+ getCollateralAmount(): import("@agoric/ertp/src/types.js").NatAmount;
76
+ getCurrentDebt(): import("@agoric/ertp/src/types.js").NatAmount;
77
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
78
+ }>;
79
+ vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
80
+ }>;
81
+ liquidating(): void;
82
+ liquidated(): void;
83
+ abortLiquidation(): string;
84
+ makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
85
+ makeCloseInvitation(): Promise<Invitation<string, undefined>>;
86
+ makeTransferInvitation(): Promise<Invitation<VaultKit>>;
87
+ getCollateralAmount(): Amount<"nat">;
88
+ getCurrentDebt(): Amount<"nat">;
89
+ getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
90
+ }>>;
91
+ };
92
+ import type { Vault } from './vault.js';
93
+ //# sourceMappingURL=orderedVaultStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderedVaultStore.d.ts","sourceRoot":"","sources":["orderedVaultStore.js"],"names":[],"mappings":"AAiBO,6CADK,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;wBAGtB,MAAM,SACN,KAAK;uBAWL,MAAM,KACJ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAkCgu1B,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADpw1B;2BApDwB,YAAY"}
@@ -3,22 +3,20 @@ import { fromVaultKey, toVaultKey } from './storeUtils.js';
3
3
  /**
4
4
  * Used by prioritizedVaults to wrap the Collections API for this use case.
5
5
  *
6
- * Designed to be replaceable by naked Collections API when composite keys are available.
6
+ * Designed to be replaceable by naked Collections API when composite keys are
7
+ * available.
7
8
  *
8
- * In this module debts are encoded as the inverse quotient (collateral over debt) so that
9
- * greater collateralization sorts after lower. (Higher debt-to-collateral come
10
- * first.)
9
+ * In this module debts are encoded as the inverse quotient (collateral over
10
+ * debt) so that greater collateralization sorts after lower. (Higher
11
+ * debt-to-collateral come first.)
11
12
  */
12
13
 
13
- /** @typedef {import('./vault').Vault} Vault */
14
- /** @typedef {import('./storeUtils').CompositeKey} CompositeKey */
14
+ /** @import {Vault} from './vault.js' */
15
+ /** @import {CompositeKey} from './storeUtils.js' */
15
16
 
16
- /**
17
- * @param {MapStore<string, Vault>} store
18
- */
17
+ /** @param {MapStore<string, Vault>} store */
19
18
  export const makeOrderedVaultStore = store => {
20
19
  /**
21
- *
22
20
  * @param {string} vaultId
23
21
  * @param {Vault} vault
24
22
  */
@@ -31,7 +29,6 @@ export const makeOrderedVaultStore = store => {
31
29
  };
32
30
 
33
31
  /**
34
- *
35
32
  * @param {string} key
36
33
  * @returns {Vault}
37
34
  */
@@ -0,0 +1,140 @@
1
+ /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
2
+ export const CHARGING_PERIOD_KEY: "ChargingPeriod";
3
+ export const RECORDING_PERIOD_KEY: "RecordingPeriod";
4
+ export const DEBT_LIMIT_KEY: "DebtLimit";
5
+ export const LIQUIDATION_MARGIN_KEY: "LiquidationMargin";
6
+ export const LIQUIDATION_PADDING_KEY: "LiquidationPadding";
7
+ export const LIQUIDATION_PENALTY_KEY: "LiquidationPenalty";
8
+ export const INTEREST_RATE_KEY: "InterestRate";
9
+ export const MINT_FEE_KEY: "MintFee";
10
+ export const MIN_INITIAL_DEBT_KEY: "MinInitialDebt";
11
+ export const SHORTFALL_INVITATION_KEY: "ShortfallInvitation";
12
+ export const REFERENCED_UI_KEY: "ReferencedUI";
13
+ export namespace vaultDirectorParamTypes {
14
+ let MinInitialDebt: "amount";
15
+ let ChargingPeriod: "nat";
16
+ let RecordingPeriod: "nat";
17
+ let ReferencedUI: "string";
18
+ }
19
+ export function makeVaultParamManager(publisherKit: import("@agoric/notifier").StoredPublisherKit<GovernanceSubscriptionState>, { debtLimit, interestRate, liquidationMargin, liquidationPadding, liquidationPenalty, mintFee, }: VaultManagerParamValues): import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
20
+ DebtLimit: "amount";
21
+ InterestRate: "ratio";
22
+ LiquidationPadding: "ratio";
23
+ LiquidationMargin: "ratio";
24
+ LiquidationPenalty: "ratio";
25
+ MintFee: "ratio";
26
+ }>;
27
+ /** @typedef {ReturnType<typeof makeVaultParamManager>} VaultParamManager */
28
+ export const vaultParamPattern: import("@endo/patterns").Matcher;
29
+ export function makeGovernedTerms({ bootstrapPaymentValue, electorateInvitationAmount, interestTiming, minInitialDebt, priceAuthority, reservePublicFacet, timer, shortfallInvitationAmount, referencedUi, }: {
30
+ electorateInvitationAmount: Amount<"set">;
31
+ minInitialDebt: Amount<"nat">;
32
+ bootstrapPaymentValue: bigint;
33
+ priceAuthority: ERef<PriceAuthority>;
34
+ timer: ERef<import("@agoric/time").TimerService>;
35
+ reservePublicFacet: AssetReservePublicFacet;
36
+ interestTiming: InterestTiming;
37
+ shortfallInvitationAmount: Amount<"set">;
38
+ referencedUi?: string;
39
+ }): {
40
+ priceAuthority: globalThis.ERef<PriceAuthority>;
41
+ reservePublicFacet: globalThis.GovernedPublicFacet<import("@endo/exo").Guarded<{
42
+ makeAddCollateralInvitation(): Promise<Invitation<string, never>>;
43
+ getPublicTopics(): {
44
+ metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("../reserve/assetReserveKit.js").MetricsNotification>;
45
+ };
46
+ }>>;
47
+ timerService: globalThis.ERef<import("@agoric/time").TimerService>;
48
+ governedParams: {
49
+ Electorate: {
50
+ type: "invitation";
51
+ value: import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key>;
52
+ };
53
+ MinInitialDebt: {
54
+ type: "amount";
55
+ value: import("@agoric/ertp/src/types.js").NatAmount;
56
+ };
57
+ ShortfallInvitation: {
58
+ type: "invitation";
59
+ value: import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key>;
60
+ };
61
+ ReferencedUI: {
62
+ type: "string";
63
+ value: string;
64
+ };
65
+ ChargingPeriod: {
66
+ type: "nat";
67
+ value: bigint;
68
+ };
69
+ RecordingPeriod: {
70
+ type: "nat";
71
+ value: bigint;
72
+ };
73
+ };
74
+ bootstrapPaymentValue: bigint;
75
+ };
76
+ export function provideVaultParamManagers(baggage: import("@agoric/vat-data").Baggage, marshaller: ERef<Marshaller>, managerParamOverrides: Record<string, VaultManagerParamOverrides>): {
77
+ /**
78
+ * @param {Brand} brand
79
+ * @param {StorageNode} storageNode
80
+ * @param {VaultManagerParamValues} initialParamValues
81
+ */
82
+ addParamManager(brand: Brand, storageNode: StorageNode, initialParamValues: VaultManagerParamValues): import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
83
+ DebtLimit: "amount";
84
+ InterestRate: "ratio";
85
+ LiquidationPadding: "ratio";
86
+ LiquidationMargin: "ratio";
87
+ LiquidationPenalty: "ratio";
88
+ MintFee: "ratio";
89
+ }>;
90
+ /** @param {Brand} brand */
91
+ get(brand: Brand): import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
92
+ DebtLimit: "amount";
93
+ InterestRate: "ratio";
94
+ LiquidationPadding: "ratio";
95
+ LiquidationMargin: "ratio";
96
+ LiquidationPenalty: "ratio";
97
+ MintFee: "ratio";
98
+ }>;
99
+ };
100
+ export type VaultDirectorParams = import("@agoric/governance/src/contractGovernance/typedParamManager.js").ParamTypesMapFromRecord<ReturnType<typeof makeVaultDirectorParams>>;
101
+ export type VaultParamManager = ReturnType<typeof makeVaultParamManager>;
102
+ export type VaultManagerParamOverrides = VaultManagerParamValues & {
103
+ brand: Brand;
104
+ };
105
+ import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
106
+ /**
107
+ * @param {Amount<'set'>} electorateInvitationAmount
108
+ * @param {Amount<'nat'>} minInitialDebt
109
+ * @param {Amount<'set'>} shortfallInvitationAmount
110
+ * @param {string} referencedUi
111
+ * @param {InterestTiming} interestTiming
112
+ */
113
+ declare function makeVaultDirectorParams(electorateInvitationAmount: Amount<"set">, minInitialDebt: Amount<"nat">, shortfallInvitationAmount: Amount<"set">, referencedUi: string, interestTiming: InterestTiming): {
114
+ Electorate: {
115
+ type: "invitation";
116
+ value: import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key>;
117
+ };
118
+ MinInitialDebt: {
119
+ type: "amount";
120
+ value: import("@agoric/ertp/src/types.js").NatAmount;
121
+ };
122
+ ShortfallInvitation: {
123
+ type: "invitation";
124
+ value: import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key>;
125
+ };
126
+ ReferencedUI: {
127
+ type: "string";
128
+ value: string;
129
+ };
130
+ ChargingPeriod: {
131
+ type: "nat";
132
+ value: bigint;
133
+ };
134
+ RecordingPeriod: {
135
+ type: "nat";
136
+ value: bigint;
137
+ };
138
+ };
139
+ export {};
140
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAiBA,8HAA8H;AAE9H,mDAAoD;AACpD,qDAAsD;AAEtD,yCAA0C;AAC1C,yDAA0D;AAC1D,2DAA4D;AAC5D,2DAA4D;AAC5D,+CAAgD;AAChD,qCAAsC;AACtC,oDAAqD;AACrD,6DAA8D;AAC9D,+CAAgD;;;;;;;AAkEzC,oDAHI,OAAO,kBAAkB,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,oGAC1E,uBAAuB;;;;;;;GAoB9B;AACJ,4EAA4E;AAE5E,iEAYE;AAeK,8MAZI;IACV,0BAA8B,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,cAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,qBAAyB,EAAE,MAAM,CAAC;IAClC,cAAkB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IACzC,KAAS,EAAE,IAAI,CAAC,OAAO,cAAc,EAAE,YAAY,CAAC,CAAC;IACrD,kBAAsB,EAAE,uBAAuB,CAAC;IAChD,cAAkB,EAAE,cAAc,CAAC;IACnC,yBAA6B,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,YAAgB,CAAC,EAAE,MAAM,CAAC;CACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BH;AAeM,mDAJI,OAAO,kBAAkB,EAAE,OAAO,cAClC,IAAI,CAAC,UAAU,CAAC,yBAChB,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC;IA+CjD;;;;OAIG;2BAHQ,KAAK,eACL,WAAW,sBACX,uBAAuB;;;;;;;;IAOlC,2BAA2B;eAAf,KAAK;;;;;;;;EAKpB;kCAhKY,OAAO,gEAAgE,EAAE,uBAAuB,CAC5G,UAAgB,CAAC,OAAO,uBAAuB,CAAC,CAC3C;gCA8BQ,UAAU,CAAC,OAAO,qBAAqB,CAAC;yCAwDxC,uBAAuB,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE;oCA1JsC,4BAA4B;AAyB1H;;;;;;GAMG;AACH,qEANW,MAAM,CAAC,KAAK,CAAC,kBACb,MAAM,CAAC,KAAK,CAAC,6BACb,MAAM,CAAC,KAAK,CAAC,gBACb,MAAM,kBACN,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;EAgCxB"}
@@ -1,6 +1,6 @@
1
1
  // @jessie-check
2
2
 
3
- import './types.js';
3
+ /// <reference path="./types-ambient.js" />
4
4
 
5
5
  import {
6
6
  CONTRACT_ELECTORATE,
@@ -12,8 +12,11 @@ import { M, makeScalarMapStore } from '@agoric/store';
12
12
  import { TimeMath } from '@agoric/time';
13
13
  import { provideDurableMapStore } from '@agoric/vat-data';
14
14
  import { subtractRatios } from '@agoric/zoe/src/contractSupport/ratio.js';
15
+ import { makeTracer } from '@agoric/internal/src/index.js';
15
16
  import { amountPattern, ratioPattern } from '../contractSupport.js';
16
17
 
18
+ /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
19
+
17
20
  export const CHARGING_PERIOD_KEY = 'ChargingPeriod';
18
21
  export const RECORDING_PERIOD_KEY = 'RecordingPeriod';
19
22
 
@@ -35,6 +38,8 @@ export const vaultDirectorParamTypes = {
35
38
  };
36
39
  harden(vaultDirectorParamTypes);
37
40
 
41
+ const trace = makeTracer('Vault Params');
42
+
38
43
  /**
39
44
  * @param {Amount<'set'>} electorateInvitationAmount
40
45
  * @param {Amount<'nat'>} minInitialDebt
@@ -75,7 +80,11 @@ const makeVaultDirectorParams = (
75
80
  };
76
81
  harden(makeVaultDirectorParams);
77
82
 
78
- /** @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager').ParamTypesMapFromRecord<ReturnType<typeof makeVaultDirectorParams>>} VaultDirectorParams */
83
+ /**
84
+ * @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager.js').ParamTypesMapFromRecord<
85
+ * ReturnType<typeof makeVaultDirectorParams>
86
+ * >} VaultDirectorParams
87
+ */
79
88
 
80
89
  /** @type {(liquidationMargin: Ratio) => Ratio} */
81
90
  const zeroRatio = liquidationMargin =>
@@ -122,20 +131,18 @@ export const vaultParamPattern = M.splitRecord(
122
131
 
123
132
  /**
124
133
  * @param {{
125
- * auctioneerPublicFacet: ERef<AuctioneerPublicFacet>,
126
- * electorateInvitationAmount: Amount<'set'>,
127
- * minInitialDebt: Amount<'nat'>,
128
- * bootstrapPaymentValue: bigint,
129
- * priceAuthority: ERef<PriceAuthority>,
130
- * timer: ERef<import('@agoric/time/src/types').TimerService>,
131
- * reservePublicFacet: AssetReservePublicFacet,
132
- * interestTiming: InterestTiming,
133
- * shortfallInvitationAmount: Amount<'set'>,
134
- * referencedUi?: string,
134
+ * electorateInvitationAmount: Amount<'set'>;
135
+ * minInitialDebt: Amount<'nat'>;
136
+ * bootstrapPaymentValue: bigint;
137
+ * priceAuthority: ERef<PriceAuthority>;
138
+ * timer: ERef<import('@agoric/time').TimerService>;
139
+ * reservePublicFacet: AssetReservePublicFacet;
140
+ * interestTiming: InterestTiming;
141
+ * shortfallInvitationAmount: Amount<'set'>;
142
+ * referencedUi?: string;
135
143
  * }} opts
136
144
  */
137
145
  export const makeGovernedTerms = ({
138
- auctioneerPublicFacet,
139
146
  bootstrapPaymentValue,
140
147
  electorateInvitationAmount,
141
148
  interestTiming,
@@ -147,7 +154,6 @@ export const makeGovernedTerms = ({
147
154
  referencedUi = 'NO REFERENCE',
148
155
  }) => {
149
156
  return harden({
150
- auctioneerPublicFacet,
151
157
  priceAuthority,
152
158
  reservePublicFacet,
153
159
  timerService: timer,
@@ -162,21 +168,34 @@ export const makeGovernedTerms = ({
162
168
  });
163
169
  };
164
170
  harden(makeGovernedTerms);
171
+
172
+ /** @typedef {VaultManagerParamValues & { brand: Brand }} VaultManagerParamOverrides */
173
+
165
174
  /**
166
- * Stop-gap which restores initial param values
167
- * UNTIL https://github.com/Agoric/agoric-sdk/issues/5200
175
+ * Stop-gap which restores initial param values UNTIL
176
+ * https://github.com/Agoric/agoric-sdk/issues/5200
168
177
  *
169
178
  * NB: changes from initial values will be lost upon restart
170
179
  *
171
180
  * @param {import('@agoric/vat-data').Baggage} baggage
172
181
  * @param {ERef<Marshaller>} marshaller
182
+ * @param {Record<string, VaultManagerParamOverrides>} managerParamOverrides
173
183
  */
174
- export const provideVaultParamManagers = (baggage, marshaller) => {
184
+ export const provideVaultParamManagers = (
185
+ baggage,
186
+ marshaller,
187
+ managerParamOverrides,
188
+ ) => {
175
189
  /** @type {MapStore<Brand, VaultParamManager>} */
176
190
  const managers = makeScalarMapStore();
177
191
 
178
192
  // the managers aren't durable but their arguments are
179
- /** @type {MapStore<Brand, {storageNode: StorageNode, initialParamValues: VaultManagerParamValues}>} */
193
+ /**
194
+ * @type {MapStore<
195
+ * Brand,
196
+ * { storageNode: StorageNode; initialParamValues: VaultManagerParamValues }
197
+ * >}
198
+ */
180
199
  const managerArgs = provideDurableMapStore(
181
200
  baggage,
182
201
  'vault param manager parts',
@@ -191,12 +210,23 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
191
210
  return manager;
192
211
  };
193
212
 
194
- // restore from baggage
195
- [...managerArgs.entries()].map(([brand, args]) => makeManager(brand, args));
213
+ // restore from baggage, unless `managerParamOverrides` overrides.
214
+ for (const [brand, args] of managerArgs.entries()) {
215
+ const newInitial = managerParamOverrides
216
+ ? Object.values(managerParamOverrides).find(e => e.brand === brand)
217
+ : undefined;
218
+
219
+ if (newInitial) {
220
+ trace(`reviving params, override`, brand, newInitial);
221
+ makeManager(brand, { ...args, initialParamValues: newInitial });
222
+ } else {
223
+ trace(`reviving params, keeping`, brand, args.initialParamValues);
224
+ makeManager(brand, args);
225
+ }
226
+ }
196
227
 
197
228
  return {
198
229
  /**
199
- *
200
230
  * @param {Brand} brand
201
231
  * @param {StorageNode} storageNode
202
232
  * @param {VaultManagerParamValues} initialParamValues
@@ -206,9 +236,7 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
206
236
  managerArgs.init(brand, args);
207
237
  return makeManager(brand, args);
208
238
  },
209
- /**
210
- * @param {Brand} brand
211
- */
239
+ /** @param {Brand} brand */
212
240
  get(brand) {
213
241
  return managers.get(brand);
214
242
  },