@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-fbe72e7.0.fbe72e7

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 (166) hide show
  1. package/README.md +6 -6
  2. package/package.json +46 -39
  3. package/scripts/build-bundles.js +5 -21
  4. package/src/auction/auctionBook.d.ts +147 -0
  5. package/src/auction/auctionBook.d.ts.map +1 -0
  6. package/src/auction/auctionBook.js +182 -151
  7. package/src/auction/auctionMath.d.ts +17 -0
  8. package/src/auction/auctionMath.d.ts.map +1 -0
  9. package/src/auction/auctionMath.js +81 -0
  10. package/src/auction/auctioneer.d.ts +70 -0
  11. package/src/auction/auctioneer.d.ts.map +1 -0
  12. package/src/auction/auctioneer.js +72 -59
  13. package/src/auction/offerBook.d.ts +46 -0
  14. package/src/auction/offerBook.d.ts.map +1 -0
  15. package/src/auction/offerBook.js +17 -12
  16. package/src/auction/params.d.ts +145 -0
  17. package/src/auction/params.d.ts.map +1 -0
  18. package/src/auction/params.js +11 -9
  19. package/src/auction/scheduleMath.d.ts +5 -0
  20. package/src/auction/scheduleMath.d.ts.map +1 -0
  21. package/src/auction/scheduleMath.js +18 -16
  22. package/src/auction/scheduler.d.ts +50 -0
  23. package/src/auction/scheduler.d.ts.map +1 -0
  24. package/src/auction/scheduler.js +53 -47
  25. package/src/auction/sortedOffers.d.ts +8 -0
  26. package/src/auction/sortedOffers.d.ts.map +1 -0
  27. package/src/auction/sortedOffers.js +10 -9
  28. package/src/auction/util.d.ts +31 -0
  29. package/src/auction/util.d.ts.map +1 -0
  30. package/src/auction/util.js +12 -6
  31. package/src/clientSupport.d.ts +168 -0
  32. package/src/clientSupport.d.ts.map +1 -0
  33. package/src/clientSupport.js +161 -98
  34. package/src/collectFees.d.ts +2 -0
  35. package/src/collectFees.d.ts.map +1 -0
  36. package/src/contractSupport.d.ts +28 -0
  37. package/src/contractSupport.d.ts.map +1 -0
  38. package/src/contractSupport.js +19 -13
  39. package/src/econCommitteeCharter.d.ts +43 -0
  40. package/src/econCommitteeCharter.d.ts.map +1 -0
  41. package/src/econCommitteeCharter.js +25 -20
  42. package/src/feeDistributor.d.ts +224 -0
  43. package/src/feeDistributor.d.ts.map +1 -0
  44. package/src/feeDistributor.js +41 -33
  45. package/src/index.d.ts +2 -0
  46. package/src/index.d.ts.map +1 -0
  47. package/src/index.js +1 -0
  48. package/src/interest-math.d.ts +4 -0
  49. package/src/interest-math.d.ts.map +1 -0
  50. package/src/interest-math.js +5 -1
  51. package/src/interest.d.ts +30 -0
  52. package/src/interest.d.ts.map +1 -0
  53. package/src/interest.js +25 -23
  54. package/src/price/README.md +14 -1
  55. package/src/price/fluxAggregatorContract.d.ts +71 -0
  56. package/src/price/fluxAggregatorContract.d.ts.map +1 -0
  57. package/src/price/fluxAggregatorContract.js +64 -55
  58. package/src/price/fluxAggregatorKit.d.ts +104 -0
  59. package/src/price/fluxAggregatorKit.d.ts.map +1 -0
  60. package/src/price/fluxAggregatorKit.js +55 -42
  61. package/src/price/priceOracleKit.d.ts +39 -0
  62. package/src/price/priceOracleKit.d.ts.map +1 -0
  63. package/src/price/priceOracleKit.js +17 -15
  64. package/src/price/roundsManager.d.ts +204 -0
  65. package/src/price/roundsManager.d.ts.map +1 -0
  66. package/src/price/roundsManager.js +132 -85
  67. package/src/proposals/README.md +2 -3
  68. package/src/proposals/add-auction.js +285 -0
  69. package/src/proposals/addAssetToVault.js +192 -40
  70. package/src/proposals/committee-proposal.js +25 -31
  71. package/src/proposals/core-proposal.js +9 -11
  72. package/src/proposals/deploy-price-feeds.js +341 -0
  73. package/src/proposals/econ-behaviors.js +84 -49
  74. package/src/proposals/price-feed-proposal.js +109 -51
  75. package/src/proposals/replace-fee-distributor.js +198 -0
  76. package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
  77. package/src/proposals/replaceElectorate.js +610 -0
  78. package/src/proposals/startEconCommittee.js +2 -2
  79. package/src/proposals/startPSM.js +44 -29
  80. package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
  81. package/src/proposals/upgrade-vaults.js +207 -0
  82. package/src/proposals/utils.d.ts +21 -0
  83. package/src/proposals/utils.d.ts.map +1 -0
  84. package/src/proposals/utils.js +66 -9
  85. package/src/proposals/withdraw-reserve-proposal.js +63 -0
  86. package/src/provisionPool.d.ts +69 -0
  87. package/src/provisionPool.d.ts.map +1 -0
  88. package/src/provisionPool.js +138 -0
  89. package/src/provisionPoolKit.d.ts +129 -0
  90. package/src/provisionPoolKit.d.ts.map +1 -0
  91. package/src/provisionPoolKit.js +608 -0
  92. package/src/psm/psm.d.ts +133 -0
  93. package/src/psm/psm.d.ts.map +1 -0
  94. package/src/psm/psm.js +85 -79
  95. package/src/psm/types-ambient.d.ts +2 -0
  96. package/src/psm/types-ambient.d.ts.map +1 -0
  97. package/src/psm/types-ambient.js +3 -0
  98. package/src/reserve/assetReserve.d.ts +58 -0
  99. package/src/reserve/assetReserve.d.ts.map +1 -0
  100. package/src/reserve/assetReserve.js +42 -34
  101. package/src/reserve/assetReserveKit.d.ts +103 -0
  102. package/src/reserve/assetReserveKit.d.ts.map +1 -0
  103. package/src/reserve/assetReserveKit.js +134 -32
  104. package/src/reserve/params.d.ts +16 -0
  105. package/src/reserve/params.d.ts.map +1 -0
  106. package/src/reserve/params.js +8 -2
  107. package/src/tokens.d.ts +3 -0
  108. package/src/tokens.d.ts.map +1 -0
  109. package/src/tokens.js +5 -0
  110. package/src/vaultFactory/burn.d.ts +2 -0
  111. package/src/vaultFactory/burn.d.ts.map +1 -0
  112. package/src/vaultFactory/burn.js +1 -1
  113. package/src/vaultFactory/liquidation.d.ts +25 -0
  114. package/src/vaultFactory/liquidation.d.ts.map +1 -0
  115. package/src/vaultFactory/liquidation.js +37 -24
  116. package/src/vaultFactory/math.d.ts +11 -0
  117. package/src/vaultFactory/math.d.ts.map +1 -0
  118. package/src/vaultFactory/math.js +11 -10
  119. package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
  120. package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
  121. package/src/vaultFactory/orderedVaultStore.js +9 -10
  122. package/src/vaultFactory/params.d.ts +143 -0
  123. package/src/vaultFactory/params.d.ts.map +1 -0
  124. package/src/vaultFactory/params.js +56 -25
  125. package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
  126. package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
  127. package/src/vaultFactory/prioritizedVaults.js +7 -4
  128. package/src/vaultFactory/proceeds.d.ts +35 -0
  129. package/src/vaultFactory/proceeds.d.ts.map +1 -0
  130. package/src/vaultFactory/proceeds.js +26 -18
  131. package/src/vaultFactory/storeUtils.d.ts +25 -0
  132. package/src/vaultFactory/storeUtils.d.ts.map +1 -0
  133. package/src/vaultFactory/storeUtils.js +10 -12
  134. package/src/vaultFactory/types-ambient.d.ts +137 -0
  135. package/src/vaultFactory/types-ambient.d.ts.map +1 -0
  136. package/src/vaultFactory/{types.js → types-ambient.js} +47 -44
  137. package/src/vaultFactory/vault.d.ts +344 -0
  138. package/src/vaultFactory/vault.d.ts.map +1 -0
  139. package/src/vaultFactory/vault.js +107 -100
  140. package/src/vaultFactory/vaultDirector.d.ts +347 -0
  141. package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
  142. package/src/vaultFactory/vaultDirector.js +94 -64
  143. package/src/vaultFactory/vaultFactory.d.ts +250 -0
  144. package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
  145. package/src/vaultFactory/vaultFactory.js +56 -33
  146. package/src/vaultFactory/vaultHolder.d.ts +170 -0
  147. package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
  148. package/src/vaultFactory/vaultHolder.js +14 -15
  149. package/src/vaultFactory/vaultKit.d.ts +33 -0
  150. package/src/vaultFactory/vaultKit.d.ts.map +1 -0
  151. package/src/vaultFactory/vaultKit.js +9 -4
  152. package/src/vaultFactory/vaultManager.d.ts +676 -0
  153. package/src/vaultFactory/vaultManager.d.ts.map +1 -0
  154. package/src/vaultFactory/vaultManager.js +286 -167
  155. package/CHANGELOG.md +0 -1041
  156. package/exported.js +0 -2
  157. package/scripts/add-collateral-core.js +0 -112
  158. package/scripts/deploy-contracts.js +0 -100
  159. package/scripts/init-core.js +0 -198
  160. package/scripts/invite-committee-core.js +0 -42
  161. package/scripts/manual-price-feed.js +0 -117
  162. package/scripts/price-feed-core.js +0 -104
  163. package/scripts/start-local-chain.sh +0 -84
  164. package/src/psm/types.js +0 -3
  165. package/src/typeGuards.js +0 -13
  166. package/src/vaultFactory/type-imports.js +0 -4
@@ -1,12 +1,23 @@
1
1
  // @jessie-check
2
+ // @ts-check
2
3
 
4
+ import { q } from '@endo/errors';
5
+ import { ToFarFunction } from '@endo/captp';
6
+ import { Far } from '@endo/marshal';
3
7
  import { AmountMath, AssetKind } from '@agoric/ertp';
4
- import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
5
8
  import { deeplyFulfilledObject } from '@agoric/internal';
6
- import { Stable } from '@agoric/vats/src/tokens.js';
9
+ import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
10
+ import { parseRatio } from '@agoric/ertp/src/ratio.js';
7
11
  import { E } from '@endo/far';
8
- import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
9
- import { reserveThenGetNames } from './utils.js';
12
+ import { Stable } from '@agoric/internal/src/tokens.js';
13
+ import { TimeMath } from '@agoric/time/src/timeMath.js';
14
+ import { makePromiseKit } from '@endo/promise-kit';
15
+
16
+ import {
17
+ oracleBrandFeedName,
18
+ reserveThenGetNames,
19
+ scaledPriceFeedName,
20
+ } from './utils.js';
10
21
 
11
22
  export * from './startPSM.js';
12
23
 
@@ -15,14 +26,18 @@ export * from './startPSM.js';
15
26
  * @property {string} [issuerBoardId]
16
27
  * @property {string} [denom]
17
28
  * @property {number} [decimalPlaces]
18
- * @property {string} [proposedName]
19
- * @property {string} keyword
20
- * @property {string} oracleBrand
29
+ * @property {string} keyword - used in regstering with reserve, vaultFactory
30
+ * @property {string} [issuerName] - used in agoricNames for compatibility:
31
+ * defaults to `keyword` if not provided
32
+ * @property {string} [proposedName] - defaults to `issuerName` if not provided
33
+ * @property {string} [oracleBrand] - defaults to `issuerName` if not provided
21
34
  * @property {number} [initialPrice]
22
35
  */
23
36
 
37
+ /** @import {EconomyBootstrapPowers} from './econ-behaviors.js' */
38
+
24
39
  /**
25
- * @param {EconomyBootstrapPowers} powers
40
+ * @param {BootstrapPowers} powers
26
41
  * @param {object} config
27
42
  * @param {object} config.options
28
43
  * @param {InterchainAssetOptions} config.options.interchainAssetOptions
@@ -31,18 +46,22 @@ export const publishInterchainAssetFromBoardId = async (
31
46
  { consume: { board, agoricNamesAdmin } },
32
47
  { options: { interchainAssetOptions } },
33
48
  ) => {
34
- const { issuerBoardId, keyword } = interchainAssetOptions;
49
+ const {
50
+ issuerBoardId,
51
+ keyword,
52
+ issuerName = keyword,
53
+ } = interchainAssetOptions;
35
54
  // Incompatible with denom.
36
55
  assert.equal(interchainAssetOptions.denom, undefined);
37
56
  assert.typeof(issuerBoardId, 'string');
38
- assert.typeof(keyword, 'string');
57
+ assert.typeof(issuerName, 'string');
39
58
 
40
- const issuer = await E(board).getValue(issuerBoardId);
59
+ const issuer = /** @type {Issuer} */ (await E(board).getValue(issuerBoardId));
41
60
  const brand = await E(issuer).getBrand();
42
61
 
43
62
  return Promise.all([
44
- E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer),
45
- E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand),
63
+ E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(issuerName, issuer),
64
+ E(E(agoricNamesAdmin).lookupAdmin('brand')).update(issuerName, brand),
46
65
  ]);
47
66
  };
48
67
 
@@ -61,18 +80,23 @@ export const publishInterchainAssetFromBank = async (
61
80
  },
62
81
  { options: { interchainAssetOptions } },
63
82
  ) => {
64
- const { denom, decimalPlaces, proposedName, keyword } =
65
- interchainAssetOptions;
83
+ const {
84
+ denom,
85
+ decimalPlaces,
86
+ keyword,
87
+ issuerName = keyword,
88
+ proposedName = keyword,
89
+ } = interchainAssetOptions;
66
90
 
67
91
  // Incompatible with issuerBoardId.
68
92
  assert.equal(interchainAssetOptions.issuerBoardId, undefined);
69
93
  assert.typeof(denom, 'string');
70
- assert.typeof(keyword, 'string');
71
94
  assert.typeof(decimalPlaces, 'number');
95
+ assert.typeof(issuerName, 'string');
72
96
  assert.typeof(proposedName, 'string');
73
97
 
74
98
  const terms = {
75
- keyword,
99
+ keyword: issuerName, // "keyword" is a misnomer in mintHolder terms
76
100
  assetKind: AssetKind.NAT,
77
101
  displayInfo: {
78
102
  decimalPlaces,
@@ -82,20 +106,20 @@ export const publishInterchainAssetFromBank = async (
82
106
 
83
107
  const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
84
108
  installation: mintHolder,
85
- label: keyword,
109
+ label: issuerName,
86
110
  privateArgs: undefined,
87
111
  terms,
88
112
  });
89
113
 
90
114
  const brand = await E(issuer).getBrand();
91
- const kit = { mint, issuer, brand };
115
+ const kit = /** @type {IssuerKit<'nat'>} */ ({ mint, issuer, brand });
92
116
 
93
117
  await E(E.get(reserveKit).creatorFacet).addIssuer(issuer, keyword);
94
118
 
95
119
  await Promise.all([
96
- E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer),
97
- E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand),
98
- E(bankManager).addAsset(denom, keyword, proposedName, kit),
120
+ E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(issuerName, issuer),
121
+ E(E(agoricNamesAdmin).lookupAdmin('brand')).update(issuerName, brand),
122
+ E(bankManager).addAsset(denom, issuerName, proposedName, kit),
99
123
  ]);
100
124
  };
101
125
 
@@ -105,7 +129,7 @@ export const publishInterchainAssetFromBank = async (
105
129
  * @param {object} config.options
106
130
  * @param {InterchainAssetOptions} config.options.interchainAssetOptions
107
131
  */
108
- export const registerScaledPriceAuthority = async (
132
+ export const startScaledPriceAuthority = async (
109
133
  {
110
134
  consume: {
111
135
  agoricNamesAdmin,
@@ -118,10 +142,11 @@ export const registerScaledPriceAuthority = async (
118
142
  ) => {
119
143
  const {
120
144
  keyword,
121
- oracleBrand,
145
+ issuerName = keyword,
146
+ oracleBrand = issuerName,
122
147
  initialPrice: initialPriceRaw,
123
148
  } = interchainAssetOptions;
124
- assert.typeof(keyword, 'string');
149
+ assert.typeof(issuerName, 'string');
125
150
  assert.typeof(oracleBrand, 'string');
126
151
 
127
152
  const [
@@ -132,7 +157,7 @@ export const registerScaledPriceAuthority = async (
132
157
  ] = await Promise.all([
133
158
  priceAuthority,
134
159
  reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('brand'), [
135
- keyword,
160
+ issuerName,
136
161
  'IST',
137
162
  ]),
138
163
  reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [
@@ -144,8 +169,9 @@ export const registerScaledPriceAuthority = async (
144
169
  ]),
145
170
  ]);
146
171
 
172
+ // TODO get unit amounts elsewhere https://github.com/Agoric/agoric-sdk/issues/10235
147
173
  // We need "unit amounts" of each brand in order to get the ratios right. You
148
- // can ignore decimalPlaces when adding and subtracting a brand with itself,
174
+ // can ignore unit amounts when adding and subtracting a brand with itself,
149
175
  // but not when creating ratios.
150
176
  const getDecimalP = async brand => {
151
177
  const displayInfo = E(brand).getDisplayInfo();
@@ -188,9 +214,11 @@ export const registerScaledPriceAuthority = async (
188
214
  }),
189
215
  );
190
216
 
217
+ const label = scaledPriceFeedName(issuerName);
218
+
191
219
  const spaKit = await E(startUpgradable)({
192
220
  installation: scaledPriceAuthority,
193
- label: `scaledPriceAuthority-${keyword}`,
221
+ label,
194
222
  terms,
195
223
  });
196
224
 
@@ -201,9 +229,100 @@ export const registerScaledPriceAuthority = async (
201
229
  stableBrand,
202
230
  true, // force
203
231
  );
232
+
233
+ return spaKit;
234
+ };
235
+
236
+ /**
237
+ * @param {BootstrapPowers} powers
238
+ * @param {object} config
239
+ * @param {object} config.options
240
+ */
241
+ export const registerScaledPriceAuthority = async (powers, { options }) => {
242
+ const {
243
+ instance: { produce: produceInstance },
244
+ } = powers;
245
+
246
+ const { keyword, issuerName = keyword } = options.interchainAssetOptions;
247
+
248
+ const spaKit = await startScaledPriceAuthority(powers, { options });
249
+
250
+ const label = scaledPriceFeedName(issuerName);
251
+
252
+ // publish into agoricNames so that others can await its presence.
253
+ // This must stay after registerPriceAuthority above so it's evidence of registration.
254
+ // eslint-disable-next-line no-restricted-syntax -- computed property
255
+ produceInstance[label].resolve(spaKit.instance);
204
256
  };
205
257
 
206
- /** @typedef {import('./econ-behaviors.js').EconomyBootstrapPowers} EconomyBootstrapPowers */
258
+ // wait a short while after end to allow things to settle
259
+ const BUFFER = 5n * 60n;
260
+ // let's insist on 20 minutes leeway for running the scripts
261
+ const COMPLETION = 20n * 60n;
262
+
263
+ /**
264
+ * This function works around an issue identified in #8307 and #8296, and fixed
265
+ * in #8301. The fix is needed until #8301 makes it into production.
266
+ *
267
+ * If there is a liveSchedule, 1) run now if start is far enough away,
268
+ * otherwise, 2) run after endTime. If neither liveSchedule nor nextSchedule is
269
+ * defined, 3) run now. If there is only a nextSchedule, 4) run now if startTime
270
+ * is far enough away, else 5) run after endTime
271
+ *
272
+ * @param {import('../auction/scheduler.js').FullSchedule} schedules
273
+ * @param {ERef<import('@agoric/time').TimerService>} timer
274
+ * @param {() => void} thunk
275
+ */
276
+ const whenQuiescent = async (schedules, timer, thunk) => {
277
+ const { nextAuctionSchedule, liveAuctionSchedule } = schedules;
278
+ const now = await E(timer).getCurrentTimestamp();
279
+
280
+ const waker = Far('addAssetWaker', { wake: () => thunk() });
281
+
282
+ if (liveAuctionSchedule) {
283
+ const safeStart = TimeMath.subtractAbsRel(
284
+ liveAuctionSchedule.startTime,
285
+ COMPLETION,
286
+ );
287
+
288
+ if (TimeMath.compareAbs(safeStart, now) < 0) {
289
+ // case 2
290
+ console.warn(
291
+ `Add Asset after live schedule's endtime: ${q(
292
+ liveAuctionSchedule.endTime,
293
+ )}`,
294
+ );
295
+
296
+ return E(timer).setWakeup(
297
+ TimeMath.addAbsRel(liveAuctionSchedule.endTime, BUFFER),
298
+ waker,
299
+ );
300
+ }
301
+ }
302
+
303
+ if (!liveAuctionSchedule && nextAuctionSchedule) {
304
+ const safeStart = TimeMath.subtractAbsRel(
305
+ nextAuctionSchedule.startTime,
306
+ COMPLETION,
307
+ );
308
+ if (TimeMath.compareAbs(safeStart, now) < 0) {
309
+ // case 5
310
+ console.warn(
311
+ `Add Asset after next schedule's endtime: ${q(
312
+ nextAuctionSchedule.endTime,
313
+ )}`,
314
+ );
315
+ return E(timer).setWakeup(
316
+ TimeMath.addAbsRel(nextAuctionSchedule.endTime, BUFFER),
317
+ waker,
318
+ );
319
+ }
320
+ }
321
+
322
+ // cases 1, 3, and 4 fall through to here.
323
+ console.warn(`Add Asset immediately`, thunk);
324
+ return thunk();
325
+ };
207
326
 
208
327
  /**
209
328
  * @param {EconomyBootstrapPowers} powers
@@ -215,10 +334,16 @@ export const registerScaledPriceAuthority = async (
215
334
  */
216
335
  export const addAssetToVault = async (
217
336
  {
218
- consume: { vaultFactoryKit, agoricNamesAdmin, auctioneerKit },
337
+ consume: {
338
+ vaultFactoryKit,
339
+ agoricNamesAdmin,
340
+ auctioneerKit,
341
+ chainTimerService,
342
+ },
219
343
  brand: {
220
344
  consume: { [Stable.symbol]: stableP },
221
345
  },
346
+ instance: { consume: consumeInstance },
222
347
  },
223
348
  {
224
349
  options: {
@@ -231,17 +356,43 @@ export const addAssetToVault = async (
231
356
  },
232
357
  },
233
358
  ) => {
234
- const { keyword, oracleBrand } = interchainAssetOptions;
359
+ const {
360
+ keyword,
361
+ issuerName = keyword,
362
+ oracleBrand = issuerName,
363
+ } = interchainAssetOptions;
235
364
  assert.typeof(keyword, 'string');
365
+ assert.typeof(issuerName, 'string');
236
366
  assert.typeof(oracleBrand, 'string');
237
367
  const [interchainIssuer] = await reserveThenGetNames(
238
368
  E(agoricNamesAdmin).lookupAdmin('issuer'),
239
- [keyword],
369
+ [issuerName],
240
370
  );
241
371
 
372
+ // don't add the collateral offering to vaultFactory until its price feed is available
373
+ // eslint-disable-next-line no-restricted-syntax -- allow this computed property
374
+ await consumeInstance[oracleBrandFeedName(oracleBrand, 'USD')];
375
+ // await also the negotiable brand
376
+ // eslint-disable-next-line no-restricted-syntax -- allow this computed property
377
+ await consumeInstance[scaledPriceFeedName(issuerName)];
378
+
379
+ const auctioneerCreator = E.get(auctioneerKit).creatorFacet;
380
+ const schedules = await E(auctioneerCreator).getSchedule();
381
+
382
+ const finishPromiseKit = makePromiseKit();
383
+ const addBrandThenResolve = ToFarFunction('addBrandThenResolve', async () => {
384
+ await E(auctioneerCreator).addBrand(interchainIssuer, keyword);
385
+ finishPromiseKit.resolve(undefined);
386
+ });
387
+
388
+ // schedules actions on a timer (or does it immediately).
389
+ // finishPromiseKit signals completion.
390
+ void whenQuiescent(schedules, chainTimerService, addBrandThenResolve);
391
+ await finishPromiseKit.promise;
392
+
242
393
  const stable = await stableP;
243
394
  const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
244
- await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
395
+ await E(vaultFactoryCreator).addVaultType(interchainIssuer, keyword, {
245
396
  debtLimit: AmountMath.make(stable, BigInt(debtLimitValue)),
246
397
  interestRate: makeRatio(interestRateValue, stable),
247
398
  // The rest of these we use safe defaults.
@@ -253,8 +404,6 @@ export const addAssetToVault = async (
253
404
  mintFee: makeRatio(50n, stable, 10_000n),
254
405
  liquidationPenalty: makeRatio(1n, stable),
255
406
  });
256
- const auctioneerCreator = E.get(auctioneerKit).creatorFacet;
257
- await E(auctioneerCreator).addBrand(interchainIssuer, keyword);
258
407
  };
259
408
 
260
409
  export const getManifestForAddAssetToVault = (
@@ -286,9 +435,7 @@ export const getManifestForAddAssetToVault = (
286
435
  consume: {
287
436
  bankManager: true,
288
437
  agoricNamesAdmin: true,
289
- bankMints: true,
290
438
  reserveKit: true,
291
- vBankKits: true,
292
439
  startUpgradable: true,
293
440
  },
294
441
  produce: { bankMints: true, vBankKits: true },
@@ -303,10 +450,9 @@ export const getManifestForAddAssetToVault = (
303
450
  startUpgradable: true,
304
451
  priceAuthorityAdmin: true,
305
452
  priceAuthority: true,
306
- scaledPriceAuthorityKits: true,
307
453
  },
308
- produce: {
309
- scaledPriceAuthorityKits: true,
454
+ instance: {
455
+ produce: true,
310
456
  },
311
457
  installation: {
312
458
  consume: { scaledPriceAuthority: true },
@@ -317,10 +463,16 @@ export const getManifestForAddAssetToVault = (
317
463
  auctioneerKit: 'auctioneer',
318
464
  vaultFactoryKit: 'vaultFactory',
319
465
  agoricNamesAdmin: true,
466
+ chainTimerService: true,
320
467
  },
321
468
  brand: {
322
469
  consume: { [Stable.symbol]: true },
323
470
  },
471
+ instance: {
472
+ // allow any instance because the AGORIC_INSTANCE_NAME of
473
+ // priceFeedOptions cannot be known statically.
474
+ consume: true,
475
+ },
324
476
  },
325
477
  },
326
478
  installations: {
@@ -4,14 +4,14 @@ import { reserveThenDeposit } from './utils.js';
4
4
 
5
5
  const { values } = Object;
6
6
 
7
- /** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
7
+ /** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
8
8
  const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
9
9
 
10
10
  const EC_HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
11
11
 
12
12
  /**
13
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
14
- * @param {{ options: { voterAddresses: Record<string, string> }}} param1
13
+ * @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
14
+ * @param {{ options: { voterAddresses: Record<string, string> } }} param1
15
15
  */
16
16
  export const inviteCommitteeMembers = async (
17
17
  {
@@ -26,18 +26,14 @@ export const inviteCommitteeMembers = async (
26
26
 
27
27
  const highPrioritySendersManager = await consume.highPrioritySendersManager;
28
28
 
29
- /**
30
- * @param {[string, Promise<Invitation>][]} addrInvitations
31
- */
29
+ /** @param {[string, Promise<Invitation>][]} addrInvitations */
32
30
  const distributeInvitations = async addrInvitations => {
33
31
  await Promise.all(
34
32
  addrInvitations.map(async ([addr, invitationP]) => {
35
- await reserveThenDeposit(
36
- `econ committee member ${addr}`,
37
- namesByAddressAdmin,
38
- addr,
39
- [invitationP],
40
- );
33
+ const debugName = `econ committee member ${addr}`;
34
+ await reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
35
+ invitationP,
36
+ ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
41
37
  if (highPrioritySendersManager) {
42
38
  await E(highPrioritySendersManager).add(
43
39
  EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
@@ -48,14 +44,14 @@ export const inviteCommitteeMembers = async (
48
44
  );
49
45
  };
50
46
 
51
- await distributeInvitations(zip(values(voterAddresses), invitations));
47
+ // This doesn't resolve until the committee members create their smart wallets.
48
+ // Don't block bootstrap on it.
49
+ void distributeInvitations(zip(values(voterAddresses), invitations));
52
50
  };
53
51
 
54
52
  harden(inviteCommitteeMembers);
55
53
 
56
- /**
57
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
58
- */
54
+ /** @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers */
59
55
  export const startEconCharter = async ({
60
56
  consume: { zoe },
61
57
  produce: { econCharterKit },
@@ -76,7 +72,7 @@ export const startEconCharter = async ({
76
72
  }),
77
73
  );
78
74
 
79
- /** @type {Promise<import('./econ-behaviors').EconCharterStartResult>} */
75
+ /** @type {Promise<import('./econ-behaviors.js').EconCharterStartResult>} */
80
76
  const startResult = E(zoe).startInstance(
81
77
  charterInstall,
82
78
  undefined,
@@ -92,7 +88,7 @@ harden(startEconCharter);
92
88
  /**
93
89
  * Introduce charter to governed creator facets.
94
90
  *
95
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
91
+ * @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
96
92
  */
97
93
  export const addGovernorsToEconCharter = async ({
98
94
  consume: { reserveKit, vaultFactoryKit, econCharterKit, auctioneerKit },
@@ -130,8 +126,8 @@ export const addGovernorsToEconCharter = async ({
130
126
  harden(addGovernorsToEconCharter);
131
127
 
132
128
  /**
133
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
134
- * @param {{ options: { voterAddresses: Record<string, string> }}} param1
129
+ * @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
130
+ * @param {{ options: { voterAddresses: Record<string, string> } }} param1
135
131
  */
136
132
  export const inviteToEconCharter = async (
137
133
  { consume: { namesByAddressAdmin, econCharterKit } },
@@ -139,15 +135,15 @@ export const inviteToEconCharter = async (
139
135
  ) => {
140
136
  const { creatorFacet } = E.get(econCharterKit);
141
137
 
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
- ),
138
+ // This doesn't resolve until the committee members create their smart wallets.
139
+ // Don't block bootstrap on it.
140
+ void Promise.all(
141
+ values(voterAddresses).map(async addr => {
142
+ const debugName = `econ charter member ${addr}`;
143
+ reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
144
+ E(creatorFacet).makeCharterMemberInvitation(),
145
+ ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
146
+ }),
151
147
  );
152
148
  };
153
149
 
@@ -180,8 +176,6 @@ export const getManifestForInviteCommittee = async (
180
176
  [addGovernorsToEconCharter.name]: {
181
177
  consume: {
182
178
  auctioneerKit: t,
183
- reserveGovernorCreatorFacet: t,
184
- vaultFactoryGovernorCreator: t,
185
179
  econCharterKit: t,
186
180
  zoe: t,
187
181
  agoricNames: t,
@@ -1,23 +1,19 @@
1
1
  // @jessie-check
2
2
 
3
- import { Stable } from '@agoric/vats/src/tokens.js';
3
+ import { Stable } from '@agoric/internal/src/tokens.js';
4
4
  import * as econBehaviors from './econ-behaviors.js';
5
5
  import { ECON_COMMITTEE_MANIFEST } from './startEconCommittee.js';
6
6
 
7
7
  export * from './econ-behaviors.js';
8
- // @ts-expect-error Module './econ-behaviors.js' has already exported a member
9
- // named 'EconomyBootstrapPowers'.
10
- export * from './startPSM.js'; // eslint-disable-line import/export
11
- export * from './startEconCommittee.js'; // eslint-disable-line import/export
8
+ export * from './startPSM.js';
9
+ export * from './startEconCommittee.js';
12
10
 
13
11
  // XXX all the startInstance() should use startUpgradable()
14
12
  // or startGovernedUpgradeable() but that would
15
13
  // require updating a lot of tests. So for now, we just
16
14
  // grab the kits afterward and store them.
17
15
 
18
- /**
19
- * @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
20
- */
16
+ /** @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers */
21
17
  export const storeInterContractStartKits = async ({
22
18
  consume: {
23
19
  contractKits,
@@ -31,13 +27,15 @@ export const storeInterContractStartKits = async ({
31
27
  },
32
28
  }) => {
33
29
  /**
34
- * @param {Promise<MapStore<string, {instance: Instance}>>} storeP
35
- * @param {Promise<{instance: Instance}>[]} kitPs
30
+ * @param {Promise<MapStore<Instance, { instance: Instance }>>} storeP
31
+ * @param {Promise<{ instance: Instance }>[]} kitPs
36
32
  */
37
33
  const storeAll = async (storeP, kitPs) => {
38
34
  const store = await storeP;
39
35
  const kits = await Promise.all(kitPs);
40
- kits.forEach(kit => store.init(kit.instance, kit));
36
+ for (const kit of kits) {
37
+ store.init(kit.instance, kit);
38
+ }
41
39
  };
42
40
 
43
41
  await storeAll(contractKits, [