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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +6 -6
  2. package/package.json +46 -39
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +182 -151
  7. package/src/auction/auctionMath.d.ts +17 -0
  8. package/src/auction/auctionMath.d.ts.map +1 -0
  9. package/src/auction/auctionMath.js +81 -0
  10. package/src/auction/auctioneer.d.ts +70 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +72 -59
  13. package/src/auction/offerBook.d.ts +46 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +17 -12
  16. package/src/auction/params.d.ts +145 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +11 -9
  19. package/src/auction/scheduleMath.d.ts +5 -0
  20. package/src/auction/scheduleMath.d.ts.map +1 -0
  21. package/src/auction/scheduleMath.js +18 -16
  22. package/src/auction/scheduler.d.ts +50 -0
  23. package/src/auction/scheduler.d.ts.map +1 -0
  24. package/src/auction/scheduler.js +53 -47
  25. package/src/auction/sortedOffers.d.ts +8 -0
  26. package/src/auction/sortedOffers.d.ts.map +1 -0
  27. package/src/auction/sortedOffers.js +10 -9
  28. package/src/auction/util.d.ts +31 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +12 -6
  31. package/src/clientSupport.d.ts +168 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +161 -98
  34. package/src/collectFees.d.ts +2 -0
  35. package/src/collectFees.d.ts.map +1 -0
  36. package/src/contractSupport.d.ts +28 -0
  37. package/src/contractSupport.d.ts.map +1 -0
  38. package/src/contractSupport.js +19 -13
  39. package/src/econCommitteeCharter.d.ts +43 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +25 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +41 -33
  45. package/src/index.d.ts +2 -0
  46. package/src/index.d.ts.map +1 -0
  47. package/src/index.js +1 -0
  48. package/src/interest-math.d.ts +4 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest-math.js +5 -1
  51. package/src/interest.d.ts +30 -0
  52. package/src/interest.d.ts.map +1 -0
  53. package/src/interest.js +25 -23
  54. package/src/price/README.md +14 -1
  55. package/src/price/fluxAggregatorContract.d.ts +71 -0
  56. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  57. package/src/price/fluxAggregatorContract.js +64 -55
  58. package/src/price/fluxAggregatorKit.d.ts +104 -0
  59. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  60. package/src/price/fluxAggregatorKit.js +55 -42
  61. package/src/price/priceOracleKit.d.ts +39 -0
  62. package/src/price/priceOracleKit.d.ts.map +1 -0
  63. package/src/price/priceOracleKit.js +17 -15
  64. package/src/price/roundsManager.d.ts +204 -0
  65. package/src/price/roundsManager.d.ts.map +1 -0
  66. package/src/price/roundsManager.js +132 -85
  67. package/src/proposals/README.md +2 -3
  68. package/src/proposals/add-auction.js +285 -0
  69. package/src/proposals/addAssetToVault.js +192 -40
  70. package/src/proposals/committee-proposal.js +25 -31
  71. package/src/proposals/core-proposal.js +9 -11
  72. package/src/proposals/deploy-price-feeds.js +341 -0
  73. package/src/proposals/econ-behaviors.js +84 -49
  74. package/src/proposals/price-feed-proposal.js +109 -51
  75. package/src/proposals/replace-fee-distributor.js +198 -0
  76. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  77. package/src/proposals/replaceElectorate.js +610 -0
  78. package/src/proposals/startEconCommittee.js +2 -2
  79. package/src/proposals/startPSM.js +44 -29
  80. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  81. package/src/proposals/upgrade-vaults.js +207 -0
  82. package/src/proposals/utils.d.ts +21 -0
  83. package/src/proposals/utils.d.ts.map +1 -0
  84. package/src/proposals/utils.js +66 -9
  85. package/src/proposals/withdraw-reserve-proposal.js +63 -0
  86. package/src/provisionPool.d.ts +69 -0
  87. package/src/provisionPool.d.ts.map +1 -0
  88. package/src/provisionPool.js +138 -0
  89. package/src/provisionPoolKit.d.ts +129 -0
  90. package/src/provisionPoolKit.d.ts.map +1 -0
  91. package/src/provisionPoolKit.js +608 -0
  92. package/src/psm/psm.d.ts +133 -0
  93. package/src/psm/psm.d.ts.map +1 -0
  94. package/src/psm/psm.js +85 -79
  95. package/src/psm/types-ambient.d.ts +2 -0
  96. package/src/psm/types-ambient.d.ts.map +1 -0
  97. package/src/psm/types-ambient.js +3 -0
  98. package/src/reserve/assetReserve.d.ts +58 -0
  99. package/src/reserve/assetReserve.d.ts.map +1 -0
  100. package/src/reserve/assetReserve.js +42 -34
  101. package/src/reserve/assetReserveKit.d.ts +103 -0
  102. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  103. package/src/reserve/assetReserveKit.js +134 -32
  104. package/src/reserve/params.d.ts +16 -0
  105. package/src/reserve/params.d.ts.map +1 -0
  106. package/src/reserve/params.js +8 -2
  107. package/src/tokens.d.ts +3 -0
  108. package/src/tokens.d.ts.map +1 -0
  109. package/src/tokens.js +5 -0
  110. package/src/vaultFactory/burn.d.ts +2 -0
  111. package/src/vaultFactory/burn.d.ts.map +1 -0
  112. package/src/vaultFactory/burn.js +1 -1
  113. package/src/vaultFactory/liquidation.d.ts +25 -0
  114. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  115. package/src/vaultFactory/liquidation.js +37 -24
  116. package/src/vaultFactory/math.d.ts +11 -0
  117. package/src/vaultFactory/math.d.ts.map +1 -0
  118. package/src/vaultFactory/math.js +11 -10
  119. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  120. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  121. package/src/vaultFactory/orderedVaultStore.js +9 -10
  122. package/src/vaultFactory/params.d.ts +143 -0
  123. package/src/vaultFactory/params.d.ts.map +1 -0
  124. package/src/vaultFactory/params.js +56 -25
  125. package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
  126. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  127. package/src/vaultFactory/prioritizedVaults.js +7 -4
  128. package/src/vaultFactory/proceeds.d.ts +35 -0
  129. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  130. package/src/vaultFactory/proceeds.js +26 -18
  131. package/src/vaultFactory/storeUtils.d.ts +25 -0
  132. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  133. package/src/vaultFactory/storeUtils.js +10 -12
  134. package/src/vaultFactory/types-ambient.d.ts +137 -0
  135. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  136. package/src/vaultFactory/{types.js → types-ambient.js} +47 -44
  137. package/src/vaultFactory/vault.d.ts +344 -0
  138. package/src/vaultFactory/vault.d.ts.map +1 -0
  139. package/src/vaultFactory/vault.js +107 -100
  140. package/src/vaultFactory/vaultDirector.d.ts +347 -0
  141. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  142. package/src/vaultFactory/vaultDirector.js +94 -64
  143. package/src/vaultFactory/vaultFactory.d.ts +250 -0
  144. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  145. package/src/vaultFactory/vaultFactory.js +56 -33
  146. package/src/vaultFactory/vaultHolder.d.ts +170 -0
  147. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  148. package/src/vaultFactory/vaultHolder.js +14 -15
  149. package/src/vaultFactory/vaultKit.d.ts +33 -0
  150. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultKit.js +9 -4
  152. package/src/vaultFactory/vaultManager.d.ts +676 -0
  153. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultManager.js +286 -167
  155. package/CHANGELOG.md +0 -1041
  156. package/exported.js +0 -2
  157. package/scripts/add-collateral-core.js +0 -112
  158. package/scripts/deploy-contracts.js +0 -100
  159. package/scripts/init-core.js +0 -198
  160. package/scripts/invite-committee-core.js +0 -42
  161. package/scripts/manual-price-feed.js +0 -117
  162. package/scripts/price-feed-core.js +0 -104
  163. package/scripts/start-local-chain.sh +0 -84
  164. package/src/psm/types.js +0 -3
  165. package/src/typeGuards.js +0 -13
  166. package/src/vaultFactory/type-imports.js +0 -4
@@ -1,7 +1,7 @@
1
1
  /**
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?)
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?)
5
5
  */
6
6
  import { AmountMath } from '@agoric/ertp';
7
7
  import { assertAllDefined, makeTracer } from '@agoric/internal';
@@ -18,17 +18,24 @@ import { Far } from '@endo/marshal';
18
18
  import { prepareOracleAdminKit } from './priceOracleKit.js';
19
19
  import { prepareRoundsManagerKit } from './roundsManager.js';
20
20
 
21
+ /**
22
+ * @import {EReturn} from '@endo/far';
23
+ * @import {TypedPattern} from '@agoric/internal';
24
+ * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
25
+ * @import {MapStore, SetStore} from '@agoric/store';
26
+ */
27
+
21
28
  const trace = makeTracer('FlxAgg', true);
22
29
 
23
30
  export const INVITATION_MAKERS_DESC = 'oracle invitation';
24
31
 
25
32
  /**
26
- * @typedef {import('@agoric/vat-data').Baggage} Baggage
27
- * @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
28
- * @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
29
- * // TODO: use RelativeTime, not RelativeTimeValue
30
- * @typedef {import('@agoric/time/src/types').RelativeTimeValue} RelativeTimeValue
31
- * @typedef {import('@agoric/time/src/types').TimerService} TimerService
33
+ * @import {Baggage} from '@agoric/vat-data'
34
+ * @import {Timestamp} from '@agoric/time'
35
+ * @import {RelativeTime} from '@agoric/time'
36
+ * RelativeTime, not RelativeTimeValue
37
+ * @import {RelativeTimeValue} from '@agoric/time'
38
+ * @import {TimerService} from '@agoric/time'
32
39
  */
33
40
 
34
41
  /** @type {(quote: PriceQuote) => PriceDescription} */
@@ -49,30 +56,35 @@ const priceDescriptionFromQuote = quote => quote.quoteAmount.value[0];
49
56
  * @typedef {object} ChainlinkConfig
50
57
  * @property {number} maxSubmissionCount
51
58
  * @property {number} minSubmissionCount
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
59
+ * @property {bigint} restartDelay the number of rounds an Oracle has to wait
60
+ * before they can initiate a round
61
+ * @property {number} minSubmissionValue an immutable check for a lower bound of
62
+ * what submission values are accepted from an oracle
63
+ * @property {number} maxSubmissionValue an immutable check for an upper bound
64
+ * of what submission values are accepted from an oracle
65
+ * @property {number} timeout the number of seconds after the previous round
66
+ * that allowed to lapse before allowing an oracle to skip an unfinished
67
+ * round
59
68
  */
60
69
 
61
70
  /**
62
- * Returns a maker for a single durable FluxAggregatorKit, closed over the prepare() arguments.
71
+ * Returns a maker for a single durable FluxAggregatorKit, closed over the
72
+ * prepare() arguments.
63
73
  *
64
74
  * The kit aggregates price inputs to produce a PriceAuthority. Unlike the
65
- * simpler `priceAggregator.js`, this approximates the *Node Operator
66
- * Aggregation* logic of [Chainlink price
75
+ * simpler `priceAggregator.js`, this approximates the _Node Operator
76
+ * Aggregation_ logic of [Chainlink price
67
77
  * feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
68
78
  *
69
79
  * @param {Baggage} baggage
70
- * @param {ZCF<ChainlinkConfig & {
71
- * timer: TimerService,
72
- * brandIn: Brand<'nat'>,
73
- * brandOut: Brand<'nat'>,
74
- * unitAmountIn?: Amount<'nat'>,
75
- * }>} zcf
80
+ * @param {ZCF<
81
+ * ChainlinkConfig & {
82
+ * timer: TimerService;
83
+ * brandIn: Brand<'nat'>;
84
+ * brandOut: Brand<'nat'>;
85
+ * unitAmountIn?: Amount<'nat'>;
86
+ * }
87
+ * >} zcf
76
88
  * @param {TimerService} timerPresence
77
89
  * @param {import('./roundsManager.js').QuoteKit} quoteKit
78
90
  * @param {StorageNode} storageNode
@@ -120,7 +132,6 @@ export const prepareFluxAggregatorKit = async (
120
132
  const makeOracleAdminKit = prepareOracleAdminKit(baggage);
121
133
 
122
134
  const makeRecorderKit = defineRecorderKit({
123
- // @ts-expect-error XXX
124
135
  makeDurablePublishKit,
125
136
  makeRecorder,
126
137
  });
@@ -128,23 +139,24 @@ export const prepareFluxAggregatorKit = async (
128
139
  // end of maker definitions /////////////////////////////////
129
140
 
130
141
  const { answerKit, latestRoundKit, priceKit } = await provideAll(baggage, {
131
- /** This is just a signal that there's a new answer, which is read from `lastValueOutForUnitIn` */
142
+ /**
143
+ * This is just a signal that there's a new answer, which is read from
144
+ * `lastValueOutForUnitIn`
145
+ */
132
146
  answerKit: () => makeDurablePublishKit(),
133
147
  /** For publishing priceAuthority values to off-chain storage */
134
148
  priceKit: () =>
135
149
  makeRecorderKit(
136
150
  storageNode,
137
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<PriceDescription>} */ (
138
- M.any()
139
- ),
151
+ /** @type {TypedPattern<PriceDescription>} */ (M.any()),
140
152
  ),
141
153
  latestRoundKit: () =>
142
154
  E.when(E(storageNode).makeChildNode('latestRound'), node =>
143
155
  makeRecorderKit(
144
156
  node,
145
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<import('./roundsManager.js').LatestRound>} */ (
146
- M.any()
147
- ),
157
+ /**
158
+ * @type {TypedPattern<import('./roundsManager.js').LatestRound>}
159
+ */ (M.any()),
148
160
  ),
149
161
  ),
150
162
  });
@@ -223,9 +235,9 @@ export const prepareFluxAggregatorKit = async (
223
235
  * An "oracle invitation" is an invitation to be able to submit data to
224
236
  * include in the priceAggregator's results.
225
237
  *
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.
238
+ * The offer result from this invitation is a OracleAdmin, which can be
239
+ * used directly to manage the price submissions as well as to terminate
240
+ * the relationship.
229
241
  *
230
242
  * @param {string} oracleId unique per contract instance
231
243
  */
@@ -235,12 +247,13 @@ export const prepareFluxAggregatorKit = async (
235
247
  /**
236
248
  * If custom arguments are supplied to the `zoe.offer` call, they can
237
249
  * indicate an OraclePriceSubmission notifier and a corresponding
238
- * `shiftValueOut` that should be adapted as part of the priceAuthority's
239
- * reported data.
250
+ * `shiftValueOut` that should be adapted as part of the
251
+ * priceAuthority's reported data.
240
252
  *
241
253
  * @param {ZCFSeat} seat
242
254
  */
243
255
  const offerHandler = async seat => {
256
+ seat.exit();
244
257
  const { oracle } = await facets.creator.initOracle(oracleId);
245
258
  const invitationMakers = Far('invitation makers', {
246
259
  /** @param {import('./roundsManager.js').PriceRound} result */
@@ -255,7 +268,6 @@ export const prepareFluxAggregatorKit = async (
255
268
  );
256
269
  },
257
270
  });
258
- seat.exit();
259
271
 
260
272
  return harden({
261
273
  invitationMakers,
@@ -299,8 +311,9 @@ export const prepareFluxAggregatorKit = async (
299
311
  },
300
312
 
301
313
  /**
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.
314
+ * a method to provide all current info oracleStatuses need. Intended
315
+ * only only to be callable by oracleStatuses. Not for use by contracts
316
+ * to read state.
304
317
  *
305
318
  * @param {string} oracleId
306
319
  * @param {bigint} queriedRoundId
@@ -359,4 +372,4 @@ export const prepareFluxAggregatorKit = async (
359
372
  return makeFluxAggregatorKit;
360
373
  };
361
374
  harden(prepareFluxAggregatorKit);
362
- /** @typedef {ReturnType<Awaited<ReturnType<typeof prepareFluxAggregatorKit>>>} FluxAggregatorKit */
375
+ /** @typedef {EReturn<EReturn<typeof prepareFluxAggregatorKit>>} FluxAggregatorKit */
@@ -0,0 +1,39 @@
1
+ export const INVITATION_MAKERS_DESC: "oracle invitation";
2
+ export function prepareOracleAdminKit(baggage: any): (args_0: HeldParams) => import("@endo/exo").GuardedKit<{
3
+ admin: {
4
+ disable(): void;
5
+ };
6
+ oracle: {
7
+ /**
8
+ * push a unitPrice result from this oracle
9
+ *
10
+ * @param {PriceDatum} datum
11
+ */
12
+ pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
13
+ /** @returns {OracleStatus} */
14
+ getStatus(): OracleStatus;
15
+ };
16
+ }>;
17
+ export type HeldParams = {
18
+ oracleId: string;
19
+ roundPowers: {
20
+ handlePush: (status: OracleStatus, result: import("./roundsManager.js").PriceRound) => Promise<OracleStatus>;
21
+ };
22
+ };
23
+ export type PriceDatum = {
24
+ roundId: number | undefined;
25
+ unitPrice: NatValue;
26
+ };
27
+ export type OracleStatus = {
28
+ disabled?: boolean | undefined;
29
+ lastReportedRound: bigint;
30
+ lastStartedRound: bigint;
31
+ latestSubmission: bigint;
32
+ oracleId: string;
33
+ };
34
+ export type ImmutableState = Readonly<HeldParams & {}>;
35
+ export type MutableState = OracleStatus & {};
36
+ export type State = ImmutableState & MutableState;
37
+ export type OracleKit = EReturn<EReturn<typeof prepareOracleAdminKit>>;
38
+ import type { EReturn } from '@endo/far';
39
+ //# sourceMappingURL=priceOracleKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priceOracleKit.d.ts","sourceRoot":"","sources":["priceOracleKit.js"],"names":[],"mappings":"AAMA,qCAAsC,mBAAmB,CAAC;AAgEnD;;;;;QAcC;;;;WAIG;iEADQ,UAAU;QA0BrB,8BAA8B;qBAAhB,YAAY;;GAa/B;yBAjHU;IACR,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,UAAU,EAAE,CACV,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,OAAO,oBAAoB,EAAE,UAAU,KAC5C,OAAO,CAAC,YAAY,CAAC,CAAC;KAC5B,CAAC;CACH;yBAGU;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,QAAQ,CAAA;CAAE;;;uBAKpD,MAAM;sBACN,MAAM;sBACN,MAAM;cACN,MAAM;;6BAGP,QAAQ,CAAC,UAAU,GAAG,EAAE,CAAC;2BAEzB,YAAY,GAAG,EAAE;oBAEhB,cAAc,GAAG,YAAY;wBAyF7B,QAAQ,QAAQ,OAAO,qBAAqB,CAAC,CAAC;6BAvHlC,WAAW"}
@@ -1,4 +1,4 @@
1
- import { Fail } from '@agoric/assert';
1
+ import { Fail } from '@endo/errors';
2
2
  import { makeTracer } from '@agoric/internal';
3
3
  import { M, prepareExoClassKit } from '@agoric/vat-data';
4
4
 
@@ -7,16 +7,23 @@ const trace = makeTracer('OrKit', true);
7
7
  export const INVITATION_MAKERS_DESC = 'oracle invitation';
8
8
 
9
9
  /**
10
- * @typedef {{
11
- * oracleId: string,
12
- * roundPowers: { handlePush: (status: OracleStatus, result: import('./roundsManager.js').PriceRound) => Promise<OracleStatus> }
13
- * }} HeldParams
10
+ * @import {EReturn} from '@endo/far';
14
11
  */
15
12
 
16
13
  /**
17
- * @typedef {{ roundId: number | undefined, unitPrice: NatValue }} PriceDatum
14
+ * @typedef {{
15
+ * oracleId: string;
16
+ * roundPowers: {
17
+ * handlePush: (
18
+ * status: OracleStatus,
19
+ * result: import('./roundsManager.js').PriceRound,
20
+ * ) => Promise<OracleStatus>;
21
+ * };
22
+ * }} HeldParams
18
23
  */
19
24
 
25
+ /** @typedef {{ roundId: number | undefined; unitPrice: NatValue }} PriceDatum */
26
+
20
27
  /**
21
28
  * @typedef {object} OracleStatus
22
29
  * @property {boolean} [disabled]
@@ -26,11 +33,9 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
26
33
  * @property {string} oracleId
27
34
  */
28
35
  /**
29
- * @typedef {Readonly<HeldParams & {
30
- * }>} ImmutableState
36
+ * @typedef {Readonly<HeldParams & {}>} ImmutableState
31
37
  *
32
- * @typedef {OracleStatus & {
33
- * }} MutableState
38
+ * @typedef {OracleStatus & {}} MutableState
34
39
  */
35
40
  /** @typedef {ImmutableState & MutableState} State */
36
41
 
@@ -106,10 +111,7 @@ export const prepareOracleAdminKit = baggage =>
106
111
  state.lastStartedRound = result.lastStartedRound;
107
112
  state.latestSubmission = result.latestSubmission;
108
113
  },
109
- /**
110
- *
111
- * @returns {OracleStatus}
112
- */
114
+ /** @returns {OracleStatus} */
113
115
  getStatus() {
114
116
  const { state } = this;
115
117
  return {
@@ -124,4 +126,4 @@ export const prepareOracleAdminKit = baggage =>
124
126
  },
125
127
  );
126
128
 
127
- /** @typedef {ReturnType<ReturnType<typeof prepareOracleAdminKit>>} OracleKit */
129
+ /** @typedef {EReturn<EReturn<typeof prepareOracleAdminKit>>} OracleKit */
@@ -0,0 +1,204 @@
1
+ /** @type {bigint} */
2
+ export const ROUND_MAX: bigint;
3
+ export function prepareRoundsManagerKit(baggage: any): (args_0: Readonly<import("./fluxAggregatorKit.js").ChainlinkConfig & {
4
+ quoteKit: QuoteKit;
5
+ answerPublisher: Publisher<void>;
6
+ brandIn: Brand<"nat">;
7
+ brandOut: Brand<"nat">;
8
+ latestRoundPublisher: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<LatestRound>;
9
+ timerPresence: TimerService;
10
+ }> & {
11
+ unitAmountIn: Amount<"nat">;
12
+ }) => import("@endo/exo").GuardedKit<{
13
+ helper: {
14
+ /** @param {bigint} roundId */
15
+ acceptingSubmissions(roundId: bigint): boolean;
16
+ /**
17
+ * @param {OracleStatus} status
18
+ * @param {bigint} roundId
19
+ */
20
+ delayed(status: OracleStatus, roundId: bigint): boolean;
21
+ /** @param {bigint} roundId */
22
+ deleteRoundDetails(roundId: bigint): void;
23
+ /** @param {bigint} roundId */
24
+ isNextRound(roundId: bigint): boolean;
25
+ /**
26
+ * @param {bigint} roundId
27
+ * @param {Timestamp} blockTimestamp
28
+ * @param {string} oracleId
29
+ */
30
+ initializeNewRound(roundId: bigint, blockTimestamp: Timestamp, oracleId: string): void;
31
+ /**
32
+ * @param {bigint} roundId
33
+ * @param {bigint} rrId reporting round ID
34
+ */
35
+ previousAndCurrentUnanswered(roundId: bigint, rrId: bigint): boolean;
36
+ /**
37
+ * @param {bigint} roundId
38
+ * @param {OracleStatus} status
39
+ * @param {Timestamp} blockTimestamp
40
+ * @returns {OracleStatus | undefined} the new status
41
+ */
42
+ proposeNewRound(roundId: bigint, status: OracleStatus, blockTimestamp: Timestamp): OracleStatus | undefined;
43
+ /**
44
+ * @param {bigint} submission
45
+ * @param {bigint} roundId
46
+ * @param {OracleStatus} status
47
+ * @returns {OracleStatus} the new status
48
+ */
49
+ recordSubmission(submission: bigint, roundId: bigint, status: OracleStatus): OracleStatus;
50
+ /**
51
+ * @param {bigint} roundId
52
+ * @param {Timestamp} blockTimestamp
53
+ */
54
+ supersedable(roundId: bigint, blockTimestamp: Timestamp): boolean;
55
+ /**
56
+ * @param {bigint} roundId
57
+ * @param {Timestamp} blockTimestamp
58
+ */
59
+ timedOut(roundId: bigint, blockTimestamp: Timestamp): boolean;
60
+ /**
61
+ * @param {bigint} roundId
62
+ * @param {Timestamp} blockTimestamp
63
+ */
64
+ updateRoundAnswer(roundId: bigint, blockTimestamp: Timestamp): (number | boolean)[] | (bigint | boolean)[];
65
+ /**
66
+ * @param {bigint} roundId
67
+ * @param {Timestamp} blockTimestamp
68
+ */
69
+ updateTimedOutRoundInfo(roundId: bigint, blockTimestamp: Timestamp): void;
70
+ /**
71
+ * @param {OracleStatus} status
72
+ * @param {bigint} roundId
73
+ * @param {Timestamp} blockTimestamp
74
+ * @returns {string | null} error message, if there is one
75
+ */
76
+ validateOracleRound(status: OracleStatus, roundId: bigint, blockTimestamp: Timestamp): string | null;
77
+ };
78
+ contract: {
79
+ /** @param {PriceQuoteValue} quote */
80
+ authenticateQuote(quote: PriceQuoteValue): Promise<{
81
+ quoteAmount: import("@agoric/ertp").SetAmount<PriceDescription>;
82
+ quotePayment: globalThis.Payment<"set", PriceDescription>;
83
+ }>;
84
+ /**
85
+ * @param {object} param0
86
+ * @param {number} [param0.overrideValueOut]
87
+ * @param {Timestamp} [param0.timestamp]
88
+ */
89
+ makeCreateQuote({ overrideValueOut, timestamp }?: {
90
+ overrideValueOut?: number | undefined;
91
+ timestamp?: Timestamp | undefined;
92
+ }): ((priceQuery: any) => Promise<{
93
+ quoteAmount: import("@agoric/ertp").SetAmount<PriceDescription>;
94
+ quotePayment: globalThis.Payment<"set", PriceDescription>;
95
+ }> | undefined) & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (priceQuery: any) => Promise<{
96
+ quoteAmount: import("@agoric/ertp").SetAmount<PriceDescription>;
97
+ quotePayment: globalThis.Payment<"set", PriceDescription>;
98
+ }> | undefined>;
99
+ /**
100
+ * @param {OracleStatus} status
101
+ * @param {bigint} queriedRoundId
102
+ * @param {Timestamp} blockTimestamp
103
+ */
104
+ eligibleForSpecificRound(status: OracleStatus, queriedRoundId: bigint, blockTimestamp: Timestamp): boolean;
105
+ /**
106
+ * consumers are encouraged to check that they're receiving fresh data
107
+ * by inspecting the updatedAt and answeredInRound return values.
108
+ *
109
+ * @param {bigint | number} roundIdRaw
110
+ * @returns {Promise<RoundData>}
111
+ */
112
+ getRoundData(roundIdRaw: bigint | number): Promise<RoundData>;
113
+ getRoundStatus(roundId: bigint): Readonly<RoundDetails & Round>;
114
+ /**
115
+ * a method to provide all current info oracleStatuses need. Intended
116
+ * only to be callable by oracleStatuses. Not for use by contracts to
117
+ * read state.
118
+ *
119
+ * @param {OracleStatus} status
120
+ * @param {Timestamp} blockTimestamp
121
+ */
122
+ oracleRoundStateSuggestRound(status: OracleStatus, blockTimestamp: Timestamp): {
123
+ eligibleForSpecificRound: boolean;
124
+ queriedRoundId: bigint;
125
+ latestSubmission: bigint;
126
+ startedAt: Timestamp;
127
+ roundTimeout: number;
128
+ };
129
+ };
130
+ oracle: {
131
+ /**
132
+ * push a unitPrice result from this oracle
133
+ *
134
+ * @param {OracleStatus} status
135
+ * @param {PriceRound} result
136
+ */
137
+ handlePush(status: OracleStatus, { roundId: roundIdRaw, unitPrice: valueRaw }: PriceRound): Promise<OracleStatus>;
138
+ };
139
+ }>;
140
+ export type PriceRound = {
141
+ roundId: number | undefined;
142
+ unitPrice: NatValue;
143
+ };
144
+ export type LatestRound = Pick<RoundData, "roundId" | "startedAt"> & {
145
+ startedBy: string;
146
+ };
147
+ export type RoundData = Round & {
148
+ roundId: bigint;
149
+ };
150
+ export type Round = {
151
+ /**
152
+ * the answer for the given round
153
+ */
154
+ answer: bigint;
155
+ /**
156
+ * the timestamp when the round was started.
157
+ * This is 0 if the round hasn't been started yet.
158
+ */
159
+ startedAt: Timestamp;
160
+ /**
161
+ * the timestamp when the round last was updated
162
+ * (i.e. answer was last computed)
163
+ */
164
+ updatedAt: Timestamp;
165
+ /**
166
+ * the round ID of the round in which the
167
+ * answer was computed. answeredInRound may be smaller than roundId when the
168
+ * round timed out. answeredInRound is equal to roundId when the round didn't
169
+ * time out and was completed regularly.
170
+ */
171
+ answeredInRound: bigint;
172
+ };
173
+ export type RoundDetails = {
174
+ submissions: bigint[];
175
+ maxSubmissions: number;
176
+ minSubmissions: number;
177
+ roundTimeout: number;
178
+ };
179
+ export type QuoteKit = IssuerKit<"set", PriceDescription>;
180
+ export type HeldParams = Readonly<import("./fluxAggregatorKit.js").ChainlinkConfig & {
181
+ quoteKit: QuoteKit;
182
+ answerPublisher: Publisher<void>;
183
+ brandIn: Brand<"nat">;
184
+ brandOut: Brand<"nat">;
185
+ latestRoundPublisher: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<LatestRound>;
186
+ timerPresence: TimerService;
187
+ }>;
188
+ export type ImmutableState = Readonly<HeldParams & {
189
+ details: MapStore<bigint, RoundDetails>;
190
+ rounds: MapStore<bigint, Round>;
191
+ unitIn: bigint;
192
+ }>;
193
+ export type MutableState = {
194
+ lastValueOutForUnitIn: bigint | null;
195
+ reportingRoundId: bigint;
196
+ };
197
+ export type State = ImmutableState & MutableState;
198
+ import type { TimerService } from '@agoric/time';
199
+ import type { OracleStatus } from './priceOracleKit.js';
200
+ import type { Timestamp } from '@agoric/time';
201
+ import type { PriceQuoteValue } from '@agoric/zoe/tools/types.js';
202
+ import type { PriceDescription } from '@agoric/zoe/tools/types.js';
203
+ import type { MapStore } from '@agoric/store';
204
+ //# sourceMappingURL=roundsManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roundsManager.d.ts","sourceRoot":"","sources":["roundsManager.js"],"names":[],"mappings":"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"}