@agoric/inter-protocol 0.13.2-dev-606cbd2.0 → 0.13.2-dev-8d17cce.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/bundles/bundle-auctioneer-js-meta.json +123 -119
  2. package/bundles/bundle-auctioneer.js +1 -1
  3. package/bundles/bundle-econCommitteeCharter-js-meta.json +71 -71
  4. package/bundles/bundle-econCommitteeCharter.js +1 -1
  5. package/bundles/bundle-feeDistributor-js-meta.json +59 -59
  6. package/bundles/bundle-feeDistributor.js +1 -1
  7. package/bundles/bundle-fluxAggregatorKit-js-meta.json +143 -139
  8. package/bundles/bundle-fluxAggregatorKit.js +1 -1
  9. package/bundles/bundle-psm-js-meta.json +136 -132
  10. package/bundles/bundle-psm.js +1 -1
  11. package/bundles/bundle-reserve-js-meta.json +115 -111
  12. package/bundles/bundle-reserve.js +1 -1
  13. package/bundles/bundle-scaledPriceAuthority-js-meta.json +125 -121
  14. package/bundles/bundle-scaledPriceAuthority.js +1 -1
  15. package/bundles/bundle-vaultFactory-js-meta.json +188 -184
  16. package/bundles/bundle-vaultFactory.js +1 -1
  17. package/package.json +17 -17
  18. package/scripts/add-collateral-core.js +2 -0
  19. package/scripts/init-core.js +1 -0
  20. package/scripts/invite-committee-core.js +1 -0
  21. package/scripts/price-feed-core.js +1 -0
  22. package/src/auction/auctionBook.js +11 -11
  23. package/src/auction/auctioneer.js +15 -11
  24. package/src/auction/params.js +4 -4
  25. package/src/auction/scheduleMath.js +77 -32
  26. package/src/auction/scheduler.js +191 -79
  27. package/src/auction/util.js +7 -0
  28. package/src/clientSupport.js +1 -2
  29. package/src/price/fluxAggregatorContract.js +29 -6
  30. package/src/proposals/addAssetToVault.js +6 -34
  31. package/src/proposals/committee-proposal.js +9 -9
  32. package/src/proposals/core-proposal.js +58 -1
  33. package/src/proposals/econ-behaviors.js +56 -45
  34. package/src/proposals/price-feed-proposal.js +9 -21
  35. package/src/proposals/startEconCommittee.js +14 -6
  36. package/src/proposals/startPSM.js +51 -34
  37. package/src/psm/psm.js +11 -6
  38. package/src/reserve/assetReserveKit.js +1 -1
  39. package/src/vaultFactory/liquidation.js +168 -33
  40. package/src/vaultFactory/vault.js +5 -4
  41. package/src/vaultFactory/vaultDirector.js +27 -17
  42. package/src/vaultFactory/vaultFactory.js +26 -11
  43. package/src/vaultFactory/vaultManager.js +139 -95
@@ -2,14 +2,22 @@ import { E } from '@endo/eventual-send';
2
2
  import { TimeMath } from '@agoric/time';
3
3
  import { Far } from '@endo/marshal';
4
4
  import { makeTracer } from '@agoric/internal';
5
+ import { observeIteration, subscribeEach } from '@agoric/notifier';
5
6
 
6
- import { AuctionState } from './util.js';
7
- import { nextDescendingStepTime, computeRoundTiming } from './scheduleMath.js';
7
+ import { AuctionState, makeCancelTokenMaker } from './util.js';
8
+ import {
9
+ computeRoundTiming,
10
+ nextDescendingStepTime,
11
+ timeVsSchedule,
12
+ } from './scheduleMath.js';
8
13
 
9
- const { Fail, quote: q } = assert;
14
+ const { details: X, Fail, quote: q } = assert;
10
15
 
11
16
  const trace = makeTracer('SCHED', false);
12
17
 
18
+ // If the startAuction wakeup is no more than 5 minutes late, go ahead with it.
19
+ const MAX_LATE_TICK = 300n;
20
+
13
21
  /**
14
22
  * @file The scheduler is presumed to be quiescent between auction rounds. Each
15
23
  * Auction round consists of a sequence of steps with decreasing prices. There
@@ -28,10 +36,8 @@ const trace = makeTracer('SCHED', false);
28
36
  * progress. It would take additional work on the manual timer to test this
29
37
  * thoroughly.
30
38
  */
31
- const makeCancelToken = () => {
32
- let tokenCount = 1;
33
- return Far(`cancelToken${(tokenCount += 1)}`, {});
34
- };
39
+
40
+ const makeCancelToken = makeCancelTokenMaker('scheduler');
35
41
 
36
42
  /**
37
43
  * @typedef {object} AuctionDriver
@@ -44,19 +50,29 @@ const makeCancelToken = () => {
44
50
  /**
45
51
  * @typedef {object} ScheduleNotification
46
52
  *
47
- * @property {Timestamp | undefined} activeStartTime start time of current
53
+ * @property {Timestamp | null} activeStartTime start time of current
48
54
  * auction if auction is active
49
- * @property {Timestamp} nextStartTime start time of next auction
50
- * @property {Timestamp} nextDescendingStepTime when the next descending step
55
+ * @property {Timestamp | null} nextStartTime start time of next auction
56
+ * @property {Timestamp | null} nextDescendingStepTime when the next descending step
51
57
  * will take place
52
58
  */
53
59
 
60
+ const safelyComputeRoundTiming = (params, baseTime) => {
61
+ try {
62
+ return computeRoundTiming(params, baseTime);
63
+ } catch (e) {
64
+ console.error('🚨 No Next Auction', e);
65
+ return null;
66
+ }
67
+ };
68
+
54
69
  /**
55
70
  * @param {AuctionDriver} auctionDriver
56
71
  * @param {import('@agoric/time/src/types').TimerService} timer
57
- * @param {Awaited<import('./params.js').AuctionParamManaager>} params
72
+ * @param {Awaited<import('./params.js').AuctionParamManager>} params
58
73
  * @param {import('@agoric/time/src/types').TimerBrand} timerBrand
59
74
  * @param {import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<ScheduleNotification>} scheduleRecorder
75
+ * @param {StoredSubscription<GovernanceSubscriptionState>} paramUpdateSubscription
60
76
  */
61
77
  export const makeScheduler = async (
62
78
  auctionDriver,
@@ -64,21 +80,22 @@ export const makeScheduler = async (
64
80
  params,
65
81
  timerBrand,
66
82
  scheduleRecorder,
83
+ paramUpdateSubscription,
67
84
  ) => {
68
85
  /**
69
86
  * live version is defined when an auction is active.
70
87
  *
71
- * @type {Schedule | undefined}
88
+ * @type {Schedule | null}
72
89
  */
73
- let liveSchedule;
90
+ let liveSchedule = null;
74
91
 
75
- /** @returns {Promise<{ now: Timestamp, nextSchedule: Schedule }>} */
92
+ /** @returns {Promise<{ now: Timestamp, nextSchedule: Schedule | null }>} */
76
93
  const initializeNextSchedule = async () => {
77
94
  return E.when(
78
95
  // XXX manualTimer returns a bigint, not a timeRecord.
79
96
  E(timer).getCurrentTimestamp(),
80
97
  now => {
81
- const nextSchedule = computeRoundTiming(
98
+ const nextSchedule = safelyComputeRoundTiming(
82
99
  params,
83
100
  TimeMath.coerceTimestampRecord(now, timerBrand),
84
101
  );
@@ -103,66 +120,105 @@ export const makeScheduler = async (
103
120
  */
104
121
  const publishSchedule = () => {
105
122
  const sched = harden({
106
- activeStartTime: liveSchedule?.startTime,
107
- nextStartTime: nextSchedule?.startTime,
123
+ activeStartTime: liveSchedule?.startTime || null,
124
+ nextStartTime: nextSchedule?.startTime || null,
108
125
  nextDescendingStepTime: nextDescendingStepTime(
109
126
  liveSchedule,
110
127
  nextSchedule,
111
128
  now,
112
129
  ),
113
130
  });
114
- scheduleRecorder.write(sched);
131
+ return scheduleRecorder.write(sched);
115
132
  };
116
133
 
117
134
  /**
118
- * @param {Schedule | undefined} schedule
135
+ * @param {Schedule | null} schedule
136
+ * @returns {Promise<void>}
119
137
  */
120
- const clockTick = schedule => {
138
+ const clockTick = async schedule => {
121
139
  trace('clockTick', schedule?.startTime, now);
122
140
  if (!schedule) {
123
141
  return;
124
142
  }
125
143
 
126
- if (
127
- TimeMath.compareAbs(now, schedule.startTime) >= 0 &&
128
- TimeMath.compareAbs(now, schedule.endTime) <= 0
129
- ) {
130
- if (auctionState !== AuctionState.ACTIVE) {
131
- auctionState = AuctionState.ACTIVE;
132
- auctionDriver.startRound();
133
- } else {
134
- auctionDriver.reducePriceAndTrade();
135
- }
136
- }
137
-
138
- if (TimeMath.compareAbs(now, schedule.endTime) >= 0) {
144
+ /** @type {() => void} */
145
+ const finishAuctionRound = () => {
139
146
  auctionState = AuctionState.WAITING;
140
-
141
147
  auctionDriver.finalize();
142
148
 
143
- if (!nextSchedule) throw Fail`nextSchedule not defined`;
144
-
145
- // only recalculate the next schedule at this point if the lock time has
146
- // not been reached.
147
- const nextLock = nextSchedule.lockTime;
148
- if (nextLock && TimeMath.compareAbs(now, nextLock) < 0) {
149
- const afterNow = TimeMath.addAbsRel(
150
- now,
151
- TimeMath.coerceRelativeTimeRecord(1n, timerBrand),
149
+ if (nextSchedule) {
150
+ // only recalculate the next schedule at this point if the lock time has
151
+ // not been reached.
152
+ const nextLock = nextSchedule.lockTime;
153
+ if (nextLock && TimeMath.compareAbs(now, nextLock) < 0) {
154
+ const afterNow = TimeMath.addAbsRel(
155
+ now,
156
+ TimeMath.coerceRelativeTimeRecord(1n, timerBrand),
157
+ );
158
+ nextSchedule = safelyComputeRoundTiming(params, afterNow);
159
+ }
160
+ } else {
161
+ console.error(
162
+ '🛠️ finishAuctionRound without scheduling the next; repair with new auctioneer params',
152
163
  );
153
- nextSchedule = computeRoundTiming(params, afterNow);
154
164
  }
155
- liveSchedule = undefined;
156
165
 
166
+ liveSchedule = null;
167
+
168
+ // Async because a remote call. In rare event of failure, wakeup is robust.
157
169
  void E(timer).cancel(stepCancelToken);
170
+ };
171
+
172
+ const advanceRound = () => {
173
+ if (auctionState === AuctionState.ACTIVE) {
174
+ auctionDriver.reducePriceAndTrade();
175
+ } else {
176
+ auctionState = AuctionState.ACTIVE;
177
+ try {
178
+ auctionDriver.startRound();
179
+ // This has been observed to fail because prices hadn't been locked.
180
+ // This may be an issue about timing during chain start-up.
181
+ } catch (e) {
182
+ console.error(
183
+ assert.error(
184
+ 'Unable to start auction cleanly. skipping this auction round.',
185
+ ),
186
+ );
187
+ finishAuctionRound();
188
+
189
+ return false;
190
+ }
191
+ }
192
+ return true;
193
+ };
194
+
195
+ switch (timeVsSchedule(now, schedule)) {
196
+ case 'before':
197
+ break;
198
+ case 'during':
199
+ advanceRound();
200
+ break;
201
+ case 'endExactly':
202
+ if (advanceRound()) {
203
+ finishAuctionRound();
204
+ }
205
+ break;
206
+ case 'after':
207
+ await finishAuctionRound();
208
+ break;
209
+ default:
210
+ Fail`invalid case`;
158
211
  }
159
212
 
160
- publishSchedule();
213
+ void publishSchedule();
161
214
  };
162
215
 
163
- // schedule the wakeups for the steps of this round
164
- const scheduleSteps = () => {
165
- if (!liveSchedule) throw Fail`liveSchedule not defined`;
216
+ // set wakeups for the steps of this round
217
+ const queueLiveSchedule = () => {
218
+ if (!liveSchedule) {
219
+ console.error('🚨 queueLiveSchedule called with no liveSchedule');
220
+ return;
221
+ }
166
222
 
167
223
  const { startTime } = liveSchedule;
168
224
  trace('START ', startTime);
@@ -172,7 +228,7 @@ export const makeScheduler = async (
172
228
  ? TimeMath.subtractAbsAbs(startTime, now)
173
229
  : TimeMath.subtractAbsAbs(startTime, startTime);
174
230
 
175
- trace('repeating', now, delayFromNow, startTime);
231
+ trace('queueLiveSchedule repeating', now, delayFromNow, startTime);
176
232
 
177
233
  void E(timer).repeatAfter(
178
234
  delayFromNow,
@@ -181,7 +237,7 @@ export const makeScheduler = async (
181
237
  wake(time) {
182
238
  setTimeMonotonically(time);
183
239
  trace('wake step', now);
184
- clockTick(liveSchedule);
240
+ void clockTick(liveSchedule);
185
241
  },
186
242
  }),
187
243
  stepCancelToken,
@@ -197,11 +253,11 @@ export const makeScheduler = async (
197
253
  wake(time) {
198
254
  setTimeMonotonically(time);
199
255
  // eslint-disable-next-line no-use-before-define
200
- void startAuction();
256
+ return startAuction();
201
257
  },
202
258
  }),
203
259
  );
204
- publishSchedule();
260
+ void publishSchedule();
205
261
  };
206
262
 
207
263
  // schedule a wakeup to lock prices
@@ -218,43 +274,99 @@ export const makeScheduler = async (
218
274
  );
219
275
  };
220
276
 
277
+ const relativeTime = t => TimeMath.coerceRelativeTimeRecord(t, timerBrand);
278
+
221
279
  const startAuction = async () => {
222
280
  !liveSchedule || Fail`can't start an auction round while one is active`;
223
281
 
224
- assert(nextSchedule);
282
+ if (!nextSchedule) {
283
+ console.error(
284
+ assert.error(X`tried to start auction when none is scheduled`),
285
+ );
286
+ return;
287
+ }
288
+
225
289
  // The clock tick may have arrived too late to trigger the next scheduled
226
290
  // round, for example because of a chain halt. When this happens the oracle
227
291
  // quote may out of date and so must be ignored. Recover by returning
228
- // deposits and scheduling the next round.
229
- if (TimeMath.compareAbs(now, nextSchedule.startTime) > 0) {
230
- console.warn(
231
- `Auction time jumped to ${q(now)} before next scheduled start ${q(
232
- nextSchedule.startTime,
233
- )}. Skipping that round.`,
234
- );
235
- nextSchedule = computeRoundTiming(params, now);
292
+ // deposits and scheduling the next round. If it's only a little late,
293
+ // continue with auction, just starting late.
294
+ const nominalStart = TimeMath.subtractAbsRel(
295
+ nextSchedule.startTime,
296
+ nextSchedule.startDelay,
297
+ );
298
+ if (TimeMath.compareAbs(now, nominalStart) > 0) {
299
+ const late = TimeMath.subtractAbsAbs(now, nominalStart);
300
+ const maxLate = relativeTime(MAX_LATE_TICK);
301
+
302
+ if (TimeMath.compareRel(late, maxLate) > 0) {
303
+ console.warn(
304
+ `Auction time jumped to ${q(now)} before next scheduled start ${q(
305
+ nextSchedule.startTime,
306
+ )}. Skipping that round.`,
307
+ );
308
+ nextSchedule = safelyComputeRoundTiming(params, now);
309
+ } else {
310
+ console.warn(`Auction started late by ${q(late)}. Starting ${q(now)}`);
311
+ }
236
312
  }
237
- liveSchedule = nextSchedule;
238
313
 
239
- const after = TimeMath.addAbsRel(
240
- liveSchedule.endTime,
241
- TimeMath.coerceRelativeTimeRecord(1n, timerBrand),
314
+ if (!nextSchedule) {
315
+ // nothing new to schedule
316
+ return;
317
+ }
318
+ // activate the nextSchedule as the live one
319
+ // (read here and in function calls below)
320
+ liveSchedule = nextSchedule;
321
+ nextSchedule = safelyComputeRoundTiming(
322
+ params,
323
+ TimeMath.addAbsRel(liveSchedule.endTime, relativeTime(1n)),
242
324
  );
243
- nextSchedule = computeRoundTiming(params, after);
244
325
 
245
- scheduleSteps();
246
- scheduleNextRound(
247
- TimeMath.subtractAbsRel(nextSchedule.startTime, nextSchedule.startDelay),
248
- );
249
- schedulePriceLock(nextSchedule.lockTime);
326
+ queueLiveSchedule();
327
+ if (nextSchedule) {
328
+ scheduleNextRound(
329
+ TimeMath.subtractAbsRel(
330
+ nextSchedule.startTime,
331
+ nextSchedule.startDelay,
332
+ ),
333
+ );
334
+ schedulePriceLock(nextSchedule.lockTime);
335
+ } else {
336
+ console.warn(
337
+ 'no nextSchedule so cannot schedule next round or price lock',
338
+ );
339
+ }
250
340
  };
251
341
 
252
- const firstStart = TimeMath.subtractAbsRel(
253
- nextSchedule.startTime,
254
- nextSchedule.startDelay,
342
+ // initial setting: firstStart is startDelay before next's startTime
343
+ const startSchedulingFromScratch = () => {
344
+ trace('startSchedulingFromScratch');
345
+ if (nextSchedule) {
346
+ const firstStart = TimeMath.subtractAbsRel(
347
+ nextSchedule.startTime,
348
+ nextSchedule.startDelay,
349
+ );
350
+ scheduleNextRound(firstStart);
351
+ schedulePriceLock(nextSchedule.lockTime);
352
+ }
353
+ };
354
+ startSchedulingFromScratch();
355
+
356
+ // when auction parameters change, schedule a next auction if one isn't
357
+ // already scheduled
358
+ void observeIteration(
359
+ subscribeEach(paramUpdateSubscription),
360
+ harden({
361
+ async updateState(_newState) {
362
+ trace('received param update');
363
+ if (!nextSchedule) {
364
+ ({ nextSchedule } = await initializeNextSchedule());
365
+ startSchedulingFromScratch();
366
+ }
367
+ },
368
+ }),
255
369
  );
256
- scheduleNextRound(firstStart);
257
- schedulePriceLock(nextSchedule.lockTime);
258
370
 
259
371
  return Far('scheduler', {
260
372
  getSchedule: () =>
@@ -279,6 +391,6 @@ export const makeScheduler = async (
279
391
 
280
392
  /**
281
393
  * @typedef {object} FullSchedule
282
- * @property {Schedule | undefined} nextAuctionSchedule
283
- * @property {Schedule | undefined} liveAuctionSchedule
394
+ * @property {Schedule | null} nextAuctionSchedule
395
+ * @property {Schedule | null} liveAuctionSchedule
284
396
  */
@@ -5,6 +5,7 @@ import {
5
5
  multiplyRatios,
6
6
  ratioGTE,
7
7
  } from '@agoric/zoe/src/contractSupport/index.js';
8
+ import { Far } from '@endo/marshal';
8
9
 
9
10
  /**
10
11
  * Constants for Auction State.
@@ -46,3 +47,9 @@ export const priceFrom = quote =>
46
47
  quote.quoteAmount.value[0].amountOut,
47
48
  quote.quoteAmount.value[0].amountIn,
48
49
  );
50
+
51
+ export const makeCancelTokenMaker = name => {
52
+ let tokenCount = 1;
53
+
54
+ return () => Far(`cancelToken-${name}-${(tokenCount += 1)}`, {});
55
+ };
@@ -174,7 +174,7 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
174
174
  * @param {Instance} instance
175
175
  * @param {Record<string, Brand>} brands
176
176
  * @param {{ offerId: number, feePct?: number } &
177
- * ({ wantMinted: number | undefined, giveMinted: number | undefined })} opts
177
+ * ({ wantMinted: number | undefined, giveMinted: number | undefined, pair: [string, string] })} opts
178
178
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
179
179
  */
180
180
  const makePsmSwapOffer = (instance, brands, opts) => {
@@ -185,7 +185,6 @@ const makePsmSwapOffer = (instance, brands, opts) => {
185
185
  brands,
186
186
  opts,
187
187
  opts.feePct ? opts.feePct / 100 : undefined,
188
- // @ts-expect-error please update types. Not sure where pair goees.
189
188
  opts.pair[1],
190
189
  );
191
190
 
@@ -6,8 +6,9 @@ import {
6
6
  prepareIssuerKit,
7
7
  } from '@agoric/ertp';
8
8
  import { handleParamGovernance } from '@agoric/governance';
9
- import { assertAllDefined, makeTracer } from '@agoric/internal';
9
+ import { makeTracer, StorageNodeShape } from '@agoric/internal';
10
10
  import { prepareDurablePublishKit } from '@agoric/notifier';
11
+ import { M } from '@agoric/store';
11
12
  import { provideAll } from '@agoric/zoe/src/contractSupport/durability.js';
12
13
  import { prepareRecorder } from '@agoric/zoe/src/contractSupport/recorder.js';
13
14
  import { E } from '@endo/eventual-send';
@@ -20,6 +21,23 @@ const trace = makeTracer('FluxAgg');
20
21
  * @typedef {import('@agoric/time/src/types').TimerService} TimerService
21
22
  */
22
23
 
24
+ export const privateArgsShape = M.splitRecord(
25
+ harden({
26
+ storageNode: StorageNodeShape,
27
+ marshaller: M.eref(M.remotable('marshaller')),
28
+ namesByAddressAdmin: M.any(),
29
+ }),
30
+ harden({
31
+ // always optional. XXX some code is including the key, set to null
32
+ highPrioritySendersManager: M.or(
33
+ M.remotable('prioritySenders manager'),
34
+ M.null(),
35
+ ),
36
+ // only necessary on first invocation, not subsequent
37
+ initialPoserInvitation: M.remotable('Invitation'),
38
+ }),
39
+ );
40
+
23
41
  /**
24
42
  * PriceAuthority for their median. Unlike the simpler `priceAggregator.js`, this approximates
25
43
  * the *Node Operator Aggregation* logic of [Chainlink price
@@ -33,9 +51,9 @@ const trace = makeTracer('FluxAgg');
33
51
  * unitAmountIn?: Amount<'nat'>,
34
52
  * }>} zcf
35
53
  * @param {{
36
- * highPrioritySendersManager: import('@agoric/internal/src/priority-senders.js').PrioritySendersManager,
54
+ * highPrioritySendersManager?: import('@agoric/internal/src/priority-senders.js').PrioritySendersManager,
37
55
  * initialPoserInvitation: Invitation,
38
- * marshaller: Marshaller,
56
+ * marshaller: ERef<Marshaller>,
39
57
  * namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>,
40
58
  * storageNode: StorageNode,
41
59
  * }} privateArgs
@@ -57,7 +75,6 @@ export const prepare = async (zcf, privateArgs, baggage) => {
57
75
  namesByAddressAdmin,
58
76
  storageNode,
59
77
  } = privateArgs;
60
- assertAllDefined({ initialPoserInvitation, marshaller, storageNode });
61
78
 
62
79
  const { description, timer } = zcf.getTerms();
63
80
 
@@ -114,7 +131,10 @@ export const prepare = async (zcf, privateArgs, baggage) => {
114
131
  addr,
115
132
  [invitation],
116
133
  );
117
- await highPrioritySendersManager.add(description, addr);
134
+ if (highPrioritySendersManager) {
135
+ // eslint-disable-next-line @jessie.js/no-nested-await -- after another await
136
+ await E(highPrioritySendersManager).add(description, addr);
137
+ }
118
138
  return `added ${addr}`;
119
139
  };
120
140
 
@@ -126,7 +146,10 @@ export const prepare = async (zcf, privateArgs, baggage) => {
126
146
  const removeOracle = async addr => {
127
147
  trace('removeOracle', addr);
128
148
  await E(faKit.creator).removeOracle(addr);
129
- highPrioritySendersManager.remove(description, addr);
149
+ if (highPrioritySendersManager) {
150
+ // eslint-disable-next-line @jessie.js/no-nested-await -- after another await
151
+ await E(highPrioritySendersManager).remove(description, addr);
152
+ }
130
153
  return `removed ${addr}`;
131
154
  };
132
155
 
@@ -54,15 +54,7 @@ export const publishInterchainAssetFromBoardId = async (
54
54
  */
55
55
  export const publishInterchainAssetFromBank = async (
56
56
  {
57
- consume: {
58
- bankManager,
59
- agoricNamesAdmin,
60
- bankMints,
61
- vBankKits,
62
- reserveKit,
63
- startUpgradable: startUpgradableP,
64
- },
65
- produce: { bankMints: produceBankMints, vBankKits: produceVBankKits },
57
+ consume: { bankManager, agoricNamesAdmin, reserveKit, startUpgradable },
66
58
  installation: {
67
59
  consume: { mintHolder },
68
60
  },
@@ -88,16 +80,11 @@ export const publishInterchainAssetFromBank = async (
88
80
  },
89
81
  };
90
82
 
91
- const startUpgradable = await startUpgradableP;
92
- produceVBankKits.resolve([]);
93
- const { creatorFacet: mint, publicFacet: issuer } = await startUpgradable({
83
+ const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
94
84
  installation: mintHolder,
95
85
  label: keyword,
96
86
  privateArgs: undefined,
97
87
  terms,
98
- produceResults: {
99
- resolve: kit => Promise.resolve(vBankKits).then(kits => kits.push(kit)),
100
- },
101
88
  });
102
89
 
103
90
  const brand = await E(issuer).getBrand();
@@ -105,13 +92,7 @@ export const publishInterchainAssetFromBank = async (
105
92
 
106
93
  await E(E.get(reserveKit).creatorFacet).addIssuer(issuer, keyword);
107
94
 
108
- // Create the mint list if it doesn't exist and wasn't already rejected.
109
- produceBankMints.resolve([]);
110
95
  await Promise.all([
111
- Promise.resolve(bankMints).then(
112
- mints => mints.push(mint),
113
- () => {}, // If the bankMints list was rejected, ignore the error.
114
- ),
115
96
  E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer),
116
97
  E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand),
117
98
  E(bankManager).addAsset(denom, keyword, proposedName, kit),
@@ -128,12 +109,10 @@ export const registerScaledPriceAuthority = async (
128
109
  {
129
110
  consume: {
130
111
  agoricNamesAdmin,
131
- startUpgradable: startUpgradableP,
112
+ startUpgradable,
132
113
  priceAuthorityAdmin,
133
114
  priceAuthority,
134
- scaledPriceAuthorityKits,
135
115
  },
136
- produce: { scaledPriceAuthorityKits: produceScaledPriceAuthorityKits },
137
116
  },
138
117
  { options: { interchainAssetOptions } },
139
118
  ) => {
@@ -209,17 +188,10 @@ export const registerScaledPriceAuthority = async (
209
188
  }),
210
189
  );
211
190
 
212
- const startUpgradable = await startUpgradableP;
213
- produceScaledPriceAuthorityKits.resolve([]);
214
- const spaKit = await startUpgradable({
191
+ const spaKit = await E(startUpgradable)({
215
192
  installation: scaledPriceAuthority,
216
193
  label: `scaledPriceAuthority-${keyword}`,
217
194
  terms,
218
- produceResults: {
219
- resolve: kit =>
220
- Promise.resolve(scaledPriceAuthorityKits).then(kits => kits.push(kit)),
221
- },
222
- privateArgs: undefined,
223
195
  });
224
196
 
225
197
  await E(priceAuthorityAdmin).registerPriceAuthority(
@@ -238,7 +210,7 @@ export const registerScaledPriceAuthority = async (
238
210
  * @param {object} config
239
211
  * @param {object} config.options
240
212
  * @param {InterchainAssetOptions} config.options.interchainAssetOptions
241
- * @param {bigint} config.options.debtLimitValue
213
+ * @param {bigint | number | string} config.options.debtLimitValue
242
214
  * @param {bigint} config.options.interestRateValue
243
215
  */
244
216
  export const addAssetToVault = async (
@@ -270,7 +242,7 @@ export const addAssetToVault = async (
270
242
  const stable = await stableP;
271
243
  const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
272
244
  await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
273
- debtLimit: AmountMath.make(stable, debtLimitValue),
245
+ debtLimit: AmountMath.make(stable, BigInt(debtLimitValue)),
274
246
  interestRate: makeRatio(interestRateValue, stable),
275
247
  // The rest of these we use safe defaults.
276
248
  // In production they will be governed by the Econ Committee.
@@ -15,11 +15,7 @@ const EC_HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
15
15
  */
16
16
  export const inviteCommitteeMembers = async (
17
17
  {
18
- consume: {
19
- namesByAddressAdmin,
20
- economicCommitteeCreatorFacet,
21
- highPrioritySendersManager,
22
- },
18
+ consume: { namesByAddressAdmin, economicCommitteeCreatorFacet, ...consume },
23
19
  },
24
20
  { options: { voterAddresses } },
25
21
  ) => {
@@ -28,6 +24,8 @@ export const inviteCommitteeMembers = async (
28
24
  ).getVoterInvitations();
29
25
  assert.equal(invitations.length, values(voterAddresses).length);
30
26
 
27
+ const highPrioritySendersManager = await consume.highPrioritySendersManager;
28
+
31
29
  /**
32
30
  * @param {[string, Promise<Invitation>][]} addrInvitations
33
31
  */
@@ -40,10 +38,12 @@ export const inviteCommitteeMembers = async (
40
38
  addr,
41
39
  [invitationP],
42
40
  );
43
- await E(highPrioritySendersManager)?.add(
44
- EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
45
- addr,
46
- );
41
+ if (highPrioritySendersManager) {
42
+ await E(highPrioritySendersManager).add(
43
+ EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
44
+ addr,
45
+ );
46
+ }
47
47
  }),
48
48
  );
49
49
  };