perp-cli 0.12.17 → 0.14.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/README.md +247 -27
- package/dist/_stderr-filter.js +0 -1
- package/dist/agent-wallet/lighter-keystore.d.ts +11 -0
- package/dist/agent-wallet/lighter-keystore.js +92 -10
- package/dist/agent-wallet/passphrase.d.ts +1 -1
- package/dist/agent-wallet/passphrase.js +16 -3
- package/dist/agent-wallet/store.d.ts +37 -4
- package/dist/agent-wallet/store.js +132 -0
- package/dist/agent-wallet/venue-keystore.d.ts +14 -0
- package/dist/agent-wallet/venue-keystore.js +121 -0
- package/dist/api/public/hyperliquid.js +4 -4
- package/dist/api/public/lighter.js +5 -5
- package/dist/api/public/pacifica.d.ts +0 -1
- package/dist/api/public/pacifica.js +4 -13
- package/dist/api/public/urls.d.ts +9 -1
- package/dist/api/public/urls.js +35 -13
- package/dist/arb/file-lock.d.ts +11 -0
- package/dist/arb/file-lock.js +74 -0
- package/dist/arb/index.d.ts +2 -2
- package/dist/arb/index.js +2 -2
- package/dist/arb/pending-entry.d.ts +32 -0
- package/dist/arb/pending-entry.js +77 -0
- package/dist/arb/sizing.d.ts +6 -13
- package/dist/arb/sizing.js +12 -51
- package/dist/arb/state.d.ts +45 -12
- package/dist/arb/state.js +214 -42
- package/dist/arb/utils.d.ts +20 -6
- package/dist/arb/utils.js +43 -39
- package/dist/bot/conditions.d.ts +4 -4
- package/dist/bot/conditions.js +11 -6
- package/dist/bot/config.d.ts +17 -1
- package/dist/bot/config.js +48 -12
- package/dist/bot/engine.d.ts +61 -2
- package/dist/bot/engine.js +610 -144
- package/dist/bot/fill-size.d.ts +7 -0
- package/dist/bot/fill-size.js +18 -0
- package/dist/bot/index.d.ts +1 -1
- package/dist/bot/index.js +1 -1
- package/dist/bot/perp-order.d.ts +99 -0
- package/dist/bot/perp-order.js +299 -0
- package/dist/bot/presets.d.ts +7 -0
- package/dist/bot/presets.js +17 -0
- package/dist/bot/quarantine.d.ts +75 -0
- package/dist/bot/quarantine.js +190 -0
- package/dist/bot/quote-rules.d.ts +23 -0
- package/dist/bot/quote-rules.js +69 -0
- package/dist/bot/strategies/avellaneda-mm.d.ts +32 -2
- package/dist/bot/strategies/avellaneda-mm.js +72 -70
- package/dist/bot/strategies/basis-arb.js +2 -0
- package/dist/bot/strategies/dca-strategy.d.ts +2 -0
- package/dist/bot/strategies/dca-strategy.js +5 -0
- package/dist/bot/strategies/funding-arb-strategy.d.ts +43 -3
- package/dist/bot/strategies/funding-arb-strategy.js +571 -380
- package/dist/bot/strategies/funding-arb-utils.d.ts +48 -23
- package/dist/bot/strategies/funding-arb-utils.js +159 -195
- package/dist/bot/strategies/funding-arb-v2.d.ts +32 -0
- package/dist/bot/strategies/funding-arb-v2.js +258 -47
- package/dist/bot/strategies/funding-auto.js +215 -194
- package/dist/bot/strategies/spot-perp-arb-strategy.d.ts +14 -0
- package/dist/bot/strategies/spot-perp-arb-strategy.js +217 -50
- package/dist/bot/strategies/spot-perp-executor.d.ts +73 -19
- package/dist/bot/strategies/spot-perp-executor.js +319 -120
- package/dist/bot/strategies/spot-perp-state.d.ts +43 -0
- package/dist/bot/strategies/spot-perp-state.js +70 -0
- package/dist/bot/strategy-types.d.ts +6 -0
- package/dist/bot/tui/BotDashboard.d.ts +7 -2
- package/dist/bot/tui/BotDashboard.js +6 -3
- package/dist/bridge-engine.d.ts +120 -19
- package/dist/bridge-engine.js +710 -422
- package/dist/bridge-signers.d.ts +54 -0
- package/dist/bridge-signers.js +161 -0
- package/dist/cache.d.ts +4 -1
- package/dist/cache.js +11 -0
- package/dist/cli-flags.d.ts +50 -0
- package/dist/cli-flags.js +104 -0
- package/dist/cli-program.d.ts +35 -0
- package/dist/cli-program.js +286 -0
- package/dist/cli-spec.js +1 -1
- package/dist/client-id-tracker.js +11 -2
- package/dist/commands/account.d.ts +7 -1
- package/dist/commands/account.js +70 -92
- package/dist/commands/agent-import.d.ts +114 -0
- package/dist/commands/agent-import.js +794 -0
- package/dist/commands/agent.d.ts +232 -2
- package/dist/commands/agent.js +1858 -955
- package/dist/commands/alerts.d.ts +1 -0
- package/dist/commands/alerts.js +31 -28
- package/dist/commands/arb/index.d.ts +60 -1
- package/dist/commands/arb/index.js +381 -384
- package/dist/commands/arb-auto.d.ts +132 -4
- package/dist/commands/arb-auto.js +1474 -967
- package/dist/commands/arb.d.ts +3 -1
- package/dist/commands/arb.js +62 -30
- package/dist/commands/bot.js +127 -47
- package/dist/commands/bridge.d.ts +2 -1
- package/dist/commands/bridge.js +339 -192
- package/dist/commands/builder.d.ts +55 -0
- package/dist/commands/builder.js +387 -0
- package/dist/commands/funds-onchain.d.ts +32 -0
- package/dist/commands/funds-onchain.js +286 -0
- package/dist/commands/funds.d.ts +25 -0
- package/dist/commands/funds.js +939 -245
- package/dist/commands/history.js +72 -45
- package/dist/commands/init.d.ts +107 -15
- package/dist/commands/init.js +1116 -249
- package/dist/commands/jobs.d.ts +2 -1
- package/dist/commands/jobs.js +77 -15
- package/dist/commands/manage.js +136 -91
- package/dist/commands/market.d.ts +4 -1
- package/dist/commands/market.js +35 -32
- package/dist/commands/outcome.d.ts +10 -0
- package/dist/commands/outcome.js +396 -0
- package/dist/commands/plan.js +52 -12
- package/dist/commands/portfolio.d.ts +1 -0
- package/dist/commands/portfolio.js +60 -72
- package/dist/commands/rebalance.d.ts +2 -1
- package/dist/commands/rebalance.js +33 -43
- package/dist/commands/risk.js +46 -19
- package/dist/commands/settings.d.ts +1 -0
- package/dist/commands/settings.js +246 -51
- package/dist/commands/trade.d.ts +50 -0
- package/dist/commands/trade.js +1943 -695
- package/dist/commands/wallet.d.ts +30 -1
- package/dist/commands/wallet.js +316 -337
- package/dist/config.d.ts +60 -9
- package/dist/config.js +252 -82
- package/dist/constants.d.ts +29 -4
- package/dist/constants.js +62 -20
- package/dist/dashboard/server.d.ts +2 -0
- package/dist/dashboard/server.js +9 -6
- package/dist/dashboard/ui.js +6 -4
- package/dist/dashboard/ws-feeds.js +20 -8
- package/dist/dex-asset-map.js +5 -3
- package/dist/errors.d.ts +122 -0
- package/dist/errors.js +194 -0
- package/dist/event-stream.js +75 -19
- package/dist/evm-master-tx.d.ts +59 -0
- package/dist/evm-master-tx.js +154 -0
- package/dist/exchanges/adapter-network.d.ts +10 -0
- package/dist/exchanges/adapter-network.js +10 -0
- package/dist/exchanges/arcus/adapter.d.ts +196 -0
- package/dist/exchanges/arcus/adapter.js +1092 -0
- package/dist/exchanges/arcus/agent.d.ts +55 -0
- package/dist/exchanges/arcus/agent.js +188 -0
- package/dist/exchanges/arcus/client.d.ts +63 -0
- package/dist/exchanges/arcus/client.js +285 -0
- package/dist/exchanges/arcus/public.d.ts +65 -0
- package/dist/exchanges/arcus/public.js +138 -0
- package/dist/exchanges/arcus/signing.d.ts +176 -0
- package/dist/exchanges/arcus/signing.js +288 -0
- package/dist/exchanges/arcus/spot-chain.d.ts +60 -0
- package/dist/exchanges/arcus/spot-chain.js +241 -0
- package/dist/exchanges/arcus/spot-router.d.ts +177 -0
- package/dist/exchanges/arcus/spot-router.js +183 -0
- package/dist/exchanges/arcus/spot.d.ts +109 -0
- package/dist/exchanges/arcus/spot.js +645 -0
- package/dist/exchanges/aster-funds.d.ts +127 -0
- package/dist/exchanges/aster-funds.js +252 -0
- package/dist/exchanges/aster-nonce.d.ts +2 -0
- package/dist/exchanges/aster-nonce.js +107 -0
- package/dist/exchanges/aster-spot.d.ts +117 -0
- package/dist/exchanges/aster-spot.js +686 -0
- package/dist/exchanges/aster-typed-data.d.ts +133 -7
- package/dist/exchanges/aster-typed-data.js +121 -7
- package/dist/exchanges/aster.d.ts +219 -6
- package/dist/exchanges/aster.js +1023 -153
- package/dist/exchanges/builder-fee.d.ts +254 -0
- package/dist/exchanges/builder-fee.js +421 -0
- package/dist/exchanges/canonical-symbols.d.ts +32 -0
- package/dist/exchanges/canonical-symbols.js +96 -0
- package/dist/exchanges/capabilities.d.ts +7 -1
- package/dist/exchanges/capabilities.js +7 -0
- package/dist/exchanges/hl-signing.d.ts +165 -0
- package/dist/exchanges/hl-signing.js +158 -0
- package/dist/exchanges/hyperliquid-outcome.d.ts +211 -0
- package/dist/exchanges/hyperliquid-outcome.js +646 -0
- package/dist/exchanges/hyperliquid-spot.d.ts +44 -5
- package/dist/exchanges/hyperliquid-spot.js +308 -117
- package/dist/exchanges/hyperliquid.d.ts +462 -57
- package/dist/exchanges/hyperliquid.js +1575 -449
- package/dist/exchanges/index.d.ts +6 -0
- package/dist/exchanges/index.js +4 -0
- package/dist/exchanges/interface.d.ts +63 -10
- package/dist/exchanges/interface.js +18 -3
- package/dist/exchanges/ioc-outcome.d.ts +44 -0
- package/dist/exchanges/ioc-outcome.js +57 -0
- package/dist/exchanges/legacy-trading-v2.d.ts +39 -0
- package/dist/exchanges/legacy-trading-v2.js +940 -0
- package/dist/exchanges/lighter-public.d.ts +43 -0
- package/dist/exchanges/lighter-public.js +276 -0
- package/dist/exchanges/lighter-rh-deposit.d.ts +62 -0
- package/dist/exchanges/lighter-rh-deposit.js +185 -0
- package/dist/exchanges/lighter-signer.d.ts +123 -0
- package/dist/exchanges/lighter-signer.js +215 -0
- package/dist/exchanges/lighter-spot.d.ts +91 -13
- package/dist/exchanges/lighter-spot.js +595 -233
- package/dist/exchanges/lighter.d.ts +611 -39
- package/dist/exchanges/lighter.js +1890 -649
- package/dist/exchanges/ondo/adapter.d.ts +166 -0
- package/dist/exchanges/ondo/adapter.js +835 -0
- package/dist/exchanges/ondo/agent.d.ts +31 -0
- package/dist/exchanges/ondo/agent.js +101 -0
- package/dist/exchanges/ondo/client.d.ts +60 -0
- package/dist/exchanges/ondo/client.js +297 -0
- package/dist/exchanges/ondo/funds.d.ts +122 -0
- package/dist/exchanges/ondo/funds.js +290 -0
- package/dist/exchanges/ondo/public.d.ts +95 -0
- package/dist/exchanges/ondo/public.js +214 -0
- package/dist/exchanges/ondo/spot.d.ts +127 -0
- package/dist/exchanges/ondo/spot.js +392 -0
- package/dist/exchanges/outcome-interface.d.ts +140 -0
- package/dist/exchanges/outcome-interface.js +16 -0
- package/dist/exchanges/pacifica-spot.d.ts +83 -0
- package/dist/exchanges/pacifica-spot.js +324 -0
- package/dist/exchanges/pacifica-typed-data.d.ts +30 -13
- package/dist/exchanges/pacifica-typed-data.js +57 -9
- package/dist/exchanges/pacifica.d.ts +288 -4
- package/dist/exchanges/pacifica.js +1013 -76
- package/dist/exchanges/precision.d.ts +47 -0
- package/dist/exchanges/precision.js +209 -0
- package/dist/exchanges/qfex/adapter.d.ts +341 -0
- package/dist/exchanges/qfex/adapter.js +1383 -0
- package/dist/exchanges/qfex/agent.d.ts +58 -0
- package/dist/exchanges/qfex/agent.js +188 -0
- package/dist/exchanges/qfex/client.d.ts +54 -0
- package/dist/exchanges/qfex/client.js +138 -0
- package/dist/exchanges/qfex/errors.d.ts +70 -0
- package/dist/exchanges/qfex/errors.js +236 -0
- package/dist/exchanges/qfex/public.d.ts +122 -0
- package/dist/exchanges/qfex/public.js +268 -0
- package/dist/exchanges/qfex/signing.d.ts +160 -0
- package/dist/exchanges/qfex/signing.js +283 -0
- package/dist/exchanges/qfex/ws-transport.d.ts +294 -0
- package/dist/exchanges/qfex/ws-transport.js +798 -0
- package/dist/exchanges/rate-limiter.d.ts +12 -0
- package/dist/exchanges/rate-limiter.js +64 -0
- package/dist/exchanges/registry.d.ts +14 -2
- package/dist/exchanges/registry.js +20 -32
- package/dist/exchanges/slippage.d.ts +37 -0
- package/dist/exchanges/slippage.js +70 -0
- package/dist/exchanges/spot-factory.d.ts +166 -0
- package/dist/exchanges/spot-factory.js +431 -0
- package/dist/exchanges/spot-interface.d.ts +98 -4
- package/dist/exchanges/spot-interface.js +27 -1
- package/dist/exchanges/spot-result.d.ts +79 -0
- package/dist/exchanges/spot-result.js +273 -0
- package/dist/exchanges/trading-v2.d.ts +117 -0
- package/dist/exchanges/trading-v2.js +301 -0
- package/dist/exchanges/venue-types.d.ts +231 -0
- package/dist/exchanges/venue-types.js +87 -0
- package/dist/exchanges/venue.d.ts +211 -0
- package/dist/exchanges/venue.js +132 -0
- package/dist/exchanges/venues/arcus.d.ts +8 -0
- package/dist/exchanges/venues/arcus.js +109 -0
- package/dist/exchanges/venues/aster.d.ts +49 -0
- package/dist/exchanges/venues/aster.js +176 -0
- package/dist/exchanges/venues/create-helpers.d.ts +18 -0
- package/dist/exchanges/venues/create-helpers.js +199 -0
- package/dist/exchanges/venues/hyperliquid.d.ts +23 -0
- package/dist/exchanges/venues/hyperliquid.js +126 -0
- package/dist/exchanges/venues/index.d.ts +16 -0
- package/dist/exchanges/venues/index.js +26 -0
- package/dist/exchanges/venues/lighter-family.d.ts +92 -0
- package/dist/exchanges/venues/lighter-family.js +166 -0
- package/dist/exchanges/venues/lighter-rh.d.ts +7 -0
- package/dist/exchanges/venues/lighter-rh.js +58 -0
- package/dist/exchanges/venues/lighter.d.ts +6 -0
- package/dist/exchanges/venues/lighter.js +55 -0
- package/dist/exchanges/venues/ondo.d.ts +34 -0
- package/dist/exchanges/venues/ondo.js +140 -0
- package/dist/exchanges/venues/pacifica.d.ts +8 -0
- package/dist/exchanges/venues/pacifica.js +95 -0
- package/dist/exchanges/venues/qfex.d.ts +28 -0
- package/dist/exchanges/venues/qfex.js +132 -0
- package/dist/execution-log.js +10 -2
- package/dist/funding/legacy-public.d.ts +31 -0
- package/dist/funding/legacy-public.js +369 -0
- package/dist/funding/normalize.d.ts +28 -16
- package/dist/funding/normalize.js +61 -29
- package/dist/funding/rates.d.ts +46 -11
- package/dist/funding/rates.js +228 -277
- package/dist/guardrail/perp-guardrail.js +0 -0
- package/dist/index.js +156 -684
- package/dist/jobs.d.ts +84 -6
- package/dist/jobs.js +239 -41
- package/dist/landing.d.ts +7 -2
- package/dist/landing.js +19 -3
- package/dist/mcp-server.d.ts +14 -4
- package/dist/mcp-server.js +820 -402
- package/dist/mcp-trade-guard.d.ts +16 -0
- package/dist/mcp-trade-guard.js +59 -0
- package/dist/pacifica/client.d.ts +41 -10
- package/dist/pacifica/client.js +167 -63
- package/dist/pacifica/constants.d.ts +0 -1
- package/dist/pacifica/constants.js +0 -5
- package/dist/pacifica/deposit.d.ts +30 -3
- package/dist/pacifica/deposit.js +119 -2
- package/dist/pacifica/faucet.d.ts +29 -0
- package/dist/pacifica/faucet.js +100 -0
- package/dist/pacifica/sign-tx.d.ts +15 -0
- package/dist/pacifica/sign-tx.js +41 -0
- package/dist/pacifica/types/account.d.ts +28 -4
- package/dist/pacifica/types/lake.d.ts +20 -5
- package/dist/pacifica/types/lake.js +4 -0
- package/dist/pacifica/types/market.d.ts +5 -0
- package/dist/pacifica/types/order.d.ts +4 -1
- package/dist/pacifica/types/position.d.ts +9 -1
- package/dist/plan-executor.d.ts +10 -5
- package/dist/plan-executor.js +165 -54
- package/dist/position-history.js +13 -0
- package/dist/rebalance.d.ts +26 -2
- package/dist/rebalance.js +86 -7
- package/dist/relay-swap.d.ts +232 -0
- package/dist/relay-swap.js +630 -0
- package/dist/risk.js +5 -1
- package/dist/secret-env.d.ts +15 -0
- package/dist/secret-env.js +36 -0
- package/dist/settings.d.ts +169 -6
- package/dist/settings.js +219 -38
- package/dist/signer/ows-evm.d.ts +13 -0
- package/dist/signer/ows-evm.js +22 -0
- package/dist/smart-order.d.ts +9 -0
- package/dist/smart-order.js +53 -8
- package/dist/strategies/dca.d.ts +6 -2
- package/dist/strategies/dca.js +66 -26
- package/dist/strategies/funding-arb.d.ts +11 -1
- package/dist/strategies/funding-arb.js +202 -89
- package/dist/strategies/grid.d.ts +31 -0
- package/dist/strategies/grid.js +89 -11
- package/dist/strategies/pending-stop.d.ts +8 -0
- package/dist/strategies/pending-stop.js +12 -0
- package/dist/strategies/split-order.d.ts +45 -17
- package/dist/strategies/split-order.js +157 -91
- package/dist/strategies/trailing-stop.d.ts +2 -1
- package/dist/strategies/trailing-stop.js +52 -6
- package/dist/strategies/twap.d.ts +6 -1
- package/dist/strategies/twap.js +39 -11
- package/dist/trade-validator.d.ts +22 -0
- package/dist/trade-validator.js +119 -15
- package/dist/utils/numeric.d.ts +46 -0
- package/dist/utils/numeric.js +79 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.js +96 -19
- package/dist/withdraw-gate.d.ts +49 -0
- package/dist/withdraw-gate.js +131 -0
- package/package.json +15 -6
- package/skills/perp-cli/SKILL.md +142 -55
- package/skills/perp-cli/references/agent-operations.md +110 -56
- package/skills/perp-cli/references/commands.md +266 -71
- package/skills/perp-cli/references/strategies.md +34 -31
- package/skills/perp-cli/scripts/arb-monitor.sh +10 -5
- package/skills/perp-cli/scripts/funding-analysis.sh +14 -9
- package/skills/perp-cli/scripts/preflight.sh +21 -14
- package/skills/perp-cli/scripts/spot-perp-scan.sh +12 -7
- package/skills/perp-cli/scripts/validate-arb.sh +31 -15
- package/vendor/lighter-signer/SHA256SUMS +2 -0
- package/vendor/lighter-signer/VERSION +8 -0
- package/vendor/lighter-signer/lighter-signer.wasm +0 -0
- package/vendor/lighter-signer/wasm_exec.js +575 -0
- package/dist/bot/strategies/funding-arb-v2-strategy.d.ts +0 -42
- package/dist/bot/strategies/funding-arb-v2-strategy.js +0 -864
|
@@ -4,22 +4,46 @@ Complete reference for non-interactive CLI operations. Every command here is saf
|
|
|
4
4
|
|
|
5
5
|
## Interactive vs Non-Interactive Commands
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Avoid bare interactive forms (they prompt and will hang an agent):
|
|
8
8
|
```
|
|
9
9
|
perp setup # interactive wizard — asks questions via stdin
|
|
10
10
|
perp init # alias for setup
|
|
11
|
-
perp wallet setup #
|
|
11
|
+
perp wallet setup # one-click setup — passphrase prompt
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Agent-safe non-interactive variants:
|
|
15
|
+
```bash
|
|
16
|
+
# Setup wizard with explicit args (no prompts):
|
|
17
|
+
OWS_PASSPHRASE=<pp> perp --json [-n testnet] setup --non-interactive \
|
|
18
|
+
(--wallet <existing-ows-wallet> | --wallet-name <new-name>) \
|
|
19
|
+
[--venues <pacifica,hyperliquid,lighter,aster,lighter-rh,ondo,arcus,qfex>] \
|
|
20
|
+
[--default-venue <venue>] \
|
|
21
|
+
[--slippage-bps <n>] [--slippage <venue>=<bps> ...]
|
|
22
|
+
# Writes settings only. Agent registration signs with the master wallet — only with
|
|
23
|
+
# explicit user consent: add --approve-agents --yes (passphrase via OWS_PASSPHRASE;
|
|
24
|
+
# Ondo key id + secret as 2 stdin lines with --ondo-secret-stdin). A failed venue
|
|
25
|
+
# returns APPROVE_FAILED with per-venue results in error.details.result.agents.
|
|
26
|
+
# No master wallet on this machine: the user creates keys on the exchange websites and
|
|
27
|
+
# pipes them in — --import-agents <venues> --yes (one stdin line per venue in order; ondo
|
|
28
|
+
# 2 lines: key id, secret; qfex 2 lines: public key, secret) [--master-address <venue>=<addr>]
|
|
29
|
+
# (required for aster / pacifica / arcus) [--allow-unverified pacifica] (required for pacifica)
|
|
30
|
+
# [--qfex-account-id <uuid>] (required for qfex) [--lighter-account-index <n> --lighter-api-key-index <n>];
|
|
31
|
+
# omit --wallet. Imported keys trade only: deposit / withdraw / transfer / bridge / referral
|
|
32
|
+
# set / agent approve then fail with NO_SIGNER_AVAILABLE → the user does them on the website.
|
|
33
|
+
|
|
34
|
+
# wallet setup (one-click) only prompts for passphrase — set OWS_PASSPHRASE env to skip:
|
|
35
|
+
OWS_PASSPHRASE=<pp> perp --json wallet setup --name <name> --max-tx-usd <usd> --max-daily-usd <usd>
|
|
12
36
|
```
|
|
13
37
|
|
|
14
38
|
### ALWAYS use these (non-interactive, agent-safe):
|
|
15
39
|
```bash
|
|
16
|
-
perp --json wallet set <exchange>
|
|
40
|
+
printf '%s' "$KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set <exchange> # import key (stdin) into OWS vault → active wallet
|
|
17
41
|
perp --json wallet generate evm # generate EVM wallet
|
|
18
42
|
perp --json wallet generate solana # generate Solana wallet
|
|
19
43
|
perp --json wallet show # check configured wallets
|
|
20
44
|
perp --json wallet list # list named wallets
|
|
21
45
|
perp --json wallet balance # on-chain USDC balances
|
|
22
|
-
perp --json -e <EX>
|
|
46
|
+
perp --json portfolio -e <EX> # per-exchange balance + positions (account balance was renamed in v0.12)
|
|
23
47
|
perp --json -e <EX> account positions # open positions
|
|
24
48
|
perp --json -e <EX> market list # available markets
|
|
25
49
|
perp --json -e <EX> trade market ... # execute trade
|
|
@@ -27,7 +51,7 @@ perp --json -e <EX> trade buy ... # alias for market buy
|
|
|
27
51
|
perp --json -e <EX> trade sell ... # alias for market sell
|
|
28
52
|
perp --json risk status # risk assessment
|
|
29
53
|
perp --json risk liquidation-distance # % from liquidation for all positions
|
|
30
|
-
perp --json risk limits
|
|
54
|
+
perp --json risk limits [--max-position <usd> ...] # view (no flags) / set risk limits
|
|
31
55
|
perp --json risk check --notional <$> --leverage <L> # pre-trade risk check
|
|
32
56
|
```
|
|
33
57
|
|
|
@@ -41,15 +65,15 @@ perp --json risk check --notional <$> --leverage <L> # pre-trade risk check
|
|
|
41
65
|
npm install -g perp-cli@latest
|
|
42
66
|
# or use npx -y perp-cli@latest as the prefix
|
|
43
67
|
|
|
44
|
-
# 2. Register wallet (user provides key)
|
|
45
|
-
perp --json wallet set hl
|
|
68
|
+
# 2. Register wallet (user provides key — on stdin, never argv)
|
|
69
|
+
printf '%s' "$USER_PRIVATE_KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set hl
|
|
46
70
|
|
|
47
71
|
# 3. Verify
|
|
48
72
|
perp --json wallet show
|
|
49
73
|
# → check "ok": true and address appears
|
|
50
74
|
|
|
51
75
|
# 4. Check balance
|
|
52
|
-
perp --json -e
|
|
76
|
+
perp --json portfolio -e hyperliquid
|
|
53
77
|
# → if balance is 0, tell user to deposit USDC
|
|
54
78
|
|
|
55
79
|
# 5. Ready to trade
|
|
@@ -58,24 +82,25 @@ perp --json -e hl market list
|
|
|
58
82
|
|
|
59
83
|
### Multi-Exchange Setup (for Funding Rate Arb)
|
|
60
84
|
To run arb, you need wallets on AT LEAST 2 exchanges. Each exchange needs:
|
|
61
|
-
- A
|
|
85
|
+
- A wallet key in the OWS vault (EVM for HL / Lighter / Aster, Solana for Pacifica)
|
|
62
86
|
- USDC balance deposited on-exchange
|
|
63
87
|
|
|
64
88
|
```bash
|
|
65
|
-
# 1. Register wallets (any 2+ of: hl, pac, lt, aster)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
perp --json wallet set
|
|
69
|
-
perp --json wallet set
|
|
89
|
+
# 1. Register wallets (any 2+ of: hl, pac, lt, aster). The active OWS wallet serves every
|
|
90
|
+
# venue, so EVM + Solana venues need one multi-chain wallet (perp wallet generate <name>)
|
|
91
|
+
# or two vault wallets selected per command with --ows <name>:
|
|
92
|
+
printf '%s' "$EVM_KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set hl --name evm
|
|
93
|
+
printf '%s' "$SOLANA_KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set pac --name sol # now active; HL: --ows evm
|
|
94
|
+
perp --json wallet agent approve lighter # Lighter trading key
|
|
70
95
|
|
|
71
96
|
# 2. Verify
|
|
72
97
|
perp --json wallet show
|
|
73
98
|
|
|
74
99
|
# 3. Check balances (each exchange holds its own balance)
|
|
75
|
-
perp --json -e
|
|
76
|
-
perp --json -e
|
|
77
|
-
perp --json -e
|
|
78
|
-
perp --json -e aster
|
|
100
|
+
perp --json portfolio -e hyperliquid
|
|
101
|
+
perp --json portfolio -e pacifica
|
|
102
|
+
perp --json portfolio -e lighter
|
|
103
|
+
perp --json portfolio -e aster
|
|
79
104
|
|
|
80
105
|
# 4. If one side needs funding, bridge USDC via funds bridge
|
|
81
106
|
perp --json funds bridge quote --from solana --to arbitrum --amount 500
|
|
@@ -90,42 +115,41 @@ perp --json arb scan --min 5
|
|
|
90
115
|
### Lighter API Key Setup
|
|
91
116
|
Lighter uses a separate API key for trading. Two paths:
|
|
92
117
|
|
|
93
|
-
1. **
|
|
118
|
+
1. **No implicit registration**: setting a key (`wallet set lt`, env) never registers a Lighter API key — adapter creation signs nothing. Register explicitly with `perp wallet agent approve lighter`.
|
|
94
119
|
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.
|
|
95
120
|
|
|
96
|
-
|
|
121
|
+
Register / retry:
|
|
97
122
|
```bash
|
|
98
123
|
perp --json wallet agent approve lighter --master <wallet>
|
|
99
124
|
```
|
|
100
125
|
|
|
101
126
|
### Using the Same EVM Key for Multiple Exchanges
|
|
102
|
-
One EVM private key works for
|
|
127
|
+
One EVM private key works for Hyperliquid, Lighter and Aster — `wallet set` imports it once as the active OWS wallet:
|
|
103
128
|
```bash
|
|
104
|
-
perp --json wallet set hl
|
|
105
|
-
perp --json wallet set lt 0xKEY # same key, different exchange binding
|
|
129
|
+
printf '%s' "$KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set hl
|
|
106
130
|
```
|
|
107
131
|
|
|
108
132
|
## Wallet Key Types
|
|
109
133
|
|
|
110
|
-
|
|
|
111
|
-
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
134
|
+
| Venue (`-e` id \| aliases) | Settles on | Credentials |
|
|
135
|
+
|----------|-------|-----------|
|
|
136
|
+
| `pacifica` \| `pac` | Solana | Solana key (`wallet set pac`), or agent (`wallet agent approve/import pacifica`) |
|
|
137
|
+
| `hyperliquid` \| `hl` | HyperCore (deposit from Arbitrum) | EVM key, or API wallet agent |
|
|
138
|
+
| `lighter` \| `lt` | Ethereum (Lighter L2) | EVM master + API key (`wallet agent approve lighter` / `import`) |
|
|
139
|
+
| `lighter-rh` \| `lrh` \| `rh` | Robinhood Chain (USDG) | API key (`wallet agent approve lighter-rh` / `import`) |
|
|
140
|
+
| `aster` \| `ast` | BNB Chain / Arbitrum | EVM key, or API wallet agent |
|
|
141
|
+
| `ondo` \| `ondo-perps` | off-chain (USDC deposits from Arbitrum / Ethereum) | API key id + secret (stdin) |
|
|
142
|
+
| `arcus` | Robinhood Chain (USDG) | Ed25519 API key (`wallet agent approve arcus --master <w>` / `import`) |
|
|
143
|
+
| `qfex` \| `qf` | custodial (USDC on Arbitrum One) | website key, imported by the user only (`wallet agent import qfex`) |
|
|
116
144
|
|
|
117
|
-
|
|
118
|
-
- `pac` or `pacifica`
|
|
119
|
-
- `hl` or `hyperliquid`
|
|
120
|
-
- `lt` or `lighter`
|
|
121
|
-
- `aster`
|
|
145
|
+
Default `-e` = `settings.defaultExchange`, else `pacifica` — always pass `-e`.
|
|
122
146
|
|
|
123
147
|
## Deposit & Withdraw Flows
|
|
124
148
|
|
|
125
149
|
### Check On-Chain vs Exchange Balance
|
|
126
150
|
```bash
|
|
127
151
|
perp --json wallet balance # on-chain USDC in your wallet
|
|
128
|
-
perp --json -e
|
|
152
|
+
perp --json portfolio -e hyperliquid # USDC deposited on exchange
|
|
129
153
|
```
|
|
130
154
|
|
|
131
155
|
**On-chain balance ≠ exchange balance.** USDC in your wallet must be deposited to the exchange before trading.
|
|
@@ -146,16 +170,19 @@ perp --json funds deposit lighter cctp arbitrum 100 # via CCTP from Arbitrum (
|
|
|
146
170
|
|
|
147
171
|
### Withdraw from Exchange (`funds withdraw`)
|
|
148
172
|
```bash
|
|
149
|
-
perp --json funds withdraw hyperliquid 100
|
|
150
|
-
perp --json funds withdraw
|
|
151
|
-
perp --json funds withdraw
|
|
173
|
+
perp --json --dry-run funds withdraw hyperliquid 100 # plan first (every withdraw supports --dry-run)
|
|
174
|
+
perp --json funds withdraw hyperliquid 100 [--chain arbitrum|ethereum|base] # CCTP to your own wallet
|
|
175
|
+
perp --json funds withdraw pacifica 100 # to your own Solana wallet
|
|
176
|
+
perp --json -e lighter funds withdraw lighter 100 # USDC → Ethereum (-e lighter-rh: USDG → Robinhood Chain)
|
|
152
177
|
```
|
|
153
178
|
|
|
154
179
|
### Internal Transfer (Hyperliquid)
|
|
155
180
|
```bash
|
|
156
|
-
perp --json funds transfer 100 <ADDRESS> # instant HL→HL
|
|
181
|
+
perp --json funds transfer 100 <ADDRESS> # instant HL→HL transfer
|
|
157
182
|
```
|
|
158
183
|
|
|
184
|
+
`funds transfer` and `funds withdraw hyperliquid --to <other address>` require the destination on the `settings withdraw.hyperliquid` allowlist (else `POLICY_DENIED`). That setting can be created / changed ONLY by the user in an interactive terminal (`--json` / piped → `POLICY_DENIED`, no `--yes`). Never try to set it; ask the user.
|
|
185
|
+
|
|
159
186
|
### Bridge Between Chains (`funds bridge`)
|
|
160
187
|
When you need to move USDC between chains (different networks):
|
|
161
188
|
```bash
|
|
@@ -176,13 +203,15 @@ perp --json funds bridge status <orderId>
|
|
|
176
203
|
perp --json funds deposit hyperliquid 500
|
|
177
204
|
```
|
|
178
205
|
|
|
179
|
-
### Inter-Exchange Rebalance (
|
|
206
|
+
### Inter-Exchange Rebalance (withdraw → bridge; deposit is manual)
|
|
180
207
|
```bash
|
|
181
208
|
perp --json funds rebalance check # current distribution
|
|
182
209
|
perp --json funds rebalance plan # compute optimal moves
|
|
183
|
-
perp --json funds rebalance execute --auto-bridge
|
|
210
|
+
perp --json --dry-run funds rebalance execute --auto-bridge # status "simulated" or "balanced"
|
|
211
|
+
perp --json funds rebalance execute --auto-bridge # withdraw → bridge only — NO deposit
|
|
184
212
|
perp --json funds rebalance execute --withdraw-only # only withdraw, manual rest
|
|
185
213
|
```
|
|
214
|
+
The envelope is `ok:true` even when a move failed: check every `moves[].status` (`withdrawn`, `bridged`, `same_chain`, `needs_bridge`, `withdraw_failed`, `bridge_failed`). Deposit by hand (`funds deposit <venue> <amt>`) after `funds bridge status` confirms arrival.
|
|
186
215
|
|
|
187
216
|
## Order Types & Execution
|
|
188
217
|
|
|
@@ -195,6 +224,14 @@ perp --json -e hl trade sell BTC 0.01 # shorthand
|
|
|
195
224
|
perp --json -e hl trade buy BTC 0.01 --smart # IOC limit at best ask (less slippage)
|
|
196
225
|
```
|
|
197
226
|
|
|
227
|
+
> **Risk gate:** `trade market / buy / sell / limit / split / market --split / scale-in /
|
|
228
|
+
> twap / multi / stop --no-reduce-only` enforce the local risk limits in `~/.perp/risk.json`
|
|
229
|
+
> (`maxPositionUsd` / `maxTotalExposureUsd` / `maxPositions`, set with `perp risk limits
|
|
230
|
+
> --max-position <usd> --max-exposure <usd> --max-positions <n>` or the `-pct` variants).
|
|
231
|
+
> A breach fails with `RISK_VIOLATION`, also in dry-run. `--force` overrides the limits —
|
|
232
|
+
> only with explicit user consent; it NEVER bypasses a quarantine (also `RISK_VIOLATION`).
|
|
233
|
+
> Reduce-only orders are exempt. Defaults are loose (`maxPositionUsd` 100000).
|
|
234
|
+
|
|
198
235
|
### Split Orders (orderbook-aware, for large orders)
|
|
199
236
|
```bash
|
|
200
237
|
perp --json -e hl trade split BTC buy 5000 # split $5000 into depth-based slices
|
|
@@ -207,8 +244,8 @@ Status: `complete` (all filled), `partial` (some filled), `failed` (none filled)
|
|
|
207
244
|
### Limit / Stop / TPSL
|
|
208
245
|
```bash
|
|
209
246
|
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
|
|
247
|
+
perp --json -e hl trade stop BTC sell 0.01 58000 # stop sell at $58k (reduce-only by default)
|
|
248
|
+
perp --json -e hl trade tpsl BTC long --tp 65000 --sl 58000 # long|short = the OPEN position's side
|
|
212
249
|
```
|
|
213
250
|
|
|
214
251
|
### Close / Reduce
|
|
@@ -225,7 +262,7 @@ perp --json -e hl account orders # list open orders
|
|
|
225
262
|
perp --json -e hl trade cancel BTC # cancel by symbol
|
|
226
263
|
perp --json -e hl trade cancel <orderId> # cancel specific order
|
|
227
264
|
perp --json -e hl trade cancel-all # cancel all orders
|
|
228
|
-
perp --json -e
|
|
265
|
+
perp --json -e pac trade cancel-stop BTC <stopId> # cancel stop order (pacifica / qfex; other venues: trade cancel)
|
|
229
266
|
perp --json -e hl trade cancel-twap BTC <twapId> # cancel TWAP order
|
|
230
267
|
```
|
|
231
268
|
|
|
@@ -261,13 +298,19 @@ Error case:
|
|
|
261
298
|
}
|
|
262
299
|
```
|
|
263
300
|
|
|
264
|
-
**Always check `ok` field first
|
|
301
|
+
**Always check `ok` field first** (`ok:false` also exits 1). If `ok` is `false`, read `error.code` and follow `error.remediation`. If `error.retryable` is `true` AND the command is read-only, wait 5 seconds and retry once. Never retry a write — writes surface an unknown outcome as `ORDER_PENDING` (non-retryable).
|
|
302
|
+
|
|
303
|
+
In scripts, capture exactly one JSON document and read `.ok` — do NOT append a fallback (`$(perp … || echo '{"ok":false}')` yields two documents on failure):
|
|
304
|
+
```bash
|
|
305
|
+
out=$(perp --json -e hl account positions 2>/dev/null; true)
|
|
306
|
+
jq -e '.ok == true' >/dev/null <<<"$out" || echo "failed: $(jq -r '.error.code // "no output"' <<<"$out")"
|
|
307
|
+
```
|
|
265
308
|
|
|
266
309
|
## Idempotency & Safety
|
|
267
310
|
|
|
268
311
|
### Safe to retry (idempotent):
|
|
269
312
|
- `wallet show`, `wallet list`, `wallet balance` — read-only
|
|
270
|
-
- `
|
|
313
|
+
- `portfolio`, `portfolio -e <ex>`, `account positions`, `account orders`, `account margin` — read-only (note: `account balance` was renamed to `portfolio` in v0.12)
|
|
271
314
|
- `market list`, `market mid`, `market book`, `market info`, `market funding` — read-only
|
|
272
315
|
- `arb scan` (any mode), `arb status`, `arb history`, `arb config` — read-only
|
|
273
316
|
- `portfolio`, `risk status`, `risk liquidation-distance` — read-only
|
|
@@ -280,12 +323,15 @@ Error case:
|
|
|
280
323
|
- `funds bridge send` — will send duplicate transfers
|
|
281
324
|
- `funds deposit *`, `funds withdraw *`, `funds transfer` — will move funds twice
|
|
282
325
|
- `arb exec`, `arb close`, `arb auto` — open/close real positions
|
|
283
|
-
- `funds rebalance execute` —
|
|
326
|
+
- `funds rebalance execute` — sends withdrawals / bridges
|
|
284
327
|
|
|
285
328
|
**For non-idempotent commands:** always verify the result before retrying. Check positions or balances to confirm whether the first attempt succeeded.
|
|
286
329
|
|
|
330
|
+
### Unknown outcome (`ORDER_PENDING`) — every write
|
|
331
|
+
Orders, cancels, edits, leverage, withdraw / deposit / bridge / transfer: `ORDER_PENDING` means the request was sent and its outcome is unknown. Do NOT resubmit. Check, in order: `perp --json -e <ex> trade status c:<id> --symbol <SYM>` (id from `remediation`), `account orders` / `account positions` / `portfolio`, the tx hash / request id in `error.details` (`funds bridge status <id>`). Unknown arb / bot / close / multi outcomes also quarantine the symbol (`perp --json strategy quarantine`); only the user clears it after verifying (`strategy quarantine-clear <SYM>`).
|
|
332
|
+
|
|
287
333
|
### Idempotency Key
|
|
288
|
-
|
|
334
|
+
`--client-id <id>` / `--auto-id` on `trade market/buy/sell/limit`. An id already recorded locally (`~/.perp/client-ids.jsonl`, not marked failed) returns `ok:true` with `data.duplicate: true` and sends nothing — this is local tracking, not a venue-side check and not an error. Formats: Pacifica a full UUID; Hyperliquid `0x` + 32 hex; Lighter / Lighter RH an integer; QFEX refuses `--client-id` (`CAPABILITY_UNSUPPORTED`; `--auto-id` works). `--client-id`/`--auto-id` with `--smart` → `CAPABILITY_UNSUPPORTED`.
|
|
289
335
|
|
|
290
336
|
## Symbol Naming Across Exchanges
|
|
291
337
|
|
|
@@ -303,20 +349,24 @@ Symbols are auto-resolved by the CLI. **Always use bare symbols** (e.g., `BTC`,
|
|
|
303
349
|
|
|
304
350
|
## Exchange-Specific Constraints
|
|
305
351
|
|
|
306
|
-
|
|
|
307
|
-
|
|
308
|
-
| Pacifica |
|
|
309
|
-
| Hyperliquid | **$10**
|
|
310
|
-
| Lighter |
|
|
311
|
-
| Aster |
|
|
352
|
+
| Venue | Notes |
|
|
353
|
+
|-------|-------|
|
|
354
|
+
| Pacifica | client ids = full UUID; `cancel-stop` / native TWAP (seconds) |
|
|
355
|
+
| Hyperliquid | **$10** min order; prices ≤ 5 significant figures (off-grid → `INVALID_TICK`); native TWAP in minutes, min $100 |
|
|
356
|
+
| Lighter / Lighter RH | min varies by symbol (`market info`); `trade status c:<id>` needs `--symbol` |
|
|
357
|
+
| Aster | funding interval per symbol; `trade status c:<id>` needs `--symbol` |
|
|
358
|
+
| Ondo / Arcus | `trade status` needs `--symbol`; restricted-region notice on stderr |
|
|
359
|
+
| QFEX | `--client-id` refused; no resting reduce-only limits, opening stops or automation; funding unverified (display only) |
|
|
360
|
+
|
|
361
|
+
`--smart` only on pacifica / hyperliquid / lighter / aster. Stops are reduce-only by default; `--no-reduce-only` is refused on ondo / qfex. Limit and trigger prices off the venue grid are refused with `INVALID_TICK`, never rounded.
|
|
312
362
|
|
|
313
363
|
**`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.
|
|
314
364
|
|
|
315
365
|
## Common Agent Mistakes
|
|
316
366
|
|
|
317
|
-
1. **Using `perp setup` / `perp init` / `perp wallet setup`** — interactive, will hang forever. Use `wallet set` instead.
|
|
367
|
+
1. **Using `perp setup` / `perp init` / `perp wallet setup`** — interactive, will hang forever. Use `wallet set` (key on stdin) or `setup --non-interactive` instead.
|
|
318
368
|
2. **Forgetting `--json`** — output becomes unparseable human text.
|
|
319
|
-
3. **Trading with zero balance** — check `
|
|
369
|
+
3. **Trading with zero balance** — check `perp --json portfolio -e <ex>` first, tell user to deposit.
|
|
320
370
|
4. **Retrying a trade without checking** — leads to double positions. Always check `account positions` after a trade, even if it seemed to fail.
|
|
321
371
|
5. **Bridging without quoting** — always run `funds bridge quote` first to show the user fees and estimated time.
|
|
322
372
|
6. **Assuming deposit is instant** — after `funds bridge send`, wait for `funds bridge status` to confirm completion before depositing to the destination exchange.
|
|
@@ -324,3 +374,7 @@ Symbols are auto-resolved by the CLI. **Always use bare symbols** (e.g., `BTC`,
|
|
|
324
374
|
8. **Order below exchange minimum** — Hyperliquid requires $10+ notional. Compute `size × price` before submitting.
|
|
325
375
|
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
376
|
10. **Calling `trade check` without `--leverage`** — the CLI does not read exchange-set leverage, so cost estimates will be wrong.
|
|
377
|
+
11. **Resubmitting after `ORDER_PENDING`** — the first request may have executed. Check status / positions / tx first.
|
|
378
|
+
12. **Working around `CAPABILITY_UNSUPPORTED`** (another order type, venue or emulation) — report it to the user instead.
|
|
379
|
+
13. **`--dry-run` on a command without dry-run support** → `INVALID_PARAMS` (e.g. `trade twap`, `trade multi`, `strategy grid`, `wallet agent approve`). Simulate bots with `perp --json --dry-run strategy run <s>` or `perp --json --dry-run arb auto`.
|
|
380
|
+
14. **Omitting `-e`** — the default venue is `settings.defaultExchange`, else `pacifica`.
|