@agoric/inter-protocol 0.13.3 → 0.13.4-dev-800c2bb.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -20
- package/bundles/bundle-auctioneer-js-meta.json +722 -0
- package/bundles/bundle-auctioneer.js +1 -0
- package/bundles/bundle-econCommitteeCharter-js-meta.json +514 -0
- package/bundles/bundle-econCommitteeCharter.js +1 -0
- package/bundles/bundle-feeDistributor-js-meta.json +458 -0
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +674 -0
- package/bundles/bundle-fluxAggregatorKit.js +1 -0
- package/bundles/bundle-psm-js-meta.json +666 -0
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-js-meta.json +662 -0
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +542 -0
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-vaultFactory-js-meta.json +786 -0
- package/bundles/bundle-vaultFactory.js +1 -1
- package/exported.js +0 -2
- package/package.json +34 -31
- package/scripts/add-collateral-core.js +14 -4
- package/scripts/build-bundles.js +9 -2
- package/scripts/deploy-contracts.js +1 -4
- package/scripts/init-core.js +20 -38
- package/scripts/invite-committee-core.js +1 -1
- package/scripts/manual-price-feed.js +2 -2
- package/scripts/price-feed-core.js +7 -6
- package/scripts/start-local-chain.sh +84 -0
- package/src/auction/auctionBook.js +755 -0
- package/src/auction/auctioneer.js +720 -0
- package/src/auction/offerBook.js +221 -0
- package/src/auction/params.js +174 -0
- package/src/auction/scheduleMath.js +167 -0
- package/src/auction/scheduler.js +370 -0
- package/src/auction/sortedOffers.js +136 -0
- package/src/auction/util.js +55 -0
- package/src/clientSupport.js +324 -0
- package/src/collectFees.js +8 -14
- package/src/contractSupport.js +24 -68
- package/src/econCommitteeCharter.js +161 -77
- package/src/feeDistributor.js +60 -20
- package/src/index.js +2 -0
- package/src/interest-math.js +1 -4
- package/src/interest.js +20 -13
- package/src/price/README.md +57 -0
- package/src/price/fluxAggregatorContract.js +190 -0
- package/src/price/fluxAggregatorKit.js +375 -0
- package/src/price/priceOracleKit.js +127 -0
- package/src/price/roundsManager.js +726 -0
- package/src/proposals/addAssetToVault.js +89 -94
- package/src/proposals/committee-proposal.js +141 -40
- package/src/proposals/core-proposal.js +100 -167
- package/src/proposals/econ-behaviors.js +320 -564
- package/src/proposals/price-feed-proposal.js +175 -78
- package/src/proposals/startEconCommittee.js +25 -12
- package/src/proposals/startPSM.js +231 -211
- package/src/proposals/utils.js +31 -17
- package/src/psm/README.md +71 -0
- package/src/psm/psm.js +272 -160
- package/src/psm/types.js +2 -0
- package/src/reserve/assetReserve.js +56 -413
- package/src/reserve/assetReserveKit.js +303 -0
- package/src/reserve/doc.md +1 -3
- package/src/reserve/params.js +2 -5
- package/src/typeGuards.js +13 -0
- package/src/vaultFactory/Liquidation.md +100 -0
- package/src/vaultFactory/burn.js +2 -1
- package/src/vaultFactory/liquidation.js +270 -108
- package/src/vaultFactory/math.js +95 -0
- package/src/vaultFactory/orderedVaultStore.js +0 -1
- package/src/vaultFactory/params.js +133 -112
- package/src/vaultFactory/prioritizedVaults.js +36 -79
- package/src/vaultFactory/storeUtils.js +67 -9
- package/src/vaultFactory/type-imports.js +2 -0
- package/src/vaultFactory/types.js +22 -26
- package/src/vaultFactory/vault.js +772 -709
- package/src/vaultFactory/vaultDirector.js +480 -483
- package/src/vaultFactory/vaultFactory.js +99 -60
- package/src/vaultFactory/vaultHolder.js +121 -95
- package/src/vaultFactory/vaultKit.js +39 -31
- package/src/vaultFactory/vaultManager.js +1249 -868
- package/bundles/bundle-amm-meta.js +0 -618
- package/bundles/bundle-amm.js +0 -1
- package/bundles/bundle-feeDistributor-meta.js +0 -346
- package/bundles/bundle-interchainPool-meta.js +0 -534
- package/bundles/bundle-interchainPool.js +0 -1
- package/bundles/bundle-liquidateIncrementally-meta.js +0 -442
- package/bundles/bundle-liquidateIncrementally.js +0 -1
- package/bundles/bundle-liquidateMinimum-meta.js +0 -442
- package/bundles/bundle-liquidateMinimum.js +0 -1
- package/bundles/bundle-psm-meta.js +0 -538
- package/bundles/bundle-psmCharter-meta.js +0 -418
- package/bundles/bundle-psmCharter.js +0 -1
- package/bundles/bundle-reserve-meta.js +0 -542
- package/bundles/bundle-scaledPriceAuthority-meta.js +0 -442
- package/bundles/bundle-stakeFactory-meta.js +0 -574
- package/bundles/bundle-stakeFactory.js +0 -1
- package/bundles/bundle-vaultFactory-meta.js +0 -598
- package/scripts/add-initial-liquidity.js +0 -180
- package/src/collect.js +0 -13
- package/src/interchainPool.js +0 -135
- package/src/makeTracer.js +0 -36
- package/src/my-lien.js +0 -85
- package/src/proposals/demoIssuers.js +0 -685
- package/src/proposals/sim-behaviors.js +0 -40
- package/src/psm/psmCharter.js +0 -139
- package/src/stakeFactory/README.md +0 -62
- package/src/stakeFactory/attestation.js +0 -267
- package/src/stakeFactory/attestationTool.js +0 -66
- package/src/stakeFactory/constants.js +0 -16
- package/src/stakeFactory/params.js +0 -31
- package/src/stakeFactory/stakeFactory.js +0 -236
- package/src/stakeFactory/stakeFactoryKit.js +0 -455
- package/src/stakeFactory/stakeFactoryManager.js +0 -296
- package/src/stakeFactory/types.js +0 -42
- package/src/vaultFactory/liquidateIncrementally.js +0 -350
- package/src/vaultFactory/liquidateMinimum.js +0 -100
- package/src/vpool-xyk-amm/AttackersGuide.md +0 -89
- package/src/vpool-xyk-amm/addLiquidity.js +0 -222
- package/src/vpool-xyk-amm/addPool.js +0 -197
- package/src/vpool-xyk-amm/constantProduct/AMM-Trade.jpeg +0 -0
- package/src/vpool-xyk-amm/constantProduct/README.md +0 -204
- package/src/vpool-xyk-amm/constantProduct/calcFees.js +0 -99
- package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +0 -85
- package/src/vpool-xyk-amm/constantProduct/core.js +0 -153
- package/src/vpool-xyk-amm/constantProduct/defaults.js +0 -5
- package/src/vpool-xyk-amm/constantProduct/getXY.js +0 -52
- package/src/vpool-xyk-amm/constantProduct/internal-types.js +0 -116
- package/src/vpool-xyk-amm/constantProduct/invariants.js +0 -43
- package/src/vpool-xyk-amm/constantProduct/swap.js +0 -272
- package/src/vpool-xyk-amm/constantProduct/types.js +0 -32
- package/src/vpool-xyk-amm/doublePool.js +0 -194
- package/src/vpool-xyk-amm/estimate.js +0 -155
- package/src/vpool-xyk-amm/multipoolMarketMaker.js +0 -520
- package/src/vpool-xyk-amm/params.js +0 -61
- package/src/vpool-xyk-amm/pool.js +0 -396
- package/src/vpool-xyk-amm/priceAuthority.js +0 -94
- package/src/vpool-xyk-amm/removeLiquidity.js +0 -31
- package/src/vpool-xyk-amm/singlePool.js +0 -73
- package/src/vpool-xyk-amm/swap.js +0 -69
- package/src/vpool-xyk-amm/types.js +0 -154
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @jessie-check
|
|
2
|
+
|
|
2
3
|
import { AmountMath, AssetKind } from '@agoric/ertp';
|
|
3
4
|
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
4
5
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
5
6
|
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
6
7
|
import { E } from '@endo/far';
|
|
8
|
+
import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
7
9
|
import { reserveThenGetNames } from './utils.js';
|
|
8
10
|
|
|
9
11
|
export * from './startPSM.js';
|
|
@@ -16,6 +18,7 @@ export * from './startPSM.js';
|
|
|
16
18
|
* @property {string} [proposedName]
|
|
17
19
|
* @property {string} keyword
|
|
18
20
|
* @property {string} oracleBrand
|
|
21
|
+
* @property {number} [initialPrice]
|
|
19
22
|
*/
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -43,44 +46,6 @@ export const publishInterchainAssetFromBoardId = async (
|
|
|
43
46
|
]);
|
|
44
47
|
};
|
|
45
48
|
|
|
46
|
-
const addPool = async (
|
|
47
|
-
zoe,
|
|
48
|
-
amm,
|
|
49
|
-
issuer,
|
|
50
|
-
keyword,
|
|
51
|
-
brand,
|
|
52
|
-
runBrand,
|
|
53
|
-
runIssuer,
|
|
54
|
-
) => {
|
|
55
|
-
const ammPub = E(zoe).getPublicFacet(amm);
|
|
56
|
-
const [addPoolInvitation] = await Promise.all([
|
|
57
|
-
E(ammPub).addPoolInvitation(),
|
|
58
|
-
E(ammPub).addIssuer(issuer, keyword),
|
|
59
|
-
]);
|
|
60
|
-
const proposal = harden({
|
|
61
|
-
give: {
|
|
62
|
-
Secondary: AmountMath.makeEmpty(brand),
|
|
63
|
-
Central: AmountMath.makeEmpty(runBrand),
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
const centralPurse = E(runIssuer).makeEmptyPurse();
|
|
67
|
-
const secondaryPurse = E(issuer).makeEmptyPurse();
|
|
68
|
-
const [emptyCentral, emptySecondary] = await Promise.all([
|
|
69
|
-
E(centralPurse).withdraw(proposal.give.Central),
|
|
70
|
-
E(secondaryPurse).withdraw(proposal.give.Secondary),
|
|
71
|
-
]);
|
|
72
|
-
const payments = harden({
|
|
73
|
-
Central: emptyCentral,
|
|
74
|
-
Secondary: emptySecondary,
|
|
75
|
-
});
|
|
76
|
-
const addLiquiditySeat = await E(zoe).offer(
|
|
77
|
-
addPoolInvitation,
|
|
78
|
-
proposal,
|
|
79
|
-
payments,
|
|
80
|
-
);
|
|
81
|
-
await E(addLiquiditySeat).getOfferResult();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
49
|
/**
|
|
85
50
|
* @param {EconomyBootstrapPowers} powers
|
|
86
51
|
* @param {object} config
|
|
@@ -89,20 +54,10 @@ const addPool = async (
|
|
|
89
54
|
*/
|
|
90
55
|
export const publishInterchainAssetFromBank = async (
|
|
91
56
|
{
|
|
92
|
-
consume: {
|
|
93
|
-
produce: { bankMints: produceBankMints },
|
|
57
|
+
consume: { bankManager, agoricNamesAdmin, reserveKit, startUpgradable },
|
|
94
58
|
installation: {
|
|
95
59
|
consume: { mintHolder },
|
|
96
60
|
},
|
|
97
|
-
instance: {
|
|
98
|
-
consume: { amm },
|
|
99
|
-
},
|
|
100
|
-
issuer: {
|
|
101
|
-
consume: { [Stable.symbol]: runIssuer },
|
|
102
|
-
},
|
|
103
|
-
brand: {
|
|
104
|
-
consume: { [Stable.symbol]: stableBrandP },
|
|
105
|
-
},
|
|
106
61
|
},
|
|
107
62
|
{ options: { interchainAssetOptions } },
|
|
108
63
|
) => {
|
|
@@ -124,27 +79,20 @@ export const publishInterchainAssetFromBank = async (
|
|
|
124
79
|
assetKind: AssetKind.NAT,
|
|
125
80
|
},
|
|
126
81
|
};
|
|
127
|
-
const { creatorFacet: mintP, publicFacet: issuerP } = E.get(
|
|
128
|
-
E(zoe).startInstance(mintHolder, {}, terms),
|
|
129
|
-
);
|
|
130
82
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
83
|
+
const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
|
|
84
|
+
installation: mintHolder,
|
|
85
|
+
label: keyword,
|
|
86
|
+
privateArgs: undefined,
|
|
87
|
+
terms,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const brand = await E(issuer).getBrand();
|
|
91
|
+
const kit = { mint, issuer, brand };
|
|
137
92
|
|
|
138
|
-
await
|
|
93
|
+
await E(E.get(reserveKit).creatorFacet).addIssuer(issuer, keyword);
|
|
139
94
|
|
|
140
|
-
// Create the mint list if it doesn't exist and wasn't already rejected.
|
|
141
|
-
produceBankMints.resolve([]);
|
|
142
95
|
await Promise.all([
|
|
143
|
-
Promise.resolve(bankMints).then(
|
|
144
|
-
// @ts-expect-error pushing a promise to a presence array
|
|
145
|
-
mints => mints.push(mintP),
|
|
146
|
-
() => {}, // If the bankMints list was rejected, ignore the error.
|
|
147
|
-
),
|
|
148
96
|
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer),
|
|
149
97
|
E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand),
|
|
150
98
|
E(bankManager).addAsset(denom, keyword, proposedName, kit),
|
|
@@ -158,16 +106,27 @@ export const publishInterchainAssetFromBank = async (
|
|
|
158
106
|
* @param {InterchainAssetOptions} config.options.interchainAssetOptions
|
|
159
107
|
*/
|
|
160
108
|
export const registerScaledPriceAuthority = async (
|
|
161
|
-
{
|
|
109
|
+
{
|
|
110
|
+
consume: {
|
|
111
|
+
agoricNamesAdmin,
|
|
112
|
+
startUpgradable,
|
|
113
|
+
priceAuthorityAdmin,
|
|
114
|
+
priceAuthority,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
162
117
|
{ options: { interchainAssetOptions } },
|
|
163
118
|
) => {
|
|
164
|
-
const {
|
|
119
|
+
const {
|
|
120
|
+
keyword,
|
|
121
|
+
oracleBrand,
|
|
122
|
+
initialPrice: initialPriceRaw,
|
|
123
|
+
} = interchainAssetOptions;
|
|
165
124
|
assert.typeof(keyword, 'string');
|
|
166
125
|
assert.typeof(oracleBrand, 'string');
|
|
167
126
|
|
|
168
127
|
const [
|
|
169
128
|
sourcePriceAuthority,
|
|
170
|
-
[interchainBrand,
|
|
129
|
+
[interchainBrand, stableBrand],
|
|
171
130
|
[interchainOracleBrand, usdBrand],
|
|
172
131
|
[scaledPriceAuthority],
|
|
173
132
|
] = await Promise.all([
|
|
@@ -201,7 +160,7 @@ export const registerScaledPriceAuthority = async (
|
|
|
201
160
|
getDecimalP(interchainOracleBrand),
|
|
202
161
|
getDecimalP(interchainBrand),
|
|
203
162
|
getDecimalP(usdBrand),
|
|
204
|
-
getDecimalP(
|
|
163
|
+
getDecimalP(stableBrand),
|
|
205
164
|
]);
|
|
206
165
|
|
|
207
166
|
const scaleIn = makeRatio(
|
|
@@ -214,23 +173,32 @@ export const registerScaledPriceAuthority = async (
|
|
|
214
173
|
10n ** BigInt(decimalPlacesUsd),
|
|
215
174
|
usdBrand,
|
|
216
175
|
10n ** BigInt(decimalPlacesRun),
|
|
217
|
-
|
|
176
|
+
stableBrand,
|
|
218
177
|
);
|
|
178
|
+
const initialPrice = initialPriceRaw
|
|
179
|
+
? parseRatio(initialPriceRaw, stableBrand, interchainBrand)
|
|
180
|
+
: undefined;
|
|
219
181
|
|
|
220
182
|
const terms = await deeplyFulfilledObject(
|
|
221
183
|
harden({
|
|
222
184
|
sourcePriceAuthority,
|
|
223
185
|
scaleIn,
|
|
224
186
|
scaleOut,
|
|
187
|
+
initialPrice,
|
|
225
188
|
}),
|
|
226
189
|
);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
190
|
+
|
|
191
|
+
const spaKit = await E(startUpgradable)({
|
|
192
|
+
installation: scaledPriceAuthority,
|
|
193
|
+
label: `scaledPriceAuthority-${keyword}`,
|
|
194
|
+
terms,
|
|
195
|
+
});
|
|
196
|
+
|
|
230
197
|
await E(priceAuthorityAdmin).registerPriceAuthority(
|
|
231
|
-
|
|
198
|
+
// @ts-expect-error The public facet should have getPriceAuthority
|
|
199
|
+
E(spaKit.publicFacet).getPriceAuthority(),
|
|
232
200
|
interchainBrand,
|
|
233
|
-
|
|
201
|
+
stableBrand,
|
|
234
202
|
true, // force
|
|
235
203
|
);
|
|
236
204
|
};
|
|
@@ -242,15 +210,26 @@ export const registerScaledPriceAuthority = async (
|
|
|
242
210
|
* @param {object} config
|
|
243
211
|
* @param {object} config.options
|
|
244
212
|
* @param {InterchainAssetOptions} config.options.interchainAssetOptions
|
|
213
|
+
* @param {bigint | number | string} config.options.debtLimitValue
|
|
214
|
+
* @param {bigint} config.options.interestRateValue
|
|
245
215
|
*/
|
|
246
216
|
export const addAssetToVault = async (
|
|
247
217
|
{
|
|
248
|
-
consume: {
|
|
218
|
+
consume: { vaultFactoryKit, agoricNamesAdmin, auctioneerKit },
|
|
249
219
|
brand: {
|
|
250
220
|
consume: { [Stable.symbol]: stableP },
|
|
251
221
|
},
|
|
252
222
|
},
|
|
253
|
-
{
|
|
223
|
+
{
|
|
224
|
+
options: {
|
|
225
|
+
// Default to 1000 IST to simplify testing. A production proposal will set this.
|
|
226
|
+
debtLimitValue = 1_000n * 1_000_000n,
|
|
227
|
+
// Default to a safe value. Production will likely set this through governance.
|
|
228
|
+
// Allow setting through bootstrap to simplify testing.
|
|
229
|
+
interestRateValue = 1n,
|
|
230
|
+
interchainAssetOptions,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
254
233
|
) => {
|
|
255
234
|
const { keyword, oracleBrand } = interchainAssetOptions;
|
|
256
235
|
assert.typeof(keyword, 'string');
|
|
@@ -261,19 +240,31 @@ export const addAssetToVault = async (
|
|
|
261
240
|
);
|
|
262
241
|
|
|
263
242
|
const stable = await stableP;
|
|
243
|
+
const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
|
|
264
244
|
await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
|
|
265
|
-
debtLimit: AmountMath.make(stable,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
245
|
+
debtLimit: AmountMath.make(stable, BigInt(debtLimitValue)),
|
|
246
|
+
interestRate: makeRatio(interestRateValue, stable),
|
|
247
|
+
// The rest of these we use safe defaults.
|
|
248
|
+
// In production they will be governed by the Econ Committee.
|
|
249
|
+
// Product deployments are also expected to have a low debtLimitValue at the outset,
|
|
250
|
+
// limiting the impact of these defaults.
|
|
251
|
+
liquidationPadding: makeRatio(25n, stable),
|
|
252
|
+
liquidationMargin: makeRatio(150n, stable),
|
|
253
|
+
mintFee: makeRatio(50n, stable, 10_000n),
|
|
269
254
|
liquidationPenalty: makeRatio(1n, stable),
|
|
270
|
-
loanFee: makeRatio(1n, stable),
|
|
271
255
|
});
|
|
256
|
+
const auctioneerCreator = E.get(auctioneerKit).creatorFacet;
|
|
257
|
+
await E(auctioneerCreator).addBrand(interchainIssuer, keyword);
|
|
272
258
|
};
|
|
273
259
|
|
|
274
260
|
export const getManifestForAddAssetToVault = (
|
|
275
261
|
{ restoreRef },
|
|
276
|
-
{
|
|
262
|
+
{
|
|
263
|
+
debtLimitValue,
|
|
264
|
+
interestRateValue,
|
|
265
|
+
interchainAssetOptions,
|
|
266
|
+
scaledPriceAuthorityRef,
|
|
267
|
+
},
|
|
277
268
|
) => {
|
|
278
269
|
const publishIssuerFromBoardId =
|
|
279
270
|
typeof interchainAssetOptions.issuerBoardId === 'string';
|
|
@@ -293,26 +284,29 @@ export const getManifestForAddAssetToVault = (
|
|
|
293
284
|
...(publishIssuerFromBank && {
|
|
294
285
|
[publishInterchainAssetFromBank.name]: {
|
|
295
286
|
consume: {
|
|
296
|
-
zoe: true,
|
|
297
287
|
bankManager: true,
|
|
298
288
|
agoricNamesAdmin: true,
|
|
299
289
|
bankMints: true,
|
|
290
|
+
reserveKit: true,
|
|
291
|
+
vBankKits: true,
|
|
292
|
+
startUpgradable: true,
|
|
300
293
|
},
|
|
301
|
-
produce: { bankMints: true },
|
|
294
|
+
produce: { bankMints: true, vBankKits: true },
|
|
302
295
|
installation: {
|
|
303
296
|
consume: { mintHolder: true },
|
|
304
297
|
},
|
|
305
|
-
instance: { consume: { amm: 'amm' } },
|
|
306
|
-
issuer: { consume: { [Stable.symbol]: 'zoe' } },
|
|
307
|
-
brand: { consume: { [Stable.symbol]: 'zoe' } },
|
|
308
298
|
},
|
|
309
299
|
}),
|
|
310
300
|
[registerScaledPriceAuthority.name]: {
|
|
311
301
|
consume: {
|
|
312
302
|
agoricNamesAdmin: true,
|
|
313
|
-
|
|
303
|
+
startUpgradable: true,
|
|
314
304
|
priceAuthorityAdmin: true,
|
|
315
305
|
priceAuthority: true,
|
|
306
|
+
scaledPriceAuthorityKits: true,
|
|
307
|
+
},
|
|
308
|
+
produce: {
|
|
309
|
+
scaledPriceAuthorityKits: true,
|
|
316
310
|
},
|
|
317
311
|
installation: {
|
|
318
312
|
consume: { scaledPriceAuthority: true },
|
|
@@ -320,9 +314,8 @@ export const getManifestForAddAssetToVault = (
|
|
|
320
314
|
},
|
|
321
315
|
[addAssetToVault.name]: {
|
|
322
316
|
consume: {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
reserveCreatorFacet: true,
|
|
317
|
+
auctioneerKit: 'auctioneer',
|
|
318
|
+
vaultFactoryKit: 'vaultFactory',
|
|
326
319
|
agoricNamesAdmin: true,
|
|
327
320
|
},
|
|
328
321
|
brand: {
|
|
@@ -334,7 +327,9 @@ export const getManifestForAddAssetToVault = (
|
|
|
334
327
|
scaledPriceAuthority: restoreRef(scaledPriceAuthorityRef),
|
|
335
328
|
},
|
|
336
329
|
options: {
|
|
330
|
+
debtLimitValue,
|
|
337
331
|
interchainAssetOptions,
|
|
332
|
+
interestRateValue,
|
|
338
333
|
},
|
|
339
334
|
};
|
|
340
335
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
3
2
|
import { E } from '@endo/far';
|
|
4
3
|
import { reserveThenDeposit } from './utils.js';
|
|
@@ -8,67 +7,43 @@ const { values } = Object;
|
|
|
8
7
|
/** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
9
8
|
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
|
|
10
9
|
|
|
10
|
+
const EC_HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
13
|
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
13
14
|
* @param {{ options: { voterAddresses: Record<string, string> }}} param1
|
|
14
15
|
*/
|
|
15
16
|
export const inviteCommitteeMembers = async (
|
|
16
17
|
{
|
|
17
|
-
consume: {
|
|
18
|
-
zoe,
|
|
19
|
-
agoricNames,
|
|
20
|
-
namesByAddressAdmin,
|
|
21
|
-
economicCommitteeCreatorFacet,
|
|
22
|
-
reserveGovernorCreatorFacet,
|
|
23
|
-
ammGovernorCreatorFacet,
|
|
24
|
-
vaultFactoryGovernorCreator,
|
|
25
|
-
},
|
|
26
|
-
installation: {
|
|
27
|
-
consume: { binaryVoteCounter: counterP },
|
|
28
|
-
},
|
|
18
|
+
consume: { namesByAddressAdmin, economicCommitteeCreatorFacet, ...consume },
|
|
29
19
|
},
|
|
30
20
|
{ options: { voterAddresses } },
|
|
31
21
|
) => {
|
|
32
|
-
/** @type {[Installation, Installation]} */
|
|
33
|
-
const [charterInstall, counterInstall] = await Promise.all([
|
|
34
|
-
E(agoricNames).lookup('installation', 'econCommitteeCharter'),
|
|
35
|
-
counterP,
|
|
36
|
-
]);
|
|
37
|
-
const terms = await deeplyFulfilledObject(
|
|
38
|
-
harden({
|
|
39
|
-
binaryVoteCounterInstallation: counterInstall,
|
|
40
|
-
}),
|
|
41
|
-
);
|
|
42
|
-
const privateFacets = {
|
|
43
|
-
reserve: reserveGovernorCreatorFacet,
|
|
44
|
-
amm: ammGovernorCreatorFacet,
|
|
45
|
-
vaults: vaultFactoryGovernorCreator,
|
|
46
|
-
};
|
|
47
|
-
const { publicFacet: votingAPI } = E.get(
|
|
48
|
-
E(zoe).startInstance(charterInstall, undefined, terms, privateFacets),
|
|
49
|
-
);
|
|
50
|
-
|
|
51
22
|
const invitations = await E(
|
|
52
23
|
economicCommitteeCreatorFacet,
|
|
53
24
|
).getVoterInvitations();
|
|
54
25
|
assert.equal(invitations.length, values(voterAddresses).length);
|
|
55
26
|
|
|
27
|
+
const highPrioritySendersManager = await consume.highPrioritySendersManager;
|
|
28
|
+
|
|
56
29
|
/**
|
|
57
30
|
* @param {[string, Promise<Invitation>][]} addrInvitations
|
|
58
31
|
*/
|
|
59
32
|
const distributeInvitations = async addrInvitations => {
|
|
60
33
|
await Promise.all(
|
|
61
34
|
addrInvitations.map(async ([addr, invitationP]) => {
|
|
62
|
-
const [voterInvitation, nullInvitation] = await Promise.all([
|
|
63
|
-
invitationP,
|
|
64
|
-
E(votingAPI).makeNullInvitation(),
|
|
65
|
-
]);
|
|
66
35
|
await reserveThenDeposit(
|
|
67
36
|
`econ committee member ${addr}`,
|
|
68
37
|
namesByAddressAdmin,
|
|
69
38
|
addr,
|
|
70
|
-
[
|
|
39
|
+
[invitationP],
|
|
71
40
|
);
|
|
41
|
+
if (highPrioritySendersManager) {
|
|
42
|
+
await E(highPrioritySendersManager).add(
|
|
43
|
+
EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
|
|
44
|
+
addr,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
72
47
|
}),
|
|
73
48
|
);
|
|
74
49
|
};
|
|
@@ -78,6 +53,106 @@ export const inviteCommitteeMembers = async (
|
|
|
78
53
|
|
|
79
54
|
harden(inviteCommitteeMembers);
|
|
80
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
58
|
+
*/
|
|
59
|
+
export const startEconCharter = async ({
|
|
60
|
+
consume: { zoe },
|
|
61
|
+
produce: { econCharterKit },
|
|
62
|
+
installation: {
|
|
63
|
+
consume: { binaryVoteCounter: counterP, econCommitteeCharter: installP },
|
|
64
|
+
},
|
|
65
|
+
instance: {
|
|
66
|
+
produce: { econCommitteeCharter: instanceP },
|
|
67
|
+
},
|
|
68
|
+
}) => {
|
|
69
|
+
const [charterInstall, counterInstall] = await Promise.all([
|
|
70
|
+
installP,
|
|
71
|
+
counterP,
|
|
72
|
+
]);
|
|
73
|
+
const terms = await deeplyFulfilledObject(
|
|
74
|
+
harden({
|
|
75
|
+
binaryVoteCounterInstallation: counterInstall,
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
/** @type {Promise<import('./econ-behaviors').EconCharterStartResult>} */
|
|
80
|
+
const startResult = E(zoe).startInstance(
|
|
81
|
+
charterInstall,
|
|
82
|
+
undefined,
|
|
83
|
+
terms,
|
|
84
|
+
undefined,
|
|
85
|
+
'econCommitteeCharter',
|
|
86
|
+
);
|
|
87
|
+
instanceP.resolve(E.get(startResult).instance);
|
|
88
|
+
econCharterKit.resolve(startResult);
|
|
89
|
+
};
|
|
90
|
+
harden(startEconCharter);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Introduce charter to governed creator facets.
|
|
94
|
+
*
|
|
95
|
+
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
96
|
+
*/
|
|
97
|
+
export const addGovernorsToEconCharter = async ({
|
|
98
|
+
consume: { reserveKit, vaultFactoryKit, econCharterKit, auctioneerKit },
|
|
99
|
+
instance: {
|
|
100
|
+
consume: { reserve, VaultFactory, auctioneer },
|
|
101
|
+
},
|
|
102
|
+
}) => {
|
|
103
|
+
const { creatorFacet } = E.get(econCharterKit);
|
|
104
|
+
|
|
105
|
+
await Promise.all(
|
|
106
|
+
[
|
|
107
|
+
{
|
|
108
|
+
label: 'reserve',
|
|
109
|
+
instanceP: reserve,
|
|
110
|
+
facetP: E.get(reserveKit).governorCreatorFacet,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: 'VaultFactory',
|
|
114
|
+
instanceP: VaultFactory,
|
|
115
|
+
facetP: E.get(vaultFactoryKit).governorCreatorFacet,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: 'auctioneer',
|
|
119
|
+
instanceP: auctioneer,
|
|
120
|
+
facetP: E.get(auctioneerKit).governorCreatorFacet,
|
|
121
|
+
},
|
|
122
|
+
].map(async ({ label, instanceP, facetP }) => {
|
|
123
|
+
const [instance, govFacet] = await Promise.all([instanceP, facetP]);
|
|
124
|
+
|
|
125
|
+
return E(creatorFacet).addInstance(instance, govFacet, label);
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
harden(addGovernorsToEconCharter);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
134
|
+
* @param {{ options: { voterAddresses: Record<string, string> }}} param1
|
|
135
|
+
*/
|
|
136
|
+
export const inviteToEconCharter = async (
|
|
137
|
+
{ consume: { namesByAddressAdmin, econCharterKit } },
|
|
138
|
+
{ options: { voterAddresses } },
|
|
139
|
+
) => {
|
|
140
|
+
const { creatorFacet } = E.get(econCharterKit);
|
|
141
|
+
|
|
142
|
+
await Promise.all(
|
|
143
|
+
values(voterAddresses).map(async addr =>
|
|
144
|
+
reserveThenDeposit(
|
|
145
|
+
`econ charter member ${addr}`,
|
|
146
|
+
namesByAddressAdmin,
|
|
147
|
+
addr,
|
|
148
|
+
[E(creatorFacet).makeCharterMemberInvitation()],
|
|
149
|
+
),
|
|
150
|
+
),
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
harden(inviteToEconCharter);
|
|
155
|
+
|
|
81
156
|
export const getManifestForInviteCommittee = async (
|
|
82
157
|
{ restoreRef },
|
|
83
158
|
{ voterAddresses, econCommitteeCharterRef },
|
|
@@ -87,17 +162,43 @@ export const getManifestForInviteCommittee = async (
|
|
|
87
162
|
manifest: {
|
|
88
163
|
[inviteCommitteeMembers.name]: {
|
|
89
164
|
consume: {
|
|
90
|
-
zoe: t,
|
|
91
|
-
agoricNames: t,
|
|
92
165
|
namesByAddressAdmin: t,
|
|
93
166
|
economicCommitteeCreatorFacet: t,
|
|
167
|
+
highPrioritySendersManager: t,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
[startEconCharter.name]: {
|
|
171
|
+
consume: { zoe: t },
|
|
172
|
+
produce: { econCharterKit: t },
|
|
173
|
+
installation: {
|
|
174
|
+
consume: { binaryVoteCounter: t, econCommitteeCharter: t },
|
|
175
|
+
},
|
|
176
|
+
instance: {
|
|
177
|
+
produce: { econCommitteeCharter: t },
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
[addGovernorsToEconCharter.name]: {
|
|
181
|
+
consume: {
|
|
182
|
+
auctioneerKit: t,
|
|
94
183
|
reserveGovernorCreatorFacet: t,
|
|
95
|
-
ammGovernorCreatorFacet: t,
|
|
96
184
|
vaultFactoryGovernorCreator: t,
|
|
185
|
+
econCharterKit: t,
|
|
186
|
+
zoe: t,
|
|
187
|
+
agoricNames: t,
|
|
188
|
+
namesByAddressAdmin: t,
|
|
189
|
+
economicCommitteeCreatorFacet: t,
|
|
190
|
+
reserveKit: t,
|
|
191
|
+
vaultFactoryKit: t,
|
|
97
192
|
},
|
|
98
193
|
installation: {
|
|
99
194
|
consume: { binaryVoteCounter: t },
|
|
100
195
|
},
|
|
196
|
+
instance: {
|
|
197
|
+
consume: { auctioneer: t, reserve: t, VaultFactory: t },
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
[inviteToEconCharter.name]: {
|
|
201
|
+
consume: { namesByAddressAdmin: t, econCharterKit: t },
|
|
101
202
|
},
|
|
102
203
|
},
|
|
103
204
|
installations: {
|