@agoric/inter-protocol 0.13.4-pismo-dev-0d5327f.0 → 0.14.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +287 -0
  2. package/README.md +26 -20
  3. package/bundles/bundle-auctioneer-js-meta.json +722 -0
  4. package/bundles/bundle-auctioneer.js +1 -0
  5. package/bundles/bundle-econCommitteeCharter-js-meta.json +514 -0
  6. package/bundles/bundle-econCommitteeCharter.js +1 -0
  7. package/bundles/bundle-feeDistributor-js-meta.json +458 -0
  8. package/bundles/bundle-feeDistributor.js +1 -1
  9. package/bundles/bundle-fluxAggregatorKit-js-meta.json +674 -0
  10. package/bundles/bundle-fluxAggregatorKit.js +1 -0
  11. package/bundles/bundle-psm-js-meta.json +666 -0
  12. package/bundles/bundle-psm.js +1 -1
  13. package/bundles/bundle-reserve-js-meta.json +662 -0
  14. package/bundles/bundle-reserve.js +1 -1
  15. package/bundles/bundle-scaledPriceAuthority-js-meta.json +542 -0
  16. package/bundles/bundle-scaledPriceAuthority.js +1 -1
  17. package/bundles/bundle-vaultFactory-js-meta.json +786 -0
  18. package/bundles/bundle-vaultFactory.js +1 -1
  19. package/exported.js +0 -2
  20. package/package.json +34 -31
  21. package/scripts/add-collateral-core.js +14 -4
  22. package/scripts/build-bundles.js +9 -2
  23. package/scripts/deploy-contracts.js +1 -4
  24. package/scripts/init-core.js +20 -38
  25. package/scripts/invite-committee-core.js +1 -1
  26. package/scripts/manual-price-feed.js +2 -2
  27. package/scripts/price-feed-core.js +7 -6
  28. package/scripts/start-local-chain.sh +84 -0
  29. package/src/auction/auctionBook.js +755 -0
  30. package/src/auction/auctioneer.js +720 -0
  31. package/src/auction/offerBook.js +221 -0
  32. package/src/auction/params.js +174 -0
  33. package/src/auction/scheduleMath.js +167 -0
  34. package/src/auction/scheduler.js +370 -0
  35. package/src/auction/sortedOffers.js +136 -0
  36. package/src/auction/util.js +55 -0
  37. package/src/clientSupport.js +324 -0
  38. package/src/collectFees.js +8 -14
  39. package/src/contractSupport.js +24 -68
  40. package/src/econCommitteeCharter.js +161 -77
  41. package/src/feeDistributor.js +60 -20
  42. package/src/index.js +2 -0
  43. package/src/interest-math.js +1 -4
  44. package/src/interest.js +20 -13
  45. package/src/price/README.md +57 -0
  46. package/src/price/fluxAggregatorContract.js +190 -0
  47. package/src/price/fluxAggregatorKit.js +375 -0
  48. package/src/price/priceOracleKit.js +127 -0
  49. package/src/price/roundsManager.js +726 -0
  50. package/src/proposals/addAssetToVault.js +89 -94
  51. package/src/proposals/committee-proposal.js +141 -40
  52. package/src/proposals/core-proposal.js +100 -167
  53. package/src/proposals/econ-behaviors.js +320 -564
  54. package/src/proposals/price-feed-proposal.js +175 -78
  55. package/src/proposals/startEconCommittee.js +25 -12
  56. package/src/proposals/startPSM.js +231 -211
  57. package/src/proposals/utils.js +31 -17
  58. package/src/psm/README.md +71 -0
  59. package/src/psm/psm.js +272 -160
  60. package/src/psm/types.js +2 -0
  61. package/src/reserve/assetReserve.js +56 -413
  62. package/src/reserve/assetReserveKit.js +303 -0
  63. package/src/reserve/doc.md +1 -3
  64. package/src/reserve/params.js +2 -5
  65. package/src/typeGuards.js +13 -0
  66. package/src/vaultFactory/Liquidation.md +100 -0
  67. package/src/vaultFactory/burn.js +2 -1
  68. package/src/vaultFactory/liquidation.js +270 -108
  69. package/src/vaultFactory/math.js +95 -0
  70. package/src/vaultFactory/orderedVaultStore.js +0 -1
  71. package/src/vaultFactory/params.js +133 -112
  72. package/src/vaultFactory/prioritizedVaults.js +36 -79
  73. package/src/vaultFactory/storeUtils.js +67 -9
  74. package/src/vaultFactory/type-imports.js +2 -0
  75. package/src/vaultFactory/types.js +22 -26
  76. package/src/vaultFactory/vault.js +772 -709
  77. package/src/vaultFactory/vaultDirector.js +480 -483
  78. package/src/vaultFactory/vaultFactory.js +99 -60
  79. package/src/vaultFactory/vaultHolder.js +121 -95
  80. package/src/vaultFactory/vaultKit.js +39 -31
  81. package/src/vaultFactory/vaultManager.js +1249 -868
  82. package/bundles/bundle-amm-meta.js +0 -618
  83. package/bundles/bundle-amm.js +0 -1
  84. package/bundles/bundle-feeDistributor-meta.js +0 -346
  85. package/bundles/bundle-interchainPool-meta.js +0 -534
  86. package/bundles/bundle-interchainPool.js +0 -1
  87. package/bundles/bundle-liquidateIncrementally-meta.js +0 -442
  88. package/bundles/bundle-liquidateIncrementally.js +0 -1
  89. package/bundles/bundle-liquidateMinimum-meta.js +0 -442
  90. package/bundles/bundle-liquidateMinimum.js +0 -1
  91. package/bundles/bundle-psm-meta.js +0 -538
  92. package/bundles/bundle-psmCharter-meta.js +0 -418
  93. package/bundles/bundle-psmCharter.js +0 -1
  94. package/bundles/bundle-reserve-meta.js +0 -542
  95. package/bundles/bundle-scaledPriceAuthority-meta.js +0 -442
  96. package/bundles/bundle-stakeFactory-meta.js +0 -574
  97. package/bundles/bundle-stakeFactory.js +0 -1
  98. package/bundles/bundle-vaultFactory-meta.js +0 -598
  99. package/scripts/add-initial-liquidity.js +0 -180
  100. package/src/collect.js +0 -13
  101. package/src/interchainPool.js +0 -135
  102. package/src/makeTracer.js +0 -36
  103. package/src/my-lien.js +0 -85
  104. package/src/proposals/demoIssuers.js +0 -685
  105. package/src/proposals/sim-behaviors.js +0 -40
  106. package/src/psm/psmCharter.js +0 -139
  107. package/src/stakeFactory/README.md +0 -62
  108. package/src/stakeFactory/attestation.js +0 -267
  109. package/src/stakeFactory/attestationTool.js +0 -66
  110. package/src/stakeFactory/constants.js +0 -16
  111. package/src/stakeFactory/params.js +0 -31
  112. package/src/stakeFactory/stakeFactory.js +0 -236
  113. package/src/stakeFactory/stakeFactoryKit.js +0 -455
  114. package/src/stakeFactory/stakeFactoryManager.js +0 -296
  115. package/src/stakeFactory/types.js +0 -42
  116. package/src/vaultFactory/liquidateIncrementally.js +0 -350
  117. package/src/vaultFactory/liquidateMinimum.js +0 -100
  118. package/src/vpool-xyk-amm/AttackersGuide.md +0 -89
  119. package/src/vpool-xyk-amm/addLiquidity.js +0 -222
  120. package/src/vpool-xyk-amm/addPool.js +0 -197
  121. package/src/vpool-xyk-amm/constantProduct/AMM-Trade.jpeg +0 -0
  122. package/src/vpool-xyk-amm/constantProduct/README.md +0 -204
  123. package/src/vpool-xyk-amm/constantProduct/calcFees.js +0 -99
  124. package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +0 -85
  125. package/src/vpool-xyk-amm/constantProduct/core.js +0 -153
  126. package/src/vpool-xyk-amm/constantProduct/defaults.js +0 -5
  127. package/src/vpool-xyk-amm/constantProduct/getXY.js +0 -52
  128. package/src/vpool-xyk-amm/constantProduct/internal-types.js +0 -116
  129. package/src/vpool-xyk-amm/constantProduct/invariants.js +0 -43
  130. package/src/vpool-xyk-amm/constantProduct/swap.js +0 -272
  131. package/src/vpool-xyk-amm/constantProduct/types.js +0 -32
  132. package/src/vpool-xyk-amm/doublePool.js +0 -194
  133. package/src/vpool-xyk-amm/estimate.js +0 -155
  134. package/src/vpool-xyk-amm/multipoolMarketMaker.js +0 -520
  135. package/src/vpool-xyk-amm/params.js +0 -61
  136. package/src/vpool-xyk-amm/pool.js +0 -396
  137. package/src/vpool-xyk-amm/priceAuthority.js +0 -94
  138. package/src/vpool-xyk-amm/removeLiquidity.js +0 -31
  139. package/src/vpool-xyk-amm/singlePool.js +0 -73
  140. package/src/vpool-xyk-amm/swap.js +0 -69
  141. package/src/vpool-xyk-amm/types.js +0 -154
@@ -1,9 +1,11 @@
1
- // @ts-check
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: { zoe, bankManager, agoricNamesAdmin, bankMints },
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 [issuer, brand, runBrand] = await Promise.all([
132
- issuerP,
133
- E(issuerP).getBrand(),
134
- stableBrandP,
135
- ]);
136
- const kit = { mint: mintP, issuer, brand };
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 addPool(zoe, amm, issuer, keyword, brand, runBrand, runIssuer);
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
- { consume: { agoricNamesAdmin, zoe, priceAuthorityAdmin, priceAuthority } },
109
+ {
110
+ consume: {
111
+ agoricNamesAdmin,
112
+ startUpgradable,
113
+ priceAuthorityAdmin,
114
+ priceAuthority,
115
+ },
116
+ },
162
117
  { options: { interchainAssetOptions } },
163
118
  ) => {
164
- const { keyword, oracleBrand } = interchainAssetOptions;
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, runBrand],
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(runBrand),
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
- runBrand,
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
- const { publicFacet } = E.get(
228
- E(zoe).startInstance(scaledPriceAuthority, undefined, terms),
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
- E(publicFacet).getPriceAuthority(),
198
+ // @ts-expect-error The public facet should have getPriceAuthority
199
+ E(spaKit.publicFacet).getPriceAuthority(),
232
200
  interchainBrand,
233
- runBrand,
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: { vaultFactoryCreator, agoricNamesAdmin },
218
+ consume: { vaultFactoryKit, agoricNamesAdmin, auctioneerKit },
249
219
  brand: {
250
220
  consume: { [Stable.symbol]: stableP },
251
221
  },
252
222
  },
253
- { options: { interchainAssetOptions } },
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, 0n),
266
- // the rest of these are arbitrary, TBD by gov cttee
267
- interestRate: makeRatio(1n, stable),
268
- liquidationMargin: makeRatio(1n, stable),
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
- { interchainAssetOptions, scaledPriceAuthorityRef },
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
- zoe: true,
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
- vaultFactoryCreator: true,
324
- ammCreatorFacet: true,
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
- [voterInvitation, nullInvitation],
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: {