@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-fbe72e7.0.fbe72e7
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 +46 -39
- 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 +182 -151
- 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 +70 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +72 -59
- package/src/auction/offerBook.d.ts +46 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +17 -12
- package/src/auction/params.d.ts +145 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +11 -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 +31 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +12 -6
- package/src/clientSupport.d.ts +168 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +161 -98
- 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 +43 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +25 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +41 -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 +4 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest-math.js +5 -1
- package/src/interest.d.ts +30 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +25 -23
- package/src/price/README.md +14 -1
- 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 +104 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +55 -42
- package/src/price/priceOracleKit.d.ts +39 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +17 -15
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +132 -85
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.js +285 -0
- package/src/proposals/addAssetToVault.js +192 -40
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/deploy-price-feeds.js +341 -0
- package/src/proposals/econ-behaviors.js +84 -49
- package/src/proposals/price-feed-proposal.js +109 -51
- package/src/proposals/replace-fee-distributor.js +198 -0
- package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
- package/src/proposals/replaceElectorate.js +610 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.js +44 -29
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.js +207 -0
- package/src/proposals/utils.d.ts +21 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +66 -9
- package/src/proposals/withdraw-reserve-proposal.js +63 -0
- package/src/provisionPool.d.ts +69 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +138 -0
- package/src/provisionPoolKit.d.ts +129 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +608 -0
- package/src/psm/psm.d.ts +133 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +85 -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 +58 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +42 -34
- package/src/reserve/assetReserveKit.d.ts +103 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +134 -32
- package/src/reserve/params.d.ts +16 -0
- package/src/reserve/params.d.ts.map +1 -0
- package/src/reserve/params.js +8 -2
- 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 +25 -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 +11 -10
- package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +9 -10
- package/src/vaultFactory/params.d.ts +143 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +56 -25
- package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +7 -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} +47 -44
- package/src/vaultFactory/vault.d.ts +344 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +107 -100
- package/src/vaultFactory/vaultDirector.d.ts +347 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +94 -64
- package/src/vaultFactory/vaultFactory.d.ts +250 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +56 -33
- package/src/vaultFactory/vaultHolder.d.ts +170 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +14 -15
- package/src/vaultFactory/vaultKit.d.ts +33 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +9 -4
- package/src/vaultFactory/vaultManager.d.ts +676 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +286 -167
- 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
|
@@ -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,15 @@ 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 {MapStore, SetStore} from '@agoric/store';
|
|
21
|
+
* @import {OracleStatus} from './priceOracleKit.js'
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
24
|
/** @type {string} */
|
|
@@ -26,36 +27,32 @@ const V3_NO_DATA_ERROR = 'No data present';
|
|
|
26
27
|
/** @type {bigint} */
|
|
27
28
|
export const ROUND_MAX = BigInt(2 ** 32 - 1);
|
|
28
29
|
|
|
29
|
-
const trace = makeTracer('RoundsM',
|
|
30
|
+
const trace = makeTracer('RoundsM', true);
|
|
30
31
|
|
|
31
|
-
/**
|
|
32
|
-
* @param {bigint} roundId
|
|
33
|
-
*/
|
|
32
|
+
/** @param {bigint} roundId */
|
|
34
33
|
const validRoundId = roundId => {
|
|
35
34
|
return roundId <= ROUND_MAX;
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
* @typedef {{ roundId: number | undefined
|
|
38
|
+
* @typedef {{ roundId: number | undefined; unitPrice: NatValue }} PriceRound
|
|
40
39
|
*
|
|
41
|
-
* @typedef {Pick<RoundData, 'roundId' | 'startedAt'> &
|
|
40
|
+
* @typedef {Pick<RoundData, 'roundId' | 'startedAt'> & { startedBy: string }} LatestRound
|
|
42
41
|
*/
|
|
43
42
|
|
|
44
|
-
/**
|
|
45
|
-
* @typedef {Round & {roundId: bigint}} RoundData
|
|
46
|
-
*/
|
|
43
|
+
/** @typedef {Round & { roundId: bigint }} RoundData */
|
|
47
44
|
|
|
48
45
|
/**
|
|
49
46
|
* @typedef {object} Round
|
|
50
47
|
* @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.
|
|
48
|
+
* @property {Timestamp} startedAt the timestamp when the round was started.
|
|
49
|
+
* This is 0 if the round hasn't been started yet.
|
|
50
|
+
* @property {Timestamp} updatedAt the timestamp when the round last was updated
|
|
51
|
+
* (i.e. answer was last computed)
|
|
52
|
+
* @property {bigint} answeredInRound the round ID of the round in which the
|
|
53
|
+
* answer was computed. answeredInRound may be smaller than roundId when the
|
|
54
|
+
* round timed out. answeredInRound is equal to roundId when the round didn't
|
|
55
|
+
* time out and was completed regularly.
|
|
59
56
|
*/
|
|
60
57
|
|
|
61
58
|
/**
|
|
@@ -66,29 +63,33 @@ const validRoundId = roundId => {
|
|
|
66
63
|
* @property {number} roundTimeout
|
|
67
64
|
*/
|
|
68
65
|
|
|
69
|
-
/**
|
|
70
|
-
* @typedef {IssuerKit<'set'>} QuoteKit
|
|
71
|
-
*/
|
|
66
|
+
/** @typedef {IssuerKit<'set', PriceDescription>} QuoteKit */
|
|
72
67
|
|
|
73
68
|
/**
|
|
74
|
-
* @typedef {Readonly<
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
69
|
+
* @typedef {Readonly<
|
|
70
|
+
* import('./fluxAggregatorKit.js').ChainlinkConfig & {
|
|
71
|
+
* quoteKit: QuoteKit;
|
|
72
|
+
* answerPublisher: Publisher<void>;
|
|
73
|
+
* brandIn: Brand<'nat'>;
|
|
74
|
+
* brandOut: Brand<'nat'>;
|
|
75
|
+
* latestRoundPublisher: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<LatestRound>;
|
|
76
|
+
* timerPresence: TimerService;
|
|
77
|
+
* }
|
|
78
|
+
* >} HeldParams
|
|
79
|
+
*
|
|
80
|
+
*
|
|
81
|
+
* @typedef {Readonly<
|
|
82
|
+
* HeldParams & {
|
|
83
|
+
* details: MapStore<bigint, RoundDetails>;
|
|
84
|
+
* rounds: MapStore<bigint, Round>;
|
|
85
|
+
* unitIn: bigint;
|
|
86
|
+
* }
|
|
87
|
+
* >} ImmutableState
|
|
82
88
|
*
|
|
83
|
-
* @typedef {Readonly<HeldParams & {
|
|
84
|
-
* details: MapStore<bigint, RoundDetails>,
|
|
85
|
-
* rounds: MapStore<bigint, Round>,
|
|
86
|
-
* unitIn: bigint,
|
|
87
|
-
* }>} ImmutableState
|
|
88
89
|
*
|
|
89
90
|
* @typedef {{
|
|
90
|
-
*
|
|
91
|
-
*
|
|
91
|
+
* lastValueOutForUnitIn: bigint?;
|
|
92
|
+
* reportingRoundId: bigint;
|
|
92
93
|
* }} MutableState
|
|
93
94
|
*/
|
|
94
95
|
/** @typedef {ImmutableState & MutableState} State */
|
|
@@ -99,24 +100,34 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
99
100
|
'RoundsManager',
|
|
100
101
|
{
|
|
101
102
|
helper: UnguardedHelperI,
|
|
102
|
-
contract: M.interface(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
contract: M.interface('contract', {
|
|
104
|
+
authenticateQuote: M.call([M.record()]).returns(M.any()),
|
|
105
|
+
makeCreateQuote: M.call()
|
|
106
|
+
.optional({
|
|
107
|
+
overrideValueOut: M.number(),
|
|
108
|
+
timestamp: TimestampShape,
|
|
109
|
+
})
|
|
110
|
+
.returns(M.any()),
|
|
111
|
+
eligibleForSpecificRound: M.call(
|
|
112
|
+
M.any(),
|
|
113
|
+
M.bigint(),
|
|
114
|
+
TimestampShape,
|
|
115
|
+
).returns(M.boolean()),
|
|
116
|
+
getRoundData: M.call(M.any()).returns(M.promise()),
|
|
117
|
+
getRoundStatus: M.call(M.bigint()).returns(M.record()),
|
|
118
|
+
oracleRoundStateSuggestRound: M.call(M.any(), TimestampShape).returns(
|
|
119
|
+
M.record(),
|
|
120
|
+
),
|
|
121
|
+
}),
|
|
115
122
|
oracle: M.interface('oracle', {
|
|
116
123
|
handlePush: M.call(M.record(), M.record()).returns(M.promise()),
|
|
117
124
|
}),
|
|
118
125
|
},
|
|
119
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* @type {(
|
|
128
|
+
* opts: HeldParams & { unitAmountIn: Amount<'nat'> },
|
|
129
|
+
* ) => State}
|
|
130
|
+
*/
|
|
120
131
|
({
|
|
121
132
|
// ChainlinkConfig
|
|
122
133
|
maxSubmissionCount,
|
|
@@ -162,17 +173,18 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
162
173
|
rounds,
|
|
163
174
|
unitIn,
|
|
164
175
|
};
|
|
176
|
+
|
|
177
|
+
const roundId = 0n;
|
|
178
|
+
|
|
165
179
|
return {
|
|
166
180
|
...immutable,
|
|
167
181
|
lastValueOutForUnitIn: null,
|
|
168
|
-
reportingRoundId:
|
|
182
|
+
reportingRoundId: roundId,
|
|
169
183
|
};
|
|
170
184
|
},
|
|
171
185
|
{
|
|
172
186
|
helper: {
|
|
173
|
-
/**
|
|
174
|
-
* @param {bigint} roundId
|
|
175
|
-
*/
|
|
187
|
+
/** @param {bigint} roundId */
|
|
176
188
|
acceptingSubmissions(roundId) {
|
|
177
189
|
const { details } = this.state;
|
|
178
190
|
return (
|
|
@@ -190,9 +202,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
190
202
|
return roundId > add(lastStarted, restartDelay) || lastStarted === 0n;
|
|
191
203
|
},
|
|
192
204
|
|
|
193
|
-
/**
|
|
194
|
-
* @param {bigint} roundId
|
|
195
|
-
*/
|
|
205
|
+
/** @param {bigint} roundId */
|
|
196
206
|
deleteRoundDetails(roundId) {
|
|
197
207
|
const { details } = this.state;
|
|
198
208
|
const roundDetails = details.get(roundId);
|
|
@@ -201,9 +211,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
201
211
|
details.delete(roundId);
|
|
202
212
|
},
|
|
203
213
|
|
|
204
|
-
/**
|
|
205
|
-
* @param {bigint} roundId
|
|
206
|
-
*/
|
|
214
|
+
/** @param {bigint} roundId */
|
|
207
215
|
isNextRound(roundId) {
|
|
208
216
|
const { reportingRoundId } = this.state;
|
|
209
217
|
return roundId === add(reportingRoundId, 1);
|
|
@@ -421,7 +429,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
421
429
|
* @param {OracleStatus} status
|
|
422
430
|
* @param {bigint} roundId
|
|
423
431
|
* @param {Timestamp} blockTimestamp
|
|
424
|
-
* @returns {string
|
|
432
|
+
* @returns {string | null} error message, if there is one
|
|
425
433
|
*/
|
|
426
434
|
validateOracleRound(status, roundId, blockTimestamp) {
|
|
427
435
|
const { reportingRoundId } = this.state;
|
|
@@ -435,8 +443,10 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
435
443
|
);
|
|
436
444
|
}
|
|
437
445
|
|
|
438
|
-
if (status.lastReportedRound >= roundId)
|
|
446
|
+
if (status.lastReportedRound >= roundId) {
|
|
439
447
|
return 'cannot report on previous rounds';
|
|
448
|
+
}
|
|
449
|
+
|
|
440
450
|
if (
|
|
441
451
|
roundId !== reportingRoundId &&
|
|
442
452
|
roundId !== add(reportingRoundId, 1) &&
|
|
@@ -449,10 +459,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
449
459
|
},
|
|
450
460
|
},
|
|
451
461
|
contract: {
|
|
452
|
-
/**
|
|
453
|
-
*
|
|
454
|
-
* @param {PriceQuoteValue} quote
|
|
455
|
-
*/
|
|
462
|
+
/** @param {PriceQuoteValue} quote */
|
|
456
463
|
async authenticateQuote(quote) {
|
|
457
464
|
const { quoteKit } = this.state;
|
|
458
465
|
const quoteAmount = AmountMath.make(quoteKit.brand, harden(quote));
|
|
@@ -470,9 +477,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
470
477
|
const { brandIn, brandOut, timerPresence } = state;
|
|
471
478
|
const { contract } = this.facets;
|
|
472
479
|
|
|
473
|
-
/**
|
|
474
|
-
* @param {PriceQuery} priceQuery
|
|
475
|
-
*/
|
|
480
|
+
/** @param {PriceQuery} priceQuery */
|
|
476
481
|
return Far('createQuote', priceQuery => {
|
|
477
482
|
const { lastValueOutForUnitIn, unitIn } = state;
|
|
478
483
|
|
|
@@ -486,9 +491,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
486
491
|
return undefined;
|
|
487
492
|
}
|
|
488
493
|
|
|
489
|
-
/**
|
|
490
|
-
* @param {Amount<'nat'>} amountIn the given amountIn
|
|
491
|
-
*/
|
|
494
|
+
/** @param {Amount<'nat'>} amountIn the given amountIn */
|
|
492
495
|
const calcAmountOut = amountIn => {
|
|
493
496
|
const valueIn = AmountMath.getValue(brandIn, amountIn);
|
|
494
497
|
return AmountMath.make(
|
|
@@ -497,9 +500,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
497
500
|
);
|
|
498
501
|
};
|
|
499
502
|
|
|
500
|
-
/**
|
|
501
|
-
* @param {Amount<'nat'>} amountOut the wanted amountOut
|
|
502
|
-
*/
|
|
503
|
+
/** @param {Amount<'nat'>} amountOut the wanted amountOut */
|
|
503
504
|
const calcAmountIn = amountOut => {
|
|
504
505
|
const valueOut = AmountMath.getValue(brandOut, amountOut);
|
|
505
506
|
return AmountMath.make(
|
|
@@ -564,9 +565,8 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
564
565
|
},
|
|
565
566
|
|
|
566
567
|
/**
|
|
567
|
-
* consumers are encouraged to check
|
|
568
|
-
*
|
|
569
|
-
* answeredInRound return values.
|
|
568
|
+
* consumers are encouraged to check that they're receiving fresh data
|
|
569
|
+
* by inspecting the updatedAt and answeredInRound return values.
|
|
570
570
|
*
|
|
571
571
|
* @param {bigint | number} roundIdRaw
|
|
572
572
|
* @returns {Promise<RoundData>}
|
|
@@ -603,8 +603,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
603
603
|
},
|
|
604
604
|
|
|
605
605
|
/**
|
|
606
|
-
* a method to provide all current info oracleStatuses need. Intended
|
|
607
|
-
* only to be callable by oracleStatuses. Not for use by contracts to
|
|
606
|
+
* a method to provide all current info oracleStatuses need. Intended
|
|
607
|
+
* only to be callable by oracleStatuses. Not for use by contracts to
|
|
608
|
+
* read state.
|
|
608
609
|
*
|
|
609
610
|
* @param {OracleStatus} status
|
|
610
611
|
* @param {Timestamp} blockTimestamp
|
|
@@ -731,4 +732,50 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
731
732
|
},
|
|
732
733
|
},
|
|
733
734
|
},
|
|
735
|
+
{
|
|
736
|
+
finish: ({ state }) => {
|
|
737
|
+
const { details, rounds, timerPresence } = state;
|
|
738
|
+
// Zero is treated as special as roundId and in times. It's hard to
|
|
739
|
+
// avoid on restart and in tests, so make 1 the minimum
|
|
740
|
+
|
|
741
|
+
const firstRound = 1n;
|
|
742
|
+
state.reportingRoundId = firstRound;
|
|
743
|
+
details.init(
|
|
744
|
+
firstRound,
|
|
745
|
+
harden({
|
|
746
|
+
submissions: [],
|
|
747
|
+
maxSubmissions: state.maxSubmissionCount,
|
|
748
|
+
minSubmissions: state.minSubmissionCount,
|
|
749
|
+
roundTimeout: state.timeout,
|
|
750
|
+
}),
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
// Cannot await in first crank. Fail if no timestamp available
|
|
754
|
+
void E.when(
|
|
755
|
+
E(timerPresence).getCurrentTimestamp(),
|
|
756
|
+
nowMaybe => {
|
|
757
|
+
const now =
|
|
758
|
+
TimeMath.compareAbs(nowMaybe, 1n) < 0
|
|
759
|
+
? TimeMath.coerceTimestampRecord(1n, nowMaybe.timerBrand)
|
|
760
|
+
: nowMaybe;
|
|
761
|
+
|
|
762
|
+
const round = harden({
|
|
763
|
+
answer: 0n,
|
|
764
|
+
startedAt: now,
|
|
765
|
+
updatedAt: 0n,
|
|
766
|
+
answeredInRound: 0n,
|
|
767
|
+
});
|
|
768
|
+
rounds.init(firstRound, round);
|
|
769
|
+
|
|
770
|
+
// In case this is a replacement priceFeed, set roundId in vstorage.
|
|
771
|
+
void state.latestRoundPublisher.write({
|
|
772
|
+
roundId: firstRound,
|
|
773
|
+
startedAt: round.startedAt,
|
|
774
|
+
startedBy: 'uninitialized',
|
|
775
|
+
});
|
|
776
|
+
},
|
|
777
|
+
reason => Fail`need a timestamp to start roundsManager ${reason}`,
|
|
778
|
+
);
|
|
779
|
+
},
|
|
780
|
+
},
|
|
734
781
|
);
|
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)
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
|
|
2
|
+
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
3
|
+
import { Stable } from '@agoric/internal/src/tokens.js';
|
|
4
|
+
import { E } from '@endo/far';
|
|
5
|
+
import { makeGovernedTerms as makeGovernedATerms } from '../auction/params.js';
|
|
6
|
+
import { provideRetiredInstances } from './utils.js';
|
|
7
|
+
|
|
8
|
+
const trace = makeTracer('NewAuction', true);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {PromiseSpaceOf<{
|
|
12
|
+
* auctionUpgradeNewInstance: Instance;
|
|
13
|
+
* auctionUpgradeNewGovCreator: any;
|
|
14
|
+
* newContractGovBundleId: string;
|
|
15
|
+
* retiredContractInstances: MapStore<string, Instance>;
|
|
16
|
+
* }>} interlockPowers
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {import('./econ-behaviors.js').EconomyBootstrapPowers &
|
|
21
|
+
* interlockPowers} powers
|
|
22
|
+
* @param {{
|
|
23
|
+
* options: {
|
|
24
|
+
* contractGovernorRef: { bundleID: string };
|
|
25
|
+
* contractGovernorInstallation: Installation;
|
|
26
|
+
* };
|
|
27
|
+
* }} options
|
|
28
|
+
*/
|
|
29
|
+
export const addAuction = async (
|
|
30
|
+
{
|
|
31
|
+
consume: {
|
|
32
|
+
agoricNamesAdmin,
|
|
33
|
+
auctioneerKit: legacyKitP,
|
|
34
|
+
board,
|
|
35
|
+
chainStorage,
|
|
36
|
+
chainTimerService,
|
|
37
|
+
economicCommitteeCreatorFacet: electorateCreatorFacet,
|
|
38
|
+
governedContractKits: governedContractKitsP,
|
|
39
|
+
priceAuthority8400,
|
|
40
|
+
retiredContractInstances: retiredContractInstancesP,
|
|
41
|
+
zoe,
|
|
42
|
+
},
|
|
43
|
+
produce: {
|
|
44
|
+
auctioneerKit: produceAuctioneerKit,
|
|
45
|
+
auctionUpgradeNewInstance,
|
|
46
|
+
auctionUpgradeNewGovCreator,
|
|
47
|
+
newContractGovBundleId,
|
|
48
|
+
retiredContractInstances: produceRetiredInstances,
|
|
49
|
+
},
|
|
50
|
+
instance: {
|
|
51
|
+
consume: { reserve: reserveInstance },
|
|
52
|
+
produce: { auctioneer: auctionInstance },
|
|
53
|
+
},
|
|
54
|
+
installation: {
|
|
55
|
+
consume: { auctioneer: auctioneerInstallationP },
|
|
56
|
+
},
|
|
57
|
+
issuer: {
|
|
58
|
+
consume: { [Stable.symbol]: stableIssuerP },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
options: {
|
|
63
|
+
contractGovernorRef: contractGovernorBundle,
|
|
64
|
+
contractGovernorInstallation,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
) => {
|
|
68
|
+
trace('addAuction start');
|
|
69
|
+
const STORAGE_PATH = 'auction';
|
|
70
|
+
|
|
71
|
+
const poserInvitationP = E(electorateCreatorFacet).getPoserInvitation();
|
|
72
|
+
const [
|
|
73
|
+
initialPoserInvitation,
|
|
74
|
+
electorateInvitationAmount,
|
|
75
|
+
stableIssuer,
|
|
76
|
+
legacyKit,
|
|
77
|
+
auctioneerInstallation,
|
|
78
|
+
] = await Promise.all([
|
|
79
|
+
poserInvitationP,
|
|
80
|
+
E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
|
|
81
|
+
stableIssuerP,
|
|
82
|
+
legacyKitP,
|
|
83
|
+
auctioneerInstallationP,
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
const retiredInstances = await provideRetiredInstances(
|
|
87
|
+
retiredContractInstancesP,
|
|
88
|
+
produceRetiredInstances,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const governedContractKits = await governedContractKitsP;
|
|
92
|
+
trace('has', governedContractKits.has(legacyKit.instance));
|
|
93
|
+
if (governedContractKits.has(legacyKit.instance)) {
|
|
94
|
+
// bootstrap tests start having already run this upgrade. Actual upgrades on
|
|
95
|
+
// mainNet or testnets should start with the promiseSpace post upgrade-17,
|
|
96
|
+
// which doesn't have this entry in the map.
|
|
97
|
+
trace(
|
|
98
|
+
'⚠️ WARNING: not expected during chain upgrade. It IS normal during bootstrap tests',
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
// @ts-expect-error The original auctioneerKit had everything it needs
|
|
102
|
+
governedContractKits.init(legacyKit.instance, legacyKit);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// save the auctioneer instance so we can manage it later
|
|
106
|
+
const boardID = await E(board).getId(legacyKit.instance);
|
|
107
|
+
const identifier = `auctioneer-${boardID}`;
|
|
108
|
+
retiredInstances.init(identifier, legacyKit.instance);
|
|
109
|
+
|
|
110
|
+
// Each field has an extra layer of type + value:
|
|
111
|
+
// AuctionStartDelay: { type: 'relativeTime', value: { relValue: 2n, timerBrand: Object [Alleged: timerBrand] {} } }
|
|
112
|
+
/** @type {any} */
|
|
113
|
+
const paramValues = await E(legacyKit.publicFacet).getGovernedParams();
|
|
114
|
+
const params = harden({
|
|
115
|
+
StartFrequency: paramValues.StartFrequency.value,
|
|
116
|
+
ClockStep: paramValues.ClockStep.value,
|
|
117
|
+
StartingRate: paramValues.StartingRate.value,
|
|
118
|
+
LowestRate: paramValues.LowestRate.value,
|
|
119
|
+
DiscountStep: paramValues.DiscountStep.value,
|
|
120
|
+
AuctionStartDelay: paramValues.AuctionStartDelay.value,
|
|
121
|
+
PriceLockPeriod: paramValues.PriceLockPeriod.value,
|
|
122
|
+
});
|
|
123
|
+
const timerBrand = await E(chainTimerService).getTimerBrand();
|
|
124
|
+
|
|
125
|
+
const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
126
|
+
const marshaller = await E(board).getReadonlyMarshaller();
|
|
127
|
+
|
|
128
|
+
const reservePublicFacet = await E(zoe).getPublicFacet(reserveInstance);
|
|
129
|
+
|
|
130
|
+
const auctionTerms = makeGovernedATerms(
|
|
131
|
+
{ storageNode, marshaller },
|
|
132
|
+
chainTimerService,
|
|
133
|
+
priceAuthority8400,
|
|
134
|
+
reservePublicFacet,
|
|
135
|
+
{
|
|
136
|
+
...params,
|
|
137
|
+
ElectorateInvitationAmount: electorateInvitationAmount,
|
|
138
|
+
TimerBrand: timerBrand,
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const governorTerms = await deeplyFulfilledObject(
|
|
143
|
+
harden({
|
|
144
|
+
timer: chainTimerService,
|
|
145
|
+
governedContractInstallation: auctioneerInstallation,
|
|
146
|
+
governed: {
|
|
147
|
+
terms: auctionTerms,
|
|
148
|
+
issuerKeywordRecord: { Bid: stableIssuer },
|
|
149
|
+
storageNode,
|
|
150
|
+
marshaller,
|
|
151
|
+
label: 'auctioneer',
|
|
152
|
+
},
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const bundleIdFromZoe = await E(zoe).getBundleIDFromInstallation(
|
|
157
|
+
contractGovernorInstallation,
|
|
158
|
+
);
|
|
159
|
+
trace('governor bundle ID', bundleIdFromZoe, contractGovernorBundle.bundleID);
|
|
160
|
+
|
|
161
|
+
/** @type {GovernorStartedInstallationKit<typeof auctioneerInstallationP>} */
|
|
162
|
+
const governorStartResult = await E(zoe).startInstance(
|
|
163
|
+
contractGovernorInstallation,
|
|
164
|
+
undefined,
|
|
165
|
+
governorTerms,
|
|
166
|
+
harden({
|
|
167
|
+
electorateCreatorFacet,
|
|
168
|
+
governed: {
|
|
169
|
+
initialPoserInvitation,
|
|
170
|
+
storageNode,
|
|
171
|
+
marshaller,
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
'auctioneer.governor',
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const [
|
|
178
|
+
governedInstance,
|
|
179
|
+
governedCreatorFacet,
|
|
180
|
+
governedPublicFacet,
|
|
181
|
+
governedAdminFacet,
|
|
182
|
+
] = await Promise.all([
|
|
183
|
+
E(governorStartResult.creatorFacet).getInstance(),
|
|
184
|
+
E(governorStartResult.creatorFacet).getCreatorFacet(),
|
|
185
|
+
E(governorStartResult.creatorFacet).getPublicFacet(),
|
|
186
|
+
E(governorStartResult.creatorFacet).getAdminFacet(),
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
const allIssuers = await E(zoe).getIssuers(legacyKit.instance);
|
|
190
|
+
const { Bid: _istIssuer, ...auctionIssuers } = allIssuers;
|
|
191
|
+
await Promise.all(
|
|
192
|
+
Object.keys(auctionIssuers).map(kwd =>
|
|
193
|
+
E(governedCreatorFacet).addBrand(
|
|
194
|
+
/** @type {Issuer<'nat'>} */ (auctionIssuers[kwd]),
|
|
195
|
+
kwd,
|
|
196
|
+
),
|
|
197
|
+
),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const kit = harden({
|
|
201
|
+
label: 'auctioneer',
|
|
202
|
+
creatorFacet: governedCreatorFacet,
|
|
203
|
+
adminFacet: governedAdminFacet,
|
|
204
|
+
publicFacet: governedPublicFacet,
|
|
205
|
+
instance: governedInstance,
|
|
206
|
+
|
|
207
|
+
governor: governorStartResult.instance,
|
|
208
|
+
governorCreatorFacet: governorStartResult.creatorFacet,
|
|
209
|
+
governorAdminFacet: governorStartResult.adminFacet,
|
|
210
|
+
});
|
|
211
|
+
produceAuctioneerKit.reset();
|
|
212
|
+
produceAuctioneerKit.resolve(kit);
|
|
213
|
+
|
|
214
|
+
auctionInstance.reset();
|
|
215
|
+
await auctionInstance.resolve(governedInstance);
|
|
216
|
+
// belt and suspenders; the above is supposed to also do this
|
|
217
|
+
await E(E(agoricNamesAdmin).lookupAdmin('instance')).update(
|
|
218
|
+
'auctioneer',
|
|
219
|
+
governedInstance,
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
governedContractKits.init(kit.instance, kit);
|
|
223
|
+
auctionUpgradeNewInstance.resolve(governedInstance);
|
|
224
|
+
auctionUpgradeNewGovCreator.resolve(kit.governorCreatorFacet);
|
|
225
|
+
newContractGovBundleId.resolve(contractGovernorBundle.bundleID);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export const ADD_AUCTION_MANIFEST = harden({
|
|
229
|
+
[addAuction.name]: {
|
|
230
|
+
consume: {
|
|
231
|
+
agoricNamesAdmin: true,
|
|
232
|
+
auctioneerKit: true,
|
|
233
|
+
board: true,
|
|
234
|
+
chainStorage: true,
|
|
235
|
+
chainTimerService: true,
|
|
236
|
+
econCharterKit: true,
|
|
237
|
+
economicCommitteeCreatorFacet: true,
|
|
238
|
+
governedContractKits: true,
|
|
239
|
+
priceAuthority8400: true,
|
|
240
|
+
retiredContractInstances: true,
|
|
241
|
+
zoe: true,
|
|
242
|
+
},
|
|
243
|
+
produce: {
|
|
244
|
+
auctioneerKit: true,
|
|
245
|
+
auctionUpgradeNewInstance: true,
|
|
246
|
+
auctionUpgradeNewGovCreator: true,
|
|
247
|
+
newContractGovBundleId: true,
|
|
248
|
+
retiredContractInstances: true,
|
|
249
|
+
},
|
|
250
|
+
instance: {
|
|
251
|
+
consume: { reserve: true },
|
|
252
|
+
produce: { auctioneer: true },
|
|
253
|
+
},
|
|
254
|
+
installation: {
|
|
255
|
+
consume: { contractGovernor: true, auctioneer: true },
|
|
256
|
+
},
|
|
257
|
+
issuer: {
|
|
258
|
+
consume: { [Stable.symbol]: true },
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Add a new auction to a chain that already has one.
|
|
265
|
+
*
|
|
266
|
+
* @param {object} utils
|
|
267
|
+
* @param {any} utils.restoreRef
|
|
268
|
+
* @param {any} addAuctionOptions
|
|
269
|
+
*/
|
|
270
|
+
export const getManifestForAddAuction = async (
|
|
271
|
+
{ restoreRef },
|
|
272
|
+
{ auctioneerRef, contractGovernorRef },
|
|
273
|
+
) => {
|
|
274
|
+
const contractGovernorInstallation = restoreRef(contractGovernorRef);
|
|
275
|
+
return {
|
|
276
|
+
manifest: ADD_AUCTION_MANIFEST,
|
|
277
|
+
// XXX we should be able to receive contractGovernorInstallation via
|
|
278
|
+
// installations.consume, but the received installation isn't right.
|
|
279
|
+
options: { contractGovernorRef, contractGovernorInstallation },
|
|
280
|
+
installations: {
|
|
281
|
+
auctioneer: restoreRef(auctioneerRef),
|
|
282
|
+
contractGovernor: restoreRef(contractGovernorRef),
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
};
|