@agoric/inter-protocol 0.16.1-dev-69236fd.0 → 0.16.1

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 (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/bundles/bundle-auctioneer-js-meta.json +285 -285
  4. package/bundles/bundle-auctioneer.js +1 -1
  5. package/bundles/bundle-econCommitteeCharter-js-meta.json +201 -201
  6. package/bundles/bundle-econCommitteeCharter.js +1 -1
  7. package/bundles/bundle-feeDistributor-js-meta.json +201 -201
  8. package/bundles/bundle-feeDistributor.js +1 -1
  9. package/bundles/bundle-fluxAggregatorKit-js-meta.json +307 -307
  10. package/bundles/bundle-fluxAggregatorKit.js +1 -1
  11. package/bundles/bundle-psm-js-meta.json +264 -264
  12. package/bundles/bundle-psm.js +1 -1
  13. package/bundles/bundle-reserve-js-meta.json +295 -295
  14. package/bundles/bundle-reserve.js +1 -1
  15. package/bundles/bundle-scaledPriceAuthority-js-meta.json +225 -225
  16. package/bundles/bundle-scaledPriceAuthority.js +1 -1
  17. package/bundles/bundle-vaultFactory-js-meta.json +346 -346
  18. package/bundles/bundle-vaultFactory.js +1 -1
  19. package/package.json +17 -18
  20. package/scripts/add-collateral-core.js +2 -2
  21. package/src/auction/scheduler.js +12 -2
  22. package/src/interest-math.js +13 -13
  23. package/src/interest.js +24 -24
  24. package/src/price/fluxAggregatorContract.js +8 -4
  25. package/src/proposals/addAssetToVault.js +7 -19
  26. package/src/proposals/price-feed-proposal.js +15 -29
  27. package/src/proposals/startPSM.js +4 -6
  28. package/src/reserve/assetReserve.js +2 -2
  29. package/src/vaultFactory/params.js +4 -4
  30. package/src/vaultFactory/storeUtils.js +7 -11
  31. package/src/vaultFactory/types.js +4 -4
  32. package/src/vaultFactory/vault.js +13 -18
  33. package/src/vaultFactory/vaultDirector.js +0 -2
  34. package/src/vaultFactory/vaultManager.js +40 -47
  35. package/scripts/add-STARS.js +0 -43
@@ -26,7 +26,7 @@
26
26
  * @property {Ratio} liquidationMargin - margin below which collateral will be
27
27
  * liquidated to satisfy the debt.
28
28
  * @property {Ratio} liquidationPenalty - penalty charged upon liquidation as proportion of debt
29
- * @property {Ratio} stabilityFee - annual interest rate charged on debt positions
29
+ * @property {Ratio} interestRate - annual interest rate charged on debt positions
30
30
  * @property {Ratio} mintFee - The fee (in BasisPoints) charged when creating
31
31
  * or increasing a debt position.
32
32
  * @property {Amount<'nat'>} debtLimit
@@ -78,7 +78,7 @@
78
78
  * @property {() => Ratio} getLiquidationMargin
79
79
  * @property {() => Ratio} getMintFee
80
80
  * @property {() => Promise<PriceQuote>} getCollateralQuote
81
- * @property {() => Ratio} getStabilityFee - The annual interest rate on a debt position
81
+ * @property {() => Ratio} getInterestRate - The annual interest rate on a debt position
82
82
  * @property {() => RelativeTime} getChargingPeriod - The period (in seconds) at
83
83
  * which interest is charged to the debt position.
84
84
  * @property {() => RelativeTime} getRecordingPeriod - The period (in seconds)
@@ -109,8 +109,8 @@
109
109
 
110
110
  /**
111
111
  * @typedef {object} DebtStatus
112
- * @property {Timestamp} latestStabilityFeeUpdate
113
- * @property {NatValue} interest interest accrued since latestStabilityFeeUpdate
112
+ * @property {Timestamp} latestInterestUpdate
113
+ * @property {NatValue} interest interest accrued since latestInterestUpdate
114
114
  * @property {NatValue} newDebt total including principal and interest
115
115
  */
116
116
 
@@ -72,7 +72,7 @@ const validTransitions = {
72
72
  *
73
73
  * @typedef {object} VaultNotification
74
74
  * @property {Amount<'nat'>} locked Amount of Collateral locked
75
- * @property {{debt: Amount<'nat'>, stabilityFee: Ratio}} debtSnapshot 'debt' at the point the compounded stabilityFee was 'stabilityFee'
75
+ * @property {{debt: Amount<'nat'>, interest: Ratio}} debtSnapshot 'debt' at the point the compounded interest was 'interest'
76
76
  * @property {HolderPhase} vaultState
77
77
  */
78
78
 
@@ -86,7 +86,7 @@ const validTransitions = {
86
86
  * @property {() => Brand<'nat'>} getDebtBrand
87
87
  * @property {MintAndTransfer} mintAndTransfer
88
88
  * @property {(amount: Amount, seat: ZCFSeat) => void} burn
89
- * @property {() => Ratio} getCompoundedStabilityFee
89
+ * @property {() => Ratio} getCompoundedInterest
90
90
  * @property {(oldDebt: import('./storeUtils.js').NormalizedDebt, oldCollateral: Amount<'nat'>, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void} handleBalanceChange
91
91
  * @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
92
92
  */
@@ -104,7 +104,7 @@ const validTransitions = {
104
104
  * Snapshot is of the debt and compounded interest when the principal was last changed.
105
105
  *
106
106
  * @typedef {{
107
- * stabilityFeeSnapshot: Ratio,
107
+ * interestSnapshot: Ratio,
108
108
  * phase: VaultPhase,
109
109
  * debtSnapshot: Amount<'nat'>,
110
110
  * outerUpdater: import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification> | null,
@@ -132,7 +132,7 @@ const VaultStateShape = harden({
132
132
  phase: M.any(),
133
133
  storageNode: M.any(),
134
134
  vaultSeat: M.any(),
135
- stabilityFeeSnapshot: M.any(),
135
+ interestSnapshot: M.any(),
136
136
  debtSnapshot: M.any(),
137
137
  });
138
138
 
@@ -174,7 +174,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
174
174
  vaultSeat: zcf.makeEmptySeatKit().zcfSeat,
175
175
 
176
176
  // Two values from the same moment
177
- stabilityFeeSnapshot: manager.getCompoundedStabilityFee(),
177
+ interestSnapshot: manager.getCompoundedInterest(),
178
178
  debtSnapshot: AmountMath.makeEmpty(manager.getDebtBrand()),
179
179
  });
180
180
  },
@@ -257,8 +257,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
257
257
 
258
258
  // update local state
259
259
  state.debtSnapshot = newDebt;
260
- state.stabilityFeeSnapshot =
261
- state.manager.getCompoundedStabilityFee();
260
+ state.interestSnapshot = state.manager.getCompoundedInterest();
262
261
  },
263
262
 
264
263
  /**
@@ -328,11 +327,10 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
328
327
  getStateSnapshot(newPhase) {
329
328
  const { state, facets } = this;
330
329
 
331
- const { debtSnapshot: debt, stabilityFeeSnapshot: stabilityFee } =
332
- state;
330
+ const { debtSnapshot: debt, interestSnapshot: interest } = state;
333
331
  /** @type {VaultNotification} */
334
332
  return harden({
335
- debtSnapshot: { debt, stabilityFee },
333
+ debtSnapshot: { debt, interest },
336
334
  locked: facets.self.getCollateralAmount(),
337
335
  // newPhase param is so that makeTransferInvitation can finish without setting the vault's phase
338
336
  // TODO refactor https://github.com/Agoric/agoric-sdk/issues/4415
@@ -787,7 +785,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
787
785
  helper.updateDebtSnapshot(self.getCurrentDebt());
788
786
  const {
789
787
  debtSnapshot: debt,
790
- stabilityFeeSnapshot: stabilityFee,
788
+ interestSnapshot: interest,
791
789
  phase,
792
790
  } = state;
793
791
  if (outerUpdater) {
@@ -797,7 +795,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
797
795
  state.outerUpdater = null;
798
796
  }
799
797
  const transferState = {
800
- debtSnapshot: { debt, stabilityFee },
798
+ debtSnapshot: { debt, interest },
801
799
  locked: self.getCollateralAmount(),
802
800
  vaultState: phase,
803
801
  };
@@ -841,8 +839,8 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
841
839
  const { state } = this;
842
840
  return calculateCurrentDebt(
843
841
  state.debtSnapshot,
844
- state.stabilityFeeSnapshot,
845
- state.manager.getCompoundedStabilityFee(),
842
+ state.interestSnapshot,
843
+ state.manager.getCompoundedInterest(),
846
844
  );
847
845
  },
848
846
 
@@ -859,10 +857,7 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
859
857
  getNormalizedDebt() {
860
858
  const { state } = this;
861
859
  // @ts-expect-error cast
862
- return reverseInterest(
863
- state.debtSnapshot,
864
- state.stabilityFeeSnapshot,
865
- );
860
+ return reverseInterest(state.debtSnapshot, state.interestSnapshot);
866
861
  },
867
862
  },
868
863
  },
@@ -250,7 +250,6 @@ const prepareVaultDirector = (
250
250
  metrics: makeRecorderTopic('Vault Factory metrics', metricsKit),
251
251
  });
252
252
 
253
- /** @param {(vm: VaultManager) => void} fn */
254
253
  const allManagersDo = fn => {
255
254
  for (const managerIndex of collateralManagers.values()) {
256
255
  const vm = vaultManagers.get(managerIndex).self;
@@ -425,7 +424,6 @@ const prepareVaultDirector = (
425
424
 
426
425
  makeLiquidationWaker() {
427
426
  return makeWaker('liquidationWaker', _timestamp => {
428
- // XXX floating promise
429
427
  allManagersDo(vm => vm.liquidateVaults(auctioneer));
430
428
  });
431
429
  },
@@ -95,16 +95,16 @@ const trace = makeTracer('VM');
95
95
 
96
96
  /**
97
97
  * @typedef {{
98
- * compoundedStabilityFee: Ratio,
99
- * stabilityFee: Ratio,
100
- * latestStabilityFeeUpdate: Timestamp,
98
+ * compoundedInterest: Ratio,
99
+ * interestRate: Ratio,
100
+ * latestInterestUpdate: Timestamp,
101
101
  * }} AssetState
102
102
  *
103
103
  * @typedef {{
104
104
  * getChargingPeriod: () => RelativeTime,
105
105
  * getRecordingPeriod: () => RelativeTime,
106
106
  * getDebtLimit: () => Amount<'nat'>,
107
- * getStabilityFee: () => Ratio,
107
+ * getInterestRate: () => Ratio,
108
108
  * getLiquidationPadding: () => Ratio,
109
109
  * getLiquidationMargin: () => Ratio,
110
110
  * getLiquidationPenalty: () => Ratio,
@@ -138,8 +138,8 @@ const trace = makeTracer('VM');
138
138
 
139
139
  /**
140
140
  * @typedef {{
141
- * compoundedStabilityFee: Ratio,
142
- * latestStabilityFeeUpdate: Timestamp,
141
+ * compoundedInterest: Ratio,
142
+ * latestInterestUpdate: Timestamp,
143
143
  * numLiquidationsCompleted: number,
144
144
  * numLiquidationsAborted: number,
145
145
  * totalCollateral: Amount<'nat'>,
@@ -230,8 +230,8 @@ export const prepareVaultManagerKit = (
230
230
  return harden({
231
231
  ...params,
232
232
  ...immutable,
233
- compoundedStabilityFee: makeRatio(100n, debtBrand), // starts at 1.0, no interest
234
- latestStabilityFeeUpdate: startTimeStamp,
233
+ compoundedInterest: makeRatio(100n, debtBrand), // starts at 1.0, no interest
234
+ latestInterestUpdate: startTimeStamp,
235
235
  numLiquidationsCompleted: 0,
236
236
  numLiquidationsAborted: 0,
237
237
  totalCollateral: zeroCollateral,
@@ -255,7 +255,7 @@ export const prepareVaultManagerKit = (
255
255
  makeVaultInvitation: M.call().returns(M.promise()),
256
256
  getPublicTopics: M.call().returns(TopicsRecordShape),
257
257
  getQuotes: M.call().returns(NotifierShape),
258
- getCompoundedStabilityFee: M.call().returns(RatioShape),
258
+ getCompoundedInterest: M.call().returns(RatioShape),
259
259
  }),
260
260
  helper: M.interface(
261
261
  'helper',
@@ -276,7 +276,7 @@ export const prepareVaultManagerKit = (
276
276
  getAssetSubscriber: M.call().returns(SubscriberShape),
277
277
  getCollateralBrand: M.call().returns(BrandShape),
278
278
  getDebtBrand: M.call().returns(BrandShape),
279
- getCompoundedStabilityFee: M.call().returns(RatioShape),
279
+ getCompoundedInterest: M.call().returns(RatioShape),
280
280
  scopeDescription: M.call(M.string()).returns(M.string()),
281
281
  handleBalanceChange: M.call(
282
282
  AmountShape,
@@ -319,8 +319,8 @@ export const prepareVaultManagerKit = (
319
319
  const ephemera = collateralEphemera(this.state.collateralBrand);
320
320
  return ephemera.storedQuotesNotifier;
321
321
  },
322
- getCompoundedStabilityFee() {
323
- return this.state.compoundedStabilityFee;
322
+ getCompoundedInterest() {
323
+ return this.state.compoundedInterest;
324
324
  },
325
325
  getPublicTopics() {
326
326
  const { assetTopicKit, metricsTopicKit } = this.state;
@@ -400,7 +400,7 @@ export const prepareVaultManagerKit = (
400
400
  // throw. See https://github.com/Agoric/agoric-sdk/issues/4317
401
401
  void observeNotifier(quoteNotifier, {
402
402
  updateState(value) {
403
- trace('storing new quote', value.quoteAmount.value);
403
+ trace('vaultManager got new collateral quote', value);
404
404
  ephemera.storedCollateralQuote = value;
405
405
  },
406
406
  fail(reason) {
@@ -419,9 +419,9 @@ export const prepareVaultManagerKit = (
419
419
  updateTime,
420
420
  });
421
421
 
422
- const stabilityFee = factoryPowers
422
+ const interestRate = factoryPowers
423
423
  .getGovernedParams(collateralBrand)
424
- .getStabilityFee();
424
+ .getInterestRate();
425
425
 
426
426
  // Update state with the results of charging interest
427
427
 
@@ -433,7 +433,7 @@ export const prepareVaultManagerKit = (
433
433
  seatAllocationKeyword: 'Minted',
434
434
  },
435
435
  {
436
- stabilityFee,
436
+ interestRate,
437
437
  chargingPeriod: factoryPowers
438
438
  .getGovernedParams(collateralBrand)
439
439
  .getChargingPeriod(),
@@ -442,15 +442,15 @@ export const prepareVaultManagerKit = (
442
442
  .getRecordingPeriod(),
443
443
  },
444
444
  {
445
- latestStabilityFeeUpdate: state.latestStabilityFeeUpdate,
446
- compoundedStabilityFee: state.compoundedStabilityFee,
445
+ latestInterestUpdate: state.latestInterestUpdate,
446
+ compoundedInterest: state.compoundedInterest,
447
447
  totalDebt: state.totalDebt,
448
448
  },
449
449
  updateTime,
450
450
  );
451
451
 
452
- state.compoundedStabilityFee = changes.compoundedStabilityFee;
453
- state.latestStabilityFeeUpdate = changes.latestStabilityFeeUpdate;
452
+ state.compoundedInterest = changes.compoundedInterest;
453
+ state.latestInterestUpdate = changes.latestInterestUpdate;
454
454
  state.totalDebt = changes.totalDebt;
455
455
 
456
456
  return facets.helper.assetNotify();
@@ -458,14 +458,14 @@ export const prepareVaultManagerKit = (
458
458
  assetNotify() {
459
459
  const { state } = this;
460
460
  const { collateralBrand, assetTopicKit } = state;
461
- const stabilityFee = factoryPowers
461
+ const interestRate = factoryPowers
462
462
  .getGovernedParams(collateralBrand)
463
- .getStabilityFee();
463
+ .getInterestRate();
464
464
  /** @type {AssetState} */
465
465
  const payload = harden({
466
- compoundedStabilityFee: state.compoundedStabilityFee,
467
- stabilityFee,
468
- latestStabilityFeeUpdate: state.latestStabilityFeeUpdate,
466
+ compoundedInterest: state.compoundedInterest,
467
+ interestRate,
468
+ latestInterestUpdate: state.latestInterestUpdate,
469
469
  });
470
470
  return assetTopicKit.recorder.write(payload);
471
471
  },
@@ -843,8 +843,8 @@ export const prepareVaultManagerKit = (
843
843
  /**
844
844
  * coefficient on existing debt to calculate new debt
845
845
  */
846
- getCompoundedStabilityFee() {
847
- return this.state.compoundedStabilityFee;
846
+ getCompoundedInterest() {
847
+ return this.state.compoundedInterest;
848
848
  },
849
849
  /**
850
850
  * Called by a vault when its balances change.
@@ -963,6 +963,7 @@ export const prepareVaultManagerKit = (
963
963
 
964
964
  try {
965
965
  // TODO `await` is allowed until the above ordering is fixed
966
+ // eslint-disable-next-line @jessie.js/no-nested-await
966
967
  const vaultKit = await vault.initVaultKit(seat, vaultStorageNode);
967
968
  // initVaultKit calls back to handleBalanceChange() which will add the
968
969
  // vault to prioritizedVaults
@@ -1036,7 +1037,7 @@ export const prepareVaultManagerKit = (
1036
1037
  if (!storedCollateralQuote)
1037
1038
  throw Fail`lockOraclePrices called before a collateral quote was available`;
1038
1039
  trace(
1039
- `lockOraclePrices`,
1040
+ `lockPrice`,
1040
1041
  getAmountIn(storedCollateralQuote),
1041
1042
  getAmountOut(storedCollateralQuote),
1042
1043
  );
@@ -1046,33 +1047,25 @@ export const prepareVaultManagerKit = (
1046
1047
  return storedCollateralQuote;
1047
1048
  },
1048
1049
  /**
1049
- * @param {ERef<AuctioneerPublicFacet>} auctionPF
1050
+ * @param {AuctioneerPublicFacet} auctionPF
1050
1051
  */
1051
1052
  async liquidateVaults(auctionPF) {
1052
1053
  const { state, facets } = this;
1053
1054
  const { self, helper } = facets;
1054
1055
  const {
1055
1056
  collateralBrand,
1056
- compoundedStabilityFee,
1057
+ compoundedInterest,
1057
1058
  debtBrand,
1058
1059
  liquidatingVaults,
1059
1060
  lockedQuote,
1060
1061
  } = state;
1061
1062
  trace(collateralBrand, 'considering liquidation');
1062
1063
 
1063
- if (!lockedQuote) {
1064
- // By design, the first cycle of auction may call this before a quote is locked
1065
- // because the schedule is global at the vaultDirector level, and if a manager
1066
- // starts after the price lock time there's nothing to be done.
1067
- // NB: this message should not log repeatedly.
1068
- console.error(
1069
- 'Skipping liquidation because no quote is locked yet (may happen with new manager)',
1070
- );
1071
- return;
1072
- }
1073
-
1074
1064
  const { prioritizedVaults } = collateralEphemera(collateralBrand);
1075
- prioritizedVaults || Fail`prioritizedVaults missing from ephemera`;
1065
+ assert(factoryPowers && prioritizedVaults && zcf);
1066
+ lockedQuote ||
1067
+ Fail`Must have locked a quote before liquidating vaults.`;
1068
+ assert(lockedQuote); // redundant with previous line
1076
1069
 
1077
1070
  const liqMargin = self.getGovernedParams().getLiquidationMargin();
1078
1071
 
@@ -1082,7 +1075,7 @@ export const prepareVaultManagerKit = (
1082
1075
  zcf,
1083
1076
  {
1084
1077
  quote: lockedQuote,
1085
- interest: compoundedStabilityFee,
1078
+ interest: compoundedInterest,
1086
1079
  margin: liqMargin,
1087
1080
  },
1088
1081
  prioritizedVaults,
@@ -1167,11 +1160,11 @@ export const prepareVaultManagerKit = (
1167
1160
  helper.start();
1168
1161
  void state.assetTopicKit.recorder.write(
1169
1162
  harden({
1170
- compoundedStabilityFee: state.compoundedStabilityFee,
1171
- stabilityFee: factoryPowers
1163
+ compoundedInterest: state.compoundedInterest,
1164
+ interestRate: factoryPowers
1172
1165
  .getGovernedParams(state.collateralBrand)
1173
- .getStabilityFee(),
1174
- latestStabilityFeeUpdate: state.latestStabilityFeeUpdate,
1166
+ .getInterestRate(),
1167
+ latestInterestUpdate: state.latestInterestUpdate,
1175
1168
  }),
1176
1169
  );
1177
1170
 
@@ -1,43 +0,0 @@
1
- import { makeHelpers } from '@agoric/deploy-script-support';
2
- import { defaultProposalBuilder as vaultProposalBuilder } from './add-collateral-core.js';
3
- import { defaultProposalBuilder as oraclesProposalBuilder } from './price-feed-core.js';
4
-
5
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
6
- export const starsVaultProposalBuilder = async powers => {
7
- return vaultProposalBuilder(powers, {
8
- interchainAssetOptions: {
9
- // Values for the Stargaze token on Osmosis
10
- denom:
11
- 'ibc/987C17B11ABC2B20019178ACE62929FE9840202CE79498E29FE8E5CB02B7C0A4',
12
- decimalPlaces: 6,
13
- keyword: 'STARS',
14
- oracleBrand: 'STARS',
15
- proposedName: 'STARS',
16
- },
17
- });
18
- };
19
-
20
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
21
- export const starsOraclesProposalBuilder = async powers => {
22
- return oraclesProposalBuilder(powers, {
23
- AGORIC_INSTANCE_NAME: `STARS-USD price feed`,
24
- IN_BRAND_LOOKUP: ['agoricNames', 'oracleBrand', 'STARS'],
25
- IN_BRAND_DECIMALS: 6,
26
- OUT_BRAND_LOOKUP: ['agoricNames', 'oracleBrand', 'USD'],
27
- OUT_BRAND_DECIMALS: 4,
28
- oracleAddresses: [
29
- // copied from decentral-main-vaults-config.json
30
- 'agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr',
31
- 'agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8',
32
- 'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78',
33
- 'agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p',
34
- 'agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj',
35
- ],
36
- });
37
- };
38
-
39
- export default async (homeP, endowments) => {
40
- const { writeCoreProposal } = await makeHelpers(homeP, endowments);
41
- await writeCoreProposal('add-STARS', starsVaultProposalBuilder);
42
- await writeCoreProposal('add-STARS-oracles', starsOraclesProposalBuilder);
43
- };