@agoric/inter-protocol 0.16.1-dev-13050c2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.16.1-dev-13050c2.0+13050c2",
3
+ "version": "0.16.1",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -10,7 +10,6 @@
10
10
  "scripts": {
11
11
  "build": "yarn build:bundles",
12
12
  "build:bundles": "node ./scripts/build-bundles.js",
13
- "build:add-STARS-proposal": "agoric run scripts/add-STARS.js",
14
13
  "test": "ava",
15
14
  "test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
16
15
  "test:xs": "exit 0",
@@ -30,29 +29,29 @@
30
29
  },
31
30
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
32
31
  "dependencies": {
33
- "@agoric/assert": "0.6.1-dev-13050c2.0+13050c2",
34
- "@agoric/ertp": "0.16.3-dev-13050c2.0+13050c2",
35
- "@agoric/governance": "0.10.3-dev-13050c2.0+13050c2",
36
- "@agoric/internal": "0.3.3-dev-13050c2.0+13050c2",
37
- "@agoric/notifier": "0.6.3-dev-13050c2.0+13050c2",
38
- "@agoric/store": "0.9.3-dev-13050c2.0+13050c2",
39
- "@agoric/time": "0.3.3-dev-13050c2.0+13050c2",
40
- "@agoric/vat-data": "0.5.3-dev-13050c2.0+13050c2",
41
- "@agoric/vats": "0.15.1-dev-13050c2.0+13050c2",
42
- "@agoric/zoe": "0.26.3-dev-13050c2.0+13050c2",
32
+ "@agoric/assert": "^0.6.0",
33
+ "@agoric/ertp": "^0.16.2",
34
+ "@agoric/governance": "^0.10.3",
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.1",
41
+ "@agoric/zoe": "^0.26.2",
43
42
  "@endo/captp": "^3.1.1",
44
43
  "@endo/eventual-send": "^0.17.2",
45
44
  "@endo/far": "^0.2.18",
46
45
  "@endo/marshal": "^0.8.5",
47
46
  "@endo/nat": "^4.1.27",
48
- "agoric": "0.21.1-dev-13050c2.0+13050c2",
47
+ "agoric": "^0.21.1",
49
48
  "jessie.js": "^0.3.2"
50
49
  },
51
50
  "devDependencies": {
52
- "@agoric/deploy-script-support": "0.10.3-dev-13050c2.0+13050c2",
53
- "@agoric/smart-wallet": "0.5.3-dev-13050c2.0+13050c2",
54
- "@agoric/swingset-liveslots": "0.10.3-dev-13050c2.0+13050c2",
55
- "@agoric/swingset-vat": "0.32.3-dev-13050c2.0+13050c2",
51
+ "@agoric/deploy-script-support": "^0.10.3",
52
+ "@agoric/smart-wallet": "^0.5.3",
53
+ "@agoric/swingset-liveslots": "^0.10.2",
54
+ "@agoric/swingset-vat": "^0.32.2",
56
55
  "@endo/bundle-source": "^2.5.1",
57
56
  "@endo/init": "^0.5.56",
58
57
  "@endo/promise-kit": "^0.2.56",
@@ -80,5 +79,5 @@
80
79
  "publishConfig": {
81
80
  "access": "public"
82
81
  },
83
- "gitHead": "13050c28e9a154e188cff8f1d08c704a4c7ca26a"
82
+ "gitHead": "ba3b776444425bbcb275ce918794d9259f8e15da"
84
83
  }
@@ -149,7 +149,18 @@ export const makeScheduler = async (
149
149
  auctionState = AuctionState.WAITING;
150
150
  auctionDriver.finalize();
151
151
 
152
- if (!nextSchedule) {
152
+ if (nextSchedule) {
153
+ // only recalculate the next schedule at this point if the lock time has
154
+ // not been reached.
155
+ const nextLock = nextSchedule.lockTime;
156
+ if (nextLock && TimeMath.compareAbs(now, nextLock) < 0) {
157
+ const afterNow = TimeMath.addAbsRel(
158
+ now,
159
+ TimeMath.coerceRelativeTimeRecord(1n, timerBrand),
160
+ );
161
+ nextSchedule = safelyComputeRoundTiming(params, afterNow);
162
+ }
163
+ } else {
153
164
  console.error(
154
165
  '🛠️ finishAuctionRound without scheduling the next; repair with new auctioneer params',
155
166
  );
@@ -322,7 +333,6 @@ export const makeScheduler = async (
322
333
  // NB: may be fired with the initial params as well
323
334
  async updateState(_newState) {
324
335
  trace('received param update', _newState);
325
- await null;
326
336
  if (!nextSchedule) {
327
337
  trace('repairing nextSchedule and restarting');
328
338
  ({ nextSchedule } = await initializeNextSchedule());
@@ -131,8 +131,10 @@ export const prepare = async (zcf, privateArgs, baggage) => {
131
131
  addr,
132
132
  [invitation],
133
133
  );
134
- await (highPrioritySendersManager &&
135
- E(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
+ }
136
138
  return `added ${addr}`;
137
139
  };
138
140
 
@@ -144,8 +146,10 @@ export const prepare = async (zcf, privateArgs, baggage) => {
144
146
  const removeOracle = async addr => {
145
147
  trace('removeOracle', addr);
146
148
  await E(faKit.creator).removeOracle(addr);
147
- await (highPrioritySendersManager &&
148
- E(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
+ }
149
153
  return `removed ${addr}`;
150
154
  };
151
155
 
@@ -1,12 +1,11 @@
1
1
  // @jessie-check
2
2
 
3
3
  import { AmountMath, AssetKind } from '@agoric/ertp';
4
+ import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
4
5
  import { deeplyFulfilledObject } from '@agoric/internal';
5
6
  import { Stable } from '@agoric/vats/src/tokens.js';
6
- import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
7
- import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
8
7
  import { E } from '@endo/far';
9
- import { instanceNameFor } from './price-feed-proposal.js';
8
+ import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
10
9
  import { reserveThenGetNames } from './utils.js';
11
10
 
12
11
  export * from './startPSM.js';
@@ -220,7 +219,6 @@ export const addAssetToVault = async (
220
219
  brand: {
221
220
  consume: { [Stable.symbol]: stableP },
222
221
  },
223
- instance: { consume: consumeInstance },
224
222
  },
225
223
  {
226
224
  options: {
@@ -241,11 +239,6 @@ export const addAssetToVault = async (
241
239
  [keyword],
242
240
  );
243
241
 
244
- const oracleInstanceName = instanceNameFor(oracleBrand, 'USD');
245
- // don't add the collateral offering to vaultFactory until its price feed is available
246
- // eslint-disable-next-line no-restricted-syntax -- allow this computed property
247
- await consumeInstance[oracleInstanceName];
248
-
249
242
  const stable = await stableP;
250
243
  const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
251
244
  await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
@@ -328,11 +321,6 @@ export const getManifestForAddAssetToVault = (
328
321
  brand: {
329
322
  consume: { [Stable.symbol]: true },
330
323
  },
331
- instance: {
332
- // allow any instance because the AGORIC_INSTANCE_NAME of
333
- // priceFeedOptions cannot be known statically.
334
- consume: true,
335
- },
336
324
  },
337
325
  },
338
326
  installations: {
@@ -1,10 +1,10 @@
1
1
  // @ts-nocheck -- lots of type errors. low prio b/c proposals are like scripts
2
- import { makeTracer } from '@agoric/internal';
2
+ import { E } from '@endo/far';
3
3
  import {
4
- assertPathSegment,
5
4
  makeStorageNodeChild,
5
+ assertPathSegment,
6
6
  } from '@agoric/internal/src/lib-chainStorage.js';
7
- import { E } from '@endo/far';
7
+ import { makeTracer } from '@agoric/internal';
8
8
 
9
9
  import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
10
10
  import { reserveThenDeposit, reserveThenGetNames } from './utils.js';
@@ -18,9 +18,6 @@ const sanitizePathSegment = name => {
18
18
  return candidate;
19
19
  };
20
20
 
21
- export const instanceNameFor = (inBrandName, outBrandName) =>
22
- `${inBrandName}-${outBrandName} price feed`;
23
-
24
21
  /**
25
22
  * @typedef {{
26
23
  * brandIn?: ERef<Brand<'nat'> | undefined>,
@@ -65,6 +62,7 @@ export const ensureOracleBrands = async (
65
62
  let b = await brand;
66
63
  if (!b) {
67
64
  // not 1st await
65
+ // eslint-disable-next-line @jessie.js/no-nested-await
68
66
  b = await E(agoricNames).provideInertBrand(
69
67
  name,
70
68
  harden({ decimalPlaces: parseInt(decimals, 10) }),
@@ -98,7 +96,6 @@ export const createPriceFeed = async (
98
96
  priceAuthorityAdmin,
99
97
  startGovernedUpgradable,
100
98
  },
101
- instance: { produce: produceInstance },
102
99
  },
103
100
  {
104
101
  options: {
@@ -164,27 +161,11 @@ export const createPriceFeed = async (
164
161
  installation: priceAggregator,
165
162
  });
166
163
 
167
- // Publish price feed in home.priceAuthority.
168
- const forceReplace = true;
169
- // Make sure this PA is registered before sharing the instance in agoricNames,
170
- // which allows contracts that depend on the registry value to wait for it and
171
- // prevent a race.
172
- await E(priceAuthorityAdmin).registerPriceAuthority(
173
- E(faKit.publicFacet).getPriceAuthority(),
174
- brandIn,
175
- brandOut,
176
- forceReplace,
177
- );
178
-
179
- await E(E(agoricNamesAdmin).lookupAdmin('instance'))
164
+ E(E(agoricNamesAdmin).lookupAdmin('instance'))
180
165
  .update(AGORIC_INSTANCE_NAME, faKit.instance)
181
166
  .catch(err =>
182
167
  console.error(`🚨 failed to update ${AGORIC_INSTANCE_NAME}`, err),
183
168
  );
184
- // being after the above awaits means that when this resolves, the consumer
185
- // gets notified that the authority is in the registry and its instance is in
186
- // agoricNames.
187
- produceInstance[AGORIC_INSTANCE_NAME].resolve(faKit.instance);
188
169
 
189
170
  E(E.get(econCharterKit).creatorFacet).addInstance(
190
171
  faKit.instance,
@@ -193,6 +174,15 @@ export const createPriceFeed = async (
193
174
  );
194
175
  trace('registered', AGORIC_INSTANCE_NAME, faKit.instance);
195
176
 
177
+ // Publish price feed in home.priceAuthority.
178
+ const forceReplace = true;
179
+ void E(priceAuthorityAdmin).registerPriceAuthority(
180
+ E(faKit.publicFacet).getPriceAuthority(),
181
+ brandIn,
182
+ brandOut,
183
+ forceReplace,
184
+ );
185
+
196
186
  /**
197
187
  * Initialize a new oracle and send an invitation to administer it.
198
188
  *
@@ -242,9 +232,6 @@ export const getManifestForPriceFeed = async (
242
232
  priceAuthorityAdmin: t,
243
233
  startGovernedUpgradable: t,
244
234
  },
245
- instance: {
246
- produce: t,
247
- },
248
235
  },
249
236
  [ensureOracleBrands.name]: {
250
237
  namedVat: {
@@ -256,7 +243,6 @@ export const getManifestForPriceFeed = async (
256
243
  },
257
244
  },
258
245
  installations: {
259
- // ??? will every eval of price-feed-proposal install priceAggregator ?
260
246
  priceAggregator: restoreRef(priceFeedOptions.priceAggregatorRef),
261
247
  },
262
248
  options: {
@@ -317,7 +303,7 @@ export const startPriceFeeds = async (
317
303
  {
318
304
  options: {
319
305
  priceFeedOptions: {
320
- AGORIC_INSTANCE_NAME: instanceNameFor(inBrandName, outBrandName),
306
+ AGORIC_INSTANCE_NAME: `${inBrandName}-${outBrandName} price feed`,
321
307
  contractTerms: {
322
308
  minSubmissionCount: 2,
323
309
  minSubmissionValue: 1,
@@ -363,25 +363,23 @@ export const makeAnchorAsset = async (
363
363
  slotToBoardRemote,
364
364
  );
365
365
  const metricsKey = `${stablePsmKey}.${keyword}.metrics`;
366
- const maybeReviveMetrics = async () => {
367
- if (!toSlotReviver.has(metricsKey)) {
368
- return;
369
- }
366
+ if (toSlotReviver.has(metricsKey)) {
370
367
  const metrics = toSlotReviver.getItem(metricsKey);
371
368
  produceAnchorBalancePayments.resolve(
372
369
  makeScalarBigMapStore('Anchor balance payments', { durable: true }),
373
370
  );
374
371
  // XXX this rule should only apply to the 1st await
372
+ // eslint-disable-next-line @jessie.js/no-nested-await
375
373
  const anchorPaymentMap = await anchorBalancePayments;
376
374
 
377
375
  // TODO: validate that `metrics.anchorPoolBalance.value` is
378
376
  // pass-by-copy PureData (e.g., contains no remotables).
377
+ // eslint-disable-next-line @jessie.js/no-nested-await
379
378
  const pmt = await E(mint).mintPayment(
380
379
  AmountMath.make(brand, metrics.anchorPoolBalance.value),
381
380
  );
382
381
  anchorPaymentMap.init(brand, pmt);
383
- };
384
- await maybeReviveMetrics();
382
+ }
385
383
 
386
384
  await Promise.all([
387
385
  E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, kit.issuer),
@@ -66,11 +66,11 @@ export const prepare = async (zcf, privateArgs, baggage) => {
66
66
  };
67
67
  trace('awaiting takeFeeMint');
68
68
  const feeMint = await takeFeeMint();
69
- const storageNode = await privateArgs.storageNode;
70
69
  const makeAssetReserveKit = await prepareAssetReserveKit(baggage, {
71
70
  feeMint,
72
71
  makeRecorderKit,
73
- storageNode,
72
+ // eslint-disable-next-line @jessie.js/no-nested-await -- spurious
73
+ storageNode: await privateArgs.storageNode,
74
74
  zcf,
75
75
  });
76
76
 
@@ -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
  },
@@ -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) {
@@ -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,7 +1047,7 @@ 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;
@@ -1060,19 +1061,11 @@ export const prepareVaultManagerKit = (
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
 
@@ -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
- };