perp-cli 0.12.15 → 0.12.17
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 +31 -4
- package/dist/commands/account.js +14 -2
- package/dist/index.js +10 -7
- package/dist/landing.d.ts +9 -0
- package/dist/landing.js +20 -0
- package/package.json +1 -1
- package/skills/perp-cli/SKILL.md +250 -133
- package/skills/perp-cli/references/agent-operations.md +95 -60
- package/skills/perp-cli/references/commands.md +267 -119
- package/skills/perp-cli/references/strategies.md +10 -7
- package/skills/perp-cli/scripts/arb-monitor.sh +15 -15
- package/skills/perp-cli/scripts/funding-analysis.sh +11 -6
- package/skills/perp-cli/scripts/validate-arb.sh +2 -1
|
@@ -6,17 +6,20 @@ Complete reference for non-interactive CLI operations. Every command here is saf
|
|
|
6
6
|
|
|
7
7
|
### NEVER use these (interactive, will hang):
|
|
8
8
|
```
|
|
9
|
-
perp setup
|
|
9
|
+
perp setup # interactive wizard — asks questions via stdin
|
|
10
|
+
perp init # alias for setup
|
|
11
|
+
perp wallet setup # interactive wallet wizard
|
|
10
12
|
```
|
|
11
13
|
|
|
12
14
|
### ALWAYS use these (non-interactive, agent-safe):
|
|
13
15
|
```bash
|
|
14
|
-
perp --json wallet set <exchange> <key> # set private key
|
|
16
|
+
perp --json wallet set <exchange> <key> # set private key (or Aster API key)
|
|
15
17
|
perp --json wallet generate evm # generate EVM wallet
|
|
16
18
|
perp --json wallet generate solana # generate Solana wallet
|
|
17
19
|
perp --json wallet show # check configured wallets
|
|
20
|
+
perp --json wallet list # list named wallets
|
|
18
21
|
perp --json wallet balance # on-chain USDC balances
|
|
19
|
-
perp --json -e <EX> account balance
|
|
22
|
+
perp --json -e <EX> account balance # exchange account balance
|
|
20
23
|
perp --json -e <EX> account positions # open positions
|
|
21
24
|
perp --json -e <EX> market list # available markets
|
|
22
25
|
perp --json -e <EX> trade market ... # execute trade
|
|
@@ -35,7 +38,8 @@ perp --json risk check --notional <$> --leverage <L> # pre-trade risk check
|
|
|
35
38
|
### Single Exchange Setup
|
|
36
39
|
```bash
|
|
37
40
|
# 1. Install
|
|
38
|
-
npm install -g perp-cli
|
|
41
|
+
npm install -g perp-cli@latest
|
|
42
|
+
# or use npx -y perp-cli@latest as the prefix
|
|
39
43
|
|
|
40
44
|
# 2. Register wallet (user provides key)
|
|
41
45
|
perp --json wallet set hl 0xUSER_PRIVATE_KEY
|
|
@@ -54,37 +58,40 @@ perp --json -e hl market list
|
|
|
54
58
|
|
|
55
59
|
### Multi-Exchange Setup (for Funding Rate Arb)
|
|
56
60
|
To run arb, you need wallets on AT LEAST 2 exchanges. Each exchange needs:
|
|
57
|
-
- A configured wallet with a private key
|
|
61
|
+
- A configured wallet with a private key (or API key for Aster)
|
|
58
62
|
- USDC balance deposited on-exchange
|
|
59
63
|
|
|
60
64
|
```bash
|
|
61
|
-
# 1. Register
|
|
65
|
+
# 1. Register wallets (any 2+ of: hl, pac, lt, aster)
|
|
62
66
|
perp --json wallet set hl 0xEVM_KEY
|
|
63
67
|
perp --json wallet set pac SOLANA_BASE58_KEY
|
|
68
|
+
perp --json wallet set lt 0xEVM_KEY # may be the same EVM key as HL
|
|
69
|
+
perp --json wallet set aster <ASTER_API_KEY>
|
|
64
70
|
|
|
65
|
-
# 2. Verify
|
|
71
|
+
# 2. Verify
|
|
66
72
|
perp --json wallet show
|
|
67
|
-
# → should show both exchanges with addresses
|
|
68
73
|
|
|
69
|
-
# 3. Check balances
|
|
74
|
+
# 3. Check balances (each exchange holds its own balance)
|
|
70
75
|
perp --json -e hl account balance
|
|
71
76
|
perp --json -e pac account balance
|
|
77
|
+
perp --json -e lt account balance
|
|
78
|
+
perp --json -e aster account balance
|
|
72
79
|
|
|
73
|
-
# 4. If one side needs funding, bridge USDC
|
|
74
|
-
perp --json bridge quote --from solana --to arbitrum --amount 500
|
|
80
|
+
# 4. If one side needs funding, bridge USDC via funds bridge
|
|
81
|
+
perp --json funds bridge quote --from solana --to arbitrum --amount 500
|
|
75
82
|
# → show quote to user, get confirmation
|
|
76
|
-
perp --json bridge send --from solana --to arbitrum --amount 500
|
|
77
|
-
perp --json bridge status <orderId> # wait for completion
|
|
83
|
+
perp --json funds bridge send --from solana --to arbitrum --amount 500
|
|
84
|
+
perp --json funds bridge status <orderId> # wait for completion
|
|
78
85
|
|
|
79
86
|
# 5. Verify both sides have balance, then start arb
|
|
80
87
|
perp --json arb scan --min 5
|
|
81
88
|
```
|
|
82
89
|
|
|
83
90
|
### Lighter API Key Setup
|
|
84
|
-
Lighter uses a separate API key for trading.
|
|
91
|
+
Lighter uses a separate API key for trading. Two paths:
|
|
85
92
|
|
|
86
|
-
1. **Auto-setup (default)**: When `LIGHTER_PRIVATE_KEY` is set (env
|
|
87
|
-
2. **Managed agent (recommended for long-running agents)**: `perp wallet agent approve lighter --master <wallet> --api-key-index <slot>` registers a per-agent slot
|
|
93
|
+
1. **Auto-setup (default)**: When `LIGHTER_PRIVATE_KEY` is set (env or `wallet set lt`), the CLI auto-generates and saves the API key on first use. Default index is 4 (indexes 0–3 are reserved by Lighter's frontend). Override with `LIGHTER_API_KEY_INDEX` env var. Valid range: 4–254.
|
|
94
|
+
2. **Managed agent (recommended for long-running agents)**: `perp wallet agent approve lighter --master <wallet> --api-key-index <slot>` registers a per-agent slot with explicit expiry tracking + 3-tier signer routing.
|
|
88
95
|
|
|
89
96
|
If auto-setup fails (e.g. transient network error), retry manually:
|
|
90
97
|
```bash
|
|
@@ -103,9 +110,9 @@ perp --json wallet set lt 0xKEY # same key, different exchange binding
|
|
|
103
110
|
| Exchange | Chain | Key Format | Example |
|
|
104
111
|
|----------|-------|-----------|---------|
|
|
105
112
|
| Pacifica | Solana | Base58 string | `5KQwrPbwdL6PhXu...` |
|
|
106
|
-
| Hyperliquid | EVM | Hex with 0x prefix, 66 chars | `0x4c0883a69102937d...` |
|
|
107
|
-
| Lighter | EVM | Hex with 0x prefix, 66 chars | `0x4c0883a69102937d...` |
|
|
108
|
-
| Aster | API
|
|
113
|
+
| Hyperliquid | EVM (HyperEVM) | Hex with 0x prefix, 66 chars | `0x4c0883a69102937d...` |
|
|
114
|
+
| Lighter | EVM (Ethereum) | Hex with 0x prefix, 66 chars | `0x4c0883a69102937d...` |
|
|
115
|
+
| Aster | API key (BNB Chain) | Hex string | `3971f62b...` |
|
|
109
116
|
|
|
110
117
|
Aliases for exchange names:
|
|
111
118
|
- `pac` or `pacifica`
|
|
@@ -118,12 +125,12 @@ Aliases for exchange names:
|
|
|
118
125
|
### Check On-Chain vs Exchange Balance
|
|
119
126
|
```bash
|
|
120
127
|
perp --json wallet balance # on-chain USDC in your wallet
|
|
121
|
-
perp --json -e hl account balance
|
|
128
|
+
perp --json -e hl account balance # USDC deposited on exchange
|
|
122
129
|
```
|
|
123
130
|
|
|
124
131
|
**On-chain balance ≠ exchange balance.** USDC in your wallet must be deposited to the exchange before trading.
|
|
125
132
|
|
|
126
|
-
### Deposit to Exchange
|
|
133
|
+
### Deposit to Exchange (`funds deposit`)
|
|
127
134
|
```bash
|
|
128
135
|
# Hyperliquid (from Arbitrum wallet)
|
|
129
136
|
perp --json funds deposit hyperliquid 100
|
|
@@ -132,36 +139,51 @@ perp --json funds deposit hyperliquid 100
|
|
|
132
139
|
perp --json funds deposit pacifica 100
|
|
133
140
|
|
|
134
141
|
# Lighter (multiple routes)
|
|
135
|
-
perp --json funds deposit lighter info
|
|
136
|
-
perp --json funds deposit lighter
|
|
142
|
+
perp --json funds deposit lighter info # show all available routes
|
|
143
|
+
perp --json funds deposit lighter ethereum 100 # L1 direct (min 1 USDC)
|
|
144
|
+
perp --json funds deposit lighter cctp arbitrum 100 # via CCTP from Arbitrum (min 5 USDC)
|
|
137
145
|
```
|
|
138
146
|
|
|
139
|
-
### Withdraw from Exchange
|
|
147
|
+
### Withdraw from Exchange (`funds withdraw`)
|
|
140
148
|
```bash
|
|
141
149
|
perp --json funds withdraw hyperliquid 100
|
|
142
150
|
perp --json funds withdraw pacifica 100
|
|
143
151
|
perp --json funds withdraw lighter 100
|
|
144
152
|
```
|
|
145
153
|
|
|
146
|
-
###
|
|
147
|
-
When you need to move USDC between exchanges on different chains:
|
|
154
|
+
### Internal Transfer (Hyperliquid)
|
|
148
155
|
```bash
|
|
149
|
-
#
|
|
156
|
+
perp --json funds transfer 100 <ADDRESS> # instant HL→HL spot transfer
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Bridge Between Chains (`funds bridge`)
|
|
160
|
+
When you need to move USDC between chains (different networks):
|
|
161
|
+
```bash
|
|
162
|
+
# 1. Withdraw from source exchange to wallet
|
|
150
163
|
perp --json funds withdraw pacifica 500
|
|
151
164
|
|
|
152
|
-
# 2. Quote the bridge
|
|
153
|
-
perp --json bridge quote --from solana --to arbitrum --amount 500
|
|
165
|
+
# 2. Quote the bridge (auto-cheapest of cctp / relay / debridge)
|
|
166
|
+
perp --json funds bridge quote --from solana --to arbitrum --amount 500
|
|
154
167
|
|
|
155
|
-
# 3. Send (after user confirmation)
|
|
156
|
-
perp --json bridge send --from solana --to arbitrum --amount 500
|
|
168
|
+
# 3. Send (after user confirmation; pin --provider to override auto)
|
|
169
|
+
perp --json funds bridge send --from solana --to arbitrum --amount 500
|
|
170
|
+
perp --json funds bridge send --from solana --to arbitrum --amount 500 --provider cctp
|
|
157
171
|
|
|
158
172
|
# 4. Wait for completion
|
|
159
|
-
perp --json bridge status <orderId>
|
|
173
|
+
perp --json funds bridge status <orderId>
|
|
160
174
|
|
|
161
175
|
# 5. Deposit to destination exchange
|
|
162
176
|
perp --json funds deposit hyperliquid 500
|
|
163
177
|
```
|
|
164
178
|
|
|
179
|
+
### Inter-Exchange Rebalance (one command, end-to-end)
|
|
180
|
+
```bash
|
|
181
|
+
perp --json funds rebalance check # current distribution
|
|
182
|
+
perp --json funds rebalance plan # compute optimal moves
|
|
183
|
+
perp --json funds rebalance execute --auto-bridge # withdraw → bridge → deposit
|
|
184
|
+
perp --json funds rebalance execute --withdraw-only # only withdraw, manual rest
|
|
185
|
+
```
|
|
186
|
+
|
|
165
187
|
## Order Types & Execution
|
|
166
188
|
|
|
167
189
|
### Market Orders (immediate execution)
|
|
@@ -170,6 +192,7 @@ perp --json -e hl trade market BTC buy 0.01 # market buy
|
|
|
170
192
|
perp --json -e hl trade market BTC sell 0.01 # market sell
|
|
171
193
|
perp --json -e hl trade buy BTC 0.01 # shorthand
|
|
172
194
|
perp --json -e hl trade sell BTC 0.01 # shorthand
|
|
195
|
+
perp --json -e hl trade buy BTC 0.01 --smart # IOC limit at best ask (less slippage)
|
|
173
196
|
```
|
|
174
197
|
|
|
175
198
|
### Split Orders (orderbook-aware, for large orders)
|
|
@@ -181,35 +204,39 @@ perp --json -e hl trade market BTC buy 0.5 --split # split via market command
|
|
|
181
204
|
Returns `{ slices[], filledUsd, avgPrice, totalSlippagePct, status }`.
|
|
182
205
|
Status: `complete` (all filled), `partial` (some filled), `failed` (none filled).
|
|
183
206
|
|
|
184
|
-
### Limit
|
|
207
|
+
### Limit / Stop / TPSL
|
|
185
208
|
```bash
|
|
186
|
-
perp --json -e hl trade
|
|
187
|
-
perp --json -e hl trade
|
|
209
|
+
perp --json -e hl trade limit BTC buy 60000 0.01 # buy 0.01 BTC at $60k
|
|
210
|
+
perp --json -e hl trade stop BTC sell 0.01 58000 # stop sell at $58k
|
|
211
|
+
perp --json -e hl trade tpsl BTC long --tp 65000 --sl 58000
|
|
188
212
|
```
|
|
189
213
|
|
|
190
|
-
### Close
|
|
214
|
+
### Close / Reduce
|
|
191
215
|
```bash
|
|
192
216
|
perp --json -e hl trade close BTC # close entire position
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
perp --json -e hl trade sl BTC 58000 # stop loss at $58k
|
|
198
|
-
perp --json -e hl trade tp BTC 65000 # take profit at $65k
|
|
217
|
+
perp --json -e hl trade close-all # close all positions on this exchange
|
|
218
|
+
perp --json -e hl trade flatten # cancel all orders + close all positions
|
|
219
|
+
perp --json -e hl trade reduce BTC 50 # reduce position by 50%
|
|
199
220
|
```
|
|
200
221
|
|
|
201
222
|
### Cancel Orders
|
|
202
223
|
```bash
|
|
203
224
|
perp --json -e hl account orders # list open orders
|
|
225
|
+
perp --json -e hl trade cancel BTC # cancel by symbol
|
|
204
226
|
perp --json -e hl trade cancel <orderId> # cancel specific order
|
|
227
|
+
perp --json -e hl trade cancel-all # cancel all orders
|
|
228
|
+
perp --json -e hl trade cancel-stop BTC <stopId> # cancel stop order
|
|
229
|
+
perp --json -e hl trade cancel-twap BTC <twapId> # cancel TWAP order
|
|
205
230
|
```
|
|
206
231
|
|
|
207
232
|
### Pre-Flight Validation
|
|
208
233
|
ALWAYS run before executing a trade:
|
|
209
234
|
```bash
|
|
210
|
-
perp --json -e hl trade check BTC buy 0.01
|
|
235
|
+
perp --json -e hl trade check BTC buy 0.01 --leverage 3
|
|
211
236
|
```
|
|
212
|
-
|
|
237
|
+
Returns estimated fees, slippage, and whether the trade is within risk limits.
|
|
238
|
+
|
|
239
|
+
> **Important:** `trade check` does NOT read the exchange-set leverage. Always pass `--leverage` explicitly so the cost estimate matches what the exchange will apply.
|
|
213
240
|
|
|
214
241
|
## Parsing JSON Output
|
|
215
242
|
|
|
@@ -218,7 +245,7 @@ Every command returns this envelope:
|
|
|
218
245
|
{
|
|
219
246
|
"ok": true,
|
|
220
247
|
"data": { ... },
|
|
221
|
-
"meta": { "timestamp": "2026-
|
|
248
|
+
"meta": { "timestamp": "2026-05-02T..." }
|
|
222
249
|
}
|
|
223
250
|
```
|
|
224
251
|
|
|
@@ -239,22 +266,27 @@ Error case:
|
|
|
239
266
|
## Idempotency & Safety
|
|
240
267
|
|
|
241
268
|
### Safe to retry (idempotent):
|
|
242
|
-
- `wallet show`, `wallet balance` — read-only
|
|
243
|
-
- `account balance`, `account positions`, `account orders` — read-only
|
|
244
|
-
- `market list`, `market mid`, `market book` — read-only
|
|
245
|
-
- `arb scan`
|
|
246
|
-
- `portfolio`, `risk
|
|
247
|
-
- `bridge quote` — read-only
|
|
248
|
-
- `
|
|
269
|
+
- `wallet show`, `wallet list`, `wallet balance` — read-only
|
|
270
|
+
- `account balance`, `account positions`, `account orders`, `account margin` — read-only
|
|
271
|
+
- `market list`, `market mid`, `market book`, `market info`, `market funding` — read-only
|
|
272
|
+
- `arb scan` (any mode), `arb status`, `arb history`, `arb config` — read-only
|
|
273
|
+
- `portfolio`, `risk status`, `risk liquidation-distance` — read-only
|
|
274
|
+
- `funds bridge quote`, `funds bridge status`, `funds rebalance check`, `funds rebalance plan` — read-only
|
|
275
|
+
- `funds info`, `funds deposit lighter info` — read-only
|
|
249
276
|
|
|
250
277
|
### NOT safe to retry blindly:
|
|
251
|
-
- `trade market`, `trade buy`, `trade sell` — will open duplicate positions
|
|
252
|
-
- `trade close` —
|
|
253
|
-
- `bridge send` — will send duplicate transfers
|
|
254
|
-
- `funds deposit
|
|
278
|
+
- `trade market`, `trade buy`, `trade sell`, `trade limit`, `trade tpsl` — will open duplicate positions
|
|
279
|
+
- `trade close`, `trade close-all`, `trade flatten` — usually safe (no-op when nothing to close), but verify
|
|
280
|
+
- `funds bridge send` — will send duplicate transfers
|
|
281
|
+
- `funds deposit *`, `funds withdraw *`, `funds transfer` — will move funds twice
|
|
282
|
+
- `arb exec`, `arb close`, `arb auto` — open/close real positions
|
|
283
|
+
- `funds rebalance execute` — orchestrated multi-leg movement
|
|
255
284
|
|
|
256
285
|
**For non-idempotent commands:** always verify the result before retrying. Check positions or balances to confirm whether the first attempt succeeded.
|
|
257
286
|
|
|
287
|
+
### Idempotency Key
|
|
288
|
+
Use `--client-id <unique>` on `trade market` to prevent duplicate orders. The CLI tracks recent client IDs and rejects duplicates.
|
|
289
|
+
|
|
258
290
|
## Symbol Naming Across Exchanges
|
|
259
291
|
|
|
260
292
|
Symbols are auto-resolved by the CLI. **Always use bare symbols** (e.g., `BTC`, `SOL`, `ICP`) — the CLI handles exchange-specific naming automatically:
|
|
@@ -267,6 +299,7 @@ Symbols are auto-resolved by the CLI. **Always use bare symbols** (e.g., `BTC`,
|
|
|
267
299
|
|
|
268
300
|
- `arb scan` returns bare symbols — pass them directly to trade/leverage commands on any exchange.
|
|
269
301
|
- Do NOT manually add `-PERP` suffix — the CLI resolves this automatically.
|
|
302
|
+
- For HL spot+perp: BTC→`UBTC`, ETH→`UETH`, SOL→`USOL` are auto-resolved.
|
|
270
303
|
|
|
271
304
|
## Exchange-Specific Constraints
|
|
272
305
|
|
|
@@ -274,18 +307,20 @@ Symbols are auto-resolved by the CLI. **Always use bare symbols** (e.g., `BTC`,
|
|
|
274
307
|
|----------|---------------------|-------|
|
|
275
308
|
| Pacifica | ~$1 (varies by symbol) | Lower minimums |
|
|
276
309
|
| Hyperliquid | **$10** | Rejects orders below $10 notional |
|
|
277
|
-
| Lighter | Varies by symbol | Check market info |
|
|
310
|
+
| Lighter | Varies by symbol | Check `market info` |
|
|
278
311
|
| Aster | Varies by symbol | BNB Chain, API key based |
|
|
279
312
|
|
|
280
313
|
**`trade check` is advisory only** — it returns `valid: true/false` but does NOT block execution. The exchange itself enforces minimums and will reject with an error if the order is too small.
|
|
281
314
|
|
|
282
315
|
## Common Agent Mistakes
|
|
283
316
|
|
|
284
|
-
1. **Using `perp setup
|
|
317
|
+
1. **Using `perp setup` / `perp init` / `perp wallet setup`** — interactive, will hang forever. Use `wallet set` instead.
|
|
285
318
|
2. **Forgetting `--json`** — output becomes unparseable human text.
|
|
286
319
|
3. **Trading with zero balance** — check `account balance` first, tell user to deposit.
|
|
287
320
|
4. **Retrying a trade without checking** — leads to double positions. Always check `account positions` after a trade, even if it seemed to fail.
|
|
288
|
-
5. **Bridging without quoting** — always run `bridge quote` first to show the user fees and estimated time.
|
|
289
|
-
6. **Assuming deposit is instant** — after `bridge send`, wait for `bridge status` to confirm completion before depositing to the destination exchange.
|
|
321
|
+
5. **Bridging without quoting** — always run `funds bridge quote` first to show the user fees and estimated time.
|
|
322
|
+
6. **Assuming deposit is instant** — after `funds bridge send`, wait for `funds bridge status` to confirm completion before depositing to the destination exchange.
|
|
290
323
|
7. **Manually adding `-PERP` suffix** — the CLI auto-resolves symbols. Just use bare names like `ICP`, `SOL`, `BTC`.
|
|
291
324
|
8. **Order below exchange minimum** — Hyperliquid requires $10+ notional. Compute `size × price` before submitting.
|
|
325
|
+
9. **Using legacy command names** — `arb rates`/`prices`/`dex`/`spot-exec`/`spot-close` are removed; use `arb scan --rates`/`--gaps`/`--hip3` and `arb exec spot:<exch>` / `arb close <SYM> --spot-exch <ex>` instead.
|
|
326
|
+
10. **Calling `trade check` without `--leverage`** — the CLI does not read exchange-set leverage, so cost estimates will be wrong.
|