@agoric/inter-protocol 0.16.2-upgrade-14-dev-c8f9e7b.0 → 0.16.2-upgrade-16-fi-dev-8879538.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 (175) hide show
  1. package/package.json +41 -34
  2. package/scripts/build-bundles.js +5 -21
  3. package/src/auction/auctionBook.d.ts +84 -0
  4. package/src/auction/auctionBook.d.ts.map +1 -0
  5. package/src/auction/auctionBook.js +135 -103
  6. package/src/auction/auctioneer.d.ts +83 -0
  7. package/src/auction/auctioneer.d.ts.map +1 -0
  8. package/src/auction/auctioneer.js +63 -49
  9. package/src/auction/offerBook.d.ts +45 -0
  10. package/src/auction/offerBook.d.ts.map +1 -0
  11. package/src/auction/offerBook.js +13 -12
  12. package/src/auction/params.d.ts +149 -0
  13. package/src/auction/params.d.ts.map +1 -0
  14. package/src/auction/params.js +10 -9
  15. package/src/auction/scheduleMath.d.ts +5 -0
  16. package/src/auction/scheduleMath.d.ts.map +1 -0
  17. package/src/auction/scheduleMath.js +17 -15
  18. package/src/auction/scheduler.d.ts +49 -0
  19. package/src/auction/scheduler.d.ts.map +1 -0
  20. package/src/auction/scheduler.js +51 -43
  21. package/src/auction/sortedOffers.d.ts +8 -0
  22. package/src/auction/sortedOffers.d.ts.map +1 -0
  23. package/src/auction/sortedOffers.js +9 -7
  24. package/src/auction/util.d.ts +32 -0
  25. package/src/auction/util.d.ts.map +1 -0
  26. package/src/auction/util.js +6 -4
  27. package/src/clientSupport.d.ts +167 -0
  28. package/src/clientSupport.d.ts.map +1 -0
  29. package/src/clientSupport.js +97 -40
  30. package/src/collectFees.d.ts +2 -0
  31. package/src/collectFees.d.ts.map +1 -0
  32. package/src/contractSupport.d.ts +28 -0
  33. package/src/contractSupport.d.ts.map +1 -0
  34. package/src/contractSupport.js +14 -12
  35. package/src/econCommitteeCharter.d.ts +39 -0
  36. package/src/econCommitteeCharter.d.ts.map +1 -0
  37. package/src/econCommitteeCharter.js +21 -20
  38. package/src/feeDistributor.d.ts +224 -0
  39. package/src/feeDistributor.d.ts.map +1 -0
  40. package/src/feeDistributor.js +37 -33
  41. package/src/index.d.ts +2 -0
  42. package/src/index.d.ts.map +1 -0
  43. package/src/index.js +1 -0
  44. package/src/interest-math.d.ts +3 -0
  45. package/src/interest-math.d.ts.map +1 -0
  46. package/src/interest.d.ts +28 -0
  47. package/src/interest.d.ts.map +1 -0
  48. package/src/interest.js +21 -16
  49. package/src/price/README.md +13 -0
  50. package/src/price/fluxAggregatorContract.d.ts +70 -0
  51. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  52. package/src/price/fluxAggregatorContract.js +62 -55
  53. package/src/price/fluxAggregatorKit.d.ts +103 -0
  54. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  55. package/src/price/fluxAggregatorKit.js +50 -37
  56. package/src/price/priceOracleKit.d.ts +38 -0
  57. package/src/price/priceOracleKit.d.ts.map +1 -0
  58. package/src/price/priceOracleKit.js +11 -13
  59. package/src/price/roundsManager.d.ts +238 -0
  60. package/src/price/roundsManager.d.ts.map +1 -0
  61. package/src/price/roundsManager.js +77 -82
  62. package/src/proposals/README.md +2 -3
  63. package/src/proposals/add-auction.d.ts +69 -0
  64. package/src/proposals/add-auction.d.ts.map +1 -0
  65. package/src/proposals/add-auction.js +181 -0
  66. package/src/proposals/addAssetToVault.d.ts +160 -0
  67. package/src/proposals/addAssetToVault.d.ts.map +1 -0
  68. package/src/proposals/addAssetToVault.js +172 -38
  69. package/src/proposals/committee-proposal.d.ts +113 -0
  70. package/src/proposals/committee-proposal.d.ts.map +1 -0
  71. package/src/proposals/committee-proposal.js +25 -31
  72. package/src/proposals/core-proposal.d.ts +149 -0
  73. package/src/proposals/core-proposal.d.ts.map +1 -0
  74. package/src/proposals/core-proposal.js +9 -11
  75. package/src/proposals/econ-behaviors.d.ts +1169 -0
  76. package/src/proposals/econ-behaviors.d.ts.map +1 -0
  77. package/src/proposals/econ-behaviors.js +66 -45
  78. package/src/proposals/price-feed-proposal.d.ts +84 -0
  79. package/src/proposals/price-feed-proposal.d.ts.map +1 -0
  80. package/src/proposals/price-feed-proposal.js +108 -51
  81. package/src/proposals/startEconCommittee.d.ts +34 -0
  82. package/src/proposals/startEconCommittee.d.ts.map +1 -0
  83. package/src/proposals/startEconCommittee.js +2 -2
  84. package/src/proposals/startPSM.d.ts +59 -0
  85. package/src/proposals/startPSM.d.ts.map +1 -0
  86. package/src/proposals/startPSM.js +38 -27
  87. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
  88. package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
  89. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  90. package/src/proposals/upgrade-vaults.d.ts +35 -0
  91. package/src/proposals/upgrade-vaults.d.ts.map +1 -0
  92. package/src/proposals/upgrade-vaults.js +202 -0
  93. package/src/proposals/utils.d.ts +17 -0
  94. package/src/proposals/utils.d.ts.map +1 -0
  95. package/src/proposals/utils.js +34 -7
  96. package/src/provisionPool.d.ts +167 -0
  97. package/src/provisionPool.d.ts.map +1 -0
  98. package/src/provisionPool.js +122 -0
  99. package/src/provisionPoolKit.d.ts +770 -0
  100. package/src/provisionPoolKit.d.ts.map +1 -0
  101. package/src/provisionPoolKit.js +463 -0
  102. package/src/psm/psm.d.ts +122 -0
  103. package/src/psm/psm.d.ts.map +1 -0
  104. package/src/psm/psm.js +73 -69
  105. package/src/psm/types-ambient.d.ts +2 -0
  106. package/src/psm/types-ambient.d.ts.map +1 -0
  107. package/src/psm/types-ambient.js +3 -0
  108. package/src/reserve/assetReserve.d.ts +47 -0
  109. package/src/reserve/assetReserve.d.ts.map +1 -0
  110. package/src/reserve/assetReserve.js +28 -19
  111. package/src/reserve/assetReserveKit.d.ts +74 -0
  112. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  113. package/src/reserve/assetReserveKit.js +18 -24
  114. package/src/reserve/params.d.ts +10 -0
  115. package/src/reserve/params.d.ts.map +1 -0
  116. package/src/tokens.d.ts +3 -0
  117. package/src/tokens.d.ts.map +1 -0
  118. package/src/tokens.js +5 -0
  119. package/src/vaultFactory/burn.d.ts +2 -0
  120. package/src/vaultFactory/burn.d.ts.map +1 -0
  121. package/src/vaultFactory/burn.js +1 -1
  122. package/src/vaultFactory/liquidation.d.ts +163 -0
  123. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  124. package/src/vaultFactory/liquidation.js +36 -22
  125. package/src/vaultFactory/math.d.ts +11 -0
  126. package/src/vaultFactory/math.d.ts.map +1 -0
  127. package/src/vaultFactory/math.js +10 -9
  128. package/src/vaultFactory/orderedVaultStore.d.ts +360 -0
  129. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  130. package/src/vaultFactory/orderedVaultStore.js +8 -11
  131. package/src/vaultFactory/params.d.ts +145 -0
  132. package/src/vaultFactory/params.d.ts.map +1 -0
  133. package/src/vaultFactory/params.js +52 -24
  134. package/src/vaultFactory/prioritizedVaults.d.ts +992 -0
  135. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  136. package/src/vaultFactory/prioritizedVaults.js +4 -4
  137. package/src/vaultFactory/proceeds.d.ts +35 -0
  138. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  139. package/src/vaultFactory/proceeds.js +26 -18
  140. package/src/vaultFactory/storeUtils.d.ts +25 -0
  141. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  142. package/src/vaultFactory/storeUtils.js +10 -12
  143. package/src/vaultFactory/types-ambient.d.ts +234 -0
  144. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  145. package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
  146. package/src/vaultFactory/vault.d.ts +402 -0
  147. package/src/vaultFactory/vault.d.ts.map +1 -0
  148. package/src/vaultFactory/vault.js +99 -93
  149. package/src/vaultFactory/vaultDirector.d.ts +388 -0
  150. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultDirector.js +61 -50
  152. package/src/vaultFactory/vaultFactory.d.ts +277 -0
  153. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultFactory.js +49 -32
  155. package/src/vaultFactory/vaultHolder.d.ts +270 -0
  156. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  157. package/src/vaultFactory/vaultHolder.js +10 -14
  158. package/src/vaultFactory/vaultKit.d.ts +102 -0
  159. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  160. package/src/vaultFactory/vaultKit.js +5 -4
  161. package/src/vaultFactory/vaultManager.d.ts +819 -0
  162. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  163. package/src/vaultFactory/vaultManager.js +248 -151
  164. package/CHANGELOG.md +0 -1066
  165. package/exported.js +0 -2
  166. package/scripts/add-collateral-core.js +0 -113
  167. package/scripts/deploy-contracts.js +0 -100
  168. package/scripts/init-core.js +0 -200
  169. package/scripts/invite-committee-core.js +0 -42
  170. package/scripts/manual-price-feed.js +0 -117
  171. package/scripts/price-feed-core.js +0 -104
  172. package/scripts/start-local-chain.sh +0 -84
  173. package/src/psm/types.js +0 -3
  174. package/src/typeGuards.js +0 -13
  175. 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,4 @@ export const prepare = async (zcf, privateArgs, baggage) => {
187
194
  publicFacet: faKit.public,
188
195
  });
189
196
  };
190
- harden(prepare);
197
+ harden(start);
@@ -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/marshal").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(): import("./priceOracleKit.js").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(): import("./priceOracleKit.js").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":"AAwBA,yDAA0D;AAgEnD;;aAXS,KAAK,CAAC,KAAK,CAAC;cACX,KAAK,CAAC,KAAK,CAAC;mBACP,MAAM,CAAC,KAAK,CAAC;2CAIxB,OAAO,oBAAoB,EAAE,QAAQ,eACrC,WAAW,yBACX,MAAM,UAAU,CAAC,GAAG,CAAC,gBACrB,OAAO,6CAA6C,EAAE,YAAY;;QAmJrE;;;;;;;;;WASG;uCADQ,MAAM;;gBAiBX,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;gBAAnD,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;;yEA9MhE,UAAU;;;;QAmOH,+BAA+B;+BAAnB,MAAM;;QAalB,+BAA+B;6BAAnB,MAAM;;;;;;;;;QAoBlB;;;;;;;;WAQG;mCAHQ,MAAM,kBACN,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC;;;;;;;;;IAqDvC;;8BA5Ua,OAAO;oBACP,MAAM;sBACN,MAAM;;kBAEN,MAAM;iBACN,MAAM;;;wBAMN,MAAM;wBACN,MAAM;;;;;kBACN,MAAM;;;;;wBAEN,MAAM;;;;;wBAEN,MAAM;;;;;;aAEN,MAAM;;gCA2TN,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC;6BA3VpD,kBAAkB;kCAKb,cAAc;oCAZiD,4BAA4B;sCAA5B,4BAA4B;+BAQ9F,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,19 @@ import { Far } from '@endo/marshal';
18
18
  import { prepareOracleAdminKit } from './priceOracleKit.js';
19
19
  import { prepareRoundsManagerKit } from './roundsManager.js';
20
20
 
21
+ /** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
22
+
21
23
  const trace = makeTracer('FlxAgg', true);
22
24
 
23
25
  export const INVITATION_MAKERS_DESC = 'oracle invitation';
24
26
 
25
27
  /**
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
28
+ * @import {Baggage} from '@agoric/vat-data'
29
+ * @import {Timestamp} from '@agoric/time'
30
+ * @import {RelativeTime} from '@agoric/time'
31
+ * RelativeTime, not RelativeTimeValue
32
+ * @import {RelativeTimeValue} from '@agoric/time'
33
+ * @import {TimerService} from '@agoric/time'
32
34
  */
33
35
 
34
36
  /** @type {(quote: PriceQuote) => PriceDescription} */
@@ -49,30 +51,35 @@ const priceDescriptionFromQuote = quote => quote.quoteAmount.value[0];
49
51
  * @typedef {object} ChainlinkConfig
50
52
  * @property {number} maxSubmissionCount
51
53
  * @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
54
+ * @property {bigint} restartDelay the number of rounds an Oracle has to wait
55
+ * before they can initiate a round
56
+ * @property {number} minSubmissionValue an immutable check for a lower bound of
57
+ * what submission values are accepted from an oracle
58
+ * @property {number} maxSubmissionValue an immutable check for an upper bound
59
+ * of what submission values are accepted from an oracle
60
+ * @property {number} timeout the number of seconds after the previous round
61
+ * that allowed to lapse before allowing an oracle to skip an unfinished
62
+ * round
59
63
  */
60
64
 
61
65
  /**
62
- * Returns a maker for a single durable FluxAggregatorKit, closed over the prepare() arguments.
66
+ * Returns a maker for a single durable FluxAggregatorKit, closed over the
67
+ * prepare() arguments.
63
68
  *
64
69
  * 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
70
+ * simpler `priceAggregator.js`, this approximates the _Node Operator
71
+ * Aggregation_ logic of [Chainlink price
67
72
  * feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
68
73
  *
69
74
  * @param {Baggage} baggage
70
- * @param {ZCF<ChainlinkConfig & {
71
- * timer: TimerService,
72
- * brandIn: Brand<'nat'>,
73
- * brandOut: Brand<'nat'>,
74
- * unitAmountIn?: Amount<'nat'>,
75
- * }>} zcf
75
+ * @param {ZCF<
76
+ * ChainlinkConfig & {
77
+ * timer: TimerService;
78
+ * brandIn: Brand<'nat'>;
79
+ * brandOut: Brand<'nat'>;
80
+ * unitAmountIn?: Amount<'nat'>;
81
+ * }
82
+ * >} zcf
76
83
  * @param {TimerService} timerPresence
77
84
  * @param {import('./roundsManager.js').QuoteKit} quoteKit
78
85
  * @param {StorageNode} storageNode
@@ -128,7 +135,10 @@ export const prepareFluxAggregatorKit = async (
128
135
  // end of maker definitions /////////////////////////////////
129
136
 
130
137
  const { answerKit, latestRoundKit, priceKit } = await provideAll(baggage, {
131
- /** This is just a signal that there's a new answer, which is read from `lastValueOutForUnitIn` */
138
+ /**
139
+ * This is just a signal that there's a new answer, which is read from
140
+ * `lastValueOutForUnitIn`
141
+ */
132
142
  answerKit: () => makeDurablePublishKit(),
133
143
  /** For publishing priceAuthority values to off-chain storage */
134
144
  priceKit: () =>
@@ -142,9 +152,11 @@ export const prepareFluxAggregatorKit = async (
142
152
  E.when(E(storageNode).makeChildNode('latestRound'), node =>
143
153
  makeRecorderKit(
144
154
  node,
145
- /** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<import('./roundsManager.js').LatestRound>} */ (
146
- M.any()
147
- ),
155
+ /**
156
+ * @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<
157
+ * import('./roundsManager.js').LatestRound
158
+ * >}
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
@@ -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;IACZ,QAAY,EAAE,MAAM,CAAC;IACrB,WAAe,EAAE;QACjB,UAAgB,EAAE,CAClB,MAAc,EAAE,YAAY,EAC5B,MAAc,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"}
@@ -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 {