@agoric/inter-protocol 0.15.0 → 0.16.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 (39) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/bundles/bundle-auctioneer-js-meta.json +314 -314
  3. package/bundles/bundle-auctioneer.js +1 -1
  4. package/bundles/bundle-econCommitteeCharter-js-meta.json +208 -208
  5. package/bundles/bundle-econCommitteeCharter.js +1 -1
  6. package/bundles/bundle-feeDistributor-js-meta.json +189 -189
  7. package/bundles/bundle-feeDistributor.js +1 -1
  8. package/bundles/bundle-fluxAggregatorKit-js-meta.json +284 -284
  9. package/bundles/bundle-fluxAggregatorKit.js +1 -1
  10. package/bundles/bundle-psm-js-meta.json +302 -302
  11. package/bundles/bundle-psm.js +1 -1
  12. package/bundles/bundle-reserve-js-meta.json +293 -293
  13. package/bundles/bundle-reserve.js +1 -1
  14. package/bundles/bundle-scaledPriceAuthority-js-meta.json +220 -220
  15. package/bundles/bundle-scaledPriceAuthority.js +1 -1
  16. package/bundles/bundle-vaultFactory-js-meta.json +330 -326
  17. package/bundles/bundle-vaultFactory.js +1 -1
  18. package/package.json +16 -16
  19. package/scripts/init-core.js +2 -2
  20. package/scripts/start-local-chain.sh +1 -1
  21. package/src/auction/auctionBook.js +10 -2
  22. package/src/clientSupport.js +79 -7
  23. package/src/contractSupport.js +16 -45
  24. package/src/price/fluxAggregatorContract.js +1 -1
  25. package/src/price/fluxAggregatorKit.js +2 -15
  26. package/src/price/roundsManager.js +8 -0
  27. package/src/proposals/core-proposal.js +4 -4
  28. package/src/proposals/econ-behaviors.js +13 -12
  29. package/src/reserve/assetReserveKit.js +1 -7
  30. package/src/reserve/doc.md +4 -4
  31. package/src/vaultFactory/Liquidation.md +1 -1
  32. package/src/vaultFactory/liquidation.js +14 -24
  33. package/src/vaultFactory/params.js +8 -8
  34. package/src/vaultFactory/proceeds.js +274 -0
  35. package/src/vaultFactory/types.js +1 -10
  36. package/src/vaultFactory/vaultDirector.js +3 -42
  37. package/src/vaultFactory/vaultFactory.js +3 -3
  38. package/src/vaultFactory/vaultHolder.js +1 -9
  39. package/src/vaultFactory/vaultManager.js +177 -322
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -30,28 +30,28 @@
30
30
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
31
  "dependencies": {
32
32
  "@agoric/assert": "^0.6.0",
33
- "@agoric/ertp": "^0.16.1",
34
- "@agoric/governance": "^0.10.1",
35
- "@agoric/internal": "^0.3.1",
36
- "@agoric/notifier": "^0.6.1",
37
- "@agoric/store": "^0.9.1",
38
- "@agoric/time": "^0.3.1",
39
- "@agoric/vat-data": "^0.5.1",
40
- "@agoric/vats": "^0.14.1",
41
- "@agoric/zoe": "^0.26.1",
33
+ "@agoric/ertp": "^0.16.2",
34
+ "@agoric/governance": "^0.10.2",
35
+ "@agoric/internal": "^0.3.2",
36
+ "@agoric/notifier": "^0.6.2",
37
+ "@agoric/store": "^0.9.2",
38
+ "@agoric/time": "^0.3.2",
39
+ "@agoric/vat-data": "^0.5.2",
40
+ "@agoric/vats": "^0.15.0",
41
+ "@agoric/zoe": "^0.26.2",
42
42
  "@endo/captp": "^3.1.1",
43
43
  "@endo/eventual-send": "^0.17.2",
44
44
  "@endo/far": "^0.2.18",
45
45
  "@endo/marshal": "^0.8.5",
46
46
  "@endo/nat": "^4.1.27",
47
- "agoric": "^0.20.0",
47
+ "agoric": "^0.21.0",
48
48
  "jessie.js": "^0.3.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@agoric/deploy-script-support": "^0.10.1",
52
- "@agoric/smart-wallet": "^0.5.1",
53
- "@agoric/swingset-liveslots": "^0.10.1",
54
- "@agoric/swingset-vat": "^0.32.1",
51
+ "@agoric/deploy-script-support": "^0.10.2",
52
+ "@agoric/smart-wallet": "^0.5.2",
53
+ "@agoric/swingset-liveslots": "^0.10.2",
54
+ "@agoric/swingset-vat": "^0.32.2",
55
55
  "@endo/bundle-source": "^2.5.1",
56
56
  "@endo/init": "^0.5.56",
57
57
  "@endo/promise-kit": "^0.2.56",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "676e947a6fba6e1bab0717ca7228824c32509bda"
82
+ "gitHead": "b66bf7c881ae462fcb617cd6e8d41b5c40ec58ef"
83
83
  }
@@ -132,7 +132,7 @@ export const defaultProposalBuilder = async (
132
132
  const {
133
133
  vaultFactoryControllerAddress = env.VAULT_FACTORY_CONTROLLER_ADDR,
134
134
  minInitialPoolLiquidity = env.MIN_INITIAL_POOL_LIQUIDITY,
135
- endorsedUi,
135
+ referencedUi,
136
136
  anchorOptions: {
137
137
  anchorDenom = env.ANCHOR_DENOM,
138
138
  anchorDecimalPlaces = '6',
@@ -168,7 +168,7 @@ export const defaultProposalBuilder = async (
168
168
  {
169
169
  vaultFactoryControllerAddress,
170
170
  minInitialPoolLiquidity: optBigInt(minInitialPoolLiquidity),
171
- endorsedUi,
171
+ referencedUi,
172
172
  anchorOptions,
173
173
  econCommitteeOptions,
174
174
  installKeys: {
@@ -55,7 +55,7 @@ make scenario2-setup-nobuild >>"$CHAIN_LOG" 2>&1
55
55
  echo "Starting the chain..."
56
56
  # use -economy target to get the kitchen sink
57
57
  # disable pruning to keep all history https://docs.desmos.network/fullnode/overview/
58
- make AGC_START_ARGS="--pruning=nothing" CHAIN_BOOTSTRAP_VAT_CONFIG=@agoric/vats/decentral-test-vaults-config.json scenario2-run-chain >>"$CHAIN_LOG" 2>&1 &
58
+ make AGC_START_ARGS="--pruning=nothing" CHAIN_BOOTSTRAP_VAT_CONFIG=@agoric/vats/decentral-itest-vaults-config.json scenario2-run-chain >>"$CHAIN_LOG" 2>&1 &
59
59
  make wait-for-cosmos
60
60
 
61
61
  # xxx sleep to let it settle
@@ -514,7 +514,11 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
514
514
  calcTargetRatio(),
515
515
  );
516
516
 
517
- if (state.remainingProceedsGoal !== null) {
517
+ if (
518
+ state.remainingProceedsGoal !== null ||
519
+ // XXX use this as an indication that the auction is active
520
+ state.curAuctionPrice !== null
521
+ ) {
518
522
  const incrementToGoal = state.startProceedsGoal
519
523
  ? AmountMath.subtract(nextProceedsGoal, state.startProceedsGoal)
520
524
  : nextProceedsGoal;
@@ -625,7 +629,11 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
625
629
  Fail`capturedPriceForRound must be set before each round`;
626
630
  assert(capturedPriceForRound);
627
631
 
628
- trace('set startPrice', capturedPriceForRound);
632
+ trace(
633
+ 'set startPrice',
634
+ capturedPriceForRound,
635
+ this.state.startProceedsGoal,
636
+ );
629
637
  this.state.remainingProceedsGoal = this.state.startProceedsGoal;
630
638
  this.state.curAuctionPrice = multiplyRatios(
631
639
  capturedPriceForRound,
@@ -142,13 +142,13 @@ export const lookupOfferIdForVault = async (vaultId, currentP) => {
142
142
 
143
143
  /**
144
144
  * @param {Record<string, Brand>} brands
145
- * @param {({ wantMinted: number | undefined, giveMinted: number | undefined })} opts
145
+ * @param {({ wantMinted: number, giveMinted?: undefined } | { giveMinted: number, wantMinted?: undefined })} opts
146
146
  * @param {number} [fee=0]
147
147
  * @param {string} [anchor]
148
148
  * @returns {Proposal} XXX not a real proposal, uses BoardRemote
149
149
  */
150
150
  const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
151
- const giving = opts.giveMinted ? 'minted' : 'anchor';
151
+ const giving = 'giveMinted' in opts ? 'minted' : 'anchor';
152
152
  const brand =
153
153
  giving === 'anchor'
154
154
  ? { in: brands[anchor], out: brands.IST }
@@ -173,14 +173,15 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
173
173
  /**
174
174
  * @param {Instance} instance
175
175
  * @param {Record<string, Brand>} brands
176
- * @param {{ offerId: number, feePct?: number } &
177
- * ({ wantMinted: number | undefined, giveMinted: number | undefined, pair: [string, string] })} opts
176
+ * @param {{ offerId: string, feePct?: number, pair: [string, string] } &
177
+ * ({ wantMinted: number } | { giveMinted: number })} opts
178
178
  * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
179
179
  */
180
180
  const makePsmSwapOffer = (instance, brands, opts) => {
181
- const method = opts.wantMinted
182
- ? 'makeWantMintedInvitation'
183
- : 'makeGiveMintedInvitation'; // ref psm.js
181
+ const method =
182
+ 'wantMinted' in opts
183
+ ? 'makeWantMintedInvitation'
184
+ : 'makeGiveMintedInvitation'; // ref psm.js
184
185
  const proposal = makePsmProposal(
185
186
  brands,
186
187
  opts,
@@ -305,10 +306,81 @@ const makeAddCollateralOffer = (brands, opts) => {
305
306
  return offerSpec;
306
307
  };
307
308
 
309
+ /**
310
+ *
311
+ * @param {Record<string, Brand>} _brands
312
+ * @param {{
313
+ * offerId: string,
314
+ * roundId?: bigint,
315
+ * unitPrice: bigint,
316
+ * }} opts
317
+ * @param {string} previousOffer
318
+ * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
319
+ */
320
+ const makePushPriceOffer = (_brands, opts, previousOffer) => {
321
+ return {
322
+ id: opts.offerId,
323
+ invitationSpec: {
324
+ source: 'continuing',
325
+ previousOffer,
326
+ invitationMakerName: 'PushPrice',
327
+ invitationArgs: harden([
328
+ { unitPrice: opts.unitPrice, roundId: opts.roundId },
329
+ ]),
330
+ },
331
+ proposal: {},
332
+ };
333
+ };
334
+
335
+ // TODO DRY with CLI wallet.js
336
+ /**
337
+ * @param {{
338
+ * brand: Record<string, Brand>,
339
+ * vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
340
+ * }} agoricNames
341
+ * @param {(msg: string) => Error} makeError error constructor
342
+ * @returns {(a: string) => Amount<'nat'>}
343
+ */
344
+ export const makeParseAmount =
345
+ (agoricNames, makeError = msg => RangeError(msg)) =>
346
+ opt => {
347
+ assert.typeof(opt, 'string', 'parseAmount expected string');
348
+ const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
349
+ if (!m || !m.groups) {
350
+ throw makeError(`invalid amount: ${opt}`);
351
+ }
352
+ const anyBrand = agoricNames.brand[m.groups.brand];
353
+ if (!anyBrand) {
354
+ throw makeError(`unknown brand: ${m.groups.brand}`);
355
+ }
356
+ const assetDesc = Object.values(agoricNames.vbankAsset).find(
357
+ d => d.brand === anyBrand,
358
+ );
359
+ if (!assetDesc) {
360
+ throw makeError(`unknown brand: ${m.groups.brand}`);
361
+ }
362
+ const { displayInfo } = assetDesc;
363
+ if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
364
+ throw makeError(`bad brand: ${displayInfo}`);
365
+ }
366
+ const value = BigInt(
367
+ Number(m.groups.value.replace(/_/g, '')) *
368
+ 10 ** displayInfo.decimalPlaces,
369
+ );
370
+ /** @type {Brand<'nat'>} */
371
+ // @ts-expect-error dynamic cast
372
+ const natBrand = anyBrand;
373
+ const amt = { value, brand: natBrand };
374
+ return amt;
375
+ };
376
+
308
377
  export const Offers = {
309
378
  auction: {
310
379
  Bid: makeBidOffer,
311
380
  },
381
+ fluxAggregator: {
382
+ PushPrice: makePushPriceOffer,
383
+ },
312
384
  psm: {
313
385
  // lowercase because it's not an invitation name. Instead it's an abstraction over two invitation makers.
314
386
  swap: makePsmSwapOffer,
@@ -1,9 +1,8 @@
1
1
  // @jessie-check
2
2
 
3
3
  import { AmountMath } from '@agoric/ertp';
4
- import { makeStoredPublisherKit, makeStoredPublishKit } from '@agoric/notifier';
5
4
  import { M } from '@agoric/store';
6
- import { E } from '@endo/eventual-send';
5
+ import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport/index.js';
7
6
 
8
7
  const { Fail, quote: q } = assert;
9
8
 
@@ -29,6 +28,17 @@ export const ratioPattern = harden({
29
28
  export const addSubtract = (base, gain, loss) =>
30
29
  AmountMath.subtract(AmountMath.add(base, gain), loss);
31
30
 
31
+ /**
32
+ * @template {Amount} T
33
+ * @param {T} left
34
+ * @param {T} right
35
+ * @returns {T}
36
+ */
37
+ export const subtractToEmpty = (left, right) =>
38
+ AmountMath.isGTE(right, left)
39
+ ? /** @type {T} */ (AmountMath.makeEmptyFromAmount(left))
40
+ : /** @type {T} */ (AmountMath.subtract(left, right));
41
+
32
42
  /**
33
43
  * Verifies that every key in the proposal is in the provided list
34
44
  *
@@ -65,27 +75,6 @@ export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {
65
75
  )} would hit total debt limit ${q(debtLimit)}`;
66
76
  };
67
77
 
68
- /**
69
- * @deprecated incompatible with durability; instead handle vstorage ephemerally on a durable PublishKit
70
- * @template T
71
- * @param {ERef<StorageNode>} storageNode
72
- * @param {ERef<Marshaller>} marshaller
73
- * @returns {MetricsPublisherKit<T>}
74
- */
75
- export const makeMetricsPublisherKit = (storageNode, marshaller) => {
76
- assert(
77
- storageNode && marshaller,
78
- 'makeMetricsPublisherKit missing storageNode or marshaller',
79
- );
80
- /** @type {import('@agoric/notifier').StoredPublisherKit<T>} */
81
- const kit = makeStoredPublisherKit(storageNode, marshaller, 'metrics');
82
- return {
83
- metricsPublication: kit.publisher,
84
- metricsSubscription: kit.subscriber,
85
- };
86
- };
87
- harden(makeMetricsPublisherKit);
88
-
89
78
  /**
90
79
  * @template T
91
80
  * @typedef {object} MetricsPublisherKit<T>
@@ -100,31 +89,13 @@ harden(makeMetricsPublisherKit);
100
89
  * @property {StoredSubscriber<T>} metricsSubscriber
101
90
  */
102
91
 
103
- /**
104
- * @deprecated incompatible with durability; instead handle vstorage ephemerally on a durable PublishKit
105
- * @template T
106
- * @param {ERef<StorageNode>} storageNode
107
- * @param {ERef<Marshaller>} marshaller
108
- * @returns {MetricsPublishKit<T>}
109
- */
110
- export const makeMetricsPublishKit = (storageNode, marshaller) => {
111
- assert(
112
- storageNode && marshaller,
113
- 'makeMetricsPublisherKit missing storageNode or marshaller',
114
- );
115
- const metricsNode = E(storageNode).makeChildNode('metrics');
116
- /** @type {StoredPublishKit<T>} */
117
- const kit = makeStoredPublishKit(metricsNode, marshaller);
118
- return {
119
- metricsPublisher: kit.publisher,
120
- metricsSubscriber: kit.subscriber,
121
- };
122
- };
123
- harden(makeMetricsPublishKit);
124
-
125
92
  /**
126
93
  * @param {Brand} brand must be a 'nat' brand, not checked
127
94
  * @param {NatValue} [min]
128
95
  */
129
96
  export const makeNatAmountShape = (brand, min) =>
130
97
  harden({ brand, value: min ? M.gte(min) : M.nat() });
98
+
99
+ /** @param {Pick<PriceDescription, 'amountIn' | 'amountOut'>} quoteAmount */
100
+ export const quoteAsRatio = quoteAmount =>
101
+ makeRatioFromAmounts(quoteAmount.amountIn, quoteAmount.amountOut);
@@ -15,7 +15,7 @@ import { E } from '@endo/eventual-send';
15
15
  import { reserveThenDeposit } from '../proposals/utils.js';
16
16
  import { prepareFluxAggregatorKit } from './fluxAggregatorKit.js';
17
17
 
18
- const trace = makeTracer('FluxAgg');
18
+ const trace = makeTracer('FluxAgg', false);
19
19
  /**
20
20
  * @typedef {import('@agoric/vat-data').Baggage} Baggage
21
21
  * @typedef {import('@agoric/time/src/types').TimerService} TimerService
@@ -5,11 +5,7 @@
5
5
  */
6
6
  import { AmountMath } from '@agoric/ertp';
7
7
  import { assertAllDefined, makeTracer } from '@agoric/internal';
8
- import {
9
- makeNotifierFromSubscriber,
10
- observeNotifier,
11
- SubscriberShape,
12
- } from '@agoric/notifier';
8
+ import { makeNotifierFromSubscriber, observeNotifier } from '@agoric/notifier';
13
9
  import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
14
10
  import {
15
11
  defineRecorderKit,
@@ -189,6 +185,7 @@ export const prepareFluxAggregatorKit = async (
189
185
  priceAuthority.makeQuoteNotifier(unitAmountIn, brandOut),
190
186
  {
191
187
  updateState: quote => {
188
+ trace('new quote', quote);
192
189
  void priceKit.recorder.write(priceDescriptionFromQuote(quote));
193
190
  },
194
191
  fail: reason => {
@@ -207,8 +204,6 @@ export const prepareFluxAggregatorKit = async (
207
204
  creator: M.interface('fluxAggregator creatorFacet', {}, { sloppy: true }),
208
205
  public: M.interface('fluxAggregator publicFacet', {
209
206
  getPriceAuthority: M.call().returns(M.any()),
210
- getSubscriber: M.call().returns(SubscriberShape),
211
- getRoundStartNotifier: M.call().returns(SubscriberShape),
212
207
  getPublicTopics: M.call().returns({
213
208
  quotes: M.any(),
214
209
  latestRound: M.any(),
@@ -345,14 +340,6 @@ export const prepareFluxAggregatorKit = async (
345
340
  getPriceAuthority() {
346
341
  return priceAuthority;
347
342
  },
348
- /** @deprecated use getPublicTopics */
349
- getSubscriber: () => {
350
- return priceKit.subscriber;
351
- },
352
- /** @deprecated use getPublicTopics */
353
- getRoundStartNotifier() {
354
- return latestRoundKit.subscriber;
355
- },
356
343
  getPublicTopics() {
357
344
  return {
358
345
  quotes: makeRecorderTopic(
@@ -1,5 +1,6 @@
1
1
  import { Fail, q } from '@agoric/assert';
2
2
  import { AmountMath } from '@agoric/ertp';
3
+ import { makeTracer } from '@agoric/internal';
3
4
  import { TimeMath } from '@agoric/time';
4
5
  import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
5
6
  import {
@@ -25,6 +26,8 @@ const V3_NO_DATA_ERROR = 'No data present';
25
26
  /** @type {bigint} */
26
27
  export const ROUND_MAX = BigInt(2 ** 32 - 1);
27
28
 
29
+ const trace = makeTracer('RoundsM', false);
30
+
28
31
  /**
29
32
  * @param {bigint} roundId
30
33
  */
@@ -290,6 +293,7 @@ export const prepareRoundsManagerKit = baggage =>
290
293
  * @returns {OracleStatus} the new status
291
294
  */
292
295
  recordSubmission(submission, roundId, status) {
296
+ trace('recordSubmission', submission, roundId, status);
293
297
  const { helper } = this.facets;
294
298
  const { details } = this.state;
295
299
  helper.acceptingSubmissions(roundId) ||
@@ -670,6 +674,7 @@ export const prepareRoundsManagerKit = baggage =>
670
674
  status,
671
675
  { roundId: roundIdRaw = undefined, unitPrice: valueRaw },
672
676
  ) {
677
+ trace('handlePush', status, roundIdRaw, valueRaw);
673
678
  const value = Nat(valueRaw);
674
679
  const { minSubmissionValue, maxSubmissionValue, timerPresence } =
675
680
  this.state;
@@ -681,6 +686,7 @@ export const prepareRoundsManagerKit = baggage =>
681
686
  Fail`value above maxSubmissionValue ${q(maxSubmissionValue)}`;
682
687
 
683
688
  const blockTimestamp = await E(timerPresence).getCurrentTimestamp();
689
+ trace('handlePush blockTimestamp', blockTimestamp.absValue);
684
690
 
685
691
  let roundId;
686
692
  if (roundIdRaw === undefined) {
@@ -719,6 +725,8 @@ export const prepareRoundsManagerKit = baggage =>
719
725
  helper.updateRoundAnswer(roundId, blockTimestamp);
720
726
  helper.deleteRoundDetails(roundId);
721
727
 
728
+ trace('handlePush returning', settledStatus);
729
+
722
730
  return settledStatus;
723
731
  },
724
732
  },
@@ -200,7 +200,7 @@ export const getManifestForMain = (
200
200
  installKeys,
201
201
  vaultFactoryControllerAddress,
202
202
  minInitialPoolLiquidity,
203
- endorsedUi,
203
+ referencedUi,
204
204
  },
205
205
  ) => {
206
206
  return {
@@ -214,7 +214,7 @@ export const getManifestForMain = (
214
214
  options: {
215
215
  vaultFactoryControllerAddress,
216
216
  minInitialPoolLiquidity,
217
- endorsedUi,
217
+ referencedUi,
218
218
  },
219
219
  };
220
220
  };
@@ -226,7 +226,7 @@ export const getManifestForInterProtocol = (
226
226
  installKeys,
227
227
  vaultFactoryControllerAddress,
228
228
  minInitialPoolLiquidity,
229
- endorsedUi,
229
+ referencedUi,
230
230
  },
231
231
  ) => {
232
232
  const econCommitteeManifest = getManifestForEconCommittee(
@@ -239,7 +239,7 @@ export const getManifestForInterProtocol = (
239
239
  installKeys,
240
240
  vaultFactoryControllerAddress,
241
241
  minInitialPoolLiquidity,
242
- endorsedUi,
242
+ referencedUi,
243
243
  },
244
244
  );
245
245
  return {
@@ -17,6 +17,7 @@ import { makeGovernedTerms as makeGovernedVFTerms } from '../vaultFactory/params
17
17
 
18
18
  const trace = makeTracer('RunEconBehaviors', true);
19
19
 
20
+ export const SECONDS_PER_MINUTE = 60n;
20
21
  export const SECONDS_PER_HOUR = 60n * 60n;
21
22
  export const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
22
23
  export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
@@ -173,7 +174,7 @@ export const setupReserve = async ({
173
174
  * @param {object} config
174
175
  * @param {InterestTiming} [config.interestTiming]
175
176
  * @param {object} [config.options]
176
- * @param {string} [config.options.endorsedUi]
177
+ * @param {string} [config.options.referencedUi]
177
178
  * @param {Amount<'nat'>} minInitialDebt
178
179
  */
179
180
  export const setupVaultFactoryArguments = async (
@@ -183,7 +184,7 @@ export const setupVaultFactoryArguments = async (
183
184
  chargingPeriod: SECONDS_PER_HOUR,
184
185
  recordingPeriod: SECONDS_PER_DAY,
185
186
  },
186
- options: { endorsedUi } = {},
187
+ options: { referencedUi } = {},
187
188
  } = {},
188
189
  minInitialDebt,
189
190
  ) => {
@@ -237,7 +238,7 @@ export const setupVaultFactoryArguments = async (
237
238
  minInitialDebt,
238
239
  bootstrapPaymentValue: 0n,
239
240
  shortfallInvitationAmount,
240
- endorsedUi,
241
+ referencedUi,
241
242
  });
242
243
 
243
244
  const vaultFactoryPrivateArgs = {
@@ -256,7 +257,7 @@ export const setupVaultFactoryArguments = async (
256
257
  * @param {object} config
257
258
  * @param {InterestTiming} [config.interestTiming]
258
259
  * @param {object} [config.options]
259
- * @param {string} [config.options.endorsedUi]
260
+ * @param {string} [config.options.referencedUi]
260
261
  * @param {bigint} minInitialDebt
261
262
  */
262
263
  export const startVaultFactory = async (
@@ -411,7 +412,7 @@ export const startRewardDistributor = async ({
411
412
  const feeDistributorTerms = await deeplyFulfilledObject(
412
413
  harden({
413
414
  timerService,
414
- collectionInterval: 60n * 60n, // 1 hour
415
+ collectionInterval: 1n * SECONDS_PER_HOUR,
415
416
  keywordShares: {
416
417
  RewardDistributor: 0n,
417
418
  Reserve: 1n,
@@ -518,18 +519,18 @@ export const startAuctioneer = async (
518
519
  },
519
520
  },
520
521
  issuer: {
521
- consume: { [Stable.symbol]: runIssuerP },
522
+ consume: { [Stable.symbol]: stableIssuerP },
522
523
  },
523
524
  },
524
525
  {
525
526
  auctionParams = {
526
- StartFrequency: 3600n,
527
- ClockStep: 3n * 60n,
527
+ StartFrequency: 1n * SECONDS_PER_HOUR,
528
+ ClockStep: 3n * SECONDS_PER_MINUTE,
528
529
  StartingRate: 10500n,
529
530
  LowestRate: 6500n,
530
531
  DiscountStep: 500n,
531
532
  AuctionStartDelay: 2n,
532
- PriceLockPeriod: 30n * 60n, // half an hour
533
+ PriceLockPeriod: SECONDS_PER_HOUR / 2n,
533
534
  },
534
535
  } = {},
535
536
  ) => {
@@ -538,11 +539,11 @@ export const startAuctioneer = async (
538
539
 
539
540
  const poserInvitationP = E(electorateCreatorFacet).getPoserInvitation();
540
541
 
541
- const [initialPoserInvitation, electorateInvitationAmount, runIssuer] =
542
+ const [initialPoserInvitation, electorateInvitationAmount, stableIssuer] =
542
543
  await Promise.all([
543
544
  poserInvitationP,
544
545
  E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
545
- runIssuerP,
546
+ stableIssuerP,
546
547
  ]);
547
548
 
548
549
  const timerBrand = await E(chainTimerService).getTimerBrand();
@@ -570,7 +571,7 @@ export const startAuctioneer = async (
570
571
  governedContractInstallation: auctionInstallation,
571
572
  governed: {
572
573
  terms: auctionTerms,
573
- issuerKeywordRecord: { Bid: runIssuer },
574
+ issuerKeywordRecord: { Bid: stableIssuer },
574
575
  storageNode,
575
576
  marshaller,
576
577
  label: 'auctioneer',
@@ -5,7 +5,6 @@ import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
5
5
  import { atomicTransfer } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
6
6
  import {
7
7
  makeRecorderTopic,
8
- SubscriberShape,
9
8
  TopicsRecordShape,
10
9
  } from '@agoric/zoe/src/contractSupport/topics.js';
11
10
  import { AmountKeywordRecordShape } from '@agoric/zoe/src/typeGuards.js';
@@ -57,7 +56,6 @@ export const prepareAssetReserveKit = async (
57
56
  }),
58
57
  public: M.interface('AssetReserve public', {
59
58
  makeAddCollateralInvitation: M.call().returns(M.promise()),
60
- getMetrics: M.call().returns(SubscriberShape),
61
59
  getPublicTopics: M.call().returns(TopicsRecordShape),
62
60
  }),
63
61
  shortfallReportingFacet: M.interface('AssetReserve shortfall reporter', {
@@ -189,7 +187,7 @@ export const prepareAssetReserveKit = async (
189
187
  await zcf.saveIssuer(issuer, keyword);
190
188
  },
191
189
 
192
- /** @deprecated use getPublicTopics metrics allocation */
190
+ /** XXX redundant with getPublicTopics metrics `allocation` */
193
191
  getAllocations() {
194
192
  return this.state.collateralSeat.getCurrentAllocation();
195
193
  },
@@ -239,10 +237,6 @@ export const prepareAssetReserveKit = async (
239
237
  };
240
238
  return zcf.makeInvitation(handler, 'Add Collateral');
241
239
  },
242
- /** @deprecated */
243
- getMetrics() {
244
- return this.state.metricsKit.subscriber;
245
- },
246
240
  getPublicTopics() {
247
241
  return {
248
242
  metrics: makeRecorderTopic(
@@ -90,20 +90,20 @@ sequenceDiagram
90
90
  participant caller
91
91
  participant reserveContract
92
92
  participant collateralSeat
93
- participant runMint
93
+ participant stableMint
94
94
  participant runSeat
95
95
  participant zcf
96
96
  participant ammPublicFacet
97
97
  participant liquidityInvite
98
98
 
99
- caller ->> reserveContract: addLiquidityToAmmPool(collateralAmount, runAmount)
99
+ caller ->> reserveContract: addLiquidityToAmmPool(collateralAmount, stableAmount)
100
100
  reserveContract ->> reserveContract: get collateralKeyword from collateralAmount.brand
101
101
  reserveContract ->> collateralSeat: get current allocation for collateralKeyword
102
102
  reserveContract ->> reserveContract: ensure current allocation for collateralKeyword is >= collateralAmount
103
103
 
104
104
 
105
105
  note right of reserveContract: create the IST
106
- reserveContract ->> runMint: mintGains of runAmount, and get runSeat
106
+ reserveContract ->> stableMint: mintGains of stableAmount, and get runSeat
107
107
  reserveContract ->> runSeat: increment collateralKeyword: collateralAmount
108
108
  reserveContract ->> collateralSeat: decrement collateralKeyword: collateralAmount
109
109
  reserveContract ->> zcf: reallocate(runSeat, collateralSeat)
@@ -112,7 +112,7 @@ note right of reserveContract: Add IST and collateral to the AMM
112
112
  reserveContract ->> ammPublicFacet: get invite for makeAddLiquidityAtRateInvitation
113
113
  reserveContract ->> reserveContract: create mapping, IST = central, collateralKeyword: secondary
114
114
  reserveContract ->> reserveContract: get liquidity brand for collateralKeyword
115
- reserveContract ->> reserveContract: terms mapping, give Central: runAmount, Secondary collateralAmount, want liquidity
115
+ reserveContract ->> reserveContract: terms mapping, give Central: stableAmount, Secondary collateralAmount, want liquidity
116
116
  reserveContract ->> zcf: offer
117
117
 
118
118
 
@@ -13,7 +13,7 @@ There are two interesting exception cases. All the collateral might be sold
13
13
  without covering the debt (flow 2a), or there might not be enough bids to
14
14
  purchase all the collateral (flow 2b). In the first case, vault-holders don't
15
15
  get anything back, we burn the currency we received to cover a portion of the
16
- debt, any excess collateral is sent to the reserve, and we report a shortfall.
16
+ debt, and we report a shortfall.
17
17
 
18
18
  In the second case, we can't tell whether it's due to a downturn in the
19
19
  market or a DoS attack on the exchange. In hopes that it's not the latter, we