@agoric/fast-usdc 0.1.1-dev-74ab972.0 → 0.1.1-dev-340ef0d.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/fast-usdc",
3
- "version": "0.1.1-dev-74ab972.0+74ab972",
3
+ "version": "0.1.1-dev-340ef0d.0+340ef0d",
4
4
  "description": "CLI and library for Fast USDC product",
5
5
  "type": "module",
6
6
  "files": [
@@ -22,9 +22,9 @@
22
22
  "lint:eslint": "eslint ."
23
23
  },
24
24
  "devDependencies": {
25
- "@agoric/swingset-liveslots": "0.10.3-dev-74ab972.0+74ab972",
26
- "@agoric/vats": "0.15.2-dev-74ab972.0+74ab972",
27
- "@agoric/zone": "0.2.3-dev-74ab972.0+74ab972",
25
+ "@agoric/swingset-liveslots": "0.10.3-dev-340ef0d.0+340ef0d",
26
+ "@agoric/vats": "0.15.2-dev-340ef0d.0+340ef0d",
27
+ "@agoric/zone": "0.2.3-dev-340ef0d.0+340ef0d",
28
28
  "@fast-check/ava": "^2.0.1",
29
29
  "ava": "^5.3.0",
30
30
  "c8": "^10.1.2",
@@ -32,15 +32,15 @@
32
32
  "ts-blank-space": "^0.4.4"
33
33
  },
34
34
  "dependencies": {
35
- "@agoric/client-utils": "0.1.1-dev-74ab972.0+74ab972",
36
- "@agoric/ertp": "0.16.3-dev-74ab972.0+74ab972",
37
- "@agoric/internal": "0.3.3-dev-74ab972.0+74ab972",
38
- "@agoric/notifier": "0.6.3-dev-74ab972.0+74ab972",
39
- "@agoric/orchestration": "0.1.1-dev-74ab972.0+74ab972",
40
- "@agoric/store": "0.9.3-dev-74ab972.0+74ab972",
41
- "@agoric/vat-data": "0.5.3-dev-74ab972.0+74ab972",
42
- "@agoric/vow": "0.1.1-dev-74ab972.0+74ab972",
43
- "@agoric/zoe": "0.26.3-dev-74ab972.0+74ab972",
35
+ "@agoric/client-utils": "0.1.1-dev-340ef0d.0+340ef0d",
36
+ "@agoric/ertp": "0.16.3-dev-340ef0d.0+340ef0d",
37
+ "@agoric/internal": "0.3.3-dev-340ef0d.0+340ef0d",
38
+ "@agoric/notifier": "0.6.3-dev-340ef0d.0+340ef0d",
39
+ "@agoric/orchestration": "0.1.1-dev-340ef0d.0+340ef0d",
40
+ "@agoric/store": "0.9.3-dev-340ef0d.0+340ef0d",
41
+ "@agoric/vat-data": "0.5.3-dev-340ef0d.0+340ef0d",
42
+ "@agoric/vow": "0.1.1-dev-340ef0d.0+340ef0d",
43
+ "@agoric/zoe": "0.26.3-dev-340ef0d.0+340ef0d",
44
44
  "@cosmjs/proto-signing": "^0.32.4",
45
45
  "@cosmjs/stargate": "^0.32.4",
46
46
  "@endo/base64": "^1.0.9",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "74ab97267871ba70884c1a140cfc1da1482b51c1"
83
+ "gitHead": "340ef0d3a3b0d80ed847fc7a78c805f0c589c7c9"
84
84
  }
@@ -56,6 +56,7 @@ const AdvancerVowCtxShape = M.splitRecord(
56
56
  const AdvancerKitI = harden({
57
57
  advancer: M.interface('AdvancerI', {
58
58
  handleTransactionEvent: M.callWhen(CctpTxEvidenceShape).returns(),
59
+ setIntermediateRecipient: M.call(ChainAddressShape).returns(),
59
60
  }),
60
61
  depositHandler: M.interface('DepositHandlerI', {
61
62
  onFulfilled: M.call(M.undefined(), AdvancerVowCtxShape).returns(VowShape),
@@ -95,7 +96,7 @@ export const prepareAdvancerKit = (
95
96
  usdc,
96
97
  vowTools: { watch, when },
97
98
  zcf,
98
- } = /** @type {AdvancerKitPowers} */ ({}),
99
+ },
99
100
  ) => {
100
101
  assertAllDefined({
101
102
  chainHub,
@@ -116,10 +117,15 @@ export const prepareAdvancerKit = (
116
117
  * notifyFacet: import('./settler.js').SettlerKit['notify'];
117
118
  * borrowerFacet: LiquidityPoolKit['borrower'];
118
119
  * poolAccount: HostInterface<OrchestrationAccount<{chainId: 'agoric'}>>;
119
- * intermediateRecipient: ChainAddress;
120
+ * intermediateRecipient?: ChainAddress;
120
121
  * }} config
121
122
  */
122
- config => harden(config),
123
+ config =>
124
+ harden({
125
+ ...config,
126
+ // make sure the state record has this property, perhaps with an undefined value
127
+ intermediateRecipient: config.intermediateRecipient,
128
+ }),
123
129
  {
124
130
  advancer: {
125
131
  /**
@@ -181,6 +187,10 @@ export const prepareAdvancerKit = (
181
187
  statusManager.observe(evidence);
182
188
  }
183
189
  },
190
+ /** @param {ChainAddress} intermediateRecipient */
191
+ setIntermediateRecipient(intermediateRecipient) {
192
+ this.state.intermediateRecipient = intermediateRecipient;
193
+ },
184
194
  },
185
195
  depositHandler: {
186
196
  /**
@@ -192,15 +202,8 @@ export const prepareAdvancerKit = (
192
202
  const { destination, advanceAmount, ...detail } = ctx;
193
203
  const transferV = E(poolAccount).transfer(
194
204
  destination,
195
- {
196
- denom: usdc.denom,
197
- value: advanceAmount.value,
198
- },
199
- {
200
- forwardOpts: {
201
- intermediateRecipient,
202
- },
203
- },
205
+ { denom: usdc.denom, value: advanceAmount.value },
206
+ { forwardOpts: { intermediateRecipient } },
204
207
  );
205
208
  return watch(transferV, this.facets.transferHandler, {
206
209
  destination,
@@ -259,7 +262,7 @@ export const prepareAdvancerKit = (
259
262
  notifyFacet: M.remotable(),
260
263
  borrowerFacet: M.remotable(),
261
264
  poolAccount: M.remotable(),
262
- intermediateRecipient: ChainAddressShape,
265
+ intermediateRecipient: M.opt(ChainAddressShape),
263
266
  }),
264
267
  },
265
268
  );
@@ -62,6 +62,7 @@ export const prepareSettler = (
62
62
  {
63
63
  creator: M.interface('SettlerCreatorI', {
64
64
  monitorMintingDeposits: M.callWhen().returns(M.any()),
65
+ setIntermediateRecipient: M.call(ChainAddressShape).returns(),
65
66
  }),
66
67
  tap: M.interface('SettlerTapI', {
67
68
  receiveUpcall: M.call(M.record()).returns(M.promise()),
@@ -94,13 +95,15 @@ export const prepareSettler = (
94
95
  * remoteDenom: Denom;
95
96
  * repayer: LiquidityPoolKit['repayer'];
96
97
  * settlementAccount: HostInterface<OrchestrationAccount<{ chainId: 'agoric' }>>
97
- * intermediateRecipient: ChainAddress;
98
+ * intermediateRecipient?: ChainAddress;
98
99
  * }} config
99
100
  */
100
101
  config => {
101
102
  log('config', config);
102
103
  return {
103
104
  ...config,
105
+ // make sure the state record has this property, perhaps with an undefined value
106
+ intermediateRecipient: config.intermediateRecipient,
104
107
  /** @type {HostInterface<TargetRegistration>|undefined} */
105
108
  registration: undefined,
106
109
  /** @type {SetStore<ReturnType<typeof makeMintedEarlyKey>>} */
@@ -117,6 +120,10 @@ export const prepareSettler = (
117
120
  assert.typeof(registration, 'object');
118
121
  this.state.registration = registration;
119
122
  },
123
+ /** @param {ChainAddress} intermediateRecipient */
124
+ setIntermediateRecipient(intermediateRecipient) {
125
+ this.state.intermediateRecipient = intermediateRecipient;
126
+ },
120
127
  },
121
128
  tap: {
122
129
  /** @param {VTransferIBCEvent} event */
@@ -265,11 +272,7 @@ export const prepareSettler = (
265
272
  const txfrV = E(settlementAccount).transfer(
266
273
  dest,
267
274
  AmountMath.make(USDC, fullValue),
268
- {
269
- forwardOpts: {
270
- intermediateRecipient,
271
- },
272
- },
275
+ { forwardOpts: { intermediateRecipient } },
273
276
  );
274
277
  void vowTools.watch(txfrV, this.facets.transferHandler, {
275
278
  txHash,
@@ -312,7 +315,7 @@ export const prepareSettler = (
312
315
  sourceChannel: M.string(),
313
316
  remoteDenom: M.string(),
314
317
  mintedEarly: M.remotable('mintedEarly'),
315
- intermediateRecipient: ChainAddressShape,
318
+ intermediateRecipient: M.opt(ChainAddressShape),
316
319
  }),
317
320
  },
318
321
  );
@@ -1,5 +1,5 @@
1
1
  import { AssetKind } from '@agoric/ertp';
2
- import { assertAllDefined, makeTracer } from '@agoric/internal';
2
+ import { makeTracer } from '@agoric/internal';
3
3
  import { observeIteration, subscribeEach } from '@agoric/notifier';
4
4
  import {
5
5
  CosmosChainInfoShape,
@@ -126,7 +126,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
126
126
  });
127
127
 
128
128
  const makeFeedKit = prepareTransactionFeedKit(zone, zcf);
129
- assertAllDefined({ makeFeedKit, makeAdvancer, makeSettler, statusManager });
130
129
 
131
130
  const makeLiquidityPoolKit = prepareLiquidityPoolKit(
132
131
  zone,
@@ -147,6 +146,20 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
147
146
  async makeOperatorInvitation(operatorId) {
148
147
  return feedKit.creator.makeOperatorInvitation(operatorId);
149
148
  },
149
+ async connectToNoble() {
150
+ return vowTools.when(nobleAccountV, nobleAccount => {
151
+ trace('nobleAccount', nobleAccount);
152
+ return vowTools.when(
153
+ E(nobleAccount).getAddress(),
154
+ intermediateRecipient => {
155
+ trace('intermediateRecipient', intermediateRecipient);
156
+ advancer.setIntermediateRecipient(intermediateRecipient);
157
+ settlerKit.creator.setIntermediateRecipient(intermediateRecipient);
158
+ return intermediateRecipient;
159
+ },
160
+ );
161
+ });
162
+ },
150
163
  });
151
164
 
152
165
  const publicFacet = zone.exo('Fast USDC Public', undefined, {
@@ -214,7 +227,9 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
214
227
  privateArgs.assetInfo,
215
228
  );
216
229
  }
230
+
217
231
  const nobleAccountV = zone.makeOnce('NobleAccount', () => makeNobleAccount());
232
+
218
233
  const feedKit = zone.makeOnce('Feed Kit', () => makeFeedKit());
219
234
 
220
235
  const poolAccountV = zone.makeOnce('PoolAccount', () => makeLocalAccount());
@@ -222,18 +237,12 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
222
237
  makeLocalAccount(),
223
238
  );
224
239
  // when() is OK here since this clearly resolves promptly.
225
- /** @type {[HostInterface<OrchestrationAccount<{chainId: 'noble-1';}>>, HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>, HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>]} */
226
- const [nobleAccount, poolAccount, settlementAccount] = await vowTools.when(
227
- vowTools.all([nobleAccountV, poolAccountV, settleAccountV]),
240
+ /** @type {[HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>, HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>]} */
241
+ const [poolAccount, settlementAccount] = await vowTools.when(
242
+ vowTools.all([poolAccountV, settleAccountV]),
228
243
  );
229
244
  trace('settlementAccount', settlementAccount);
230
245
  trace('poolAccount', poolAccount);
231
- trace('nobleAccount', nobleAccount);
232
-
233
- const intermediateRecipient = await vowTools.when(
234
- E(nobleAccount).getAddress(),
235
- );
236
- trace('intermediateRecipient', intermediateRecipient);
237
246
 
238
247
  const [_agoric, _noble, agToNoble] = await vowTools.when(
239
248
  chainHub.getChainsAndConnection('agoric', 'noble'),
@@ -243,7 +252,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
243
252
  sourceChannel: agToNoble.transferChannel.counterPartyChannelId,
244
253
  remoteDenom: 'uusdc',
245
254
  settlementAccount,
246
- intermediateRecipient,
247
255
  });
248
256
 
249
257
  const advancer = zone.makeOnce('Advancer', () =>
@@ -251,7 +259,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
251
259
  borrowerFacet: poolKit.borrower,
252
260
  notifyFacet: settlerKit.notify,
253
261
  poolAccount,
254
- intermediateRecipient,
255
262
  }),
256
263
  );
257
264
  // Connect evidence stream to advancer
@@ -147,12 +147,11 @@ export const startFastUSDC = async (
147
147
  USDC: await E(USDCissuer).getBrand(),
148
148
  });
149
149
 
150
- const { terms, oracles, feeConfig, feedPolicy, chainInfo, assetInfo } =
151
- fromExternalConfig(
152
- config?.options, // just in case config is missing somehow
153
- brands,
154
- FastUSDCConfigShape,
155
- );
150
+ const { terms, oracles, feeConfig, feedPolicy, ...net } = fromExternalConfig(
151
+ config.options,
152
+ brands,
153
+ FastUSDCConfigShape,
154
+ );
156
155
  trace('using terms', terms);
157
156
  trace('using fee config', feeConfig);
158
157
 
@@ -186,8 +185,8 @@ export const startFastUSDC = async (
186
185
  storageNode,
187
186
  timerService,
188
187
  marshaller,
189
- chainInfo,
190
- assetInfo,
188
+ chainInfo: net.chainInfo,
189
+ assetInfo: net.assetInfo,
191
190
  }),
192
191
  );
193
192
 
@@ -224,6 +223,11 @@ export const startFastUSDC = async (
224
223
 
225
224
  produceInstance.reset();
226
225
  produceInstance.resolve(instance);
226
+
227
+ if (!net.noNoble) {
228
+ const addr = await E(kit.creatorFacet).connectToNoble();
229
+ trace('noble intermediate recipient', addr);
230
+ }
227
231
  trace('startFastUSDC done', instance);
228
232
  };
229
233
  harden(startFastUSDC);
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@ import type {
6
6
  } from '@agoric/orchestration';
7
7
  import type { IBCChannelID } from '@agoric/vats';
8
8
  import type { Amount } from '@agoric/ertp';
9
- import type { Passable } from '@endo/pass-style';
9
+ import type { CopyRecord, Passable } from '@endo/pass-style';
10
10
  import type { PendingTxStatus } from './constants.js';
11
11
  import type { FastUsdcTerms } from './fast-usdc.contract.js';
12
12
 
@@ -78,14 +78,15 @@ export interface FeedPolicy {
78
78
  eventFilter?: string;
79
79
  }
80
80
 
81
- export type FastUSDCConfig = Passable & {
81
+ export type FastUSDCConfig = {
82
82
  terms: FastUsdcTerms;
83
83
  oracles: Record<string, string>;
84
84
  feeConfig: FeeConfig;
85
85
  feedPolicy: FeedPolicy & Passable;
86
+ noNoble: boolean; // support a3p-integration, which has no noble chain
86
87
  chainInfo: Record<string, CosmosChainInfo & Passable>;
87
88
  assetInfo: [Denom, DenomDetail & { brandKey?: string }][];
88
- };
89
+ } & CopyRecord;
89
90
 
90
91
  export type * from './constants.js';
91
92
  export type { LiquidityPoolKit } from './exos/liquidity-pool.js';
@@ -35,6 +35,11 @@ export const defaultAssetInfo = [
35
35
  },
36
36
  ],
37
37
  ];
38
+ harden(defaultAssetInfo);
39
+
40
+ const agoricAssetInfo = defaultAssetInfo.filter(
41
+ ([_d, i]) => i.chainName === 'agoric',
42
+ );
38
43
 
39
44
  /**
40
45
  * @type {Record<string, Pick<FastUSDCConfig, 'oracles' | 'feedPolicy' | 'chainInfo' | 'assetInfo' >>}
@@ -43,6 +48,11 @@ export const defaultAssetInfo = [
43
48
  * meanwhile, use price oracle addresses (from updatePriceFeeds.js).
44
49
  */
45
50
  export const configurations = {
51
+ /**
52
+ * NOTE: The a3p-integration runtime does _not_ include
53
+ * a noble chain; this limits functionality to advancing
54
+ * to the Agoric chain.
55
+ */
46
56
  A3P_INTEGRATION: {
47
57
  oracles: {
48
58
  gov1: 'agoric1ee9hr0jyrxhy999y755mp862ljgycmwyp4pl7q',
@@ -50,7 +60,7 @@ export const configurations = {
50
60
  gov3: 'agoric1ydzxwh6f893jvpaslmaz6l8j2ulup9a7x8qvvq',
51
61
  },
52
62
  feedPolicy: {
53
- nobleAgoricChannelId: 'TODO',
63
+ nobleAgoricChannelId: 'channel-does-not-exist',
54
64
  nobleDomainId: 4,
55
65
  chainPolicies: {
56
66
  Arbitrum: {
@@ -63,9 +73,13 @@ export const configurations = {
63
73
  },
64
74
  },
65
75
  chainInfo: /** @type {Record<string, CosmosChainInfo & Passable>} */ (
66
- withChainCapabilities(fetchedChainInfo)
76
+ withChainCapabilities({
77
+ agoric: fetchedChainInfo.agoric,
78
+ // registering USDC-on-agoric requires registering the noble chain
79
+ noble: fetchedChainInfo.noble,
80
+ })
67
81
  ),
68
- assetInfo: defaultAssetInfo,
82
+ assetInfo: agoricAssetInfo,
69
83
  },
70
84
  MAINNET: {
71
85
  oracles: {
@@ -139,3 +153,4 @@ export const configurations = {
139
153
  assetInfo: defaultAssetInfo, // TODO: use emerynet values
140
154
  },
141
155
  };
156
+ harden(configurations);