@agoric/inter-protocol 0.16.2-dev-57802f9.0 → 0.16.2-other-dev-70beeb7.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 (160) hide show
  1. package/CHANGELOG.md +1041 -0
  2. package/package.json +30 -33
  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 +32 -32
  17. package/src/auction/sortedOffers.js +7 -8
  18. package/src/auction/util.js +4 -4
  19. package/src/clientSupport.js +96 -152
  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/fluxAggregatorContract.js +45 -51
  25. package/src/price/fluxAggregatorKit.js +33 -48
  26. package/src/price/priceOracleKit.js +13 -11
  27. package/src/price/roundsManager.js +64 -52
  28. package/src/proposals/addAssetToVault.js +6 -15
  29. package/src/proposals/committee-proposal.js +27 -21
  30. package/src/proposals/core-proposal.js +7 -7
  31. package/src/proposals/econ-behaviors.js +32 -57
  32. package/src/proposals/price-feed-proposal.js +34 -66
  33. package/src/proposals/startEconCommittee.js +1 -1
  34. package/src/proposals/startPSM.js +22 -32
  35. package/src/proposals/utils.js +7 -26
  36. package/src/psm/psm.js +63 -69
  37. package/src/reserve/assetReserve.js +18 -27
  38. package/src/reserve/assetReserveKit.js +22 -14
  39. package/src/typeGuards.js +13 -0
  40. package/src/vaultFactory/liquidation.js +17 -30
  41. package/src/vaultFactory/math.js +9 -8
  42. package/src/vaultFactory/orderedVaultStore.js +9 -6
  43. package/src/vaultFactory/params.js +18 -24
  44. package/src/vaultFactory/prioritizedVaults.js +2 -2
  45. package/src/vaultFactory/proceeds.js +18 -24
  46. package/src/vaultFactory/storeUtils.js +12 -8
  47. package/src/vaultFactory/types.js +28 -38
  48. package/src/vaultFactory/vault.js +89 -88
  49. package/src/vaultFactory/vaultDirector.js +44 -35
  50. package/src/vaultFactory/vaultFactory.js +26 -33
  51. package/src/vaultFactory/vaultHolder.js +13 -8
  52. package/src/vaultFactory/vaultKit.js +2 -3
  53. package/src/vaultFactory/vaultManager.js +120 -138
  54. package/src/auction/auctionBook.d.ts +0 -83
  55. package/src/auction/auctionBook.d.ts.map +0 -1
  56. package/src/auction/auctioneer.d.ts +0 -75
  57. package/src/auction/auctioneer.d.ts.map +0 -1
  58. package/src/auction/offerBook.d.ts +0 -72
  59. package/src/auction/offerBook.d.ts.map +0 -1
  60. package/src/auction/params.d.ts +0 -142
  61. package/src/auction/params.d.ts.map +0 -1
  62. package/src/auction/scheduleMath.d.ts +0 -4
  63. package/src/auction/scheduleMath.d.ts.map +0 -1
  64. package/src/auction/scheduler.d.ts +0 -49
  65. package/src/auction/scheduler.d.ts.map +0 -1
  66. package/src/auction/sortedOffers.d.ts +0 -8
  67. package/src/auction/sortedOffers.d.ts.map +0 -1
  68. package/src/auction/util.d.ts +0 -30
  69. package/src/auction/util.d.ts.map +0 -1
  70. package/src/clientSupport.d.ts +0 -167
  71. package/src/clientSupport.d.ts.map +0 -1
  72. package/src/collectFees.d.ts +0 -2
  73. package/src/collectFees.d.ts.map +0 -1
  74. package/src/contractSupport.d.ts +0 -33
  75. package/src/contractSupport.d.ts.map +0 -1
  76. package/src/econCommitteeCharter.d.ts +0 -41
  77. package/src/econCommitteeCharter.d.ts.map +0 -1
  78. package/src/feeDistributor.d.ts +0 -212
  79. package/src/feeDistributor.d.ts.map +0 -1
  80. package/src/index.d.ts +0 -2
  81. package/src/index.d.ts.map +0 -1
  82. package/src/interest-math.d.ts +0 -3
  83. package/src/interest-math.d.ts.map +0 -1
  84. package/src/interest.d.ts +0 -29
  85. package/src/interest.d.ts.map +0 -1
  86. package/src/price/fluxAggregatorContract.d.ts +0 -112
  87. package/src/price/fluxAggregatorContract.d.ts.map +0 -1
  88. package/src/price/fluxAggregatorKit.d.ts +0 -155
  89. package/src/price/fluxAggregatorKit.d.ts.map +0 -1
  90. package/src/price/priceOracleKit.d.ts +0 -52
  91. package/src/price/priceOracleKit.d.ts.map +0 -1
  92. package/src/price/roundsManager.d.ts +0 -330
  93. package/src/price/roundsManager.d.ts.map +0 -1
  94. package/src/proposals/addAssetToVault.d.ts +0 -143
  95. package/src/proposals/addAssetToVault.d.ts.map +0 -1
  96. package/src/proposals/committee-proposal.d.ts +0 -113
  97. package/src/proposals/committee-proposal.d.ts.map +0 -1
  98. package/src/proposals/core-proposal.d.ts +0 -149
  99. package/src/proposals/core-proposal.d.ts.map +0 -1
  100. package/src/proposals/econ-behaviors.d.ts +0 -201
  101. package/src/proposals/econ-behaviors.d.ts.map +0 -1
  102. package/src/proposals/price-feed-proposal.d.ts +0 -82
  103. package/src/proposals/price-feed-proposal.d.ts.map +0 -1
  104. package/src/proposals/startEconCommittee.d.ts +0 -34
  105. package/src/proposals/startEconCommittee.d.ts.map +0 -1
  106. package/src/proposals/startPSM.d.ts +0 -61
  107. package/src/proposals/startPSM.d.ts.map +0 -1
  108. package/src/proposals/utils.d.ts +0 -15
  109. package/src/proposals/utils.d.ts.map +0 -1
  110. package/src/provisionPool.d.ts +0 -165
  111. package/src/provisionPool.d.ts.map +0 -1
  112. package/src/provisionPool.js +0 -119
  113. package/src/provisionPoolKit.d.ts +0 -379
  114. package/src/provisionPoolKit.d.ts.map +0 -1
  115. package/src/provisionPoolKit.js +0 -461
  116. package/src/psm/psm.d.ts +0 -178
  117. package/src/psm/psm.d.ts.map +0 -1
  118. package/src/psm/types.d.ts +0 -2
  119. package/src/psm/types.d.ts.map +0 -1
  120. package/src/reserve/assetReserve.d.ts +0 -44
  121. package/src/reserve/assetReserve.d.ts.map +0 -1
  122. package/src/reserve/assetReserveKit.d.ts +0 -114
  123. package/src/reserve/assetReserveKit.d.ts.map +0 -1
  124. package/src/reserve/params.d.ts +0 -10
  125. package/src/reserve/params.d.ts.map +0 -1
  126. package/src/tokens.d.ts +0 -3
  127. package/src/tokens.d.ts.map +0 -1
  128. package/src/tokens.js +0 -5
  129. package/src/vaultFactory/burn.d.ts +0 -2
  130. package/src/vaultFactory/burn.d.ts.map +0 -1
  131. package/src/vaultFactory/liquidation.d.ts +0 -24
  132. package/src/vaultFactory/liquidation.d.ts.map +0 -1
  133. package/src/vaultFactory/math.d.ts +0 -10
  134. package/src/vaultFactory/math.d.ts.map +0 -1
  135. package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
  136. package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
  137. package/src/vaultFactory/params.d.ts +0 -159
  138. package/src/vaultFactory/params.d.ts.map +0 -1
  139. package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
  140. package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
  141. package/src/vaultFactory/proceeds.d.ts +0 -34
  142. package/src/vaultFactory/proceeds.d.ts.map +0 -1
  143. package/src/vaultFactory/storeUtils.d.ts +0 -25
  144. package/src/vaultFactory/storeUtils.d.ts.map +0 -1
  145. package/src/vaultFactory/type-imports.d.ts +0 -2
  146. package/src/vaultFactory/type-imports.d.ts.map +0 -1
  147. package/src/vaultFactory/types.d.ts +0 -137
  148. package/src/vaultFactory/types.d.ts.map +0 -1
  149. package/src/vaultFactory/vault.d.ts +0 -529
  150. package/src/vaultFactory/vault.d.ts.map +0 -1
  151. package/src/vaultFactory/vaultDirector.d.ts +0 -560
  152. package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
  153. package/src/vaultFactory/vaultFactory.d.ts +0 -162
  154. package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
  155. package/src/vaultFactory/vaultHolder.d.ts +0 -201
  156. package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
  157. package/src/vaultFactory/vaultKit.d.ts +0 -32
  158. package/src/vaultFactory/vaultKit.d.ts.map +0 -1
  159. package/src/vaultFactory/vaultManager.d.ts +0 -554
  160. package/src/vaultFactory/vaultManager.d.ts.map +0 -1
package/src/interest.js CHANGED
@@ -12,7 +12,6 @@ import { TimeMath } from '@agoric/time';
12
12
 
13
13
  /**
14
14
  * @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
15
- *
16
15
  * @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
17
16
  */
18
17
 
@@ -21,7 +20,9 @@ const BASIS_POINTS = 10000;
21
20
  // single digit APR is less than a basis point per day.
22
21
  const LARGE_DENOMINATOR = BASIS_POINTS * BASIS_POINTS;
23
22
 
24
- /** Number chosen from 6 digits for a basis point, doubled for multiplication. */
23
+ /**
24
+ * Number chosen from 6 digits for a basis point, doubled for multiplication.
25
+ */
25
26
  const COMPOUNDED_INTEREST_DENOMINATOR = 10n ** 20n;
26
27
 
27
28
  /**
@@ -146,27 +147,20 @@ const validatedBrand = (mint, debt) => {
146
147
  * Charge interest accrued between `latestInterestUpdate` and `accruedUntil`.
147
148
  *
148
149
  * @param {{
149
- * mint: ZCFMint<'nat'>;
150
- * mintAndTransferWithFee: MintAndTransfer;
151
- * poolIncrementSeat: ZCFSeat;
152
- * seatAllocationKeyword: Keyword;
153
- * }} powers
150
+ * mint: ZCFMint<'nat'>,
151
+ * mintAndTransferWithFee: MintAndTransfer,
152
+ * poolIncrementSeat: ZCFSeat,
153
+ * seatAllocationKeyword: Keyword }} powers
154
154
  * @param {{
155
- * interestRate: Ratio;
156
- * chargingPeriod: RelativeTime;
157
- * recordingPeriod: RelativeTime;
158
- * }} params
155
+ * interestRate: Ratio,
156
+ * chargingPeriod: RelativeTime,
157
+ * recordingPeriod: RelativeTime}} params
159
158
  * @param {{
160
- * latestInterestUpdate: Timestamp;
161
- * compoundedInterest: Ratio;
162
- * totalDebt: Amount<'nat'>;
163
- * }} prior
159
+ * latestInterestUpdate: Timestamp,
160
+ * compoundedInterest: Ratio,
161
+ * totalDebt: Amount<'nat'>}} prior
164
162
  * @param {Timestamp} accruedUntil
165
- * @returns {{
166
- * compoundedInterest: Ratio;
167
- * latestInterestUpdate: Timestamp;
168
- * totalDebt: Amount<'nat'>;
169
- * }}
163
+ * @returns {{compoundedInterest: Ratio, latestInterestUpdate: Timestamp, totalDebt: Amount<'nat'> }}
170
164
  */
171
165
  export const chargeInterest = (powers, params, prior, accruedUntil) => {
172
166
  const brand = validatedBrand(powers.mint, prior.totalDebt);
@@ -18,56 +18,48 @@ import { prepareFluxAggregatorKit } from './fluxAggregatorKit.js';
18
18
  const trace = makeTracer('FluxAgg', false);
19
19
  /**
20
20
  * @typedef {import('@agoric/vat-data').Baggage} Baggage
21
- *
22
21
  * @typedef {import('@agoric/time/src/types').TimerService} TimerService
23
22
  */
24
23
 
25
- /** @type {ContractMeta} */
26
- export const meta = {
27
- privateArgsShape: M.splitRecord(
28
- {
29
- storageNode: StorageNodeShape,
30
- marshaller: M.eref(M.remotable('marshaller')),
31
- namesByAddressAdmin: M.any(),
32
- },
33
- {
34
- // always optional. XXX some code is including the key, set to null
35
- highPrioritySendersManager: M.or(
36
- M.remotable('prioritySenders manager'),
37
- M.null(),
38
- ),
39
- // only necessary on first invocation, not subsequent
40
- initialPoserInvitation: M.remotable('Invitation'),
41
- },
42
- ),
43
- upgradability: 'canUpgrade',
44
- };
45
- harden(meta);
24
+ export const privateArgsShape = M.splitRecord(
25
+ harden({
26
+ storageNode: StorageNodeShape,
27
+ marshaller: M.eref(M.remotable('marshaller')),
28
+ namesByAddressAdmin: M.any(),
29
+ }),
30
+ harden({
31
+ // always optional. XXX some code is including the key, set to null
32
+ highPrioritySendersManager: M.or(
33
+ M.remotable('prioritySenders manager'),
34
+ M.null(),
35
+ ),
36
+ // only necessary on first invocation, not subsequent
37
+ initialPoserInvitation: M.remotable('Invitation'),
38
+ }),
39
+ );
46
40
 
47
41
  /**
48
- * PriceAuthority for their median. Unlike the simpler `priceAggregator.js`,
49
- * this approximates the _Node Operator Aggregation_ logic of [Chainlink price
42
+ * PriceAuthority for their median. Unlike the simpler `priceAggregator.js`, this approximates
43
+ * the *Node Operator Aggregation* logic of [Chainlink price
50
44
  * feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
51
45
  *
52
- * @param {ZCF<
53
- * import('./fluxAggregatorKit.js').ChainlinkConfig & {
54
- * timer: TimerService;
55
- * brandIn: Brand<'nat'>;
56
- * brandOut: Brand<'nat'>;
57
- * description: string;
58
- * unitAmountIn?: Amount<'nat'>;
59
- * }
60
- * >} zcf
46
+ * @param {ZCF<import('./fluxAggregatorKit.js').ChainlinkConfig & {
47
+ * timer: TimerService,
48
+ * brandIn: Brand<'nat'>,
49
+ * brandOut: Brand<'nat'>,
50
+ * description: string,
51
+ * unitAmountIn?: Amount<'nat'>,
52
+ * }>} zcf
61
53
  * @param {{
62
- * highPrioritySendersManager?: import('@agoric/internal/src/priority-senders.js').PrioritySendersManager;
63
- * initialPoserInvitation: Invitation;
64
- * marshaller: ERef<Marshaller>;
65
- * namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>;
66
- * storageNode: StorageNode;
54
+ * highPrioritySendersManager?: import('@agoric/internal/src/priority-senders.js').PrioritySendersManager,
55
+ * initialPoserInvitation: Invitation,
56
+ * marshaller: ERef<Marshaller>,
57
+ * namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>,
58
+ * storageNode: StorageNode,
67
59
  * }} privateArgs
68
60
  * @param {Baggage} baggage
69
61
  */
70
- export const start = async (zcf, privateArgs, baggage) => {
62
+ export const prepare = async (zcf, privateArgs, baggage) => {
71
63
  trace('prepare with baggage keys', [...baggage.keys()]);
72
64
 
73
65
  // xxx uses contract baggage as issuerBagage, assumes one issuer in this contract
@@ -139,8 +131,10 @@ export const start = async (zcf, privateArgs, baggage) => {
139
131
  addr,
140
132
  [invitation],
141
133
  );
142
- await (highPrioritySendersManager &&
143
- E(highPrioritySendersManager).add(description, addr));
134
+ if (highPrioritySendersManager) {
135
+ // eslint-disable-next-line @jessie.js/no-nested-await -- after another await
136
+ await E(highPrioritySendersManager).add(description, addr);
137
+ }
144
138
  return `added ${addr}`;
145
139
  };
146
140
 
@@ -152,29 +146,29 @@ export const start = async (zcf, privateArgs, baggage) => {
152
146
  const removeOracle = async addr => {
153
147
  trace('removeOracle', addr);
154
148
  await E(faKit.creator).removeOracle(addr);
155
- await (highPrioritySendersManager &&
156
- E(highPrioritySendersManager).remove(description, addr));
149
+ if (highPrioritySendersManager) {
150
+ // eslint-disable-next-line @jessie.js/no-nested-await -- after another await
151
+ await E(highPrioritySendersManager).remove(description, addr);
152
+ }
157
153
  return `removed ${addr}`;
158
154
  };
159
155
 
160
156
  const governedApis = {
161
157
  /**
162
- * Add the specified oracles. May partially fail, such that some oracles are
163
- * added and others aren't.
158
+ * Add the specified oracles. May partially fail, such that some oracles are added and others aren't.
164
159
  *
165
160
  * @param {string[]} addrs
166
- * @returns {Promise<PromiseSettledResult<string>[]>}
161
+ * @returns {Promise<Array<PromiseSettledResult<string>>>}
167
162
  */
168
163
  addOracles: addrs => {
169
164
  return Promise.allSettled(addrs.map(addOracle));
170
165
  },
171
166
  /**
172
- * Remove the specified oracles. May partially fail, such that some oracles
173
- * are removed and others aren't. If the oracle was never part of the set
174
- * that's a PromiseRejectedResult
167
+ * Remove the specified oracles. May partially fail, such that some oracles are removed and others aren't.
168
+ * If the oracle was never part of the set that's a PromiseRejectedResult
175
169
  *
176
170
  * @param {string[]} addrs
177
- * @returns {Promise<PromiseSettledResult<string>[]>}
171
+ * @returns {Promise<Array<PromiseSettledResult<string>>>}
178
172
  */
179
173
  removeOracles: addrs => {
180
174
  return Promise.allSettled(addrs.map(removeOracle));
@@ -193,4 +187,4 @@ export const start = async (zcf, privateArgs, baggage) => {
193
187
  publicFacet: faKit.public,
194
188
  });
195
189
  };
196
- harden(start);
190
+ harden(prepare);
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @file Adaptation of Chainlink algorithm to the Agoric platform. Modeled on
3
- * https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.6/FluxAggregator.sol
4
- * (version?)
2
+ * @file
3
+ * Adaptation of Chainlink algorithm to the Agoric platform.
4
+ * Modeled on https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.6/FluxAggregator.sol (version?)
5
5
  */
6
6
  import { AmountMath } from '@agoric/ertp';
7
7
  import { assertAllDefined, makeTracer } from '@agoric/internal';
@@ -24,14 +24,10 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
24
24
 
25
25
  /**
26
26
  * @typedef {import('@agoric/vat-data').Baggage} Baggage
27
- *
28
27
  * @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
29
- *
30
- * @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime //
31
- * TODO: use RelativeTime, not RelativeTimeValue
32
- *
28
+ * @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
29
+ * // TODO: use RelativeTime, not RelativeTimeValue
33
30
  * @typedef {import('@agoric/time/src/types').RelativeTimeValue} RelativeTimeValue
34
- *
35
31
  * @typedef {import('@agoric/time/src/types').TimerService} TimerService
36
32
  */
37
33
 
@@ -53,35 +49,30 @@ const priceDescriptionFromQuote = quote => quote.quoteAmount.value[0];
53
49
  * @typedef {object} ChainlinkConfig
54
50
  * @property {number} maxSubmissionCount
55
51
  * @property {number} minSubmissionCount
56
- * @property {bigint} restartDelay the number of rounds an Oracle has to wait
57
- * before they can initiate a round
58
- * @property {number} minSubmissionValue an immutable check for a lower bound of
59
- * what submission values are accepted from an oracle
60
- * @property {number} maxSubmissionValue an immutable check for an upper bound
61
- * of what submission values are accepted from an oracle
62
- * @property {number} timeout the number of seconds after the previous round
63
- * that allowed to lapse before allowing an oracle to skip an unfinished
64
- * round
52
+ * @property {bigint} restartDelay the number of rounds an Oracle has to wait before they can initiate a round
53
+ * @property {number} minSubmissionValue an immutable check for a lower bound of what
54
+ * submission values are accepted from an oracle
55
+ * @property {number} maxSubmissionValue an immutable check for an upper bound of what
56
+ * submission values are accepted from an oracle
57
+ * @property {number} timeout the number of seconds after the previous round that
58
+ * allowed to lapse before allowing an oracle to skip an unfinished round
65
59
  */
66
60
 
67
61
  /**
68
- * Returns a maker for a single durable FluxAggregatorKit, closed over the
69
- * prepare() arguments.
62
+ * Returns a maker for a single durable FluxAggregatorKit, closed over the prepare() arguments.
70
63
  *
71
64
  * The kit aggregates price inputs to produce a PriceAuthority. Unlike the
72
- * simpler `priceAggregator.js`, this approximates the _Node Operator
73
- * Aggregation_ logic of [Chainlink price
65
+ * simpler `priceAggregator.js`, this approximates the *Node Operator
66
+ * Aggregation* logic of [Chainlink price
74
67
  * feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
75
68
  *
76
69
  * @param {Baggage} baggage
77
- * @param {ZCF<
78
- * ChainlinkConfig & {
79
- * timer: TimerService;
80
- * brandIn: Brand<'nat'>;
81
- * brandOut: Brand<'nat'>;
82
- * unitAmountIn?: Amount<'nat'>;
83
- * }
84
- * >} zcf
70
+ * @param {ZCF<ChainlinkConfig & {
71
+ * timer: TimerService,
72
+ * brandIn: Brand<'nat'>,
73
+ * brandOut: Brand<'nat'>,
74
+ * unitAmountIn?: Amount<'nat'>,
75
+ * }>} zcf
85
76
  * @param {TimerService} timerPresence
86
77
  * @param {import('./roundsManager.js').QuoteKit} quoteKit
87
78
  * @param {StorageNode} storageNode
@@ -137,10 +128,7 @@ export const prepareFluxAggregatorKit = async (
137
128
  // end of maker definitions /////////////////////////////////
138
129
 
139
130
  const { answerKit, latestRoundKit, priceKit } = await provideAll(baggage, {
140
- /**
141
- * This is just a signal that there's a new answer, which is read from
142
- * `lastValueOutForUnitIn`
143
- */
131
+ /** This is just a signal that there's a new answer, which is read from `lastValueOutForUnitIn` */
144
132
  answerKit: () => makeDurablePublishKit(),
145
133
  /** For publishing priceAuthority values to off-chain storage */
146
134
  priceKit: () =>
@@ -154,11 +142,9 @@ export const prepareFluxAggregatorKit = async (
154
142
  E.when(E(storageNode).makeChildNode('latestRound'), node =>
155
143
  makeRecorderKit(
156
144
  node,
157
- /**
158
- * @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<
159
- * import('./roundsManager.js').LatestRound
160
- * >}
161
- */ (M.any()),
145
+ /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<import('./roundsManager.js').LatestRound>} */ (
146
+ M.any()
147
+ ),
162
148
  ),
163
149
  ),
164
150
  });
@@ -237,9 +223,9 @@ export const prepareFluxAggregatorKit = async (
237
223
  * An "oracle invitation" is an invitation to be able to submit data to
238
224
  * include in the priceAggregator's results.
239
225
  *
240
- * The offer result from this invitation is a OracleAdmin, which can be
241
- * used directly to manage the price submissions as well as to terminate
242
- * the relationship.
226
+ * The offer result from this invitation is a OracleAdmin, which can be used
227
+ * directly to manage the price submissions as well as to terminate the
228
+ * relationship.
243
229
  *
244
230
  * @param {string} oracleId unique per contract instance
245
231
  */
@@ -249,13 +235,12 @@ export const prepareFluxAggregatorKit = async (
249
235
  /**
250
236
  * If custom arguments are supplied to the `zoe.offer` call, they can
251
237
  * indicate an OraclePriceSubmission notifier and a corresponding
252
- * `shiftValueOut` that should be adapted as part of the
253
- * priceAuthority's reported data.
238
+ * `shiftValueOut` that should be adapted as part of the priceAuthority's
239
+ * reported data.
254
240
  *
255
241
  * @param {ZCFSeat} seat
256
242
  */
257
243
  const offerHandler = async seat => {
258
- seat.exit();
259
244
  const { oracle } = await facets.creator.initOracle(oracleId);
260
245
  const invitationMakers = Far('invitation makers', {
261
246
  /** @param {import('./roundsManager.js').PriceRound} result */
@@ -270,6 +255,7 @@ export const prepareFluxAggregatorKit = async (
270
255
  );
271
256
  },
272
257
  });
258
+ seat.exit();
273
259
 
274
260
  return harden({
275
261
  invitationMakers,
@@ -313,9 +299,8 @@ export const prepareFluxAggregatorKit = async (
313
299
  },
314
300
 
315
301
  /**
316
- * a method to provide all current info oracleStatuses need. Intended
317
- * only only to be callable by oracleStatuses. Not for use by contracts
318
- * to read state.
302
+ * a method to provide all current info oracleStatuses need. Intended only
303
+ * only to be callable by oracleStatuses. Not for use by contracts to read state.
319
304
  *
320
305
  * @param {string} oracleId
321
306
  * @param {bigint} queriedRoundId
@@ -8,17 +8,14 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
8
8
 
9
9
  /**
10
10
  * @typedef {{
11
- * oracleId: string;
12
- * roundPowers: {
13
- * handlePush: (
14
- * status: OracleStatus,
15
- * result: import('./roundsManager.js').PriceRound,
16
- * ) => Promise<OracleStatus>;
17
- * };
11
+ * oracleId: string,
12
+ * roundPowers: { handlePush: (status: OracleStatus, result: import('./roundsManager.js').PriceRound) => Promise<OracleStatus> }
18
13
  * }} HeldParams
19
14
  */
20
15
 
21
- /** @typedef {{ roundId: number | undefined; unitPrice: NatValue }} PriceDatum */
16
+ /**
17
+ * @typedef {{ roundId: number | undefined, unitPrice: NatValue }} PriceDatum
18
+ */
22
19
 
23
20
  /**
24
21
  * @typedef {object} OracleStatus
@@ -29,9 +26,11 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
29
26
  * @property {string} oracleId
30
27
  */
31
28
  /**
32
- * @typedef {Readonly<HeldParams & {}>} ImmutableState
29
+ * @typedef {Readonly<HeldParams & {
30
+ * }>} ImmutableState
33
31
  *
34
- * @typedef {OracleStatus & {}} MutableState
32
+ * @typedef {OracleStatus & {
33
+ * }} MutableState
35
34
  */
36
35
  /** @typedef {ImmutableState & MutableState} State */
37
36
 
@@ -107,7 +106,10 @@ export const prepareOracleAdminKit = baggage =>
107
106
  state.lastStartedRound = result.lastStartedRound;
108
107
  state.latestSubmission = result.latestSubmission;
109
108
  },
110
- /** @returns {OracleStatus} */
109
+ /**
110
+ *
111
+ * @returns {OracleStatus}
112
+ */
111
113
  getStatus() {
112
114
  const { state } = this;
113
115
  return {
@@ -10,14 +10,13 @@ import {
10
10
  import { E } from '@endo/eventual-send';
11
11
  import { Far } from '@endo/marshal';
12
12
  import { isNat, Nat } from '@endo/nat';
13
- import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
13
+ import { UnguardedHelperI } from '../typeGuards.js';
14
14
 
15
15
  const { add, subtract, multiply, floorDivide, ceilDivide, isGTE } = natSafeMath;
16
16
 
17
17
  /** @typedef {import('./priceOracleKit.js').OracleStatus} OracleStatus */
18
18
  /**
19
19
  * @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
20
- *
21
20
  * @typedef {import('@agoric/time/src/types').TimerService} TimerService
22
21
  */
23
22
 
@@ -29,30 +28,34 @@ export const ROUND_MAX = BigInt(2 ** 32 - 1);
29
28
 
30
29
  const trace = makeTracer('RoundsM', false);
31
30
 
32
- /** @param {bigint} roundId */
31
+ /**
32
+ * @param {bigint} roundId
33
+ */
33
34
  const validRoundId = roundId => {
34
35
  return roundId <= ROUND_MAX;
35
36
  };
36
37
 
37
38
  /**
38
- * @typedef {{ roundId: number | undefined; unitPrice: NatValue }} PriceRound
39
+ * @typedef {{ roundId: number | undefined, unitPrice: NatValue }} PriceRound
39
40
  *
40
- * @typedef {Pick<RoundData, 'roundId' | 'startedAt'> & { startedBy: string }} LatestRound
41
+ * @typedef {Pick<RoundData, 'roundId' | 'startedAt'> & { startedBy: string }} LatestRound
41
42
  */
42
43
 
43
- /** @typedef {Round & { roundId: bigint }} RoundData */
44
+ /**
45
+ * @typedef {Round & {roundId: bigint}} RoundData
46
+ */
44
47
 
45
48
  /**
46
49
  * @typedef {object} Round
47
50
  * @property {bigint} answer the answer for the given round
48
- * @property {Timestamp} startedAt the timestamp when the round was started.
49
- * This is 0 if the round hasn't been started yet.
50
- * @property {Timestamp} updatedAt the timestamp when the round last was updated
51
- * (i.e. answer was last computed)
52
- * @property {bigint} answeredInRound the round ID of the round in which the
53
- * answer was computed. answeredInRound may be smaller than roundId when the
54
- * round timed out. answeredInRound is equal to roundId when the round didn't
55
- * time out and was completed regularly.
51
+ * @property {Timestamp} startedAt the timestamp when the round was started. This is 0
52
+ * if the round hasn't been started yet.
53
+ * @property {Timestamp} updatedAt the timestamp when the round last was updated (i.e.
54
+ * answer was last computed)
55
+ * @property {bigint} answeredInRound the round ID of the round in which the answer
56
+ * was computed. answeredInRound may be smaller than roundId when the round
57
+ * timed out. answeredInRound is equal to roundId when the round didn't time out
58
+ * and was completed regularly.
56
59
  */
57
60
 
58
61
  /**
@@ -63,31 +66,29 @@ const validRoundId = roundId => {
63
66
  * @property {number} roundTimeout
64
67
  */
65
68
 
66
- /** @typedef {IssuerKit<'set'>} QuoteKit */
69
+ /**
70
+ * @typedef {IssuerKit<'set'>} QuoteKit
71
+ */
67
72
 
68
73
  /**
69
- * @typedef {Readonly<
70
- * import('./fluxAggregatorKit.js').ChainlinkConfig & {
71
- * quoteKit: QuoteKit;
72
- * answerPublisher: Publisher<void>;
73
- * brandIn: Brand<'nat'>;
74
- * brandOut: Brand<'nat'>;
75
- * latestRoundPublisher: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<LatestRound>;
76
- * timerPresence: TimerService;
77
- * }
78
- * >} HeldParams
74
+ * @typedef {Readonly<import('./fluxAggregatorKit.js').ChainlinkConfig & {
75
+ * quoteKit: QuoteKit,
76
+ * answerPublisher: Publisher<void>,
77
+ * brandIn: Brand<'nat'>,
78
+ * brandOut: Brand<'nat'>,
79
+ * latestRoundPublisher: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<LatestRound>,
80
+ * timerPresence: TimerService,
81
+ * }>} HeldParams
79
82
  *
80
- * @typedef {Readonly<
81
- * HeldParams & {
82
- * details: MapStore<bigint, RoundDetails>;
83
- * rounds: MapStore<bigint, Round>;
84
- * unitIn: bigint;
85
- * }
86
- * >} ImmutableState
83
+ * @typedef {Readonly<HeldParams & {
84
+ * details: MapStore<bigint, RoundDetails>,
85
+ * rounds: MapStore<bigint, Round>,
86
+ * unitIn: bigint,
87
+ * }>} ImmutableState
87
88
  *
88
89
  * @typedef {{
89
- * lastValueOutForUnitIn: bigint?;
90
- * reportingRoundId: bigint;
90
+ * lastValueOutForUnitIn: bigint?,
91
+ * reportingRoundId: bigint,
91
92
  * }} MutableState
92
93
  */
93
94
  /** @typedef {ImmutableState & MutableState} State */
@@ -115,11 +116,7 @@ export const prepareRoundsManagerKit = baggage =>
115
116
  handlePush: M.call(M.record(), M.record()).returns(M.promise()),
116
117
  }),
117
118
  },
118
- /**
119
- * @type {(
120
- * opts: HeldParams & { unitAmountIn: Amount<'nat'> },
121
- * ) => State}
122
- */
119
+ /** @type {(opts: HeldParams & { unitAmountIn: Amount<'nat'> }) => State} */
123
120
  ({
124
121
  // ChainlinkConfig
125
122
  maxSubmissionCount,
@@ -173,7 +170,9 @@ export const prepareRoundsManagerKit = baggage =>
173
170
  },
174
171
  {
175
172
  helper: {
176
- /** @param {bigint} roundId */
173
+ /**
174
+ * @param {bigint} roundId
175
+ */
177
176
  acceptingSubmissions(roundId) {
178
177
  const { details } = this.state;
179
178
  return (
@@ -191,7 +190,9 @@ export const prepareRoundsManagerKit = baggage =>
191
190
  return roundId > add(lastStarted, restartDelay) || lastStarted === 0n;
192
191
  },
193
192
 
194
- /** @param {bigint} roundId */
193
+ /**
194
+ * @param {bigint} roundId
195
+ */
195
196
  deleteRoundDetails(roundId) {
196
197
  const { details } = this.state;
197
198
  const roundDetails = details.get(roundId);
@@ -200,7 +201,9 @@ export const prepareRoundsManagerKit = baggage =>
200
201
  details.delete(roundId);
201
202
  },
202
203
 
203
- /** @param {bigint} roundId */
204
+ /**
205
+ * @param {bigint} roundId
206
+ */
204
207
  isNextRound(roundId) {
205
208
  const { reportingRoundId } = this.state;
206
209
  return roundId === add(reportingRoundId, 1);
@@ -418,7 +421,7 @@ export const prepareRoundsManagerKit = baggage =>
418
421
  * @param {OracleStatus} status
419
422
  * @param {bigint} roundId
420
423
  * @param {Timestamp} blockTimestamp
421
- * @returns {string | null} error message, if there is one
424
+ * @returns {string?} error message, if there is one
422
425
  */
423
426
  validateOracleRound(status, roundId, blockTimestamp) {
424
427
  const { reportingRoundId } = this.state;
@@ -446,7 +449,10 @@ export const prepareRoundsManagerKit = baggage =>
446
449
  },
447
450
  },
448
451
  contract: {
449
- /** @param {PriceQuoteValue} quote */
452
+ /**
453
+ *
454
+ * @param {PriceQuoteValue} quote
455
+ */
450
456
  async authenticateQuote(quote) {
451
457
  const { quoteKit } = this.state;
452
458
  const quoteAmount = AmountMath.make(quoteKit.brand, harden(quote));
@@ -464,7 +470,9 @@ export const prepareRoundsManagerKit = baggage =>
464
470
  const { brandIn, brandOut, timerPresence } = state;
465
471
  const { contract } = this.facets;
466
472
 
467
- /** @param {PriceQuery} priceQuery */
473
+ /**
474
+ * @param {PriceQuery} priceQuery
475
+ */
468
476
  return Far('createQuote', priceQuery => {
469
477
  const { lastValueOutForUnitIn, unitIn } = state;
470
478
 
@@ -478,7 +486,9 @@ export const prepareRoundsManagerKit = baggage =>
478
486
  return undefined;
479
487
  }
480
488
 
481
- /** @param {Amount<'nat'>} amountIn the given amountIn */
489
+ /**
490
+ * @param {Amount<'nat'>} amountIn the given amountIn
491
+ */
482
492
  const calcAmountOut = amountIn => {
483
493
  const valueIn = AmountMath.getValue(brandIn, amountIn);
484
494
  return AmountMath.make(
@@ -487,7 +497,9 @@ export const prepareRoundsManagerKit = baggage =>
487
497
  );
488
498
  };
489
499
 
490
- /** @param {Amount<'nat'>} amountOut the wanted amountOut */
500
+ /**
501
+ * @param {Amount<'nat'>} amountOut the wanted amountOut
502
+ */
491
503
  const calcAmountIn = amountOut => {
492
504
  const valueOut = AmountMath.getValue(brandOut, amountOut);
493
505
  return AmountMath.make(
@@ -552,8 +564,9 @@ export const prepareRoundsManagerKit = baggage =>
552
564
  },
553
565
 
554
566
  /**
555
- * consumers are encouraged to check that they're receiving fresh data
556
- * by inspecting the updatedAt and answeredInRound return values.
567
+ * consumers are encouraged to check
568
+ * that they're receiving fresh data by inspecting the updatedAt and
569
+ * answeredInRound return values.
557
570
  *
558
571
  * @param {bigint | number} roundIdRaw
559
572
  * @returns {Promise<RoundData>}
@@ -590,9 +603,8 @@ export const prepareRoundsManagerKit = baggage =>
590
603
  },
591
604
 
592
605
  /**
593
- * a method to provide all current info oracleStatuses need. Intended
594
- * only only to be callable by oracleStatuses. Not for use by contracts
595
- * to read state.
606
+ * a method to provide all current info oracleStatuses need. Intended only
607
+ * only to be callable by oracleStatuses. Not for use by contracts to read state.
596
608
  *
597
609
  * @param {OracleStatus} status
598
610
  * @param {Timestamp} blockTimestamp