@agoric/inter-protocol 0.16.2-dev-5dc325b.0 → 0.16.2-getting-started-dev-d127d1d.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 +1057 -0
- package/package.json +30 -37
- 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 +59 -74
- 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 +39 -47
- package/src/auction/sortedOffers.js +7 -8
- package/src/auction/util.js +4 -4
- package/src/clientSupport.js +96 -154
- package/src/contractSupport.js +5 -5
- package/src/econCommitteeCharter.js +17 -18
- package/src/feeDistributor.js +33 -34
- package/src/interest.js +14 -20
- package/src/price/README.md +0 -13
- package/src/price/fluxAggregatorContract.js +53 -59
- package/src/price/fluxAggregatorKit.js +33 -48
- package/src/price/priceOracleKit.js +13 -11
- package/src/price/roundsManager.js +64 -52
- package/src/proposals/addAssetToVault.js +36 -170
- package/src/proposals/committee-proposal.js +27 -21
- package/src/proposals/core-proposal.js +7 -7
- package/src/proposals/econ-behaviors.js +32 -57
- package/src/proposals/price-feed-proposal.js +36 -71
- package/src/proposals/startEconCommittee.js +1 -1
- package/src/proposals/startPSM.js +22 -32
- package/src/proposals/utils.js +7 -32
- 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 +19 -25
- package/src/vaultFactory/prioritizedVaults.js +2 -2
- package/src/vaultFactory/proceeds.js +18 -24
- package/src/vaultFactory/storeUtils.js +12 -8
- package/src/vaultFactory/type-imports.js +1 -1
- package/src/vaultFactory/types.js +28 -38
- package/src/vaultFactory/vault.js +89 -88
- package/src/vaultFactory/vaultDirector.js +44 -35
- 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 -160
- package/src/proposals/addAssetToVault.d.ts.map +0 -1
- package/src/proposals/committee-proposal.d.ts +0 -113
- 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 -82
- 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 -17
- 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
package/src/interest.js
CHANGED
|
@@ -12,7 +12,6 @@ import { TimeMath } from '@agoric/time';
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
|
|
15
|
-
*
|
|
16
15
|
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
|
|
17
16
|
*/
|
|
18
17
|
|
|
@@ -21,7 +20,9 @@ const BASIS_POINTS = 10000;
|
|
|
21
20
|
// single digit APR is less than a basis point per day.
|
|
22
21
|
const LARGE_DENOMINATOR = BASIS_POINTS * BASIS_POINTS;
|
|
23
22
|
|
|
24
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Number chosen from 6 digits for a basis point, doubled for multiplication.
|
|
25
|
+
*/
|
|
25
26
|
const COMPOUNDED_INTEREST_DENOMINATOR = 10n ** 20n;
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -146,27 +147,20 @@ const validatedBrand = (mint, debt) => {
|
|
|
146
147
|
* Charge interest accrued between `latestInterestUpdate` and `accruedUntil`.
|
|
147
148
|
*
|
|
148
149
|
* @param {{
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* }} powers
|
|
150
|
+
* mint: ZCFMint<'nat'>,
|
|
151
|
+
* mintAndTransferWithFee: MintAndTransfer,
|
|
152
|
+
* poolIncrementSeat: ZCFSeat,
|
|
153
|
+
* seatAllocationKeyword: Keyword }} powers
|
|
154
154
|
* @param {{
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* }} params
|
|
155
|
+
* interestRate: Ratio,
|
|
156
|
+
* chargingPeriod: RelativeTime,
|
|
157
|
+
* recordingPeriod: RelativeTime}} params
|
|
159
158
|
* @param {{
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* }} prior
|
|
159
|
+
* latestInterestUpdate: Timestamp,
|
|
160
|
+
* compoundedInterest: Ratio,
|
|
161
|
+
* totalDebt: Amount<'nat'>}} prior
|
|
164
162
|
* @param {Timestamp} accruedUntil
|
|
165
|
-
* @returns {{
|
|
166
|
-
* compoundedInterest: Ratio;
|
|
167
|
-
* latestInterestUpdate: Timestamp;
|
|
168
|
-
* totalDebt: Amount<'nat'>;
|
|
169
|
-
* }}
|
|
163
|
+
* @returns {{compoundedInterest: Ratio, latestInterestUpdate: Timestamp, totalDebt: Amount<'nat'> }}
|
|
170
164
|
*/
|
|
171
165
|
export const chargeInterest = (powers, params, prior, accruedUntil) => {
|
|
172
166
|
const brand = validatedBrand(powers.mint, prior.totalDebt);
|
package/src/price/README.md
CHANGED
|
@@ -4,19 +4,6 @@ This directory contains the `fluxAggregatorKit.js` contract which takes prices a
|
|
|
4
4
|
input and outputs a best known price. There are multiple ways to get the price,
|
|
5
5
|
including a PriceAuthority interface.
|
|
6
6
|
|
|
7
|
-
## Design
|
|
8
|
-
|
|
9
|
-
The authorities are hierarchical. Many authorities can be registered in the priceAuthorityRegistry.
|
|
10
|
-
|
|
11
|
-
For oracles, there must be two: the negotiable brand and the _oracle_ brand (an inert one).
|
|
12
|
-
|
|
13
|
-
The intended flow is that:
|
|
14
|
-
1. a negotiable brand is created (e.g. ATOM)
|
|
15
|
-
2. a price provider says “i can give you quotes for that” and runs price-feed-proposal. That makes “oracleBrands” (which are inert and have a separate identity so that they don’t have the authority to say they’re the real quote for it).
|
|
16
|
-
3. Some higher authority (eg EC, Stakers) decides that should be the quote source for negotiable brand so it registers it under the real brand identity in the registry (with a new instance of a scaledPriceAuthority ).
|
|
17
|
-
|
|
18
|
-
In practice we do these all in one core proposal. And each vault manager is started with a limit on minting to the EC has another way to gate transactions.
|
|
19
|
-
|
|
20
7
|
## Usage
|
|
21
8
|
|
|
22
9
|
See the [Smart Wallet integration test](/packages/inter-protocol/test/smartWallet/test-oracle-integration.js) for how it's used.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
hasIssuer,
|
|
5
|
+
makeDurableIssuerKit,
|
|
6
|
+
prepareIssuerKit,
|
|
7
|
+
} from '@agoric/ertp';
|
|
4
8
|
import { handleParamGovernance } from '@agoric/governance';
|
|
5
9
|
import { makeTracer, StorageNodeShape } from '@agoric/internal';
|
|
6
10
|
import { prepareDurablePublishKit } from '@agoric/notifier';
|
|
@@ -14,67 +18,55 @@ import { prepareFluxAggregatorKit } from './fluxAggregatorKit.js';
|
|
|
14
18
|
const trace = makeTracer('FluxAgg', false);
|
|
15
19
|
/**
|
|
16
20
|
* @typedef {import('@agoric/vat-data').Baggage} Baggage
|
|
17
|
-
*
|
|
18
21
|
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
|
|
19
22
|
*/
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
),
|
|
39
|
-
upgradability: 'canUpgrade',
|
|
40
|
-
};
|
|
41
|
-
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
|
+
);
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
|
-
* PriceAuthority for their median. Unlike the simpler `priceAggregator.js`,
|
|
45
|
-
*
|
|
42
|
+
* PriceAuthority for their median. Unlike the simpler `priceAggregator.js`, this approximates
|
|
43
|
+
* the *Node Operator Aggregation* logic of [Chainlink price
|
|
46
44
|
* feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
|
|
47
45
|
*
|
|
48
|
-
* @param {ZCF<
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* }
|
|
56
|
-
* >} 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
|
|
57
53
|
* @param {{
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
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,
|
|
63
59
|
* }} privateArgs
|
|
64
60
|
* @param {Baggage} baggage
|
|
65
61
|
*/
|
|
66
|
-
export const
|
|
62
|
+
export const prepare = async (zcf, privateArgs, baggage) => {
|
|
67
63
|
trace('prepare with baggage keys', [...baggage.keys()]);
|
|
68
64
|
|
|
69
65
|
// xxx uses contract baggage as issuerBagage, assumes one issuer in this contract
|
|
70
66
|
/** @type {import('./roundsManager.js').QuoteKit} */
|
|
71
|
-
const quoteIssuerKit =
|
|
72
|
-
baggage
|
|
73
|
-
'quote',
|
|
74
|
-
'set',
|
|
75
|
-
undefined,
|
|
76
|
-
undefined,
|
|
77
|
-
);
|
|
67
|
+
const quoteIssuerKit = hasIssuer(baggage)
|
|
68
|
+
? prepareIssuerKit(baggage)
|
|
69
|
+
: makeDurableIssuerKit(baggage, 'quote', 'set');
|
|
78
70
|
|
|
79
71
|
const {
|
|
80
72
|
highPrioritySendersManager,
|
|
@@ -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,13 +235,12 @@ export const prepareFluxAggregatorKit = async (
|
|
|
249
235
|
/**
|
|
250
236
|
* If custom arguments are supplied to the `zoe.offer` call, they can
|
|
251
237
|
* indicate an OraclePriceSubmission notifier and a corresponding
|
|
252
|
-
* `shiftValueOut` that should be adapted as part of the
|
|
253
|
-
*
|
|
238
|
+
* `shiftValueOut` that should be adapted as part of the priceAuthority's
|
|
239
|
+
* reported data.
|
|
254
240
|
*
|
|
255
241
|
* @param {ZCFSeat} seat
|
|
256
242
|
*/
|
|
257
243
|
const offerHandler = async seat => {
|
|
258
|
-
seat.exit();
|
|
259
244
|
const { oracle } = await facets.creator.initOracle(oracleId);
|
|
260
245
|
const invitationMakers = Far('invitation makers', {
|
|
261
246
|
/** @param {import('./roundsManager.js').PriceRound} result */
|
|
@@ -270,6 +255,7 @@ export const prepareFluxAggregatorKit = async (
|
|
|
270
255
|
);
|
|
271
256
|
},
|
|
272
257
|
});
|
|
258
|
+
seat.exit();
|
|
273
259
|
|
|
274
260
|
return harden({
|
|
275
261
|
invitationMakers,
|
|
@@ -313,9 +299,8 @@ export const prepareFluxAggregatorKit = async (
|
|
|
313
299
|
},
|
|
314
300
|
|
|
315
301
|
/**
|
|
316
|
-
* a method to provide all current info oracleStatuses need. Intended
|
|
317
|
-
* only
|
|
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 {
|