@agoric/inter-protocol 0.13.2-dev-e61a41e.0 → 0.13.2-dev-d092592.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-e61a41e.0+e61a41e",
3
+ "version": "0.13.2-dev-d092592.0+d092592",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -29,17 +29,17 @@
29
29
  },
30
30
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
31
  "dependencies": {
32
- "@agoric/assert": "0.5.2-dev-e61a41e.0+e61a41e",
33
- "@agoric/ertp": "0.15.4-dev-e61a41e.0+e61a41e",
34
- "@agoric/governance": "0.9.2-dev-e61a41e.0+e61a41e",
35
- "@agoric/internal": "0.2.2-dev-e61a41e.0+e61a41e",
32
+ "@agoric/assert": "0.5.2-dev-d092592.0+d092592",
33
+ "@agoric/ertp": "0.15.4-dev-d092592.0+d092592",
34
+ "@agoric/governance": "0.9.2-dev-d092592.0+d092592",
35
+ "@agoric/internal": "0.2.2-dev-d092592.0+d092592",
36
36
  "@agoric/nat": "^4.1.0",
37
- "@agoric/notifier": "0.5.2-dev-e61a41e.0+e61a41e",
38
- "@agoric/store": "0.8.4-dev-e61a41e.0+e61a41e",
39
- "@agoric/swingset-vat": "0.30.3-dev-e61a41e.0+e61a41e",
40
- "@agoric/vat-data": "0.4.4-dev-e61a41e.0+e61a41e",
41
- "@agoric/vats": "0.13.1-dev-e61a41e.0+e61a41e",
42
- "@agoric/zoe": "0.25.4-dev-e61a41e.0+e61a41e",
37
+ "@agoric/notifier": "0.5.2-dev-d092592.0+d092592",
38
+ "@agoric/store": "0.8.4-dev-d092592.0+d092592",
39
+ "@agoric/swingset-vat": "0.30.3-dev-d092592.0+d092592",
40
+ "@agoric/vat-data": "0.4.4-dev-d092592.0+d092592",
41
+ "@agoric/vats": "0.13.1-dev-d092592.0+d092592",
42
+ "@agoric/zoe": "0.25.4-dev-d092592.0+d092592",
43
43
  "@endo/bundle-source": "^2.4.2",
44
44
  "@endo/captp": "^2.0.18",
45
45
  "@endo/eventual-send": "^0.16.8",
@@ -49,9 +49,9 @@
49
49
  "@endo/promise-kit": "^0.2.52"
50
50
  },
51
51
  "devDependencies": {
52
- "@agoric/cosmic-swingset": "0.39.3-dev-e61a41e.0+e61a41e",
53
- "@agoric/deploy-script-support": "0.9.5-dev-e61a41e.0+e61a41e",
54
- "@agoric/smart-wallet": "0.4.3-dev-e61a41e.0+e61a41e",
52
+ "@agoric/cosmic-swingset": "0.39.3-dev-d092592.0+d092592",
53
+ "@agoric/deploy-script-support": "0.9.5-dev-d092592.0+d092592",
54
+ "@agoric/smart-wallet": "0.4.3-dev-d092592.0+d092592",
55
55
  "@endo/init": "^0.5.52",
56
56
  "@fast-check/ava": "^1.0.1",
57
57
  "ava": "^5.0.1",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "e61a41e501c1964013df94c61f8ec6c092a83c5b"
81
+ "gitHead": "d0925925fe4c47daf823a4e34aad95869dbd22ed"
82
82
  }
@@ -25,7 +25,10 @@ await extractProposalBundles(
25
25
  await createBundles(
26
26
  [
27
27
  ['../src/psm/psm.js', '../bundles/bundle-psm.js'],
28
- ['../src/psm/psmCharter.js', '../bundles/bundle-psmCharter.js'],
28
+ [
29
+ '../src/econCommitteeCharter.js',
30
+ '../bundles/bundle-econCommitteeCharter.js',
31
+ ],
29
32
  ],
30
33
  dirname,
31
34
  );
@@ -51,8 +51,8 @@
51
51
  "psm": {
52
52
  "sourceSpec": "@agoric/inter-protocol/src/psm/psm.js"
53
53
  },
54
- "psmCharter": {
55
- "sourceSpec": "@agoric/inter-protocol/src/psm/psmCharter.js"
54
+ "econCommitteeCharter": {
55
+ "sourceSpec": "@agoric/inter-protocol/src/econCommitteeCharter.js"
56
56
  },
57
57
  "priceAggregator": {
58
58
  "sourceSpec": "@agoric/zoe/src/contracts/priceAggregator.js"
@@ -1,100 +1,132 @@
1
1
  import '@agoric/governance/exported.js';
2
+ import { makeScalarMapStore, M, makeHeapFarInstance, fit } from '@agoric/store';
2
3
  import '@agoric/zoe/exported.js';
3
4
  import '@agoric/zoe/src/contracts/exported.js';
4
-
5
- import { E, Far } from '@endo/far';
5
+ import { InstanceHandleShape } from '@agoric/zoe/src/typeGuards.js';
6
+ import { TimestampShape } from '@agoric/swingset-vat/src/vats/timer/typeGuards.js';
7
+ import { E } from '@endo/far';
6
8
 
7
9
  /**
8
10
  * @file
9
11
  *
10
- * This extremely quick and dirty contract simplifies the process of
11
- * calling for votes on changes to the economy by gathering the governor creator
12
- * facets in one place and invokes `voteOnParamChanges` and
13
- * `voteOnApiInvocation` on each when requested. A cleaner version would
14
- * validate parameters, constrain deadlines and probably split the ability to
15
- * call for vote into separate capabilities for finer grain encapsulation.
12
+ * This contract makes it possible for those who govern contracts to call for
13
+ * votes on changes. A more complete implementation would validate parameters,
14
+ * constrain deadlines and possibly split the ability to call for votes into
15
+ * separate capabilities for finer grain encapsulation.
16
+ */
17
+
18
+ export const INVITATION_MAKERS_DESC = 'charter member invitation';
19
+
20
+ /**
21
+ * @typedef {object} ParamChangesOfferArgs
22
+ * @property {bigint} deadline
23
+ * @property {Instance} instance
24
+ * @property {Record<string, unknown>} params
25
+ * @property {{paramPath: { key: string }}} [path]
16
26
  */
27
+ const ParamChangesOfferArgsShape = harden(
28
+ M.split(
29
+ {
30
+ deadline: TimestampShape,
31
+ instance: InstanceHandleShape,
32
+ params: M.recordOf(M.string(), M.any()),
33
+ },
34
+ M.partial({
35
+ path: { paramPath: { key: M.any() } },
36
+ }),
37
+ ),
38
+ );
17
39
 
18
40
  /**
19
41
  * @param {ZCF<{binaryVoteCounterInstallation:Installation}>} zcf
20
- * @param {{reserve:GovernedContractFacetAccess<{},{}>, amm:GovernedCreatorFacet<{}>, vaults:GovernedCreatorFacet<{}>}} privateArgs
21
42
  */
22
- export const start = async (zcf, privateArgs) => {
43
+ export const start = async zcf => {
23
44
  const { binaryVoteCounterInstallation: counter } = zcf.getTerms();
24
- const { reserve, amm, vaults } = privateArgs;
45
+ /** @type {MapStore<Instance,GovernedContractFacetAccess<{},{}>>} */
46
+ const instanceToGovernor = makeScalarMapStore();
47
+
48
+ const makeParamInvitation = () => {
49
+ /**
50
+ * @param {ZCFSeat} seat
51
+ * @param {ParamChangesOfferArgs} args
52
+ */
53
+ const voteOnParamChanges = (seat, args) => {
54
+ fit(args, ParamChangesOfferArgsShape);
55
+ seat.exit();
56
+
57
+ const {
58
+ params,
59
+ instance,
60
+ deadline,
61
+ path = { paramPath: { key: 'governedApi' } },
62
+ } = args;
63
+ const governor = instanceToGovernor.get(instance);
64
+ return E(governor).voteOnParamChanges(counter, deadline, {
65
+ ...path,
66
+ changes: params,
67
+ });
68
+ };
25
69
 
26
- /**
27
- * @param {*} target
28
- * @param {Record<string, unknown>} params
29
- * @param {bigint} deadline
30
- * @param {{paramPath: { key: unknown }}} [path]
31
- */
32
- const voteOnParamChanges = (
33
- target,
34
- params,
35
- deadline,
36
- path = { paramPath: { key: 'governedApi' } },
37
- ) => {
38
- return E(target).voteOnParamChanges(counter, deadline, {
39
- ...path,
40
- changes: params,
41
- });
70
+ return zcf.makeInvitation(voteOnParamChanges, 'vote on param changes');
42
71
  };
43
72
 
44
- /**
45
- * @param {*} target
46
- * @param {string} method
47
- * @param {unknown[]} args
48
- * @param {bigint} deadline
49
- */
50
- const voteOnApiInvocation = (target, method, args, deadline) => {
51
- return E(target).voteOnApiInvocation(method, args, counter, deadline);
73
+ const makeOfferFilterInvitation = (instance, strings, deadline) => {
74
+ const voteOnOfferFilterHandler = seat => {
75
+ seat.exit();
76
+
77
+ const governor = instanceToGovernor.get(instance);
78
+ return E(governor).voteOnOfferFilter(counter, deadline, strings);
79
+ };
80
+
81
+ return zcf.makeInvitation(voteOnOfferFilterHandler, 'vote on offer filter');
52
82
  };
53
83
 
54
- const makeNullInvitation = () => {
55
- return zcf.makeInvitation(() => {}, 'econCommitteeCharter noop');
84
+ const MakerShape = M.interface('Charter InvitationMakers', {
85
+ VoteOnParamChange: M.call().returns(M.promise()),
86
+ VoteOnPauseOffers: M.call(
87
+ InstanceHandleShape,
88
+ M.arrayOf(M.string()),
89
+ TimestampShape,
90
+ ).returns(M.promise()),
91
+ });
92
+ const invitationMakers = makeHeapFarInstance(
93
+ 'Charter Invitation Makers',
94
+ MakerShape,
95
+ {
96
+ VoteOnParamChange: makeParamInvitation,
97
+ VoteOnPauseOffers: makeOfferFilterInvitation,
98
+ },
99
+ );
100
+
101
+ const charterMemberHandler = seat => {
102
+ seat.exit();
103
+ return harden({ invitationMakers });
56
104
  };
57
105
 
58
- const publicFacet = Far('votingAPI', {
59
- /**
60
- * @param {Record<string, unknown>} params
61
- * @param {bigint} deadline
62
- */
63
- voteOnAmmParamChanges: (params, deadline) =>
64
- voteOnParamChanges(amm, params, deadline),
65
- /**
66
- * @param {Record<string, unknown>} params
67
- * @param {bigint} deadline
68
- */
69
- voteOnReserveParamChanges: (params, deadline) =>
70
- voteOnParamChanges(reserve, params, deadline),
71
- /**
72
- * vote on param changes for a vaultManager
73
- *
74
- * @param {Record<string, unknown>} params
75
- * @param {{collateralBrand: Brand}} brand
76
- * @param {bigint} deadline
77
- */
78
- voteOnVaultParamChanges: (params, brand, deadline) =>
79
- voteOnParamChanges(vaults, params, deadline, {
80
- paramPath: { key: brand },
81
- }),
82
- /**
83
- * vote on param changes across the vaultFactory
84
- *
85
- * @param {Record<string, unknown>} params
86
- * @param {bigint} deadline
87
- */
88
- voteOnVaultFactoryParamChanges: (params, deadline) =>
89
- voteOnParamChanges(vaults, params, deadline),
90
- /**
91
- * @param {Amount[]} amounts
92
- * @param {bigint} deadline
93
- */
94
- voteOnReserveApiInvocation: (amounts, deadline) =>
95
- voteOnApiInvocation(reserve, 'addLiquidityToAmmPool', amounts, deadline),
96
- makeNullInvitation,
106
+ const charterCreatorI = M.interface('Charter creatorFacet', {
107
+ addInstance: M.call(InstanceHandleShape, M.any())
108
+ .optional(M.string())
109
+ .returns(),
110
+ makeCharterMemberInvitation: M.call().returns(M.promise()),
97
111
  });
98
112
 
99
- return harden({ publicFacet });
113
+ const creatorFacet = makeHeapFarInstance(
114
+ 'Charter creatorFacet',
115
+ charterCreatorI,
116
+ {
117
+ /**
118
+ * @param {Instance} governedInstance
119
+ * @param {GovernedContractFacetAccess<{},{}>} governorFacet
120
+ * @param {string} [label] for diagnostic use only
121
+ */
122
+ addInstance: (governedInstance, governorFacet, label) => {
123
+ console.log('charter: adding instance', label);
124
+ instanceToGovernor.init(governedInstance, governorFacet);
125
+ },
126
+ makeCharterMemberInvitation: () =>
127
+ zcf.makeInvitation(charterMemberHandler, INVITATION_MAKERS_DESC),
128
+ },
129
+ );
130
+
131
+ return harden({ creatorFacet });
100
132
  };
@@ -22,12 +22,17 @@ export const inviteCommitteeMembers = async (
22
22
  ammGovernorCreatorFacet,
23
23
  vaultFactoryGovernorCreator,
24
24
  },
25
+ produce: { econCharterStartResult },
25
26
  installation: {
26
27
  consume: { binaryVoteCounter: counterP },
27
28
  },
29
+ instance: {
30
+ consume: { amm, reserve, VaultFactory },
31
+ },
28
32
  },
29
33
  { options: { voterAddresses } },
30
34
  ) => {
35
+ // FIXME: why doesn't this use the promise space?
31
36
  /** @type {[Installation, Installation]} */
32
37
  const [charterInstall, counterInstall] = await Promise.all([
33
38
  E(agoricNames).lookup('installation', 'econCommitteeCharter'),
@@ -38,13 +43,25 @@ export const inviteCommitteeMembers = async (
38
43
  binaryVoteCounterInstallation: counterInstall,
39
44
  }),
40
45
  );
41
- const privateFacets = {
42
- reserve: reserveGovernorCreatorFacet,
43
- amm: ammGovernorCreatorFacet,
44
- vaults: vaultFactoryGovernorCreator,
45
- };
46
- const { publicFacet: votingAPI } = E.get(
47
- E(zoe).startInstance(charterInstall, undefined, terms, privateFacets),
46
+ /** @type {Promise<import('./econ-behaviors').EconCharterStartResult>} */
47
+ const startResult = E(zoe).startInstance(charterInstall, undefined, terms);
48
+ const { creatorFacet } = E.get(startResult);
49
+ econCharterStartResult.resolve(startResult);
50
+
51
+ // Introduce charter to governed creator facets.
52
+ await Promise.all(
53
+ [
54
+ { instanceP: amm, facetP: ammGovernorCreatorFacet },
55
+ { instanceP: reserve, facetP: reserveGovernorCreatorFacet },
56
+ {
57
+ instanceP: VaultFactory,
58
+ facetP: vaultFactoryGovernorCreator,
59
+ },
60
+ ].map(async ({ instanceP, facetP }) => {
61
+ const [instance, govFacet] = await Promise.all([instanceP, facetP]);
62
+
63
+ return E(creatorFacet).addInstance(instance, govFacet);
64
+ }),
48
65
  );
49
66
 
50
67
  const invitations = await E(
@@ -60,7 +77,7 @@ export const inviteCommitteeMembers = async (
60
77
  addrInvitations.map(async ([addr, invitationP]) => {
61
78
  const [voterInvitation, nullInvitation] = await Promise.all([
62
79
  invitationP,
63
- E(votingAPI).makeNullInvitation(),
80
+ E(creatorFacet).makeCharterMemberInvitation(),
64
81
  ]);
65
82
  await reserveThenDeposit(
66
83
  `econ committee member ${addr}`,
@@ -85,6 +102,7 @@ export const getManifestForInviteCommittee = async (
85
102
  return {
86
103
  manifest: {
87
104
  [inviteCommitteeMembers.name]: {
105
+ produce: { econCharterStartResult: t },
88
106
  consume: {
89
107
  zoe: t,
90
108
  agoricNames: t,
@@ -97,6 +115,9 @@ export const getManifestForInviteCommittee = async (
97
115
  installation: {
98
116
  consume: { binaryVoteCounter: t },
99
117
  },
118
+ instance: {
119
+ consume: { amm: t, reserve: t, VaultFactory: t },
120
+ },
100
121
  },
101
122
  },
102
123
  installations: {
@@ -56,8 +56,7 @@ const MILLI = 1_000_000n;
56
56
  * periodicFeeCollectors: import('../feeDistributor.js').PeriodicFeeCollector[],
57
57
  * bankMints: Mint[],
58
58
  * psmFacets: MapStore<Brand, PSMFacets>,
59
- * psmCharterCreatorFacet: Awaited<ReturnType<import('../psm/psmCharter.js').start>>['creatorFacet'],
60
- * psmCharterAdminFacet: AdminFacet,
59
+ * econCharterStartResult: EconCharterStartResult,
61
60
  * reservePublicFacet: import('../reserve/assetReserve.js').AssetReservePublicFacet,
62
61
  * reserveCreatorFacet: import('../reserve/assetReserve.js').AssetReserveLimitedCreatorFacet,
63
62
  * reserveGovernorCreatorFacet: GovernedAssetReserveFacetAccess,
@@ -69,6 +68,14 @@ const MILLI = 1_000_000n;
69
68
  * }>} EconomyBootstrapSpace
70
69
  */
71
70
 
71
+ /**
72
+ * @param {ERef<ZoeService>} zoe
73
+ * @param {Installation<import('../econCommitteeCharter').start>} inst
74
+ * @typedef {Awaited<ReturnType<typeof startCharterInstance>>} EconCharterStartResult
75
+ */
76
+ // eslint-disable-next-line no-unused-vars
77
+ const startCharterInstance = (zoe, inst) => E(zoe).startInstance(inst);
78
+
72
79
  /**
73
80
  * @file A collection of productions, each of which declares inputs and outputs.
74
81
  * Each function is passed a set of powers for reading from and writing to the vat config.
@@ -32,7 +32,7 @@ export const startPSM = async (
32
32
  zoe,
33
33
  feeMintAccess: feeMintAccessP,
34
34
  economicCommitteeCreatorFacet,
35
- psmCharterCreatorFacet,
35
+ econCharterStartResult,
36
36
  provisionPoolStartResult,
37
37
  chainStorage,
38
38
  chainTimerService,
@@ -174,11 +174,10 @@ export const startPSM = async (
174
174
 
175
175
  await Promise.all([
176
176
  E(instanceAdmin).update(instanceKey, newPsmFacets.psm),
177
- E(psmCharterCreatorFacet).addInstance(
177
+ E(E.get(econCharterStartResult).creatorFacet).addInstance(
178
178
  psm,
179
179
  governorFacets.creatorFacet,
180
- anchorBrand,
181
- minted,
180
+ instanceKey,
182
181
  ),
183
182
  // @ts-expect-error TODO type for provisionPoolStartResult
184
183
  E(E.get(provisionPoolStartResult).creatorFacet).initPSM(
@@ -276,7 +275,7 @@ export const installGovAndPSMContracts = async ({
276
275
  committee,
277
276
  binaryVoteCounter,
278
277
  psm,
279
- psmCharter,
278
+ econCommitteeCharter,
280
279
  },
281
280
  },
282
281
  }) => {
@@ -292,7 +291,7 @@ export const installGovAndPSMContracts = async ({
292
291
  committee,
293
292
  binaryVoteCounter,
294
293
  psm,
295
- psmCharter,
294
+ econCommitteeCharter,
296
295
  }).map(async ([name, producer]) => {
297
296
  const bundleCap = D(vatAdmin).getNamedBundleCap(name);
298
297
  const bundle = D(bundleCap).getBundle();
@@ -303,15 +302,18 @@ export const installGovAndPSMContracts = async ({
303
302
  );
304
303
  };
305
304
 
306
- /** @param {EconomyBootstrapPowers} powers */
305
+ /**
306
+ * @deprecated the PSM charter has been merged with the econ charter
307
+ * @param {EconomyBootstrapPowers} powers
308
+ */
307
309
  export const startPSMCharter = async ({
308
310
  consume: { zoe },
309
- produce: { psmCharterCreatorFacet, psmCharterAdminFacet },
311
+ produce: { econCharterStartResult },
310
312
  installation: {
311
- consume: { binaryVoteCounter, psmCharter: installP },
313
+ consume: { binaryVoteCounter, econCommitteeCharter: installP },
312
314
  },
313
315
  instance: {
314
- produce: { psmCharter: instanceP },
316
+ produce: { econCommitteeCharter: instanceP },
315
317
  },
316
318
  }) => {
317
319
  const [charterR, counterR] = await Promise.all([installP, binaryVoteCounter]);
@@ -320,8 +322,7 @@ export const startPSMCharter = async ({
320
322
  const facets = await E(zoe).startInstance(charterR, {}, terms);
321
323
 
322
324
  instanceP.resolve(facets.instance);
323
- psmCharterCreatorFacet.resolve(facets.creatorFacet);
324
- psmCharterAdminFacet.resolve(facets.adminFacet);
325
+ econCharterStartResult.resolve(facets);
325
326
  };
326
327
 
327
328
  /**
@@ -343,21 +344,20 @@ export const PSM_GOV_MANIFEST = {
343
344
  committee: 'zoe',
344
345
  binaryVoteCounter: 'zoe',
345
346
  psm: 'zoe',
346
- psmCharter: 'zoe',
347
+ econCommitteeCharter: 'zoe',
347
348
  },
348
349
  },
349
350
  },
350
351
  [startPSMCharter.name]: {
351
352
  consume: { zoe: 'zoe' },
352
353
  produce: {
353
- psmCharterCreatorFacet: 'psmCharter',
354
- psmCharterAdminFacet: 'psmCharter',
354
+ econCharterStartResult: 'econCommitteeCharter',
355
355
  },
356
356
  installation: {
357
- consume: { binaryVoteCounter: 'zoe', psmCharter: 'zoe' },
357
+ consume: { binaryVoteCounter: 'zoe', econCommitteeCharter: 'zoe' },
358
358
  },
359
359
  instance: {
360
- produce: { psmCharter: 'psmCharter' },
360
+ produce: { econCommitteeCharter: 'econCommitteeCharter' },
361
361
  },
362
362
  },
363
363
  };
@@ -374,7 +374,7 @@ export const invitePSMCommitteeMembers = async (
374
374
  consume: {
375
375
  namesByAddressAdmin,
376
376
  economicCommitteeCreatorFacet,
377
- psmCharterCreatorFacet,
377
+ econCharterStartResult,
378
378
  },
379
379
  },
380
380
  { options: { voterAddresses = {} } },
@@ -392,7 +392,9 @@ export const invitePSMCommitteeMembers = async (
392
392
  addrInvitations.map(async ([addr, invitationP]) => {
393
393
  const [voterInvitation, charterMemberInvitation] = await Promise.all([
394
394
  invitationP,
395
- E(psmCharterCreatorFacet).makeCharterMemberInvitation(),
395
+ E(
396
+ E.get(econCharterStartResult).creatorFacet,
397
+ ).makeCharterMemberInvitation(),
396
398
  ]);
397
399
  console.log('sending charter, voting invitations to', addr);
398
400
  await reserveThenDeposit(
@@ -416,7 +418,7 @@ export const INVITE_PSM_COMMITTEE_MANIFEST = harden({
416
418
  consume: {
417
419
  namesByAddressAdmin: true,
418
420
  economicCommitteeCreatorFacet: true,
419
- psmCharterCreatorFacet: true,
421
+ econCharterStartResult: true,
420
422
  },
421
423
  },
422
424
  });
@@ -444,7 +446,7 @@ export const PSM_MANIFEST = harden({
444
446
  feeMintAccess: 'zoe',
445
447
  economicCommitteeCreatorFacet: 'economicCommittee',
446
448
  provisionPoolStartResult: true,
447
- psmCharterCreatorFacet: 'psmCharter',
449
+ econCharterStartResult: 'econCommitteeCharter',
448
450
  chainTimerService: 'timer',
449
451
  psmFacets: true,
450
452
  },