@agoric/inter-protocol 0.13.2-dev-65d3f14.0 → 0.13.2-pismo-dev-12e97f1.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/bundles/bundle-amm-meta.js +168 -188
- package/bundles/bundle-amm.js +1 -1
- package/bundles/bundle-feeDistributor-meta.js +92 -92
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-interchainPool-meta.js +174 -190
- package/bundles/bundle-interchainPool.js +1 -1
- package/bundles/bundle-liquidateIncrementally-meta.js +149 -109
- package/bundles/bundle-liquidateIncrementally.js +1 -1
- package/bundles/bundle-liquidateMinimum-meta.js +149 -109
- package/bundles/bundle-liquidateMinimum.js +1 -1
- package/bundles/bundle-psm-meta.js +148 -168
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-psmCharter-meta.js +418 -0
- package/bundles/bundle-psmCharter.js +1 -0
- package/bundles/bundle-reserve-meta.js +176 -192
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-meta.js +173 -133
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-stakeFactory-meta.js +186 -206
- package/bundles/bundle-stakeFactory.js +1 -1
- package/bundles/bundle-vaultFactory-meta.js +197 -217
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +23 -25
- package/scripts/add-collateral-core.js +3 -52
- package/scripts/add-initial-liquidity.js +1 -0
- package/scripts/build-bundles.js +1 -4
- package/scripts/deploy-contracts.js +1 -0
- package/scripts/init-core.js +9 -11
- package/scripts/invite-committee-core.js +1 -0
- package/scripts/manual-price-feed.js +1 -1
- package/scripts/price-feed-core.js +2 -2
- package/src/collect.js +2 -0
- package/src/collectFees.js +4 -3
- package/src/contractSupport.js +27 -13
- package/src/econCommitteeCharter.js +80 -110
- package/src/feeDistributor.js +8 -6
- package/src/interchainPool.js +8 -7
- package/src/interest-math.js +2 -0
- package/src/interest.js +10 -6
- package/src/makeTracer.js +0 -5
- package/src/my-lien.js +7 -3
- package/src/proposals/addAssetToVault.js +5 -3
- package/src/proposals/committee-proposal.js +42 -112
- package/src/proposals/core-proposal.js +30 -17
- package/src/proposals/demoIssuers.js +16 -17
- package/src/proposals/econ-behaviors.js +115 -156
- package/src/proposals/price-feed-proposal.js +6 -118
- package/src/proposals/sim-behaviors.js +1 -0
- package/src/proposals/startEconCommittee.js +2 -1
- package/src/proposals/startPSM.js +117 -77
- package/src/proposals/utils.js +12 -23
- package/src/psm/psm.js +55 -37
- package/src/psm/psmCharter.js +139 -0
- package/src/reserve/assetReserve.js +35 -28
- package/src/reserve/params.js +2 -0
- package/src/stakeFactory/attestation.js +9 -4
- package/src/stakeFactory/attestationTool.js +1 -0
- package/src/stakeFactory/params.js +1 -0
- package/src/stakeFactory/stakeFactory.js +1 -1
- package/src/stakeFactory/stakeFactoryKit.js +20 -13
- package/src/stakeFactory/stakeFactoryManager.js +3 -2
- package/src/vaultFactory/burn.js +1 -0
- package/src/vaultFactory/liquidateIncrementally.js +8 -5
- package/src/vaultFactory/liquidateMinimum.js +6 -2
- package/src/vaultFactory/liquidation.js +2 -2
- package/src/vaultFactory/orderedVaultStore.js +1 -0
- package/src/vaultFactory/params.js +12 -7
- package/src/vaultFactory/prioritizedVaults.js +1 -0
- package/src/vaultFactory/storeUtils.js +1 -0
- package/src/vaultFactory/types.js +2 -0
- package/src/vaultFactory/vault.js +40 -26
- package/src/vaultFactory/vaultDirector.js +18 -15
- package/src/vaultFactory/vaultFactory.js +20 -19
- package/src/vaultFactory/vaultHolder.js +3 -4
- package/src/vaultFactory/vaultKit.js +1 -0
- package/src/vaultFactory/vaultManager.js +10 -7
- package/src/vpool-xyk-amm/addLiquidity.js +4 -3
- package/src/vpool-xyk-amm/addPool.js +20 -23
- package/src/vpool-xyk-amm/constantProduct/calcFees.js +12 -6
- package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +2 -0
- package/src/vpool-xyk-amm/constantProduct/core.js +24 -16
- package/src/vpool-xyk-amm/constantProduct/defaults.js +2 -0
- package/src/vpool-xyk-amm/constantProduct/getXY.js +6 -2
- package/src/vpool-xyk-amm/constantProduct/internal-types.js +14 -12
- package/src/vpool-xyk-amm/constantProduct/invariants.js +8 -4
- package/src/vpool-xyk-amm/constantProduct/swap.js +19 -17
- package/src/vpool-xyk-amm/constantProduct/types.js +2 -0
- package/src/vpool-xyk-amm/doublePool.js +14 -20
- package/src/vpool-xyk-amm/estimate.js +2 -0
- package/src/vpool-xyk-amm/multipoolMarketMaker.js +5 -3
- package/src/vpool-xyk-amm/params.js +2 -0
- package/src/vpool-xyk-amm/pool.js +14 -16
- package/src/vpool-xyk-amm/priceAuthority.js +3 -1
- package/src/vpool-xyk-amm/removeLiquidity.js +2 -0
- package/src/vpool-xyk-amm/singlePool.js +14 -29
- package/src/vpool-xyk-amm/swap.js +1 -0
- package/src/vpool-xyk-amm/types.js +12 -10
- package/bundles/bundle-econCommitteeCharter-meta.js +0 -418
- package/bundles/bundle-econCommitteeCharter.js +0 -1
- package/scripts/start-local-chain-boot.js +0 -96
- package/scripts/start-local-chain-config.json +0 -83
- package/scripts/start-local-chain.sh +0 -69
- package/src/psm/README.md +0 -71
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import '../../exported.js';
|
|
2
4
|
|
|
3
5
|
import { AmountMath } from '@agoric/ertp';
|
|
@@ -6,7 +8,7 @@ import '@agoric/vats/exported.js';
|
|
|
6
8
|
import '@agoric/vats/src/core/types.js';
|
|
7
9
|
import { makeStorageNodeChild } from '@agoric/vats/src/lib-chainStorage.js';
|
|
8
10
|
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
9
|
-
import { E } from '@endo/far';
|
|
11
|
+
import { E, Far } from '@endo/far';
|
|
10
12
|
import { Stable, Stake } from '@agoric/vats/src/tokens.js';
|
|
11
13
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
12
14
|
import * as Collect from '../collect.js';
|
|
@@ -20,7 +22,7 @@ import { makeAmmTerms } from '../vpool-xyk-amm/params.js';
|
|
|
20
22
|
|
|
21
23
|
const trace = makeTracer('RunEconBehaviors', false);
|
|
22
24
|
|
|
23
|
-
const {
|
|
25
|
+
const { details: X } = assert;
|
|
24
26
|
|
|
25
27
|
const SECONDS_PER_HOUR = 60n * 60n;
|
|
26
28
|
const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
@@ -32,11 +34,10 @@ const MILLI = 1_000_000n;
|
|
|
32
34
|
* @typedef {GovernedCreatorFacet<import('../stakeFactory/stakeFactory.js').StakeFactoryCreator>} StakeFactoryCreator
|
|
33
35
|
* @typedef {import('../stakeFactory/stakeFactory.js').StakeFactoryPublic} StakeFactoryPublic
|
|
34
36
|
* @typedef {import('../reserve/assetReserve.js').GovernedAssetReserveFacetAccess} GovernedAssetReserveFacetAccess
|
|
35
|
-
* @typedef {import('../vaultFactory/vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
|
|
36
37
|
*/
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
|
-
* @typedef {object}
|
|
40
|
+
* @typedef {object} PSMFacets
|
|
40
41
|
* @property {Instance} psm
|
|
41
42
|
* @property {Instance} psmGovernor
|
|
42
43
|
* @property {Awaited<ReturnType<import('../psm/psm.js').start>>['creatorFacet']} psmCreatorFacet
|
|
@@ -48,47 +49,28 @@ const MILLI = 1_000_000n;
|
|
|
48
49
|
* @typedef { WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace
|
|
49
50
|
* } EconomyBootstrapPowers
|
|
50
51
|
* @typedef {PromiseSpaceOf<{
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* },
|
|
58
|
-
* economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet,
|
|
59
|
-
* feeDistributorKit: {
|
|
60
|
-
* creatorFacet: import('../feeDistributor.js').FeeDistributorCreatorFacet,
|
|
61
|
-
* publicFacet: import('../feeDistributor.js').FeeDistributorPublicFacet,
|
|
62
|
-
* adminFacet: AdminFacet,
|
|
63
|
-
* },
|
|
52
|
+
* ammInstanceWithoutReserve: Instance,
|
|
53
|
+
* ammCreatorFacet: XYKAMMCreatorFacet,
|
|
54
|
+
* ammGovernorCreatorFacet: GovernedContractFacetAccess<XYKAMMPublicFacet,XYKAMMCreatorFacet>,
|
|
55
|
+
* economicCommitteeCreatorFacet: CommitteeElectorateCreatorFacet,
|
|
56
|
+
* feeDistributorCreatorFacet: import('../feeDistributor.js').FeeDistributorCreatorFacet,
|
|
57
|
+
* feeDistributorPublicFacet: import('../feeDistributor.js').FeeDistributorPublicFacet,
|
|
64
58
|
* periodicFeeCollectors: import('../feeDistributor.js').PeriodicFeeCollector[],
|
|
65
59
|
* bankMints: Mint[],
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* governorCreatorFacet: GovernedContractFacetAccess<{}, {}>,
|
|
77
|
-
* adminFacet: AdminFacet,
|
|
78
|
-
* publicFacet: StakeFactoryPublic,
|
|
79
|
-
* },
|
|
80
|
-
* vaultFactoryKit: {
|
|
81
|
-
* publicFacet: VaultFactoryPublicFacet,
|
|
82
|
-
* creatorFacet: VaultFactoryCreatorFacet,
|
|
83
|
-
* governorCreatorFacet: GovernedContractFacetAccess<{},{}>,
|
|
84
|
-
* adminFacet: AdminFacet,
|
|
85
|
-
* },
|
|
60
|
+
* psmFacets: MapStore<Brand, PSMFacets>,
|
|
61
|
+
* psmCharterCreatorFacet: Awaited<ReturnType<import('../psm/psmCharter.js').start>>['creatorFacet'],
|
|
62
|
+
* psmCharterAdminFacet: AdminFacet,
|
|
63
|
+
* reservePublicFacet: import('../reserve/assetReserve.js').AssetReservePublicFacet,
|
|
64
|
+
* reserveCreatorFacet: import('../reserve/assetReserve.js').AssetReserveLimitedCreatorFacet,
|
|
65
|
+
* reserveGovernorCreatorFacet: GovernedAssetReserveFacetAccess,
|
|
66
|
+
* stakeFactoryCreatorFacet: StakeFactoryCreator,
|
|
67
|
+
* vaultFactoryCreator: VaultFactoryCreatorFacet,
|
|
68
|
+
* vaultFactoryGovernorCreator: GovernedContractFacetAccess<{},{}>,
|
|
69
|
+
* vaultFactoryVoteCreator: unknown,
|
|
86
70
|
* minInitialDebt: NatValue,
|
|
87
71
|
* }>} EconomyBootstrapSpace
|
|
88
72
|
*/
|
|
89
73
|
|
|
90
|
-
/** @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<import('../econCommitteeCharter').start>} EconCharterStartResult */
|
|
91
|
-
|
|
92
74
|
/**
|
|
93
75
|
* @file A collection of productions, each of which declares inputs and outputs.
|
|
94
76
|
* Each function is passed a set of powers for reading from and writing to the vat config.
|
|
@@ -167,7 +149,11 @@ export const setupAmm = async (
|
|
|
167
149
|
economicCommitteeCreatorFacet: committeeCreator,
|
|
168
150
|
chainStorage,
|
|
169
151
|
},
|
|
170
|
-
produce: {
|
|
152
|
+
produce: {
|
|
153
|
+
ammCreatorFacet,
|
|
154
|
+
ammInstanceWithoutReserve,
|
|
155
|
+
ammGovernorCreatorFacet,
|
|
156
|
+
},
|
|
171
157
|
brand: {
|
|
172
158
|
consume: { [Stable.symbol]: runBrandP },
|
|
173
159
|
},
|
|
@@ -194,7 +180,7 @@ export const setupAmm = async (
|
|
|
194
180
|
|
|
195
181
|
const ammTerms = makeAmmTerms(
|
|
196
182
|
chainTimerService,
|
|
197
|
-
E(E(zoe).getInvitationIssuer()).getAmountOf(
|
|
183
|
+
E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
|
|
198
184
|
AmountMath.make(runBrand, minInitialPoolLiquidity),
|
|
199
185
|
);
|
|
200
186
|
|
|
@@ -215,7 +201,7 @@ export const setupAmm = async (
|
|
|
215
201
|
}),
|
|
216
202
|
);
|
|
217
203
|
|
|
218
|
-
/** @type {{ creatorFacet: GovernedContractFacetAccess<XYKAMMPublicFacet,XYKAMMCreatorFacet>, publicFacet: GovernorPublic, instance: Instance
|
|
204
|
+
/** @type {{ creatorFacet: GovernedContractFacetAccess<XYKAMMPublicFacet,XYKAMMCreatorFacet>, publicFacet: GovernorPublic, instance: Instance }} */
|
|
219
205
|
const g = await E(zoe).startInstance(
|
|
220
206
|
governorInstallation,
|
|
221
207
|
{},
|
|
@@ -235,19 +221,13 @@ export const setupAmm = async (
|
|
|
235
221
|
E(g.creatorFacet).getPublicFacet(),
|
|
236
222
|
E(g.publicFacet).getGovernedContract(),
|
|
237
223
|
]);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
creatorFacet,
|
|
241
|
-
instanceWithoutReserve: instance,
|
|
242
|
-
governorCreatorFacet: g.creatorFacet,
|
|
243
|
-
adminFacet: g.adminFacet,
|
|
244
|
-
publicFacet: ammPublicFacet,
|
|
245
|
-
}),
|
|
246
|
-
);
|
|
224
|
+
ammGovernorCreatorFacet.resolve(g.creatorFacet);
|
|
225
|
+
ammCreatorFacet.resolve(creatorFacet);
|
|
247
226
|
|
|
248
227
|
// Confirm that the amm was indeed setup
|
|
249
|
-
ammPublicFacet
|
|
228
|
+
assert(ammPublicFacet, X`ammPublicFacet broken ${ammPublicFacet}`);
|
|
250
229
|
|
|
230
|
+
ammInstanceWithoutReserve.resolve(instance);
|
|
251
231
|
ammGovernor.resolve(g.instance);
|
|
252
232
|
return ammInstallation;
|
|
253
233
|
};
|
|
@@ -255,7 +235,8 @@ export const setupAmm = async (
|
|
|
255
235
|
/** @param {EconomyBootstrapPowers} powers */
|
|
256
236
|
export const setupReserve = async ({
|
|
257
237
|
consume: {
|
|
258
|
-
|
|
238
|
+
ammCreatorFacet,
|
|
239
|
+
ammInstanceWithoutReserve,
|
|
259
240
|
board,
|
|
260
241
|
feeMintAccess: feeMintAccessP,
|
|
261
242
|
chainStorage,
|
|
@@ -263,7 +244,11 @@ export const setupReserve = async ({
|
|
|
263
244
|
zoe,
|
|
264
245
|
economicCommitteeCreatorFacet: committeeCreator,
|
|
265
246
|
},
|
|
266
|
-
produce: {
|
|
247
|
+
produce: {
|
|
248
|
+
reserveCreatorFacet,
|
|
249
|
+
reserveGovernorCreatorFacet,
|
|
250
|
+
reservePublicFacet,
|
|
251
|
+
},
|
|
267
252
|
issuer: {
|
|
268
253
|
consume: { [Stable.symbol]: centralIssuer },
|
|
269
254
|
},
|
|
@@ -284,17 +269,16 @@ export const setupReserve = async ({
|
|
|
284
269
|
const STORAGE_PATH = 'reserve';
|
|
285
270
|
trace('setupReserve');
|
|
286
271
|
const poserInvitationP = E(committeeCreator).getPoserInvitation();
|
|
287
|
-
const [poserInvitation, poserInvitationAmount, feeMintAccess
|
|
272
|
+
const [poserInvitation, poserInvitationAmount, feeMintAccess] =
|
|
288
273
|
await Promise.all([
|
|
289
274
|
poserInvitationP,
|
|
290
275
|
E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
|
|
291
276
|
feeMintAccessP,
|
|
292
|
-
ammKitP,
|
|
293
277
|
]);
|
|
294
278
|
|
|
295
279
|
const reserveTerms = makeReserveTerms(
|
|
296
280
|
poserInvitationAmount,
|
|
297
|
-
|
|
281
|
+
ammInstanceWithoutReserve,
|
|
298
282
|
);
|
|
299
283
|
|
|
300
284
|
const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
@@ -310,7 +294,7 @@ export const setupReserve = async ({
|
|
|
310
294
|
},
|
|
311
295
|
}),
|
|
312
296
|
);
|
|
313
|
-
/** @type {{ creatorFacet: GovernedAssetReserveFacetAccess, publicFacet: GovernorPublic, instance: Instance
|
|
297
|
+
/** @type {{ creatorFacet: GovernedAssetReserveFacetAccess, publicFacet: GovernorPublic, instance: Instance }} */
|
|
314
298
|
const g = await E(zoe).startInstance(
|
|
315
299
|
governorInstallation,
|
|
316
300
|
{},
|
|
@@ -332,14 +316,9 @@ export const setupReserve = async ({
|
|
|
332
316
|
E(g.publicFacet).getGovernedContract(),
|
|
333
317
|
]);
|
|
334
318
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
creatorFacet,
|
|
339
|
-
governorCreatorFacet: g.creatorFacet,
|
|
340
|
-
adminFacet: g.adminFacet,
|
|
341
|
-
}),
|
|
342
|
-
);
|
|
319
|
+
reserveGovernorCreatorFacet.resolve(g.creatorFacet);
|
|
320
|
+
reserveCreatorFacet.resolve(creatorFacet);
|
|
321
|
+
reservePublicFacet.resolve(publicFacet);
|
|
343
322
|
|
|
344
323
|
reserveInstanceProducer.resolve(instance);
|
|
345
324
|
reserveGovernor.resolve(g.instance);
|
|
@@ -348,9 +327,9 @@ export const setupReserve = async ({
|
|
|
348
327
|
// time because Reserve requires AMM itself in order to be started.
|
|
349
328
|
// Now that we have the reserve, provide it to the AMM.
|
|
350
329
|
trace('Resolving the reserve public facet on the AMM');
|
|
351
|
-
await E(
|
|
330
|
+
await E(ammCreatorFacet).resolveReserveFacet(publicFacet);
|
|
352
331
|
// it now has the reserve
|
|
353
|
-
ammInstanceProducer.resolve(
|
|
332
|
+
ammInstanceProducer.resolve(ammInstanceWithoutReserve);
|
|
354
333
|
|
|
355
334
|
return reserveInstallation;
|
|
356
335
|
};
|
|
@@ -371,9 +350,9 @@ export const startVaultFactory = async (
|
|
|
371
350
|
zoe,
|
|
372
351
|
feeMintAccess: feeMintAccessP,
|
|
373
352
|
economicCommitteeCreatorFacet: electorateCreatorFacet,
|
|
374
|
-
|
|
353
|
+
reserveCreatorFacet,
|
|
375
354
|
},
|
|
376
|
-
produce
|
|
355
|
+
produce, // { vaultFactoryCreator }
|
|
377
356
|
brand: {
|
|
378
357
|
consume: { [Stable.symbol]: centralBrandP },
|
|
379
358
|
},
|
|
@@ -401,9 +380,8 @@ export const startVaultFactory = async (
|
|
|
401
380
|
trace('startVaultFactory');
|
|
402
381
|
|
|
403
382
|
const poserInvitationP = E(electorateCreatorFacet).getPoserInvitation();
|
|
404
|
-
const shortfallInvitationP =
|
|
405
|
-
E.
|
|
406
|
-
).makeShortfallReportingInvitation();
|
|
383
|
+
const shortfallInvitationP =
|
|
384
|
+
E(reserveCreatorFacet).makeShortfallReportingInvitation();
|
|
407
385
|
const [
|
|
408
386
|
initialPoserInvitation,
|
|
409
387
|
poserInvitationAmount,
|
|
@@ -455,41 +433,37 @@ export const startVaultFactory = async (
|
|
|
455
433
|
}),
|
|
456
434
|
);
|
|
457
435
|
|
|
458
|
-
const {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
},
|
|
475
|
-
}),
|
|
476
|
-
);
|
|
436
|
+
const { creatorFacet: governorCreatorFacet, instance: governorInstance } =
|
|
437
|
+
await E(zoe).startInstance(
|
|
438
|
+
contractGovernorInstallation,
|
|
439
|
+
undefined,
|
|
440
|
+
governorTerms,
|
|
441
|
+
harden({
|
|
442
|
+
electorateCreatorFacet,
|
|
443
|
+
governed: {
|
|
444
|
+
feeMintAccess,
|
|
445
|
+
initialPoserInvitation,
|
|
446
|
+
initialShortfallInvitation,
|
|
447
|
+
marshaller,
|
|
448
|
+
storageNode,
|
|
449
|
+
},
|
|
450
|
+
}),
|
|
451
|
+
);
|
|
477
452
|
|
|
478
|
-
const [vaultFactoryInstance, vaultFactoryCreator
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
E(governorCreatorFacet).getPublicFacet(),
|
|
483
|
-
]);
|
|
453
|
+
const [vaultFactoryInstance, vaultFactoryCreator] = await Promise.all([
|
|
454
|
+
E(governorCreatorFacet).getInstance(),
|
|
455
|
+
E(governorCreatorFacet).getCreatorFacet(),
|
|
456
|
+
]);
|
|
484
457
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
governorCreatorFacet,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
);
|
|
458
|
+
const voteCreator = Far('vaultFactory vote creator', {
|
|
459
|
+
/** @type {VoteOnParamChanges} */
|
|
460
|
+
voteOnParamChanges: (...args) =>
|
|
461
|
+
E(governorCreatorFacet).voteOnParamChanges(...args),
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
produce.vaultFactoryCreator.resolve(vaultFactoryCreator);
|
|
465
|
+
produce.vaultFactoryGovernorCreator.resolve(governorCreatorFacet);
|
|
466
|
+
produce.vaultFactoryVoteCreator.resolve(voteCreator);
|
|
493
467
|
|
|
494
468
|
// Advertise the installations, instances in agoricNames.
|
|
495
469
|
instanceProduce.VaultFactory.resolve(vaultFactoryInstance);
|
|
@@ -507,7 +481,7 @@ export const startVaultFactory = async (
|
|
|
507
481
|
* @param {string} [root0.options.vaultFactoryControllerAddress]
|
|
508
482
|
*/
|
|
509
483
|
export const grantVaultFactoryControl = async (
|
|
510
|
-
{ consume: { client, priceAuthorityAdmin,
|
|
484
|
+
{ consume: { client, priceAuthorityAdmin, vaultFactoryCreator } },
|
|
511
485
|
{ options: { vaultFactoryControllerAddress } = {} } = {},
|
|
512
486
|
) => {
|
|
513
487
|
await E(client).assignBundle([
|
|
@@ -515,7 +489,7 @@ export const grantVaultFactoryControl = async (
|
|
|
515
489
|
vaultFactoryCreatorFacet:
|
|
516
490
|
typeof vaultFactoryControllerAddress === 'string' &&
|
|
517
491
|
addr === vaultFactoryControllerAddress
|
|
518
|
-
?
|
|
492
|
+
? vaultFactoryCreator
|
|
519
493
|
: undefined,
|
|
520
494
|
priceAuthorityAdminFacet:
|
|
521
495
|
typeof vaultFactoryControllerAddress === 'string' &&
|
|
@@ -622,14 +596,17 @@ export const startRewardDistributor = async ({
|
|
|
622
596
|
consume: {
|
|
623
597
|
chainTimerService,
|
|
624
598
|
bankManager,
|
|
625
|
-
|
|
599
|
+
vaultFactoryCreator,
|
|
626
600
|
periodicFeeCollectors,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
601
|
+
ammCreatorFacet,
|
|
602
|
+
stakeFactoryCreatorFacet,
|
|
603
|
+
reservePublicFacet,
|
|
630
604
|
zoe,
|
|
631
605
|
},
|
|
632
|
-
produce: {
|
|
606
|
+
produce: {
|
|
607
|
+
feeDistributorCreatorFacet: feeDistributorCreatorFacetP,
|
|
608
|
+
periodicFeeCollectors: periodicFeeCollectorsP,
|
|
609
|
+
},
|
|
633
610
|
instance: {
|
|
634
611
|
produce: { feeDistributor: feeDistributorP },
|
|
635
612
|
},
|
|
@@ -671,50 +648,43 @@ export const startRewardDistributor = async ({
|
|
|
671
648
|
return undefined;
|
|
672
649
|
});
|
|
673
650
|
|
|
674
|
-
const
|
|
651
|
+
const feeDistributorFacets = await E(zoe).startInstance(
|
|
675
652
|
feeDistributor,
|
|
676
653
|
{ Fee: centralIssuer },
|
|
677
654
|
feeDistributorTerms,
|
|
678
655
|
);
|
|
679
|
-
await E(
|
|
656
|
+
await E(feeDistributorFacets.creatorFacet).setDestinations({
|
|
680
657
|
RewardDistributor:
|
|
681
658
|
rewardDistributorDepositFacet &&
|
|
682
|
-
E(
|
|
659
|
+
E(feeDistributorFacets.creatorFacet).makeDepositFacetDestination(
|
|
683
660
|
rewardDistributorDepositFacet,
|
|
684
661
|
),
|
|
685
|
-
Reserve: E(
|
|
662
|
+
Reserve: E(feeDistributorFacets.creatorFacet).makeOfferDestination(
|
|
686
663
|
'Collateral',
|
|
687
|
-
|
|
664
|
+
reservePublicFacet,
|
|
688
665
|
'makeAddCollateralInvitation',
|
|
689
666
|
),
|
|
690
667
|
});
|
|
691
668
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
creatorFacet: instanceKit.creatorFacet,
|
|
695
|
-
publicFacet: instanceKit.publicFacet,
|
|
696
|
-
adminFacet: instanceKit.adminFacet,
|
|
697
|
-
}),
|
|
698
|
-
);
|
|
699
|
-
feeDistributorP.resolve(instanceKit.instance);
|
|
669
|
+
feeDistributorCreatorFacetP.resolve(feeDistributorFacets.creatorFacet);
|
|
670
|
+
feeDistributorP.resolve(feeDistributorFacets.instance);
|
|
700
671
|
|
|
701
672
|
// Initialize the periodic collectors list if we don't have one.
|
|
702
673
|
periodicFeeCollectorsP.resolve([]);
|
|
703
674
|
const periodicCollectors = await periodicFeeCollectors;
|
|
704
675
|
|
|
705
|
-
const
|
|
706
|
-
vaultFactory:
|
|
707
|
-
amm:
|
|
708
|
-
runStake:
|
|
676
|
+
const collectorFacets = {
|
|
677
|
+
vaultFactory: vaultFactoryCreator,
|
|
678
|
+
amm: ammCreatorFacet,
|
|
679
|
+
runStake: stakeFactoryCreatorFacet,
|
|
709
680
|
};
|
|
710
681
|
await Promise.all(
|
|
711
|
-
Object.entries(
|
|
712
|
-
const collector = E(
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
);
|
|
682
|
+
Object.entries(collectorFacets).map(async ([debugName, collectorFacet]) => {
|
|
683
|
+
const collector = E(
|
|
684
|
+
feeDistributorFacets.creatorFacet,
|
|
685
|
+
).makeContractFeeCollector(zoe, collectorFacet);
|
|
716
686
|
const periodicCollector = await E(
|
|
717
|
-
|
|
687
|
+
feeDistributorFacets.creatorFacet,
|
|
718
688
|
).startPeriodicCollection(debugName, collector);
|
|
719
689
|
periodicCollectors.push(periodicCollector);
|
|
720
690
|
}),
|
|
@@ -776,7 +746,8 @@ export const startStakeFactory = async (
|
|
|
776
746
|
chainStorage,
|
|
777
747
|
economicCommitteeCreatorFacet,
|
|
778
748
|
},
|
|
779
|
-
|
|
749
|
+
// @ts-expect-error TODO: add to BootstrapPowers
|
|
750
|
+
produce: { stakeFactoryCreatorFacet, stakeFactoryGovernorCreatorFacet },
|
|
780
751
|
installation: {
|
|
781
752
|
consume: {
|
|
782
753
|
contractGovernor: contractGovernorInstallation,
|
|
@@ -852,8 +823,8 @@ export const startStakeFactory = async (
|
|
|
852
823
|
}),
|
|
853
824
|
);
|
|
854
825
|
|
|
855
|
-
/** @type {{ publicFacet: GovernorPublic, creatorFacet: GovernedContractFacetAccess<StakeFactoryPublic,StakeFactoryCreator
|
|
856
|
-
const
|
|
826
|
+
/** @type {{ publicFacet: GovernorPublic, creatorFacet: GovernedContractFacetAccess<StakeFactoryPublic,StakeFactoryCreator>}} */
|
|
827
|
+
const governorFacets = await E(zoe).startInstance(
|
|
857
828
|
contractGovernorInstallation,
|
|
858
829
|
{},
|
|
859
830
|
stakeTerms,
|
|
@@ -867,28 +838,16 @@ export const startStakeFactory = async (
|
|
|
867
838
|
},
|
|
868
839
|
},
|
|
869
840
|
);
|
|
870
|
-
|
|
871
|
-
const
|
|
872
|
-
await Promise.all([
|
|
873
|
-
E(governorStartResult.creatorFacet).getInstance(),
|
|
874
|
-
E(governorStartResult.creatorFacet).getCreatorFacet(),
|
|
875
|
-
E(governorStartResult.creatorFacet).getPublicFacet(),
|
|
876
|
-
]);
|
|
841
|
+
const governedInstance = await E(governorFacets.creatorFacet).getInstance();
|
|
842
|
+
const creatorFacet = E(governorFacets.creatorFacet).getCreatorFacet();
|
|
877
843
|
|
|
878
844
|
const {
|
|
879
845
|
issuers: { Attestation: attIssuer },
|
|
880
846
|
brands: { Attestation: attBrand },
|
|
881
847
|
} = await E(zoe).getTerms(governedInstance);
|
|
882
848
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
creatorFacet: governedCreatorFacet,
|
|
886
|
-
governorCreatorFacet: governorStartResult.creatorFacet,
|
|
887
|
-
adminFacet: governorStartResult.adminFacet,
|
|
888
|
-
publicFacet: governedPublicFacet,
|
|
889
|
-
}),
|
|
890
|
-
);
|
|
891
|
-
|
|
849
|
+
stakeFactoryCreatorFacet.resolve(creatorFacet);
|
|
850
|
+
stakeFactoryGovernorCreatorFacet.resolve(governorFacets.creatorFacet);
|
|
892
851
|
stakeFactoryinstanceR.resolve(governedInstance);
|
|
893
852
|
attestationBrandR.resolve(attBrand);
|
|
894
853
|
attestationIssuerR.resolve(attIssuer);
|
|
@@ -896,7 +855,7 @@ export const startStakeFactory = async (
|
|
|
896
855
|
E(client).assignBundle([
|
|
897
856
|
address => ({
|
|
898
857
|
// @ts-expect-error ??? creatorFacet is a StakeFactoryCreator; it has the method
|
|
899
|
-
attMaker: E(
|
|
858
|
+
attMaker: E(creatorFacet).provideAttestationMaker(address),
|
|
900
859
|
}),
|
|
901
860
|
]),
|
|
902
861
|
]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck -- lots of type errors. low prio b/c proposals are like scripts
|
|
2
1
|
import { E } from '@endo/far';
|
|
3
2
|
import { makeIssuerKit } from '@agoric/ertp';
|
|
4
3
|
import {
|
|
@@ -9,35 +8,14 @@ import { deeplyFulfilledObject } from '@agoric/internal';
|
|
|
9
8
|
|
|
10
9
|
import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
|
|
11
10
|
import { reserveThenDeposit, reserveThenGetNames } from './utils.js';
|
|
12
|
-
import { makeTracer } from '../makeTracer.js';
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/** @type {(name: string) => string} */
|
|
12
|
+
/** @type {(name: string) => void} */
|
|
17
13
|
const sanitizePathSegment = name => {
|
|
18
14
|
const candidate = name.replace(/ /g, '_');
|
|
19
15
|
assertPathSegment(candidate);
|
|
20
16
|
return candidate;
|
|
21
17
|
};
|
|
22
18
|
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {{
|
|
25
|
-
* brandIn?: ERef<Brand<'nat'> | undefined>,
|
|
26
|
-
* brandOut?: ERef<Brand<'nat'> | undefined>,
|
|
27
|
-
* IN_BRAND_NAME: string,
|
|
28
|
-
* IN_BRAND_DECIMALS: string,
|
|
29
|
-
* OUT_BRAND_NAME: string,
|
|
30
|
-
* OUT_BRAND_DECIMALS: string,
|
|
31
|
-
* }} PriceFeedOptions
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Create inert brands (no mint or issuer) referred to by price oracles.
|
|
36
|
-
*
|
|
37
|
-
* @param {ChainBootstrapSpace} space
|
|
38
|
-
* @param {{options: {priceFeedOptions: PriceFeedOptions}}} opt
|
|
39
|
-
* @returns {Promise<[Brand<'nat'>, Brand<'nat'>]>}
|
|
40
|
-
*/
|
|
41
19
|
export const ensureOracleBrands = async (
|
|
42
20
|
{ consume: { agoricNamesAdmin } },
|
|
43
21
|
{
|
|
@@ -53,11 +31,9 @@ export const ensureOracleBrands = async (
|
|
|
53
31
|
},
|
|
54
32
|
},
|
|
55
33
|
) => {
|
|
56
|
-
|
|
57
|
-
/** @type {Promise<import('@agoric/vats').NameAdmin>} */
|
|
34
|
+
/** @type {NameAdmin} */
|
|
58
35
|
const obAdmin = E(agoricNamesAdmin).lookupAdmin('oracleBrand');
|
|
59
36
|
|
|
60
|
-
/** @type {(brand: ERef<Brand<'nat'> | undefined>, name: string, decimals: string) => Promise<Brand<'nat'>>} */
|
|
61
37
|
const updateFreshBrand = async (brand, name, decimals) => {
|
|
62
38
|
const b = await brand;
|
|
63
39
|
if (b) {
|
|
@@ -87,7 +63,7 @@ export const ensureOracleBrands = async (
|
|
|
87
63
|
|
|
88
64
|
/**
|
|
89
65
|
* @param {ChainBootstrapSpace} powers
|
|
90
|
-
* @param {{options: {priceFeedOptions: {AGORIC_INSTANCE_NAME: string, oracleAddresses:
|
|
66
|
+
* @param {{options: {priceFeedOptions: {AGORIC_INSTANCE_NAME: string, oracleAddresses: UNKNOWN, contractTerms: unknown, IN_BRAND_NAME: string, OUT_BRAND_NAME: string}}}} config
|
|
91
67
|
*/
|
|
92
68
|
export const createPriceFeed = async (
|
|
93
69
|
{
|
|
@@ -117,7 +93,6 @@ export const createPriceFeed = async (
|
|
|
117
93
|
},
|
|
118
94
|
},
|
|
119
95
|
) => {
|
|
120
|
-
trace('createPriceFeed');
|
|
121
96
|
const STORAGE_PATH = 'priceFeed';
|
|
122
97
|
|
|
123
98
|
// Default to an empty Map and home.priceAuthority.
|
|
@@ -129,7 +104,7 @@ export const createPriceFeed = async (
|
|
|
129
104
|
/**
|
|
130
105
|
* Values come from economy-template.json, which at this writing had IN:ATOM, OUT:USD
|
|
131
106
|
*
|
|
132
|
-
* @type {[[Brand
|
|
107
|
+
* @type {[[Brand, Brand], [Installation<import('@agoric/zoe/src/contracts/priceAggregator.js').start>]]}
|
|
133
108
|
*/
|
|
134
109
|
const [[brandIn, brandOut], [priceAggregator]] = await Promise.all([
|
|
135
110
|
reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [
|
|
@@ -153,6 +128,7 @@ export const createPriceFeed = async (
|
|
|
153
128
|
unitAmountIn,
|
|
154
129
|
}),
|
|
155
130
|
);
|
|
131
|
+
terms.absent;
|
|
156
132
|
|
|
157
133
|
const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
158
134
|
const marshaller = E(board).getReadonlyMarshaller();
|
|
@@ -204,19 +180,11 @@ export const createPriceFeed = async (
|
|
|
204
180
|
);
|
|
205
181
|
};
|
|
206
182
|
|
|
207
|
-
trace('distributing invitations', oracleAddresses);
|
|
208
183
|
await Promise.all(oracleAddresses.map(distributeInvitation));
|
|
209
|
-
trace('createPriceFeed complete');
|
|
210
184
|
};
|
|
211
185
|
|
|
186
|
+
// Return the manifest, installations, and options.
|
|
212
187
|
const t = 'priceFeed';
|
|
213
|
-
/**
|
|
214
|
-
* Add a price feed to a running chain, returning the manifest, installations, and options.
|
|
215
|
-
*
|
|
216
|
-
* @param {object} utils
|
|
217
|
-
* @param {(ref: unknown) => Promise<unknown>} [utils.restoreRef]
|
|
218
|
-
* @param {PriceFeedOptions} priceFeedOptions
|
|
219
|
-
*/
|
|
220
188
|
export const getManifestForPriceFeed = async (
|
|
221
189
|
{ restoreRef },
|
|
222
190
|
priceFeedOptions,
|
|
@@ -257,83 +225,3 @@ export const getManifestForPriceFeed = async (
|
|
|
257
225
|
},
|
|
258
226
|
},
|
|
259
227
|
});
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
263
|
-
* @param {object} [config]
|
|
264
|
-
* @param {object} [config.options]
|
|
265
|
-
* @param {string[]} [config.options.demoOracleAddresses]
|
|
266
|
-
*/
|
|
267
|
-
export const startPriceFeeds = async (
|
|
268
|
-
{
|
|
269
|
-
consume,
|
|
270
|
-
produce,
|
|
271
|
-
installation: {
|
|
272
|
-
consume: { priceAggregator },
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
{ options: { demoOracleAddresses = [] } = {} },
|
|
276
|
-
) => {
|
|
277
|
-
trace('startPriceFeeds');
|
|
278
|
-
|
|
279
|
-
// eventually this will have be parameterized. for now we just need one contract
|
|
280
|
-
// working well enough to build tooling around.
|
|
281
|
-
const inBrandName = 'ATOM';
|
|
282
|
-
const outBrandName = 'USD';
|
|
283
|
-
|
|
284
|
-
/** @type {ERef<NameAdmin>} */
|
|
285
|
-
const installAdmin = E(consume.agoricNamesAdmin).lookupAdmin('installation');
|
|
286
|
-
await E(installAdmin).update('priceAggregator', priceAggregator);
|
|
287
|
-
|
|
288
|
-
await ensureOracleBrands(
|
|
289
|
-
{ consume },
|
|
290
|
-
{
|
|
291
|
-
options: {
|
|
292
|
-
priceFeedOptions: {
|
|
293
|
-
IN_BRAND_NAME: inBrandName,
|
|
294
|
-
IN_BRAND_DECIMALS: '6',
|
|
295
|
-
OUT_BRAND_NAME: outBrandName,
|
|
296
|
-
OUT_BRAND_DECIMALS: '6',
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
await createPriceFeed(
|
|
303
|
-
{ consume, produce },
|
|
304
|
-
{
|
|
305
|
-
options: {
|
|
306
|
-
priceFeedOptions: {
|
|
307
|
-
AGORIC_INSTANCE_NAME: `${inBrandName}-${outBrandName} price feed`,
|
|
308
|
-
contractTerms: {
|
|
309
|
-
POLL_INTERVAL: 1n,
|
|
310
|
-
},
|
|
311
|
-
oracleAddresses: demoOracleAddresses,
|
|
312
|
-
IN_BRAND_NAME: inBrandName,
|
|
313
|
-
OUT_BRAND_NAME: outBrandName,
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
);
|
|
318
|
-
trace('startPriceFeeds complete');
|
|
319
|
-
};
|
|
320
|
-
harden(startPriceFeeds);
|
|
321
|
-
|
|
322
|
-
export const PRICE_FEEDS_MANIFEST = harden({
|
|
323
|
-
[startPriceFeeds.name]: {
|
|
324
|
-
consume: {
|
|
325
|
-
agoricNamesAdmin: true,
|
|
326
|
-
aggregators: true,
|
|
327
|
-
board: true,
|
|
328
|
-
chainStorage: true,
|
|
329
|
-
chainTimerService: true,
|
|
330
|
-
client: true,
|
|
331
|
-
namesByAddressAdmin: true,
|
|
332
|
-
priceAuthority: true,
|
|
333
|
-
priceAuthorityAdmin: true,
|
|
334
|
-
zoe: true,
|
|
335
|
-
},
|
|
336
|
-
produce: { aggregators: true },
|
|
337
|
-
installation: { consume: { priceAggregator: true } },
|
|
338
|
-
},
|
|
339
|
-
});
|