@agoric/inter-protocol 0.13.2-dev-2f08018.0 → 0.13.2-dev-8cbf697.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.13.2-dev-2f08018.0+2f08018",
3
+ "version": "0.13.2-dev-8cbf697.0+8cbf697",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -29,18 +29,18 @@
29
29
  },
30
30
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
31
  "dependencies": {
32
- "@agoric/assert": "0.5.2-dev-2f08018.0+2f08018",
33
- "@agoric/ertp": "0.15.4-dev-2f08018.0+2f08018",
34
- "@agoric/governance": "0.9.2-dev-2f08018.0+2f08018",
35
- "@agoric/internal": "0.2.2-dev-2f08018.0+2f08018",
36
- "@agoric/notifier": "0.5.2-dev-2f08018.0+2f08018",
37
- "@agoric/store": "0.8.4-dev-2f08018.0+2f08018",
38
- "@agoric/swingset-liveslots": "0.9.1-dev-2f08018.0+2f08018",
39
- "@agoric/swingset-vat": "0.30.3-dev-2f08018.0+2f08018",
40
- "@agoric/time": "0.2.2-dev-2f08018.0+2f08018",
41
- "@agoric/vat-data": "0.4.4-dev-2f08018.0+2f08018",
42
- "@agoric/vats": "0.13.1-dev-2f08018.0+2f08018",
43
- "@agoric/zoe": "0.25.4-dev-2f08018.0+2f08018",
32
+ "@agoric/assert": "0.5.2-dev-8cbf697.0+8cbf697",
33
+ "@agoric/ertp": "0.15.4-dev-8cbf697.0+8cbf697",
34
+ "@agoric/governance": "0.9.2-dev-8cbf697.0+8cbf697",
35
+ "@agoric/internal": "0.2.2-dev-8cbf697.0+8cbf697",
36
+ "@agoric/notifier": "0.5.2-dev-8cbf697.0+8cbf697",
37
+ "@agoric/store": "0.8.4-dev-8cbf697.0+8cbf697",
38
+ "@agoric/swingset-liveslots": "0.9.1-dev-8cbf697.0+8cbf697",
39
+ "@agoric/swingset-vat": "0.30.3-dev-8cbf697.0+8cbf697",
40
+ "@agoric/time": "0.2.2-dev-8cbf697.0+8cbf697",
41
+ "@agoric/vat-data": "0.4.4-dev-8cbf697.0+8cbf697",
42
+ "@agoric/vats": "0.13.1-dev-8cbf697.0+8cbf697",
43
+ "@agoric/zoe": "0.25.4-dev-8cbf697.0+8cbf697",
44
44
  "@endo/bundle-source": "^2.4.2",
45
45
  "@endo/captp": "^2.0.18",
46
46
  "@endo/eventual-send": "^0.16.8",
@@ -50,8 +50,8 @@
50
50
  "@endo/promise-kit": "^0.2.52"
51
51
  },
52
52
  "devDependencies": {
53
- "@agoric/deploy-script-support": "0.9.5-dev-2f08018.0+2f08018",
54
- "@agoric/smart-wallet": "0.4.3-dev-2f08018.0+2f08018",
53
+ "@agoric/deploy-script-support": "0.9.5-dev-8cbf697.0+8cbf697",
54
+ "@agoric/smart-wallet": "0.4.3-dev-8cbf697.0+8cbf697",
55
55
  "@endo/init": "^0.5.52",
56
56
  "@fast-check/ava": "^1.1.3",
57
57
  "ava": "^5.1.0",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "2f0801825db82c1a391ca38578c9cc6cbc790bb4"
81
+ "gitHead": "8cbf6974a8c1e189589620fef4b682b1c3e134b2"
82
82
  }
@@ -89,6 +89,7 @@ const validTransitions = {
89
89
  * @property {() => Subscriber<import('./vaultManager').AssetState>} getAssetSubscriber
90
90
  * @property {(collateralAmount: Amount) => ERef<Amount<'nat'>>} maxDebtFor
91
91
  * @property {() => Brand} getCollateralBrand
92
+ * @property {(base: string) => string} scopeDescription
92
93
  * @property {() => Brand<'nat'>} getDebtBrand
93
94
  * @property {MintAndReallocate} mintAndReallocate
94
95
  * @property {(amount: Amount, seat: ZCFSeat) => void} burnAndRecord
@@ -796,22 +797,22 @@ export const prepareVault = (baggage, marshaller, zcf) => {
796
797
  },
797
798
 
798
799
  makeAdjustBalancesInvitation() {
799
- const { facets } = this;
800
+ const { state, facets } = this;
800
801
  const { helper } = facets;
801
802
  helper.assertActive();
802
803
  return zcf.makeInvitation(
803
804
  seat => helper.adjustBalancesHook(seat),
804
- 'AdjustBalances',
805
+ state.manager.scopeDescription('AdjustBalances'),
805
806
  );
806
807
  },
807
808
 
808
809
  makeCloseInvitation() {
809
- const { facets } = this;
810
+ const { state, facets } = this;
810
811
  const { helper } = facets;
811
812
  helper.assertCloseable();
812
813
  return zcf.makeInvitation(
813
814
  seat => helper.closeHook(seat),
814
- 'CloseVault',
815
+ state.manager.scopeDescription('CloseVault'),
815
816
  );
816
817
  },
817
818
 
@@ -840,7 +841,7 @@ export const prepareVault = (baggage, marshaller, zcf) => {
840
841
  };
841
842
  return zcf.makeInvitation(
842
843
  seat => helper.makeTransferInvitationHook(seat),
843
- 'TransferVault',
844
+ state.manager.scopeDescription('TransferVault'),
844
845
  transferState,
845
846
  );
846
847
  },
@@ -6,7 +6,6 @@ import { E } from '@endo/eventual-send';
6
6
 
7
7
  import { keyEQ, M, makeScalarMapStore, mustMatch } from '@agoric/store';
8
8
  import {
9
- assertProposalShape,
10
9
  getAmountIn,
11
10
  getAmountOut,
12
11
  provideChildBaggage,
@@ -98,6 +97,7 @@ export const prepareVaultDirector = (
98
97
  const mintSeat = provideEmptySeat(zcf, baggage, 'mintSeat');
99
98
  const rewardPoolSeat = provideEmptySeat(zcf, baggage, 'rewardPoolSeat');
100
99
 
100
+ /** @type {MapStore<Brand, VaultManager>} */
101
101
  const collateralTypes = provideDurableMapStore(baggage, 'collateralTypes');
102
102
 
103
103
  // Non-durable map because param managers aren't durable.
@@ -215,6 +215,7 @@ export const prepareVaultDirector = (
215
215
  getLimitedCreatorFacet: M.call().returns(M.remotable()),
216
216
  getGovernedApis: M.call().returns(M.record()),
217
217
  getGovernedApiNames: M.call().returns(M.record()),
218
+ setOfferFilter: M.call(M.arrayOf(M.string())).returns(M.promise()),
218
219
  }),
219
220
  machine: M.interface('machine', {
220
221
  addVaultType: M.call(IssuerShape, M.string(), M.record()).returns(
@@ -229,7 +230,6 @@ export const prepareVaultDirector = (
229
230
  getCollateralManager: M.call(BrandShape).returns(M.remotable()),
230
231
  getCollaterals: M.call().returns(M.promise()),
231
232
  getMetrics: M.call().returns(SubscriberShape),
232
- makeVaultInvitation: M.call().returns(M.promise()),
233
233
  getRunIssuer: M.call().returns(IssuerShape),
234
234
  getSubscription: M.call({ collateralBrand: BrandShape }).returns(
235
235
  SubscriberShape,
@@ -274,6 +274,7 @@ export const prepareVaultDirector = (
274
274
  getGovernedApiNames() {
275
275
  return harden({});
276
276
  },
277
+ setOfferFilter: strings => zcf.setOfferFilter(strings),
277
278
  },
278
279
  machine: {
279
280
  // TODO move this under governance #3924
@@ -301,10 +302,10 @@ export const prepareVaultDirector = (
301
302
  !collateralTypes.has(collateralBrand) ||
302
303
  Fail`Collateral brand ${q(collateralBrand)} has already been added`;
303
304
 
305
+ // counter to be incremented at end of addVaultType
306
+ const managerId = `manager${state.managerCounter}`;
304
307
  const managerStorageNode =
305
- storageNode &&
306
- E(storageNode).makeChildNode(`manager${state.managerCounter}`);
307
- state.managerCounter += 1;
308
+ storageNode && E(storageNode).makeChildNode(managerId);
308
309
 
309
310
  /** a powerful object; can modify parameters */
310
311
  const vaultParamManager = makeVaultParamManager(
@@ -397,13 +398,16 @@ export const prepareVaultDirector = (
397
398
  brandName,
398
399
  prepareVaultManagerKit,
399
400
  zcf,
400
- debtMint,
401
- collateralBrand,
402
- collateralUnit,
403
- factoryPowers,
404
- startTimeStamp,
405
- managerStorageNode,
406
401
  marshaller,
402
+ {
403
+ debtMint,
404
+ collateralBrand,
405
+ collateralUnit,
406
+ descriptionScope: managerId,
407
+ factoryPowers,
408
+ startTimeStamp,
409
+ storageNode: managerStorageNode,
410
+ },
407
411
  );
408
412
 
409
413
  const { self: vm } = makeVaultManager();
@@ -412,6 +416,7 @@ export const prepareVaultDirector = (
412
416
  await vm.setupLiquidator(install, terms);
413
417
  watchGovernance(vm, install, terms);
414
418
  facets.machine.updateMetrics();
419
+ state.managerCounter += 1;
415
420
  return vm;
416
421
  },
417
422
  makeCollectFeesInvitation() {
@@ -472,40 +477,6 @@ export const prepareVaultDirector = (
472
477
  getMetrics() {
473
478
  return metricsSubscriber;
474
479
  },
475
- /**
476
- * @deprecated use getCollateralManager and then makeVaultInvitation instead
477
- *
478
- * Make a vault in the vaultManager based on the collateral type.
479
- */
480
- makeVaultInvitation() {
481
- /** @param {ZCFSeat} seat */
482
- const makeVaultHook = async seat => {
483
- assertProposalShape(seat, {
484
- give: { Collateral: null },
485
- want: { Minted: null },
486
- });
487
- const {
488
- give: { Collateral: collateralAmount },
489
- want: { Minted: requestedAmount },
490
- } = seat.getProposal();
491
- const { brand: brandIn } = collateralAmount;
492
- collateralTypes.has(brandIn) ||
493
- Fail`Not a supported collateral type ${brandIn}`;
494
-
495
- AmountMath.isGTE(
496
- requestedAmount,
497
- directorParamManager.getMinInitialDebt(),
498
- ) ||
499
- Fail`The request must be for at least ${
500
- directorParamManager.getMinInitialDebt().value
501
- }. ${requestedAmount.value} is too small`;
502
-
503
- /** @type {VaultManager} */
504
- const mgr = collateralTypes.get(brandIn);
505
- return mgr.makeVaultKit(seat);
506
- };
507
- return zcf.makeInvitation(makeVaultHook, 'MakeVault');
508
- },
509
480
  getRunIssuer() {
510
481
  return debtMint.getIssuerRecord().issuer;
511
482
  },
@@ -127,24 +127,30 @@ const trace = makeTracer('VM', false);
127
127
  *
128
128
  * @param {import('@agoric/ertp').Baggage} baggage
129
129
  * @param {import('./vaultFactory.js').VaultFactoryZCF} zcf
130
- * @param {ZCFMint<'nat'>} debtMint
131
- * @param {Brand<'nat'>} collateralBrand
132
- * @param {Amount<'nat'>} collateralUnit
133
- * @param {import('./vaultDirector.js').FactoryPowersFacet} factoryPowers
134
- * @param {Timestamp} startTimeStamp
135
- * @param {ERef<StorageNode>} storageNode
136
130
  * @param {ERef<Marshaller>} marshaller
131
+ * @param {Readonly<{
132
+ * debtMint: ZCFMint<'nat'>,
133
+ * collateralBrand: Brand<'nat'>,
134
+ * collateralUnit: Amount<'nat'>,
135
+ * factoryPowers: import('./vaultDirector.js').FactoryPowersFacet,
136
+ * descriptionScope: string,
137
+ * startTimeStamp: Timestamp,
138
+ * storageNode: ERef<StorageNode>,
139
+ * }>} unique per singleton
137
140
  */
138
141
  export const prepareVaultManagerKit = (
139
142
  baggage,
140
143
  zcf,
141
- debtMint,
142
- collateralBrand,
143
- collateralUnit,
144
- factoryPowers,
145
- startTimeStamp,
146
- storageNode,
147
144
  marshaller,
145
+ {
146
+ debtMint,
147
+ collateralBrand,
148
+ collateralUnit,
149
+ descriptionScope,
150
+ factoryPowers,
151
+ startTimeStamp,
152
+ storageNode,
153
+ },
148
154
  ) => {
149
155
  assert(
150
156
  storageNode && marshaller,
@@ -276,6 +282,7 @@ export const prepareVaultManagerKit = (
276
282
  getCollateralBrand: M.call().returns(BrandShape),
277
283
  getDebtBrand: M.call().returns(BrandShape),
278
284
  getCompoundedInterest: M.call().returns(RatioShape),
285
+ scopeDescription: M.call(M.string()).returns(M.string()),
279
286
  handleBalanceChange: M.call(
280
287
  AmountShape,
281
288
  AmountShape,
@@ -299,9 +306,10 @@ export const prepareVaultManagerKit = (
299
306
  {
300
307
  collateral: {
301
308
  makeVaultInvitation() {
309
+ const { facets } = this;
302
310
  return zcf.makeInvitation(
303
311
  seat => this.facets.self.makeVaultKit(seat),
304
- 'MakeVault',
312
+ facets.manager.scopeDescription('MakeVault'),
305
313
  );
306
314
  },
307
315
  /** @deprecated use getPublicTopics */
@@ -688,6 +696,14 @@ export const prepareVaultManagerKit = (
688
696
  getDebtBrand() {
689
697
  return debtBrand;
690
698
  },
699
+ /**
700
+ * Prepend with an identifier of this vault manager
701
+ *
702
+ * @param {string} base
703
+ */
704
+ scopeDescription(base) {
705
+ return `${descriptionScope}: ${base}`;
706
+ },
691
707
  /**
692
708
  * coefficient on existing debt to calculate new debt
693
709
  */