@agoric/inter-protocol 0.16.2-dev-5dc325b.0 → 0.16.2-getting-started-dev-d127d1d.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 (162) hide show
  1. package/CHANGELOG.md +1057 -0
  2. package/package.json +30 -37
  3. package/scripts/add-collateral-core.js +112 -0
  4. package/scripts/build-bundles.js +21 -5
  5. package/scripts/deploy-contracts.js +100 -0
  6. package/scripts/init-core.js +198 -0
  7. package/scripts/invite-committee-core.js +42 -0
  8. package/scripts/manual-price-feed.js +117 -0
  9. package/scripts/price-feed-core.js +104 -0
  10. package/scripts/start-local-chain.sh +84 -0
  11. package/src/auction/auctionBook.js +59 -74
  12. package/src/auction/auctioneer.js +44 -56
  13. package/src/auction/offerBook.js +11 -12
  14. package/src/auction/params.js +5 -3
  15. package/src/auction/scheduleMath.js +13 -13
  16. package/src/auction/scheduler.js +39 -47
  17. package/src/auction/sortedOffers.js +7 -8
  18. package/src/auction/util.js +4 -4
  19. package/src/clientSupport.js +96 -154
  20. package/src/contractSupport.js +5 -5
  21. package/src/econCommitteeCharter.js +17 -18
  22. package/src/feeDistributor.js +33 -34
  23. package/src/interest.js +14 -20
  24. package/src/price/README.md +0 -13
  25. package/src/price/fluxAggregatorContract.js +53 -59
  26. package/src/price/fluxAggregatorKit.js +33 -48
  27. package/src/price/priceOracleKit.js +13 -11
  28. package/src/price/roundsManager.js +64 -52
  29. package/src/proposals/addAssetToVault.js +36 -170
  30. package/src/proposals/committee-proposal.js +27 -21
  31. package/src/proposals/core-proposal.js +7 -7
  32. package/src/proposals/econ-behaviors.js +32 -57
  33. package/src/proposals/price-feed-proposal.js +36 -71
  34. package/src/proposals/startEconCommittee.js +1 -1
  35. package/src/proposals/startPSM.js +22 -32
  36. package/src/proposals/utils.js +7 -32
  37. package/src/psm/psm.js +63 -69
  38. package/src/reserve/assetReserve.js +18 -27
  39. package/src/reserve/assetReserveKit.js +22 -14
  40. package/src/typeGuards.js +13 -0
  41. package/src/vaultFactory/liquidation.js +17 -30
  42. package/src/vaultFactory/math.js +9 -8
  43. package/src/vaultFactory/orderedVaultStore.js +9 -6
  44. package/src/vaultFactory/params.js +19 -25
  45. package/src/vaultFactory/prioritizedVaults.js +2 -2
  46. package/src/vaultFactory/proceeds.js +18 -24
  47. package/src/vaultFactory/storeUtils.js +12 -8
  48. package/src/vaultFactory/type-imports.js +1 -1
  49. package/src/vaultFactory/types.js +28 -38
  50. package/src/vaultFactory/vault.js +89 -88
  51. package/src/vaultFactory/vaultDirector.js +44 -35
  52. package/src/vaultFactory/vaultFactory.js +26 -33
  53. package/src/vaultFactory/vaultHolder.js +13 -8
  54. package/src/vaultFactory/vaultKit.js +2 -3
  55. package/src/vaultFactory/vaultManager.js +120 -138
  56. package/src/auction/auctionBook.d.ts +0 -83
  57. package/src/auction/auctionBook.d.ts.map +0 -1
  58. package/src/auction/auctioneer.d.ts +0 -75
  59. package/src/auction/auctioneer.d.ts.map +0 -1
  60. package/src/auction/offerBook.d.ts +0 -72
  61. package/src/auction/offerBook.d.ts.map +0 -1
  62. package/src/auction/params.d.ts +0 -142
  63. package/src/auction/params.d.ts.map +0 -1
  64. package/src/auction/scheduleMath.d.ts +0 -4
  65. package/src/auction/scheduleMath.d.ts.map +0 -1
  66. package/src/auction/scheduler.d.ts +0 -49
  67. package/src/auction/scheduler.d.ts.map +0 -1
  68. package/src/auction/sortedOffers.d.ts +0 -8
  69. package/src/auction/sortedOffers.d.ts.map +0 -1
  70. package/src/auction/util.d.ts +0 -30
  71. package/src/auction/util.d.ts.map +0 -1
  72. package/src/clientSupport.d.ts +0 -167
  73. package/src/clientSupport.d.ts.map +0 -1
  74. package/src/collectFees.d.ts +0 -2
  75. package/src/collectFees.d.ts.map +0 -1
  76. package/src/contractSupport.d.ts +0 -33
  77. package/src/contractSupport.d.ts.map +0 -1
  78. package/src/econCommitteeCharter.d.ts +0 -41
  79. package/src/econCommitteeCharter.d.ts.map +0 -1
  80. package/src/feeDistributor.d.ts +0 -212
  81. package/src/feeDistributor.d.ts.map +0 -1
  82. package/src/index.d.ts +0 -2
  83. package/src/index.d.ts.map +0 -1
  84. package/src/interest-math.d.ts +0 -3
  85. package/src/interest-math.d.ts.map +0 -1
  86. package/src/interest.d.ts +0 -29
  87. package/src/interest.d.ts.map +0 -1
  88. package/src/price/fluxAggregatorContract.d.ts +0 -112
  89. package/src/price/fluxAggregatorContract.d.ts.map +0 -1
  90. package/src/price/fluxAggregatorKit.d.ts +0 -155
  91. package/src/price/fluxAggregatorKit.d.ts.map +0 -1
  92. package/src/price/priceOracleKit.d.ts +0 -52
  93. package/src/price/priceOracleKit.d.ts.map +0 -1
  94. package/src/price/roundsManager.d.ts +0 -330
  95. package/src/price/roundsManager.d.ts.map +0 -1
  96. package/src/proposals/addAssetToVault.d.ts +0 -160
  97. package/src/proposals/addAssetToVault.d.ts.map +0 -1
  98. package/src/proposals/committee-proposal.d.ts +0 -113
  99. package/src/proposals/committee-proposal.d.ts.map +0 -1
  100. package/src/proposals/core-proposal.d.ts +0 -149
  101. package/src/proposals/core-proposal.d.ts.map +0 -1
  102. package/src/proposals/econ-behaviors.d.ts +0 -201
  103. package/src/proposals/econ-behaviors.d.ts.map +0 -1
  104. package/src/proposals/price-feed-proposal.d.ts +0 -82
  105. package/src/proposals/price-feed-proposal.d.ts.map +0 -1
  106. package/src/proposals/startEconCommittee.d.ts +0 -34
  107. package/src/proposals/startEconCommittee.d.ts.map +0 -1
  108. package/src/proposals/startPSM.d.ts +0 -61
  109. package/src/proposals/startPSM.d.ts.map +0 -1
  110. package/src/proposals/utils.d.ts +0 -17
  111. package/src/proposals/utils.d.ts.map +0 -1
  112. package/src/provisionPool.d.ts +0 -165
  113. package/src/provisionPool.d.ts.map +0 -1
  114. package/src/provisionPool.js +0 -119
  115. package/src/provisionPoolKit.d.ts +0 -379
  116. package/src/provisionPoolKit.d.ts.map +0 -1
  117. package/src/provisionPoolKit.js +0 -461
  118. package/src/psm/psm.d.ts +0 -178
  119. package/src/psm/psm.d.ts.map +0 -1
  120. package/src/psm/types.d.ts +0 -2
  121. package/src/psm/types.d.ts.map +0 -1
  122. package/src/reserve/assetReserve.d.ts +0 -44
  123. package/src/reserve/assetReserve.d.ts.map +0 -1
  124. package/src/reserve/assetReserveKit.d.ts +0 -114
  125. package/src/reserve/assetReserveKit.d.ts.map +0 -1
  126. package/src/reserve/params.d.ts +0 -10
  127. package/src/reserve/params.d.ts.map +0 -1
  128. package/src/tokens.d.ts +0 -3
  129. package/src/tokens.d.ts.map +0 -1
  130. package/src/tokens.js +0 -5
  131. package/src/vaultFactory/burn.d.ts +0 -2
  132. package/src/vaultFactory/burn.d.ts.map +0 -1
  133. package/src/vaultFactory/liquidation.d.ts +0 -24
  134. package/src/vaultFactory/liquidation.d.ts.map +0 -1
  135. package/src/vaultFactory/math.d.ts +0 -10
  136. package/src/vaultFactory/math.d.ts.map +0 -1
  137. package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
  138. package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
  139. package/src/vaultFactory/params.d.ts +0 -159
  140. package/src/vaultFactory/params.d.ts.map +0 -1
  141. package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
  142. package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
  143. package/src/vaultFactory/proceeds.d.ts +0 -34
  144. package/src/vaultFactory/proceeds.d.ts.map +0 -1
  145. package/src/vaultFactory/storeUtils.d.ts +0 -25
  146. package/src/vaultFactory/storeUtils.d.ts.map +0 -1
  147. package/src/vaultFactory/type-imports.d.ts +0 -2
  148. package/src/vaultFactory/type-imports.d.ts.map +0 -1
  149. package/src/vaultFactory/types.d.ts +0 -137
  150. package/src/vaultFactory/types.d.ts.map +0 -1
  151. package/src/vaultFactory/vault.d.ts +0 -529
  152. package/src/vaultFactory/vault.d.ts.map +0 -1
  153. package/src/vaultFactory/vaultDirector.d.ts +0 -560
  154. package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
  155. package/src/vaultFactory/vaultFactory.d.ts +0 -162
  156. package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
  157. package/src/vaultFactory/vaultHolder.d.ts +0 -201
  158. package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
  159. package/src/vaultFactory/vaultKit.d.ts +0 -32
  160. package/src/vaultFactory/vaultKit.d.ts.map +0 -1
  161. package/src/vaultFactory/vaultManager.d.ts +0 -554
  162. package/src/vaultFactory/vaultManager.d.ts.map +0 -1
@@ -10,6 +10,7 @@ const { Fail } = assert;
10
10
  */
11
11
  export const reserveThenGetNamePaths = async (nameAdmin, paths) => {
12
12
  /**
13
+ *
13
14
  * @param {ERef<import('@agoric/vats').NameAdmin>} nextAdmin
14
15
  * @param {string[]} path
15
16
  */
@@ -53,7 +54,7 @@ export const reserveThenGetNames = async (nameAdmin, names) =>
53
54
  * @param {string} debugName
54
55
  * @param {ERef<import('@agoric/vats').NameAdmin>} namesByAddressAdmin
55
56
  * @param {string} addr
56
- * @param {ERef<Payment>[]} payments
57
+ * @param {Array<ERef<Payment>>} payments
57
58
  */
58
59
  export const reserveThenDeposit = async (
59
60
  debugName,
@@ -78,15 +79,7 @@ export const reserveThenDeposit = async (
78
79
  );
79
80
  };
80
81
 
81
- /**
82
- * @type {<T>(
83
- * store: ERef<
84
- * Map<string, T> | import('@agoric/internal/src/scratch.js').ScratchPad
85
- * >,
86
- * key: string,
87
- * make: () => T,
88
- * ) => Promise<T>}
89
- */
82
+ /** @type {<T>(store: ERef<Map<string, T> | import('@agoric/internal/src/scratch.js').ScratchPad>, key: string, make: () => T) => Promise<T>} */
90
83
  const provideWhen = async (store, key, make) => {
91
84
  const found = await E(store).get(key);
92
85
  if (found) {
@@ -98,33 +91,21 @@ const provideWhen = async (store, key, make) => {
98
91
  };
99
92
 
100
93
  /**
101
- * @param {{
102
- * scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad>;
103
- * }} homeP
94
+ * @param {{ scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad> }} homeP
104
95
  * @param {object} opts
105
- * @param {(specifier: string) => Promise<{ default: Bundle }>} opts.loadBundle
96
+ * @param {(specifier: string) => Promise<{default: Bundle}>} opts.loadBundle
106
97
  * @param {string} [opts.installCacheKey]
107
98
  */
108
99
  export const makeInstallCache = async (
109
100
  homeP,
110
101
  { installCacheKey = 'installCache', loadBundle },
111
102
  ) => {
112
- /**
113
- * @type {CopyMap<
114
- * string,
115
- * { installation: Installation; boardId: string; path?: string }
116
- * >}
117
- */
103
+ /** @type {CopyMap<string, {installation: Installation, boardId: string, path?: string}>} */
118
104
  const initial = await provideWhen(E.get(homeP).scratch, installCacheKey, () =>
119
105
  makeCopyMap([]),
120
106
  );
121
107
  // ISSUE: getCopyMapEntries of CopyMap<K, V> loses K, V.
122
- /**
123
- * @type {Map<
124
- * string,
125
- * { installation: Installation; boardId: string; path?: string }
126
- * >}
127
- */
108
+ /** @type {Map<string, {installation: Installation, boardId: string, path?: string}>} */
128
109
  const working = new Map(getCopyMapEntries(initial));
129
110
 
130
111
  const saveCache = async () => {
@@ -156,9 +137,3 @@ export const makeInstallCache = async (
156
137
 
157
138
  return { wrapInstall, saveCache };
158
139
  };
159
-
160
- export const oracleBrandFeedName = (inBrandName, outBrandName) =>
161
- `${inBrandName}-${outBrandName} price feed`;
162
-
163
- export const scaledPriceFeedName = issuerName =>
164
- `scaledPriceAuthority-${issuerName}`;
package/src/psm/psm.js CHANGED
@@ -41,86 +41,80 @@ const { Fail } = assert;
41
41
 
42
42
  /**
43
43
  * @file The Parity Stability Module supports efficiently minting/burning a
44
- * stable token at a specified fixed ratio to a reference stable token, which
45
- * thereby acts as an anchor to provide additional stability. For flexible
46
- * economic policies, the fee percentage for trading into and out of the
47
- * stable token are specified separately.
44
+ * stable token at a specified fixed ratio to a reference stable token, which
45
+ * thereby acts as an anchor to provide additional stability. For flexible
46
+ * economic policies, the fee percentage for trading into and out of the stable
47
+ * token are specified separately.
48
48
  */
49
49
 
50
50
  /**
51
- * @typedef {object} MetricsNotification Metrics naming scheme is that nouns are
52
- * present values and past-participles are accumulative.
53
- * @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token available
54
- * to be swapped
55
- * @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
56
- * outstanding (the amount minted minus the amount burned).
57
- * @property {Amount<'nat'>} feePoolBalance amount of Minted token fees
58
- * available to be collected
59
- * @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor ever
60
- * given by this contract
61
- * @property {Amount<'nat'>} totalMintedProvided running sum of Minted ever
62
- * given by this contract
51
+ * @typedef {object} MetricsNotification
52
+ * Metrics naming scheme is that nouns are present values and past-participles
53
+ * are accumulative.
54
+ *
55
+ * @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token
56
+ * available to be swapped
57
+ * @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
58
+ * outstanding (the amount minted minus the amount burned).
59
+ * @property {Amount<'nat'>} feePoolBalance amount of Minted token
60
+ * fees available to be collected
61
+ *
62
+ * @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor
63
+ * ever given by this contract
64
+ * @property {Amount<'nat'>} totalMintedProvided running sum of Minted
65
+ * ever given by this contract
63
66
  */
64
67
 
65
68
  /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
66
69
 
67
- /** @type {ContractMeta} */
68
- export const meta = {
69
- upgradability: 'canUpgrade',
70
- customTermsShape: {
71
- anchorBrand: BrandShape,
72
- anchorPerMinted: RatioShape,
73
- electionManager: InstanceHandleShape,
74
- governedParams: {
75
- [CONTRACT_ELECTORATE]: {
76
- type: ParamTypes.INVITATION,
77
- value: AmountShape,
78
- },
79
- WantMintedFee: {
80
- type: ParamTypes.RATIO,
81
- value: RatioShape,
82
- },
83
- GiveMintedFee: {
84
- type: ParamTypes.RATIO,
85
- value: RatioShape,
86
- },
87
- MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
70
+ export const customTermsShape = {
71
+ anchorBrand: BrandShape,
72
+ anchorPerMinted: RatioShape,
73
+ electionManager: InstanceHandleShape,
74
+ governedParams: {
75
+ [CONTRACT_ELECTORATE]: {
76
+ type: ParamTypes.INVITATION,
77
+ value: AmountShape,
88
78
  },
89
- },
90
- privateArgsShape: M.splitRecord(
91
- {
92
- marshaller: M.remotable('Marshaller'),
93
- storageNode: StorageNodeShape,
79
+ WantMintedFee: {
80
+ type: ParamTypes.RATIO,
81
+ value: RatioShape,
94
82
  },
95
- {
96
- // only necessary on first invocation, not subsequent
97
- feeMintAccess: FeeMintAccessShape,
98
- initialPoserInvitation: InvitationShape,
83
+ GiveMintedFee: {
84
+ type: ParamTypes.RATIO,
85
+ value: RatioShape,
99
86
  },
100
- ),
87
+ MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
88
+ },
101
89
  };
102
- harden(meta);
90
+ harden(customTermsShape);
91
+
92
+ export const privateArgsShape = M.splitRecord(
93
+ harden({
94
+ marshaller: M.remotable('Marshaller'),
95
+ storageNode: StorageNodeShape,
96
+ }),
97
+ harden({
98
+ // only necessary on first invocation, not subsequent
99
+ feeMintAccess: FeeMintAccessShape,
100
+ initialPoserInvitation: InvitationShape,
101
+ }),
102
+ );
103
+ harden(privateArgsShape);
103
104
 
104
105
  /**
105
- * @param {ZCF<
106
- * GovernanceTerms<{
107
- * GiveMintedFee: 'ratio';
108
- * WantMintedFee: 'ratio';
109
- * MintLimit: 'amount';
106
+ * @param {ZCF<GovernanceTerms<{
107
+ * GiveMintedFee: 'ratio',
108
+ * WantMintedFee: 'ratio',
109
+ * MintLimit: 'amount',
110
110
  * }> & {
111
- * anchorBrand: Brand<'nat'>;
112
- * anchorPerMinted: Ratio;
113
- * }
114
- * >} zcf
115
- * @param {{
116
- * feeMintAccess: FeeMintAccess;
117
- * initialPoserInvitation: Invitation;
118
- * storageNode: StorageNode;
119
- * marshaller: Marshaller;
120
- * }} privateArgs
111
+ * anchorBrand: Brand<'nat'>,
112
+ * anchorPerMinted: Ratio,
113
+ * }>} zcf
114
+ * @param {{feeMintAccess: FeeMintAccess, initialPoserInvitation: Invitation, storageNode: StorageNode, marshaller: Marshaller}} privateArgs
121
115
  * @param {Baggage} baggage
122
116
  */
123
- export const start = async (zcf, privateArgs, baggage) => {
117
+ export const prepare = async (zcf, privateArgs, baggage) => {
124
118
  const { anchorBrand, anchorPerMinted } = zcf.getTerms();
125
119
  console.log('PSM Starting', anchorBrand, anchorPerMinted);
126
120
 
@@ -237,7 +231,9 @@ export const start = async (zcf, privateArgs, baggage) => {
237
231
  updateMetrics();
238
232
  };
239
233
 
240
- /** @param {Amount<'nat'>} toMint */
234
+ /**
235
+ * @param {Amount<'nat'>} toMint
236
+ */
241
237
  const assertUnderLimit = toMint => {
242
238
  const mintedAfter = AmountMath.add(
243
239
  baggage.get('mintedPoolBalance'),
@@ -266,8 +262,7 @@ export const start = async (zcf, privateArgs, baggage) => {
266
262
  /**
267
263
  * @param {ZCFSeat} seat
268
264
  * @param {Amount<'nat'>} given
269
- * @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange
270
- * rate minus fees)
265
+ * @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange rate minus fees)
271
266
  */
272
267
  const giveMinted = (seat, given, wanted = emptyAnchor) => {
273
268
  const fee = ceilMultiplyBy(given, params.getGiveMintedFee());
@@ -445,6 +440,5 @@ export const start = async (zcf, privateArgs, baggage) => {
445
440
  publicFacet,
446
441
  });
447
442
  };
448
- harden(start);
449
443
 
450
- /** @typedef {Awaited<ReturnType<typeof start>>['publicFacet']} PsmPublicFacet */
444
+ /** @typedef {Awaited<ReturnType<typeof prepare>>['publicFacet']} PsmPublicFacet */
@@ -10,42 +10,36 @@ import { prepareAssetReserveKit } from './assetReserveKit.js';
10
10
 
11
11
  const trace = makeTracer('AR', true);
12
12
 
13
- /** @type {ContractMeta} */
14
- export const meta = {
15
- upgradability: 'canUpgrade',
16
- };
17
- harden(meta);
18
-
19
13
  /**
20
14
  * @typedef {{
21
- * increaseLiquidationShortfall: (increase: Amount) => void;
22
- * reduceLiquidationShortfall: (reduction: Amount) => void;
15
+ * increaseLiquidationShortfall: (increase: Amount) => void
16
+ * reduceLiquidationShortfall: (reduction: Amount) => void
23
17
  * }} ShortfallReportingFacet
24
18
  */
25
19
 
26
20
  /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
27
21
 
28
22
  /**
29
- * Asset Reserve holds onto assets for the Inter Protocol, and can dispense it
30
- * for various purposes under governance control.
23
+ * Asset Reserve holds onto assets for the Inter Protocol, and can
24
+ * dispense it for various purposes under governance control.
31
25
  *
32
26
  * This contract has the ability to mint Fee tokens, granted through its private
33
27
  * arguments.
34
28
  *
35
- * @param {ZCF<
36
- * GovernanceTerms<{}> & {
37
- * governedApis: ['burnFeesToReduceShortfall'];
38
- * }
29
+ * @param {ZCF<GovernanceTerms<{}> &
30
+ * {
31
+ * governedApis: ['burnFeesToReduceShortfall'],
32
+ * }
39
33
  * >} zcf
40
34
  * @param {{
41
- * feeMintAccess: FeeMintAccess;
42
- * initialPoserInvitation: Invitation;
43
- * marshaller: ERef<Marshaller>;
44
- * storageNode: ERef<StorageNode>;
35
+ * feeMintAccess: FeeMintAccess,
36
+ * initialPoserInvitation: Invitation,
37
+ * marshaller: ERef<Marshaller>,
38
+ * storageNode: ERef<StorageNode>,
45
39
  * }} privateArgs
46
40
  * @param {Baggage} baggage
47
41
  */
48
- export const start = async (zcf, privateArgs, baggage) => {
42
+ export const prepare = async (zcf, privateArgs, baggage) => {
49
43
  trace('prepare', Object.keys(privateArgs), [...baggage.keys()]);
50
44
  // This contract mixes two styles of access to durable state. durableStores
51
45
  // are declared at the top level and referenced lexically. local state is
@@ -72,11 +66,11 @@ export const start = async (zcf, privateArgs, baggage) => {
72
66
  };
73
67
  trace('awaiting takeFeeMint');
74
68
  const feeMint = await takeFeeMint();
75
- const storageNode = await privateArgs.storageNode;
76
69
  const makeAssetReserveKit = await prepareAssetReserveKit(baggage, {
77
70
  feeMint,
78
71
  makeRecorderKit,
79
- storageNode,
72
+ // eslint-disable-next-line @jessie.js/no-nested-await -- spurious
73
+ storageNode: await privateArgs.storageNode,
80
74
  zcf,
81
75
  });
82
76
 
@@ -112,7 +106,7 @@ export const start = async (zcf, privateArgs, baggage) => {
112
106
  publicFacet: /** @type {any} */ (assetReserveKit.public),
113
107
  };
114
108
  };
115
- harden(start);
109
+ harden(prepare);
116
110
 
117
111
  /**
118
112
  * @typedef {object} ShortfallReporter
@@ -127,8 +121,5 @@ harden(start);
127
121
  * @property {() => Promise<Invitation<ShortfallReporter>>} makeShortfallReportingInvitation
128
122
  */
129
123
 
130
- /** @typedef {Awaited<ReturnType<typeof start>>['publicFacet']} AssetReservePublicFacet */
131
- /**
132
- * @typedef {Awaited<ReturnType<typeof start>>['creatorFacet']} AssetReserveCreatorFacet
133
- * the creator facet for the governor
134
- */
124
+ /** @typedef {Awaited<ReturnType<typeof prepare>>['publicFacet']} AssetReservePublicFacet */
125
+ /** @typedef {Awaited<ReturnType<typeof prepare>>['creatorFacet']} AssetReserveCreatorFacet the creator facet for the governor */
@@ -9,7 +9,7 @@ import {
9
9
  } from '@agoric/zoe/src/contractSupport/topics.js';
10
10
  import { AmountKeywordRecordShape } from '@agoric/zoe/src/typeGuards.js';
11
11
  import { E } from '@endo/eventual-send';
12
- import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
12
+ import { UnguardedHelperI } from '../typeGuards.js';
13
13
 
14
14
  const { quote: q } = assert;
15
15
 
@@ -17,6 +17,7 @@ const trace = makeTracer('ReserveKit', true);
17
17
 
18
18
  /**
19
19
  * @typedef {object} MetricsNotification
20
+ *
20
21
  * @property {AmountKeywordRecord} allocations
21
22
  * @property {Amount<'nat'>} shortfallBalance shortfall from liquidation that
22
23
  * has not yet been compensated.
@@ -27,11 +28,10 @@ const trace = makeTracer('ReserveKit', true);
27
28
  /**
28
29
  * @param {import('@agoric/vat-data').Baggage} baggage
29
30
  * @param {{
30
- * feeMint: ZCFMint<'nat'>;
31
- * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
32
- * storageNode: StorageNode;
33
- * zcf: ZCF;
34
- * }} powers
31
+ * feeMint: ZCFMint<'nat'>,
32
+ * makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit,
33
+ * storageNode: StorageNode,
34
+ * zcf: ZCF}} powers
35
35
  */
36
36
  export const prepareAssetReserveKit = async (
37
37
  baggage,
@@ -63,7 +63,10 @@ export const prepareAssetReserveKit = async (
63
63
  reduceLiquidationShortfall: M.call(AmountShape).returns(),
64
64
  }),
65
65
  },
66
- /** @param {StorageNode} metricsNode */
66
+ /**
67
+ *
68
+ * @param {StorageNode} metricsNode
69
+ */
67
70
  metricsNode => {
68
71
  /**
69
72
  * Used to look up the unique keyword for each brand, including Fee brand.
@@ -74,8 +77,7 @@ export const prepareAssetReserveKit = async (
74
77
  durable: true,
75
78
  });
76
79
  /**
77
- * Used to look up the brands for keywords, excluding Fee because it's a
78
- * special case.
80
+ * Used to look up the brands for keywords, excluding Fee because it's a special case.
79
81
  *
80
82
  * @type {MapStore<Keyword, Brand>}
81
83
  */
@@ -135,6 +137,7 @@ export const prepareAssetReserveKit = async (
135
137
  },
136
138
  governedApis: {
137
139
  /**
140
+ *
138
141
  * @param {Amount<'nat'>} reduction
139
142
  * @returns {void}
140
143
  */
@@ -202,11 +205,12 @@ export const prepareAssetReserveKit = async (
202
205
  },
203
206
  },
204
207
  /**
205
- * XXX missing governance public methods
206
- * https://github.com/Agoric/agoric-sdk/issues/5200
208
+ * XXX missing governance public methods https://github.com/Agoric/agoric-sdk/issues/5200
207
209
  */
208
210
  public: {
209
- /** Anyone can deposit any assets to the reserve */
211
+ /**
212
+ * Anyone can deposit any assets to the reserve
213
+ */
210
214
  makeAddCollateralInvitation() {
211
215
  /** @type {OfferHandler<Promise<string>>} */
212
216
  const handler = async seat => {
@@ -243,7 +247,9 @@ export const prepareAssetReserveKit = async (
243
247
  },
244
248
  },
245
249
  shortfallReportingFacet: {
246
- /** @param {Amount<'nat'>} shortfall */
250
+ /**
251
+ * @param {Amount<"nat">} shortfall
252
+ */
247
253
  increaseLiquidationShortfall(shortfall) {
248
254
  const { facets, state } = this;
249
255
  state.shortfallBalance = AmountMath.add(
@@ -254,7 +260,9 @@ export const prepareAssetReserveKit = async (
254
260
  },
255
261
 
256
262
  // currently exposed for testing. Maybe it only gets called internally?
257
- /** @param {Amount<'nat'>} reduction */
263
+ /**
264
+ * @param {Amount<"nat">} reduction
265
+ */
258
266
  reduceLiquidationShortfall(reduction) {
259
267
  const { state } = this;
260
268
  if (AmountMath.isGTE(reduction, state.shortfallBalance)) {
@@ -0,0 +1,13 @@
1
+ // @jessie-check
2
+
3
+ import { M } from '@agoric/store';
4
+
5
+ /**
6
+ * To be used only for 'helper' facets where the calls are from trusted code.
7
+ */
8
+ export const UnguardedHelperI = M.interface(
9
+ 'helper',
10
+ {},
11
+ // not exposed so sloppy okay
12
+ { sloppy: true },
13
+ );
@@ -22,8 +22,7 @@ const makeCancelToken = makeCancelTokenMaker('liq');
22
22
 
23
23
  /**
24
24
  * 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
26
- * schedule
25
+ * all events and unset it. When auction params are changed, we'll restart the schedule
27
26
  *
28
27
  * @type {object | undefined}
29
28
  */
@@ -48,16 +47,15 @@ const cancelWakeups = timer => {
48
47
  };
49
48
 
50
49
  /**
51
- * Schedule wakeups for the _next_ auction round.
50
+ * Schedule wakeups for the *next* auction round.
52
51
  *
53
- * In practice, there are these cases to handle (with N as "live" and N+1 is
54
- * "next"):
52
+ * In practice, there are these cases to handle (with N as "live" and N+1 is "next"):
55
53
  *
56
- * | when (now within the range) | what |
57
- * | ------------------------------- | ---------------------------------------- |
58
- * | [start N, nominalStart N+1] | good: schedule normally the three wakers |
59
- * | (nominalStart N+1, endTime N+1] | recover: skip round N+1 and schedule N+2 |
60
- * | (endTime N+1, ∞) | give up: wait for repair by governance |
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 |
61
59
  *
62
60
  * @param {object} opts
63
61
  * @param {ERef<TimerService>} opts.timer
@@ -134,7 +132,7 @@ const setWakeups = ({
134
132
  };
135
133
 
136
134
  /**
137
- * Schedule wakeups for the _next_ auction round.
135
+ * Schedule wakeups for the *next* auction round.
138
136
  *
139
137
  * Called by vaultDirector's resetWakeupsForNextAuction at start() and every
140
138
  * time there's a "reschedule" wakeup.
@@ -187,7 +185,7 @@ harden(setWakeupsForNextAuction);
187
185
  /**
188
186
  * @param {Amount<'nat'>} debt
189
187
  * @param {Amount<'nat'>} minted
190
- * @returns {{ overage: Amount<'nat'>; shortfall: Amount<'nat'> }}
188
+ * @returns {{ overage: Amount<'nat'>, shortfall: Amount<'nat'>}}
191
189
  */
192
190
  export const liquidationResults = (debt, minted) => {
193
191
  if (AmountMath.isEmpty(minted)) {
@@ -242,21 +240,15 @@ export const watchForGovernanceChange = (
242
240
  * @param {PriceQuote} collateralizationDetails.quote
243
241
  * @param {Ratio} collateralizationDetails.interest
244
242
  * @param {Ratio} collateralizationDetails.margin
245
- * @param {ReturnType<
246
- * typeof import('./prioritizedVaults.js').makePrioritizedVaults
247
- * >} prioritizedVaults
243
+ * @param {ReturnType<typeof import('./prioritizedVaults.js').makePrioritizedVaults>} prioritizedVaults
248
244
  * @param {SetStore<Vault>} liquidatingVaults
249
245
  * @param {Brand<'nat'>} debtBrand
250
246
  * @param {Brand<'nat'>} collateralBrand
251
247
  * @returns {{
252
- * vaultData: MapStore<
253
- * Vault,
254
- * { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
255
- * >;
256
- * totalDebt: Amount<'nat'>;
257
- * totalCollateral: Amount<'nat'>;
258
- * liqSeat: ZCFSeat;
259
- * }}
248
+ * vaultData: MapStore<Vault, { collateralAmount: Amount<'nat'>, debtAmount: Amount<'nat'>}>,
249
+ * totalDebt: Amount<'nat'>,
250
+ * totalCollateral: Amount<'nat'>,
251
+ * liqSeat: ZCFSeat}}
260
252
  */
261
253
  export const getLiquidatableVaults = (
262
254
  zcf,
@@ -269,18 +261,13 @@ export const getLiquidatableVaults = (
269
261
  const vaultsToLiquidate = prioritizedVaults.removeVaultsBelow(
270
262
  collateralizationDetails,
271
263
  );
272
- /**
273
- * @type {MapStore<
274
- * Vault,
275
- * { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
276
- * >}
277
- */
264
+ /** @type {MapStore<Vault, { collateralAmount: Amount<'nat'>, debtAmount: Amount<'nat'>}>} */
278
265
  const vaultData = makeScalarMapStore();
279
266
 
280
267
  const { zcfSeat: liqSeat } = zcf.makeEmptySeatKit();
281
268
  let totalDebt = AmountMath.makeEmpty(debtBrand);
282
269
  let totalCollateral = AmountMath.makeEmpty(collateralBrand);
283
- /** @type {TransferPart[]} */
270
+ /** @type {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} */
284
271
  const transfers = [];
285
272
 
286
273
  for (const vault of vaultsToLiquidate.values()) {
@@ -1,8 +1,8 @@
1
1
  // @jessie-check
2
2
 
3
3
  /**
4
- * @file calculations specific to the Vault Factory contract See also
5
- * ../interest-math.js
4
+ * @file calculations specific to the Vault Factory contract
5
+ * See also ../interest-math.js
6
6
  */
7
7
 
8
8
  import { AmountMath } from '@agoric/ertp';
@@ -17,8 +17,8 @@ import { priceFrom } from '../auction/util.js';
17
17
  import { addSubtract } from '../contractSupport.js';
18
18
 
19
19
  /**
20
- * Calculate the minimum collateralization given the liquidation margin and the
21
- * "padding" from that liquidation threshold.
20
+ * Calculate the minimum collateralization given the liquidation margin and the "padding"
21
+ * from that liquidation threshold.
22
22
  *
23
23
  * @param {Ratio} liquidationMargin
24
24
  * @param {Ratio} liquidationPadding
@@ -74,10 +74,11 @@ export const maxDebtForVault = (
74
74
  };
75
75
 
76
76
  /**
77
- * Calculate the fee, the amount to mint and the resulting debt. The give and
78
- * the want together reflect a delta, where typically one is zero because they
79
- * come from the gave/want of an offer proposal. If the `want` is zero, the
80
- * `fee` will also be zero, so the simple math works.
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.
81
82
  *
82
83
  * @param {Amount<'nat'>} currentDebt
83
84
  * @param {Amount<'nat'>} give excess of currentDebt is returned in 'surplus'
@@ -3,20 +3,22 @@ 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
7
- * available.
6
+ * Designed to be replaceable by naked Collections API when composite keys are available.
8
7
  *
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.)
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.)
12
11
  */
13
12
 
14
13
  /** @typedef {import('./vault').Vault} Vault */
15
14
  /** @typedef {import('./storeUtils').CompositeKey} CompositeKey */
16
15
 
17
- /** @param {MapStore<string, Vault>} store */
16
+ /**
17
+ * @param {MapStore<string, Vault>} store
18
+ */
18
19
  export const makeOrderedVaultStore = store => {
19
20
  /**
21
+ *
20
22
  * @param {string} vaultId
21
23
  * @param {Vault} vault
22
24
  */
@@ -29,6 +31,7 @@ export const makeOrderedVaultStore = store => {
29
31
  };
30
32
 
31
33
  /**
34
+ *
32
35
  * @param {string} key
33
36
  * @returns {Vault}
34
37
  */