@parallel-protocol/cli 0.1.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 (3) hide show
  1. package/README.md +431 -0
  2. package/dist/index.js +14269 -0
  3. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,431 @@
1
+ # @parallel-protocol/cli
2
+
3
+ Command-line interface for the [Parallel Protocol](https://parallel.best/) — query live on-chain data, build and sign transactions, and interact with the x402 payment layer directly from your terminal.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Install globally
11
+ npm install -g @parallel-protocol/cli
12
+
13
+ # Or run without installing
14
+ npx @parallel-protocol/cli <command>
15
+ ```
16
+
17
+ **Requirements:** Node.js ≥ 18
18
+
19
+ ---
20
+
21
+ ## Quick start
22
+
23
+ ```bash
24
+ # 1. Configure (interactive wizard — runs once)
25
+ parallel config init
26
+
27
+ # 2. Explore
28
+ parallel protocol overview
29
+ parallel protocol tvl --chain base
30
+ parallel protocol savings-rate
31
+
32
+ # 3. Build a transaction (dry-run — no wallet needed)
33
+ parallel swap quote --op mint --collateral USDC --amount 1000 --chain avalanche
34
+ parallel swap mint --collateral USDC --amount 1000 --chain avalanche --dry-run
35
+ ```
36
+
37
+ > **Development (from the parallel-mcp repo):**
38
+ > ```bash
39
+ > npm run build:cli # build once
40
+ > alias parallel="node packages/cli/dist/index.js"
41
+ > parallel protocol overview
42
+ > ```
43
+
44
+ ---
45
+
46
+ ## Configuration
47
+
48
+ ### `parallel config init`
49
+
50
+ Interactive wizard that creates `~/.parallel/config.toml`:
51
+
52
+ ```toml
53
+ [network]
54
+ default_chain = "base"
55
+
56
+ [wallet]
57
+ keystore_path = "~/.parallel/keystore.json"
58
+
59
+ [display]
60
+ default_format = "table" # table | json
61
+ ```
62
+
63
+ ### `parallel config get / set`
64
+
65
+ ```bash
66
+ parallel config get network.default_chain # → base
67
+ parallel config set network.default_chain ethereum
68
+ ```
69
+
70
+ ### Creating a keystore
71
+
72
+ > **Always use a dedicated wallet for testing — never your main wallet.**
73
+
74
+ The CLI uses the [Ethereum V3 keystore](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) format (AES-128-CTR encrypted, password required at each use). Three ways to create one:
75
+
76
+ **Option A — Foundry `cast` (recommended for developers)**
77
+
78
+ ```bash
79
+ cast wallet new ~/.parallel/keystore.json
80
+ # → generates a fresh address and encrypts it with a password you choose
81
+ ```
82
+
83
+ **Option B — Geth**
84
+
85
+ ```bash
86
+ geth account new --keystore ~/.parallel/
87
+ ```
88
+
89
+ **Option C — From MetaMask (non-dev users)**
90
+
91
+ ```bash
92
+ # 1. MetaMask → Account details → Export Private Key
93
+ # 2. Convert to keystore:
94
+ cast wallet import ~/.parallel/keystore.json --interactive
95
+ # → paste the private key, set a password
96
+ ```
97
+
98
+ Then point the CLI to it:
99
+
100
+ ```bash
101
+ parallel config set wallet.keystore_path ~/.parallel/keystore.json
102
+ # or pass it directly: --wallet ~/.parallel/keystore.json
103
+ ```
104
+
105
+ ### Environment variables
106
+
107
+ All optional — they override the config file when set.
108
+
109
+ | Variable | Description |
110
+ |---|---|
111
+ | `PARALLEL_PRIVATE_KEY` | Raw private key (hex, `0x` prefix) — alternative to keystore, useful for scripts and CI |
112
+ | `PARALLEL_DEFAULT_CHAIN` | Default chain — overrides `network.default_chain` in config |
113
+ | `PARALLEL_JSON` | Set to `true` to force JSON output on all commands |
114
+
115
+
116
+ ---
117
+
118
+ ## Global flags
119
+
120
+ These flags are available across most commands. Command-specific flags (e.g. `--collateral`, `--amount`, `--op`) are documented in each command's section.
121
+
122
+ | Flag | Alias | Description |
123
+ |---|---|---|
124
+ | `--chain <chain>` | `-c` | Target chain (e.g. `base`, `ethereum`, `avalanche`) |
125
+ | `--json` | `-j` | Force JSON output |
126
+ | `--dry-run` | | Build transaction without broadcasting (write commands only) |
127
+ | `--wallet [path\|env]` | `-w` | Sign with a wallet — see below |
128
+ | `--help` | `-h` | Contextual help |
129
+
130
+ **`--wallet` resolution:**
131
+
132
+ | Usage | Behavior |
133
+ |---|---|
134
+ | `--wallet` (alone) | Auto-resolves: reads `wallet.keystore_path` from config first, then falls back to `$PARALLEL_PRIVATE_KEY` |
135
+ | `--wallet env` | Explicitly uses `$PARALLEL_PRIVATE_KEY` |
136
+ | `--wallet /path/to/keystore.json` | Uses that specific keystore file (password prompted) |
137
+
138
+ ---
139
+
140
+ ## Commands
141
+
142
+ ### `parallel protocol`
143
+
144
+ Read-only. No wallet required.
145
+
146
+ ```bash
147
+ parallel protocol overview # TVL · supply · APY · backing ratio
148
+ parallel protocol tvl [--chain <chain>] # Total Value Locked per chain
149
+ parallel protocol supply <usdp|susdp|prl|sprl1|sprl2> [--chain <chain>] # Token supply breakdown
150
+ parallel protocol backing [--chain <chain>] # Collateral composition + backing ratio
151
+ parallel protocol chains # Supported chains + feature matrix
152
+ parallel protocol collaterals --chain <chain> # Accepted collaterals · caps · fees
153
+ parallel protocol mint-capacity --collateral <symbol> --chain <chain> [--amount <n>]
154
+ parallel protocol fees [--collateral <symbol>] [--chain <chain>]
155
+ parallel protocol savings-rate [--chain <chain>] # Global APY + per-chain breakdown
156
+ parallel protocol exchange-rate [--chain <chain>] # sUSDp / USDp rate
157
+ parallel protocol solvency [--chain <chain>] # Backing ratio per chain
158
+ parallel protocol surplus [--chain <chain>] # Pending surplus (USDp)
159
+ parallel protocol flashloan [--chain <chain>] # Flash loan capacity + fee rate
160
+ ```
161
+
162
+ ---
163
+
164
+ ### `parallel swap`
165
+
166
+ Build Parallelizer transactions (mint / burn / redeem).
167
+
168
+ ```bash
169
+ # Get a quote first
170
+ parallel swap quote --op mint --collateral <symbol> --amount <n> --chain <chain>
171
+ parallel swap quote --op burn --collateral <symbol> --amount <n> --chain <chain>
172
+ parallel swap quote --op redeem --amount <n> --chain <chain>
173
+
174
+ # Dry-run (shows raw unsigned tx — no wallet needed)
175
+ parallel swap mint --collateral <symbol> --amount <n> --chain <chain> --dry-run
176
+ parallel swap burn --collateral <symbol> --amount <n> --chain <chain> --dry-run
177
+ parallel swap redeem --amount <n> --chain <chain> --dry-run
178
+
179
+ # Sign and broadcast
180
+ parallel swap mint --collateral <symbol> --amount <n> --chain <chain> --wallet
181
+ parallel swap burn --collateral <symbol> --amount <n> --chain <chain> --wallet
182
+ parallel swap redeem --amount <n> --chain <chain> --wallet # proportional redeem
183
+ ```
184
+
185
+ **Options:**
186
+
187
+ | Flag | Default | Description |
188
+ |---|---|---|
189
+ | `--op <mint\|burn\|redeem>` | | Operation (quote only) |
190
+ | `--collateral <symbol>` | | Collateral symbol (e.g. `USDC`, `USDS`, `sUSDS`) |
191
+ | `--amount <n>` | | Amount in USDp (or collateral units for mint) |
192
+ | `--address <0x...>` | | Receiver address for dry-run (no key needed) |
193
+
194
+ ---
195
+
196
+ ### `parallel savings`
197
+
198
+ sUSDp savings operations.
199
+
200
+ ```bash
201
+ parallel savings rate [--chain <chain>] # APY + exchange rate + TVL
202
+ parallel savings estimate --amount <n> --duration <days> # Projected yield
203
+
204
+ parallel savings balance <address> [--chain <chain>] # sUSDp balance + USDp equivalent
205
+
206
+ # Dry-run
207
+ parallel savings deposit --amount <n> --chain <chain> --dry-run
208
+ parallel savings withdraw --amount <n> --chain <chain> --dry-run # amount in sUSDp shares
209
+
210
+ # Sign and broadcast
211
+ parallel savings deposit --amount <n> --chain <chain> --wallet
212
+ parallel savings withdraw --amount <n> --chain <chain> --wallet
213
+ ```
214
+
215
+ > **Note:** `savings deposit` uses EIP-3009 `transferWithAuthorization` when available — single signature, gasless on L2/sidechains.
216
+
217
+ ---
218
+
219
+ ### `parallel bridge`
220
+
221
+ LayerZero cross-chain bridge (USDp / sUSDp).
222
+
223
+ ```bash
224
+ parallel bridge quote --token <usdp|susdp> --from <chain> --to <chain> --amount <n>
225
+ parallel bridge fees --from <chain> --token <usdp|susdp> # fees to all destinations
226
+ parallel bridge limits [--chain <chain>] # daily + global limits
227
+
228
+ # Dry-run
229
+ parallel bridge send --token <usdp|susdp> --from <chain> --to <chain> --amount <n> --dry-run
230
+
231
+ # Sign and broadcast
232
+ parallel bridge send --token <usdp|susdp> --from <chain> --to <chain> --amount <n> --wallet [--recipient <address>]
233
+
234
+ parallel bridge status <txHash> --from <chain>
235
+ ```
236
+
237
+ > **Note:** Mantle does not support bridging (no BridgeableToken deployed). All other chains support bridge.
238
+
239
+ ---
240
+
241
+ ### `parallel staking`
242
+
243
+ PRL staking — sPRL1 (single-sided) and sPRL2 (BPT, Balancer).
244
+
245
+ ```bash
246
+ parallel staking overview # global stats: supply, voting power, rewards
247
+ parallel staking info <address> # per-address: staked, voting power, pending rewards
248
+ parallel staking cooldown <address> # cooldown status + expiry date
249
+
250
+ # sPRL1 — stake PRL on Ethereum
251
+ parallel staking stake --type sprl1 --amount <n> --dry-run
252
+ parallel staking unstake --type sprl1 --amount <n> --dry-run
253
+ parallel staking stake --type sprl1 --amount <n> --wallet
254
+ parallel staking unstake --type sprl1 --amount <n> --wallet
255
+
256
+ # sPRL2 — Ethereum only (Balancer BPT, multi-step: Balancer → Aura)
257
+ parallel staking stake --type sprl2 --amount <n> --dry-run # BPT path
258
+ parallel staking stake --type sprl2 --amount <n> --weth-amount <n> --dry-run # PRL+WETH path
259
+ parallel staking unstake --type sprl2 --amount <n> --wallet # initiate cooldown
260
+ parallel staking unstake --type sprl2 --wallet # execute ready withdrawals
261
+
262
+ # Claim rewards
263
+ parallel staking claim --type sprl1 --dry-run
264
+ parallel staking claim --type sprl2 --dry-run
265
+ parallel staking claim --type all --wallet
266
+ ```
267
+
268
+ ---
269
+
270
+ ### `parallel gov`
271
+
272
+ Snapshot governance — read-only.
273
+
274
+ ```bash
275
+ parallel gov proposals [--status active|pending|passed|rejected] [--type PIP|PGP|PIR]
276
+ parallel gov proposal <PIP-65|0xabc...> # full details + vote results + description
277
+ parallel gov params # protocol parameters: fee rates, collateral caps
278
+ ```
279
+
280
+ ---
281
+
282
+ ### `parallel pay`
283
+
284
+ x402 payment layer.
285
+
286
+ ```bash
287
+ # Explore what's available on a chain
288
+ parallel pay capabilities [--chain <chain>]
289
+
290
+ # Gas sponsoring quota for an address
291
+ parallel pay quota --chain <chain> [--address <address>]
292
+
293
+ # Verify a payment on-chain
294
+ parallel pay verify <txHash> --chain <chain>
295
+ ```
296
+
297
+ #### `parallel pay prepare`
298
+
299
+ Builds a signed or unsigned x402 payment payload.
300
+
301
+ ```bash
302
+ # Unsigned — shows route + payload (no wallet required)
303
+ parallel pay prepare \
304
+ --amount <n> \
305
+ --recipient <address> \
306
+ --chain <chain>
307
+
308
+ # Signed — reads wallet balance, auto-selects best route, encodes the payload
309
+ parallel pay prepare \
310
+ --amount <n> \
311
+ --recipient <address> \
312
+ --chain <chain> \
313
+ --wallet
314
+
315
+ # Force which token the agent pays with
316
+ parallel pay prepare --amount <n> --recipient <address> --chain <chain> --pay-with <usdp|usdc|susdp>
317
+ ```
318
+
319
+ **`--token`** controls what the **merchant receives** (default: `usdp`). Accepted values: `usdp` · `usdc` · `susdp` · any backing collateral symbol (`susds`, `sfrxusd`, …).
320
+
321
+ **`--pay-with`** overrides which token the **agent pays with** (default: auto-detected from wallet balance). Accepted values: `usdp` · `usdc` · `susdp`.
322
+
323
+ **Auto-route selection** (when `--wallet` is provided):
324
+
325
+ | `--token` (merchant receives) | Agent wallet | Route | Method |
326
+ |---|---|---|---|
327
+ | `usdp` | USDp ≥ amount | A | `transferWithAuthorization` |
328
+ | `usdp` | sUSDp only | H | `redeemWithAuthorization` → USDp |
329
+ | `usdp` | sUSDp + USDp (top-up) | L | `partialRedeemWithAuthorization` |
330
+ | `usdc` | USDp | B | `swapExactOutputWithAuthorization` |
331
+ | `usdc` | sUSDp | I | `redeemWithAuthorization` → USDC |
332
+ | `usdc` | USDC | F | `transferWithAuthorization` |
333
+ | `susdp` | USDp | C | `depositWithAuthorization` |
334
+ | `susdp` | sUSDp | J | `transferWithAuthorization` |
335
+ | collateral (e.g. `susds`) | USDp | D | `swapExactOutputWithAuthorization` |
336
+ | collateral (e.g. `susds`) | sUSDp | K | `redeemWithAuthorization` → collateral |
337
+
338
+ Without `--wallet`, the payload is unsigned and `tokenIn` defaults to `usdp`.
339
+
340
+ ---
341
+
342
+ ### `parallel cashback`
343
+
344
+ Cashback rewards — read-only, via facilitator API.
345
+
346
+ ```bash
347
+ parallel cashback balance <address> # current month spend + earnings + tier
348
+ parallel cashback tier <address> # 4-tier breakdown + rates
349
+ parallel cashback history <address> [--limit <n>] # monthly history + distribution status
350
+ parallel cashback estimate <address> [--projected-spend <n>] # projected earnings this month
351
+ parallel cashback quota <address> [--chain <chain>] # gas sponsoring quota
352
+ ```
353
+
354
+ ---
355
+
356
+ ### Utilities
357
+
358
+ ```bash
359
+ parallel version # CLI version · MCP server version · Node version
360
+ parallel health [--chain <chain>] # RPC latency check for all chains (or one)
361
+ parallel config init # interactive setup wizard
362
+ parallel config get <key> # e.g. network.default_chain
363
+ parallel config set <key> <value> # e.g. parallel config set network.default_chain ethereum
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Output
369
+
370
+ All commands print a human-readable table by default.
371
+
372
+ ```bash
373
+ # Force JSON
374
+ parallel protocol tvl --json
375
+ # {"success":true,"data":{...}}
376
+
377
+ # Pipe-friendly: JSON is automatic when stdout is not a TTY
378
+ parallel protocol tvl | jq '.data.totalTVL'
379
+ ```
380
+
381
+ JSON envelope:
382
+
383
+ ```json
384
+ { "success": true, "data": { ... } }
385
+ { "success": false, "error": { "code": "CHAIN_SUNSET", "message": "..." } }
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Supported chains
391
+
392
+ `ethereum` · `base` · `arbitrum` · `optimism` · `polygon` · `avalanche` · `bsc` · `scroll` · `gnosis` · `sei` · `berachain` · `hyperevm` · `unichain` · `ink` · `tac` · `mantle` · `linea` · `xlayer` · `fraxtal` · `worldchain` · `hemi` · `plume` · `plasma` · `katana`
393
+
394
+ > `sonic` is sunset (PIP-64) — read operations work, write operations return `CHAIN_SUNSET`.
395
+
396
+ Not all chains support every feature. Use `parallel protocol chains` to see the full feature matrix (Parallelizer, sUSDp, bridge).
397
+
398
+ ---
399
+
400
+ ## Error codes
401
+
402
+ | Code | Trigger |
403
+ |---|---|
404
+ | `CHAIN_SUNSET` | Operation not available on a sunset chain |
405
+ | `CHAIN_PAUSED` | Chain temporarily paused (auto-pause by Hypernative or governance) |
406
+ | `PARALLELIZER_NOT_DEPLOYED` | Feature requires Parallelizer, not deployed on this chain |
407
+ | `UNKNOWN_CHAIN` | Chain identifier not recognised |
408
+ | `INSUFFICIENT_BALANCE` | Wallet balance too low for the requested amount |
409
+ | `EXCEEDS_CAP` | Amount would exceed a collateral exposure cap |
410
+ | `EXCEEDS_BRIDGE_LIMIT` | Amount exceeds daily or global bridge limit |
411
+ | `SLIPPAGE_EXCEEDED` | Actual slippage exceeds the configured tolerance |
412
+ | `COOLDOWN_ACTIVE` | Unstake impossible — cooldown period not yet expired |
413
+ | `COLLATERAL_NOT_SUPPORTED` | Collateral not accepted on this chain |
414
+ | `WALLET_REQUIRED` | Write command called without `--wallet` or `--dry-run` |
415
+ | `INVALID_KEYSTORE` | Keystore file not found or invalid format |
416
+ | `WRONG_PASSWORD` | Incorrect keystore decryption password |
417
+ | `INVALID_AMOUNT` | Negative, zero, or unparseable amount |
418
+ | `MISSING_OPTION` | Required flag not provided |
419
+ | `INVALID_ADDRESS` | Argument is not a valid EVM address |
420
+ | `PAYMENT_EXPIRED` | x402 payment — `validBefore` exceeded, re-sign required |
421
+ | `INVALID_SIGNATURE` | x402 payment — EIP-712 signature invalid |
422
+ | `INVALID_NONCE` | x402 payment — nonce already used |
423
+ | `ROUTE_UNAVAILABLE` | x402 payment — no route available for this merchant/chain combination |
424
+ | `RPC_ERROR` | RPC call failed (network issue or node unreachable) |
425
+
426
+ ---
427
+
428
+ ## Related
429
+
430
+ - [parallel-mcp](https://github.com/parallel-protocol/parallel-mcp) — MCP server + x402 facilitator
431
+ - [Parallel Protocol](https://parallel.best)