@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
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  import {
2
4
  divideBy,
3
5
  multiplyBy,
package/src/interest.js CHANGED
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  import { AmountMath } from '@agoric/ertp';
2
4
  import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
3
5
  import {
@@ -5,7 +7,7 @@ import {
5
7
  multiplyRatios,
6
8
  quantize,
7
9
  } from '@agoric/zoe/src/contractSupport/ratio.js';
8
- import { Fail } from '@agoric/assert';
10
+ import { assert, details as X } from '@agoric/assert';
9
11
  import { TimeMath } from '@agoric/swingset-vat/src/vats/timer/timeMath.js';
10
12
 
11
13
  export const SECONDS_PER_YEAR = 60n * 60n * 24n * 365n;
@@ -125,15 +127,17 @@ export const calculateCompoundedInterest = (
125
127
 
126
128
  /**
127
129
  *
128
- * @template {AssetKind} K
129
- * @param {ZCFMint<K>} mint
130
- * @param {Amount<K>} debt
130
+ *
131
+ * @param {ZCFMint} mint
132
+ * @param {Amount} debt
131
133
  */
132
134
  const validatedBrand = (mint, debt) => {
133
135
  const { brand: debtBrand } = debt;
134
136
  const { brand: issuerBrand } = mint.getIssuerRecord();
135
137
  debtBrand === issuerBrand ||
136
- Fail`Debt and issuer brands differ: ${debtBrand} != ${issuerBrand}`;
138
+ assert.fail(
139
+ X`Debt and issuer brands differ: ${debtBrand} != ${issuerBrand}`,
140
+ );
137
141
  return issuerBrand;
138
142
  };
139
143
 
@@ -141,7 +145,7 @@ const validatedBrand = (mint, debt) => {
141
145
  * Charge interest accrued between `latestInterestUpdate` and `accruedUntil`.
142
146
  *
143
147
  * @param {{
144
- * mint: ZCFMint<'nat'>,
148
+ * mint: ZCFMint,
145
149
  * mintAndReallocateWithFee: MintAndReallocate,
146
150
  * poolIncrementSeat: ZCFSeat,
147
151
  * seatAllocationKeyword: Keyword }} powers
package/src/makeTracer.js CHANGED
@@ -1,10 +1,5 @@
1
1
  let debugInstance = 1;
2
2
 
3
- /**
4
- *
5
- * @param {string} name
6
- * @param {boolean | 'verbose'} enable
7
- */
8
3
  const makeTracer = (name, enable = true) => {
9
4
  debugInstance += 1;
10
5
  let debugCount = 1;
package/src/my-lien.js CHANGED
@@ -1,7 +1,8 @@
1
+ // @ts-check
1
2
  import { AmountMath } from '@agoric/ertp';
2
3
  import { E, Far } from '@endo/far';
3
4
 
4
- const { Fail } = assert;
5
+ const { details: X } = assert;
5
6
 
6
7
  /**
7
8
  * per golang/cosmos/x/lien/lien.go
@@ -20,13 +21,14 @@ const XLien = /** @type { const } */ ({
20
21
  */
21
22
 
22
23
  /**
23
- * @param {ERef<import('@agoric/vats').BridgeManager>} bridgeManager
24
+ * @param {ERef<BridgeManager>} bridgeManager
24
25
  * @param {Brand<'nat'>} brand
25
26
  * @param {string} [denom]
26
27
  * @returns {StakingAuthority}
27
28
  */
28
29
  export const makeStakeReporter = (bridgeManager, brand, denom = 'ubld') => {
29
30
  const { make: makeAmt } = AmountMath;
31
+ /** @param {string} numeral */
30
32
  const toStake = numeral => makeAmt(brand, BigInt(numeral));
31
33
  /**
32
34
  * @param {string} address
@@ -56,7 +58,9 @@ export const makeStakeReporter = (bridgeManager, brand, denom = 'ubld') => {
56
58
  },
57
59
  getAccountState: async (address, wantedBrand) => {
58
60
  wantedBrand === brand ||
59
- Fail`Cannot getAccountState for ${wantedBrand}. Expected ${brand}.`;
61
+ assert.fail(
62
+ X`Cannot getAccountState for ${wantedBrand}. Expected ${brand}.`,
63
+ );
60
64
  /** @type { AccountState<string> } */
61
65
  const { currentTime, bonded, liened, locked, total, unbonding } = await E(
62
66
  bridgeManager,
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { AmountMath, AssetKind } from '@agoric/ertp';
2
3
  import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
3
4
  import { deeplyFulfilledObject } from '@agoric/internal';
@@ -244,7 +245,7 @@ export const registerScaledPriceAuthority = async (
244
245
  */
245
246
  export const addAssetToVault = async (
246
247
  {
247
- consume: { vaultFactoryKit, agoricNamesAdmin },
248
+ consume: { vaultFactoryCreator, agoricNamesAdmin },
248
249
  brand: {
249
250
  consume: { [Stable.symbol]: stableP },
250
251
  },
@@ -260,7 +261,6 @@ export const addAssetToVault = async (
260
261
  );
261
262
 
262
263
  const stable = await stableP;
263
- const vaultFactoryCreator = E.get(vaultFactoryKit).creatorFacet;
264
264
  await E(vaultFactoryCreator).addVaultType(interchainIssuer, oracleBrand, {
265
265
  debtLimit: AmountMath.make(stable, 0n),
266
266
  // the rest of these are arbitrary, TBD by gov cttee
@@ -320,7 +320,9 @@ export const getManifestForAddAssetToVault = (
320
320
  },
321
321
  [addAssetToVault.name]: {
322
322
  consume: {
323
- vaultFactoryKit: true,
323
+ vaultFactoryCreator: true,
324
+ ammCreatorFacet: true,
325
+ reserveCreatorFacet: true,
324
326
  agoricNamesAdmin: true,
325
327
  },
326
328
  brand: {
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { deeplyFulfilledObject } from '@agoric/internal';
2
3
  import { E } from '@endo/far';
3
4
  import { reserveThenDeposit } from './utils.js';
@@ -12,9 +13,41 @@ const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
12
13
  * @param {{ options: { voterAddresses: Record<string, string> }}} param1
13
14
  */
14
15
  export const inviteCommitteeMembers = async (
15
- { consume: { namesByAddressAdmin, economicCommitteeCreatorFacet } },
16
+ {
17
+ consume: {
18
+ zoe,
19
+ agoricNames,
20
+ namesByAddressAdmin,
21
+ economicCommitteeCreatorFacet,
22
+ reserveGovernorCreatorFacet,
23
+ ammGovernorCreatorFacet,
24
+ vaultFactoryGovernorCreator,
25
+ },
26
+ installation: {
27
+ consume: { binaryVoteCounter: counterP },
28
+ },
29
+ },
16
30
  { options: { voterAddresses } },
17
31
  ) => {
32
+ /** @type {[Installation, Installation]} */
33
+ const [charterInstall, counterInstall] = await Promise.all([
34
+ E(agoricNames).lookup('installation', 'econCommitteeCharter'),
35
+ counterP,
36
+ ]);
37
+ const terms = await deeplyFulfilledObject(
38
+ harden({
39
+ binaryVoteCounterInstallation: counterInstall,
40
+ }),
41
+ );
42
+ const privateFacets = {
43
+ reserve: reserveGovernorCreatorFacet,
44
+ amm: ammGovernorCreatorFacet,
45
+ vaults: vaultFactoryGovernorCreator,
46
+ };
47
+ const { publicFacet: votingAPI } = E.get(
48
+ E(zoe).startInstance(charterInstall, undefined, terms, privateFacets),
49
+ );
50
+
18
51
  const invitations = await E(
19
52
  economicCommitteeCreatorFacet,
20
53
  ).getVoterInvitations();
@@ -26,11 +59,15 @@ export const inviteCommitteeMembers = async (
26
59
  const distributeInvitations = async addrInvitations => {
27
60
  await Promise.all(
28
61
  addrInvitations.map(async ([addr, invitationP]) => {
62
+ const [voterInvitation, nullInvitation] = await Promise.all([
63
+ invitationP,
64
+ E(votingAPI).makeNullInvitation(),
65
+ ]);
29
66
  await reserveThenDeposit(
30
67
  `econ committee member ${addr}`,
31
68
  namesByAddressAdmin,
32
69
  addr,
33
- [invitationP],
70
+ [voterInvitation, nullInvitation],
34
71
  );
35
72
  }),
36
73
  );
@@ -41,90 +78,6 @@ export const inviteCommitteeMembers = async (
41
78
 
42
79
  harden(inviteCommitteeMembers);
43
80
 
44
- /**
45
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
46
- */
47
- export const startEconCharter = async ({
48
- consume: { zoe },
49
- produce: { econCharterKit },
50
- installation: {
51
- consume: { binaryVoteCounter: counterP, econCommitteeCharter: installP },
52
- },
53
- instance: {
54
- produce: { econCommitteeCharter: instanceP },
55
- },
56
- }) => {
57
- const [charterInstall, counterInstall] = await Promise.all([
58
- installP,
59
- counterP,
60
- ]);
61
- const terms = await deeplyFulfilledObject(
62
- harden({
63
- binaryVoteCounterInstallation: counterInstall,
64
- }),
65
- );
66
-
67
- /** @type {Promise<import('./econ-behaviors').EconCharterStartResult>} */
68
- const startResult = E(zoe).startInstance(charterInstall, undefined, terms);
69
- instanceP.resolve(E.get(startResult).instance);
70
- econCharterKit.resolve(startResult);
71
- };
72
- harden(startEconCharter);
73
-
74
- /**
75
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
76
- */
77
- export const addGovernorsToEconCharter = async ({
78
- consume: { reserveKit, ammKit, vaultFactoryKit, econCharterKit },
79
- instance: {
80
- consume: { amm, reserve, VaultFactory },
81
- },
82
- }) => {
83
- const { creatorFacet } = E.get(econCharterKit);
84
-
85
- // Introduce charter to governed creator facets.
86
- await Promise.all(
87
- [
88
- { instanceP: amm, facetP: E.get(ammKit).governorCreatorFacet },
89
- { instanceP: reserve, facetP: E.get(reserveKit).governorCreatorFacet },
90
- {
91
- instanceP: VaultFactory,
92
- facetP: E.get(vaultFactoryKit).governorCreatorFacet,
93
- },
94
- ].map(async ({ instanceP, facetP }) => {
95
- const [instance, govFacet] = await Promise.all([instanceP, facetP]);
96
-
97
- return E(creatorFacet).addInstance(instance, govFacet);
98
- }),
99
- );
100
- };
101
-
102
- harden(addGovernorsToEconCharter);
103
-
104
- /**
105
- * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
106
- * @param {{ options: { voterAddresses: Record<string, string> }}} param1
107
- */
108
- export const inviteToEconCharter = async (
109
- { consume: { namesByAddressAdmin, econCharterKit } },
110
- { options: { voterAddresses } },
111
- ) => {
112
- const { creatorFacet } = E.get(econCharterKit);
113
-
114
- await Promise.all(
115
- values(voterAddresses).map(async addr =>
116
- reserveThenDeposit(
117
- `econ charter member ${addr}`,
118
- namesByAddressAdmin,
119
- addr,
120
- [E(creatorFacet).makeCharterMemberInvitation()],
121
- ),
122
- ),
123
- );
124
- };
125
-
126
- harden(inviteToEconCharter);
127
-
128
81
  export const getManifestForInviteCommittee = async (
129
82
  { restoreRef },
130
83
  { voterAddresses, econCommitteeCharterRef },
@@ -133,41 +86,18 @@ export const getManifestForInviteCommittee = async (
133
86
  return {
134
87
  manifest: {
135
88
  [inviteCommitteeMembers.name]: {
136
- consume: { namesByAddressAdmin: t, economicCommitteeCreatorFacet: t },
137
- },
138
- [startEconCharter.name]: {
139
- consume: { zoe: t },
140
- produce: { econCharterKit: t },
141
- installation: {
142
- consume: { binaryVoteCounter: t, econCommitteeCharter: t },
143
- },
144
- instance: {
145
- produce: { econCommitteeCharter: t },
146
- },
147
- },
148
- [addGovernorsToEconCharter.name]: {
149
89
  consume: {
150
- reserveGovernorCreatorFacet: t,
151
- ammGovernorCreatorFacet: t,
152
- vaultFactoryGovernorCreator: t,
153
- econCharterKit: t,
154
90
  zoe: t,
155
91
  agoricNames: t,
156
92
  namesByAddressAdmin: t,
157
93
  economicCommitteeCreatorFacet: t,
158
- reserveKit: t,
159
- ammKit: t,
160
- vaultFactoryKit: t,
94
+ reserveGovernorCreatorFacet: t,
95
+ ammGovernorCreatorFacet: t,
96
+ vaultFactoryGovernorCreator: t,
161
97
  },
162
98
  installation: {
163
99
  consume: { binaryVoteCounter: t },
164
100
  },
165
- instance: {
166
- consume: { amm: t, reserve: t, VaultFactory: t },
167
- },
168
- },
169
- [inviteToEconCharter.name]: {
170
- consume: { namesByAddressAdmin: t, econCharterKit: t },
171
101
  },
172
102
  },
173
103
  installations: {
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { Stable } from '@agoric/vats/src/tokens.js';
2
3
  import * as econBehaviors from './econ-behaviors.js';
3
4
  import { ECON_COMMITTEE_MANIFEST } from './startEconCommittee.js';
@@ -7,12 +8,10 @@ export * from './econ-behaviors.js';
7
8
  export * from './sim-behaviors.js';
8
9
  // @ts-expect-error Module './econ-behaviors.js' has already exported a member
9
10
  // named 'EconomyBootstrapPowers'.
10
- export * from './startPSM.js'; // eslint-disable-line import/export
11
- export * from './startEconCommittee.js'; // eslint-disable-line import/export
11
+ export * from './startPSM.js';
12
+ export * from './startEconCommittee.js';
12
13
 
13
- /** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifest} */
14
14
  const SHARED_MAIN_MANIFEST = harden({
15
- /** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifestPermit} */
16
15
  [econBehaviors.setupAmm.name]: {
17
16
  consume: {
18
17
  board: 'board',
@@ -21,7 +20,11 @@ const SHARED_MAIN_MANIFEST = harden({
21
20
  zoe: 'zoe',
22
21
  economicCommitteeCreatorFacet: 'economicCommittee',
23
22
  },
24
- produce: { ammKit: 'amm' },
23
+ produce: {
24
+ ammCreatorFacet: 'amm',
25
+ ammInstanceWithoutReserve: 'amm',
26
+ ammGovernorCreatorFacet: 'amm',
27
+ },
25
28
  issuer: { consume: { [Stable.symbol]: 'zoe' } },
26
29
  brand: { consume: { [Stable.symbol]: 'zoe' } },
27
30
  installation: {
@@ -56,9 +59,13 @@ const SHARED_MAIN_MANIFEST = harden({
56
59
  zoe: 'zoe',
57
60
  priceAuthority: 'priceAuthority',
58
61
  economicCommitteeCreatorFacet: 'economicCommittee',
59
- reserveKit: 'reserve',
62
+ reserveCreatorFacet: 'reserve',
63
+ },
64
+ produce: {
65
+ vaultFactoryCreator: 'VaultFactory',
66
+ vaultFactoryGovernorCreator: 'VaultFactory',
67
+ vaultFactoryVoteCreator: 'VaultFactory',
60
68
  },
61
- produce: { vaultFactoryKit: 'VaultFactory' },
62
69
  brand: { consume: { [Stable.symbol]: 'zoe' } },
63
70
  oracleBrand: { consume: { USD: true } },
64
71
  installation: {
@@ -84,13 +91,14 @@ const SHARED_MAIN_MANIFEST = harden({
84
91
  consume: {
85
92
  client: 'provisioning',
86
93
  priceAuthorityAdmin: 'priceAuthority',
87
- vaultFactoryKit: 'VaultFactory',
94
+ vaultFactoryCreator: 'VaultFactory',
88
95
  },
89
96
  },
90
97
 
91
98
  [econBehaviors.setupReserve.name]: {
92
99
  consume: {
93
- ammKit: 'amm',
100
+ ammCreatorFacet: 'amm',
101
+ ammInstanceWithoutReserve: 'amm',
94
102
  board: 'board',
95
103
  chainStorage: true,
96
104
  feeMintAccess: 'zoe',
@@ -98,7 +106,11 @@ const SHARED_MAIN_MANIFEST = harden({
98
106
  zoe: 'zoe',
99
107
  economicCommitteeCreatorFacet: 'economicCommittee',
100
108
  },
101
- produce: { reserveKit: 'reserve' },
109
+ produce: {
110
+ reserveCreatorFacet: 'reserve',
111
+ reserveGovernorCreatorFacet: 'reserve',
112
+ reservePublicFacet: 'reserve',
113
+ },
102
114
  issuer: { consume: { [Stable.symbol]: 'zoe' } },
103
115
  brand: { consume: { [Stable.symbol]: 'zoe' } },
104
116
  installation: {
@@ -142,14 +154,14 @@ const REWARD_MANIFEST = harden({
142
154
  consume: {
143
155
  chainTimerService: true,
144
156
  bankManager: true,
145
- vaultFactoryKit: true,
157
+ vaultFactoryCreator: true,
146
158
  periodicFeeCollectors: true,
147
- ammKit: true,
148
- stakeFactoryKit: true,
149
- reserveKit: true,
159
+ ammCreatorFacet: true,
160
+ stakeFactoryCreatorFacet: true,
161
+ reservePublicFacet: true,
150
162
  zoe: true,
151
163
  },
152
- produce: { feeDistributorKit: true, periodicFeeCollectors: true },
164
+ produce: { feeDistributorCreatorFacet: true, periodicFeeCollectors: true },
153
165
  instance: { produce: { feeDistributor: true } },
154
166
  installation: { consume: { feeDistributor: true } },
155
167
  issuer: { consume: { [Stable.symbol]: 'zoe' } },
@@ -177,7 +189,8 @@ const STAKE_FACTORY_MANIFEST = harden({
177
189
  economicCommitteeCreatorFacet: 'economicCommittee',
178
190
  },
179
191
  produce: {
180
- stakeFactoryKit: 'stakeFactory',
192
+ stakeFactoryCreatorFacet: 'stakeFactory',
193
+ stakeFactoryGovernorCreatorFacet: 'stakeFactory',
181
194
  },
182
195
  installation: {
183
196
  consume: { contractGovernor: 'zoe', stakeFactory: 'zoe' },
@@ -208,7 +221,7 @@ export const SIM_CHAIN_MANIFEST = harden({
208
221
  mints: 'mints',
209
222
  priceAuthorityVat: 'priceAuthority',
210
223
  priceAuthorityAdmin: 'priceAuthority',
211
- vaultFactoryKit: 'VaultFactory',
224
+ vaultFactoryCreator: 'VaultFactory',
212
225
  zoe: true,
213
226
  },
214
227
  installation: {
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  import { AmountMath, AssetKind } from '@agoric/ertp';
2
4
  import { objectMap } from '@agoric/internal';
3
5
  import {
@@ -9,7 +11,7 @@ import { Stake, Stable } from '@agoric/vats/src/tokens.js';
9
11
  import { Nat } from '@endo/nat';
10
12
  import * as Collect from '../collect.js';
11
13
 
12
- const { Fail, quote: q } = assert;
14
+ const { details: X, quote: q } = assert;
13
15
  const { multiply, floorDivide } = natSafeMath;
14
16
  const { entries, fromEntries, keys, values } = Object;
15
17
 
@@ -77,7 +79,7 @@ export const showBrand = b =>
77
79
  `${b}`.replace(/.object Alleged: (.*) brand./, '$1');
78
80
  export const showAmount = ({ brand, value }) => {
79
81
  const b = `${showBrand(brand)}`;
80
- b in DecimalPlaces || Fail`unknown brand name: ${q(b)}`;
82
+ assert(b in DecimalPlaces, X`unknown brand name: ${q(b)}`);
81
83
  return `${decimal(value, DecimalPlaces[b])} ${b}`;
82
84
  };
83
85
 
@@ -185,7 +187,7 @@ const run2places = f =>
185
187
  * feeMintAccess: ERef<FeeMintAccess>,
186
188
  * zoe: ERef<ZoeService>,
187
189
  * }} powers
188
- * @returns {Promise<Payment<'nat'>>}
190
+ * @returns {Promise<Payment>}
189
191
  */
190
192
  const mintRunPayment = async (
191
193
  value,
@@ -417,7 +419,7 @@ export const splitAllCentralPayments = async (
417
419
  * @param {string} issuerName
418
420
  * @param {typeof AMMDemoState['ATOM']} record
419
421
  * @param {Record<string, { issuer: ERef<Issuer>, brand: Brand }>} kits
420
- * @param {{ issuer: ERef<Issuer<'nat'>>, brand: Brand<'nat'> }} central
422
+ * @param {{ issuer: ERef<Issuer>, brand: Brand }} central
421
423
  */
422
424
  export const poolRates = (issuerName, record, kits, central) => {
423
425
  /** @param {bigint} n */
@@ -464,7 +466,7 @@ export const fundAMM = async ({
464
466
  mints,
465
467
  priceAuthorityVat,
466
468
  priceAuthorityAdmin,
467
- vaultFactoryKit,
469
+ vaultFactoryCreator,
468
470
  zoe,
469
471
  },
470
472
  installation: {
@@ -505,10 +507,7 @@ export const fundAMM = async ({
505
507
  },
506
508
  ),
507
509
  );
508
-
509
- const central = /** @type {Pick<IssuerKit<'nat'>, 'issuer' | 'brand'>} */ (
510
- kits[Stable.symbol]
511
- );
510
+ const central = kits[Stable.symbol];
512
511
 
513
512
  /** @type {[ XYKAMMPublicFacet, TimerService]} */
514
513
  const [ammPublicFacet, timer] = await Promise.all([
@@ -542,17 +541,17 @@ export const fundAMM = async ({
542
541
  );
543
542
 
544
543
  const kit = kits[issuerName];
545
- if (!kit.mint) {
546
- throw Fail`no mint for ${q(issuerName)}`;
547
- }
544
+ assert(kit.mint, X`no mint for ${q(issuerName)}`);
548
545
  // @@ doesn't work for BLD?
549
546
  const secondaryPayment = await E(kit.mint).mintPayment(
550
547
  AmountMath.make(kit.brand, initialValue),
551
548
  );
552
- secondaryPayment || Fail`no payment for ${q(issuerName)}`;
553
- kit.issuer || Fail`No issuer for ${q(issuerName)}`;
554
- const liquidityIssuer = /** @type {Promise<Issuer<'nat'>>} */ (
555
- E(ammPublicFacet).addIssuer(kit.issuer, issuerName)
549
+ assert(secondaryPayment, X`no payment for ${q(issuerName)}`);
550
+
551
+ assert(kit.issuer, X`No issuer for ${q(issuerName)}`);
552
+ const liquidityIssuer = E(ammPublicFacet).addIssuer(
553
+ kit.issuer,
554
+ issuerName,
556
555
  );
557
556
  const [secondaryAmount, liquidityBrand] = await Promise.all([
558
557
  // Error: (an undefined) was not a live payment for brand
@@ -576,7 +575,7 @@ export const fundAMM = async ({
576
575
  );
577
576
 
578
577
  const issuerPresence = await kit.issuer;
579
- return E(E.get(vaultFactoryKit).creatorFacet).addVaultType(
578
+ return E(vaultFactoryCreator).addVaultType(
580
579
  issuerPresence,
581
580
  issuerName,
582
581
  rates,