@agoric/inter-protocol 0.13.2-dev-65d3f14.0 → 0.13.2-pismo-dev-12e97f1.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 (103) hide show
  1. package/bundles/bundle-amm-meta.js +168 -188
  2. package/bundles/bundle-amm.js +1 -1
  3. package/bundles/bundle-feeDistributor-meta.js +92 -92
  4. package/bundles/bundle-feeDistributor.js +1 -1
  5. package/bundles/bundle-interchainPool-meta.js +174 -190
  6. package/bundles/bundle-interchainPool.js +1 -1
  7. package/bundles/bundle-liquidateIncrementally-meta.js +149 -109
  8. package/bundles/bundle-liquidateIncrementally.js +1 -1
  9. package/bundles/bundle-liquidateMinimum-meta.js +149 -109
  10. package/bundles/bundle-liquidateMinimum.js +1 -1
  11. package/bundles/bundle-psm-meta.js +148 -168
  12. package/bundles/bundle-psm.js +1 -1
  13. package/bundles/bundle-psmCharter-meta.js +418 -0
  14. package/bundles/bundle-psmCharter.js +1 -0
  15. package/bundles/bundle-reserve-meta.js +176 -192
  16. package/bundles/bundle-reserve.js +1 -1
  17. package/bundles/bundle-scaledPriceAuthority-meta.js +173 -133
  18. package/bundles/bundle-scaledPriceAuthority.js +1 -1
  19. package/bundles/bundle-stakeFactory-meta.js +186 -206
  20. package/bundles/bundle-stakeFactory.js +1 -1
  21. package/bundles/bundle-vaultFactory-meta.js +197 -217
  22. package/bundles/bundle-vaultFactory.js +1 -1
  23. package/package.json +23 -25
  24. package/scripts/add-collateral-core.js +3 -52
  25. package/scripts/add-initial-liquidity.js +1 -0
  26. package/scripts/build-bundles.js +1 -4
  27. package/scripts/deploy-contracts.js +1 -0
  28. package/scripts/init-core.js +9 -11
  29. package/scripts/invite-committee-core.js +1 -0
  30. package/scripts/manual-price-feed.js +1 -1
  31. package/scripts/price-feed-core.js +2 -2
  32. package/src/collect.js +2 -0
  33. package/src/collectFees.js +4 -3
  34. package/src/contractSupport.js +27 -13
  35. package/src/econCommitteeCharter.js +80 -110
  36. package/src/feeDistributor.js +8 -6
  37. package/src/interchainPool.js +8 -7
  38. package/src/interest-math.js +2 -0
  39. package/src/interest.js +10 -6
  40. package/src/makeTracer.js +0 -5
  41. package/src/my-lien.js +7 -3
  42. package/src/proposals/addAssetToVault.js +5 -3
  43. package/src/proposals/committee-proposal.js +42 -112
  44. package/src/proposals/core-proposal.js +30 -17
  45. package/src/proposals/demoIssuers.js +16 -17
  46. package/src/proposals/econ-behaviors.js +115 -156
  47. package/src/proposals/price-feed-proposal.js +6 -118
  48. package/src/proposals/sim-behaviors.js +1 -0
  49. package/src/proposals/startEconCommittee.js +2 -1
  50. package/src/proposals/startPSM.js +117 -77
  51. package/src/proposals/utils.js +12 -23
  52. package/src/psm/psm.js +55 -37
  53. package/src/psm/psmCharter.js +139 -0
  54. package/src/reserve/assetReserve.js +35 -28
  55. package/src/reserve/params.js +2 -0
  56. package/src/stakeFactory/attestation.js +9 -4
  57. package/src/stakeFactory/attestationTool.js +1 -0
  58. package/src/stakeFactory/params.js +1 -0
  59. package/src/stakeFactory/stakeFactory.js +1 -1
  60. package/src/stakeFactory/stakeFactoryKit.js +20 -13
  61. package/src/stakeFactory/stakeFactoryManager.js +3 -2
  62. package/src/vaultFactory/burn.js +1 -0
  63. package/src/vaultFactory/liquidateIncrementally.js +8 -5
  64. package/src/vaultFactory/liquidateMinimum.js +6 -2
  65. package/src/vaultFactory/liquidation.js +2 -2
  66. package/src/vaultFactory/orderedVaultStore.js +1 -0
  67. package/src/vaultFactory/params.js +12 -7
  68. package/src/vaultFactory/prioritizedVaults.js +1 -0
  69. package/src/vaultFactory/storeUtils.js +1 -0
  70. package/src/vaultFactory/types.js +2 -0
  71. package/src/vaultFactory/vault.js +40 -26
  72. package/src/vaultFactory/vaultDirector.js +18 -15
  73. package/src/vaultFactory/vaultFactory.js +20 -19
  74. package/src/vaultFactory/vaultHolder.js +3 -4
  75. package/src/vaultFactory/vaultKit.js +1 -0
  76. package/src/vaultFactory/vaultManager.js +10 -7
  77. package/src/vpool-xyk-amm/addLiquidity.js +4 -3
  78. package/src/vpool-xyk-amm/addPool.js +20 -23
  79. package/src/vpool-xyk-amm/constantProduct/calcFees.js +12 -6
  80. package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +2 -0
  81. package/src/vpool-xyk-amm/constantProduct/core.js +24 -16
  82. package/src/vpool-xyk-amm/constantProduct/defaults.js +2 -0
  83. package/src/vpool-xyk-amm/constantProduct/getXY.js +6 -2
  84. package/src/vpool-xyk-amm/constantProduct/internal-types.js +14 -12
  85. package/src/vpool-xyk-amm/constantProduct/invariants.js +8 -4
  86. package/src/vpool-xyk-amm/constantProduct/swap.js +19 -17
  87. package/src/vpool-xyk-amm/constantProduct/types.js +2 -0
  88. package/src/vpool-xyk-amm/doublePool.js +14 -20
  89. package/src/vpool-xyk-amm/estimate.js +2 -0
  90. package/src/vpool-xyk-amm/multipoolMarketMaker.js +5 -3
  91. package/src/vpool-xyk-amm/params.js +2 -0
  92. package/src/vpool-xyk-amm/pool.js +14 -16
  93. package/src/vpool-xyk-amm/priceAuthority.js +3 -1
  94. package/src/vpool-xyk-amm/removeLiquidity.js +2 -0
  95. package/src/vpool-xyk-amm/singlePool.js +14 -29
  96. package/src/vpool-xyk-amm/swap.js +1 -0
  97. package/src/vpool-xyk-amm/types.js +12 -10
  98. package/bundles/bundle-econCommitteeCharter-meta.js +0 -418
  99. package/bundles/bundle-econCommitteeCharter.js +0 -1
  100. package/scripts/start-local-chain-boot.js +0 -96
  101. package/scripts/start-local-chain-config.json +0 -83
  102. package/scripts/start-local-chain.sh +0 -69
  103. package/src/psm/README.md +0 -71
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.13.2-dev-65d3f14.0+65d3f14",
3
+ "version": "0.13.2-pismo-dev-12e97f1.0+12e97f1",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -16,7 +16,7 @@
16
16
  "lint-fix": "yarn lint:eslint --fix",
17
17
  "lint": "run-s --continue-on-error lint:*",
18
18
  "lint:eslint": "eslint .",
19
- "lint:types": "tsc -p jsconfig.json"
19
+ "lint:types": "tsc --maxNodeModuleJsDepth 5 -p jsconfig.json"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -29,32 +29,30 @@
29
29
  },
30
30
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
31
  "dependencies": {
32
- "@agoric/assert": "0.5.2-dev-65d3f14.0+65d3f14",
33
- "@agoric/ertp": "0.15.4-dev-65d3f14.0+65d3f14",
34
- "@agoric/governance": "0.9.2-dev-65d3f14.0+65d3f14",
35
- "@agoric/internal": "0.2.2-dev-65d3f14.0+65d3f14",
32
+ "@agoric/assert": "0.5.2-pismo-dev-12e97f1.0+12e97f1",
33
+ "@agoric/ertp": "0.15.4-pismo-dev-12e97f1.0+12e97f1",
34
+ "@agoric/governance": "0.9.2-pismo-dev-12e97f1.0+12e97f1",
35
+ "@agoric/internal": "0.2.2-pismo-dev-12e97f1.0+12e97f1",
36
36
  "@agoric/nat": "^4.1.0",
37
- "@agoric/notifier": "0.5.2-dev-65d3f14.0+65d3f14",
38
- "@agoric/store": "0.8.4-dev-65d3f14.0+65d3f14",
39
- "@agoric/swingset-vat": "0.30.3-dev-65d3f14.0+65d3f14",
40
- "@agoric/vat-data": "0.4.4-dev-65d3f14.0+65d3f14",
41
- "@agoric/vats": "0.13.1-dev-65d3f14.0+65d3f14",
42
- "@agoric/zoe": "0.25.4-dev-65d3f14.0+65d3f14",
43
- "@endo/bundle-source": "^2.4.2",
44
- "@endo/captp": "^2.0.18",
45
- "@endo/eventual-send": "^0.16.8",
46
- "@endo/far": "^0.2.14",
47
- "@endo/marshal": "^0.8.1",
48
- "@endo/nat": "^4.1.23",
49
- "@endo/promise-kit": "^0.2.52"
37
+ "@agoric/notifier": "0.5.2-pismo-dev-12e97f1.0+12e97f1",
38
+ "@agoric/store": "0.8.4-pismo-dev-12e97f1.0+12e97f1",
39
+ "@agoric/swingset-vat": "0.30.3-pismo-dev-12e97f1.0+12e97f1",
40
+ "@agoric/vat-data": "0.4.4-pismo-dev-12e97f1.0+12e97f1",
41
+ "@agoric/vats": "0.13.1-pismo-dev-12e97f1.0+12e97f1",
42
+ "@agoric/zoe": "0.25.4-pismo-dev-12e97f1.0+12e97f1",
43
+ "@endo/bundle-source": "^2.3.1",
44
+ "@endo/captp": "^2.0.15",
45
+ "@endo/eventual-send": "^0.16.5",
46
+ "@endo/far": "^0.2.11",
47
+ "@endo/marshal": "^0.7.5",
48
+ "@endo/nat": "^4.1.20",
49
+ "@endo/promise-kit": "^0.2.49"
50
50
  },
51
51
  "devDependencies": {
52
- "@agoric/cosmic-swingset": "0.39.3-dev-65d3f14.0+65d3f14",
53
- "@agoric/deploy-script-support": "0.9.5-dev-65d3f14.0+65d3f14",
54
- "@agoric/smart-wallet": "0.4.3-dev-65d3f14.0+65d3f14",
55
- "@endo/init": "^0.5.52",
52
+ "@agoric/deploy-script-support": "0.9.5-pismo-dev-12e97f1.0+12e97f1",
53
+ "@endo/init": "^0.5.49",
56
54
  "@fast-check/ava": "^1.0.1",
57
- "ava": "^5.0.1",
55
+ "ava": "^4.3.1",
58
56
  "c8": "^7.11.0",
59
57
  "deep-object-diff": "^1.1.7",
60
58
  "import-meta-resolve": "^1.1.1"
@@ -78,5 +76,5 @@
78
76
  "publishConfig": {
79
77
  "access": "public"
80
78
  },
81
- "gitHead": "65d3f14c8102993168d2568eed5e6acbcba0c48a"
79
+ "gitHead": "12e97f1e7d384c11c76b61de67ee0de30de00fe6"
82
80
  }
@@ -1,11 +1,9 @@
1
1
  /* global process */
2
+ // @ts-check
2
3
  import { makeHelpers } from '@agoric/deploy-script-support';
3
4
 
4
5
  import { getManifestForAddAssetToVault } from '../src/proposals/addAssetToVault.js';
5
- import {
6
- getManifestForPsm,
7
- getManifestForPsmGovernance,
8
- } from '../src/proposals/startPSM.js';
6
+ import { getManifestForPsm } from '../src/proposals/startPSM.js';
9
7
  import { makeInstallCache } from '../src/proposals/utils.js';
10
8
 
11
9
  export const defaultProposalBuilder = async (
@@ -54,52 +52,6 @@ export const defaultProposalBuilder = async (
54
52
  });
55
53
  };
56
54
 
57
- export const psmGovernanceBuilder = async ({
58
- publishRef,
59
- install: install0,
60
- wrapInstall,
61
- }) => {
62
- const install = wrapInstall ? wrapInstall(install0) : install0;
63
-
64
- return harden({
65
- sourceSpec: '../src/proposals/startPSM.js',
66
- getManifestCall: [
67
- getManifestForPsmGovernance.name,
68
- {
69
- installKeys: {
70
- psm: publishRef(
71
- install('../src/psm/psm.js', '../bundles/bundle-psm.js'),
72
- ),
73
- econCommitteeCharter: publishRef(
74
- install(
75
- '../src/econCommitteeCharter.js',
76
- '../bundles/bundle-econCommitteeCharter.js',
77
- ),
78
- ),
79
- contractGovernor: publishRef(
80
- install(
81
- '@agoric/governance/src/contractGovernor.js',
82
- '../../governance/bundles/bundle-contractGovernor.js',
83
- ),
84
- ),
85
- committee: publishRef(
86
- install(
87
- '@agoric/governance/src/committee.js',
88
- '../../governance/bundles/bundle-committee.js',
89
- ),
90
- ),
91
- binaryVoteCounter: publishRef(
92
- install(
93
- '@agoric/governance/src/binaryVoteCounter.js',
94
- '../../governance/bundles/bundle-binaryVoteCounter.js',
95
- ),
96
- ),
97
- },
98
- },
99
- ],
100
- });
101
- };
102
-
103
55
  export const psmProposalBuilder = async (
104
56
  { publishRef, install: install0, wrapInstall },
105
57
  { anchorOptions = /** @type {object} */ ({}) } = {},
@@ -112,12 +64,11 @@ export const psmProposalBuilder = async (
112
64
  const install = wrapInstall ? wrapInstall(install0) : install0;
113
65
 
114
66
  return harden({
115
- sourceSpec: '../src/proposals/startPSM.js',
67
+ sourceSpec: '../src/proposals/addAssetToVault.js',
116
68
  getManifestCall: [
117
69
  getManifestForPsm.name,
118
70
  {
119
71
  anchorOptions: {
120
- ...anchorOptions,
121
72
  denom,
122
73
  decimalPlaces,
123
74
  },
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { AmountMath } from '@agoric/ertp';
2
3
  import { makeNotifierFromAsyncIterable } from '@agoric/notifier';
3
4
  import { E } from '@endo/far';
@@ -25,10 +25,7 @@ await extractProposalBundles(
25
25
  await createBundles(
26
26
  [
27
27
  ['../src/psm/psm.js', '../bundles/bundle-psm.js'],
28
- [
29
- '../src/econCommitteeCharter.js',
30
- '../bundles/bundle-econCommitteeCharter.js',
31
- ],
28
+ ['../src/psm/psmCharter.js', '../bundles/bundle-psmCharter.js'],
32
29
  ],
33
30
  dirname,
34
31
  );
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ // @ts-check
2
3
  import url from 'url';
3
4
  import { makeHelpers } from '@agoric/deploy-script-support';
4
5
  import { E } from '@endo/eventual-send';
@@ -1,8 +1,5 @@
1
1
  /* global process */
2
- /**
3
- * @file can be run with `agoric deploy` after a chain is running (depends on chain state)
4
- * Only works with "local" chain and not sim-chain b/c it needs governance votes (n/a on sim-chain).
5
- */
2
+ // @ts-check
6
3
  import { makeHelpers } from '@agoric/deploy-script-support';
7
4
  import { objectMap } from '@agoric/internal';
8
5
 
@@ -71,15 +68,16 @@ const installKeyGroups = {
71
68
  * @param {(m: string, b: string, opts?: any) => I} opts.install
72
69
  * @param {<T>(f: T) => T} [opts.wrapInstall]
73
70
  *
74
- * @param {object} [options]
75
- * @param {{ committeeName?: string, committeeSize?: number}} [options.econCommitteeOptions]
76
71
  * @template I
77
72
  * @template R
78
73
  */
79
- export const committeeProposalBuilder = async (
80
- { publishRef, install: install0, wrapInstall },
81
- { econCommitteeOptions } = {},
82
- ) => {
74
+ export const committeeProposalBuilder = async ({
75
+ publishRef,
76
+ install: install0,
77
+ wrapInstall,
78
+ }) => {
79
+ const { ROLE = 'chain' } = process.env;
80
+
83
81
  const install = wrapInstall ? wrapInstall(install0) : install0;
84
82
 
85
83
  /** @param {Record<string, [string, string]>} group */
@@ -92,7 +90,7 @@ export const committeeProposalBuilder = async (
92
90
  getManifestCall: [
93
91
  getManifestForEconCommittee.name,
94
92
  {
95
- econCommitteeOptions,
93
+ ROLE,
96
94
  installKeys: {
97
95
  ...publishGroup(installKeyGroups.econCommittee),
98
96
  },
@@ -1,4 +1,5 @@
1
1
  /* global process */
2
+ // @ts-check
2
3
  import { makeHelpers } from '@agoric/deploy-script-support';
3
4
 
4
5
  import { getManifestForInviteCommittee } from '../src/proposals/committee-proposal.js';
@@ -21,7 +21,7 @@ import process from 'process';
21
21
  * E(oa).pushResult('19.37')
22
22
  * E(qn).getUpdateSince()
23
23
  *
24
- * @typedef {{ board: import('@agoric/vats').Board, chainTimerService, scratch, zoe }} Home
24
+ * @typedef {{ board: Board, chainTimerService, scratch, zoe }} Home
25
25
  * @param {Promise<Home>} homePromise
26
26
  * @param {object} root0
27
27
  * @param {(...path: string[]) => Promise<any>} root0.lookup
@@ -71,9 +71,9 @@ export const createGov = async (homeP, endowments) => {
71
71
 
72
72
  const {
73
73
  AGORIC_INSTANCE_NAME,
74
- IN_BRAND_DECIMALS = '6',
74
+ IN_BRAND_DECIMALS,
75
75
  IN_BRAND_LOOKUP = JSON.stringify(['wallet', 'brand', 'BLD']),
76
- OUT_BRAND_DECIMALS = '6',
76
+ OUT_BRAND_DECIMALS,
77
77
  OUT_BRAND_LOOKUP = JSON.stringify(['agoricNames', 'oracleBrand', 'USD']),
78
78
  ORACLE_ADDRESSES,
79
79
  } = process.env;
package/src/collect.js CHANGED
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  const { fromEntries, keys, values } = Object;
2
4
 
3
5
  /** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
@@ -1,5 +1,4 @@
1
- import { atomicTransfer } from '@agoric/zoe/src/contractSupport';
2
-
1
+ // @ts-check
3
2
  /**
4
3
  * Provide shared support for providing access to fees from a service contract.
5
4
  *
@@ -16,7 +15,9 @@ export const makeMakeCollectFeesInvitation = (
16
15
  ) => {
17
16
  const collectFees = seat => {
18
17
  const amount = feeSeat.getAmountAllocated(keyword, feeBrand);
19
- atomicTransfer(zcf, feeSeat, seat, { [keyword]: amount }, { Fee: amount });
18
+ feeSeat.decrementBy(harden({ [keyword]: amount }));
19
+ seat.incrementBy(harden({ Fee: amount }));
20
+ zcf.reallocate(seat, feeSeat);
20
21
 
21
22
  seat.exit();
22
23
  return `paid out ${amount.value}`;
@@ -1,9 +1,10 @@
1
+ // @ts-check
1
2
  import { AmountMath } from '@agoric/ertp';
2
3
  import { makeStoredPublisherKit, makeStoredPublishKit } from '@agoric/notifier';
3
4
  import { M } from '@agoric/store';
4
5
  import { E } from '@endo/eventual-send';
5
6
 
6
- const { Fail, quote: q } = assert;
7
+ const { details: X, quote: q } = assert;
7
8
 
8
9
  export const amountPattern = harden({ brand: M.remotable(), value: M.any() });
9
10
  export const ratioPattern = harden({
@@ -18,11 +19,10 @@ export const ratioPattern = harden({
18
19
  * on a proposal. We use two Amounts because an Amount cannot represent
19
20
  * a negative number (so we use a "loss" that will be subtracted).
20
21
  *
21
- * @template {AssetKind} K
22
- * @param {Amount<K>} base
23
- * @param {Amount<K>} gain
24
- * @param {Amount<K>} loss
25
- * @returns {Amount<K>}
22
+ * @param {Amount} base
23
+ * @param {Amount} gain
24
+ * @param {Amount} loss
25
+ * @returns {Amount}
26
26
  */
27
27
  export const addSubtract = (base, gain, loss) =>
28
28
  AmountMath.subtract(AmountMath.add(base, gain), loss);
@@ -37,8 +37,10 @@ export const assertOnlyKeys = (proposal, keys) => {
37
37
  /** @param {AmountKeywordRecord} clause */
38
38
  const onlyKeys = clause =>
39
39
  Object.getOwnPropertyNames(clause).every(c => keys.includes(c));
40
- onlyKeys(proposal.give) || Fail`extraneous terms in give: ${proposal.give}`;
41
- onlyKeys(proposal.want) || Fail`extraneous terms in want: ${proposal.want}`;
40
+ onlyKeys(proposal.give) ||
41
+ assert.fail(X`extraneous terms in give: ${proposal.give}`);
42
+ onlyKeys(proposal.want) ||
43
+ assert.fail(X`extraneous terms in want: ${proposal.want}`);
42
44
  };
43
45
 
44
46
  /**
@@ -46,7 +48,6 @@ export const assertOnlyKeys = (proposal, keys) => {
46
48
  * the gain and a loss on the `fromSeat`. The gain/loss are typically from the
47
49
  * give/want respectively of a proposal. The `key` is the allocation keyword.
48
50
  *
49
- * @deprecated Use atomicRearrange instead
50
51
  * @param {ZCFSeat} fromSeat
51
52
  * @param {ZCFSeat} toSeat
52
53
  * @param {Amount} fromLoses
@@ -71,10 +72,12 @@ export const stageDelta = (fromSeat, toSeat, fromLoses, fromGains, key) => {
71
72
  */
72
73
  export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {
73
74
  const debtPost = AmountMath.add(totalDebt, toMint);
74
- !AmountMath.isGTE(debtPost, debtLimit) ||
75
- Fail`Minting ${q(toMint)} past ${q(
76
- totalDebt,
77
- )} would hit total debt limit ${q(debtLimit)}`;
75
+ assert(
76
+ !AmountMath.isGTE(debtPost, debtLimit),
77
+ X`Minting ${q(toMint)} past ${q(totalDebt)} would hit total debt limit ${q(
78
+ debtLimit,
79
+ )}`,
80
+ );
78
81
  };
79
82
 
80
83
  /**
@@ -158,3 +161,14 @@ export const makeEphemeraProvider = init => {
158
161
  };
159
162
  };
160
163
  harden(makeEphemeraProvider);
164
+
165
+ /**
166
+ * @template {Record<string, unknown>} T
167
+ * @param {T} specimen
168
+ * @param {Array<keyof T>} keyList
169
+ */
170
+ export const assertKeysDefined = (specimen, keyList) => {
171
+ for (const key of keyList) {
172
+ assert(specimen[key], X`Missing ${q(key)}`);
173
+ }
174
+ };
@@ -1,132 +1,102 @@
1
- import '@agoric/governance/exported.js';
2
- import { makeScalarMapStore, M, makeHeapFarInstance, fit } from '@agoric/store';
1
+ // @ts-check
2
+
3
+ import '@agoric/governance/src/exported.js';
3
4
  import '@agoric/zoe/exported.js';
4
5
  import '@agoric/zoe/src/contracts/exported.js';
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
+
7
+ import { E, Far } from '@endo/far';
8
8
 
9
9
  /**
10
10
  * @file
11
11
  *
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.
12
+ * This extremely quick and dirty contract simplifies the process of
13
+ * calling for votes on changes to the economy by gathering the governor creator
14
+ * facets in one place and invokes `voteOnParamChanges` and
15
+ * `voteOnApiInvocation` on each when requested. A cleaner version would
16
+ * validate parameters, constrain deadlines and probably split the ability to
17
+ * call for vote into separate capabilities for finer grain encapsulation.
16
18
  */
17
19
 
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]
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
- );
39
-
40
20
  /**
41
21
  * @param {ZCF<{binaryVoteCounterInstallation:Installation}>} zcf
22
+ * @param {{reserve:GovernedContractFacetAccess<{},{}>, amm:GovernedCreatorFacet<{}>, vaults:GovernedCreatorFacet<{}>}} privateArgs
42
23
  */
43
- export const start = async zcf => {
24
+ export const start = async (zcf, privateArgs) => {
44
25
  const { binaryVoteCounterInstallation: counter } = zcf.getTerms();
45
- /** @type {MapStore<Instance,GovernedContractFacetAccess<{},{}>>} */
46
- const instanceToGovernor = makeScalarMapStore();
26
+ const { reserve, amm, vaults } = privateArgs;
47
27
 
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
- };
69
-
70
- return zcf.makeInvitation(voteOnParamChanges, 'vote on param changes');
28
+ /**
29
+ * @param {*} target
30
+ * @param {Record<string, unknown>} params
31
+ * @param {bigint} deadline
32
+ * @param {{paramPath: { key: unknown }}} [path]
33
+ */
34
+ const voteOnParamChanges = (
35
+ target,
36
+ params,
37
+ deadline,
38
+ path = { paramPath: { key: 'governedApi' } },
39
+ ) => {
40
+ return E(target).voteOnParamChanges(counter, deadline, {
41
+ ...path,
42
+ changes: params,
43
+ });
71
44
  };
72
45
 
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');
46
+ /**
47
+ * @param {*} target
48
+ * @param {string} method
49
+ * @param {unknown[]} args
50
+ * @param {bigint} deadline
51
+ */
52
+ const voteOnApiInvocation = (target, method, args, deadline) => {
53
+ return E(target).voteOnApiInvocation(method, args, counter, deadline);
82
54
  };
83
55
 
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
+ const makeNullInvitation = () => {
57
+ return zcf.makeInvitation(() => {}, 'econCommitteeCharter noop');
104
58
  };
105
59
 
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()),
60
+ const publicFacet = Far('votingAPI', {
61
+ /**
62
+ * @param {Record<string, unknown>} params
63
+ * @param {bigint} deadline
64
+ */
65
+ voteOnAmmParamChanges: (params, deadline) =>
66
+ voteOnParamChanges(amm, params, deadline),
67
+ /**
68
+ * @param {Record<string, unknown>} params
69
+ * @param {bigint} deadline
70
+ */
71
+ voteOnReserveParamChanges: (params, deadline) =>
72
+ voteOnParamChanges(reserve, params, deadline),
73
+ /**
74
+ * vote on param changes for a vaultManager
75
+ *
76
+ * @param {Record<string, unknown>} params
77
+ * @param {{collateralBrand: Brand}} brand
78
+ * @param {bigint} deadline
79
+ */
80
+ voteOnVaultParamChanges: (params, brand, deadline) =>
81
+ voteOnParamChanges(vaults, params, deadline, {
82
+ paramPath: { key: brand },
83
+ }),
84
+ /**
85
+ * vote on param changes across the vaultFactory
86
+ *
87
+ * @param {Record<string, unknown>} params
88
+ * @param {bigint} deadline
89
+ */
90
+ voteOnVaultFactoryParamChanges: (params, deadline) =>
91
+ voteOnParamChanges(vaults, params, deadline),
92
+ /**
93
+ * @param {Amount[]} amounts
94
+ * @param {bigint} deadline
95
+ */
96
+ voteOnReserveApiInvocation: (amounts, deadline) =>
97
+ voteOnApiInvocation(reserve, 'addLiquidityToAmmPool', amounts, deadline),
98
+ makeNullInvitation,
111
99
  });
112
100
 
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 });
101
+ return harden({ publicFacet });
132
102
  };
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  import { AmountMath } from '@agoric/ertp';
2
4
  import { E, Far } from '@endo/far';
3
5
  import { observeNotifier } from '@agoric/notifier';
@@ -8,7 +10,7 @@ const { details: X } = assert;
8
10
  /**
9
11
  * @typedef {object} FeeCollector
10
12
  *
11
- * @property {() => ERef<Payment<'nat'>>} collectFees
13
+ * @property {() => ERef<Payment>} collectFees
12
14
  */
13
15
 
14
16
  /**
@@ -107,8 +109,8 @@ export const makeShareConfig = (destinations = {}, keywordShares = {}) => {
107
109
  /**
108
110
  * Split and deposit a payment given a share configuration.
109
111
  *
110
- * @param {Payment<'nat'>} payment
111
- * @param {ERef<Issuer<'nat'>>} issuer
112
+ * @param {Payment} payment
113
+ * @param {ERef<Issuer>} issuer
112
114
  * @param {ShareConfig} shareConfig
113
115
  */
114
116
  export const sharePayment = async (
@@ -158,7 +160,7 @@ export const sharePayment = async (
158
160
  };
159
161
 
160
162
  /**
161
- * @param {ERef<Issuer<'nat'>>} feeIssuer
163
+ * @param {ERef<Issuer>} feeIssuer
162
164
  * @param {{ keywordShares: Record<Keyword, bigint>, timerService: ERef<TimerService>, collectionInterval: RelativeTime}} terms
163
165
  */
164
166
  export const makeFeeDistributor = (feeIssuer, terms) => {
@@ -171,7 +173,7 @@ export const makeFeeDistributor = (feeIssuer, terms) => {
171
173
  /** @type {SetStore<FeeCollector>} */
172
174
  const collectors = makeScalarSetStore();
173
175
 
174
- /** @param {Payment<'nat'>} payment */
176
+ /** @param {Payment} payment */
175
177
  const distributeFees = payment =>
176
178
  sharePayment(payment, feeIssuer, shareConfig);
177
179
 
@@ -226,7 +228,7 @@ export const makeFeeDistributor = (feeIssuer, terms) => {
226
228
  },
227
229
 
228
230
  /**
229
- * @param {import('@endo/far').EOnly<DepositFacet>} depositFacet
231
+ * @param {EOnly<DepositFacet>} depositFacet
230
232
  */
231
233
  makeDepositFacetDestination: depositFacet => {
232
234
  return Far(`DepositFacetDestination`, {
@@ -1,12 +1,10 @@
1
+ // @ts-check
1
2
  import { E, Far } from '@endo/far';
2
3
  import { AmountMath, AssetKind, makeIssuerKit } from '@agoric/ertp';
3
- import {
4
- offerTo,
5
- atomicTransfer,
6
- } from '@agoric/zoe/src/contractSupport/index.js';
4
+ import { offerTo } from '@agoric/zoe/src/contractSupport/index.js';
7
5
  import { MIN_INITIAL_POOL_LIQUIDITY_KEY } from './vpool-xyk-amm/params.js';
8
6
 
9
- const { Fail, quote: q } = assert;
7
+ const { details: X, quote: q } = assert;
10
8
 
11
9
  const COSMOS_DECIMALS = 6;
12
10
 
@@ -59,7 +57,9 @@ export const start = (zcf, { bankManager }) => {
59
57
  give: { Central: centralAmt },
60
58
  } = seat.getProposal();
61
59
  AmountMath.isGTE(centralAmt, minimumCentral) ||
62
- Fail`at least ${q(minimumCentral)} required; only ${q(centralAmt)} given`;
60
+ assert.fail(
61
+ X`at least ${q(minimumCentral)} required; only ${q(centralAmt)} given`,
62
+ );
63
63
 
64
64
  const interAsset = makeIssuerKit(
65
65
  denom,
@@ -90,7 +90,8 @@ export const start = (zcf, { bankManager }) => {
90
90
  },
91
91
  });
92
92
 
93
- atomicTransfer(zcf, seat, seat2, { Central: centralAmt });
93
+ seat2.incrementBy(seat.decrementBy(harden({ Central: centralAmt })));
94
+ zcf.reallocate(seat, seat2);
94
95
 
95
96
  const invitation = await E(ammPub).addPoolInvitation();
96
97
  const { userSeatPromise, deposited } = await offerTo(