@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-3eb1a1d.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 (191) hide show
  1. package/README.md +6 -6
  2. package/package.json +42 -36
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +156 -150
  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 +69 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +70 -59
  13. package/src/auction/offerBook.d.ts +45 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +13 -12
  16. package/src/auction/params.d.ts +144 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +10 -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 +30 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +9 -6
  31. package/src/clientSupport.d.ts +167 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +155 -97
  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 +40 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +21 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +37 -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 +3 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest.d.ts +28 -0
  51. package/src/interest.d.ts.map +1 -0
  52. package/src/interest.js +23 -18
  53. package/src/price/README.md +13 -0
  54. package/src/price/fluxAggregatorContract.d.ts +71 -0
  55. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  56. package/src/price/fluxAggregatorContract.js +64 -55
  57. package/src/price/fluxAggregatorKit.d.ts +103 -0
  58. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  59. package/src/price/fluxAggregatorKit.js +52 -40
  60. package/src/price/priceOracleKit.d.ts +38 -0
  61. package/src/price/priceOracleKit.d.ts.map +1 -0
  62. package/src/price/priceOracleKit.js +12 -14
  63. package/src/price/roundsManager.d.ts +204 -0
  64. package/src/price/roundsManager.d.ts.map +1 -0
  65. package/src/price/roundsManager.js +131 -85
  66. package/src/proposals/README.md +2 -3
  67. package/src/proposals/add-auction.d.ts +109 -0
  68. package/src/proposals/add-auction.d.ts.map +1 -0
  69. package/src/proposals/add-auction.js +256 -0
  70. package/src/proposals/addAssetToVault.d.ts +173 -0
  71. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  72. package/src/proposals/addAssetToVault.js +192 -40
  73. package/src/proposals/committee-proposal.d.ts +113 -0
  74. package/src/proposals/committee-proposal.d.ts.map +1 -0
  75. package/src/proposals/committee-proposal.js +25 -31
  76. package/src/proposals/core-proposal.d.ts +149 -0
  77. package/src/proposals/core-proposal.d.ts.map +1 -0
  78. package/src/proposals/core-proposal.js +9 -11
  79. package/src/proposals/deploy-price-feeds.d.ts +76 -0
  80. package/src/proposals/deploy-price-feeds.d.ts.map +1 -0
  81. package/src/proposals/deploy-price-feeds.js +316 -0
  82. package/src/proposals/econ-behaviors.d.ts +541 -0
  83. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  84. package/src/proposals/econ-behaviors.js +64 -45
  85. package/src/proposals/price-feed-proposal.d.ts +84 -0
  86. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  87. package/src/proposals/price-feed-proposal.js +109 -51
  88. package/src/proposals/replace-fee-distributor.d.ts +48 -0
  89. package/src/proposals/replace-fee-distributor.d.ts.map +1 -0
  90. package/src/proposals/replace-fee-distributor.js +195 -0
  91. package/src/proposals/replace-scaledPriceAuthorities.d.ts +30 -0
  92. package/src/proposals/replace-scaledPriceAuthorities.d.ts.map +1 -0
  93. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  94. package/src/proposals/replaceElectorate.d.ts +55 -0
  95. package/src/proposals/replaceElectorate.d.ts.map +1 -0
  96. package/src/proposals/replaceElectorate.js +521 -0
  97. package/src/proposals/startEconCommittee.d.ts +34 -0
  98. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  99. package/src/proposals/startEconCommittee.js +2 -2
  100. package/src/proposals/startPSM.d.ts +59 -0
  101. package/src/proposals/startPSM.d.ts.map +1 -0
  102. package/src/proposals/startPSM.js +44 -29
  103. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  104. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  105. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  106. package/src/proposals/upgrade-vaults.d.ts +41 -0
  107. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  108. package/src/proposals/upgrade-vaults.js +202 -0
  109. package/src/proposals/utils.d.ts +19 -0
  110. package/src/proposals/utils.d.ts.map +1 -0
  111. package/src/proposals/utils.js +43 -9
  112. package/src/provisionPool.d.ts +163 -0
  113. package/src/provisionPool.d.ts.map +1 -0
  114. package/src/provisionPool.js +122 -0
  115. package/src/provisionPoolKit.d.ts +359 -0
  116. package/src/provisionPoolKit.d.ts.map +1 -0
  117. package/src/provisionPoolKit.js +522 -0
  118. package/src/psm/psm.d.ts +125 -0
  119. package/src/psm/psm.d.ts.map +1 -0
  120. package/src/psm/psm.js +80 -79
  121. package/src/psm/types-ambient.d.ts +2 -0
  122. package/src/psm/types-ambient.d.ts.map +1 -0
  123. package/src/psm/types-ambient.js +3 -0
  124. package/src/reserve/assetReserve.d.ts +47 -0
  125. package/src/reserve/assetReserve.d.ts.map +1 -0
  126. package/src/reserve/assetReserve.js +28 -19
  127. package/src/reserve/assetReserveKit.d.ts +74 -0
  128. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  129. package/src/reserve/assetReserveKit.js +24 -30
  130. package/src/reserve/params.d.ts +10 -0
  131. package/src/reserve/params.d.ts.map +1 -0
  132. package/src/tokens.d.ts +3 -0
  133. package/src/tokens.d.ts.map +1 -0
  134. package/src/tokens.js +5 -0
  135. package/src/vaultFactory/burn.d.ts +2 -0
  136. package/src/vaultFactory/burn.d.ts.map +1 -0
  137. package/src/vaultFactory/burn.js +1 -1
  138. package/src/vaultFactory/liquidation.d.ts +23 -0
  139. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  140. package/src/vaultFactory/liquidation.js +37 -24
  141. package/src/vaultFactory/math.d.ts +11 -0
  142. package/src/vaultFactory/math.d.ts.map +1 -0
  143. package/src/vaultFactory/math.js +10 -9
  144. package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
  145. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  146. package/src/vaultFactory/orderedVaultStore.js +8 -11
  147. package/src/vaultFactory/params.d.ts +140 -0
  148. package/src/vaultFactory/params.d.ts.map +1 -0
  149. package/src/vaultFactory/params.js +52 -24
  150. package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
  151. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  152. package/src/vaultFactory/prioritizedVaults.js +4 -4
  153. package/src/vaultFactory/proceeds.d.ts +35 -0
  154. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  155. package/src/vaultFactory/proceeds.js +26 -18
  156. package/src/vaultFactory/storeUtils.d.ts +25 -0
  157. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  158. package/src/vaultFactory/storeUtils.js +10 -12
  159. package/src/vaultFactory/types-ambient.d.ts +137 -0
  160. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  161. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  162. package/src/vaultFactory/vault.d.ts +343 -0
  163. package/src/vaultFactory/vault.d.ts.map +1 -0
  164. package/src/vaultFactory/vault.js +105 -99
  165. package/src/vaultFactory/vaultDirector.d.ts +341 -0
  166. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  167. package/src/vaultFactory/vaultDirector.js +86 -64
  168. package/src/vaultFactory/vaultFactory.d.ts +202 -0
  169. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  170. package/src/vaultFactory/vaultFactory.js +52 -33
  171. package/src/vaultFactory/vaultHolder.d.ts +126 -0
  172. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  173. package/src/vaultFactory/vaultHolder.js +11 -16
  174. package/src/vaultFactory/vaultKit.d.ts +32 -0
  175. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  176. package/src/vaultFactory/vaultKit.js +5 -4
  177. package/src/vaultFactory/vaultManager.d.ts +674 -0
  178. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  179. package/src/vaultFactory/vaultManager.js +257 -158
  180. package/CHANGELOG.md +0 -1041
  181. package/exported.js +0 -2
  182. package/scripts/add-collateral-core.js +0 -112
  183. package/scripts/deploy-contracts.js +0 -100
  184. package/scripts/init-core.js +0 -198
  185. package/scripts/invite-committee-core.js +0 -42
  186. package/scripts/manual-price-feed.js +0 -117
  187. package/scripts/price-feed-core.js +0 -104
  188. package/scripts/start-local-chain.sh +0 -84
  189. package/src/psm/types.js +0 -3
  190. package/src/typeGuards.js +0 -13
  191. package/src/vaultFactory/type-imports.js +0 -4
@@ -1,10 +1,6 @@
1
1
  // @jessie-check
2
2
 
3
- import {
4
- hasIssuer,
5
- makeDurableIssuerKit,
6
- prepareIssuerKit,
7
- } from '@agoric/ertp';
3
+ import { prepareIssuerKit } from '@agoric/ertp';
8
4
  import { handleParamGovernance } from '@agoric/governance';
9
5
  import { makeTracer, StorageNodeShape } from '@agoric/internal';
10
6
  import { prepareDurablePublishKit } from '@agoric/notifier';
@@ -17,56 +13,69 @@ import { prepareFluxAggregatorKit } from './fluxAggregatorKit.js';
17
13
 
18
14
  const trace = makeTracer('FluxAgg', false);
19
15
  /**
20
- * @typedef {import('@agoric/vat-data').Baggage} Baggage
21
- * @typedef {import('@agoric/time/src/types').TimerService} TimerService
16
+ * @import {Baggage} from '@agoric/vat-data'
17
+ * @import {TimerService} from '@agoric/time'
22
18
  */
23
19
 
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
- );
20
+ /** @type {ContractMeta} */
21
+ export const meta = {
22
+ privateArgsShape: M.splitRecord(
23
+ {
24
+ storageNode: StorageNodeShape,
25
+ marshaller: M.eref(M.remotable('marshaller')),
26
+ namesByAddressAdmin: M.any(),
27
+ },
28
+ {
29
+ // always optional. XXX some code is including the key, set to null
30
+ highPrioritySendersManager: M.or(
31
+ M.remotable('prioritySenders manager'),
32
+ M.null(),
33
+ ),
34
+ // only necessary on first invocation, not subsequent
35
+ initialPoserInvitation: M.remotable('Invitation'),
36
+ },
37
+ ),
38
+ upgradability: 'canUpgrade',
39
+ };
40
+ harden(meta);
40
41
 
41
42
  /**
42
- * PriceAuthority for their median. Unlike the simpler `priceAggregator.js`, this approximates
43
- * the *Node Operator Aggregation* logic of [Chainlink price
43
+ * PriceAuthority for their median. Unlike the simpler `priceAggregator.js`,
44
+ * this approximates the _Node Operator Aggregation_ logic of [Chainlink price
44
45
  * feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
45
46
  *
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
47
+ * @param {ZCF<
48
+ * import('./fluxAggregatorKit.js').ChainlinkConfig & {
49
+ * timer: TimerService;
50
+ * brandIn: Brand<'nat'>;
51
+ * brandOut: Brand<'nat'>;
52
+ * description: string;
53
+ * unitAmountIn?: Amount<'nat'>;
54
+ * }
55
+ * >} zcf
53
56
  * @param {{
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,
57
+ * highPrioritySendersManager?: import('@agoric/internal/src/priority-senders.js').PrioritySendersManager;
58
+ * initialPoserInvitation: Invitation;
59
+ * marshaller: ERef<Marshaller>;
60
+ * namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>;
61
+ * storageNode: StorageNode;
59
62
  * }} privateArgs
60
63
  * @param {Baggage} baggage
61
64
  */
62
- export const prepare = async (zcf, privateArgs, baggage) => {
65
+ export const start = async (zcf, privateArgs, baggage) => {
63
66
  trace('prepare with baggage keys', [...baggage.keys()]);
64
67
 
65
68
  // xxx uses contract baggage as issuerBagage, assumes one issuer in this contract
66
69
  /** @type {import('./roundsManager.js').QuoteKit} */
67
- const quoteIssuerKit = hasIssuer(baggage)
68
- ? prepareIssuerKit(baggage)
69
- : makeDurableIssuerKit(baggage, 'quote', 'set');
70
+ // @ts-expect-error cast
71
+ const quoteIssuerKit = prepareIssuerKit(
72
+ baggage,
73
+ 'quote',
74
+ 'set',
75
+ undefined,
76
+ undefined,
77
+ { recoverySetsOption: 'noRecoverySets' },
78
+ );
70
79
 
71
80
  const {
72
81
  highPrioritySendersManager,
@@ -131,10 +140,8 @@ export const prepare = async (zcf, privateArgs, baggage) => {
131
140
  addr,
132
141
  [invitation],
133
142
  );
134
- if (highPrioritySendersManager) {
135
- // eslint-disable-next-line @jessie.js/no-nested-await -- after another await
136
- await E(highPrioritySendersManager).add(description, addr);
137
- }
143
+ await (highPrioritySendersManager &&
144
+ E(highPrioritySendersManager).add(description, addr));
138
145
  return `added ${addr}`;
139
146
  };
140
147
 
@@ -146,29 +153,29 @@ export const prepare = async (zcf, privateArgs, baggage) => {
146
153
  const removeOracle = async addr => {
147
154
  trace('removeOracle', addr);
148
155
  await E(faKit.creator).removeOracle(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
- }
156
+ await (highPrioritySendersManager &&
157
+ E(highPrioritySendersManager).remove(description, addr));
153
158
  return `removed ${addr}`;
154
159
  };
155
160
 
156
161
  const governedApis = {
157
162
  /**
158
- * Add the specified oracles. May partially fail, such that some oracles are added and others aren't.
163
+ * Add the specified oracles. May partially fail, such that some oracles are
164
+ * added and others aren't.
159
165
  *
160
166
  * @param {string[]} addrs
161
- * @returns {Promise<Array<PromiseSettledResult<string>>>}
167
+ * @returns {Promise<PromiseSettledResult<string>[]>}
162
168
  */
163
169
  addOracles: addrs => {
164
170
  return Promise.allSettled(addrs.map(addOracle));
165
171
  },
166
172
  /**
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
173
+ * Remove the specified oracles. May partially fail, such that some oracles
174
+ * are removed and others aren't. If the oracle was never part of the set
175
+ * that's a PromiseRejectedResult
169
176
  *
170
177
  * @param {string[]} addrs
171
- * @returns {Promise<Array<PromiseSettledResult<string>>>}
178
+ * @returns {Promise<PromiseSettledResult<string>[]>}
172
179
  */
173
180
  removeOracles: addrs => {
174
181
  return Promise.allSettled(addrs.map(removeOracle));
@@ -187,4 +194,6 @@ export const prepare = async (zcf, privateArgs, baggage) => {
187
194
  publicFacet: faKit.public,
188
195
  });
189
196
  };
190
- harden(prepare);
197
+ harden(start);
198
+
199
+ /** @typedef {typeof start} FluxStartFn */
@@ -0,0 +1,103 @@
1
+ export const INVITATION_MAKERS_DESC: "oracle invitation";
2
+ export function prepareFluxAggregatorKit(baggage: Baggage, zcf: ZCF<ChainlinkConfig & {
3
+ timer: TimerService;
4
+ brandIn: Brand<"nat">;
5
+ brandOut: Brand<"nat">;
6
+ unitAmountIn?: Amount<"nat">;
7
+ }>, timerPresence: TimerService, quoteKit: import("./roundsManager.js").QuoteKit, storageNode: StorageNode, makeDurablePublishKit: () => PublishKit<any>, makeRecorder: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorder): Promise<() => import("@endo/exo").GuardedKit<{
8
+ creator: {
9
+ /**
10
+ * An "oracle invitation" is an invitation to be able to submit data to
11
+ * include in the priceAggregator's results.
12
+ *
13
+ * The offer result from this invitation is a OracleAdmin, which can be
14
+ * used directly to manage the price submissions as well as to terminate
15
+ * the relationship.
16
+ *
17
+ * @param {string} oracleId unique per contract instance
18
+ */
19
+ makeOracleInvitation(oracleId: string): Promise<Invitation<{
20
+ invitationMakers: {
21
+ /** @param {import('./roundsManager.js').PriceRound} result */
22
+ PushPrice(result: import("./roundsManager.js").PriceRound): Promise<Invitation<void, undefined>>;
23
+ } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
24
+ /** @param {import('./roundsManager.js').PriceRound} result */
25
+ PushPrice(result: import("./roundsManager.js").PriceRound): Promise<Invitation<void, undefined>>;
26
+ }>;
27
+ oracle: import("@endo/exo").Guarded<{
28
+ pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
29
+ getStatus(): OracleStatus;
30
+ }>;
31
+ }, undefined>>;
32
+ /** @param {string} oracleId */
33
+ removeOracle(oracleId: string): Promise<void>;
34
+ getRoundData: (roundIdRaw: any) => Promise<import("./roundsManager.js").RoundData>;
35
+ /** @param {string} oracleId */
36
+ initOracle(oracleId: string): Promise<import("@endo/exo").GuardedKit<{
37
+ admin: {
38
+ disable(): void;
39
+ };
40
+ oracle: {
41
+ pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
42
+ getStatus(): OracleStatus;
43
+ };
44
+ }>>;
45
+ /**
46
+ * a method to provide all current info oracleStatuses need. Intended
47
+ * only only to be callable by oracleStatuses. Not for use by contracts
48
+ * to read state.
49
+ *
50
+ * @param {string} oracleId
51
+ * @param {bigint} queriedRoundId
52
+ * @returns {Promise<RoundState>}
53
+ */
54
+ oracleRoundState(oracleId: string, queriedRoundId: bigint): Promise<RoundState>;
55
+ };
56
+ public: {
57
+ getPriceAuthority(): PriceAuthority;
58
+ getPublicTopics(): {
59
+ quotes: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<PriceDescription>;
60
+ latestRound: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./roundsManager.js").LatestRound>;
61
+ };
62
+ };
63
+ }>>;
64
+ export type RoundState = {
65
+ eligibleForSpecificRound: boolean;
66
+ queriedRoundId: bigint;
67
+ latestSubmission: bigint;
68
+ startedAt: Timestamp;
69
+ roundTimeout: number;
70
+ oracleCount: number;
71
+ };
72
+ export type ChainlinkConfig = {
73
+ maxSubmissionCount: number;
74
+ minSubmissionCount: number;
75
+ /**
76
+ * the number of rounds an Oracle has to wait
77
+ * before they can initiate a round
78
+ */
79
+ restartDelay: bigint;
80
+ /**
81
+ * an immutable check for a lower bound of
82
+ * what submission values are accepted from an oracle
83
+ */
84
+ minSubmissionValue: number;
85
+ /**
86
+ * an immutable check for an upper bound
87
+ * of what submission values are accepted from an oracle
88
+ */
89
+ maxSubmissionValue: number;
90
+ /**
91
+ * the number of seconds after the previous round
92
+ * that allowed to lapse before allowing an oracle to skip an unfinished
93
+ * round
94
+ */
95
+ timeout: number;
96
+ };
97
+ export type FluxAggregatorKit = ReturnType<Awaited<ReturnType<typeof prepareFluxAggregatorKit>>>;
98
+ import type { Baggage } from '@agoric/vat-data';
99
+ import type { TimerService } from '@agoric/time';
100
+ import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
101
+ import type { PriceDescription } from '@agoric/zoe/tools/types.js';
102
+ import type { Timestamp } from '@agoric/time';
103
+ //# sourceMappingURL=fluxAggregatorKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fluxAggregatorKit.d.ts","sourceRoot":"","sources":["fluxAggregatorKit.js"],"names":[],"mappings":"AA2BA,yDAA0D;AAgEnD,kDAfI,OAAO,OACP,GAAG,CACT,eAAe,GAAG;IAChB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC9B,CACF,iBACO,YAAY,YACZ,OAAO,oBAAoB,EAAE,QAAQ,eACrC,WAAW,yBACX,MAAM,UAAU,CAAC,GAAG,CAAC,gBACrB,OAAO,6CAA6C,EAAE,YAAY;;QA+IrE;;;;;;;;;WASG;uCADQ,MAAM;;gBAiBX,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;gBAAnD,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;;;;;;QAqBzD,+BAA+B;+BAAnB,MAAM;;QAalB,+BAA+B;6BAAnB,MAAM;;;;;;;;;QAoBlB;;;;;;;;WAQG;mCAHQ,MAAM,kBACN,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC;;;;;;;;;IAqDvC;;8BAxUa,OAAO;oBACP,MAAM;sBACN,MAAM;eACN,SAAS;kBACT,MAAM;iBACN,MAAM;;;wBAMN,MAAM;wBACN,MAAM;;;;;kBACN,MAAM;;;;;wBAEN,MAAM;;;;;wBAEN,MAAM;;;;;;aAEN,MAAM;;gCAuTN,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;6BAvVpD,kBAAkB;kCAKb,cAAc;oCAbgD,4BAA4B;sCAA5B,4BAA4B;+BAS7F,cAAc"}
@@ -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,22 @@ import { Far } from '@endo/marshal';
18
18
  import { prepareOracleAdminKit } from './priceOracleKit.js';
19
19
  import { prepareRoundsManagerKit } from './roundsManager.js';
20
20
 
21
+ /**
22
+ * @import {TypedPattern} from '@agoric/internal';
23
+ * @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
24
+ */
25
+
21
26
  const trace = makeTracer('FlxAgg', true);
22
27
 
23
28
  export const INVITATION_MAKERS_DESC = 'oracle invitation';
24
29
 
25
30
  /**
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
31
+ * @import {Baggage} from '@agoric/vat-data'
32
+ * @import {Timestamp} from '@agoric/time'
33
+ * @import {RelativeTime} from '@agoric/time'
34
+ * RelativeTime, not RelativeTimeValue
35
+ * @import {RelativeTimeValue} from '@agoric/time'
36
+ * @import {TimerService} from '@agoric/time'
32
37
  */
33
38
 
34
39
  /** @type {(quote: PriceQuote) => PriceDescription} */
@@ -49,30 +54,35 @@ const priceDescriptionFromQuote = quote => quote.quoteAmount.value[0];
49
54
  * @typedef {object} ChainlinkConfig
50
55
  * @property {number} maxSubmissionCount
51
56
  * @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
57
+ * @property {bigint} restartDelay the number of rounds an Oracle has to wait
58
+ * before they can initiate a round
59
+ * @property {number} minSubmissionValue an immutable check for a lower bound of
60
+ * what submission values are accepted from an oracle
61
+ * @property {number} maxSubmissionValue an immutable check for an upper bound
62
+ * of what submission values are accepted from an oracle
63
+ * @property {number} timeout the number of seconds after the previous round
64
+ * that allowed to lapse before allowing an oracle to skip an unfinished
65
+ * round
59
66
  */
60
67
 
61
68
  /**
62
- * Returns a maker for a single durable FluxAggregatorKit, closed over the prepare() arguments.
69
+ * Returns a maker for a single durable FluxAggregatorKit, closed over the
70
+ * prepare() arguments.
63
71
  *
64
72
  * 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
73
+ * simpler `priceAggregator.js`, this approximates the _Node Operator
74
+ * Aggregation_ logic of [Chainlink price
67
75
  * feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
68
76
  *
69
77
  * @param {Baggage} baggage
70
- * @param {ZCF<ChainlinkConfig & {
71
- * timer: TimerService,
72
- * brandIn: Brand<'nat'>,
73
- * brandOut: Brand<'nat'>,
74
- * unitAmountIn?: Amount<'nat'>,
75
- * }>} zcf
78
+ * @param {ZCF<
79
+ * ChainlinkConfig & {
80
+ * timer: TimerService;
81
+ * brandIn: Brand<'nat'>;
82
+ * brandOut: Brand<'nat'>;
83
+ * unitAmountIn?: Amount<'nat'>;
84
+ * }
85
+ * >} zcf
76
86
  * @param {TimerService} timerPresence
77
87
  * @param {import('./roundsManager.js').QuoteKit} quoteKit
78
88
  * @param {StorageNode} storageNode
@@ -128,23 +138,24 @@ export const prepareFluxAggregatorKit = async (
128
138
  // end of maker definitions /////////////////////////////////
129
139
 
130
140
  const { answerKit, latestRoundKit, priceKit } = await provideAll(baggage, {
131
- /** This is just a signal that there's a new answer, which is read from `lastValueOutForUnitIn` */
141
+ /**
142
+ * This is just a signal that there's a new answer, which is read from
143
+ * `lastValueOutForUnitIn`
144
+ */
132
145
  answerKit: () => makeDurablePublishKit(),
133
146
  /** For publishing priceAuthority values to off-chain storage */
134
147
  priceKit: () =>
135
148
  makeRecorderKit(
136
149
  storageNode,
137
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<PriceDescription>} */ (
138
- M.any()
139
- ),
150
+ /** @type {TypedPattern<PriceDescription>} */ (M.any()),
140
151
  ),
141
152
  latestRoundKit: () =>
142
153
  E.when(E(storageNode).makeChildNode('latestRound'), node =>
143
154
  makeRecorderKit(
144
155
  node,
145
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<import('./roundsManager.js').LatestRound>} */ (
146
- M.any()
147
- ),
156
+ /**
157
+ * @type {TypedPattern<import('./roundsManager.js').LatestRound>}
158
+ */ (M.any()),
148
159
  ),
149
160
  ),
150
161
  });
@@ -223,9 +234,9 @@ export const prepareFluxAggregatorKit = async (
223
234
  * An "oracle invitation" is an invitation to be able to submit data to
224
235
  * include in the priceAggregator's results.
225
236
  *
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.
237
+ * The offer result from this invitation is a OracleAdmin, which can be
238
+ * used directly to manage the price submissions as well as to terminate
239
+ * the relationship.
229
240
  *
230
241
  * @param {string} oracleId unique per contract instance
231
242
  */
@@ -235,12 +246,13 @@ export const prepareFluxAggregatorKit = async (
235
246
  /**
236
247
  * If custom arguments are supplied to the `zoe.offer` call, they can
237
248
  * indicate an OraclePriceSubmission notifier and a corresponding
238
- * `shiftValueOut` that should be adapted as part of the priceAuthority's
239
- * reported data.
249
+ * `shiftValueOut` that should be adapted as part of the
250
+ * priceAuthority's reported data.
240
251
  *
241
252
  * @param {ZCFSeat} seat
242
253
  */
243
254
  const offerHandler = async seat => {
255
+ seat.exit();
244
256
  const { oracle } = await facets.creator.initOracle(oracleId);
245
257
  const invitationMakers = Far('invitation makers', {
246
258
  /** @param {import('./roundsManager.js').PriceRound} result */
@@ -255,7 +267,6 @@ export const prepareFluxAggregatorKit = async (
255
267
  );
256
268
  },
257
269
  });
258
- seat.exit();
259
270
 
260
271
  return harden({
261
272
  invitationMakers,
@@ -299,8 +310,9 @@ export const prepareFluxAggregatorKit = async (
299
310
  },
300
311
 
301
312
  /**
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.
313
+ * a method to provide all current info oracleStatuses need. Intended
314
+ * only only to be callable by oracleStatuses. Not for use by contracts
315
+ * to read state.
304
316
  *
305
317
  * @param {string} oracleId
306
318
  * @param {bigint} queriedRoundId
@@ -0,0 +1,38 @@
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 = ReturnType<ReturnType<typeof prepareOracleAdminKit>>;
38
+ //# sourceMappingURL=priceOracleKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priceOracleKit.d.ts","sourceRoot":"","sources":["priceOracleKit.js"],"names":[],"mappings":"AAMA,yDAA0D;AA4DnD;;;;;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,UAAU,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -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
 
@@ -8,14 +8,17 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
8
8
 
9
9
  /**
10
10
  * @typedef {{
11
- * oracleId: string,
12
- * roundPowers: { handlePush: (status: OracleStatus, result: import('./roundsManager.js').PriceRound) => Promise<OracleStatus> }
11
+ * oracleId: string;
12
+ * roundPowers: {
13
+ * handlePush: (
14
+ * status: OracleStatus,
15
+ * result: import('./roundsManager.js').PriceRound,
16
+ * ) => Promise<OracleStatus>;
17
+ * };
13
18
  * }} HeldParams
14
19
  */
15
20
 
16
- /**
17
- * @typedef {{ roundId: number | undefined, unitPrice: NatValue }} PriceDatum
18
- */
21
+ /** @typedef {{ roundId: number | undefined; unitPrice: NatValue }} PriceDatum */
19
22
 
20
23
  /**
21
24
  * @typedef {object} OracleStatus
@@ -26,11 +29,9 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
26
29
  * @property {string} oracleId
27
30
  */
28
31
  /**
29
- * @typedef {Readonly<HeldParams & {
30
- * }>} ImmutableState
32
+ * @typedef {Readonly<HeldParams & {}>} ImmutableState
31
33
  *
32
- * @typedef {OracleStatus & {
33
- * }} MutableState
34
+ * @typedef {OracleStatus & {}} MutableState
34
35
  */
35
36
  /** @typedef {ImmutableState & MutableState} State */
36
37
 
@@ -106,10 +107,7 @@ export const prepareOracleAdminKit = baggage =>
106
107
  state.lastStartedRound = result.lastStartedRound;
107
108
  state.latestSubmission = result.latestSubmission;
108
109
  },
109
- /**
110
- *
111
- * @returns {OracleStatus}
112
- */
110
+ /** @returns {OracleStatus} */
113
111
  getStatus() {
114
112
  const { state } = this;
115
113
  return {