@agoric/inter-protocol 0.13.2-dev-606cbd2.0 → 0.13.2-dev-8d17cce.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-auctioneer-js-meta.json +123 -119
- package/bundles/bundle-auctioneer.js +1 -1
- package/bundles/bundle-econCommitteeCharter-js-meta.json +71 -71
- package/bundles/bundle-econCommitteeCharter.js +1 -1
- package/bundles/bundle-feeDistributor-js-meta.json +59 -59
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +143 -139
- package/bundles/bundle-fluxAggregatorKit.js +1 -1
- package/bundles/bundle-psm-js-meta.json +136 -132
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-js-meta.json +115 -111
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +125 -121
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-vaultFactory-js-meta.json +188 -184
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +17 -17
- package/scripts/add-collateral-core.js +2 -0
- package/scripts/init-core.js +1 -0
- package/scripts/invite-committee-core.js +1 -0
- package/scripts/price-feed-core.js +1 -0
- package/src/auction/auctionBook.js +11 -11
- package/src/auction/auctioneer.js +15 -11
- package/src/auction/params.js +4 -4
- package/src/auction/scheduleMath.js +77 -32
- package/src/auction/scheduler.js +191 -79
- package/src/auction/util.js +7 -0
- package/src/clientSupport.js +1 -2
- package/src/price/fluxAggregatorContract.js +29 -6
- package/src/proposals/addAssetToVault.js +6 -34
- package/src/proposals/committee-proposal.js +9 -9
- package/src/proposals/core-proposal.js +58 -1
- package/src/proposals/econ-behaviors.js +56 -45
- package/src/proposals/price-feed-proposal.js +9 -21
- package/src/proposals/startEconCommittee.js +14 -6
- package/src/proposals/startPSM.js +51 -34
- package/src/psm/psm.js +11 -6
- package/src/reserve/assetReserveKit.js +1 -1
- package/src/vaultFactory/liquidation.js +168 -33
- package/src/vaultFactory/vault.js +5 -4
- package/src/vaultFactory/vaultDirector.js +27 -17
- package/src/vaultFactory/vaultFactory.js +26 -11
- package/src/vaultFactory/vaultManager.js +139 -95
|
@@ -10,6 +10,48 @@ export * from './econ-behaviors.js';
|
|
|
10
10
|
export * from './startPSM.js'; // eslint-disable-line import/export
|
|
11
11
|
export * from './startEconCommittee.js'; // eslint-disable-line import/export
|
|
12
12
|
|
|
13
|
+
// XXX all the startInstance() should use startUpgradable()
|
|
14
|
+
// or startGovernedUpgradeable() but that would
|
|
15
|
+
// require updating a lot of tests. So for now, we just
|
|
16
|
+
// grab the kits afterward and store them.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
|
|
20
|
+
*/
|
|
21
|
+
export const storeInterContractStartKits = async ({
|
|
22
|
+
consume: {
|
|
23
|
+
contractKits,
|
|
24
|
+
governedContractKits,
|
|
25
|
+
econCharterKit,
|
|
26
|
+
economicCommitteeKit,
|
|
27
|
+
feeDistributorKit,
|
|
28
|
+
auctioneerKit,
|
|
29
|
+
reserveKit,
|
|
30
|
+
vaultFactoryKit,
|
|
31
|
+
},
|
|
32
|
+
}) => {
|
|
33
|
+
/**
|
|
34
|
+
* @param {Promise<MapStore<string, {instance: Instance}>>} storeP
|
|
35
|
+
* @param {Promise<{instance: Instance}>[]} kitPs
|
|
36
|
+
*/
|
|
37
|
+
const storeAll = async (storeP, kitPs) => {
|
|
38
|
+
const store = await storeP;
|
|
39
|
+
const kits = await Promise.all(kitPs);
|
|
40
|
+
kits.forEach(kit => store.init(kit.instance, kit));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
await storeAll(contractKits, [
|
|
44
|
+
economicCommitteeKit,
|
|
45
|
+
econCharterKit,
|
|
46
|
+
feeDistributorKit,
|
|
47
|
+
]);
|
|
48
|
+
await storeAll(governedContractKits, [
|
|
49
|
+
auctioneerKit,
|
|
50
|
+
reserveKit,
|
|
51
|
+
vaultFactoryKit,
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
|
|
13
55
|
/** @type {import('@agoric/vats/src/core/lib-boot.js').BootstrapManifest} */
|
|
14
56
|
const SHARED_MAIN_MANIFEST = harden({
|
|
15
57
|
/** @type {import('@agoric/vats/src/core/lib-boot.js').BootstrapManifestPermit} */
|
|
@@ -17,6 +59,7 @@ const SHARED_MAIN_MANIFEST = harden({
|
|
|
17
59
|
consume: {
|
|
18
60
|
board: 'board',
|
|
19
61
|
chainStorage: true,
|
|
62
|
+
diagnostics: true,
|
|
20
63
|
feeMintAccess: 'zoe',
|
|
21
64
|
chainTimerService: 'timer',
|
|
22
65
|
zoe: 'zoe',
|
|
@@ -41,7 +84,6 @@ const SHARED_MAIN_MANIFEST = harden({
|
|
|
41
84
|
},
|
|
42
85
|
produce: {
|
|
43
86
|
VaultFactory: 'VaultFactory',
|
|
44
|
-
Treasury: 'VaultFactory',
|
|
45
87
|
VaultFactoryGovernor: 'VaultFactoryGovernor',
|
|
46
88
|
},
|
|
47
89
|
},
|
|
@@ -58,6 +100,7 @@ const SHARED_MAIN_MANIFEST = harden({
|
|
|
58
100
|
consume: {
|
|
59
101
|
board: 'board',
|
|
60
102
|
chainStorage: true,
|
|
103
|
+
diagnostics: true,
|
|
61
104
|
feeMintAccess: 'zoe',
|
|
62
105
|
chainTimerService: 'timer',
|
|
63
106
|
zoe: 'zoe',
|
|
@@ -98,12 +141,26 @@ const SHARED_MAIN_MANIFEST = harden({
|
|
|
98
141
|
consume: { [Stable.symbol]: 'zoe' },
|
|
99
142
|
},
|
|
100
143
|
},
|
|
144
|
+
|
|
145
|
+
[storeInterContractStartKits.name]: {
|
|
146
|
+
consume: {
|
|
147
|
+
contractKits: true,
|
|
148
|
+
governedContractKits: true,
|
|
149
|
+
econCharterKit: true,
|
|
150
|
+
economicCommitteeKit: true,
|
|
151
|
+
feeDistributorKit: true,
|
|
152
|
+
auctioneerKit: true,
|
|
153
|
+
reserveKit: true,
|
|
154
|
+
vaultFactoryKit: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
101
157
|
});
|
|
102
158
|
|
|
103
159
|
const REWARD_MANIFEST = harden({
|
|
104
160
|
[econBehaviors.startRewardDistributor.name]: {
|
|
105
161
|
consume: {
|
|
106
162
|
chainTimerService: true,
|
|
163
|
+
diagnostics: true,
|
|
107
164
|
bankManager: true,
|
|
108
165
|
vaultFactoryKit: true,
|
|
109
166
|
periodicFeeCollectors: true,
|
|
@@ -10,14 +10,15 @@ import '@agoric/vats/exported.js';
|
|
|
10
10
|
import '@agoric/vats/src/core/types.js';
|
|
11
11
|
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
12
12
|
import { E } from '@endo/far';
|
|
13
|
+
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
13
14
|
import { makeGovernedTerms as makeGovernedATerms } from '../auction/params.js';
|
|
14
15
|
import { makeReserveTerms } from '../reserve/params.js';
|
|
15
16
|
import { makeGovernedTerms as makeGovernedVFTerms } from '../vaultFactory/params.js';
|
|
16
17
|
|
|
17
18
|
const trace = makeTracer('RunEconBehaviors', false);
|
|
18
19
|
|
|
19
|
-
const SECONDS_PER_HOUR = 60n * 60n;
|
|
20
|
-
const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
20
|
+
export const SECONDS_PER_HOUR = 60n * 60n;
|
|
21
|
+
export const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* @typedef {import('../vaultFactory/vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
|
|
@@ -27,6 +28,7 @@ const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* @typedef {object} PSMKit
|
|
31
|
+
* @property {string} label
|
|
30
32
|
* @property {Instance} psm
|
|
31
33
|
* @property {Instance} psmGovernor
|
|
32
34
|
* @property {Awaited<ReturnType<Awaited<ReturnType<import('../psm/psm.js')['prepare']>>['creatorFacet']['getLimitedCreatorFacet']>>} psmCreatorFacet
|
|
@@ -44,14 +46,8 @@ const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
|
|
|
44
46
|
* @typedef {PromiseSpaceOf<{
|
|
45
47
|
* economicCommitteeKit: CommitteeStartResult,
|
|
46
48
|
* economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet,
|
|
47
|
-
* feeDistributorKit:
|
|
48
|
-
*
|
|
49
|
-
* publicFacet: import('../feeDistributor.js').FeeDistributorPublicFacet,
|
|
50
|
-
* adminFacet: AdminFacet,
|
|
51
|
-
* },
|
|
52
|
-
* periodicFeeCollectors: import('../feeDistributor.js').PeriodicFeeCollector[],
|
|
53
|
-
* bankMints: Mint[],
|
|
54
|
-
* vBankKits: import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<any>[],
|
|
49
|
+
* feeDistributorKit: StartedInstanceKit<typeof import('../feeDistributor.js').start>,
|
|
50
|
+
* periodicFeeCollectors: MapStore<number, import('../feeDistributor.js').PeriodicFeeCollector>,
|
|
55
51
|
* psmKit: MapStore<Brand, PSMKit>,
|
|
56
52
|
* anchorBalancePayments: MapStore<Brand, Payment<'nat'>>,
|
|
57
53
|
* econCharterKit: EconCharterStartResult,
|
|
@@ -81,6 +77,7 @@ export const setupReserve = async ({
|
|
|
81
77
|
feeMintAccess: feeMintAccessP,
|
|
82
78
|
chainStorage,
|
|
83
79
|
chainTimerService,
|
|
80
|
+
diagnostics,
|
|
84
81
|
zoe,
|
|
85
82
|
economicCommitteeCreatorFacet: committeeCreator,
|
|
86
83
|
},
|
|
@@ -125,19 +122,20 @@ export const setupReserve = async ({
|
|
|
125
122
|
},
|
|
126
123
|
}),
|
|
127
124
|
);
|
|
125
|
+
const privateArgs = {
|
|
126
|
+
governed: {
|
|
127
|
+
feeMintAccess,
|
|
128
|
+
initialPoserInvitation: poserInvitation,
|
|
129
|
+
marshaller,
|
|
130
|
+
storageNode,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
128
133
|
/** @type {GovernorStartedInstallationKit<typeof reserveInstallation>} */
|
|
129
134
|
const g = await E(zoe).startInstance(
|
|
130
135
|
governorInstallation,
|
|
131
136
|
{},
|
|
132
137
|
reserveGovernorTerms,
|
|
133
|
-
|
|
134
|
-
governed: {
|
|
135
|
-
feeMintAccess,
|
|
136
|
-
initialPoserInvitation: poserInvitation,
|
|
137
|
-
marshaller,
|
|
138
|
-
storageNode,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
138
|
+
privateArgs,
|
|
141
139
|
'reserve.governor',
|
|
142
140
|
);
|
|
143
141
|
|
|
@@ -149,14 +147,19 @@ export const setupReserve = async ({
|
|
|
149
147
|
|
|
150
148
|
reserveKit.resolve(
|
|
151
149
|
harden({
|
|
150
|
+
label: 'AssetReserve',
|
|
152
151
|
instance,
|
|
153
|
-
governor: g.instance,
|
|
154
152
|
publicFacet,
|
|
155
153
|
creatorFacet,
|
|
156
|
-
governorCreatorFacet: g.creatorFacet,
|
|
157
154
|
adminFacet: g.adminFacet,
|
|
155
|
+
|
|
156
|
+
governor: g.instance,
|
|
157
|
+
governorCreatorFacet: g.creatorFacet,
|
|
158
|
+
governorAdminFacet: g.adminFacet,
|
|
158
159
|
}),
|
|
159
160
|
);
|
|
161
|
+
await E(diagnostics).savePrivateArgs(instance, privateArgs.governed);
|
|
162
|
+
await E(diagnostics).savePrivateArgs(g.instance, privateArgs);
|
|
160
163
|
|
|
161
164
|
reserveInstanceProducer.resolve(instance);
|
|
162
165
|
reserveGovernor.resolve(g.instance);
|
|
@@ -297,11 +300,7 @@ export const startVaultFactory = async (
|
|
|
297
300
|
);
|
|
298
301
|
|
|
299
302
|
/** @type {GovernorStartedInstallationKit<typeof vaultFactoryInstallation>} */
|
|
300
|
-
const
|
|
301
|
-
creatorFacet: governorCreatorFacet,
|
|
302
|
-
instance: governorInstance,
|
|
303
|
-
adminFacet,
|
|
304
|
-
} = await E(consume.zoe).startInstance(
|
|
303
|
+
const g = await E(consume.zoe).startInstance(
|
|
305
304
|
contractGovernorInstallation,
|
|
306
305
|
undefined,
|
|
307
306
|
governorTerms,
|
|
@@ -312,29 +311,40 @@ export const startVaultFactory = async (
|
|
|
312
311
|
'vaultFactory.governor',
|
|
313
312
|
);
|
|
314
313
|
|
|
315
|
-
const [vaultFactoryInstance, vaultFactoryCreator, publicFacet] =
|
|
314
|
+
const [vaultFactoryInstance, vaultFactoryCreator, publicFacet, adminFacet] =
|
|
316
315
|
await Promise.all([
|
|
317
|
-
E(
|
|
318
|
-
E(
|
|
319
|
-
E(
|
|
316
|
+
E(g.creatorFacet).getInstance(),
|
|
317
|
+
E(g.creatorFacet).getCreatorFacet(),
|
|
318
|
+
E(g.creatorFacet).getPublicFacet(),
|
|
319
|
+
E(g.creatorFacet).getAdminFacet(),
|
|
320
320
|
]);
|
|
321
321
|
|
|
322
|
+
// XXX omitting the governor
|
|
323
|
+
await E(consume.diagnostics).savePrivateArgs(
|
|
324
|
+
vaultFactoryInstance,
|
|
325
|
+
vaultFactoryPrivateArgs,
|
|
326
|
+
);
|
|
327
|
+
|
|
322
328
|
vaultFactoryKit.resolve(
|
|
323
329
|
harden({
|
|
330
|
+
label: 'VaultFactory',
|
|
324
331
|
creatorFacet: vaultFactoryCreator,
|
|
325
|
-
governorCreatorFacet,
|
|
326
332
|
adminFacet,
|
|
327
333
|
publicFacet,
|
|
328
|
-
governor: governorInstance,
|
|
329
334
|
instance: vaultFactoryInstance,
|
|
335
|
+
|
|
336
|
+
governor: g.instance,
|
|
337
|
+
governorAdminFacet: g.adminFacet,
|
|
338
|
+
governorCreatorFacet: g.creatorFacet,
|
|
339
|
+
|
|
340
|
+
// XXX try refactoring to use savePrivateArgs
|
|
330
341
|
privateArgs: vaultFactoryPrivateArgs,
|
|
331
342
|
}),
|
|
332
343
|
);
|
|
333
344
|
|
|
334
345
|
// Advertise the installations, instances in agoricNames.
|
|
335
346
|
instanceProduce.VaultFactory.resolve(vaultFactoryInstance);
|
|
336
|
-
instanceProduce.
|
|
337
|
-
instanceProduce.VaultFactoryGovernor.resolve(governorInstance);
|
|
347
|
+
instanceProduce.VaultFactoryGovernor.resolve(g.instance);
|
|
338
348
|
};
|
|
339
349
|
|
|
340
350
|
/**
|
|
@@ -452,16 +462,14 @@ export const startRewardDistributor = async ({
|
|
|
452
462
|
});
|
|
453
463
|
|
|
454
464
|
feeDistributorKit.resolve(
|
|
455
|
-
harden({
|
|
456
|
-
creatorFacet: instanceKit.creatorFacet,
|
|
457
|
-
publicFacet: instanceKit.publicFacet,
|
|
458
|
-
adminFacet: instanceKit.adminFacet,
|
|
459
|
-
}),
|
|
465
|
+
harden({ ...instanceKit, label: 'feeDistributor' }),
|
|
460
466
|
);
|
|
461
467
|
feeDistributorP.resolve(instanceKit.instance);
|
|
462
468
|
|
|
463
469
|
// Initialize the periodic collectors list if we don't have one.
|
|
464
|
-
periodicFeeCollectorsP.resolve(
|
|
470
|
+
periodicFeeCollectorsP.resolve(
|
|
471
|
+
makeScalarBigMapStore('periodicCollectors', { durable: true }),
|
|
472
|
+
);
|
|
465
473
|
const periodicCollectors = await periodicFeeCollectors;
|
|
466
474
|
|
|
467
475
|
const collectorKit = {
|
|
@@ -476,7 +484,7 @@ export const startRewardDistributor = async ({
|
|
|
476
484
|
const periodicCollector = await E(
|
|
477
485
|
instanceKit.creatorFacet,
|
|
478
486
|
).startPeriodicCollection(debugName, collector);
|
|
479
|
-
periodicCollectors.
|
|
487
|
+
periodicCollectors.init(periodicCollectors.getSize(), periodicCollector);
|
|
480
488
|
}),
|
|
481
489
|
);
|
|
482
490
|
};
|
|
@@ -514,13 +522,13 @@ export const startAuctioneer = async (
|
|
|
514
522
|
},
|
|
515
523
|
{
|
|
516
524
|
auctionParams = {
|
|
517
|
-
|
|
525
|
+
StartFrequency: 3600n,
|
|
518
526
|
ClockStep: 3n * 60n,
|
|
519
527
|
StartingRate: 10500n,
|
|
520
|
-
LowestRate:
|
|
528
|
+
LowestRate: 6500n,
|
|
521
529
|
DiscountStep: 500n,
|
|
522
530
|
AuctionStartDelay: 2n,
|
|
523
|
-
PriceLockPeriod:
|
|
531
|
+
PriceLockPeriod: 30n * 60n, // half an hour
|
|
524
532
|
},
|
|
525
533
|
} = {},
|
|
526
534
|
) => {
|
|
@@ -594,12 +602,15 @@ export const startAuctioneer = async (
|
|
|
594
602
|
|
|
595
603
|
auctioneerKit.resolve(
|
|
596
604
|
harden({
|
|
605
|
+
label: 'auctioneer',
|
|
597
606
|
creatorFacet: governedCreatorFacet,
|
|
598
|
-
governorCreatorFacet: governorStartResult.creatorFacet,
|
|
599
607
|
adminFacet: governorStartResult.adminFacet,
|
|
600
608
|
publicFacet: governedPublicFacet,
|
|
601
|
-
governor: governorStartResult.instance,
|
|
602
609
|
instance: governedInstance,
|
|
610
|
+
|
|
611
|
+
governor: governorStartResult.instance,
|
|
612
|
+
governorCreatorFacet: governorStartResult.creatorFacet,
|
|
613
|
+
governorAdminFacet: governorStartResult.adminFacet,
|
|
603
614
|
}),
|
|
604
615
|
);
|
|
605
616
|
|
|
@@ -94,10 +94,8 @@ export const createPriceFeed = async (
|
|
|
94
94
|
namesByAddressAdmin,
|
|
95
95
|
priceAuthority,
|
|
96
96
|
priceAuthorityAdmin,
|
|
97
|
-
startGovernedUpgradable
|
|
98
|
-
fluxAggregatorKits,
|
|
97
|
+
startGovernedUpgradable,
|
|
99
98
|
},
|
|
100
|
-
produce: { fluxAggregatorKits: produceFluxAggregatorKits },
|
|
101
99
|
},
|
|
102
100
|
{
|
|
103
101
|
options: {
|
|
@@ -147,16 +145,13 @@ export const createPriceFeed = async (
|
|
|
147
145
|
const label = sanitizePathSegment(AGORIC_INSTANCE_NAME);
|
|
148
146
|
|
|
149
147
|
const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
|
|
150
|
-
const marshaller = E(board).getReadonlyMarshaller();
|
|
148
|
+
const marshaller = await E(board).getReadonlyMarshaller();
|
|
151
149
|
|
|
152
150
|
trace('awaiting startInstance');
|
|
153
|
-
|
|
154
|
-
const startGovernedUpgradable = await startGovernedUpgradableP;
|
|
155
|
-
produceFluxAggregatorKits.resolve([]);
|
|
156
|
-
const faKit = await startGovernedUpgradable({
|
|
151
|
+
const faKit = await E(startGovernedUpgradable)({
|
|
157
152
|
governedParams: {},
|
|
158
153
|
privateArgs: {
|
|
159
|
-
highPrioritySendersManager,
|
|
154
|
+
highPrioritySendersManager: await highPrioritySendersManager,
|
|
160
155
|
marshaller,
|
|
161
156
|
namesByAddressAdmin,
|
|
162
157
|
storageNode: await E(storageNode).makeChildNode(label),
|
|
@@ -164,16 +159,13 @@ export const createPriceFeed = async (
|
|
|
164
159
|
terms,
|
|
165
160
|
label,
|
|
166
161
|
installation: priceAggregator,
|
|
167
|
-
produceResults: {
|
|
168
|
-
resolve: kit =>
|
|
169
|
-
Promise.resolve(fluxAggregatorKits).then(kits => kits.push(kit)),
|
|
170
|
-
},
|
|
171
162
|
});
|
|
172
163
|
|
|
173
|
-
E(E(agoricNamesAdmin).lookupAdmin('instance'))
|
|
174
|
-
AGORIC_INSTANCE_NAME,
|
|
175
|
-
|
|
176
|
-
|
|
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
|
+
);
|
|
177
169
|
|
|
178
170
|
E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
179
171
|
faKit.instance,
|
|
@@ -239,10 +231,6 @@ export const getManifestForPriceFeed = async (
|
|
|
239
231
|
priceAuthority: t,
|
|
240
232
|
priceAuthorityAdmin: t,
|
|
241
233
|
startGovernedUpgradable: t,
|
|
242
|
-
fluxAggregatorKits: t,
|
|
243
|
-
},
|
|
244
|
-
produce: {
|
|
245
|
-
fluxAggregatorKits: t,
|
|
246
234
|
},
|
|
247
235
|
},
|
|
248
236
|
[ensureOracleBrands.name]: {
|
|
@@ -28,7 +28,7 @@ const sanitizePathSegment = name => {
|
|
|
28
28
|
*/
|
|
29
29
|
export const startEconomicCommittee = async (
|
|
30
30
|
{
|
|
31
|
-
consume: { board, chainStorage, zoe },
|
|
31
|
+
consume: { board, chainStorage, diagnostics, zoe },
|
|
32
32
|
produce: { economicCommitteeKit, economicCommitteeCreatorFacet },
|
|
33
33
|
installation: {
|
|
34
34
|
consume: { committee },
|
|
@@ -59,19 +59,26 @@ export const startEconomicCommittee = async (
|
|
|
59
59
|
// NB: committee must only publish what it intended to be public
|
|
60
60
|
const marshaller = await E(board).getPublishingMarshaller();
|
|
61
61
|
|
|
62
|
+
const privateArgs = {
|
|
63
|
+
storageNode,
|
|
64
|
+
marshaller,
|
|
65
|
+
};
|
|
62
66
|
const startResult = await E(zoe).startInstance(
|
|
63
67
|
committee,
|
|
64
68
|
{},
|
|
65
69
|
{ committeeName, committeeSize, ...rest },
|
|
66
|
-
|
|
67
|
-
storageNode,
|
|
68
|
-
marshaller,
|
|
69
|
-
},
|
|
70
|
+
privateArgs,
|
|
70
71
|
'economicCommittee',
|
|
71
72
|
);
|
|
72
73
|
const { creatorFacet, instance } = startResult;
|
|
73
74
|
|
|
74
|
-
economicCommitteeKit.resolve(
|
|
75
|
+
economicCommitteeKit.resolve(
|
|
76
|
+
// XXX should startInstance return its label?
|
|
77
|
+
harden({ ...startResult, label: 'economicCommittee' }),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
await E(diagnostics).savePrivateArgs(startResult.instance, privateArgs);
|
|
81
|
+
|
|
75
82
|
economicCommitteeCreatorFacet.resolve(creatorFacet);
|
|
76
83
|
economicCommittee.resolve(instance);
|
|
77
84
|
};
|
|
@@ -82,6 +89,7 @@ export const ECON_COMMITTEE_MANIFEST = harden({
|
|
|
82
89
|
consume: {
|
|
83
90
|
board: true,
|
|
84
91
|
chainStorage: true,
|
|
92
|
+
diagnostics: true,
|
|
85
93
|
zoe: true,
|
|
86
94
|
},
|
|
87
95
|
produce: {
|
|
@@ -7,9 +7,13 @@ import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
|
7
7
|
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
8
8
|
import { E } from '@endo/far';
|
|
9
9
|
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
makeHistoryReviver,
|
|
12
|
+
makeBoardRemote,
|
|
13
|
+
slotToBoardRemote,
|
|
14
|
+
} from '@agoric/vats/tools/board-utils.js';
|
|
11
15
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
12
|
-
import {
|
|
16
|
+
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
13
17
|
|
|
14
18
|
import { reserveThenGetNamePaths } from './utils.js';
|
|
15
19
|
|
|
@@ -39,7 +43,10 @@ const stablePsmKey = `published.psm.${Stable.symbol}`;
|
|
|
39
43
|
const findOldPSMState = (chainStorageEntries, keyword, brands) => {
|
|
40
44
|
// In this reviver, object references are revived as boardIDs
|
|
41
45
|
// from the pre-bulldozer board.
|
|
42
|
-
const toSlotReviver = makeHistoryReviver(
|
|
46
|
+
const toSlotReviver = makeHistoryReviver(
|
|
47
|
+
chainStorageEntries,
|
|
48
|
+
slotToBoardRemote,
|
|
49
|
+
);
|
|
43
50
|
if (!toSlotReviver.has(`${stablePsmKey}.${keyword}.metrics`)) {
|
|
44
51
|
return {};
|
|
45
52
|
}
|
|
@@ -47,12 +54,19 @@ const findOldPSMState = (chainStorageEntries, keyword, brands) => {
|
|
|
47
54
|
`${stablePsmKey}.${keyword}.metrics`,
|
|
48
55
|
);
|
|
49
56
|
const oldIDtoNewBrand = makeMap([
|
|
50
|
-
[metricsWithOldBoardIDs.feePoolBalance.brand, brands.minted],
|
|
51
|
-
[
|
|
57
|
+
[metricsWithOldBoardIDs.feePoolBalance.brand.getBoardId(), brands.minted],
|
|
58
|
+
[
|
|
59
|
+
metricsWithOldBoardIDs.anchorPoolBalance.brand.getBoardId(),
|
|
60
|
+
brands.anchor,
|
|
61
|
+
],
|
|
52
62
|
]);
|
|
53
|
-
// revive brands; other object references map to
|
|
54
|
-
const brandReviver = makeHistoryReviver(
|
|
55
|
-
|
|
63
|
+
// revive brands; other object references map to dummy remotables
|
|
64
|
+
const brandReviver = makeHistoryReviver(
|
|
65
|
+
chainStorageEntries,
|
|
66
|
+
(slotID, iface) => {
|
|
67
|
+
const newBrand = oldIDtoNewBrand.get(slotID);
|
|
68
|
+
return newBrand || makeBoardRemote({ boardId: slotID, iface });
|
|
69
|
+
},
|
|
56
70
|
);
|
|
57
71
|
return {
|
|
58
72
|
metrics: brandReviver.getItem(`${stablePsmKey}.${keyword}.metrics`),
|
|
@@ -74,6 +88,7 @@ export const startPSM = async (
|
|
|
74
88
|
consume: {
|
|
75
89
|
agoricNamesAdmin,
|
|
76
90
|
board,
|
|
91
|
+
diagnostics,
|
|
77
92
|
zoe,
|
|
78
93
|
feeMintAccess: feeMintAccessP,
|
|
79
94
|
economicCommitteeCreatorFacet,
|
|
@@ -189,6 +204,12 @@ export const startPSM = async (
|
|
|
189
204
|
},
|
|
190
205
|
}),
|
|
191
206
|
);
|
|
207
|
+
const psmPrivateArgs = {
|
|
208
|
+
feeMintAccess,
|
|
209
|
+
initialPoserInvitation,
|
|
210
|
+
marshaller,
|
|
211
|
+
storageNode,
|
|
212
|
+
};
|
|
192
213
|
/** @type {GovernorStartedInstallationKit<typeof psmInstall>} */
|
|
193
214
|
const governorFacets = await E(zoe).startInstance(
|
|
194
215
|
contractGovernor,
|
|
@@ -196,12 +217,7 @@ export const startPSM = async (
|
|
|
196
217
|
governorTerms,
|
|
197
218
|
harden({
|
|
198
219
|
economicCommitteeCreatorFacet,
|
|
199
|
-
governed:
|
|
200
|
-
feeMintAccess,
|
|
201
|
-
initialPoserInvitation,
|
|
202
|
-
marshaller,
|
|
203
|
-
storageNode,
|
|
204
|
-
},
|
|
220
|
+
governed: psmPrivateArgs,
|
|
205
221
|
}),
|
|
206
222
|
`${instanceKey}.governor`,
|
|
207
223
|
);
|
|
@@ -211,6 +227,7 @@ export const startPSM = async (
|
|
|
211
227
|
E(governorFacets.creatorFacet).getCreatorFacet(),
|
|
212
228
|
E(governorFacets.creatorFacet).getAdminFacet(),
|
|
213
229
|
]);
|
|
230
|
+
await E(diagnostics).savePrivateArgs(psm, psmPrivateArgs);
|
|
214
231
|
|
|
215
232
|
/** @param {MetricsNotification} metrics */
|
|
216
233
|
const restoreMetrics = async metrics => {
|
|
@@ -229,22 +246,23 @@ export const startPSM = async (
|
|
|
229
246
|
};
|
|
230
247
|
await (oldState.metrics && restoreMetrics(oldState.metrics));
|
|
231
248
|
|
|
232
|
-
/** @
|
|
233
|
-
|
|
234
|
-
|
|
249
|
+
/** @type {import('./econ-behaviors.js').PSMKit} */
|
|
250
|
+
const newpsmKit = harden({
|
|
251
|
+
label: instanceKey,
|
|
235
252
|
psm,
|
|
236
253
|
psmGovernor: governorFacets.instance,
|
|
237
254
|
psmCreatorFacet,
|
|
238
255
|
psmAdminFacet,
|
|
239
256
|
psmGovernorCreatorFacet: governorFacets.creatorFacet,
|
|
240
|
-
};
|
|
257
|
+
});
|
|
241
258
|
|
|
242
259
|
// Provide pattern with a promise.
|
|
243
|
-
producepsmKit.resolve(
|
|
260
|
+
producepsmKit.resolve(makeScalarBigMapStore('PSM Kits', { durable: true }));
|
|
244
261
|
|
|
245
|
-
/** @type {MapStore<Brand,
|
|
262
|
+
/** @type {MapStore<Brand, import('./econ-behaviors.js').PSMKit>} */
|
|
246
263
|
const psmKitMap = await psmKit;
|
|
247
264
|
|
|
265
|
+
// TODO init into governedContractKits too to simplify testing
|
|
248
266
|
psmKitMap.init(anchorBrand, newpsmKit);
|
|
249
267
|
const instanceAdmin = E(agoricNamesAdmin).lookupAdmin('instance');
|
|
250
268
|
|
|
@@ -290,16 +308,14 @@ export const makeAnchorAsset = async (
|
|
|
290
308
|
consume: {
|
|
291
309
|
agoricNamesAdmin,
|
|
292
310
|
bankManager,
|
|
293
|
-
startUpgradable
|
|
311
|
+
startUpgradable,
|
|
294
312
|
anchorBalancePayments,
|
|
295
|
-
anchorKits,
|
|
296
313
|
},
|
|
297
314
|
installation: {
|
|
298
315
|
consume: { mintHolder },
|
|
299
316
|
},
|
|
300
317
|
produce: {
|
|
301
318
|
testFirstAnchorKit,
|
|
302
|
-
anchorKits: produceAnchorKits,
|
|
303
319
|
anchorBalancePayments: produceAnchorBalancePayments,
|
|
304
320
|
},
|
|
305
321
|
},
|
|
@@ -329,35 +345,35 @@ export const makeAnchorAsset = async (
|
|
|
329
345
|
}),
|
|
330
346
|
);
|
|
331
347
|
|
|
332
|
-
const startUpgradable = await startUpgradableP;
|
|
333
|
-
produceAnchorKits.resolve([]);
|
|
334
348
|
/** @type {{ creatorFacet: ERef<Mint<'nat'>>, publicFacet: ERef<Issuer<'nat'>> }} */
|
|
335
349
|
// @ts-expect-error cast
|
|
336
|
-
const { creatorFacet: mint, publicFacet:
|
|
350
|
+
const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
|
|
337
351
|
installation: mintHolder,
|
|
338
352
|
label: keyword,
|
|
339
353
|
terms,
|
|
340
|
-
privateArgs: undefined,
|
|
341
|
-
produceResults: {
|
|
342
|
-
resolve: kit => Promise.resolve(anchorKits).then(kits => kits.push(kit)),
|
|
343
|
-
},
|
|
344
354
|
});
|
|
345
|
-
const issuer = await issuerP; // identity of issuers is important
|
|
346
355
|
|
|
347
356
|
const brand = await E(issuer).getBrand();
|
|
348
|
-
const kit = { mint, issuer, brand };
|
|
357
|
+
const kit = harden({ mint, issuer, brand });
|
|
349
358
|
|
|
350
359
|
testFirstAnchorKit.resolve(kit);
|
|
351
360
|
|
|
352
|
-
const toSlotReviver = makeHistoryReviver(
|
|
361
|
+
const toSlotReviver = makeHistoryReviver(
|
|
362
|
+
chainStorageEntries,
|
|
363
|
+
slotToBoardRemote,
|
|
364
|
+
);
|
|
353
365
|
const metricsKey = `${stablePsmKey}.${keyword}.metrics`;
|
|
354
366
|
if (toSlotReviver.has(metricsKey)) {
|
|
355
367
|
const metrics = toSlotReviver.getItem(metricsKey);
|
|
356
|
-
produceAnchorBalancePayments.resolve(
|
|
368
|
+
produceAnchorBalancePayments.resolve(
|
|
369
|
+
makeScalarBigMapStore('Anchor balance payments', { durable: true }),
|
|
370
|
+
);
|
|
357
371
|
// XXX this rule should only apply to the 1st await
|
|
358
372
|
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
359
373
|
const anchorPaymentMap = await anchorBalancePayments;
|
|
360
374
|
|
|
375
|
+
// TODO: validate that `metrics.anchorPoolBalance.value` is
|
|
376
|
+
// pass-by-copy PureData (e.g., contains no remotables).
|
|
361
377
|
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
362
378
|
const pmt = await E(mint).mintPayment(
|
|
363
379
|
AmountMath.make(brand, metrics.anchorPoolBalance.value),
|
|
@@ -423,6 +439,7 @@ export const PSM_MANIFEST = {
|
|
|
423
439
|
agoricNamesAdmin: true,
|
|
424
440
|
board: true,
|
|
425
441
|
chainStorage: true,
|
|
442
|
+
diagnostics: true,
|
|
426
443
|
zoe: 'zoe',
|
|
427
444
|
feeMintAccess: 'zoe',
|
|
428
445
|
economicCommitteeCreatorFacet: 'economicCommittee',
|
package/src/psm/psm.js
CHANGED
|
@@ -89,12 +89,17 @@ export const customTermsShape = {
|
|
|
89
89
|
};
|
|
90
90
|
harden(customTermsShape);
|
|
91
91
|
|
|
92
|
-
export const privateArgsShape =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
export const privateArgsShape = M.splitRecord(
|
|
93
|
+
harden({
|
|
94
|
+
marshaller: M.remotable('Marshaller'),
|
|
95
|
+
storageNode: StorageNodeShape,
|
|
96
|
+
}),
|
|
97
|
+
harden({
|
|
98
|
+
// only necessary on first invocation, not subsequent
|
|
99
|
+
feeMintAccess: FeeMintAccessShape,
|
|
100
|
+
initialPoserInvitation: InvitationShape,
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
98
103
|
harden(privateArgsShape);
|
|
99
104
|
|
|
100
105
|
/**
|
|
@@ -134,7 +134,7 @@ export const prepareAssetReserveKit = async (
|
|
|
134
134
|
totalFeeMinted: state.totalFeeMinted,
|
|
135
135
|
totalFeeBurned: state.totalFeeBurned,
|
|
136
136
|
});
|
|
137
|
-
state.metricsKit.recorder.write(metrics);
|
|
137
|
+
void state.metricsKit.recorder.write(metrics);
|
|
138
138
|
},
|
|
139
139
|
},
|
|
140
140
|
governedApis: {
|