@agoric/inter-protocol 0.13.2-dev-0e039d9.0 → 0.13.2-dev-ed5ee58.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 (71) hide show
  1. package/bundles/bundle-econCommitteeCharter-meta.js +78 -78
  2. package/bundles/bundle-econCommitteeCharter.js +1 -1
  3. package/bundles/bundle-feeDistributor-meta.js +61 -61
  4. package/bundles/bundle-feeDistributor.js +1 -1
  5. package/bundles/bundle-fluxAggregator-meta.js +114 -114
  6. package/bundles/bundle-fluxAggregator.js +1 -1
  7. package/bundles/bundle-psm-meta.js +112 -112
  8. package/bundles/bundle-psm.js +1 -1
  9. package/bundles/bundle-reserve-meta.js +110 -114
  10. package/bundles/bundle-reserve.js +1 -1
  11. package/bundles/bundle-scaledPriceAuthority-meta.js +78 -78
  12. package/bundles/bundle-scaledPriceAuthority.js +1 -1
  13. package/bundles/bundle-stakeFactory-meta.js +118 -118
  14. package/bundles/bundle-stakeFactory.js +1 -1
  15. package/bundles/bundle-vaultFactory-meta.js +128 -128
  16. package/bundles/bundle-vaultFactory.js +1 -1
  17. package/exported.js +0 -1
  18. package/package.json +16 -16
  19. package/scripts/deploy-contracts.js +0 -2
  20. package/scripts/init-core.js +0 -16
  21. package/src/feeDistributor.js +1 -1
  22. package/src/proposals/addAssetToVault.js +4 -57
  23. package/src/proposals/committee-proposal.js +3 -6
  24. package/src/proposals/core-proposal.js +1 -73
  25. package/src/proposals/demoIssuers.js +1 -232
  26. package/src/proposals/econ-behaviors.js +10 -193
  27. package/src/proposals/sim-behaviors.js +1 -1
  28. package/src/reserve/assetReserve.js +9 -170
  29. package/src/reserve/params.js +1 -4
  30. package/src/vaultFactory/liquidateIncrementally.js +16 -141
  31. package/src/vaultFactory/liquidateMinimum.js +19 -21
  32. package/src/vaultFactory/params.js +0 -29
  33. package/src/vaultFactory/types.js +0 -6
  34. package/src/vaultFactory/vault.js +1 -3
  35. package/src/vaultFactory/vaultDirector.js +1 -33
  36. package/src/vaultFactory/vaultFactory.js +2 -12
  37. package/src/vaultFactory/vaultManager.js +10 -217
  38. package/bundles/bundle-amm-meta.js +0 -686
  39. package/bundles/bundle-amm.js +0 -1
  40. package/bundles/bundle-interchainPool-meta.js +0 -606
  41. package/bundles/bundle-interchainPool.js +0 -1
  42. package/bundles/bundle-liquidateIncrementally-meta.js +0 -470
  43. package/bundles/bundle-liquidateIncrementally.js +0 -1
  44. package/bundles/bundle-liquidateMinimum-meta.js +0 -470
  45. package/bundles/bundle-liquidateMinimum.js +0 -1
  46. package/scripts/add-initial-liquidity.js +0 -179
  47. package/src/interchainPool.js +0 -134
  48. package/src/vpool-xyk-amm/AttackersGuide.md +0 -89
  49. package/src/vpool-xyk-amm/addLiquidity.js +0 -221
  50. package/src/vpool-xyk-amm/addPool.js +0 -200
  51. package/src/vpool-xyk-amm/constantProduct/AMM-Trade.jpeg +0 -0
  52. package/src/vpool-xyk-amm/constantProduct/README.md +0 -204
  53. package/src/vpool-xyk-amm/constantProduct/calcFees.js +0 -93
  54. package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +0 -83
  55. package/src/vpool-xyk-amm/constantProduct/core.js +0 -145
  56. package/src/vpool-xyk-amm/constantProduct/defaults.js +0 -3
  57. package/src/vpool-xyk-amm/constantProduct/getXY.js +0 -48
  58. package/src/vpool-xyk-amm/constantProduct/internal-types.js +0 -114
  59. package/src/vpool-xyk-amm/constantProduct/invariants.js +0 -39
  60. package/src/vpool-xyk-amm/constantProduct/swap.js +0 -270
  61. package/src/vpool-xyk-amm/constantProduct/types.js +0 -30
  62. package/src/vpool-xyk-amm/doublePool.js +0 -200
  63. package/src/vpool-xyk-amm/estimate.js +0 -175
  64. package/src/vpool-xyk-amm/multipoolMarketMaker.js +0 -530
  65. package/src/vpool-xyk-amm/params.js +0 -59
  66. package/src/vpool-xyk-amm/pool.js +0 -398
  67. package/src/vpool-xyk-amm/priceAuthority.js +0 -92
  68. package/src/vpool-xyk-amm/removeLiquidity.js +0 -29
  69. package/src/vpool-xyk-amm/singlePool.js +0 -88
  70. package/src/vpool-xyk-amm/swap.js +0 -68
  71. package/src/vpool-xyk-amm/types.js +0 -152
@@ -12,19 +12,14 @@ import { E } from '@endo/far';
12
12
  import { LienBridgeId, makeStakeReporter } from '../my-lien.js';
13
13
  import { makeReserveTerms } from '../reserve/params.js';
14
14
  import { makeStakeFactoryTerms } from '../stakeFactory/params.js';
15
- import { liquidationDetailTerms } from '../vaultFactory/liquidation.js';
16
15
  import { makeGovernedTerms } from '../vaultFactory/params.js';
17
- import { makeAmmTerms } from '../vpool-xyk-amm/params.js';
18
16
 
19
17
  const trace = makeTracer('RunEconBehaviors', false);
20
18
 
21
- const { Fail } = assert;
22
-
23
19
  const SECONDS_PER_HOUR = 60n * 60n;
24
20
  const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR;
25
21
 
26
22
  const BASIS_POINTS = 10_000n;
27
- const MILLI = 1_000_000n;
28
23
 
29
24
  /**
30
25
  * @typedef {GovernedCreatorFacet<import('../stakeFactory/stakeFactory.js').StakeFactoryCreator>} StakeFactoryCreator
@@ -46,13 +41,6 @@ const MILLI = 1_000_000n;
46
41
  * @typedef { WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace
47
42
  * } EconomyBootstrapPowers
48
43
  * @typedef {PromiseSpaceOf<{
49
- * ammKit: {
50
- * instanceWithoutReserve: Instance,
51
- * creatorFacet: XYKAMMCreatorFacet,
52
- * governorCreatorFacet: GovernedContractFacetAccess<XYKAMMPublicFacet,XYKAMMCreatorFacet>,
53
- * adminFacet: AdminFacet,
54
- * publicFacet: XYKAMMPublicFacet,
55
- * },
56
44
  * economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet,
57
45
  * feeDistributorKit: {
58
46
  * creatorFacet: import('../feeDistributor.js').FeeDistributorCreatorFacet,
@@ -96,164 +84,9 @@ const MILLI = 1_000_000n;
96
84
  * In production called by @agoric/vats to bootstrap.
97
85
  */
98
86
 
99
- /**
100
- * @param {EconomyBootstrapPowers} powers
101
- * @param {{
102
- * interchainPoolOptions?: { minimumCentral?: bigint }
103
- * }} [options]
104
- */
105
- export const startInterchainPool = async (
106
- {
107
- consume: { bankManager: mgrP, zoe, agoricNamesAdmin },
108
- installation: {
109
- consume: { interchainPool: installation },
110
- },
111
- instance: {
112
- consume: { amm },
113
- produce: { interchainPool: _viaAgoricNamesAdmin },
114
- },
115
- brand: {
116
- consume: { [Stable.symbol]: centralBrandP },
117
- },
118
- issuer: {
119
- consume: { [Stable.symbol]: centralIssuerP },
120
- },
121
- },
122
- { interchainPoolOptions = {} } = {},
123
- ) => {
124
- trace('startInterchainPool');
125
- // TODO: get minimumCentral dynamically from the AMM
126
- const { minimumCentral = 100n * MILLI } = interchainPoolOptions;
127
- const [centralIssuer, centralBrand, bankManager] = await Promise.all([
128
- centralIssuerP,
129
- centralBrandP,
130
- mgrP,
131
- ]);
132
-
133
- const terms = await deeplyFulfilledObject(
134
- harden({
135
- minimumCentral: AmountMath.make(centralBrand, minimumCentral),
136
- amm,
137
- }),
138
- );
139
- const { instance } = await E(zoe).startInstance(
140
- installation,
141
- { Central: centralIssuer },
142
- terms,
143
- {
144
- bankManager,
145
- },
146
- );
147
-
148
- const instanceAdmin = E(agoricNamesAdmin).lookupAdmin('instance');
149
- await E(instanceAdmin).update('interchainPool', instance);
150
- };
151
- harden(startInterchainPool);
152
-
153
- const AMM_STORAGE_PATH = 'amm'; // TODO: share with agoricNames?
154
-
155
- /**
156
- * @param {EconomyBootstrapPowers} powers
157
- * @param {{ options?: { minInitialPoolLiquidity?: bigint }}} opts
158
- */
159
- export const setupAmm = async (
160
- {
161
- consume: {
162
- board,
163
- chainTimerService,
164
- zoe,
165
- economicCommitteeCreatorFacet: committeeCreator,
166
- chainStorage,
167
- },
168
- produce: { ammKit },
169
- brand: {
170
- consume: { [Stable.symbol]: runBrandP },
171
- },
172
- issuer: {
173
- consume: { [Stable.symbol]: centralIssuer },
174
- },
175
- instance: {
176
- produce: { ammGovernor },
177
- },
178
- installation: {
179
- consume: { contractGovernor: governorInstallation, amm: ammInstallation },
180
- },
181
- },
182
- { options = {} } = {},
183
- ) => {
184
- trace('setupAmm');
185
-
186
- const poserInvitationP = E(committeeCreator).getPoserInvitation();
187
- const [poserInvitation, runBrand] = await Promise.all([
188
- poserInvitationP,
189
- runBrandP,
190
- ]);
191
- const { minInitialPoolLiquidity = 1_000_000_000n } = options;
192
-
193
- const ammTerms = makeAmmTerms(
194
- chainTimerService,
195
- E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitation),
196
- AmountMath.make(runBrand, minInitialPoolLiquidity),
197
- );
198
-
199
- const storageNode = await makeStorageNodeChild(
200
- chainStorage,
201
- AMM_STORAGE_PATH,
202
- );
203
- const marshaller = await E(board).getPublishingMarshaller();
204
-
205
- const ammGovernorTerms = await deeplyFulfilledObject(
206
- harden({
207
- timer: chainTimerService,
208
- governedContractInstallation: ammInstallation,
209
- governed: {
210
- terms: ammTerms,
211
- issuerKeywordRecord: { Central: centralIssuer },
212
- },
213
- }),
214
- );
215
-
216
- /** @type {{ creatorFacet: GovernedContractFacetAccess<XYKAMMPublicFacet,XYKAMMCreatorFacet>, publicFacet: GovernorPublic, instance: Instance, adminFacet: AdminFacet }} */
217
- const g = await E(zoe).startInstance(
218
- governorInstallation,
219
- {},
220
- ammGovernorTerms,
221
- {
222
- electorateCreatorFacet: committeeCreator,
223
- governed: {
224
- initialPoserInvitation: poserInvitation,
225
- storageNode,
226
- marshaller,
227
- },
228
- },
229
- );
230
-
231
- const [creatorFacet, ammPublicFacet, instance] = await Promise.all([
232
- E(g.creatorFacet).getCreatorFacet(),
233
- E(g.creatorFacet).getPublicFacet(),
234
- E(g.publicFacet).getGovernedContract(),
235
- ]);
236
- ammKit.resolve(
237
- harden({
238
- creatorFacet,
239
- instanceWithoutReserve: instance,
240
- governorCreatorFacet: g.creatorFacet,
241
- adminFacet: g.adminFacet,
242
- publicFacet: ammPublicFacet,
243
- }),
244
- );
245
-
246
- // Confirm that the amm was indeed setup
247
- ammPublicFacet || Fail`ammPublicFacet broken ${ammPublicFacet}`;
248
-
249
- ammGovernor.resolve(g.instance);
250
- return ammInstallation;
251
- };
252
-
253
87
  /** @param {EconomyBootstrapPowers} powers */
254
88
  export const setupReserve = async ({
255
89
  consume: {
256
- ammKit: ammKitP,
257
90
  board,
258
91
  feeMintAccess: feeMintAccessP,
259
92
  chainStorage,
@@ -266,11 +99,7 @@ export const setupReserve = async ({
266
99
  consume: { [Stable.symbol]: centralIssuer },
267
100
  },
268
101
  instance: {
269
- produce: {
270
- amm: ammInstanceProducer,
271
- reserve: reserveInstanceProducer,
272
- reserveGovernor,
273
- },
102
+ produce: { reserve: reserveInstanceProducer, reserveGovernor },
274
103
  },
275
104
  installation: {
276
105
  consume: {
@@ -282,17 +111,21 @@ export const setupReserve = async ({
282
111
  const STORAGE_PATH = 'reserve';
283
112
  trace('setupReserve');
284
113
  const poserInvitationP = E(committeeCreator).getPoserInvitation();
285
- const [poserInvitation, poserInvitationAmount, feeMintAccess, ammKit] =
114
+
115
+ await poserInvitationP;
116
+ await E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP);
117
+ await feeMintAccessP;
118
+
119
+ const [poserInvitation, poserInvitationAmount, feeMintAccess] =
286
120
  await Promise.all([
287
121
  poserInvitationP,
288
122
  E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
289
123
  feeMintAccessP,
290
- ammKitP,
291
124
  ]);
292
125
 
293
126
  const reserveTerms = makeReserveTerms(
294
127
  poserInvitationAmount,
295
- ammKit.instanceWithoutReserve,
128
+ chainTimerService,
296
129
  );
297
130
 
298
131
  const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
@@ -342,14 +175,6 @@ export const setupReserve = async ({
342
175
  reserveInstanceProducer.resolve(instance);
343
176
  reserveGovernor.resolve(g.instance);
344
177
 
345
- // AMM requires Reserve in order to add pools, but we can't provide it at startInstance
346
- // time because Reserve requires AMM itself in order to be started.
347
- // Now that we have the reserve, provide it to the AMM.
348
- trace('Resolving the reserve public facet on the AMM');
349
- await E(ammKit.creatorFacet).resolveReserveFacet(publicFacet);
350
- // it now has the reserve
351
- ammInstanceProducer.resolve(ammKit.instanceWithoutReserve);
352
-
353
178
  return reserveInstallation;
354
179
  };
355
180
 
@@ -379,12 +204,11 @@ export const startVaultFactory = async (
379
204
  },
380
205
  instance: {
381
206
  produce: instanceProduce,
382
- consume: { amm: ammInstance, reserve: reserveInstance },
207
+ consume: { reserve: reserveInstance },
383
208
  },
384
209
  installation: {
385
210
  consume: {
386
211
  VaultFactory: vaultFactoryInstallation,
387
- liquidate: liquidateInstallationP,
388
212
  contractGovernor: contractGovernorInstallation,
389
213
  },
390
214
  },
@@ -405,25 +229,23 @@ export const startVaultFactory = async (
405
229
  const shortfallInvitationP = E(
406
230
  E.get(reserveKit).creatorFacet,
407
231
  ).makeShortfallReportingInvitation();
232
+
408
233
  const [
409
234
  initialPoserInvitation,
410
235
  poserInvitationAmount,
411
236
  initialShortfallInvitation,
412
237
  shortfallInvitationAmount,
413
- liquidateInstallation,
414
238
  feeMintAccess,
415
239
  ] = await Promise.all([
416
240
  poserInvitationP,
417
241
  E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
418
242
  shortfallInvitationP,
419
243
  E(E(zoe).getInvitationIssuer()).getAmountOf(shortfallInvitationP),
420
- liquidateInstallationP,
421
244
  feeMintAccessP,
422
245
  ]);
423
246
 
424
247
  const centralBrand = await centralBrandP;
425
248
 
426
- const ammPublicFacet = await E(zoe).getPublicFacet(ammInstance);
427
249
  const reservePublicFacet = await E(zoe).getPublicFacet(reserveInstance);
428
250
  const storageNode = await makeStorageNodeChild(chainStorage, STORAGE_PATH);
429
251
  const marshaller = await E(board).getReadonlyMarshaller();
@@ -434,11 +256,8 @@ export const startVaultFactory = async (
434
256
  priceAuthority,
435
257
  reservePublicFacet,
436
258
  loanTiming: loanParams,
437
- liquidationInstall: liquidateInstallation,
438
259
  timer: chainTimerService,
439
260
  electorateInvitationAmount: poserInvitationAmount,
440
- ammPublicFacet,
441
- liquidationTerms: liquidationDetailTerms(centralBrand),
442
261
  minInitialDebt: AmountMath.make(centralBrand, minInitialDebt),
443
262
  bootstrapPaymentValue: 0n,
444
263
  shortfallInvitationAmount,
@@ -540,7 +359,6 @@ export const startRewardDistributor = async ({
540
359
  bankManager,
541
360
  vaultFactoryKit,
542
361
  periodicFeeCollectors,
543
- ammKit,
544
362
  stakeFactoryKit,
545
363
  reserveKit,
546
364
  zoe,
@@ -620,7 +438,6 @@ export const startRewardDistributor = async ({
620
438
 
621
439
  const collectorKit = {
622
440
  vaultFactory: E.get(vaultFactoryKit).creatorFacet,
623
- amm: E.get(ammKit).creatorFacet,
624
441
  runStake: E.get(stakeFactoryKit).creatorFacet,
625
442
  };
626
443
  await Promise.all(
@@ -1,7 +1,7 @@
1
1
  import { E, Far } from '@endo/far';
2
2
  import { addRemote } from '@agoric/vats/src/core/utils.js';
3
3
 
4
- export { connectFaucet, fundAMM } from './demoIssuers.js';
4
+ export { connectFaucet } from './demoIssuers.js';
5
5
 
6
6
  /** @param {BootstrapPowers} powers */
7
7
  export const installSimEgress = async ({
@@ -1,24 +1,16 @@
1
1
  import { E, Far } from '@endo/far';
2
2
  import { AmountMath } from '@agoric/ertp';
3
- import { handleParamGovernance, ParamTypes } from '@agoric/governance';
4
- import {
5
- offerTo,
6
- atomicTransfer,
7
- } from '@agoric/zoe/src/contractSupport/index.js';
3
+ import { handleParamGovernance } from '@agoric/governance';
4
+ import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js';
8
5
  import { provideDurableMapStore, prepareKindMulti } from '@agoric/vat-data';
9
6
 
10
7
  import { makeTracer } from '@agoric/internal';
11
- import { AMM_INSTANCE } from './params.js';
12
8
  import { makeMetricsPublisherKit } from '../contractSupport.js';
13
9
 
14
10
  const { Fail, quote: q } = assert;
15
11
 
16
12
  const trace = makeTracer('Reserve', false);
17
13
 
18
- const makeLiquidityKeyword = keyword => `${keyword}Liquidity`;
19
-
20
- const nonalphanumeric = /[^A-Za-z0-9]/g;
21
-
22
14
  /**
23
15
  * @typedef {object} MetricsNotification
24
16
  *
@@ -56,18 +48,11 @@ const nonalphanumeric = /[^A-Za-z0-9]/g;
56
48
 
57
49
  /**
58
50
  * Asset Reserve holds onto assets for the Inter Protocol, and can
59
- * dispense it for various purposes under governance control. It currently
60
- * supports governance decisions to add liquidity to an AMM pool.
51
+ * dispense it for various purposes under governance control.
61
52
  *
62
- * This contract has the ability to mint Fee tokens, granted through its private
63
- * arguments. When adding liquidity to an AMM pool, it mints new Fee tokens and
64
- * merges them with the specified amount of collateral on hand. It then deposits
65
- * both into an AMM pool by using the AMM's method that allows the pool balance
66
- * to be determined based on the contributed funds.
67
- *
68
- * @param {ZCF<GovernanceTerms<{AmmInstance: 'instance'}> &
53
+ * @param {ZCF<GovernanceTerms<{}> &
69
54
  * {
70
- * governedApis: ['addLiquidityToAmmPool'],
55
+ * governedApis: ['burnFeesToReduceShortfall'],
71
56
  * }
72
57
  * >} zcf
73
58
  * @param {{
@@ -96,13 +81,6 @@ const start = async (zcf, privateArgs, baggage) => {
96
81
  * @type {MapStore<Keyword, Brand>}
97
82
  */
98
83
  const brandForKeyword = provideDurableMapStore(baggage, 'brandForKeyword');
99
- /**
100
- * @type {MapStore<Brand<'nat'>, Brand<'nat'>>}
101
- */
102
- const liquidityBrandForBrand = provideDurableMapStore(
103
- baggage,
104
- 'liquidityBrandForBrand',
105
- );
106
84
 
107
85
  /** @type {() => Promise<ZCFMint<'nat'>>} */
108
86
  const takeFeeMint = async () => {
@@ -133,22 +111,15 @@ const start = async (zcf, privateArgs, baggage) => {
133
111
  saveBrandKeyword(feeKit.brand, 'Fee');
134
112
  // no need to saveIssuer() b/c registerFeeMint did it
135
113
 
136
- const { augmentVirtualPublicFacet, makeVirtualGovernorFacet, params } =
114
+ const { augmentVirtualPublicFacet, makeVirtualGovernorFacet } =
137
115
  await handleParamGovernance(
138
116
  zcf,
139
117
  privateArgs.initialPoserInvitation,
140
- {
141
- [AMM_INSTANCE]: ParamTypes.INSTANCE,
142
- },
118
+ {},
143
119
  privateArgs.storageNode,
144
120
  privateArgs.marshaller,
145
121
  );
146
122
 
147
- /** @type {Promise<XYKAMMPublicFacet>} */
148
- const ammPublicFacet = E(zcf.getZoeService()).getPublicFacet(
149
- params.getAmmInstance(),
150
- );
151
-
152
123
  /**
153
124
  * @param {MethodContext} _context
154
125
  * @param {Issuer} issuer
@@ -171,71 +142,6 @@ const start = async (zcf, privateArgs, baggage) => {
171
142
  await zcf.saveIssuer(issuer, keyword);
172
143
  };
173
144
 
174
- /**
175
- * @param {MethodContext} _context
176
- * @param {Issuer<'nat'>} baseIssuer on which the liquidity issuer is based
177
- */
178
- const addLiquidityIssuer = async (_context, baseIssuer) => {
179
- const getBrand = () => {
180
- try {
181
- return zcf.getBrandForIssuer(baseIssuer);
182
- } catch {
183
- assert.fail(
184
- `baseIssuer ${baseIssuer} not known; try addIssuer() first`,
185
- );
186
- }
187
- };
188
- const baseBrand = getBrand();
189
- const baseKeyword = keywordForBrand.get(baseBrand);
190
- const liquidityIssuer = E(ammPublicFacet).getLiquidityIssuer(baseBrand);
191
- const liquidityBrand = await E(liquidityIssuer).getBrand();
192
- const liquidityKeyword = makeLiquidityKeyword(baseKeyword);
193
-
194
- trace('addLiquidityIssuer', {
195
- baseBrand,
196
- baseKeyword,
197
- liquidityBrand,
198
- liquidityKeyword,
199
- });
200
- saveBrandKeyword(liquidityBrand, liquidityKeyword);
201
- liquidityBrandForBrand.init(baseBrand, liquidityBrand);
202
-
203
- await zcf.saveIssuer(liquidityIssuer, liquidityKeyword);
204
- };
205
-
206
- const conjureKeyword = async baseBrand => {
207
- const allegedName = await E(baseBrand).getAllegedName();
208
- const safeName = allegedName.replace(nonalphanumeric, '');
209
- let keyword;
210
- let keywordNum = 0;
211
- do {
212
- // 'R' to guarantee leading uppercase
213
- keyword = `R${safeName}${keywordNum || ''}`;
214
- keywordNum += 1;
215
- } while (brandForKeyword.has(keyword));
216
- return keyword;
217
- };
218
-
219
- /**
220
- * @param {MethodContext} context
221
- * @param {Brand<'nat'>} ammSecondaryBrand
222
- * @returns {Promise<void>}
223
- */
224
- const addIssuerFromAmm = async (context, ammSecondaryBrand) => {
225
- assert(
226
- ammSecondaryBrand !== feeKit.brand,
227
- 'Fee is a special case handled by the reserve contract',
228
- );
229
-
230
- const keyword = await conjureKeyword(ammSecondaryBrand);
231
- trace('addIssuerFromAmm', { ammSecondaryBrand, keyword });
232
- // validate the AMM has this brand and match its issuer
233
- const issuer = await E(ammPublicFacet).getSecondaryIssuer(
234
- ammSecondaryBrand,
235
- );
236
- await addIssuer(context, issuer, keyword);
237
- };
238
-
239
145
  const getKeywordForBrand = brand => {
240
146
  keywordForBrand.has(brand) ||
241
147
  Fail`Issuer not defined for brand ${q(brand)}; first call addIssuer()`;
@@ -319,70 +225,6 @@ const start = async (zcf, privateArgs, baggage) => {
319
225
  return initialState;
320
226
  };
321
227
 
322
- /**
323
- * Takes collateral from the reserve, mints Fee tokens to accompany it, and uses both
324
- * to add Liquidity to a pool in the AMM.
325
- *
326
- * @param {MethodContext} context
327
- * @param {Amount<'nat'>} collateral
328
- * @param {Amount<'nat'>} fee
329
- */
330
- const addLiquidityToAmmPool = async ({ state }, collateral, fee) => {
331
- // verify we have the funds
332
- const collateralKeyword = getKeywordForBrand(collateral.brand);
333
- if (
334
- !AmountMath.isGTE(
335
- collateralSeat.getCurrentAllocation()[collateralKeyword],
336
- collateral,
337
- )
338
- ) {
339
- throw new Error('insufficient reserves for that transaction');
340
- }
341
-
342
- // create the Fee tokens
343
- const offerToSeat = feeMint.mintGains(harden({ Fee: fee }));
344
- state.totalFeeMinted = AmountMath.add(state.totalFeeMinted, fee);
345
-
346
- atomicTransfer(zcf, collateralSeat, offerToSeat, {
347
- [collateralKeyword]: collateral,
348
- });
349
-
350
- // Add Fee tokens and collateral to the AMM
351
- const invitation = await E(
352
- ammPublicFacet,
353
- ).makeAddLiquidityAtRateInvitation();
354
- const mapping = harden({
355
- Fee: 'Central',
356
- [collateralKeyword]: 'Secondary',
357
- });
358
-
359
- const liqBrand = liquidityBrandForBrand.get(collateral.brand);
360
- const proposal = harden({
361
- give: {
362
- Central: fee,
363
- Secondary: collateral,
364
- },
365
- want: { Liquidity: AmountMath.makeEmpty(liqBrand) },
366
- });
367
-
368
- // chain await the completion of both the offer and the `deposited` promise
369
- await E.get(offerTo(zcf, invitation, mapping, proposal, offerToSeat))
370
- .deposited;
371
-
372
- // transfer from userSeat to LiquidityToken holdings
373
- const liquidityAmount = offerToSeat.getCurrentAllocation();
374
- const liquidityKeyword = makeLiquidityKeyword(collateralKeyword);
375
-
376
- atomicTransfer(
377
- zcf,
378
- offerToSeat,
379
- collateralSeat,
380
- { Liquidity: liquidityAmount.Liquidity },
381
- { [liquidityKeyword]: liquidityAmount.Liquidity },
382
- );
383
- updateMetrics({ state });
384
- };
385
-
386
228
  /**
387
229
  *
388
230
  * @param {MethodContext} context
@@ -431,13 +273,11 @@ const start = async (zcf, privateArgs, baggage) => {
431
273
  getMetrics: () => metricsSubscription,
432
274
  });
433
275
 
434
- const governedApis = { addLiquidityToAmmPool, burnFeesToReduceShortfall };
276
+ const governedApis = { burnFeesToReduceShortfall };
435
277
 
436
278
  const publicFacet = augmentVirtualPublicFacet(
437
279
  Far('Collateral Reserve public', {
438
280
  makeAddCollateralInvitation,
439
- addIssuerFromAmm,
440
- addLiquidityIssuer,
441
281
  }),
442
282
  );
443
283
 
@@ -467,7 +307,7 @@ export { start };
467
307
  * @typedef {object} OriginalAssetReserveCreatorFacet
468
308
  * @property {() => Invitation} makeAddCollateralInvitation
469
309
  * @property {() => Allocation} getAllocations
470
- * @property {(issuer: Issuer) => void} addIssuer
310
+ * @property {(issuer: Issuer, kwd: string) => void} addIssuer
471
311
  * @property {() => Invitation<ShortfallReporter>} makeShortfallReportingInvitation
472
312
  * @property {() => StoredSubscription<MetricsNotification>} getMetrics
473
313
  */
@@ -475,7 +315,6 @@ export { start };
475
315
  /**
476
316
  * @typedef {object} OriginalAssetReservePublicFacet
477
317
  * @property {() => Invitation} makeAddCollateralInvitation
478
- * @property {(brand: Brand) => void} addIssuerFromAmm
479
318
  * @property {(issuer: Issuer) => void} addLiquidityIssuer
480
319
  */
481
320
 
@@ -1,11 +1,8 @@
1
1
  import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
2
2
 
3
- export const AMM_INSTANCE = 'AmmInstance';
4
-
5
- const makeReserveTerms = (poserInvitationAmount, ammInstance, timer) => ({
3
+ const makeReserveTerms = (poserInvitationAmount, timer) => ({
6
4
  timer,
7
5
  governedParams: harden({
8
- [AMM_INSTANCE]: { type: ParamTypes.INSTANCE, value: ammInstance },
9
6
  [CONTRACT_ELECTORATE]: {
10
7
  type: ParamTypes.INVITATION,
11
8
  value: poserInvitationAmount,