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