@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-3eb1a1d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +42 -36
- package/scripts/build-bundles.js +5 -21
- package/src/auction/auctionBook.d.ts +147 -0
- package/src/auction/auctionBook.d.ts.map +1 -0
- package/src/auction/auctionBook.js +156 -150
- package/src/auction/auctionMath.d.ts +17 -0
- package/src/auction/auctionMath.d.ts.map +1 -0
- package/src/auction/auctionMath.js +81 -0
- package/src/auction/auctioneer.d.ts +69 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +70 -59
- package/src/auction/offerBook.d.ts +45 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +13 -12
- package/src/auction/params.d.ts +144 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +10 -9
- package/src/auction/scheduleMath.d.ts +5 -0
- package/src/auction/scheduleMath.d.ts.map +1 -0
- package/src/auction/scheduleMath.js +18 -16
- package/src/auction/scheduler.d.ts +50 -0
- package/src/auction/scheduler.d.ts.map +1 -0
- package/src/auction/scheduler.js +53 -47
- package/src/auction/sortedOffers.d.ts +8 -0
- package/src/auction/sortedOffers.d.ts.map +1 -0
- package/src/auction/sortedOffers.js +10 -9
- package/src/auction/util.d.ts +30 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +9 -6
- package/src/clientSupport.d.ts +167 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +155 -97
- package/src/collectFees.d.ts +2 -0
- package/src/collectFees.d.ts.map +1 -0
- package/src/contractSupport.d.ts +28 -0
- package/src/contractSupport.d.ts.map +1 -0
- package/src/contractSupport.js +19 -13
- package/src/econCommitteeCharter.d.ts +40 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +21 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +37 -33
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +1 -0
- package/src/interest-math.d.ts +3 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest.d.ts +28 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +23 -18
- package/src/price/README.md +13 -0
- package/src/price/fluxAggregatorContract.d.ts +71 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -0
- package/src/price/fluxAggregatorContract.js +64 -55
- package/src/price/fluxAggregatorKit.d.ts +103 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +52 -40
- package/src/price/priceOracleKit.d.ts +38 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +12 -14
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +131 -85
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.d.ts +109 -0
- package/src/proposals/add-auction.d.ts.map +1 -0
- package/src/proposals/add-auction.js +256 -0
- package/src/proposals/addAssetToVault.d.ts +173 -0
- package/src/proposals/addAssetToVault.d.ts.map +1 -0
- package/src/proposals/addAssetToVault.js +192 -40
- package/src/proposals/committee-proposal.d.ts +113 -0
- package/src/proposals/committee-proposal.d.ts.map +1 -0
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.d.ts +149 -0
- package/src/proposals/core-proposal.d.ts.map +1 -0
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/deploy-price-feeds.d.ts +76 -0
- package/src/proposals/deploy-price-feeds.d.ts.map +1 -0
- package/src/proposals/deploy-price-feeds.js +316 -0
- package/src/proposals/econ-behaviors.d.ts +541 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -0
- package/src/proposals/econ-behaviors.js +64 -45
- package/src/proposals/price-feed-proposal.d.ts +84 -0
- package/src/proposals/price-feed-proposal.d.ts.map +1 -0
- package/src/proposals/price-feed-proposal.js +109 -51
- package/src/proposals/replace-fee-distributor.d.ts +48 -0
- package/src/proposals/replace-fee-distributor.d.ts.map +1 -0
- package/src/proposals/replace-fee-distributor.js +195 -0
- package/src/proposals/replace-scaledPriceAuthorities.d.ts +30 -0
- package/src/proposals/replace-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
- package/src/proposals/replaceElectorate.d.ts +55 -0
- package/src/proposals/replaceElectorate.d.ts.map +1 -0
- package/src/proposals/replaceElectorate.js +521 -0
- package/src/proposals/startEconCommittee.d.ts +34 -0
- package/src/proposals/startEconCommittee.d.ts.map +1 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.d.ts +59 -0
- package/src/proposals/startPSM.d.ts.map +1 -0
- package/src/proposals/startPSM.js +44 -29
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.d.ts +41 -0
- package/src/proposals/upgrade-vaults.d.ts.map +1 -0
- package/src/proposals/upgrade-vaults.js +202 -0
- package/src/proposals/utils.d.ts +19 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +43 -9
- package/src/provisionPool.d.ts +163 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +122 -0
- package/src/provisionPoolKit.d.ts +359 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +522 -0
- package/src/psm/psm.d.ts +125 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +80 -79
- package/src/psm/types-ambient.d.ts +2 -0
- package/src/psm/types-ambient.d.ts.map +1 -0
- package/src/psm/types-ambient.js +3 -0
- package/src/reserve/assetReserve.d.ts +47 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +28 -19
- package/src/reserve/assetReserveKit.d.ts +74 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +24 -30
- package/src/reserve/params.d.ts +10 -0
- package/src/reserve/params.d.ts.map +1 -0
- package/src/tokens.d.ts +3 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +5 -0
- package/src/vaultFactory/burn.d.ts +2 -0
- package/src/vaultFactory/burn.d.ts.map +1 -0
- package/src/vaultFactory/burn.js +1 -1
- package/src/vaultFactory/liquidation.d.ts +23 -0
- package/src/vaultFactory/liquidation.d.ts.map +1 -0
- package/src/vaultFactory/liquidation.js +37 -24
- package/src/vaultFactory/math.d.ts +11 -0
- package/src/vaultFactory/math.d.ts.map +1 -0
- package/src/vaultFactory/math.js +10 -9
- package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +8 -11
- package/src/vaultFactory/params.d.ts +140 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +52 -24
- package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +4 -4
- package/src/vaultFactory/proceeds.d.ts +35 -0
- package/src/vaultFactory/proceeds.d.ts.map +1 -0
- package/src/vaultFactory/proceeds.js +26 -18
- package/src/vaultFactory/storeUtils.d.ts +25 -0
- package/src/vaultFactory/storeUtils.d.ts.map +1 -0
- package/src/vaultFactory/storeUtils.js +10 -12
- package/src/vaultFactory/types-ambient.d.ts +137 -0
- package/src/vaultFactory/types-ambient.d.ts.map +1 -0
- package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
- package/src/vaultFactory/vault.d.ts +343 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +105 -99
- package/src/vaultFactory/vaultDirector.d.ts +341 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +86 -64
- package/src/vaultFactory/vaultFactory.d.ts +202 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +52 -33
- package/src/vaultFactory/vaultHolder.d.ts +126 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +11 -16
- package/src/vaultFactory/vaultKit.d.ts +32 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +5 -4
- package/src/vaultFactory/vaultManager.d.ts +674 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +257 -158
- package/CHANGELOG.md +0 -1041
- package/exported.js +0 -2
- package/scripts/add-collateral-core.js +0 -112
- package/scripts/deploy-contracts.js +0 -100
- package/scripts/init-core.js +0 -198
- package/scripts/invite-committee-core.js +0 -42
- package/scripts/manual-price-feed.js +0 -117
- package/scripts/price-feed-core.js +0 -104
- package/scripts/start-local-chain.sh +0 -84
- package/src/psm/types.js +0 -3
- package/src/typeGuards.js +0 -13
- package/src/vaultFactory/type-imports.js +0 -4
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/** @type {bigint} */
|
|
2
|
+
export const ROUND_MAX: bigint;
|
|
3
|
+
export function prepareRoundsManagerKit(baggage: any): (args_0: Readonly<import("./fluxAggregatorKit.js").ChainlinkConfig & {
|
|
4
|
+
quoteKit: QuoteKit;
|
|
5
|
+
answerPublisher: Publisher<void>;
|
|
6
|
+
brandIn: Brand<"nat">;
|
|
7
|
+
brandOut: Brand<"nat">;
|
|
8
|
+
latestRoundPublisher: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<LatestRound>;
|
|
9
|
+
timerPresence: TimerService;
|
|
10
|
+
}> & {
|
|
11
|
+
unitAmountIn: Amount<"nat">;
|
|
12
|
+
}) => import("@endo/exo").GuardedKit<{
|
|
13
|
+
helper: {
|
|
14
|
+
/** @param {bigint} roundId */
|
|
15
|
+
acceptingSubmissions(roundId: bigint): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @param {OracleStatus} status
|
|
18
|
+
* @param {bigint} roundId
|
|
19
|
+
*/
|
|
20
|
+
delayed(status: OracleStatus, roundId: bigint): boolean;
|
|
21
|
+
/** @param {bigint} roundId */
|
|
22
|
+
deleteRoundDetails(roundId: bigint): void;
|
|
23
|
+
/** @param {bigint} roundId */
|
|
24
|
+
isNextRound(roundId: bigint): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @param {bigint} roundId
|
|
27
|
+
* @param {Timestamp} blockTimestamp
|
|
28
|
+
* @param {string} oracleId
|
|
29
|
+
*/
|
|
30
|
+
initializeNewRound(roundId: bigint, blockTimestamp: Timestamp, oracleId: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* @param {bigint} roundId
|
|
33
|
+
* @param {bigint} rrId reporting round ID
|
|
34
|
+
*/
|
|
35
|
+
previousAndCurrentUnanswered(roundId: bigint, rrId: bigint): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @param {bigint} roundId
|
|
38
|
+
* @param {OracleStatus} status
|
|
39
|
+
* @param {Timestamp} blockTimestamp
|
|
40
|
+
* @returns {OracleStatus | undefined} the new status
|
|
41
|
+
*/
|
|
42
|
+
proposeNewRound(roundId: bigint, status: OracleStatus, blockTimestamp: Timestamp): OracleStatus | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* @param {bigint} submission
|
|
45
|
+
* @param {bigint} roundId
|
|
46
|
+
* @param {OracleStatus} status
|
|
47
|
+
* @returns {OracleStatus} the new status
|
|
48
|
+
*/
|
|
49
|
+
recordSubmission(submission: bigint, roundId: bigint, status: OracleStatus): OracleStatus;
|
|
50
|
+
/**
|
|
51
|
+
* @param {bigint} roundId
|
|
52
|
+
* @param {Timestamp} blockTimestamp
|
|
53
|
+
*/
|
|
54
|
+
supersedable(roundId: bigint, blockTimestamp: Timestamp): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* @param {bigint} roundId
|
|
57
|
+
* @param {Timestamp} blockTimestamp
|
|
58
|
+
*/
|
|
59
|
+
timedOut(roundId: bigint, blockTimestamp: Timestamp): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @param {bigint} roundId
|
|
62
|
+
* @param {Timestamp} blockTimestamp
|
|
63
|
+
*/
|
|
64
|
+
updateRoundAnswer(roundId: bigint, blockTimestamp: Timestamp): (number | boolean)[] | (bigint | boolean)[];
|
|
65
|
+
/**
|
|
66
|
+
* @param {bigint} roundId
|
|
67
|
+
* @param {Timestamp} blockTimestamp
|
|
68
|
+
*/
|
|
69
|
+
updateTimedOutRoundInfo(roundId: bigint, blockTimestamp: Timestamp): void;
|
|
70
|
+
/**
|
|
71
|
+
* @param {OracleStatus} status
|
|
72
|
+
* @param {bigint} roundId
|
|
73
|
+
* @param {Timestamp} blockTimestamp
|
|
74
|
+
* @returns {string | null} error message, if there is one
|
|
75
|
+
*/
|
|
76
|
+
validateOracleRound(status: OracleStatus, roundId: bigint, blockTimestamp: Timestamp): string | null;
|
|
77
|
+
};
|
|
78
|
+
contract: {
|
|
79
|
+
/** @param {PriceQuoteValue} quote */
|
|
80
|
+
authenticateQuote(quote: PriceQuoteValue): Promise<{
|
|
81
|
+
quoteAmount: import("@agoric/ertp").SetAmount<PriceDescription>;
|
|
82
|
+
quotePayment: globalThis.Payment<"set", PriceDescription>;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* @param {object} param0
|
|
86
|
+
* @param {number} [param0.overrideValueOut]
|
|
87
|
+
* @param {Timestamp} [param0.timestamp]
|
|
88
|
+
*/
|
|
89
|
+
makeCreateQuote({ overrideValueOut, timestamp }?: {
|
|
90
|
+
overrideValueOut?: number | undefined;
|
|
91
|
+
timestamp?: Timestamp | undefined;
|
|
92
|
+
}): ((priceQuery: any) => Promise<{
|
|
93
|
+
quoteAmount: import("@agoric/ertp").SetAmount<PriceDescription>;
|
|
94
|
+
quotePayment: globalThis.Payment<"set", PriceDescription>;
|
|
95
|
+
}> | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (priceQuery: any) => Promise<{
|
|
96
|
+
quoteAmount: import("@agoric/ertp").SetAmount<PriceDescription>;
|
|
97
|
+
quotePayment: globalThis.Payment<"set", PriceDescription>;
|
|
98
|
+
}> | undefined>;
|
|
99
|
+
/**
|
|
100
|
+
* @param {OracleStatus} status
|
|
101
|
+
* @param {bigint} queriedRoundId
|
|
102
|
+
* @param {Timestamp} blockTimestamp
|
|
103
|
+
*/
|
|
104
|
+
eligibleForSpecificRound(status: OracleStatus, queriedRoundId: bigint, blockTimestamp: Timestamp): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* consumers are encouraged to check that they're receiving fresh data
|
|
107
|
+
* by inspecting the updatedAt and answeredInRound return values.
|
|
108
|
+
*
|
|
109
|
+
* @param {bigint | number} roundIdRaw
|
|
110
|
+
* @returns {Promise<RoundData>}
|
|
111
|
+
*/
|
|
112
|
+
getRoundData(roundIdRaw: bigint | number): Promise<RoundData>;
|
|
113
|
+
/** @type {(roundId: bigint) => Readonly<RoundDetails & Round>} */
|
|
114
|
+
getRoundStatus(roundId: bigint): Readonly<RoundDetails & Round>;
|
|
115
|
+
/**
|
|
116
|
+
* a method to provide all current info oracleStatuses need. Intended
|
|
117
|
+
* only to be callable by oracleStatuses. Not for use by contracts to
|
|
118
|
+
* read state.
|
|
119
|
+
*
|
|
120
|
+
* @param {OracleStatus} status
|
|
121
|
+
* @param {Timestamp} blockTimestamp
|
|
122
|
+
*/
|
|
123
|
+
oracleRoundStateSuggestRound(status: OracleStatus, blockTimestamp: Timestamp): {
|
|
124
|
+
eligibleForSpecificRound: boolean;
|
|
125
|
+
queriedRoundId: bigint;
|
|
126
|
+
latestSubmission: bigint;
|
|
127
|
+
startedAt: Timestamp;
|
|
128
|
+
roundTimeout: number;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
oracle: {
|
|
132
|
+
/**
|
|
133
|
+
* push a unitPrice result from this oracle
|
|
134
|
+
*
|
|
135
|
+
* @param {OracleStatus} status
|
|
136
|
+
* @param {PriceRound} result
|
|
137
|
+
*/
|
|
138
|
+
handlePush(status: OracleStatus, { roundId: roundIdRaw, unitPrice: valueRaw }: PriceRound): Promise<OracleStatus>;
|
|
139
|
+
};
|
|
140
|
+
}>;
|
|
141
|
+
export type PriceRound = {
|
|
142
|
+
roundId: number | undefined;
|
|
143
|
+
unitPrice: NatValue;
|
|
144
|
+
};
|
|
145
|
+
export type LatestRound = Pick<RoundData, "roundId" | "startedAt"> & {
|
|
146
|
+
startedBy: string;
|
|
147
|
+
};
|
|
148
|
+
export type RoundData = Round & {
|
|
149
|
+
roundId: bigint;
|
|
150
|
+
};
|
|
151
|
+
export type Round = {
|
|
152
|
+
/**
|
|
153
|
+
* the answer for the given round
|
|
154
|
+
*/
|
|
155
|
+
answer: bigint;
|
|
156
|
+
/**
|
|
157
|
+
* the timestamp when the round was started.
|
|
158
|
+
* This is 0 if the round hasn't been started yet.
|
|
159
|
+
*/
|
|
160
|
+
startedAt: Timestamp;
|
|
161
|
+
/**
|
|
162
|
+
* the timestamp when the round last was updated
|
|
163
|
+
* (i.e. answer was last computed)
|
|
164
|
+
*/
|
|
165
|
+
updatedAt: Timestamp;
|
|
166
|
+
/**
|
|
167
|
+
* the round ID of the round in which the
|
|
168
|
+
* answer was computed. answeredInRound may be smaller than roundId when the
|
|
169
|
+
* round timed out. answeredInRound is equal to roundId when the round didn't
|
|
170
|
+
* time out and was completed regularly.
|
|
171
|
+
*/
|
|
172
|
+
answeredInRound: bigint;
|
|
173
|
+
};
|
|
174
|
+
export type RoundDetails = {
|
|
175
|
+
submissions: bigint[];
|
|
176
|
+
maxSubmissions: number;
|
|
177
|
+
minSubmissions: number;
|
|
178
|
+
roundTimeout: number;
|
|
179
|
+
};
|
|
180
|
+
export type QuoteKit = IssuerKit<"set", PriceDescription>;
|
|
181
|
+
export type HeldParams = Readonly<import("./fluxAggregatorKit.js").ChainlinkConfig & {
|
|
182
|
+
quoteKit: QuoteKit;
|
|
183
|
+
answerPublisher: Publisher<void>;
|
|
184
|
+
brandIn: Brand<"nat">;
|
|
185
|
+
brandOut: Brand<"nat">;
|
|
186
|
+
latestRoundPublisher: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<LatestRound>;
|
|
187
|
+
timerPresence: TimerService;
|
|
188
|
+
}>;
|
|
189
|
+
export type ImmutableState = Readonly<HeldParams & {
|
|
190
|
+
details: MapStore<bigint, RoundDetails>;
|
|
191
|
+
rounds: MapStore<bigint, Round>;
|
|
192
|
+
unitIn: bigint;
|
|
193
|
+
}>;
|
|
194
|
+
export type MutableState = {
|
|
195
|
+
lastValueOutForUnitIn: bigint | null;
|
|
196
|
+
reportingRoundId: bigint;
|
|
197
|
+
};
|
|
198
|
+
export type State = ImmutableState & MutableState;
|
|
199
|
+
import type { TimerService } from '@agoric/time';
|
|
200
|
+
import type { OracleStatus } from './priceOracleKit.js';
|
|
201
|
+
import type { Timestamp } from '@agoric/time';
|
|
202
|
+
import type { PriceQuoteValue } from '@agoric/zoe/tools/types.js';
|
|
203
|
+
import type { PriceDescription } from '@agoric/zoe/tools/types.js';
|
|
204
|
+
//# sourceMappingURL=roundsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roundsManager.d.ts","sourceRoot":"","sources":["roundsManager.js"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Fail, q } from '@
|
|
1
|
+
import { Fail, q } from '@endo/errors';
|
|
2
2
|
import { AmountMath } from '@agoric/ertp';
|
|
3
3
|
import { makeTracer } from '@agoric/internal';
|
|
4
|
-
import { TimeMath } from '@agoric/time';
|
|
4
|
+
import { TimeMath, TimestampShape } from '@agoric/time';
|
|
5
5
|
import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
|
|
6
6
|
import {
|
|
7
7
|
calculateMedian,
|
|
@@ -10,14 +10,14 @@ 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 '@agoric/internal/src/typeGuards.js';
|
|
14
14
|
|
|
15
15
|
const { add, subtract, multiply, floorDivide, ceilDivide, isGTE } = natSafeMath;
|
|
16
16
|
|
|
17
|
-
/** @typedef {import('./priceOracleKit.js').OracleStatus} OracleStatus */
|
|
18
17
|
/**
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
18
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
19
|
+
* @import {Timestamp, TimerService} from '@agoric/time'
|
|
20
|
+
* @import {OracleStatus} from './priceOracleKit.js'
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/** @type {string} */
|
|
@@ -26,36 +26,32 @@ const V3_NO_DATA_ERROR = 'No data present';
|
|
|
26
26
|
/** @type {bigint} */
|
|
27
27
|
export const ROUND_MAX = BigInt(2 ** 32 - 1);
|
|
28
28
|
|
|
29
|
-
const trace = makeTracer('RoundsM',
|
|
29
|
+
const trace = makeTracer('RoundsM', true);
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* @param {bigint} roundId
|
|
33
|
-
*/
|
|
31
|
+
/** @param {bigint} roundId */
|
|
34
32
|
const validRoundId = roundId => {
|
|
35
33
|
return roundId <= ROUND_MAX;
|
|
36
34
|
};
|
|
37
35
|
|
|
38
36
|
/**
|
|
39
|
-
* @typedef {{ roundId: number | undefined
|
|
37
|
+
* @typedef {{ roundId: number | undefined; unitPrice: NatValue }} PriceRound
|
|
40
38
|
*
|
|
41
|
-
* @typedef {Pick<RoundData, 'roundId' | 'startedAt'> &
|
|
39
|
+
* @typedef {Pick<RoundData, 'roundId' | 'startedAt'> & { startedBy: string }} LatestRound
|
|
42
40
|
*/
|
|
43
41
|
|
|
44
|
-
/**
|
|
45
|
-
* @typedef {Round & {roundId: bigint}} RoundData
|
|
46
|
-
*/
|
|
42
|
+
/** @typedef {Round & { roundId: bigint }} RoundData */
|
|
47
43
|
|
|
48
44
|
/**
|
|
49
45
|
* @typedef {object} Round
|
|
50
46
|
* @property {bigint} answer the answer for the given round
|
|
51
|
-
* @property {Timestamp} startedAt the timestamp when the round was started.
|
|
52
|
-
* if the round hasn't been started yet.
|
|
53
|
-
* @property {Timestamp} updatedAt the timestamp when the round last was updated
|
|
54
|
-
* answer was last computed)
|
|
55
|
-
* @property {bigint} answeredInRound the round ID of the round in which the
|
|
56
|
-
* was computed. answeredInRound may be smaller than roundId when the
|
|
57
|
-
* timed out. answeredInRound is equal to roundId when the round didn't
|
|
58
|
-
* and was completed regularly.
|
|
47
|
+
* @property {Timestamp} startedAt the timestamp when the round was started.
|
|
48
|
+
* This is 0 if the round hasn't been started yet.
|
|
49
|
+
* @property {Timestamp} updatedAt the timestamp when the round last was updated
|
|
50
|
+
* (i.e. answer was last computed)
|
|
51
|
+
* @property {bigint} answeredInRound the round ID of the round in which the
|
|
52
|
+
* answer was computed. answeredInRound may be smaller than roundId when the
|
|
53
|
+
* round timed out. answeredInRound is equal to roundId when the round didn't
|
|
54
|
+
* time out and was completed regularly.
|
|
59
55
|
*/
|
|
60
56
|
|
|
61
57
|
/**
|
|
@@ -66,29 +62,33 @@ const validRoundId = roundId => {
|
|
|
66
62
|
* @property {number} roundTimeout
|
|
67
63
|
*/
|
|
68
64
|
|
|
69
|
-
/**
|
|
70
|
-
* @typedef {IssuerKit<'set'>} QuoteKit
|
|
71
|
-
*/
|
|
65
|
+
/** @typedef {IssuerKit<'set', PriceDescription>} QuoteKit */
|
|
72
66
|
|
|
73
67
|
/**
|
|
74
|
-
* @typedef {Readonly<
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
68
|
+
* @typedef {Readonly<
|
|
69
|
+
* import('./fluxAggregatorKit.js').ChainlinkConfig & {
|
|
70
|
+
* quoteKit: QuoteKit;
|
|
71
|
+
* answerPublisher: Publisher<void>;
|
|
72
|
+
* brandIn: Brand<'nat'>;
|
|
73
|
+
* brandOut: Brand<'nat'>;
|
|
74
|
+
* latestRoundPublisher: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<LatestRound>;
|
|
75
|
+
* timerPresence: TimerService;
|
|
76
|
+
* }
|
|
77
|
+
* >} HeldParams
|
|
78
|
+
*
|
|
79
|
+
*
|
|
80
|
+
* @typedef {Readonly<
|
|
81
|
+
* HeldParams & {
|
|
82
|
+
* details: MapStore<bigint, RoundDetails>;
|
|
83
|
+
* rounds: MapStore<bigint, Round>;
|
|
84
|
+
* unitIn: bigint;
|
|
85
|
+
* }
|
|
86
|
+
* >} ImmutableState
|
|
82
87
|
*
|
|
83
|
-
* @typedef {Readonly<HeldParams & {
|
|
84
|
-
* details: MapStore<bigint, RoundDetails>,
|
|
85
|
-
* rounds: MapStore<bigint, Round>,
|
|
86
|
-
* unitIn: bigint,
|
|
87
|
-
* }>} ImmutableState
|
|
88
88
|
*
|
|
89
89
|
* @typedef {{
|
|
90
|
-
*
|
|
91
|
-
*
|
|
90
|
+
* lastValueOutForUnitIn: bigint?;
|
|
91
|
+
* reportingRoundId: bigint;
|
|
92
92
|
* }} MutableState
|
|
93
93
|
*/
|
|
94
94
|
/** @typedef {ImmutableState & MutableState} State */
|
|
@@ -99,24 +99,34 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
99
99
|
'RoundsManager',
|
|
100
100
|
{
|
|
101
101
|
helper: UnguardedHelperI,
|
|
102
|
-
contract: M.interface(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
102
|
+
contract: M.interface('contract', {
|
|
103
|
+
authenticateQuote: M.call([M.record()]).returns(M.any()),
|
|
104
|
+
makeCreateQuote: M.call()
|
|
105
|
+
.optional({
|
|
106
|
+
overrideValueOut: M.number(),
|
|
107
|
+
timestamp: TimestampShape,
|
|
108
|
+
})
|
|
109
|
+
.returns(M.any()),
|
|
110
|
+
eligibleForSpecificRound: M.call(
|
|
111
|
+
M.any(),
|
|
112
|
+
M.bigint(),
|
|
113
|
+
TimestampShape,
|
|
114
|
+
).returns(M.boolean()),
|
|
115
|
+
getRoundData: M.call(M.any()).returns(M.promise()),
|
|
116
|
+
getRoundStatus: M.call(M.bigint()).returns(M.record()),
|
|
117
|
+
oracleRoundStateSuggestRound: M.call(M.any(), TimestampShape).returns(
|
|
118
|
+
M.record(),
|
|
119
|
+
),
|
|
120
|
+
}),
|
|
115
121
|
oracle: M.interface('oracle', {
|
|
116
122
|
handlePush: M.call(M.record(), M.record()).returns(M.promise()),
|
|
117
123
|
}),
|
|
118
124
|
},
|
|
119
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* @type {(
|
|
127
|
+
* opts: HeldParams & { unitAmountIn: Amount<'nat'> },
|
|
128
|
+
* ) => State}
|
|
129
|
+
*/
|
|
120
130
|
({
|
|
121
131
|
// ChainlinkConfig
|
|
122
132
|
maxSubmissionCount,
|
|
@@ -162,17 +172,18 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
162
172
|
rounds,
|
|
163
173
|
unitIn,
|
|
164
174
|
};
|
|
175
|
+
|
|
176
|
+
const roundId = 0n;
|
|
177
|
+
|
|
165
178
|
return {
|
|
166
179
|
...immutable,
|
|
167
180
|
lastValueOutForUnitIn: null,
|
|
168
|
-
reportingRoundId:
|
|
181
|
+
reportingRoundId: roundId,
|
|
169
182
|
};
|
|
170
183
|
},
|
|
171
184
|
{
|
|
172
185
|
helper: {
|
|
173
|
-
/**
|
|
174
|
-
* @param {bigint} roundId
|
|
175
|
-
*/
|
|
186
|
+
/** @param {bigint} roundId */
|
|
176
187
|
acceptingSubmissions(roundId) {
|
|
177
188
|
const { details } = this.state;
|
|
178
189
|
return (
|
|
@@ -190,9 +201,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
190
201
|
return roundId > add(lastStarted, restartDelay) || lastStarted === 0n;
|
|
191
202
|
},
|
|
192
203
|
|
|
193
|
-
/**
|
|
194
|
-
* @param {bigint} roundId
|
|
195
|
-
*/
|
|
204
|
+
/** @param {bigint} roundId */
|
|
196
205
|
deleteRoundDetails(roundId) {
|
|
197
206
|
const { details } = this.state;
|
|
198
207
|
const roundDetails = details.get(roundId);
|
|
@@ -201,9 +210,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
201
210
|
details.delete(roundId);
|
|
202
211
|
},
|
|
203
212
|
|
|
204
|
-
/**
|
|
205
|
-
* @param {bigint} roundId
|
|
206
|
-
*/
|
|
213
|
+
/** @param {bigint} roundId */
|
|
207
214
|
isNextRound(roundId) {
|
|
208
215
|
const { reportingRoundId } = this.state;
|
|
209
216
|
return roundId === add(reportingRoundId, 1);
|
|
@@ -421,7 +428,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
421
428
|
* @param {OracleStatus} status
|
|
422
429
|
* @param {bigint} roundId
|
|
423
430
|
* @param {Timestamp} blockTimestamp
|
|
424
|
-
* @returns {string
|
|
431
|
+
* @returns {string | null} error message, if there is one
|
|
425
432
|
*/
|
|
426
433
|
validateOracleRound(status, roundId, blockTimestamp) {
|
|
427
434
|
const { reportingRoundId } = this.state;
|
|
@@ -435,8 +442,10 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
435
442
|
);
|
|
436
443
|
}
|
|
437
444
|
|
|
438
|
-
if (status.lastReportedRound >= roundId)
|
|
445
|
+
if (status.lastReportedRound >= roundId) {
|
|
439
446
|
return 'cannot report on previous rounds';
|
|
447
|
+
}
|
|
448
|
+
|
|
440
449
|
if (
|
|
441
450
|
roundId !== reportingRoundId &&
|
|
442
451
|
roundId !== add(reportingRoundId, 1) &&
|
|
@@ -449,10 +458,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
449
458
|
},
|
|
450
459
|
},
|
|
451
460
|
contract: {
|
|
452
|
-
/**
|
|
453
|
-
*
|
|
454
|
-
* @param {PriceQuoteValue} quote
|
|
455
|
-
*/
|
|
461
|
+
/** @param {PriceQuoteValue} quote */
|
|
456
462
|
async authenticateQuote(quote) {
|
|
457
463
|
const { quoteKit } = this.state;
|
|
458
464
|
const quoteAmount = AmountMath.make(quoteKit.brand, harden(quote));
|
|
@@ -470,9 +476,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
470
476
|
const { brandIn, brandOut, timerPresence } = state;
|
|
471
477
|
const { contract } = this.facets;
|
|
472
478
|
|
|
473
|
-
/**
|
|
474
|
-
* @param {PriceQuery} priceQuery
|
|
475
|
-
*/
|
|
479
|
+
/** @param {PriceQuery} priceQuery */
|
|
476
480
|
return Far('createQuote', priceQuery => {
|
|
477
481
|
const { lastValueOutForUnitIn, unitIn } = state;
|
|
478
482
|
|
|
@@ -486,9 +490,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
486
490
|
return undefined;
|
|
487
491
|
}
|
|
488
492
|
|
|
489
|
-
/**
|
|
490
|
-
* @param {Amount<'nat'>} amountIn the given amountIn
|
|
491
|
-
*/
|
|
493
|
+
/** @param {Amount<'nat'>} amountIn the given amountIn */
|
|
492
494
|
const calcAmountOut = amountIn => {
|
|
493
495
|
const valueIn = AmountMath.getValue(brandIn, amountIn);
|
|
494
496
|
return AmountMath.make(
|
|
@@ -497,9 +499,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
497
499
|
);
|
|
498
500
|
};
|
|
499
501
|
|
|
500
|
-
/**
|
|
501
|
-
* @param {Amount<'nat'>} amountOut the wanted amountOut
|
|
502
|
-
*/
|
|
502
|
+
/** @param {Amount<'nat'>} amountOut the wanted amountOut */
|
|
503
503
|
const calcAmountIn = amountOut => {
|
|
504
504
|
const valueOut = AmountMath.getValue(brandOut, amountOut);
|
|
505
505
|
return AmountMath.make(
|
|
@@ -564,9 +564,8 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
564
564
|
},
|
|
565
565
|
|
|
566
566
|
/**
|
|
567
|
-
* consumers are encouraged to check
|
|
568
|
-
*
|
|
569
|
-
* answeredInRound return values.
|
|
567
|
+
* consumers are encouraged to check that they're receiving fresh data
|
|
568
|
+
* by inspecting the updatedAt and answeredInRound return values.
|
|
570
569
|
*
|
|
571
570
|
* @param {bigint | number} roundIdRaw
|
|
572
571
|
* @returns {Promise<RoundData>}
|
|
@@ -603,8 +602,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
603
602
|
},
|
|
604
603
|
|
|
605
604
|
/**
|
|
606
|
-
* a method to provide all current info oracleStatuses need. Intended
|
|
607
|
-
* only to be callable by oracleStatuses. Not for use by contracts to
|
|
605
|
+
* a method to provide all current info oracleStatuses need. Intended
|
|
606
|
+
* only to be callable by oracleStatuses. Not for use by contracts to
|
|
607
|
+
* read state.
|
|
608
608
|
*
|
|
609
609
|
* @param {OracleStatus} status
|
|
610
610
|
* @param {Timestamp} blockTimestamp
|
|
@@ -731,4 +731,50 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
731
731
|
},
|
|
732
732
|
},
|
|
733
733
|
},
|
|
734
|
+
{
|
|
735
|
+
finish: ({ state }) => {
|
|
736
|
+
const { details, rounds, timerPresence } = state;
|
|
737
|
+
// Zero is treated as special as roundId and in times. It's hard to
|
|
738
|
+
// avoid on restart and in tests, so make 1 the minimum
|
|
739
|
+
|
|
740
|
+
const firstRound = 1n;
|
|
741
|
+
state.reportingRoundId = firstRound;
|
|
742
|
+
details.init(
|
|
743
|
+
firstRound,
|
|
744
|
+
harden({
|
|
745
|
+
submissions: [],
|
|
746
|
+
maxSubmissions: state.maxSubmissionCount,
|
|
747
|
+
minSubmissions: state.minSubmissionCount,
|
|
748
|
+
roundTimeout: state.timeout,
|
|
749
|
+
}),
|
|
750
|
+
);
|
|
751
|
+
|
|
752
|
+
// Cannot await in first crank. Fail if no timestamp available
|
|
753
|
+
void E.when(
|
|
754
|
+
E(timerPresence).getCurrentTimestamp(),
|
|
755
|
+
nowMaybe => {
|
|
756
|
+
const now =
|
|
757
|
+
TimeMath.compareAbs(nowMaybe, 1n) < 0
|
|
758
|
+
? TimeMath.coerceTimestampRecord(1n, nowMaybe.timerBrand)
|
|
759
|
+
: nowMaybe;
|
|
760
|
+
|
|
761
|
+
const round = harden({
|
|
762
|
+
answer: 0n,
|
|
763
|
+
startedAt: now,
|
|
764
|
+
updatedAt: 0n,
|
|
765
|
+
answeredInRound: 0n,
|
|
766
|
+
});
|
|
767
|
+
rounds.init(firstRound, round);
|
|
768
|
+
|
|
769
|
+
// In case this is a replacement priceFeed, set roundId in vstorage.
|
|
770
|
+
void state.latestRoundPublisher.write({
|
|
771
|
+
roundId: firstRound,
|
|
772
|
+
startedAt: round.startedAt,
|
|
773
|
+
startedBy: 'uninitialized',
|
|
774
|
+
});
|
|
775
|
+
},
|
|
776
|
+
reason => Fail`need a timestamp to start roundsManager ${reason}`,
|
|
777
|
+
);
|
|
778
|
+
},
|
|
779
|
+
},
|
|
734
780
|
);
|
package/src/proposals/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Proposals
|
|
2
2
|
|
|
3
|
-
These are
|
|
3
|
+
These scripts are referenced by proposals to the BLDer DAO to run on the chain.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
See the documentation in .../deploy-script-support/README.md
|
|
6
6
|
|
|
7
|
-
[syntax of the manifests](../../packages/vats/src/core/manifest.js)
|