@agoric/fast-usdc 0.1.1-other-dev-3eb1a1d.0 → 0.1.1-other-dev-d15096d.0.d15096d

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/README.md CHANGED
@@ -1,58 +1,184 @@
1
1
  # Fast USDC
2
2
 
3
- Development package for the Fast USDC product.
4
- Here in agoric-sdk as a convenience for integration testing and iterating on the SDK affordances required for the product.
3
+ Development package for the Fast USDC product. Here in agoric-sdk as a
4
+ convenience for integration testing and iterating on the SDK affordances
5
+ required for the product.
5
6
 
6
7
  # Factoring
7
8
 
8
- This package is meant to contain all the code for the Fast USDC product. However there are some constraints:
9
+ This package is meant to contain all the code for the Fast USDC product.
10
+ However, there are some constraints:
9
11
 
10
- - a3p integration tests are in the `a3p-integration` top-level package, separate from this workspace
11
- - the proposal builders are in `@agoric/builders` to work with the a3p-integration `build:submissions` script
12
- - the RunUtils tests are in `@agoric/boot` to test running them atop a fresh bootstrapped environment
12
+ - a3p integration tests are in the `a3p-integration` top-level package, separate
13
+ from this workspace
14
+ - the proposal builders are in `@agoric/builders` to work with the
15
+ a3p-integration `build:submissions` script
16
+ - the RunUtils tests are in `@aglocal/boot` to test running them atop a fresh
17
+ bootstrapped environment
13
18
 
14
19
  Over time we can update our tooling to decouple this more from the `packages` directory.
15
20
 
16
- 1. Make a3p-integration `build:submissions` script work with arbitrary builder paths, allowing this to be above `@agoric/builders` in the package graph
17
- 2. Export bootstrap testing utilities from `@agoric/boot`, allowing this to be above `@agoric/boot` in the package graph
18
- 3. Update CI to support packages that aren't under `packages/`, eg. a top-level `dapps` directory
21
+ 1. Make a3p-integration `build:submissions` script work with arbitrary builder
22
+ paths, allowing this to be above `@agoric/builders` in the package graph
23
+ 2. Export bootstrap testing utilities from `@aglocal/boot`, allowing this to be
24
+ above `@aglocal/boot` in the package graph
25
+ 3. Update CI to support packages that aren't under `packages/`, eg. a top-level
26
+ `dapps` directory. `multichain-testing` does this now but not organized per contract.
19
27
  4. Move this package out of agoric-sdk
20
28
 
21
- # Transaction feed
29
+ # Funds flow
22
30
 
23
- ## Oracles interface
24
-
25
- Oracles run off-chain and interact with the contract via an Agoric smart wallet bridge.
26
31
  ```mermaid
27
32
  sequenceDiagram
28
- title Becoming an oracle operator
29
- participant OW as Operator N<br/>Smart Wallet
30
- participant FUC as Fast USDC<br/>Contract Exo
31
- participant CE as Core Eval
33
+ actor User as User
34
+ participant NEA as User Wallet<br>[Browser]
35
+ participant ETH as CCTP Contract<br>[Ethereum]
36
+ participant NFA as Noble Forwarding Account<br/>[Noble]
37
+ participant NC as Noble Chain<br/>[Noble]
38
+ participant NAR as Noble-Agoric<br/>[IBC Relayer]
39
+ participant SA as Settlement Account<br/>[Agoric]
40
+ participant CFA as Contract Fee Account<br/>[Agoric]
41
+ participant DAR as Destination-Agoric<br/>[IBC Relayer]
42
+ participant EUD as End User Destination<br/>[Dest Chain]
43
+
44
+ autonumber
45
+ rect rgb(240, 248, 255)
46
+ User ->> NEA: Sign transaction<br/>(MintAmount, to NFA)
47
+ NEA ->> ETH: Submit USDC Burn Txn via CCTP
48
+ end
49
+ rect rgb(200, 255, 230)
50
+ FUC ->> P: Initiate PFM transfer(AdvanceAmount, EUD) from pool<br/>of Noble-Agoric tokens to EUD Chain
51
+ P ->> NC: PFM transfer(AdvanceAmount of Agoric USDC denom) to EUD
52
+ NC ->> EUD: deliver AdvanceAmount as final USDC denom
53
+ end
54
+ Note over User, EUD: User got their AdvanceAmountof IBC USDC<br/>UX COMPLETE
55
+ rect rgb(255, 200, 200)
56
+ Note over ETH, SA: Minting Process
57
+ Note over ETH: ~12 minutes for Ethereum finality
58
+ Note over NC: 1-6 minutes for CCTP<br/>to Mint on Noble
59
+ NC ->> NFA: Noble CCTP contract mints USDC<br/> into Noble Forwarding Address
60
+ NFA ->> NAR: Broadcast Forward MintAmount (as Agoric USDC Denom) to FU Account
61
+ NAR ->> SA: Relay
62
+ end
63
+ rect rgb(255, 245, 230)
64
+ Note over FUC, CFA: Settlement Process
65
+ alt Advance was started:
66
+ FUC ->> SA: Initiate transfers out of settlement
67
+ SA ->> P: Deposit the AdvanceAmount + PoolFee (= MintAmount - ContractFee)
68
+ SA ->> CFA: Deposit ContractFee
69
+ else Advance for matched transaction that has not yet started:
70
+ P ->> NC: PFM transfer(MintAmount of Agoric USDC denom) to EUD
71
+ NC ->> EUD: deliver MintAmount as final USDC denom
72
+ else Settlement for unknown transaction:
73
+ Note over SA: Leave funds in SettlementAccount.
74
+ Note over SA: Wait for observation from watcher
75
+ end
76
+ end
77
+ ```
32
78
 
33
- CE->>FUC: makeOperatorInvitation()
34
- FUC-->>CE: operatorInvitation
35
- CE->>+OW: deposit(operatorInvitation)
79
+ Not pictured:
80
+ - Circle Attestation Service
81
+ - CCTP Relayer
36
82
 
37
- Note left of FUC: Off-chain wallet accepts the operator invitation
83
+ "Noble Forwarding Account" is also owned by the CCTP Relayer as they actually register it
84
+ CCTP Relayer can be many parties, but only one when caller is specified
38
85
 
39
- OW->>+FUC: offer(operatorInvitation)
40
- FUC-->>OW: operator invitationMakers: {SubmitEvidence}
41
86
 
42
- Note left of FUC: Off-chain watcher detects evidence
43
- OW->>+FUC: offer(SubmitEvidence, evidence)
44
- ```
87
+ # Transaction flow
45
88
 
46
89
  ```mermaid
90
+ %%{init: {
91
+ 'theme': 'base',
92
+ 'themeVariables': {
93
+ 'primaryColor': '#f0f8ff',
94
+ 'primaryTextColor': '#2c3e50',
95
+ 'primaryBorderColor': '#7fb2e6',
96
+ 'lineColor': '#7fb2e6',
97
+ 'secondaryColor': '#f6f8fa',
98
+ 'tertiaryColor': '#fff5e6'
99
+ }
100
+ }}%%
47
101
  sequenceDiagram
48
- title Receiving evidence
49
- participant W as Operator N<br/>Smart Wallet
50
- participant A as Operator N<br/>Admin Oexo
51
- participant TF as Transaction<br/>Feed
52
-
53
- W->>A: offer(SubmitEvidence, evidence)
54
-
55
- Note left of A: Once 3 operators push the same…
56
-
57
- A->>TF: notify(evidence)
102
+ title Fast USDC Transaction Process
103
+ autonumber
104
+ actor User
105
+ %% [Where it runs]
106
+ participant NEA as Noble Express app<br/>[Browser]
107
+ participant ETH as CCTP Contract<br/>[Ethereum]
108
+ participant NFA as Noble Forwarding Account<br/>[Noble]
109
+ participant NC as Noble Chain<br/>[Noble]
110
+ participant NAR as Noble-Agoric<br/>[Relayer]
111
+ participant OCW as Eth Watcher<br/>[Off-chain]
112
+ participant FUC as Fast USDC Contract<br/>[Agoric]
113
+ participant P as Pool<br/>[Agoric]
114
+ participant SA as Settlement Account<br/>[Agoric]
115
+ participant CFA as Contract Fee Account<br/>[Agoric]
116
+ participant DAR as Destination-Agoric<br/>[Relayer]
117
+ participant EUD as End User Destination<br/>[User]
118
+
119
+ %% Notation: --> for async, ->> for sync
120
+ rect rgb(240, 248, 255)
121
+ Note over User,OCW: User request
122
+ Note over NEA: App looks up fees and SettlementAccount address
123
+ User->>NEA: Input desired MintAmount and EUD
124
+ NEA->>User: Display fees and AdvanceAmount
125
+ Note over NEA: Calculate VirtualRecipient from (SettlementAccount, EUD)
126
+ Note over NEA: Calculate NFA address from (VirtualRecipient) using Signerless forwarding
127
+ %% Getting from here to the burn is mostly up to Noble
128
+ User->>NEA: Initiate transfer
129
+ NEA-->>NC: Register NFA
130
+ NEA->>User: Request signature
131
+ User->>NEA: Sign transaction<br/>(MintAmount, to NFA)
132
+ NEA->>ETH: Submit USDC Burn Txn via CCTP
133
+ Note over ETH: Burn succeeds,<br/>implying mint to NFA will happen
134
+ OCW->>ETH: Query CCTP transactions to Noble
135
+ ETH-->>OCW: 1 block confirmed
136
+ OCW->>NC: Look up recipient of NFA<br/>by account query
137
+ NC->>OCW: RPC replies with account including `recipient` (LCA+EUD)
138
+ end
139
+
140
+ Note over OCW: Continue if recipient is over the Noble-Agoric channel
141
+ rect rgb(200, 255, 230)
142
+ Note over NC,EUD: Advancement Process
143
+ Note over OCW: Log proof of each confirmation
144
+ Note over OCW,FUC: Provide info needed by policy to make a decision
145
+ OCW->>FUC: Notify of each confirmation<br/>(dest=agoric1 recipient, amount,<br/>metadata=transaction-nonce,chain,block,timestamp)
146
+ Note over FUC: MM's policy decides whether to advance (e.g. 2 confirmations from Ethereum, 5 from Polygon)
147
+ Note over FUC: Syslog with sufficient detail to debug
148
+ Note over FUC: calculate AdvanceAmount = (MintAmount – PoolFee - ContractFee)<br/>based on fee rates at this moment, and record for future lookup
149
+ FUC->>P: Initiate PFM transfer(AdvanceAmount, EUD) from pool<br/>of Noble-Agoric tokens to EUD Chain
150
+ P->>NC: PFM transfer(AdvanceAmount of Agoric USDC denom) to EUD
151
+ NC->>EUD: deliver AdvanceAmount as final USDC denom
152
+ %% TODO do need epsilon tolerance on MintAmount for if Noble takes a small cut of the minted amount
153
+ %% TODO map out the event handling for these states: START: only-observed,advance-started,received-minted-unobserved, END: done
154
+ Note over SA: Wake up the settlement process to handle observed (key=EUD,MintAmount)
155
+
156
+ end
157
+ Note over User,EUD: User got their AdvanceAmountof IBC USDC<br/>UX COMPLETE
158
+
159
+ rect rgb(255, 200, 200)
160
+ Note over ETH,SA: Minting Process
161
+ Note over ETH: ~12 minutes for Ethereum finality
162
+ Note over NC: 1-6 minutes for CCTP<br/>to Mint on Noble
163
+ NC->>NFA: Noble CCTP contract mints USDC<br/> into Noble Forwarding Address
164
+ NFA->>SA: Forward MintAmount (as Agoric USDC Denom) to FU Account
165
+ end
166
+
167
+ rect rgb(255, 245, 230)
168
+ Note over FUC,CFA: Settlement Process
169
+ Note over FUC,SA: Tap on account reads MintAmount,<br/>parses EUD from virtual address recipient<br/>and looks up AdvanceAmount,PoolFee,ContractFee.<br/>Matches against an unsettled transaction (by EUD and approx amount).
170
+ %% Treat starting the advance as an atomic action. Assume it will complete once started.
171
+ alt Advance was started:
172
+ FUC->>SA: Initiate transfers out of settlement
173
+ SA->>P: Deposit the AdvanceAmount + PoolFee (= MintAmount - ContractFee)
174
+ SA->>CFA: Deposit ContractFee
175
+ else Advance for matched transaction that has not yet started:
176
+ P->>NC: PFM transfer(MintAmount of Agoric USDC denom) to EUD
177
+ NC->>EUD: deliver MintAmount as final USDC denom
178
+ else Settlement for unknown transaction:
179
+ %% Have not received notification of this Amount,EUD from the watcher
180
+ Note over SA: Leave funds in SettlementAccount.
181
+ Note over SA: Wait for observation from watcher
182
+ end
183
+ end
58
184
  ```
package/package.json CHANGED
@@ -1,57 +1,52 @@
1
1
  {
2
2
  "name": "@agoric/fast-usdc",
3
- "version": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
3
+ "version": "0.1.1-other-dev-d15096d.0.d15096d",
4
4
  "description": "CLI and library for Fast USDC product",
5
5
  "type": "module",
6
6
  "files": [
7
- "contract",
8
- "src"
7
+ "src",
8
+ "tools"
9
9
  ],
10
- "bin": {
11
- "fast-usdc": "./src/cli/bin.js"
12
- },
10
+ "main": "src/main.js",
11
+ "bin": "./src/cli/bin.js",
13
12
  "scripts": {
14
13
  "build": "exit 0",
15
14
  "test": "ava",
16
- "test:c8": "c8 --all $C8_OPTIONS ava",
15
+ "test:c8": "c8 --all ${C8_OPTIONS:-} ava",
17
16
  "test:xs": "exit 0",
18
17
  "lint-fix": "yarn lint:eslint --fix",
19
- "lint": "run-s --continue-on-error lint:*",
20
- "lint:types": "tsc",
21
- "lint:eslint": "eslint ."
18
+ "lint": "yarn run -T run-s --continue-on-error 'lint:*'",
19
+ "lint:eslint": "yarn run -T eslint .",
20
+ "lint:types": "yarn run -T tsc"
22
21
  },
23
22
  "devDependencies": {
24
- "@agoric/swingset-liveslots": "0.10.3-other-dev-3eb1a1d.0+3eb1a1d",
25
- "@agoric/vats": "0.15.2-other-dev-3eb1a1d.0+3eb1a1d",
26
- "@agoric/zone": "0.2.3-other-dev-3eb1a1d.0+3eb1a1d",
27
23
  "@fast-check/ava": "^2.0.1",
28
24
  "ava": "^5.3.0",
29
- "c8": "^10.1.2",
30
- "execa": "9.1.0",
31
- "ts-blank-space": "^0.4.1"
25
+ "c8": "^10.1.3",
26
+ "nano-spawn": "^1.0.2",
27
+ "ts-blank-space": "^0.6.2"
32
28
  },
33
29
  "dependencies": {
34
- "@agoric/client-utils": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
35
- "@agoric/ertp": "0.16.3-other-dev-3eb1a1d.0+3eb1a1d",
36
- "@agoric/internal": "0.3.3-other-dev-3eb1a1d.0+3eb1a1d",
37
- "@agoric/notifier": "0.6.3-other-dev-3eb1a1d.0+3eb1a1d",
38
- "@agoric/orchestration": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
39
- "@agoric/store": "0.9.3-other-dev-3eb1a1d.0+3eb1a1d",
40
- "@agoric/vat-data": "0.5.3-other-dev-3eb1a1d.0+3eb1a1d",
41
- "@agoric/vow": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
42
- "@agoric/zoe": "0.26.3-other-dev-3eb1a1d.0+3eb1a1d",
43
- "@cosmjs/proto-signing": "^0.32.4",
44
- "@cosmjs/stargate": "^0.32.4",
45
- "@endo/base64": "^1.0.9",
46
- "@endo/common": "^1.2.8",
47
- "@endo/errors": "^1.2.8",
48
- "@endo/eventual-send": "^1.2.8",
49
- "@endo/far": "^1.1.9",
50
- "@endo/init": "^1.1.7",
51
- "@endo/marshal": "^1.6.2",
52
- "@endo/pass-style": "^1.4.7",
53
- "@endo/patterns": "^1.4.7",
54
- "@endo/promise-kit": "^1.1.8",
30
+ "@agoric/client-utils": "0.1.1-other-dev-d15096d.0.d15096d",
31
+ "@agoric/cosmic-proto": "0.4.1-other-dev-d15096d.0.d15096d",
32
+ "@agoric/ertp": "0.16.3-other-dev-d15096d.0.d15096d",
33
+ "@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
34
+ "@agoric/notifier": "0.6.3-other-dev-d15096d.0.d15096d",
35
+ "@agoric/orchestration": "0.1.1-other-dev-d15096d.0.d15096d",
36
+ "@agoric/zoe": "0.26.3-other-dev-d15096d.0.d15096d",
37
+ "@cosmjs/proto-signing": "^0.36.0",
38
+ "@cosmjs/stargate": "^0.36.0",
39
+ "@endo/base64": "^1.0.12",
40
+ "@endo/common": "^1.2.13",
41
+ "@endo/errors": "^1.2.13",
42
+ "@endo/eventual-send": "^1.3.4",
43
+ "@endo/far": "^1.1.14",
44
+ "@endo/init": "^1.1.12",
45
+ "@endo/marshal": "^1.8.0",
46
+ "@endo/nat": "^5.1.3",
47
+ "@endo/pass-style": "^1.6.3",
48
+ "@endo/patterns": "^1.7.0",
49
+ "@endo/promise-kit": "^1.1.13",
55
50
  "@nick134-bit/noblejs": "0.0.2",
56
51
  "bech32": "^2.0.0",
57
52
  "commander": "^12.1.0",
@@ -78,5 +73,11 @@
78
73
  "publishConfig": {
79
74
  "access": "public"
80
75
  },
81
- "gitHead": "3eb1a1d2d75b2b4a94807cd3bf759bc9fc531f05"
76
+ "typeCoverage": {
77
+ "atLeast": 97.08
78
+ },
79
+ "engines": {
80
+ "node": "^20.9 || ^22.11"
81
+ },
82
+ "gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
82
83
  }
@@ -0,0 +1,41 @@
1
+ import { boardSlottingMarshaller } from '@agoric/client-utils';
2
+
3
+ /**
4
+ * @import {BridgeAction} from '@agoric/smart-wallet/src/smartWallet.js';
5
+ * @import {Writable} from 'stream';
6
+ */
7
+
8
+ const defaultMarshaller = boardSlottingMarshaller();
9
+
10
+ /** @typedef {ReturnType<typeof boardSlottingMarshaller>} BoardSlottingMarshaller */
11
+
12
+ /**
13
+ * @param {BridgeAction} bridgeAction
14
+ * @param {Pick<Writable,'write'>} stdout
15
+ * @param {BoardSlottingMarshaller} marshaller
16
+ */
17
+ const outputAction = (bridgeAction, stdout, marshaller) => {
18
+ const capData = marshaller.toCapData(harden(bridgeAction));
19
+ stdout.write(JSON.stringify(capData));
20
+ stdout.write('\n');
21
+ };
22
+
23
+ export const sendHint =
24
+ 'Now use `agoric wallet send ...` to sign and broadcast the offer.\n';
25
+
26
+ /**
27
+ * @param {BridgeAction} bridgeAction
28
+ * @param {{
29
+ * stdout: Pick<Writable,'write'>,
30
+ * stderr: Pick<Writable,'write'>,
31
+ * }} io
32
+ * @param {BoardSlottingMarshaller | undefined} marshaller
33
+ */
34
+ export const outputActionAndHint = (
35
+ bridgeAction,
36
+ { stdout, stderr },
37
+ marshaller = defaultMarshaller,
38
+ ) => {
39
+ outputAction(bridgeAction, stdout, marshaller);
40
+ stderr.write(sendHint);
41
+ };
package/src/cli/cli.js CHANGED
@@ -1,9 +1,6 @@
1
- import { assertParsableNumber } from '@agoric/zoe/src/contractSupport/ratio.js';
2
- import {
3
- Command,
4
- InvalidArgumentError,
5
- InvalidOptionArgumentError,
6
- } from 'commander';
1
+ /* eslint-env node */
2
+ /* global globalThis */
3
+ import { Command } from 'commander';
7
4
  import { existsSync, mkdirSync, readFileSync } from 'fs';
8
5
  import { fileURLToPath } from 'url';
9
6
  import { dirname, resolve } from 'path';
@@ -12,9 +9,12 @@ import {
12
9
  readFile as readAsync,
13
10
  writeFile as writeAsync,
14
11
  } from 'node:fs/promises';
15
- import configLib from './config.js';
16
- import transferLib from './transfer.js';
17
- import { makeFile } from '../util/file.js';
12
+ import { addConfigCommands } from './config-commands.js';
13
+ import { addOperatorCommands } from './operator-commands.js';
14
+ import * as configLib from './config.js';
15
+ import * as transferLib from './transfer.js';
16
+ import { makeFile } from './util/file.js';
17
+ import { addLPCommands } from './lp-commands.js';
18
18
 
19
19
  const packageJson = JSON.parse(
20
20
  readFileSync(
@@ -32,6 +32,11 @@ export const initProgram = (
32
32
  writeFile = writeAsync,
33
33
  mkdir = mkdirSync,
34
34
  exists = existsSync,
35
+ fetch = globalThis.fetch,
36
+ stdout = process.stdout,
37
+ stderr = process.stderr,
38
+ env = process.env,
39
+ now = () => Date.now(),
35
40
  ) => {
36
41
  const program = new Command();
37
42
 
@@ -45,153 +50,36 @@ export const initProgram = (
45
50
  `${defaultHome}/.fast-usdc/`,
46
51
  );
47
52
 
48
- const config = program.command('config').description('Manage config');
49
-
50
- const configFilename = 'config.json';
51
- const getConfigPath = () => {
52
- const { home: configDir } = program.opts();
53
- return configDir + configFilename;
54
- };
55
-
56
- const makeConfigFile = () =>
57
- makeFile(getConfigPath(), readFile, writeFile, mkdir, exists);
58
-
59
- config
60
- .command('show')
61
- .description('Show current config')
62
- .action(async () => {
63
- await configHelpers.show(makeConfigFile());
64
- });
65
-
66
- config
67
- .command('init')
68
- .description('Set initial config values')
69
- .requiredOption(
70
- '--noble-seed <seed>',
71
- 'Seed phrase for Noble account. CAUTION: Stored unencrypted in file system',
72
- )
73
- .requiredOption(
74
- '--eth-seed <seed>',
75
- 'Seed phrase for Ethereum account. CAUTION: Stored unencrypted in file system',
76
- )
77
- .requiredOption(
78
- '--agoric-seed <seed>',
79
- 'Seed phrase for Agoric LP account. CAUTION: Stored unencrypted in file system',
80
- )
81
- .option(
82
- '--agoric-rpc [url]',
83
- 'Agoric RPC endpoint',
84
- 'http://127.0.0.1:26656',
85
- )
86
- .option(
87
- '--agoric-api [url]',
88
- 'Agoric RPC endpoint',
89
- 'http://127.0.0.1:1317',
90
- )
91
- .option('--noble-rpc [url]', 'Noble RPC endpoint', 'http://127.0.0.1:26657')
92
- .option('--noble-api [url]', 'Noble API endpoint', 'http://127.0.0.1:1318')
93
- .option('--eth-rpc [url]', 'Ethereum RPC Endpoint', 'http://127.0.0.1:8545')
94
- .option(
95
- '--noble-to-agoric-channel [channel]',
96
- 'Channel ID on Noble for Agoric',
97
- 'channel-21',
98
- )
99
- .option(
100
- '--token-messenger-address [address]',
101
- 'Address of TokenMessenger contract',
102
- // Default to ETH mainnet contract address. For ETH sepolia, use 0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5
103
- '0xbd3fa81b58ba92a82136038b25adec7066af3155',
104
- )
105
- .option(
106
- '--token-contract-address [address]',
107
- 'Address of USDC token contract',
108
- // Detault to ETH mainnet token address. For ETH sepolia, use 0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238
109
- '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
110
- )
111
- .action(async options => {
112
- await configHelpers.init(makeConfigFile(), options);
113
- });
114
-
115
- config
116
- .command('update')
117
- .description('Update config values')
118
- .option(
119
- '--noble-seed [string]',
120
- 'Seed phrase for Noble account. CAUTION: Stored unencrypted in file system',
121
- )
122
- .option(
123
- '--eth-seed [string]',
124
- 'Seed phrase for Ethereum account. CAUTION: Stored unencrypted in file system',
125
- )
126
- .option(
127
- '--agoric-seed <seed>',
128
- 'Seed phrase for Agoric LP account. CAUTION: Stored unencrypted in file system',
129
- )
130
- .option('--agoric-rpc [url]', 'Agoric RPC endpoint')
131
- .option('--agoric-api [url]', 'Agoric API endpoint')
132
- .option('--noble-rpc [url]', 'Noble RPC endpoint')
133
- .option('--noble-api [url]', 'Noble API endpoint')
134
- .option('--eth-rpc [url]', 'Ethereum RPC Endpoint')
135
- .option(
136
- '--noble-to-agoric-channel [channel]',
137
- 'Channel ID on Noble for Agoric',
138
- )
139
- .option(
140
- '--token-messenger-address [address]',
141
- 'Address of TokenMessenger contract',
142
- )
143
- .option(
144
- '--token-contract-address [address]',
145
- 'Address of USDC token contract',
146
- )
147
- .action(async options => {
148
- await configHelpers.update(makeConfigFile(), options);
149
- });
150
-
151
- /** @param {string} value */
152
- const parseDecimal = value => {
153
- try {
154
- assertParsableNumber(value);
155
- } catch {
156
- throw new InvalidArgumentError('Not a decimal number.');
157
- }
158
- return value;
159
- };
160
-
161
- /**
162
- * @param {string} str
163
- * @returns {'auto' | number}
164
- */
165
- const parseFee = str => {
166
- if (str === 'auto') return 'auto';
167
- const num = parseFloat(str);
168
- if (Number.isNaN(num)) {
169
- throw new InvalidOptionArgumentError('Fee must be a number.');
170
- }
171
- return num;
53
+ const makeConfigFile = () => {
54
+ const getConfigPath = () => {
55
+ const { home: configDir } = program.opts();
56
+ return `${configDir}config.json`;
57
+ };
58
+ return makeFile(getConfigPath(), readFile, writeFile, mkdir, exists);
172
59
  };
173
60
 
174
- program
175
- .command('deposit')
176
- .description('Offer assets to the liquidity pool')
177
- .argument('<give>', 'USDC to give', parseDecimal)
178
- .option('--id [offer-id]', 'Offer ID')
179
- .option('--fee [fee]', 'Cosmos fee', parseFee)
180
- .action(() => {
181
- console.error('TODO actually send deposit');
182
- // TODO: Implement deposit logic
183
- });
184
-
185
- program
186
- .command('withdraw')
187
- .description('Withdraw assets from the liquidity pool')
188
- .argument('<want>', 'USDC to withdraw', parseDecimal)
189
- .option('--id [offer-id]', 'Offer ID')
190
- .option('--fee [fee]', 'Cosmos fee', parseFee)
191
- .action(() => {
192
- console.error('TODO actually send withdrawal');
193
- // TODO: Implement withdraw logic
194
- });
61
+ program.addHelpText(
62
+ 'afterAll',
63
+ `
64
+ Agoric test networks provide configuration info at, for example,
65
+
66
+ https://devnet.agoric.net/network-config
67
+
68
+ To use RPC endpoints from such a configuration, use:
69
+ export AGORIC_NET=devnet
70
+
71
+ Use AGORIC_NET=local or leave it unset to use localhost and chain id agoriclocal.
72
+ `,
73
+ );
74
+ addConfigCommands(program, configHelpers, makeConfigFile);
75
+ addOperatorCommands(program, {
76
+ fetch,
77
+ stdout,
78
+ stderr,
79
+ env,
80
+ now,
81
+ });
82
+ addLPCommands(program, { fetch, stdout, stderr, env, now });
195
83
 
196
84
  program
197
85
  .command('transfer')
@@ -203,7 +91,12 @@ export const initProgram = (
203
91
  /** @type {string} */ amount,
204
92
  /** @type {string} */ destination,
205
93
  ) => {
94
+ const start = now();
206
95
  await transferHelpers.transfer(makeConfigFile(), amount, destination);
96
+ const duration = now() - start;
97
+ stdout.write(
98
+ `Transfer finished in ${(duration / 1000).toFixed(1)} seconds`,
99
+ );
207
100
  },
208
101
  );
209
102