@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
|
@@ -10,14 +10,13 @@ import {
|
|
|
10
10
|
import { E } from '@endo/eventual-send';
|
|
11
11
|
import { Far } from '@endo/marshal';
|
|
12
12
|
import { isNat, Nat } from '@endo/nat';
|
|
13
|
-
import { UnguardedHelperI } from '
|
|
13
|
+
import { UnguardedHelperI } from '../typeGuards.js';
|
|
14
14
|
|
|
15
15
|
const { add, subtract, multiply, floorDivide, ceilDivide, isGTE } = natSafeMath;
|
|
16
16
|
|
|
17
17
|
/** @typedef {import('./priceOracleKit.js').OracleStatus} OracleStatus */
|
|
18
18
|
/**
|
|
19
19
|
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
|
|
20
|
-
*
|
|
21
20
|
* @typedef {import('@agoric/time/src/types').TimerService} TimerService
|
|
22
21
|
*/
|
|
23
22
|
|
|
@@ -29,30 +28,34 @@ export const ROUND_MAX = BigInt(2 ** 32 - 1);
|
|
|
29
28
|
|
|
30
29
|
const trace = makeTracer('RoundsM', false);
|
|
31
30
|
|
|
32
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* @param {bigint} roundId
|
|
33
|
+
*/
|
|
33
34
|
const validRoundId = roundId => {
|
|
34
35
|
return roundId <= ROUND_MAX;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
|
-
* @typedef {{ roundId: number | undefined
|
|
39
|
+
* @typedef {{ roundId: number | undefined, unitPrice: NatValue }} PriceRound
|
|
39
40
|
*
|
|
40
|
-
* @typedef {Pick<RoundData, 'roundId' | 'startedAt'> &
|
|
41
|
+
* @typedef {Pick<RoundData, 'roundId' | 'startedAt'> & { startedBy: string }} LatestRound
|
|
41
42
|
*/
|
|
42
43
|
|
|
43
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {Round & {roundId: bigint}} RoundData
|
|
46
|
+
*/
|
|
44
47
|
|
|
45
48
|
/**
|
|
46
49
|
* @typedef {object} Round
|
|
47
50
|
* @property {bigint} answer the answer for the given round
|
|
48
|
-
* @property {Timestamp} startedAt the timestamp when the round was started.
|
|
49
|
-
*
|
|
50
|
-
* @property {Timestamp} updatedAt the timestamp when the round last was updated
|
|
51
|
-
*
|
|
52
|
-
* @property {bigint} answeredInRound the round ID of the round in which the
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
51
|
+
* @property {Timestamp} startedAt the timestamp when the round was started. This is 0
|
|
52
|
+
* if the round hasn't been started yet.
|
|
53
|
+
* @property {Timestamp} updatedAt the timestamp when the round last was updated (i.e.
|
|
54
|
+
* answer was last computed)
|
|
55
|
+
* @property {bigint} answeredInRound the round ID of the round in which the answer
|
|
56
|
+
* was computed. answeredInRound may be smaller than roundId when the round
|
|
57
|
+
* timed out. answeredInRound is equal to roundId when the round didn't time out
|
|
58
|
+
* and was completed regularly.
|
|
56
59
|
*/
|
|
57
60
|
|
|
58
61
|
/**
|
|
@@ -63,31 +66,29 @@ const validRoundId = roundId => {
|
|
|
63
66
|
* @property {number} roundTimeout
|
|
64
67
|
*/
|
|
65
68
|
|
|
66
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {IssuerKit<'set'>} QuoteKit
|
|
71
|
+
*/
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
|
-
* @typedef {Readonly<
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* }
|
|
78
|
-
* >} HeldParams
|
|
74
|
+
* @typedef {Readonly<import('./fluxAggregatorKit.js').ChainlinkConfig & {
|
|
75
|
+
* quoteKit: QuoteKit,
|
|
76
|
+
* answerPublisher: Publisher<void>,
|
|
77
|
+
* brandIn: Brand<'nat'>,
|
|
78
|
+
* brandOut: Brand<'nat'>,
|
|
79
|
+
* latestRoundPublisher: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<LatestRound>,
|
|
80
|
+
* timerPresence: TimerService,
|
|
81
|
+
* }>} HeldParams
|
|
79
82
|
*
|
|
80
|
-
* @typedef {Readonly<
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* }
|
|
86
|
-
* >} ImmutableState
|
|
83
|
+
* @typedef {Readonly<HeldParams & {
|
|
84
|
+
* details: MapStore<bigint, RoundDetails>,
|
|
85
|
+
* rounds: MapStore<bigint, Round>,
|
|
86
|
+
* unitIn: bigint,
|
|
87
|
+
* }>} ImmutableState
|
|
87
88
|
*
|
|
88
89
|
* @typedef {{
|
|
89
|
-
*
|
|
90
|
-
*
|
|
90
|
+
* lastValueOutForUnitIn: bigint?,
|
|
91
|
+
* reportingRoundId: bigint,
|
|
91
92
|
* }} MutableState
|
|
92
93
|
*/
|
|
93
94
|
/** @typedef {ImmutableState & MutableState} State */
|
|
@@ -115,11 +116,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
115
116
|
handlePush: M.call(M.record(), M.record()).returns(M.promise()),
|
|
116
117
|
}),
|
|
117
118
|
},
|
|
118
|
-
/**
|
|
119
|
-
* @type {(
|
|
120
|
-
* opts: HeldParams & { unitAmountIn: Amount<'nat'> },
|
|
121
|
-
* ) => State}
|
|
122
|
-
*/
|
|
119
|
+
/** @type {(opts: HeldParams & { unitAmountIn: Amount<'nat'> }) => State} */
|
|
123
120
|
({
|
|
124
121
|
// ChainlinkConfig
|
|
125
122
|
maxSubmissionCount,
|
|
@@ -173,7 +170,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
173
170
|
},
|
|
174
171
|
{
|
|
175
172
|
helper: {
|
|
176
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* @param {bigint} roundId
|
|
175
|
+
*/
|
|
177
176
|
acceptingSubmissions(roundId) {
|
|
178
177
|
const { details } = this.state;
|
|
179
178
|
return (
|
|
@@ -191,7 +190,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
191
190
|
return roundId > add(lastStarted, restartDelay) || lastStarted === 0n;
|
|
192
191
|
},
|
|
193
192
|
|
|
194
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* @param {bigint} roundId
|
|
195
|
+
*/
|
|
195
196
|
deleteRoundDetails(roundId) {
|
|
196
197
|
const { details } = this.state;
|
|
197
198
|
const roundDetails = details.get(roundId);
|
|
@@ -200,7 +201,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
200
201
|
details.delete(roundId);
|
|
201
202
|
},
|
|
202
203
|
|
|
203
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* @param {bigint} roundId
|
|
206
|
+
*/
|
|
204
207
|
isNextRound(roundId) {
|
|
205
208
|
const { reportingRoundId } = this.state;
|
|
206
209
|
return roundId === add(reportingRoundId, 1);
|
|
@@ -418,7 +421,7 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
418
421
|
* @param {OracleStatus} status
|
|
419
422
|
* @param {bigint} roundId
|
|
420
423
|
* @param {Timestamp} blockTimestamp
|
|
421
|
-
* @returns {string
|
|
424
|
+
* @returns {string?} error message, if there is one
|
|
422
425
|
*/
|
|
423
426
|
validateOracleRound(status, roundId, blockTimestamp) {
|
|
424
427
|
const { reportingRoundId } = this.state;
|
|
@@ -446,7 +449,10 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
446
449
|
},
|
|
447
450
|
},
|
|
448
451
|
contract: {
|
|
449
|
-
/**
|
|
452
|
+
/**
|
|
453
|
+
*
|
|
454
|
+
* @param {PriceQuoteValue} quote
|
|
455
|
+
*/
|
|
450
456
|
async authenticateQuote(quote) {
|
|
451
457
|
const { quoteKit } = this.state;
|
|
452
458
|
const quoteAmount = AmountMath.make(quoteKit.brand, harden(quote));
|
|
@@ -464,7 +470,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
464
470
|
const { brandIn, brandOut, timerPresence } = state;
|
|
465
471
|
const { contract } = this.facets;
|
|
466
472
|
|
|
467
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* @param {PriceQuery} priceQuery
|
|
475
|
+
*/
|
|
468
476
|
return Far('createQuote', priceQuery => {
|
|
469
477
|
const { lastValueOutForUnitIn, unitIn } = state;
|
|
470
478
|
|
|
@@ -478,7 +486,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
478
486
|
return undefined;
|
|
479
487
|
}
|
|
480
488
|
|
|
481
|
-
/**
|
|
489
|
+
/**
|
|
490
|
+
* @param {Amount<'nat'>} amountIn the given amountIn
|
|
491
|
+
*/
|
|
482
492
|
const calcAmountOut = amountIn => {
|
|
483
493
|
const valueIn = AmountMath.getValue(brandIn, amountIn);
|
|
484
494
|
return AmountMath.make(
|
|
@@ -487,7 +497,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
487
497
|
);
|
|
488
498
|
};
|
|
489
499
|
|
|
490
|
-
/**
|
|
500
|
+
/**
|
|
501
|
+
* @param {Amount<'nat'>} amountOut the wanted amountOut
|
|
502
|
+
*/
|
|
491
503
|
const calcAmountIn = amountOut => {
|
|
492
504
|
const valueOut = AmountMath.getValue(brandOut, amountOut);
|
|
493
505
|
return AmountMath.make(
|
|
@@ -552,8 +564,9 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
552
564
|
},
|
|
553
565
|
|
|
554
566
|
/**
|
|
555
|
-
* consumers are encouraged to check
|
|
556
|
-
* by inspecting the updatedAt and
|
|
567
|
+
* consumers are encouraged to check
|
|
568
|
+
* that they're receiving fresh data by inspecting the updatedAt and
|
|
569
|
+
* answeredInRound return values.
|
|
557
570
|
*
|
|
558
571
|
* @param {bigint | number} roundIdRaw
|
|
559
572
|
* @returns {Promise<RoundData>}
|
|
@@ -590,9 +603,8 @@ export const prepareRoundsManagerKit = baggage =>
|
|
|
590
603
|
},
|
|
591
604
|
|
|
592
605
|
/**
|
|
593
|
-
* a method to provide all current info oracleStatuses need. Intended
|
|
594
|
-
* only
|
|
595
|
-
* to read state.
|
|
606
|
+
* a method to provide all current info oracleStatuses need. Intended only
|
|
607
|
+
* only to be callable by oracleStatuses. Not for use by contracts to read state.
|
|
596
608
|
*
|
|
597
609
|
* @param {OracleStatus} status
|
|
598
610
|
* @param {Timestamp} blockTimestamp
|
|
@@ -1,44 +1,28 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
|
-
// @ts-check
|
|
3
2
|
|
|
4
|
-
import { ToFarFunction } from '@endo/captp';
|
|
5
|
-
import { Far } from '@endo/marshal';
|
|
6
3
|
import { AmountMath, AssetKind } from '@agoric/ertp';
|
|
7
|
-
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
8
4
|
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
9
|
-
import {
|
|
5
|
+
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
6
|
+
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
10
7
|
import { E } from '@endo/far';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { makePromiseKit } from '@endo/promise-kit';
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
oracleBrandFeedName,
|
|
17
|
-
reserveThenGetNames,
|
|
18
|
-
scaledPriceFeedName,
|
|
19
|
-
} from './utils.js';
|
|
8
|
+
import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
9
|
+
import { reserveThenGetNames } from './utils.js';
|
|
20
10
|
|
|
21
11
|
export * from './startPSM.js';
|
|
22
12
|
|
|
23
|
-
const { quote: q } = assert;
|
|
24
|
-
|
|
25
13
|
/**
|
|
26
14
|
* @typedef {object} InterchainAssetOptions
|
|
27
15
|
* @property {string} [issuerBoardId]
|
|
28
16
|
* @property {string} [denom]
|
|
29
17
|
* @property {number} [decimalPlaces]
|
|
30
|
-
* @property {string}
|
|
31
|
-
* @property {string}
|
|
32
|
-
*
|
|
33
|
-
* @property {string} [proposedName] - defaults to `issuerName` if not provided
|
|
34
|
-
* @property {string} [oracleBrand] - defaults to `issuerName` if not provided
|
|
18
|
+
* @property {string} [proposedName]
|
|
19
|
+
* @property {string} keyword
|
|
20
|
+
* @property {string} oracleBrand
|
|
35
21
|
* @property {number} [initialPrice]
|
|
36
22
|
*/
|
|
37
23
|
|
|
38
|
-
/** @typedef {import('./econ-behaviors.js').EconomyBootstrapPowers} EconomyBootstrapPowers */
|
|
39
|
-
|
|
40
24
|
/**
|
|
41
|
-
* @param {
|
|
25
|
+
* @param {EconomyBootstrapPowers} powers
|
|
42
26
|
* @param {object} config
|
|
43
27
|
* @param {object} config.options
|
|
44
28
|
* @param {InterchainAssetOptions} config.options.interchainAssetOptions
|
|
@@ -47,22 +31,18 @@ export const publishInterchainAssetFromBoardId = async (
|
|
|
47
31
|
{ consume: { board, agoricNamesAdmin } },
|
|
48
32
|
{ options: { interchainAssetOptions } },
|
|
49
33
|
) => {
|
|
50
|
-
const {
|
|
51
|
-
issuerBoardId,
|
|
52
|
-
keyword,
|
|
53
|
-
issuerName = keyword,
|
|
54
|
-
} = interchainAssetOptions;
|
|
34
|
+
const { issuerBoardId, keyword } = interchainAssetOptions;
|
|
55
35
|
// Incompatible with denom.
|
|
56
36
|
assert.equal(interchainAssetOptions.denom, undefined);
|
|
57
37
|
assert.typeof(issuerBoardId, 'string');
|
|
58
|
-
assert.typeof(
|
|
38
|
+
assert.typeof(keyword, 'string');
|
|
59
39
|
|
|
60
40
|
const issuer = await E(board).getValue(issuerBoardId);
|
|
61
41
|
const brand = await E(issuer).getBrand();
|
|
62
42
|
|
|
63
43
|
return Promise.all([
|
|
64
|
-
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(
|
|
65
|
-
E(E(agoricNamesAdmin).lookupAdmin('brand')).update(
|
|
44
|
+
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer),
|
|
45
|
+
E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand),
|
|
66
46
|
]);
|
|
67
47
|
};
|
|
68
48
|
|
|
@@ -81,23 +61,18 @@ export const publishInterchainAssetFromBank = async (
|
|
|
81
61
|
},
|
|
82
62
|
{ options: { interchainAssetOptions } },
|
|
83
63
|
) => {
|
|
84
|
-
const {
|
|
85
|
-
|
|
86
|
-
decimalPlaces,
|
|
87
|
-
keyword,
|
|
88
|
-
issuerName = keyword,
|
|
89
|
-
proposedName = keyword,
|
|
90
|
-
} = interchainAssetOptions;
|
|
64
|
+
const { denom, decimalPlaces, proposedName, keyword } =
|
|
65
|
+
interchainAssetOptions;
|
|
91
66
|
|
|
92
67
|
// Incompatible with issuerBoardId.
|
|
93
68
|
assert.equal(interchainAssetOptions.issuerBoardId, undefined);
|
|
94
69
|
assert.typeof(denom, 'string');
|
|
70
|
+
assert.typeof(keyword, 'string');
|
|
95
71
|
assert.typeof(decimalPlaces, 'number');
|
|
96
|
-
assert.typeof(issuerName, 'string');
|
|
97
72
|
assert.typeof(proposedName, 'string');
|
|
98
73
|
|
|
99
74
|
const terms = {
|
|
100
|
-
keyword
|
|
75
|
+
keyword,
|
|
101
76
|
assetKind: AssetKind.NAT,
|
|
102
77
|
displayInfo: {
|
|
103
78
|
decimalPlaces,
|
|
@@ -107,7 +82,7 @@ export const publishInterchainAssetFromBank = async (
|
|
|
107
82
|
|
|
108
83
|
const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
|
|
109
84
|
installation: mintHolder,
|
|
110
|
-
label:
|
|
85
|
+
label: keyword,
|
|
111
86
|
privateArgs: undefined,
|
|
112
87
|
terms,
|
|
113
88
|
});
|
|
@@ -118,9 +93,9 @@ export const publishInterchainAssetFromBank = async (
|
|
|
118
93
|
await E(E.get(reserveKit).creatorFacet).addIssuer(issuer, keyword);
|
|
119
94
|
|
|
120
95
|
await Promise.all([
|
|
121
|
-
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(
|
|
122
|
-
E(E(agoricNamesAdmin).lookupAdmin('brand')).update(
|
|
123
|
-
E(bankManager).addAsset(denom,
|
|
96
|
+
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer),
|
|
97
|
+
E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand),
|
|
98
|
+
E(bankManager).addAsset(denom, keyword, proposedName, kit),
|
|
124
99
|
]);
|
|
125
100
|
};
|
|
126
101
|
|
|
@@ -138,17 +113,15 @@ export const registerScaledPriceAuthority = async (
|
|
|
138
113
|
priceAuthorityAdmin,
|
|
139
114
|
priceAuthority,
|
|
140
115
|
},
|
|
141
|
-
instance: { produce: produceInstance },
|
|
142
116
|
},
|
|
143
117
|
{ options: { interchainAssetOptions } },
|
|
144
118
|
) => {
|
|
145
119
|
const {
|
|
146
120
|
keyword,
|
|
147
|
-
|
|
148
|
-
oracleBrand = issuerName,
|
|
121
|
+
oracleBrand,
|
|
149
122
|
initialPrice: initialPriceRaw,
|
|
150
123
|
} = interchainAssetOptions;
|
|
151
|
-
assert.typeof(
|
|
124
|
+
assert.typeof(keyword, 'string');
|
|
152
125
|
assert.typeof(oracleBrand, 'string');
|
|
153
126
|
|
|
154
127
|
const [
|
|
@@ -159,7 +132,7 @@ export const registerScaledPriceAuthority = async (
|
|
|
159
132
|
] = await Promise.all([
|
|
160
133
|
priceAuthority,
|
|
161
134
|
reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('brand'), [
|
|
162
|
-
|
|
135
|
+
keyword,
|
|
163
136
|
'IST',
|
|
164
137
|
]),
|
|
165
138
|
reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [
|
|
@@ -215,11 +188,9 @@ export const registerScaledPriceAuthority = async (
|
|
|
215
188
|
}),
|
|
216
189
|
);
|
|
217
190
|
|
|
218
|
-
const label = scaledPriceFeedName(issuerName);
|
|
219
|
-
|
|
220
191
|
const spaKit = await E(startUpgradable)({
|
|
221
192
|
installation: scaledPriceAuthority,
|
|
222
|
-
label
|
|
193
|
+
label: `scaledPriceAuthority-${keyword}`,
|
|
223
194
|
terms,
|
|
224
195
|
});
|
|
225
196
|
|
|
@@ -230,81 +201,9 @@ export const registerScaledPriceAuthority = async (
|
|
|
230
201
|
stableBrand,
|
|
231
202
|
true, // force
|
|
232
203
|
);
|
|
233
|
-
|
|
234
|
-
// publish into agoricNames so that others can await its presence.
|
|
235
|
-
// This must stay after registerPriceAuthority above so it's evidence of registration.
|
|
236
|
-
// eslint-disable-next-line no-restricted-syntax -- computed property
|
|
237
|
-
produceInstance[label].resolve(spaKit.instance);
|
|
238
204
|
};
|
|
239
205
|
|
|
240
|
-
|
|
241
|
-
const BUFFER = 5n * 60n;
|
|
242
|
-
// let's insist on 20 minutes leeway for running the scripts
|
|
243
|
-
const COMPLETION = 20n * 60n;
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* This function works around an issue identified in #8307 and #8296, and fixed
|
|
247
|
-
* in #8301. The fix is needed until #8301 makes it into production.
|
|
248
|
-
*
|
|
249
|
-
* If there is a liveSchedule, 1) run now if start is far enough away,
|
|
250
|
-
* otherwise, 2) run after endTime. If neither liveSchedule nor nextSchedule is
|
|
251
|
-
* defined, 3) run now. If there is only a nextSchedule, 4) run now if startTime
|
|
252
|
-
* is far enough away, else 5) run after endTime
|
|
253
|
-
*
|
|
254
|
-
* @param {import('../auction/scheduler.js').FullSchedule} schedules
|
|
255
|
-
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
|
|
256
|
-
* @param {() => void} thunk
|
|
257
|
-
*/
|
|
258
|
-
const whenQuiescent = async (schedules, timer, thunk) => {
|
|
259
|
-
const { nextAuctionSchedule, liveAuctionSchedule } = schedules;
|
|
260
|
-
const now = await E(timer).getCurrentTimestamp();
|
|
261
|
-
|
|
262
|
-
const waker = Far('addAssetWaker', { wake: () => thunk() });
|
|
263
|
-
|
|
264
|
-
if (liveAuctionSchedule) {
|
|
265
|
-
const safeStart = TimeMath.subtractAbsRel(
|
|
266
|
-
liveAuctionSchedule.startTime,
|
|
267
|
-
COMPLETION,
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
if (TimeMath.compareAbs(safeStart, now) < 0) {
|
|
271
|
-
// case 2
|
|
272
|
-
console.warn(
|
|
273
|
-
`Add Asset after live schedule's endtime: ${q(
|
|
274
|
-
liveAuctionSchedule.endTime,
|
|
275
|
-
)}`,
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
return E(timer).setWakeup(
|
|
279
|
-
TimeMath.addAbsRel(liveAuctionSchedule.endTime, BUFFER),
|
|
280
|
-
waker,
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (!liveAuctionSchedule && nextAuctionSchedule) {
|
|
286
|
-
const safeStart = TimeMath.subtractAbsRel(
|
|
287
|
-
nextAuctionSchedule.startTime,
|
|
288
|
-
COMPLETION,
|
|
289
|
-
);
|
|
290
|
-
if (TimeMath.compareAbs(safeStart, now) < 0) {
|
|
291
|
-
// case 5
|
|
292
|
-
console.warn(
|
|
293
|
-
`Add Asset after next schedule's endtime: ${q(
|
|
294
|
-
nextAuctionSchedule.endTime,
|
|
295
|
-
)}`,
|
|
296
|
-
);
|
|
297
|
-
return E(timer).setWakeup(
|
|
298
|
-
TimeMath.addAbsRel(nextAuctionSchedule.endTime, BUFFER),
|
|
299
|
-
waker,
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// cases 1, 3, and 4 fall through to here.
|
|
305
|
-
console.warn(`Add Asset immediately`, thunk);
|
|
306
|
-
return thunk();
|
|
307
|
-
};
|
|
206
|
+
/** @typedef {import('./econ-behaviors.js').EconomyBootstrapPowers} EconomyBootstrapPowers */
|
|
308
207
|
|
|
309
208
|
/**
|
|
310
209
|
* @param {EconomyBootstrapPowers} powers
|
|
@@ -316,16 +215,10 @@ const whenQuiescent = async (schedules, timer, thunk) => {
|
|
|
316
215
|
*/
|
|
317
216
|
export const addAssetToVault = async (
|
|
318
217
|
{
|
|
319
|
-
consume: {
|
|
320
|
-
vaultFactoryKit,
|
|
321
|
-
agoricNamesAdmin,
|
|
322
|
-
auctioneerKit,
|
|
323
|
-
chainTimerService,
|
|
324
|
-
},
|
|
218
|
+
consume: { vaultFactoryKit, agoricNamesAdmin, auctioneerKit },
|
|
325
219
|
brand: {
|
|
326
220
|
consume: { [Stable.symbol]: stableP },
|
|
327
221
|
},
|
|
328
|
-
instance: { consume: consumeInstance },
|
|
329
222
|
},
|
|
330
223
|
{
|
|
331
224
|
options: {
|
|
@@ -338,43 +231,17 @@ export const addAssetToVault = async (
|
|
|
338
231
|
},
|
|
339
232
|
},
|
|
340
233
|
) => {
|
|
341
|
-
const {
|
|
342
|
-
keyword,
|
|
343
|
-
issuerName = keyword,
|
|
344
|
-
oracleBrand = issuerName,
|
|
345
|
-
} = interchainAssetOptions;
|
|
234
|
+
const { keyword, oracleBrand } = interchainAssetOptions;
|
|
346
235
|
assert.typeof(keyword, 'string');
|
|
347
|
-
assert.typeof(issuerName, 'string');
|
|
348
236
|
assert.typeof(oracleBrand, 'string');
|
|
349
237
|
const [interchainIssuer] = await reserveThenGetNames(
|
|
350
238
|
E(agoricNamesAdmin).lookupAdmin('issuer'),
|
|
351
|
-
[
|
|
239
|
+
[keyword],
|
|
352
240
|
);
|
|
353
241
|
|
|
354
|
-
// don't add the collateral offering to vaultFactory until its price feed is available
|
|
355
|
-
// eslint-disable-next-line no-restricted-syntax -- allow this computed property
|
|
356
|
-
await consumeInstance[oracleBrandFeedName(oracleBrand, 'USD')];
|
|
357
|
-
// await also the negotiable brand
|
|
358
|
-
// eslint-disable-next-line no-restricted-syntax -- allow this computed property
|
|
359
|
-
await consumeInstance[scaledPriceFeedName(issuerName)];
|
|
360
|
-
|
|
361
|
-
const auctioneerCreator = E.get(auctioneerKit).creatorFacet;
|
|
362
|
-
const schedules = await E(auctioneerCreator).getSchedule();
|
|
363
|
-
|
|
364
|
-
const finishPromiseKit = makePromiseKit();
|
|
365
|
-
const addBrandThenResolve = ToFarFunction('addBrandThenResolve', async () => {
|
|
366
|
-
await E(auctioneerCreator).addBrand(interchainIssuer, keyword);
|
|
367
|
-
finishPromiseKit.resolve(undefined);
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
// schedules actions on a timer (or does it immediately).
|
|
371
|
-
// finishPromiseKit signals completion.
|
|
372
|
-
void whenQuiescent(schedules, chainTimerService, addBrandThenResolve);
|
|
373
|
-
await finishPromiseKit.promise;
|
|
374
|
-
|
|
375
242
|
const stable = await stableP;
|
|
376
243
|
const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
|
|
377
|
-
await E(vaultFactoryCreator).addVaultType(interchainIssuer,
|
|
244
|
+
await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
|
|
378
245
|
debtLimit: AmountMath.make(stable, BigInt(debtLimitValue)),
|
|
379
246
|
interestRate: makeRatio(interestRateValue, stable),
|
|
380
247
|
// The rest of these we use safe defaults.
|
|
@@ -386,6 +253,8 @@ export const addAssetToVault = async (
|
|
|
386
253
|
mintFee: makeRatio(50n, stable, 10_000n),
|
|
387
254
|
liquidationPenalty: makeRatio(1n, stable),
|
|
388
255
|
});
|
|
256
|
+
const auctioneerCreator = E.get(auctioneerKit).creatorFacet;
|
|
257
|
+
await E(auctioneerCreator).addBrand(interchainIssuer, keyword);
|
|
389
258
|
};
|
|
390
259
|
|
|
391
260
|
export const getManifestForAddAssetToVault = (
|
|
@@ -417,7 +286,9 @@ export const getManifestForAddAssetToVault = (
|
|
|
417
286
|
consume: {
|
|
418
287
|
bankManager: true,
|
|
419
288
|
agoricNamesAdmin: true,
|
|
289
|
+
bankMints: true,
|
|
420
290
|
reserveKit: true,
|
|
291
|
+
vBankKits: true,
|
|
421
292
|
startUpgradable: true,
|
|
422
293
|
},
|
|
423
294
|
produce: { bankMints: true, vBankKits: true },
|
|
@@ -432,9 +303,10 @@ export const getManifestForAddAssetToVault = (
|
|
|
432
303
|
startUpgradable: true,
|
|
433
304
|
priceAuthorityAdmin: true,
|
|
434
305
|
priceAuthority: true,
|
|
306
|
+
scaledPriceAuthorityKits: true,
|
|
435
307
|
},
|
|
436
|
-
|
|
437
|
-
|
|
308
|
+
produce: {
|
|
309
|
+
scaledPriceAuthorityKits: true,
|
|
438
310
|
},
|
|
439
311
|
installation: {
|
|
440
312
|
consume: { scaledPriceAuthority: true },
|
|
@@ -445,16 +317,10 @@ export const getManifestForAddAssetToVault = (
|
|
|
445
317
|
auctioneerKit: 'auctioneer',
|
|
446
318
|
vaultFactoryKit: 'vaultFactory',
|
|
447
319
|
agoricNamesAdmin: true,
|
|
448
|
-
chainTimerService: true,
|
|
449
320
|
},
|
|
450
321
|
brand: {
|
|
451
322
|
consume: { [Stable.symbol]: true },
|
|
452
323
|
},
|
|
453
|
-
instance: {
|
|
454
|
-
// allow any instance because the AGORIC_INSTANCE_NAME of
|
|
455
|
-
// priceFeedOptions cannot be known statically.
|
|
456
|
-
consume: true,
|
|
457
|
-
},
|
|
458
324
|
},
|
|
459
325
|
},
|
|
460
326
|
installations: {
|