@agoric/inter-protocol 0.13.3 → 0.13.4-dev-800c2bb.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 +26 -20
- package/bundles/bundle-auctioneer-js-meta.json +722 -0
- package/bundles/bundle-auctioneer.js +1 -0
- package/bundles/bundle-econCommitteeCharter-js-meta.json +514 -0
- package/bundles/bundle-econCommitteeCharter.js +1 -0
- package/bundles/bundle-feeDistributor-js-meta.json +458 -0
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +674 -0
- package/bundles/bundle-fluxAggregatorKit.js +1 -0
- package/bundles/bundle-psm-js-meta.json +666 -0
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-js-meta.json +662 -0
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +542 -0
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-vaultFactory-js-meta.json +786 -0
- package/bundles/bundle-vaultFactory.js +1 -1
- package/exported.js +0 -2
- package/package.json +34 -31
- package/scripts/add-collateral-core.js +14 -4
- package/scripts/build-bundles.js +9 -2
- package/scripts/deploy-contracts.js +1 -4
- package/scripts/init-core.js +20 -38
- package/scripts/invite-committee-core.js +1 -1
- package/scripts/manual-price-feed.js +2 -2
- package/scripts/price-feed-core.js +7 -6
- package/scripts/start-local-chain.sh +84 -0
- package/src/auction/auctionBook.js +755 -0
- package/src/auction/auctioneer.js +720 -0
- package/src/auction/offerBook.js +221 -0
- package/src/auction/params.js +174 -0
- package/src/auction/scheduleMath.js +167 -0
- package/src/auction/scheduler.js +370 -0
- package/src/auction/sortedOffers.js +136 -0
- package/src/auction/util.js +55 -0
- package/src/clientSupport.js +324 -0
- package/src/collectFees.js +8 -14
- package/src/contractSupport.js +24 -68
- package/src/econCommitteeCharter.js +161 -77
- package/src/feeDistributor.js +60 -20
- package/src/index.js +2 -0
- package/src/interest-math.js +1 -4
- package/src/interest.js +20 -13
- package/src/price/README.md +57 -0
- package/src/price/fluxAggregatorContract.js +190 -0
- package/src/price/fluxAggregatorKit.js +375 -0
- package/src/price/priceOracleKit.js +127 -0
- package/src/price/roundsManager.js +726 -0
- package/src/proposals/addAssetToVault.js +89 -94
- package/src/proposals/committee-proposal.js +141 -40
- package/src/proposals/core-proposal.js +100 -167
- package/src/proposals/econ-behaviors.js +320 -564
- package/src/proposals/price-feed-proposal.js +175 -78
- package/src/proposals/startEconCommittee.js +25 -12
- package/src/proposals/startPSM.js +231 -211
- package/src/proposals/utils.js +31 -17
- package/src/psm/README.md +71 -0
- package/src/psm/psm.js +272 -160
- package/src/psm/types.js +2 -0
- package/src/reserve/assetReserve.js +56 -413
- package/src/reserve/assetReserveKit.js +303 -0
- package/src/reserve/doc.md +1 -3
- package/src/reserve/params.js +2 -5
- package/src/typeGuards.js +13 -0
- package/src/vaultFactory/Liquidation.md +100 -0
- package/src/vaultFactory/burn.js +2 -1
- package/src/vaultFactory/liquidation.js +270 -108
- package/src/vaultFactory/math.js +95 -0
- package/src/vaultFactory/orderedVaultStore.js +0 -1
- package/src/vaultFactory/params.js +133 -112
- package/src/vaultFactory/prioritizedVaults.js +36 -79
- package/src/vaultFactory/storeUtils.js +67 -9
- package/src/vaultFactory/type-imports.js +2 -0
- package/src/vaultFactory/types.js +22 -26
- package/src/vaultFactory/vault.js +772 -709
- package/src/vaultFactory/vaultDirector.js +480 -483
- package/src/vaultFactory/vaultFactory.js +99 -60
- package/src/vaultFactory/vaultHolder.js +121 -95
- package/src/vaultFactory/vaultKit.js +39 -31
- package/src/vaultFactory/vaultManager.js +1249 -868
- package/bundles/bundle-amm-meta.js +0 -618
- package/bundles/bundle-amm.js +0 -1
- package/bundles/bundle-feeDistributor-meta.js +0 -346
- package/bundles/bundle-interchainPool-meta.js +0 -534
- package/bundles/bundle-interchainPool.js +0 -1
- package/bundles/bundle-liquidateIncrementally-meta.js +0 -442
- package/bundles/bundle-liquidateIncrementally.js +0 -1
- package/bundles/bundle-liquidateMinimum-meta.js +0 -442
- package/bundles/bundle-liquidateMinimum.js +0 -1
- package/bundles/bundle-psm-meta.js +0 -538
- package/bundles/bundle-psmCharter-meta.js +0 -418
- package/bundles/bundle-psmCharter.js +0 -1
- package/bundles/bundle-reserve-meta.js +0 -542
- package/bundles/bundle-scaledPriceAuthority-meta.js +0 -442
- package/bundles/bundle-stakeFactory-meta.js +0 -574
- package/bundles/bundle-stakeFactory.js +0 -1
- package/bundles/bundle-vaultFactory-meta.js +0 -598
- package/scripts/add-initial-liquidity.js +0 -180
- package/src/collect.js +0 -13
- package/src/interchainPool.js +0 -135
- package/src/makeTracer.js +0 -36
- package/src/my-lien.js +0 -85
- package/src/proposals/demoIssuers.js +0 -685
- package/src/proposals/sim-behaviors.js +0 -40
- package/src/psm/psmCharter.js +0 -139
- package/src/stakeFactory/README.md +0 -62
- package/src/stakeFactory/attestation.js +0 -267
- package/src/stakeFactory/attestationTool.js +0 -66
- package/src/stakeFactory/constants.js +0 -16
- package/src/stakeFactory/params.js +0 -31
- package/src/stakeFactory/stakeFactory.js +0 -236
- package/src/stakeFactory/stakeFactoryKit.js +0 -455
- package/src/stakeFactory/stakeFactoryManager.js +0 -296
- package/src/stakeFactory/types.js +0 -42
- package/src/vaultFactory/liquidateIncrementally.js +0 -350
- package/src/vaultFactory/liquidateMinimum.js +0 -100
- package/src/vpool-xyk-amm/AttackersGuide.md +0 -89
- package/src/vpool-xyk-amm/addLiquidity.js +0 -222
- package/src/vpool-xyk-amm/addPool.js +0 -197
- package/src/vpool-xyk-amm/constantProduct/AMM-Trade.jpeg +0 -0
- package/src/vpool-xyk-amm/constantProduct/README.md +0 -204
- package/src/vpool-xyk-amm/constantProduct/calcFees.js +0 -99
- package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +0 -85
- package/src/vpool-xyk-amm/constantProduct/core.js +0 -153
- package/src/vpool-xyk-amm/constantProduct/defaults.js +0 -5
- package/src/vpool-xyk-amm/constantProduct/getXY.js +0 -52
- package/src/vpool-xyk-amm/constantProduct/internal-types.js +0 -116
- package/src/vpool-xyk-amm/constantProduct/invariants.js +0 -43
- package/src/vpool-xyk-amm/constantProduct/swap.js +0 -272
- package/src/vpool-xyk-amm/constantProduct/types.js +0 -32
- package/src/vpool-xyk-amm/doublePool.js +0 -194
- package/src/vpool-xyk-amm/estimate.js +0 -155
- package/src/vpool-xyk-amm/multipoolMarketMaker.js +0 -520
- package/src/vpool-xyk-amm/params.js +0 -61
- package/src/vpool-xyk-amm/pool.js +0 -396
- package/src/vpool-xyk-amm/priceAuthority.js +0 -94
- package/src/vpool-xyk-amm/removeLiquidity.js +0 -31
- package/src/vpool-xyk-amm/singlePool.js +0 -73
- package/src/vpool-xyk-amm/swap.js +0 -69
- package/src/vpool-xyk-amm/types.js +0 -154
|
@@ -1,23 +1,48 @@
|
|
|
1
|
+
// @ts-nocheck -- lots of type errors. low prio b/c proposals are like scripts
|
|
1
2
|
import { E } from '@endo/far';
|
|
2
|
-
import { makeIssuerKit } from '@agoric/ertp';
|
|
3
3
|
import {
|
|
4
4
|
makeStorageNodeChild,
|
|
5
5
|
assertPathSegment,
|
|
6
|
-
} from '@agoric/
|
|
7
|
-
import {
|
|
6
|
+
} from '@agoric/internal/src/lib-chainStorage.js';
|
|
7
|
+
import { makeTracer } from '@agoric/internal';
|
|
8
8
|
|
|
9
9
|
import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
|
|
10
10
|
import { reserveThenDeposit, reserveThenGetNames } from './utils.js';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const trace = makeTracer('RunPriceFeed', true);
|
|
13
|
+
|
|
14
|
+
/** @type {(name: string) => string} */
|
|
13
15
|
const sanitizePathSegment = name => {
|
|
14
16
|
const candidate = name.replace(/ /g, '_');
|
|
15
17
|
assertPathSegment(candidate);
|
|
16
18
|
return candidate;
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* brandIn?: ERef<Brand<'nat'> | undefined>,
|
|
24
|
+
* brandOut?: ERef<Brand<'nat'> | undefined>,
|
|
25
|
+
* IN_BRAND_NAME: string,
|
|
26
|
+
* IN_BRAND_DECIMALS: string,
|
|
27
|
+
* OUT_BRAND_NAME: string,
|
|
28
|
+
* OUT_BRAND_DECIMALS: string,
|
|
29
|
+
* }} PriceFeedOptions
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create inert brands (no mint or issuer) referred to by price oracles.
|
|
34
|
+
*
|
|
35
|
+
* @param {ChainBootstrapSpace & NamedVatPowers} space
|
|
36
|
+
* @param {{options: {priceFeedOptions: PriceFeedOptions}}} opt
|
|
37
|
+
* @returns {Promise<[Brand<'nat'>, Brand<'nat'>]>}
|
|
38
|
+
*/
|
|
19
39
|
export const ensureOracleBrands = async (
|
|
20
|
-
{
|
|
40
|
+
{
|
|
41
|
+
namedVat: {
|
|
42
|
+
consume: { agoricNames },
|
|
43
|
+
},
|
|
44
|
+
oracleBrand: { produce: oracleBrandProduce },
|
|
45
|
+
},
|
|
21
46
|
{
|
|
22
47
|
options: {
|
|
23
48
|
priceFeedOptions: {
|
|
@@ -31,28 +56,19 @@ export const ensureOracleBrands = async (
|
|
|
31
56
|
},
|
|
32
57
|
},
|
|
33
58
|
) => {
|
|
34
|
-
|
|
35
|
-
const obAdmin = E(agoricNamesAdmin).lookupAdmin('oracleBrand');
|
|
59
|
+
trace('ensureOracleBrands');
|
|
36
60
|
|
|
37
61
|
const updateFreshBrand = async (brand, name, decimals) => {
|
|
38
|
-
|
|
39
|
-
if (b) {
|
|
40
|
-
//
|
|
41
|
-
|
|
62
|
+
let b = await brand;
|
|
63
|
+
if (!b) {
|
|
64
|
+
// not 1st await
|
|
65
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
66
|
+
b = await E(agoricNames).provideInertBrand(
|
|
67
|
+
name,
|
|
68
|
+
harden({ decimalPlaces: parseInt(decimals, 10) }),
|
|
69
|
+
);
|
|
42
70
|
}
|
|
43
|
-
|
|
44
|
-
name,
|
|
45
|
-
undefined,
|
|
46
|
-
harden({ decimalPlaces: parseInt(decimals, 10) }),
|
|
47
|
-
).brand;
|
|
48
|
-
|
|
49
|
-
if (!name) {
|
|
50
|
-
// Don't update unnamed brands.
|
|
51
|
-
return freshBrand;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Atomically update if not already set.
|
|
55
|
-
return E(obAdmin).default(name, freshBrand);
|
|
71
|
+
oracleBrandProduce[name].resolve(b);
|
|
56
72
|
};
|
|
57
73
|
|
|
58
74
|
return Promise.all([
|
|
@@ -63,23 +79,23 @@ export const ensureOracleBrands = async (
|
|
|
63
79
|
|
|
64
80
|
/**
|
|
65
81
|
* @param {ChainBootstrapSpace} powers
|
|
66
|
-
* @param {{options: {priceFeedOptions: {AGORIC_INSTANCE_NAME: string, oracleAddresses:
|
|
82
|
+
* @param {{options: {priceFeedOptions: {AGORIC_INSTANCE_NAME: string, oracleAddresses: string[], contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig, IN_BRAND_NAME: string, OUT_BRAND_NAME: string}}}} config
|
|
67
83
|
*/
|
|
68
84
|
export const createPriceFeed = async (
|
|
69
85
|
{
|
|
70
86
|
consume: {
|
|
71
87
|
agoricNamesAdmin,
|
|
72
|
-
aggregators,
|
|
73
88
|
board,
|
|
74
89
|
chainStorage,
|
|
75
90
|
chainTimerService,
|
|
76
91
|
client,
|
|
92
|
+
econCharterKit,
|
|
93
|
+
highPrioritySendersManager,
|
|
77
94
|
namesByAddressAdmin,
|
|
78
95
|
priceAuthority,
|
|
79
96
|
priceAuthorityAdmin,
|
|
80
|
-
|
|
97
|
+
startGovernedUpgradable,
|
|
81
98
|
},
|
|
82
|
-
produce: { aggregators: produceAggregators },
|
|
83
99
|
},
|
|
84
100
|
{
|
|
85
101
|
options: {
|
|
@@ -93,18 +109,17 @@ export const createPriceFeed = async (
|
|
|
93
109
|
},
|
|
94
110
|
},
|
|
95
111
|
) => {
|
|
112
|
+
trace('createPriceFeed');
|
|
96
113
|
const STORAGE_PATH = 'priceFeed';
|
|
97
114
|
|
|
98
|
-
|
|
99
|
-
produceAggregators.resolve(new Map());
|
|
100
|
-
E(client).assignBundle([_addr => ({ priceAuthority })]);
|
|
115
|
+
void E(client).assignBundle([_addr => ({ priceAuthority })]);
|
|
101
116
|
|
|
102
117
|
const timer = await chainTimerService;
|
|
103
118
|
|
|
104
119
|
/**
|
|
105
120
|
* Values come from economy-template.json, which at this writing had IN:ATOM, OUT:USD
|
|
106
121
|
*
|
|
107
|
-
* @type {[[Brand
|
|
122
|
+
* @type {[[Brand<'nat'>, Brand<'nat'>], [Installation<import('@agoric/inter-protocol/src/price/fluxAggregatorContract.js').prepare>]]}
|
|
108
123
|
*/
|
|
109
124
|
const [[brandIn, brandOut], [priceAggregator]] = await Promise.all([
|
|
110
125
|
reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [
|
|
@@ -117,61 +132,64 @@ export const createPriceFeed = async (
|
|
|
117
132
|
]);
|
|
118
133
|
|
|
119
134
|
const unitAmountIn = await unitAmount(brandIn);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
131
|
-
terms.absent;
|
|
135
|
+
const terms = harden({
|
|
136
|
+
...contractTerms,
|
|
137
|
+
description: AGORIC_INSTANCE_NAME,
|
|
138
|
+
brandIn,
|
|
139
|
+
brandOut,
|
|
140
|
+
timer,
|
|
141
|
+
unitAmountIn,
|
|
142
|
+
});
|
|
143
|
+
trace('got terms');
|
|
144
|
+
|
|
145
|
+
const label = sanitizePathSegment(AGORIC_INSTANCE_NAME);
|
|
132
146
|
|
|
133
147
|
const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
134
|
-
const marshaller = E(board).getReadonlyMarshaller();
|
|
148
|
+
const marshaller = await E(board).getReadonlyMarshaller();
|
|
135
149
|
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
storageNode: E(storageNode).makeChildNode(
|
|
143
|
-
sanitizePathSegment(AGORIC_INSTANCE_NAME),
|
|
144
|
-
),
|
|
150
|
+
trace('awaiting startInstance');
|
|
151
|
+
const faKit = await E(startGovernedUpgradable)({
|
|
152
|
+
governedParams: {},
|
|
153
|
+
privateArgs: {
|
|
154
|
+
highPrioritySendersManager: await highPrioritySendersManager,
|
|
145
155
|
marshaller,
|
|
156
|
+
namesByAddressAdmin,
|
|
157
|
+
storageNode: await E(storageNode).makeChildNode(label),
|
|
146
158
|
},
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
terms,
|
|
160
|
+
label,
|
|
161
|
+
installation: priceAggregator,
|
|
162
|
+
});
|
|
149
163
|
|
|
150
|
-
E(E(agoricNamesAdmin).lookupAdmin('instance'))
|
|
164
|
+
E(E(agoricNamesAdmin).lookupAdmin('instance'))
|
|
165
|
+
.update(AGORIC_INSTANCE_NAME, faKit.instance)
|
|
166
|
+
.catch(err =>
|
|
167
|
+
console.error(`🚨 failed to update ${AGORIC_INSTANCE_NAME}`, err),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
171
|
+
faKit.instance,
|
|
172
|
+
faKit.governorCreatorFacet,
|
|
151
173
|
AGORIC_INSTANCE_NAME,
|
|
152
|
-
aggregator.instance,
|
|
153
174
|
);
|
|
175
|
+
trace('registered', AGORIC_INSTANCE_NAME, faKit.instance);
|
|
154
176
|
|
|
155
177
|
// Publish price feed in home.priceAuthority.
|
|
156
178
|
const forceReplace = true;
|
|
157
|
-
E(priceAuthorityAdmin)
|
|
158
|
-
.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
)
|
|
164
|
-
.then(deleter => E(aggregators).set(terms, { aggregator, deleter }));
|
|
179
|
+
void E(priceAuthorityAdmin).registerPriceAuthority(
|
|
180
|
+
E(faKit.publicFacet).getPriceAuthority(),
|
|
181
|
+
brandIn,
|
|
182
|
+
brandOut,
|
|
183
|
+
forceReplace,
|
|
184
|
+
);
|
|
165
185
|
|
|
166
186
|
/**
|
|
167
|
-
*
|
|
187
|
+
* Initialize a new oracle and send an invitation to administer it.
|
|
168
188
|
*
|
|
169
189
|
* @param {string} addr
|
|
170
190
|
*/
|
|
171
|
-
const
|
|
172
|
-
const invitation = await E(
|
|
173
|
-
addr,
|
|
174
|
-
);
|
|
191
|
+
const addOracle = async addr => {
|
|
192
|
+
const invitation = await E(faKit.creatorFacet).makeOracleInvitation(addr);
|
|
175
193
|
await reserveThenDeposit(
|
|
176
194
|
`${AGORIC_INSTANCE_NAME} member ${addr}`,
|
|
177
195
|
namesByAddressAdmin,
|
|
@@ -180,11 +198,19 @@ export const createPriceFeed = async (
|
|
|
180
198
|
);
|
|
181
199
|
};
|
|
182
200
|
|
|
183
|
-
|
|
201
|
+
trace('distributing invitations', oracleAddresses);
|
|
202
|
+
await Promise.all(oracleAddresses.map(addOracle));
|
|
203
|
+
trace('createPriceFeed complete');
|
|
184
204
|
};
|
|
185
205
|
|
|
186
|
-
// Return the manifest, installations, and options.
|
|
187
206
|
const t = 'priceFeed';
|
|
207
|
+
/**
|
|
208
|
+
* Add a price feed to a running chain, returning the manifest, installations, and options.
|
|
209
|
+
*
|
|
210
|
+
* @param {object} utils
|
|
211
|
+
* @param {(ref: unknown) => Promise<unknown>} [utils.restoreRef]
|
|
212
|
+
* @param {PriceFeedOptions} priceFeedOptions
|
|
213
|
+
*/
|
|
188
214
|
export const getManifestForPriceFeed = async (
|
|
189
215
|
{ restoreRef },
|
|
190
216
|
priceFeedOptions,
|
|
@@ -192,22 +218,27 @@ export const getManifestForPriceFeed = async (
|
|
|
192
218
|
manifest: {
|
|
193
219
|
[createPriceFeed.name]: {
|
|
194
220
|
consume: {
|
|
195
|
-
aggregators: t,
|
|
196
221
|
agoricNamesAdmin: t,
|
|
197
222
|
board: t,
|
|
198
223
|
chainStorage: t,
|
|
199
224
|
chainTimerService: t,
|
|
200
225
|
client: t,
|
|
226
|
+
contractGovernor: t,
|
|
227
|
+
econCharterKit: t,
|
|
228
|
+
economicCommitteeCreatorFacet: t,
|
|
229
|
+
highPrioritySendersManager: t,
|
|
201
230
|
namesByAddressAdmin: t,
|
|
202
231
|
priceAuthority: t,
|
|
203
232
|
priceAuthorityAdmin: t,
|
|
204
|
-
|
|
233
|
+
startGovernedUpgradable: t,
|
|
205
234
|
},
|
|
206
|
-
produce: { aggregators: t },
|
|
207
235
|
},
|
|
208
236
|
[ensureOracleBrands.name]: {
|
|
209
|
-
|
|
210
|
-
|
|
237
|
+
namedVat: {
|
|
238
|
+
consume: { agoricNames: 'agoricNames' },
|
|
239
|
+
},
|
|
240
|
+
oracleBrand: {
|
|
241
|
+
produce: t,
|
|
211
242
|
},
|
|
212
243
|
},
|
|
213
244
|
},
|
|
@@ -225,3 +256,69 @@ export const getManifestForPriceFeed = async (
|
|
|
225
256
|
},
|
|
226
257
|
},
|
|
227
258
|
});
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
262
|
+
* @param {object} [config]
|
|
263
|
+
* @param {object} [config.options]
|
|
264
|
+
* @param {string[]} [config.options.demoOracleAddresses]
|
|
265
|
+
*/
|
|
266
|
+
export const startPriceFeeds = async (
|
|
267
|
+
{
|
|
268
|
+
consume,
|
|
269
|
+
produce,
|
|
270
|
+
installation: {
|
|
271
|
+
consume: { priceAggregator },
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{ options: { demoOracleAddresses = [] } = {} },
|
|
275
|
+
) => {
|
|
276
|
+
trace('startPriceFeeds');
|
|
277
|
+
|
|
278
|
+
// eventually this will have be parameterized. for now we just need one contract
|
|
279
|
+
// working well enough to build tooling around.
|
|
280
|
+
const inBrandName = 'ATOM';
|
|
281
|
+
const outBrandName = 'USD';
|
|
282
|
+
|
|
283
|
+
/** @type {ERef<NameAdmin>} */
|
|
284
|
+
const installAdmin = E(consume.agoricNamesAdmin).lookupAdmin('installation');
|
|
285
|
+
await E(installAdmin).update('priceAggregator', priceAggregator);
|
|
286
|
+
|
|
287
|
+
await ensureOracleBrands(
|
|
288
|
+
{ consume },
|
|
289
|
+
{
|
|
290
|
+
options: {
|
|
291
|
+
priceFeedOptions: {
|
|
292
|
+
IN_BRAND_NAME: inBrandName,
|
|
293
|
+
IN_BRAND_DECIMALS: '6',
|
|
294
|
+
OUT_BRAND_NAME: outBrandName,
|
|
295
|
+
OUT_BRAND_DECIMALS: '6',
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
await createPriceFeed(
|
|
302
|
+
{ consume, produce },
|
|
303
|
+
{
|
|
304
|
+
options: {
|
|
305
|
+
priceFeedOptions: {
|
|
306
|
+
AGORIC_INSTANCE_NAME: `${inBrandName}-${outBrandName} price feed`,
|
|
307
|
+
contractTerms: {
|
|
308
|
+
minSubmissionCount: 2,
|
|
309
|
+
minSubmissionValue: 1,
|
|
310
|
+
maxSubmissionCount: 5,
|
|
311
|
+
maxSubmissionValue: 99999,
|
|
312
|
+
restartDelay: 1n,
|
|
313
|
+
timeout: 10,
|
|
314
|
+
},
|
|
315
|
+
oracleAddresses: demoOracleAddresses,
|
|
316
|
+
IN_BRAND_NAME: inBrandName,
|
|
317
|
+
OUT_BRAND_NAME: outBrandName,
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
);
|
|
322
|
+
trace('startPriceFeeds complete');
|
|
323
|
+
};
|
|
324
|
+
harden(startPriceFeeds);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { makeTracer } from '@agoric/internal';
|
|
2
2
|
import {
|
|
3
3
|
assertPathSegment,
|
|
4
4
|
makeStorageNodeChild,
|
|
5
|
-
} from '@agoric/
|
|
5
|
+
} from '@agoric/internal/src/lib-chainStorage.js';
|
|
6
6
|
import { E } from '@endo/far';
|
|
7
|
-
import { makeTracer } from '../makeTracer.js';
|
|
8
7
|
|
|
9
|
-
const trace = makeTracer('
|
|
8
|
+
const trace = makeTracer('RunEconCommittee', true);
|
|
10
9
|
|
|
11
10
|
/** @type {(name: string) => string} */
|
|
12
11
|
const sanitizePathSegment = name => {
|
|
@@ -29,8 +28,8 @@ const sanitizePathSegment = name => {
|
|
|
29
28
|
*/
|
|
30
29
|
export const startEconomicCommittee = async (
|
|
31
30
|
{
|
|
32
|
-
consume: { board, chainStorage, zoe },
|
|
33
|
-
produce: { economicCommitteeCreatorFacet },
|
|
31
|
+
consume: { board, chainStorage, diagnostics, zoe },
|
|
32
|
+
produce: { economicCommitteeKit, economicCommitteeCreatorFacet },
|
|
34
33
|
installation: {
|
|
35
34
|
consume: { committee },
|
|
36
35
|
},
|
|
@@ -60,16 +59,26 @@ export const startEconomicCommittee = async (
|
|
|
60
59
|
// NB: committee must only publish what it intended to be public
|
|
61
60
|
const marshaller = await E(board).getPublishingMarshaller();
|
|
62
61
|
|
|
63
|
-
const
|
|
62
|
+
const privateArgs = {
|
|
63
|
+
storageNode,
|
|
64
|
+
marshaller,
|
|
65
|
+
};
|
|
66
|
+
const startResult = await E(zoe).startInstance(
|
|
64
67
|
committee,
|
|
65
68
|
{},
|
|
66
69
|
{ committeeName, committeeSize, ...rest },
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
privateArgs,
|
|
71
|
+
'economicCommittee',
|
|
72
|
+
);
|
|
73
|
+
const { creatorFacet, instance } = startResult;
|
|
74
|
+
|
|
75
|
+
economicCommitteeKit.resolve(
|
|
76
|
+
// XXX should startInstance return its label?
|
|
77
|
+
harden({ ...startResult, label: 'economicCommittee' }),
|
|
71
78
|
);
|
|
72
79
|
|
|
80
|
+
await E(diagnostics).savePrivateArgs(startResult.instance, privateArgs);
|
|
81
|
+
|
|
73
82
|
economicCommitteeCreatorFacet.resolve(creatorFacet);
|
|
74
83
|
economicCommittee.resolve(instance);
|
|
75
84
|
};
|
|
@@ -80,9 +89,13 @@ export const ECON_COMMITTEE_MANIFEST = harden({
|
|
|
80
89
|
consume: {
|
|
81
90
|
board: true,
|
|
82
91
|
chainStorage: true,
|
|
92
|
+
diagnostics: true,
|
|
83
93
|
zoe: true,
|
|
84
94
|
},
|
|
85
|
-
produce: {
|
|
95
|
+
produce: {
|
|
96
|
+
economicCommitteeKit: true,
|
|
97
|
+
economicCommitteeCreatorFacet: 'economicCommittee',
|
|
98
|
+
},
|
|
86
99
|
installation: {
|
|
87
100
|
consume: { committee: 'zoe' },
|
|
88
101
|
},
|