@agoric/inter-protocol 0.13.3 → 0.13.4-dev-d32a66a.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,45 +1,105 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { makeMap } from 'jessie.js';
|
|
3
4
|
import { AmountMath, AssetKind } from '@agoric/ertp';
|
|
4
5
|
import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
|
|
5
|
-
import { makeStorageNodeChild } from '@agoric/
|
|
6
|
+
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
6
7
|
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
7
8
|
import { E } from '@endo/far';
|
|
8
9
|
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
10
|
+
import {
|
|
11
|
+
makeHistoryReviver,
|
|
12
|
+
makeBoardRemote,
|
|
13
|
+
slotToBoardRemote,
|
|
14
|
+
} from '@agoric/vats/tools/board-utils.js';
|
|
9
15
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
10
|
-
import {
|
|
16
|
+
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
11
17
|
|
|
12
|
-
import {
|
|
18
|
+
import { reserveThenGetNamePaths } from './utils.js';
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
inviteCommitteeMembers,
|
|
22
|
+
startEconCharter,
|
|
23
|
+
inviteToEconCharter,
|
|
24
|
+
} from './committee-proposal.js';
|
|
25
|
+
|
|
26
|
+
/** @typedef {import('@agoric/vats/src/core/lib-boot.js').BootstrapManifest} BootstrapManifest */
|
|
27
|
+
/** @typedef {import('../psm/psm.js').MetricsNotification} MetricsNotification */
|
|
28
|
+
/** @typedef {import('./econ-behaviors.js').EconomyBootstrapPowers} EconomyBootstrapPowers */
|
|
13
29
|
|
|
14
30
|
const BASIS_POINTS = 10000n;
|
|
15
31
|
const { details: X } = assert;
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
export { inviteCommitteeMembers, startEconCharter, inviteToEconCharter };
|
|
34
|
+
|
|
35
|
+
const stablePsmKey = `published.psm.${Stable.symbol}`;
|
|
18
36
|
|
|
19
37
|
/**
|
|
20
|
-
* @param {
|
|
38
|
+
* @param {Array<[key: string, value: string]>} chainStorageEntries
|
|
39
|
+
* @param {string} keyword
|
|
40
|
+
* @param {{ minted: Brand<'nat'>, anchor: Brand<'nat'> }} brands
|
|
41
|
+
* @returns {{ metrics?: MetricsNotification, governance?: GovernanceSubscriptionState }}
|
|
42
|
+
*/
|
|
43
|
+
const findOldPSMState = (chainStorageEntries, keyword, brands) => {
|
|
44
|
+
// In this reviver, object references are revived as boardIDs
|
|
45
|
+
// from the pre-bulldozer board.
|
|
46
|
+
const toSlotReviver = makeHistoryReviver(
|
|
47
|
+
chainStorageEntries,
|
|
48
|
+
slotToBoardRemote,
|
|
49
|
+
);
|
|
50
|
+
if (!toSlotReviver.has(`${stablePsmKey}.${keyword}.metrics`)) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
const metricsWithOldBoardIDs = toSlotReviver.getItem(
|
|
54
|
+
`${stablePsmKey}.${keyword}.metrics`,
|
|
55
|
+
);
|
|
56
|
+
const oldIDtoNewBrand = makeMap([
|
|
57
|
+
[metricsWithOldBoardIDs.feePoolBalance.brand.getBoardId(), brands.minted],
|
|
58
|
+
[
|
|
59
|
+
metricsWithOldBoardIDs.anchorPoolBalance.brand.getBoardId(),
|
|
60
|
+
brands.anchor,
|
|
61
|
+
],
|
|
62
|
+
]);
|
|
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
|
+
},
|
|
70
|
+
);
|
|
71
|
+
return {
|
|
72
|
+
metrics: brandReviver.getItem(`${stablePsmKey}.${keyword}.metrics`),
|
|
73
|
+
governance: brandReviver.getItem(`${stablePsmKey}.${keyword}.governance`),
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {EconomyBootstrapPowers & WellKnownSpaces & ChainStorageVatParams} powers
|
|
21
79
|
* @param {object} [config]
|
|
22
80
|
* @param {bigint} [config.WantMintedFeeBP]
|
|
23
81
|
* @param {bigint} [config.GiveMintedFeeBP]
|
|
24
82
|
* @param {bigint} [config.MINT_LIMIT]
|
|
25
83
|
* @param {{ anchorOptions?: AnchorOptions } } [config.options]
|
|
26
|
-
*
|
|
27
|
-
* @typedef {import('./econ-behaviors.js').EconomyBootstrapPowers} EconomyBootstrapPowers
|
|
28
84
|
*/
|
|
29
85
|
export const startPSM = async (
|
|
30
86
|
{
|
|
87
|
+
vatParameters: { chainStorageEntries = [] },
|
|
31
88
|
consume: {
|
|
32
89
|
agoricNamesAdmin,
|
|
33
90
|
board,
|
|
91
|
+
diagnostics,
|
|
34
92
|
zoe,
|
|
35
93
|
feeMintAccess: feeMintAccessP,
|
|
36
94
|
economicCommitteeCreatorFacet,
|
|
37
|
-
|
|
95
|
+
econCharterKit,
|
|
38
96
|
provisionPoolStartResult,
|
|
39
97
|
chainStorage,
|
|
40
98
|
chainTimerService,
|
|
41
|
-
|
|
99
|
+
psmKit,
|
|
100
|
+
anchorBalancePayments: anchorBalancePaymentsP,
|
|
42
101
|
},
|
|
102
|
+
produce: { psmKit: producepsmKit },
|
|
43
103
|
installation: {
|
|
44
104
|
consume: { contractGovernor, psm: psmInstall },
|
|
45
105
|
},
|
|
@@ -88,6 +148,12 @@ export const startPSM = async (
|
|
|
88
148
|
const mintLimit = AmountMath.make(minted, MINT_LIMIT);
|
|
89
149
|
const anchorDecimalPlaces = anchorInfo.decimalPlaces || 1n;
|
|
90
150
|
const mintedDecimalPlaces = mintedInfo.decimalPlaces || 1n;
|
|
151
|
+
|
|
152
|
+
const oldState = findOldPSMState(chainStorageEntries, keyword, {
|
|
153
|
+
minted,
|
|
154
|
+
anchor: anchorBrand,
|
|
155
|
+
});
|
|
156
|
+
|
|
91
157
|
const terms = await deeplyFulfilledObject(
|
|
92
158
|
harden({
|
|
93
159
|
anchorBrand,
|
|
@@ -98,10 +164,6 @@ export const startPSM = async (
|
|
|
98
164
|
minted,
|
|
99
165
|
),
|
|
100
166
|
governedParams: {
|
|
101
|
-
[CONTRACT_ELECTORATE]: {
|
|
102
|
-
type: ParamTypes.INVITATION,
|
|
103
|
-
value: electorateInvitationAmount,
|
|
104
|
-
},
|
|
105
167
|
WantMintedFee: {
|
|
106
168
|
type: ParamTypes.RATIO,
|
|
107
169
|
value: makeRatio(WantMintedFeeBP, minted, BASIS_POINTS),
|
|
@@ -111,21 +173,26 @@ export const startPSM = async (
|
|
|
111
173
|
value: makeRatio(GiveMintedFeeBP, minted, BASIS_POINTS),
|
|
112
174
|
},
|
|
113
175
|
MintLimit: { type: ParamTypes.AMOUNT, value: mintLimit },
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
176
|
+
// Override numeric config values from restored state.
|
|
177
|
+
...oldState.governance?.current,
|
|
178
|
+
// Don't override the invitation amount;
|
|
179
|
+
// the electorate is re-constituted rather than restored.
|
|
180
|
+
[CONTRACT_ELECTORATE]: {
|
|
181
|
+
type: ParamTypes.INVITATION,
|
|
182
|
+
value: electorateInvitationAmount,
|
|
183
|
+
},
|
|
118
184
|
},
|
|
119
185
|
}),
|
|
120
186
|
);
|
|
121
187
|
|
|
122
188
|
const psmStorageNode = await makeStorageNodeChild(chainStorage, 'psm');
|
|
123
|
-
const storageNode = E(
|
|
189
|
+
const storageNode = await E(
|
|
124
190
|
E(psmStorageNode).makeChildNode(Stable.symbol),
|
|
125
191
|
).makeChildNode(keyword);
|
|
126
192
|
|
|
127
193
|
const marshaller = await E(board).getPublishingMarshaller();
|
|
128
194
|
|
|
195
|
+
const instanceKey = `psm-${Stable.symbol}-${keyword}`;
|
|
129
196
|
const governorTerms = await deeplyFulfilledObject(
|
|
130
197
|
harden({
|
|
131
198
|
timer: chainTimerService,
|
|
@@ -133,22 +200,26 @@ export const startPSM = async (
|
|
|
133
200
|
governed: {
|
|
134
201
|
terms,
|
|
135
202
|
issuerKeywordRecord: { [keyword]: anchorIssuer },
|
|
203
|
+
label: instanceKey,
|
|
136
204
|
},
|
|
137
205
|
}),
|
|
138
206
|
);
|
|
207
|
+
const psmPrivateArgs = {
|
|
208
|
+
feeMintAccess,
|
|
209
|
+
initialPoserInvitation,
|
|
210
|
+
marshaller,
|
|
211
|
+
storageNode,
|
|
212
|
+
};
|
|
213
|
+
/** @type {GovernorStartedInstallationKit<typeof psmInstall>} */
|
|
139
214
|
const governorFacets = await E(zoe).startInstance(
|
|
140
215
|
contractGovernor,
|
|
141
216
|
{},
|
|
142
217
|
governorTerms,
|
|
143
218
|
harden({
|
|
144
219
|
economicCommitteeCreatorFacet,
|
|
145
|
-
governed:
|
|
146
|
-
feeMintAccess,
|
|
147
|
-
initialPoserInvitation,
|
|
148
|
-
marshaller,
|
|
149
|
-
storageNode,
|
|
150
|
-
},
|
|
220
|
+
governed: psmPrivateArgs,
|
|
151
221
|
}),
|
|
222
|
+
`${instanceKey}.governor`,
|
|
152
223
|
);
|
|
153
224
|
|
|
154
225
|
const [psm, psmCreatorFacet, psmAdminFacet] = await Promise.all([
|
|
@@ -156,36 +227,56 @@ export const startPSM = async (
|
|
|
156
227
|
E(governorFacets.creatorFacet).getCreatorFacet(),
|
|
157
228
|
E(governorFacets.creatorFacet).getAdminFacet(),
|
|
158
229
|
]);
|
|
230
|
+
await E(diagnostics).savePrivateArgs(psm, psmPrivateArgs);
|
|
231
|
+
|
|
232
|
+
/** @param {MetricsNotification} metrics */
|
|
233
|
+
const restoreMetrics = async metrics => {
|
|
234
|
+
const anchorBalancePayments = await anchorBalancePaymentsP;
|
|
235
|
+
const anchorPmt = anchorBalancePayments.get(anchorBrand);
|
|
236
|
+
|
|
237
|
+
const { anchorPoolBalance: _a, ...nonPaymentMetrics } = metrics;
|
|
238
|
+
|
|
239
|
+
const seat = E(zoe).offer(
|
|
240
|
+
E(psmCreatorFacet).makeRestoreMetricsInvitation(),
|
|
241
|
+
harden({ give: { Anchor: metrics.anchorPoolBalance } }),
|
|
242
|
+
harden({ Anchor: anchorPmt }),
|
|
243
|
+
harden(nonPaymentMetrics),
|
|
244
|
+
);
|
|
245
|
+
await E(seat).getPayouts();
|
|
246
|
+
};
|
|
247
|
+
await (oldState.metrics && restoreMetrics(oldState.metrics));
|
|
159
248
|
|
|
160
|
-
/** @
|
|
161
|
-
|
|
162
|
-
|
|
249
|
+
/** @type {import('./econ-behaviors.js').PSMKit} */
|
|
250
|
+
const newpsmKit = harden({
|
|
251
|
+
label: instanceKey,
|
|
163
252
|
psm,
|
|
164
253
|
psmGovernor: governorFacets.instance,
|
|
165
254
|
psmCreatorFacet,
|
|
166
255
|
psmAdminFacet,
|
|
167
256
|
psmGovernorCreatorFacet: governorFacets.creatorFacet,
|
|
168
|
-
};
|
|
257
|
+
});
|
|
169
258
|
|
|
170
|
-
|
|
171
|
-
|
|
259
|
+
// Provide pattern with a promise.
|
|
260
|
+
producepsmKit.resolve(makeScalarBigMapStore('PSM Kits', { durable: true }));
|
|
172
261
|
|
|
173
|
-
|
|
174
|
-
const
|
|
262
|
+
/** @type {MapStore<Brand, import('./econ-behaviors.js').PSMKit>} */
|
|
263
|
+
const psmKitMap = await psmKit;
|
|
264
|
+
|
|
265
|
+
// TODO init into governedContractKits too to simplify testing
|
|
266
|
+
psmKitMap.init(anchorBrand, newpsmKit);
|
|
175
267
|
const instanceAdmin = E(agoricNamesAdmin).lookupAdmin('instance');
|
|
176
268
|
|
|
177
269
|
await Promise.all([
|
|
178
|
-
E(instanceAdmin).update(instanceKey,
|
|
179
|
-
E(
|
|
270
|
+
E(instanceAdmin).update(instanceKey, newpsmKit.psm),
|
|
271
|
+
E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
180
272
|
psm,
|
|
181
273
|
governorFacets.creatorFacet,
|
|
182
|
-
|
|
183
|
-
minted,
|
|
274
|
+
instanceKey,
|
|
184
275
|
),
|
|
185
276
|
// @ts-expect-error TODO type for provisionPoolStartResult
|
|
186
277
|
E(E.get(provisionPoolStartResult).creatorFacet).initPSM(
|
|
187
278
|
anchorBrand,
|
|
188
|
-
|
|
279
|
+
newpsmKit.psm,
|
|
189
280
|
),
|
|
190
281
|
]);
|
|
191
282
|
};
|
|
@@ -203,16 +294,30 @@ harden(startPSM);
|
|
|
203
294
|
* Make anchor issuer out of a Cosmos asset; presumably
|
|
204
295
|
* USDC over IBC. Add it to BankManager.
|
|
205
296
|
*
|
|
206
|
-
*
|
|
297
|
+
* Also, if vatParameters shows an anchorPoolBalance for this asset,
|
|
298
|
+
* mint a payment for that balance.
|
|
299
|
+
*
|
|
300
|
+
* TODO: address redundancy with publishInterchainAssetFromBank
|
|
301
|
+
*
|
|
302
|
+
* @param {EconomyBootstrapPowers & WellKnownSpaces & ChainStorageVatParams} powers
|
|
207
303
|
* @param {{options?: { anchorOptions?: AnchorOptions } }} [config]
|
|
208
304
|
*/
|
|
209
305
|
export const makeAnchorAsset = async (
|
|
210
306
|
{
|
|
211
|
-
|
|
307
|
+
vatParameters: { chainStorageEntries = [] },
|
|
308
|
+
consume: {
|
|
309
|
+
agoricNamesAdmin,
|
|
310
|
+
bankManager,
|
|
311
|
+
startUpgradable,
|
|
312
|
+
anchorBalancePayments,
|
|
313
|
+
},
|
|
212
314
|
installation: {
|
|
213
315
|
consume: { mintHolder },
|
|
214
316
|
},
|
|
215
|
-
produce: {
|
|
317
|
+
produce: {
|
|
318
|
+
testFirstAnchorKit,
|
|
319
|
+
anchorBalancePayments: produceAnchorBalancePayments,
|
|
320
|
+
},
|
|
216
321
|
},
|
|
217
322
|
{ options: { anchorOptions = {} } = {} },
|
|
218
323
|
) => {
|
|
@@ -239,17 +344,44 @@ export const makeAnchorAsset = async (
|
|
|
239
344
|
},
|
|
240
345
|
}),
|
|
241
346
|
);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const
|
|
347
|
+
|
|
348
|
+
/** @type {{ creatorFacet: ERef<Mint<'nat'>>, publicFacet: ERef<Issuer<'nat'>> }} */
|
|
349
|
+
// @ts-expect-error cast
|
|
350
|
+
const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
|
|
351
|
+
installation: mintHolder,
|
|
352
|
+
label: keyword,
|
|
353
|
+
terms,
|
|
354
|
+
});
|
|
246
355
|
|
|
247
356
|
const brand = await E(issuer).getBrand();
|
|
248
|
-
const kit = { mint, issuer, brand };
|
|
357
|
+
const kit = harden({ mint, issuer, brand });
|
|
249
358
|
|
|
250
359
|
testFirstAnchorKit.resolve(kit);
|
|
251
360
|
|
|
252
|
-
|
|
361
|
+
const toSlotReviver = makeHistoryReviver(
|
|
362
|
+
chainStorageEntries,
|
|
363
|
+
slotToBoardRemote,
|
|
364
|
+
);
|
|
365
|
+
const metricsKey = `${stablePsmKey}.${keyword}.metrics`;
|
|
366
|
+
if (toSlotReviver.has(metricsKey)) {
|
|
367
|
+
const metrics = toSlotReviver.getItem(metricsKey);
|
|
368
|
+
produceAnchorBalancePayments.resolve(
|
|
369
|
+
makeScalarBigMapStore('Anchor balance payments', { durable: true }),
|
|
370
|
+
);
|
|
371
|
+
// XXX this rule should only apply to the 1st await
|
|
372
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
373
|
+
const anchorPaymentMap = await anchorBalancePayments;
|
|
374
|
+
|
|
375
|
+
// TODO: validate that `metrics.anchorPoolBalance.value` is
|
|
376
|
+
// pass-by-copy PureData (e.g., contains no remotables).
|
|
377
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
378
|
+
const pmt = await E(mint).mintPayment(
|
|
379
|
+
AmountMath.make(brand, metrics.anchorPoolBalance.value),
|
|
380
|
+
);
|
|
381
|
+
anchorPaymentMap.init(brand, pmt);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
await Promise.all([
|
|
253
385
|
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, kit.issuer),
|
|
254
386
|
E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, kit.brand),
|
|
255
387
|
E(bankManager).addAsset(
|
|
@@ -264,185 +396,60 @@ harden(makeAnchorAsset);
|
|
|
264
396
|
|
|
265
397
|
/** @typedef {import('./econ-behaviors.js').EconomyBootstrapSpace} EconomyBootstrapSpace */
|
|
266
398
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
contractGovernor,
|
|
276
|
-
committee,
|
|
277
|
-
binaryVoteCounter,
|
|
278
|
-
psm,
|
|
279
|
-
psmCharter,
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
}) => {
|
|
283
|
-
// In order to support multiple instances of the PSM, we store all the facets
|
|
284
|
-
// indexed by the brand. Since each name in the BootstrapSpace can only be
|
|
285
|
-
// produced once, we produce an empty store here, and each time a PSM is
|
|
286
|
-
// started up, the details are added to the store.
|
|
287
|
-
psmFacets.resolve(makeScalarMapStore());
|
|
288
|
-
|
|
289
|
-
return Promise.all(
|
|
290
|
-
Object.entries({
|
|
291
|
-
contractGovernor,
|
|
292
|
-
committee,
|
|
293
|
-
binaryVoteCounter,
|
|
294
|
-
psm,
|
|
295
|
-
psmCharter,
|
|
296
|
-
}).map(async ([name, producer]) => {
|
|
297
|
-
const bundleCap = D(vatAdmin).getNamedBundleCap(name);
|
|
298
|
-
const bundle = D(bundleCap).getBundle();
|
|
299
|
-
const installation = E(zoe).install(bundle);
|
|
300
|
-
|
|
301
|
-
producer.resolve(installation);
|
|
302
|
-
}),
|
|
303
|
-
);
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
/** @param {EconomyBootstrapPowers} powers */
|
|
307
|
-
export const startPSMCharter = async ({
|
|
308
|
-
consume: { zoe },
|
|
309
|
-
produce: { psmCharterCreatorFacet, psmCharterAdminFacet },
|
|
310
|
-
installation: {
|
|
311
|
-
consume: { binaryVoteCounter, psmCharter: installP },
|
|
312
|
-
},
|
|
313
|
-
instance: {
|
|
314
|
-
produce: { psmCharter: instanceP },
|
|
315
|
-
},
|
|
316
|
-
}) => {
|
|
317
|
-
const [charterR, counterR] = await Promise.all([installP, binaryVoteCounter]);
|
|
318
|
-
|
|
319
|
-
const terms = { binaryVoteCounterInstallation: counterR };
|
|
320
|
-
const facets = await E(zoe).startInstance(charterR, {}, terms);
|
|
321
|
-
|
|
322
|
-
instanceP.resolve(facets.instance);
|
|
323
|
-
psmCharterCreatorFacet.resolve(facets.creatorFacet);
|
|
324
|
-
psmCharterAdminFacet.resolve(facets.adminFacet);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* PSM and gov contracts are available as
|
|
329
|
-
* named swingset bundles only in
|
|
330
|
-
* decentral-psm-config.json
|
|
331
|
-
*/
|
|
332
|
-
export const PSM_GOV_MANIFEST = {
|
|
333
|
-
[installGovAndPSMContracts.name]: {
|
|
334
|
-
vatPowers: { D: true },
|
|
335
|
-
devices: { vatAdmin: true },
|
|
336
|
-
consume: { zoe: 'zoe' },
|
|
337
|
-
produce: { psmFacets: 'true' },
|
|
338
|
-
installation: {
|
|
339
|
-
produce: {
|
|
340
|
-
contractGovernor: 'zoe',
|
|
341
|
-
committee: 'zoe',
|
|
342
|
-
binaryVoteCounter: 'zoe',
|
|
343
|
-
psm: 'zoe',
|
|
344
|
-
psmCharter: 'zoe',
|
|
399
|
+
export const INVITE_PSM_COMMITTEE_MANIFEST = harden(
|
|
400
|
+
/** @type {BootstrapManifest} */ ({
|
|
401
|
+
[inviteCommitteeMembers.name]: {
|
|
402
|
+
consume: {
|
|
403
|
+
namesByAddressAdmin: true,
|
|
404
|
+
economicCommitteeCreatorFacet: true,
|
|
405
|
+
econCharterKit: true,
|
|
406
|
+
highPrioritySendersManager: true,
|
|
345
407
|
},
|
|
346
408
|
},
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
psmCharterAdminFacet: 'psmCharter',
|
|
353
|
-
},
|
|
354
|
-
installation: {
|
|
355
|
-
consume: { binaryVoteCounter: 'zoe', psmCharter: 'zoe' },
|
|
356
|
-
},
|
|
357
|
-
instance: {
|
|
358
|
-
produce: { psmCharter: 'psmCharter' },
|
|
359
|
-
},
|
|
360
|
-
},
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
/** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
364
|
-
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
368
|
-
* @param {{ options: { voterAddresses: Record<string, string> }}} param1
|
|
369
|
-
*/
|
|
370
|
-
export const invitePSMCommitteeMembers = async (
|
|
371
|
-
{
|
|
372
|
-
consume: {
|
|
373
|
-
namesByAddressAdmin,
|
|
374
|
-
economicCommitteeCreatorFacet,
|
|
375
|
-
psmCharterCreatorFacet,
|
|
409
|
+
[inviteToEconCharter.name]: {
|
|
410
|
+
consume: {
|
|
411
|
+
namesByAddressAdmin: true,
|
|
412
|
+
econCharterKit: true,
|
|
413
|
+
},
|
|
376
414
|
},
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
) => {
|
|
380
|
-
const invitations = await E(
|
|
381
|
-
economicCommitteeCreatorFacet,
|
|
382
|
-
).getVoterInvitations();
|
|
383
|
-
assert.equal(invitations.length, values(voterAddresses).length);
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* @param {[string, Promise<Invitation>][]} addrInvitations
|
|
387
|
-
*/
|
|
388
|
-
const distributeInvitations = async addrInvitations => {
|
|
389
|
-
await Promise.all(
|
|
390
|
-
addrInvitations.map(async ([addr, invitationP]) => {
|
|
391
|
-
const [voterInvitation, charterMemberInvitation] = await Promise.all([
|
|
392
|
-
invitationP,
|
|
393
|
-
E(psmCharterCreatorFacet).makeCharterMemberInvitation(),
|
|
394
|
-
]);
|
|
395
|
-
console.log('sending charter, voting invitations to', addr);
|
|
396
|
-
await reserveThenDeposit(
|
|
397
|
-
`econ committee member ${addr}`,
|
|
398
|
-
namesByAddressAdmin,
|
|
399
|
-
addr,
|
|
400
|
-
[voterInvitation, charterMemberInvitation],
|
|
401
|
-
);
|
|
402
|
-
console.log('sent charter, voting invitations to', addr);
|
|
403
|
-
}),
|
|
404
|
-
);
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
await distributeInvitations(zip(values(voterAddresses), invitations));
|
|
408
|
-
};
|
|
409
|
-
harden(invitePSMCommitteeMembers);
|
|
415
|
+
}),
|
|
416
|
+
);
|
|
410
417
|
|
|
411
|
-
|
|
412
|
-
|
|
418
|
+
/** @type {BootstrapManifest} */
|
|
419
|
+
export const PSM_MANIFEST = {
|
|
420
|
+
[makeAnchorAsset.name]: {
|
|
421
|
+
vatParameters: { chainStorageEntries: true },
|
|
413
422
|
consume: {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
423
|
+
agoricNamesAdmin: true,
|
|
424
|
+
bankManager: 'bank',
|
|
425
|
+
startUpgradable: true,
|
|
426
|
+
anchorBalancePayments: true,
|
|
427
|
+
anchorKits: true,
|
|
417
428
|
},
|
|
418
|
-
},
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
export const PSM_MANIFEST = harden({
|
|
422
|
-
[makeAnchorAsset.name]: {
|
|
423
|
-
consume: { agoricNamesAdmin: true, bankManager: 'bank', zoe: 'zoe' },
|
|
424
429
|
installation: { consume: { mintHolder: 'zoe' } },
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
produce: { AUSD: true },
|
|
430
|
+
produce: {
|
|
431
|
+
testFirstAnchorKit: true,
|
|
432
|
+
anchorBalancePayments: true,
|
|
433
|
+
anchorKits: true,
|
|
430
434
|
},
|
|
431
|
-
produce: { testFirstAnchorKit: true },
|
|
432
435
|
},
|
|
433
436
|
[startPSM.name]: {
|
|
437
|
+
vatParameters: { chainStorageEntries: true },
|
|
434
438
|
consume: {
|
|
435
439
|
agoricNamesAdmin: true,
|
|
436
440
|
board: true,
|
|
437
441
|
chainStorage: true,
|
|
442
|
+
diagnostics: true,
|
|
438
443
|
zoe: 'zoe',
|
|
439
444
|
feeMintAccess: 'zoe',
|
|
440
445
|
economicCommitteeCreatorFacet: 'economicCommittee',
|
|
441
446
|
provisionPoolStartResult: true,
|
|
442
|
-
|
|
447
|
+
econCharterKit: 'econCommitteeCharter',
|
|
443
448
|
chainTimerService: 'timer',
|
|
444
|
-
|
|
449
|
+
psmKit: true,
|
|
450
|
+
anchorBalancePayments: true,
|
|
445
451
|
},
|
|
452
|
+
produce: { psmKit: 'true' },
|
|
446
453
|
installation: {
|
|
447
454
|
consume: { contractGovernor: 'zoe', psm: 'zoe' },
|
|
448
455
|
},
|
|
@@ -450,13 +457,26 @@ export const PSM_MANIFEST = harden({
|
|
|
450
457
|
consume: { economicCommittee: 'economicCommittee' },
|
|
451
458
|
},
|
|
452
459
|
brand: {
|
|
453
|
-
consume: {
|
|
454
|
-
},
|
|
455
|
-
issuer: {
|
|
456
|
-
consume: { AUSD: 'bank' },
|
|
460
|
+
consume: { [Stable.symbol]: 'zoe' },
|
|
457
461
|
},
|
|
458
462
|
},
|
|
459
|
-
}
|
|
463
|
+
};
|
|
464
|
+
harden(PSM_MANIFEST);
|
|
465
|
+
|
|
466
|
+
export const getManifestForPsmGovernance = (
|
|
467
|
+
{ restoreRef },
|
|
468
|
+
{ installKeys },
|
|
469
|
+
) => {
|
|
470
|
+
return {
|
|
471
|
+
manifest: {},
|
|
472
|
+
installations: {
|
|
473
|
+
econCommitteeCharter: restoreRef(installKeys.econCommitteeCharter),
|
|
474
|
+
contractGovernor: restoreRef(installKeys.contractGovernor),
|
|
475
|
+
committee: restoreRef(installKeys.committee),
|
|
476
|
+
binaryVoteCounter: restoreRef(installKeys.binaryVoteCounter),
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
};
|
|
460
480
|
|
|
461
481
|
export const getManifestForPsm = (
|
|
462
482
|
{ restoreRef },
|