perp-cli
Multi-DEX perpetual futures trading via the perp-cli command-line tool. Use when user asks to: trade perps, check funding rates, scan/execute arbitrage (perp-perp or spot-perp), run delta-neutral strategies, bridge USDC across chains, manage positions/orders/leverage, deposit/withdraw, hedge spot+perp, trade HIP-3 DEXes, read Derive options chains, use Pacifica Print or Pacifica vaults, or mentions perp-cli, hypurrquant, Pacifica, Hyperliquid, Lighter, Aster, Lighter RH, Ondo Perps, Arcus, QFEX, RISEx, TxFlow, Variational, GRVT, Extended, Derive, HyperEVM, funding arb, or U-tokens (UBTC/UETH/USOL). Covers Pacifica (Solana), Hyperliquid (HyperEVM), Lighter (Ethereum), Aster (BNB Chain), Lighter RH and Arcus (Robinhood chain), Ondo Perps and QFEX (off-chain), RISEx (RISE chain), TxFlow (manual trading; mainnet whitelisted; official API in Beta), Variational Omni (market data only, official API), GRVT and Extended (Starknet) (market data only for now, official API), Derive options (read-only), and Pacifica Print / vaults.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- perp-cli
- license
- MIT
- metadata
- { "author": "hypurrquant", "version": "0.17.0" }
- description
- Multi-DEX perpetual futures trading via the perp-cli command-line tool. Use when user asks to: trade perps, check funding rates, scan/execute arbitrage (perp-perp or spot-perp), run delta-neutral strategies, bridge USDC across chains, manage positions/orders/leverage, deposit/withdraw, hedge spot+perp, trade HIP-3 DEXes, read Derive options chains, use Pacifica Print or Pacifica vaults, or mentions perp-cli, hypurrquant, Pacifica, Hyperliquid, Lighter, Aster, Lighter RH, Ondo Perps, Arcus, QFEX, RISEx, TxFlow, Variational, GRVT, Extended, Derive, HyperEVM, funding arb, or U-tokens (UBTC/UETH/USOL). Covers Pacifica (Solana), Hyperliquid (HyperEVM), Lighter (Ethereum), Aster (BNB Chain), Lighter RH and Arcus (Robinhood chain), Ondo Perps and QFEX (off-chain), RISEx (RISE chain), TxFlow (manual trading; mainnet whitelisted; official API in Beta), Variational Omni (market data only, official API), GRVT and Extended (Starknet) (market data only for now, official API), Derive options (read-only), and Pacifica Print / vaults.
- allowed-tools
- Bash(perp:*), Bash(bash scripts/preflight.sh:*), Bash(bash scripts/arb-monitor.sh:*), Bash(bash scripts/funding-analysis.sh:*), Bash(bash scripts/spot-perp-scan.sh:*), Bash(bash scripts/validate-arb.sh:*)
- compatibility
- Requires Node.js 20 or newer and the perp-cli npm package installed by the user (version must be >= 0.17.0; the user runs `npm install -g perp-cli` — never install it yourself). Network access required for exchange APIs and bridge providers. Mutating commands need a wallet key imported into the OWS vault via 'perp wallet set EXCHANGE' (key on stdin or hidden prompt — never argv). Skill is portable across Claude Code, Claude.ai, Cursor, Codex, and Gemini CLI — no platform-specific features.
02 资源文件 13
- 许可证LICENSE1.0 KB
- 参考文档package.json931 B
- 参考文档references/agent-operations.md22.7 KB
- 参考文档references/commands.md55.4 KB
- 参考文档references/strategies.md24.7 KB
- 参考文档references/ws-library.md34.5 KB
- 脚本scripts/arb-monitor.sh2.9 KB
- 脚本scripts/funding-analysis.sh5.2 KB
- 脚本scripts/preflight.sh4.3 KB
- 脚本scripts/spot-perp-scan.sh4.1 KB
- 脚本scripts/validate-arb.sh6.3 KB
- 参考文档SOURCE.md194 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
perp-cli
Multi-DEX perpetual futures CLI + MCP server for Pacifica (Solana), Hyperliquid (HyperEVM), Lighter (Ethereum), Aster (BNB Chain), Lighter RH (lighter-rh, Robinhood chain, USDG), Ondo Perps (ondo), QFEX (qfex, custodial TradFi perps — import-only API key; resting reduce-only limits and automation are refused for now, see "QFEX" below), Arcus (arcus, Robinhood chain, USDG), RISEx (risex|rise, RISE chain, USDC — trading through a trading-only session signer, not yet verified on mainnet; deposits / withdrawals in the RISEx app only, see "RISEx" below), TxFlow (txflow|txf, official API (Beta) — manual trading with an approved agent key, verified on testnet only; mainnet whitelisted; see "TxFlow" below), Variational Omni (variational|var|omni, MARKET DATA ONLY through its official read-only API — RFQ venue, no public trading API yet, see "Variational" below), GRVT (grvt|grv, MARKET DATA ONLY in this version through its official API — trading is planned for a later release, see "GRVT" below), Extended (extended|ext|x10, Starknet, formerly X10 — MARKET DATA ONLY in this version through its official public API, see "Extended" below). v0.13.0+ also supports Hyperliquid Outcome markets (HIP-4) — fully-collateralized binary/range contracts; each outcome's quote token comes from outcomeMeta.quoteToken (USDC on every listed outcome as of 2026-10-12), minimum order value 10 quote tokens.
Instructions
When to use this skill
Activate whenever the user wants to do anything against perp-cli, including: scanning funding-rate arbitrage, executing perp-perp or spot+perp legs, running long-running strategy bots, moving USDC between chains/exchanges, checking account/portfolio state, configuring wallets, or troubleshooting any of the above.
Do NOT answer trading questions from memory — always run the actual CLI command and parse its JSON output.
Reference files (load only when needed)
This skill uses progressive disclosure. Read these on demand:
references/commands.md— full command tree for every group (market, account, trade, outcome, options, print, vault, arb, funds, wallet, risk, history, strategy, background, alerts, settings, backtest)references/agent-operations.md— non-interactive setup flows, idempotency rules, error codes, common mistakesreferences/strategies.md— funding-arb decision framework + risk-management playbook (read before designing arb strategy)references/ws-library.md— WebSocket library (shipped since 0.15.0, @experimental), published standalone as@hypurrquant/perp-ws(zero dependencies; recommended for integrators —npm install @hypurrquant/perp-ws) and inside perp-cli asperp-cli/ws(same code, use it when perp-cli is already installed): build a live dashboard / funding comparison / account feed in the browser or Node (streams, events, nullability, comparator, user channels, errors, capability matrix). Cross-venue subscriptions usecanonicals(e.g.{ kind: "allMarkets", canonicals: ["BTC"] }), neversymbols(those are per-venue directory symbols); always surfacereadyrejections — anidlevenue is not "fine"
Also bundled under scripts/: preflight.sh, arb-monitor.sh, funding-analysis.sh, spot-perp-scan.sh, validate-arb.sh. Use these for repeatable multi-step diagnostics. They need perp on PATH (else they exit 1 with PERP_NOT_FOUND — ask the user to install it) and exit non-zero on a failed read; funding-analysis.sh / spot-perp-scan.sh take -n mainnet|testnet, spot-perp-scan.sh --no-portfolio scans without a wallet.
Critical rules
- Always pass
--json. Without it, output is human-formatted and hard to parse.ok:falsealso exits 1. - Always pass
-e <venue>on venue-scoped commands. The default issettings.defaultExchange, elsepacifica— never rely on it. - Always run
--dry-runfirst for any mutating command that supports it, show the result, get user confirmation, then execute without--dry-run.--helpis NOT a reliable indicator — the 0.16.0 list: everytradewrite (market / buy / sell / limit / split / cancel / cancel-all / stop / tpsl / scale-tp / scale-in / edit / atomic / leverage / close / close-all / flatten / reduce / spot-buy / spot-sell / spot-limit / spot-cancel / spot-transfer),arb exec|close|auto|rebalance,funds deposit|withdraw|transfer|faucet|bridge send|bridge exchange|rebalance execute|address-book add,outcome buy|sell,print deposit|cancel,vault deposit|withdraw,wallet builder approve|revoke,wallet manage referral set,strategy run,strategy plan execute. Everything else (read-only commands too;trade twap|multi|cancel-stop|cancel-twap; the moved stubswallet manage lake deposit|withdraw→ usevault deposit|withdraw) refuses--dry-runwithINVALID_PARAMS— that refusal means "unsupported", nothing ran (see "Safety rules"). - Always use
--fieldswhen you only need specific data — saves tokens. - Avoid bare
perp setup/perp init/perp wallet setup— they prompt and will hang an agent. Useprintf '%s' "$KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set <exchange>for key registration (key on stdin; a key on argv or-kis rejected), orperp --json setup --non-interactive --wallet <ows-wallet> --venues <list> [--default-venue <v>] [--slippage-bps <n>] [--slippage <venue>=<bps>](new wallet:--wallet-name <name>with the passphrase inOWS_PASSPHRASE; agent registration only with--approve-agents --yes, after user confirmation) (andOWS_PASSPHRASE=<pp> perp wallet setup --name <n> --max-tx-usd <usd> --max-daily-usd <usd>) when the wizard is required. The passphrase goes inOWS_PASSPHRASEor stdin — the root--passphraseflag is deprecated (visible inps). - NEVER trade without explicit user confirmation. A dry-run is not consent.
- NEVER read
~/.perp/.envor other key files. The CLI reads them — you should not. - NEVER manually add
-PERPsuffix to symbols. Use bare names (BTC,SOL,ICP); the CLI resolves exchange-specific naming. - NEVER resubmit after
ORDER_PENDING(or any unknown outcome). See "Safety rules".
Step 1: Verify install, version, venue health
perp --version # must be >= 0.17.0
perp --json health # keyless venue connectivity
If perp is missing or older, STOP and ask the user to install / upgrade it (npm install -g perp-cli) — never install it yourself and never switch to npx. health: data.healthy = every OFFICIAL-API venue is up (use this); allHealthy also counts unofficial APIs (listed under unofficial[]; none at present). Market-data-only venues (e.g. TxFlow) count toward healthy too — a venue you are not using being down is not a reason to stop; skipped[] = venues with no environment on this network (not probed). Don't use a venue whose exchanges[].status is not "ok".
Step 2: Verify wallet + balance
perp --json wallet show # with an OWS wallet, `exchanges: []` is normal — owsActiveWallet serves every venue
perp --json portfolio -e <venue> # per-exchange perp.available (aliases like hl / pac accepted)
If any required exchange is missing, register it (user supplies the key):
printf '%s' "$EVM_HEX_KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set hl # Hyperliquid / Lighter / Aster (EVM)
printf '%s' "$SOLANA_BASE58_KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set pac # Pacifica (Solana)
The key is read from stdin (never argv — an argv key is rejected) and imported into the OWS vault; the imported wallet becomes owsActiveWallet, which serves every venue. The same EVM key works for Hyperliquid, Lighter and Aster. Lighter trading additionally needs perp wallet agent approve lighter.
Lighter RH / Ondo Perps / Arcus have no wallet set path — register an agent / API key (user runs it; Ondo reads key id + secret from stdin):
perp --json wallet agent approve lighter-rh
printf '%s\n%s\n' "$KEY_ID" "$SECRET" | perp --json wallet agent approve ondo
perp --json wallet agent approve arcus --master <ows-wallet> # address must be on the Arcus access whitelist
No master wallet on this computer? The user can create the agent / API key on the exchange website and import it — key on stdin only, verified against the venue before it is stored (verification.status is "unverified" only for Pacifica, which lists bindings master-signed only):
printf '%s' "$AGENT_KEY" | perp --json wallet agent import hyperliquid # master read from HL
printf '%s' "$AGENT_KEY" | perp --json wallet agent import aster --master-address 0x… # also Aster testnet
printf '%s' "$AGENT_KEY" | perp --json wallet agent import pacifica --master-address <SOL>
printf '%s' "$API_KEY" | perp --json wallet agent import lighter --account-index <n> --api-key-index <slot>
printf '%s' "$ED25519_KEY" | perp --json wallet agent import arcus --master-address 0x…
Imported keys trade; funds deposit|withdraw|transfer|bridge, wallet manage referral set and wallet agent approve need the master → NO_SIGNER_AVAILABLE (tell the user to do it on the website or perp wallet import the master). wallet agent revoke of an imported key needs --local-only and does NOT revoke it on the exchange; rotate is refused (new key on the website → import --replace).
QFEX (-e qfex, testnet = QFEX UAT): keys are created on the QFEX website and imported by the USER (perp wallet agent import qfex [--account-id <uuid>] — the resolved account UUID must be confirmed). Rules an agent must follow:
- Works: market / IOC reduce-only closes (
trade close/close-all/flatten/reduce), reduce-only stop-market orders (trade stop,trade tpslTP/SL legs,--tp/--slas separate stops after the verified fill; cancel withtrade cancel <S> <id>ortrade cancel-stop),trade editof a plain LIMIT / ALO (the venue assigns a new order id; the client id is kept). - Refused with
CAPABILITY_UNSUPPORTED(do not work around): resting reduce-only limits (GTC / ALO / FOK,scale-tp), stop-limit and opening stops, amend of a reduce-only order,--client-id, non-USD-quoted markets, unattended automation (bots / plans / TWAP / DCA / grid / background jobs), QFEX as a funding-arb / funding-bot leg. - After a close, reduce-only / stop orders left on a now-flat symbol are listed as a WARNING (the venue does not cancel them) — cancel them, or use
trade flatten, which cancels them. - Limit GTC / ALO returns
status: accepted, finality: pendingafter the ACK;openonly viaperp --json trade status c:<id> --symbol <S> -e qfex. ORDER_PENDING= outcome unknown: NEVER resubmit; check with thec:<id>in the remediation.- Funding rates on QFEX are unverified: excluded everywhere unless
perp --json arb scan --rates --include-unverified(display only). - Withdrawals are disabled in perp-cli for now:
funds withdraw qfex→CAPABILITY_UNSUPPORTED(also under--dry-run). Withdraw in the QFEX web app. Ondo Perps has no API withdrawals either.
RISEx (-e risex, testnet = -n testnet, official API): orders are signed by a session SIGNER that the user registers with the master wallet (perp wallet agent approve risex --master <ows-wallet> [--expires-in 30d], default 30 days). Mainnet RISEx trading has NOT been verified with real funds yet (testnet-verified 2026-10-14): ask the user before placing mainnet RISEx orders. Rules an agent must follow:
- Approve = master signs RegisterSigner (+ the new signer's VerifySigner), then the signer is restricted ON-CHAIN to trading only (it signs DisablePermission for every other permission; the MASTER sends those transactions and needs a little ETH on RISE chain for gas —
INSUFFICIENT_BALANCEbefore anything is registered otherwise). Only the master can re-enable a permission. If the restriction fails, the signer is revoked automatically;APPROVE_PARTIALmeans it could not be — tell the user to revoke it in the RISEx app. - Never interrupt
wallet agent approve risex(no Ctrl-C, no timeout kill, no closing the terminal): between registration and the last DisablePermission transaction the signer briefly holds FULL permissions (including fund movement). If it was interrupted anyway: runperp --json wallet agent verify risex—POLICY_DENIEDor an unknown signer means revoke it now (perp wallet agent revoke risex <name>, or in the RISEx app for a signer perp-cli did not record), then approve again. - Trading-only is proven from the raw on-chain permission bitmap (the bits of permissions 0, 3 and 4 clear and trading's set; permission 1 is the "all" mask and is never disabled — doing so would wipe trading too), cross-checked with
hasPermission(exactly {trading}) and the key's status and expiry, the reviewed Authorization, Router and AccountRegistry contract versions, and the absence of any newer permission id — at approve (before the signer is registered), atverify, and before signed actions (re-checked at least every 60 s in long-running processes). If RISEx upgrades any of those contracts or adds a permission, every RISEx signed action — including cancel and cancel-all — is refused (POLICY_DENIED) until perp-cli is updated; manage open orders and positions in app.rise.trade meanwhile, and revoke withperp wallet agent revoke risex <name>if in doubt. Do not work around it. - Residual risk: those contracts are upgradeable by RISEx's admin keys, so RISEx itself can change what a registered signer may do. perp-cli only detects it (fail closed); the gap between an upgrade and the next check is not covered.
wallet agent import risexis refused (CAPABILITY_UNSUPPORTED): an app-created signer keeps fund-movement permissions.wallet agent verify risexre-reads the on-chain permissions;wallet agent revoke risex <name>revokes with the master.- Deposits and withdrawals are app-only:
funds deposit|withdraw risex→CAPABILITY_UNSUPPORTED(also under--dry-run), remediation app.rise.trade. Testnet only:perp -n testnet funds faucet risex(1000 test USDC, once). - Works: market (IOC within
--slippage-bps, which must fit the market's match price band, 2% on mainnet today), limit GTC / IOC / FOK / ALO (post-only), reduce-only, cancel, cancel-all, leverage, margin mode (refused while a position is open),trade status c:<id>. Sizes / prices must sit exactly on the step / tick grid (INVALID_TICK, never rounded). Client ids are uint64 decimals (generated when omitted). - Not supported: TP/SL / stops (RISEx executes them from the venue backend against an account-signed OperatorHub spending allowance, outside the trading-only signer — perp-cli does not grant it; set TP/SL in the RISEx app), amend, builder fee (
CAPABILITY_UNSUPPORTED). Bots / TWAP / grid / background jobs /strategy …on RISEx are refused (CAPABILITY_UNSUPPORTED, "unattended trading on RISEx is not enabled until its trading path is verified on mainnet") — trade RISEx manually. - Account reads (
portfolio,account balance|positions|orders|history|trades|funding-history) work with only the master address selected (public by address) — no signer needed. ORDER_PENDING= outcome unknown (the symbol is quarantined): NEVER resubmit; check withperp --json trade status c:<id> --symbol <S> -e risex. Each signed action uses a fresh permit nonce that is never reused.- Funding: hourly,
current_funding_rate= the last settled hourly print (verified against funding payments).
TxFlow (-e txflow, testnet = -n testnet, official API in Beta): manual trading is on. It was verified on testnet only — no mainnet TxFlow order has been run yet; tell the user before their first mainnet TxFlow order. Trading uses an AGENT key the master approves (perp wallet agent approve txflow --master <ows>, or wallet agent import txflow; wallet agent verify txflow checks it read-only). Rules:
- Mainnet
/exchangeis whitelisted: a refusal isPOLICY_DENIEDwith "apply at https://txflow.com/apply" — tell the user; never retry. Testnet is open; an unfunded account isDEPOSIT_REQUIRED(fund it in the TxFlow web app). - Works: market data (
market list|prices|info|book|trades|kline), account reads (portfolio,account positions|orders|history|trades|funding),trade market|buy|sell|limit(TIF GTC / IOC / ALO; FOK refused),trade cancel|cancel-all|close|reduce|flatten,trade edit(price + new TOTAL size, same order id),trade stop(reduce-only trigger on the MARK price),--tp/--slon a market / IOC entry (legs placed after the verified fill),trade tpsl,trade leverage [--isolated],trade status c:<id> --symbol <S>, MCPget_balance|get_positions|get_open_orders|trade_*. - The venue's answer never says filled / resting: perp-cli reads the order back by its client id.
status: accepted, finality: pending= executed but not visible yet — check withtrade status c:<id>.ORDER_PENDING= outcome unknown: NEVER resubmit. - Refused with
CAPABILITY_UNSUPPORTEDbefore anything is sent:funds deposit|withdraw txflow,funds transfer -e txflow,funds rebalance(the user moves funds in the TxFlow web app); builder codes; everystrategy …/ bot / TWAP / background job (automation gate);arb exec|autolegs; hedge-mode accounts;account positions --address(no keyless reads for TxFlow). - Funding is percent per hour on the venue, shown as a FRACTION per hour, and is UNVERIFIED — display only (
arb scan --rates --include-unverified);market funding(history) is refused.
Variational (-e variational, aliases var, omni): Variational Omni, read-only (market data) in perp-cli through its OFFICIAL documented API (GET /metadata/v2/stats, one call for all ~575 markets, cached ~5 s; venue limit 10 requests / 10 s per IP). Variational has no public trading API yet. It is an RFQ venue: one market maker (the OLP) quotes every trade — there is no order book.
- Works:
market list|prices|info|funding|book -e variational,perp health(official), and Variational rows inperp --json arb scan --rates --include-unverified/--compare <sym> --include-unverifiedonly — display only, never ranked or traded: funding is UNVERIFIED (a moving predicted rate, not checked against settled payments).US500-PERPis the SPDR S&P 500 ETF, compared asSPY; SPX (SPX6900) and QNT (Quant) are never matched. market bookshows the OLP's INDICATIVE RFQ quotes at fixed notionals (min order, $1k, $100k, $1M when published;kind: "rfqQuotes"), never order-book levels; they may be up to 600 s old (updatedAt).market mid|trades|klineare refused (CAPABILITY_UNSUPPORTED).- Funding: the interval is PER MARKET (1h / 4h / 8h perps;
fundingHourson each row), positive = longs pay.fundingRateis the fraction for one interval;market funding <sym>shows the current terms (kind: "currentFunding": per interval, hourly, APR %, next time) — there is no funding history.rateKindispredicted: the rate for the window ending atnextFundingTime, recomputed during the window. - Perp symbols are the base (
BTC); swaps keep their suffix (XAU-SWAP): daily-funded TradFi swaps with separate long / short rates,fundingRatenull and never matched across venues. Open interest is published in USD, single-sided (openInterestUsd); base-unitopenInterestis null. No index price, tick, lot or leverage is published (null). - Refused with
CAPABILITY_UNSUPPORTEDbefore any request: every trade / account / portfolio / funds / agent / builder / bot command (also with--dry-run). The user trades on omni.variational.io. No testnet. Variational's terms exclude US / Canada persons and sanctioned regions (perp-cli only warns).
GRVT (-e grvt, testnet = -n testnet): official Market Data API (api-docs.grvt.io), READ-ONLY in this version. Rules an agent must follow:
- Works:
market list|prices|info|book|trades|funding|kline -e grvt,perp health(counted among the official venues), and GRVT rows inperp --json arb scan --rates --include-unverified(display only). - Symbols are the base ticker (
BTC,KPEPE,XAU,AAPL;BTC_USDT_Perpalso accepted);venueSymbolis GRVT's instrument name. Unknown symbols →SYMBOL_NOT_FOUND. Pre-IPO markets (OPENAI, ANTHROPIC, SPACEX) are never matched across venues. - Funding interval is PER MARKET (8 h or 4 h —
fundingHours); rates are fractions per that interval (GRVT publishes percent).market list|prices|inforows carry the INDICATIVE rate of the running interval (fundingRateKind: "predicted", moves untilnextFundingTime);market fundingis the settled history (rateKind: "lastSettled",intervalHoursper row). Funding is UNVERIFIED (not yet checked against settled payments) — never rank or trade on it. stepSizeis null (GRVT publishes a minimum size,minSize, but no lot step);maxLeverage/marginTierscome from GRVT's margin rules and are filled bymarket list|prices|infoonly (cached up to 6 h —leverageAsOfsays when they were read) — MCPget_markets/get_pricesrows have them null (price-only path). Equities match other venues only when reviewed; an unreviewed new GRVT equity hascanonical: null.- Refused with
CAPABILITY_UNSUPPORTEDbefore any request (also under--dry-run): every trade / account / portfolio / funds / agent / builder / bot command andsetupvenue selection — remediation "GRVT is read-only (market data) in this version; trading is planned for a later release". GRVT trading needs KYC and is banned in restricted jurisdictions (US, CA, SG, HK, …) — relevant once trading lands.
Extended (-e extended, aliases ext / x10; testnet = Sepolia via -n testnet): official public API (api.docs.extended.exchange), READ-ONLY in this version — counted as an official venue in perp health. Rules an agent must follow:
- Works:
market list|prices|info|book|trades|funding|kline -e extended, and Extended rows inperp --json arb scan --rates --include-unverified(display only — funding is UNVERIFIED: never rank or trade on it).market listrows carryassetClass(crypto / equity / etf / index / commodity / fx / preIpo; human table "Class" column),venueSymbol(wire name, e.g.TSLA_24_5-USD),tickSize,minSize,tradable(false whileREDUCE_ONLYorisOffHours),isRfq,tradingHours. - Symbols:
assetNamewithout the_24_5suffix (TSLA_24_5-USD→TSLA,SPX500m-USD→SPX500M);-e extended market book TSLA-USDand the wire name also resolve. The cryptoSPXmarket is SPX6900, not the S&P 500 (index =SPX500M). RWA tickers that are also crypto tickers (PURR = Hyperliquid Strategies Inc., QNT, BB, ON, ADI, BOT), XIAOMI and the crypto SPX are never matched across venues. - Funding: applied hourly;
fundingRatein market rows = the current hour's ACCRUING rate (fraction per hour, recomputed every minute, rounded to 6 decimals by the venue — no public source is more precise;fundingRateKind: "accruing",nextFundingTime),market funding= applied hourly prints (rateKind: "lastSettled",annualizedPct)._24_5equities print 0 while their underlying is closed (weekends / holidays), so an annualized rate overstates them. - Refused with
CAPABILITY_UNSUPPORTEDbefore any request ("Extended is read-only (market data) in this version; trading is planned for a later release"): every trade / account / portfolio / funds / agent / builder / bot command, also under--dry-run. RFQ markets' REST order book is the indicative book.
Venue rules for these: trade limit defaults to --tif GTC on every venue (arcus maps it to GTT; ondo offers GTC|IOC|ALO; FOK is never emulated → CAPABILITY_UNSUPPORTED where not offered); market orders on every venue are bounded by --slippage-bps <n> → settings.slippageBps.<venue> → settings.defaultSlippageBps (shipped default 50). Ondo (US, PA) and Arcus (US, CA, GB) print a one-time restricted-region notice on stderr when used with credentials (warn only, never blocks).
Step 3: Discover (read-only)
perp --json arb scan # all modes (perp-perp + spot-perp), default --min 10 (% annual)
perp --json arb scan --mode perp-perp --top 10
perp --json arb scan --mode spot-perp --top 10
perp --json arb scan --rates # raw funding rates
perp --json arb scan --basis [<symbol>] # cross-exchange basis
perp --json arb scan --gaps # cross-exchange price gaps
perp --json arb scan --hip3 # HIP-3 cross-dex spreads
perp --json arb scan --history <symbol> # LOCAL snapshots only (written by earlier `arb scan --rates` runs; often `rates: {}`)
perp --json -e <ex> market funding <symbol> -l 24 # real settled history (newest first; rate per `intervalHours`)
perp --json arb scan --compare <symbol> # one symbol across all exchanges
perp --json arb scan --positions # funding impact on open positions
perp --json arb scan --live --interval 60 # continuous monitoring
Common knobs: --min <pct>, --top <n>, --hold-days <n> (default 7), --bridge-cost <usd>, --size <usd>.
Prices: perp --json -e <ex> market mid <SYM> is the canonical price read; cross-venue: arb scan --compare <SYM>. market prices takes no symbol (every market). There is no spot price / book read (market * are perp markets; HYPE/USDC, @107, HYPE-SPOT → SYMBOL_NOT_FOUND), and arb scan --basis is cross-venue PERP basis, not spot-perp.
Reading scan rows — act only on these fields (detail: references/commands.md → "Arbitrage"):
- perp-perp rows (
mode: "perp-perp"):longExch/shortExch,netSpread/grossSpread(=netSpreadPct/grossSpreadPct, annual %),estFeesPct(estimated round trip on BOTH legs incl. 0.1 % slippage — e.g. hl+hl 0.24 %;perp settings fees showis the per-fill taker rate it is built from). - spot-perp rows (
mode: "spot-perp"):spotExchanges[],perpExchange,direction,netSpread,estFeesPct,breakEvenDays— nolongExch/shortExch. Executable ONLY whendirection == "long-spot-short-perp":arb exec <SYM> spot:<one of spotExchanges> <perpExchange> <USD>.arb exec spot:does not look at the funding sign — it always buys spot and shorts the perp, so on asell-spot-long-perprow it would PAY the funding. Never act onsell-spot-long-perprows. --rates/--comparerows:longExchange/shortExchange/maxSpreadAnnual(all null when fewer than two verified rates),executable,readOnlyLegs,unverifiedLegs,mixedKinds(the legs' rates are of different kinds — lastSettled / accruing / predicted);--ratestop level hasminSpread/belowMinSpread. Act only whenexecutable === true.--compare <unknown>isok:truewithdata.available: false.- Testnet funding rates and spreads are meaningless (thousands of % / yr). Never report them as opportunities; do yield analysis on mainnet public reads (keyless,
-n mainnet).
HIP-3 dexes (part of Hyperliquid, not a separate venue)
HIP-3 dexes are selected on the Hyperliquid venue with the root --dex <name> flag; every market / account / trade command works the same way. Same account and wallet as native Hyperliquid perps.
perp --json -e hyperliquid market hip3 # deployed dexes: name, deployer, assets, delistedAssets, delisted
perp --json -e hyperliquid market list --hip3 # native + every HIP-3 dex market
perp --json -e hyperliquid --dex xyz market list # markets on dex "xyz"
perp --json -e hyperliquid --dex xyz market info GOLD # symbols WITHOUT the "xyz:" prefix
perp --json -e hyperliquid --dex xyz account positions # positions on that dex only
perp --json -e hyperliquid account positions --hip3 # native + every HIP-3 dex
perp --json -e hyperliquid --dex xyz --dry-run trade market GOLD buy 0.01
--dexwith any other-evenue →INVALID_PARAMS(never ignored).- A dex symbol without
--dex(e.g.-e hyperliquid market mid xyz:GOLD) →SYMBOL_NOT_FOUNDwith remediation--dex xyz; it is never read from the native dex. portfolio --dexesworks only with--serve(web dashboard); for HIP-3 positions useaccount positions --hip3/--dex <name>or--address. Builder fees are never attached on HIP-3.- Symbols: input is bare (
BTC; HIP-3TSLA+--dex xyz). Output differs: market rows are plain, keyed HL native position / order rows show<COIN>-PERP, HIP-3 rowsxyz:TSLA— pass the bare name back (BTC,TSLA+--dex xyz). - MCP tools cover native Hyperliquid perps only, except
get_positions_by_address(reads every HIP-3 dex) — use the CLI for the rest of HIP-3.
Options market data (Derive, read-only)
Derive (derive.xyz) options via the official public API — keyless, never trades. Not a perp venue (-e derive works only with perp options).
perp --json -e derive options expiries ETH # active expiries
perp --json -e derive options chain ETH --expiry 2026-12-25 --strikes 10 # calls/puts per strike: bid/ask, mark, IV, greeks, OI
perp --json -e derive options quote ETH-20261225-3500-P # one option
schema: 1; decimals are strings; null = unknown (empty side, uncomputable IV). Unknown underlying / expiry / instrument → SYMBOL_NOT_FOUND. Full reference: references/commands.md → "Options market data".
Step 4: Validate before mutating
For arb:
perp --json portfolio -e <longEx> # perp.available (long leg)
perp --json portfolio -e <shortEx> # perp.available (short leg)
perp --json --dry-run arb exec <SYM> <longEx> <shortEx> <USD>
Spot-perp (spot:<venue> long leg, only for direction == "long-spot-short-perp" rows): the spot leg needs the full spot notional in the spot venue's quote (perp --json -e <venue> trade spot-balance; separate-margin venues transfer the shortfall perp→spot) plus perp margin on the perp leg — the dry-run checks both and refuses an empty book or a > 5% spot/perp price gap.
For a single trade:
perp --json -e <ex> market info <SYM> # markPrice, stepSize (lot), maxLeverage
perp --json -e <ex> trade check <SYM> <SIDE> <SIZE> --leverage <N>
perp --json --dry-run -e <ex> trade buy <SYM> <SIZE> # market entry
perp --json --dry-run -e <ex> trade buy <SYM> <SIZE> --tp <PX> --sl <PX> # entry + TP/SL
perp --json --dry-run -e <ex> trade buy <SYM> <SIZE> --smart # IOC at best ask + 1 tick (no TP/SL)
trade checkdoes NOT read exchange-set leverage. Always pass--leverageexplicitly.
--tp/--slare ABSOLUTE trigger prices (not %). Market entries: every venue (venues that place TP/SL as separate orders need a market / IOC entry);trade limit --tp/--sl: ondo / arcus on any entry, elsewhere only with--tif IOC. TP/SL on an already open position:trade tpsl <SYM> long|short --tp <PX> --sl <PX>(side = the position's side).
--smart(IOC at best bid/ask ± 1 tick) exists only on pacifica / hyperliquid / lighter / aster, and is refused (CAPABILITY_UNSUPPORTED) together with--tp/--slor--client-id/--auto-id— need TP/SL → plain market entry (or--smart, thentrade tpsl).Pacifica basket (pair trade):
perp --json --dry-run -e pacifica trade atomic --long BTC:50 --short ETH:50 --usd 1000— one batch of market orders, NOT all-or-nothing (a leg can fill while another is refused →ORDER_PARTIAL; an unconfirmed leg →ORDER_PENDING+ quarantine). A batch failure other than HTTP 400 / 429 quarantines every leg. Pacifica's Chase / OCO / Trailing Stop / Swarm / Trigger Swarm / Conditional orders have no documented API / SDK path (as of 2026-10-19); nearest here:trade twap(≈ Swarm) andtrade tpsl(≈ OCO bracket exit).
Show the dry-run output to the user. Wait for confirmation.
Minimum order size and tick (not in market info; trade check and --dry-run do NOT enforce the minimum)
| Venue | Min order value (USD notional) |
|---|---|
| hyperliquid | $10 (also spot; HIP-4 outcomes: 10 quote tokens) |
| pacifica | $10 (per market min_order_size) |
| lighter, lighter-rh | $10 (per market min_quote_amount; a few markets 0) |
| aster | $5 (MIN_NOTIONAL) |
| arcus | $5 (minOrderNotional; reduce-only exempt; perp-cli refuses below it, SIZE_TOO_SMALL) |
| ondo, qfex | unknown (not published) |
Values read from the venues' public market data on 2026-10-26; keyless MCP get_markets (no credentials configured) returns them per market as minNotional, with tickSize / minSize. Default smallest order = $15 notional (on every venue, including the $5 ones and the unknown ones): mark = market mid <SYM>, step = stepSize from market info; size = ceil(15 / mark / step) × step, then trade check + dry-run. The $15 buffer over the $10 venue minimum absorbs price moves between sizing and the fill, step rounding and fees; below the venue minimum the live order is rejected. Use the bare venue minimum only when the user explicitly asks for it. Anything that splits a position must keep every piece ≥ $15 too: trade reduce 50 / scale-tp / partial tpsl --size need a position of ≥ $30 (≥ $15 × number of pieces), and an arb's matched size must clear $15 on both legs. Tick: off-grid limit / trigger prices are refused with INVALID_TICK on the live send (never rounded, nothing sent) — Hyperliquid: ≤ 5 significant figures; elsewhere take tickSize from keyless MCP get_markets or the price steps of market book <SYM>.
Step 5: Execute
After explicit user confirmation:
# Perp-perp arb: legs are SEQUENTIAL — long first, then the short sized to the verified long fill;
# reconcile is always on (the long is trimmed reduce-only to the short's verified fill).
# An unconfirmed leg quarantines the symbol (see "Safety rules").
perp --json arb exec <SYM> <longEx> <shortEx> <USD> --smart
# Spot+perp arb (spot has 0 funding cost; spot:<venue> = hl, lt, lrh, aster, ondo)
# ONLY for a spot-perp scan row with direction == "long-spot-short-perp": buys spot, shorts the perp.
perp --json arb exec <SYM> spot:hl hl <USD>
perp --json arb exec <SYM> spot:lt pac <USD>
# Single trade
perp --json -e <ex> trade buy <SYM> <SIZE> --smart
perp --json -e <ex> trade sell <SYM> <SIZE> --tp <PX> --sl <PX>
perp --json -e <ex> trade split <SYM> buy <USD> --max-slippage 0.5
Orders: limit / status / edit / cancel
perp --json -e <ex> trade limit <SYM> buy|sell <PRICE> <SIZE> [--tif GTC|IOC|FOK|ALO] [--reduce-only] # default GTC
perp --json -e <ex> account orders # open orders + ids
perp --json -e <ex> trade status <ORDER_ID> [--symbol <SYM>] # --symbol required on ondo / arcus / qfex
perp --json -e <ex> trade edit <SYM> <ORDER_ID> <PRICE> <SIZE> # SIZE = new open (unfilled) size
perp --json -e <ex> trade cancel <SYM> <ORDER_ID> # one order
perp --json -e <ex> trade cancel <SYM> # every order on that symbol
All of these writes take --dry-run. trade edit may return a NEW orderId — always continue with the id it returns: pacifica (ALO → native edit, GTC / TOB → cancel+replace; new id either way, TIF kept), ondo (cancel+replace), qfex (venue assigns a new id); hyperliquid / lighter / lighter-rh / aster / arcus amend natively — use the returned id anyway. trade edit --tif only on ondo / pacifica.
HL spot uses U-tokens (BTC→UBTC, ETH→UETH, SOL→USOL) — auto-resolved.
Step 6: Monitor
perp --json arb status # open arb positions, PnL, funding earned
perp --json portfolio # cross-exchange equity + risk
perp --json risk status # canTrade, level, violations
perp --json risk liquidation-distance # % from liq for ALL positions
perp --json -e <ex> account positions --address <ADDR> [--symbol BTC] [--account-index <n>] # keyless, ANY account
perp --json -e <ex> account balance --address <ADDR> [--account-index <n>] # keyless balances of ANY account
arb status reads every configured venue and fails as a whole (EXCHANGE_ERROR) when one venue's read fails — there is no venue filter; check the venues one by one with perp --json -e <ex> account positions and report which one failed. Never read the failure as "no positions".
account positions --address (keyless, nothing signed; without -e: every venue that supports it): hyperliquid (0x; native + every HIP-3 dex, rows carry dex), lighter / lighter-rh (0x; every account of the address, rows carry accountIndex, narrow with --account-index), pacifica (Solana address), risex (0x). Other venues → CAPABILITY_UNSUPPORTED. MCP get_positions_by_address returns the same rows (HIP-3 included). account balance --address (same venues and address rules; MCP get_balance_by_address): data = { exchange, address, balance, spot } — balance = { equity, available, marginUsed, unrealizedPnl } (+ Pacifica usdcBalance / borrowedUsdc / pendingInterest / availableToWithdraw), spot = token rows or null (RISEx). Hyperliquid: accountMode decides equity (unified / portfolio → the spot collateral row; standard / default → perp accountValue; read meta.notes), dexes = HIP-3 dexes with a non-zero value, a failed dex → meta.errors["hip3:<dex>"] + meta.warnings (unknown, not zero). Lighter: top-level balance / spot null, one row per account in accounts: [{ accountIndex, balance, spot }]; no account → [] + note. account balance WITHOUT --address is the renamed-command error — your own balance is perp portfolio.
If risk status.canTrade === false, do NOT open new positions. If liquidation distance falls below the user's --min-liq-distance, recommend reducing position size.
For continuous monitoring, run bash scripts/arb-monitor.sh --json.
Step 7: Close
perp --json arb close <SYM> # perp-perp arb
perp --json arb close <SYM> --pair <longEx>:<shortEx> # disambiguate
perp --json arb close <SYM> --spot-exch hl --perp-exch hl # spot+perp
perp --json arb close <SYM> --smart # IOC limits
perp --json arb close <SYM> --force # quarantined symbol — only after the user checked positions
perp --json arb close <SYM> --state-only --yes # drop a stale state entry (arb status staleStateEntries); sends no order
# Single trade (dry-run first, then confirm)
perp --json -e <ex> trade close <SYM> # close one symbol
perp --json -e <ex> trade close-all # close all positions on this exchange
perp --json -e <ex> trade flatten # cancel ALL orders, then close ALL positions
trade close / close-all close positions only — perp-cli does not cancel resting TP/SL / stop / limit orders (QFEX lists the leftovers as a WARNING). After a close, run account orders and cancel what is left (trade cancel <SYM> <id>), or use trade flatten, which cancels every order on the venue first.
Pacifica Print and vaults (perp print, perp vault)
Pacifica-only, details in references/commands.md. Reads first (print games, print quote, print positions, vault list|info|positions); every write is --dry-run first and needs the user's confirmation:
- Print (
print deposit <game> long|short <usd> --strike <px> --leverage <n> [--cycles 1-1000]) locks the deposit until a fill or until a cancel settles at the END of the running cycle (up to 30 days onBTC_1M). Before asking, show the user: cycle length,--cycles, leverage,maxLoss(deposit + premiums), and thatdocsLiquidationPriceis only an outer bound (a liquidation was observed earlier in one live case; the venue trigger is unpublished). Checkpoint-only evaluation applies while resting; after a fill it is an ordinary position in the main account (continuous liquidation, nets with an existing position) —account positions. The premium is not quoted by perp-cli.print canceluses an UNOFFICIAL endpoint: live runs need--unverified-endpoint. - Vaults (
vault deposit <vault> <usd>,vault withdraw <vault> <shares>|--all): third-party trading pools (can lose the whole deposit); every deposit restarts the lock-up for the whole balance; withdrawals only go to the own account, inside the vault's window.vault depositis master-only (never an agent key). Pass the vault ADDRESS and confirm the shown manager with the user — nicknames are not unique (an ambiguous one is refused with the candidates). ORDER_PENDINGon any of them → NEVER resubmit with a new key; checkprint positions/vault positionsagainsterror.details.before. The only safe retry is the same command with--idempotency-key <reported key>(dedupe window unverified).
Funds workflow (deposit / withdraw / transfer / bridge / rebalance)
All money movement lives under perp funds:
# Exchange in/out
perp --json funds deposit hyperliquid 100
perp --json funds deposit pacifica 100
perp --json funds deposit lighter ethereum 100 # L1 direct
perp --json funds deposit lighter cctp arbitrum 100 # via CCTP
perp --json funds withdraw hyperliquid 100 [--chain arbitrum|ethereum|base] # CCTP to your own wallet
perp --json funds transfer 100 <ADDRESS> # HL internal (instant) — allowlisted destinations only
# Cross-chain bridge (auto-cheapest cctp/relay/debridge)
perp --json funds bridge quote --from solana --to arbitrum --amount 100
perp --json funds bridge send --from solana --to arbitrum --amount 100
perp --json funds bridge status <orderId> # poll until success
# Inter-exchange rebalance
perp --json funds rebalance check
perp --json funds rebalance plan
perp --json --dry-run funds rebalance execute --auto-bridge # status "simulated" (moves[].status "dry_run"), or "balanced" (nothing to move)
perp --json funds rebalance execute --auto-bridge # withdraw → bridge ONLY; no deposit
Always run funds bridge quote before funds bridge send so the user sees fees + ETA.
funds rebalance executereturnsok:trueeven when a move failed: check EVERYmoves[].status(withdrawn,bridged,same_chain,needs_bridge,withdraw_failed,bridge_failed). It never deposits — after the bridge arrives, deposit manually (funds deposit <venue> <amt>).funds transfer <amt> <addr>(HL) andfunds withdraw hyperliquid --to <other address>require the destination on thesettings withdraw.hyperliquidallowlist (POLICY_DENIEDotherwise). Only the user can set it, in an interactive terminal (--json/ piped →POLICY_DENIED). NEVER try to set or changewithdraw.<venue>yourself.- HL withdraw goes over CCTP (native USDC); on Arbitrum a 0.2 USDC forwarding fee is deducted (an amount ≤ the fee →
SIZE_TOO_SMALL). - Bridges: exactly
--amountleaves the wallet (fees come out of it); a deBridgenativeFeeis shown separately and is paid in the source chain's native token. Solana-origin deBridge is refused (NO_BRIDGE_ROUTE) →--provider cctp.--fast= fast CCTP finality (higher fee). funds bridge exchange --from <ex> --to <ex>bridges the master wallet's OWN USDC between the venues' chains (pacifica → solana, lighter → arbitrum); it does NOT withdraw from / deposit into Pacifica or Lighter. Exception hyperliquid:--from hyperliquidspends HyperCore spot USDC,--to hyperliquidcredits HyperCore perps. HyperCore → Solana is refused (NO_BRIDGE_ROUTE).
Relay swaps between assets (--from-asset / --to-asset, chains robinhood, arbitrum, bsc, base, destination solana): run perp --json --dry-run funds bridge send ... first — it prints the locally verified quote (amount in, expected out, protocol-guaranteed minimum, fees, ETA) and the min-out verdict without loading a key. Stable → native (e.g. USDG → SOL / ETH) needs --min-out. The recipient is always the master wallet's own address; an ORDER_PENDING result carries the Relay request id — never bridge again before checking it.
Strategy engine (20 algorithms + scripted plans)
perp strategy list-strategies # 20 registered
perp strategy run <strategy> [symbol] # run any strategy (multi-venue: --exchanges must include the -e venue)
perp --json --dry-run strategy run <strategy> [symbol] # simulate: actions logged, never sent
perp strategy apex [symbol] # APEX orchestrator
perp strategy reflect # performance analysis
perp --json strategy plan validate <FILE> # validate scripted plan
perp --json strategy plan execute <FILE> --dry-run # dry-run scripted plan
Strategies: grid, dca, simple-mm, engine-mm, avellaneda-mm, regime-mm, grid-mm, liquidation-mm, momentum-breakout, mean-reversion, aggressive-taker, funding-arb, funding-arb-v2, funding-auto, basis-arb, spot-perp-arb, hedge-agent, rfq-agent, claude-agent, apex.
Background daemon (tmux):
perp --json --dry-run arb auto --min-spread 30 --size 100 # simulate first (--background inherits --dry-run)
perp --json arb auto --min-spread 30 --size 100 --background
perp --json background list
perp --json background logs <id> -f
perp --json background stop <id> [--timeout 90] # graceful: SIGINT, job cancels its orders, waits, reports what is left on the venue
strategy funding-arb is monitor-only unless --auto-execute. Bots: equity is null when a balance read fails — arb strategies then skip new entries and the bot stops after 10 consecutive unknown ticks; ordersPlaced counts orders sent, fills only venue-reported fills — a resting order is placed, not filled.
Background jobs inherit the parent's -n, --dry-run, -e, --ows, -w, --no-agent, --dex, and never receive key material (argv/env): they resolve credentials from the OWS vault / agent keystores / ~/.perp/.env themselves. --background with -k, --passphrase, --ows-key or a shell-exported key / OWS_PASSPHRASE → INVALID_PARAMS — register an agent (perp wallet agent approve <venue>), which signs without the master passphrase.
Position sizing & safety
- Single position notional < 80% of that exchange's available balance.
- Leverage 1–3x for arb; never above 5x for arb positions.
arb execsizes the short to the verified long fill and always reconciles; still checkarb status(unconfirmedPairs,staleStateEntries) afterwards.- ALWAYS follow
longExch/shortExch(perp-perp) orlongExchange/shortExchange(--rates/--compare) — NEVER reverse direction. Spot-perp: onlydirection == "long-spot-short-perp". - NEVER enter if
netSpread <= 0ornetSpread < estimated round-trip slippage. - Capital that's mid-bridge is "at risk" and unhedged — factor it in.
For deeper risk-management framework, read references/strategies.md.
Examples
Example 1: "Find funding-rate arb opportunities"
# 1. Discover
perp --json arb scan --min 10 --top 10
# 2. Show top 3 to user; ask which to evaluate
# 3. Check balances on the two exchanges
perp --json portfolio -e <longEx>
perp --json portfolio -e <shortEx>
# 4. Recommend size + dry-run
perp --json --dry-run arb exec BTC <longEx> <shortEx> 100
# 5. After user confirmation:
perp --json arb exec BTC <longEx> <shortEx> 100 --smart
perp --json arb status
Example 2: "ETH spot+perp arb, $100"
perp --json arb scan --mode spot-perp --min 0 # ETH row must say direction "long-spot-short-perp"
perp --json --dry-run arb exec ETH spot:hl hl 100
# → show dry-run, ask confirmation
perp --json arb exec ETH spot:hl hl 100
perp --json arb status
# Later, to close both legs:
perp --json arb close ETH --spot-exch hl --perp-exch hl
Example 3: "Long SOL 0.5 on Hyperliquid with 2x leverage"
perp --json -e hl trade check SOL buy 0.5 --leverage 2
perp --json --dry-run -e hl trade leverage SOL 2 --isolated
perp --json --dry-run -e hl trade buy SOL 0.5 --smart
# → show both dry-runs (isolated 2x + the order), ask confirmation; only then:
perp --json -e hl trade leverage SOL 2 --isolated
perp --json -e hl trade buy SOL 0.5 --smart
perp --json -e hl account positions
Example 4: "Move 500 USDC from Pacifica to Hyperliquid"
perp --json --dry-run funds withdraw pacifica 500
perp --json funds bridge quote --from solana --to arbitrum --amount 500
# → show the withdraw plan + bridge fee / ETA, ask confirmation; only then:
perp --json funds withdraw pacifica 500
perp --json funds bridge send --from solana --to arbitrum --amount 500
perp --json funds bridge status <orderId> # poll until completed
perp --json funds deposit hyperliquid 500
funds rebalance execute --auto-bridge only withdraws and bridges — check every moves[].status, then deposit by hand (funds deposit hyperliquid <amt>) after the bridge arrives.
Example 5: "Run a delta-neutral funding bot in background"
perp --json --dry-run arb auto --min-spread 30 --close-spread 5 --size 100 --max-positions 5
# → show the simulation, ask confirmation
perp --json arb auto --min-spread 30 --close-spread 5 --size 100 --max-positions 5 --background
perp --json background list
perp --json background logs <id> -f
# To stop:
perp --json background stop <id>
Troubleshooting
Every response is { "ok": true, "data": ... } or { "ok": false, "error": { "code": "...", "retryable": true|false, "remediation"?: "..." } }; ok:false exits 1. Always check ok first and follow error.remediation. retryable: true → wait and retry ONCE, and only for read-only commands — a write is never blindly retried.
| Error code | Meaning | Action |
|---|---|---|
ORDER_PENDING |
A write was sent, outcome unknown | NEVER resubmit. See "Safety rules". |
ORDER_PARTIAL |
Part of a multi-leg / close succeeded | Don't retry; check positions per venue, close residuals by hand (may be quarantined). |
ORDER_REJECTED / ACTION_REJECTED |
Definitely not placed / not executed | Fix the cause from error.message; a new attempt is a new decision (ask the user). |
RISK_VIOLATION |
Local risk limit breached, or symbol quarantined | Report to the user. --force only with explicit user consent, and never bypasses quarantine. |
CAPABILITY_UNSUPPORTED |
Venue/feature combination not offered | Do NOT work around it (no emulation via other orders/venues); tell the user. |
INVALID_TICK |
Limit/trigger price off the venue grid (HL: ≤ 5 significant figures) | Refused, never rounded — re-price on the grid and confirm with the user. |
INVALID_PARAMS |
Bad argument (incl. strict sizes: 1,000 / 1e3 / 10abc refused; --dry-run on a command without dry-run) |
Fix the argument. |
CLI_ERROR |
Command parse error (unknown command / missing option) | Check <cmd> --help. |
NO_SIGNER_AVAILABLE |
No key that may sign this (e.g. imported agent key for a master-only action) | User does it on the website, or perp wallet imports the master. |
AGENT_NOT_REGISTERED / AGENT_EXPIRED |
Agent key missing, on the other network, or expired | Follow remediation: master on this computer → perp wallet agent approve <venue> [--rotate] (master-signed: user consent); imported key → new key on the website, wallet agent import <venue> --replace. |
POLICY_DENIED |
Local withdraw gate / OWS policy refused | Never change withdraw.<venue> — only the user can, in a terminal. |
PASSPHRASE_REQUIRED |
Vault passphrase needed | Ask the user to provide OWS_PASSPHRASE (or stdin); never put it on argv. |
LOCK_HELD |
Another perp process holds a state lock | Wait ~5s and retry once; check background list. |
NO_BRIDGE_ROUTE |
No supported bridge route (e.g. deBridge from Solana, HyperCore → Solana) | Use the route in remediation (e.g. --provider cctp). |
RATE_LIMITED / EXCHANGE_UNREACHABLE |
Throttled / API down (reads) | Wait 5–10s (or retryAfterMs when present — Pacifica sets it from its credit headers), retry once; then skip that venue. |
INSUFFICIENT_BALANCE |
Not enough collateral on that venue | Reduce size or move funds first (user-confirmed). |
SYMBOL_NOT_FOUND |
Not listed on this venue | market list. Don't add -PERP. |
SIZE_TOO_SMALL |
Below venue minimum (HL TWAP: $100 total) | Compute size × price; raise size (minimum table in Step 4). |
UNKNOWN |
Unclassified failure (the message matched no known code) | Read error.message. After a write: treat the outcome as unknown — check account orders / account positions / portfolio before anything else, never resubmit blindly; report to the user. |
Lighter / Lighter RH "account not found" (venue code 21100): the address has no account on that venue / network — the user must fund (create) the account first, then perp wallet agent approve lighter (or lighter-rh).
--client-id (trade market/buy/sell/limit): an id already recorded in ~/.perp/client-ids.jsonl (and not marked failed) returns ok:true with data.duplicate: true and sends nothing — local tracking only, not a venue check (it is NOT a DUPLICATE_ORDER error). Formats: Pacifica a full UUID, Hyperliquid 0x + 32 hex; QFEX refuses --client-id (use --auto-id); --smart + client id → CAPABILITY_UNSUPPORTED.
Safety rules
- Unknown outcome (
ORDER_PENDING) on ANY write — orders, cancels, edits, leverage, withdraw / deposit / bridge / transfer: do NOT resubmit. Checkperp --json -e <ex> trade status c:<id> --symbol <S>(the id inremediation),account orders/account positions/portfolio, and the tx hash / request id inerror.details(funds bridge status <id>for bridges). Report to the user. - Quarantine: an unknown or unhedged outcome (arb, bots,
trade close,trade multi,trade atomic) quarantines the symbol — global per symbol, scoped by network. It blocks opening orders,arb exec,arb autoand bots (RISK_VIOLATION); reduce-only orders pass. List:perp --json strategy quarantine. Clear only after the USER has verified the positions on the venues:perp --json strategy quarantine-clear <SYM>.arb closeon a quarantined symbol needs--force. - Risk gate:
trade market / buy / sell / limit / split / market --split / scale-in / twap / multi / atomic / stop --no-reduce-onlycheck~/.perp/risk.json(perp risk limits ...); reduce-only is exempt.--forcebypasses the limits (never quarantine) — only with explicit user consent. - Stops (
trade stop,tpsl) are reduce-only by default;--no-reduce-onlyis refused on ondo and qfex.trade tpsl <SYM> long|short= the OPEN position's side; legs are sized to the live position. - Dry-run is default-deny: commands that cannot simulate refuse
--dry-runwithINVALID_PARAMS(e.g.trade twap,trade multi,trade cancel-stop,trade cancel-twap,strategy start / preset / grid / dca / quick-* / funding-arb,wallet agent approve,wallet rotate). Simulate bots withperp --json --dry-run strategy run <strategy>/perp --json --dry-run arb auto. - A dry-run is not a full venue check: it validates arguments, the risk gate and quarantine, but some venue rules are enforced only on the live send — e.g. an off-grid limit price (
INVALID_TICK) or--no-reduce-onlyon ondo / qfex (CAPABILITY_UNSUPPORTED). Those refusals happen before anything is sent. wallet rotatecreates a new wallet and transfers assets, with no dry-run — only on the user's explicit request.
Common mistakes
- Forgetting
--json→ output becomes unparseable human text. The very first thing to check when parsing fails. - Using legacy command names —
arb rates/arb prices/arb dex/arb spot-exec/arb spot-closeare removed. Usearb scan --rates|--gaps|--hip3andarb exec spot:<exch>/arb close <SYM> --spot-exch <ex>. - Calling
trade checkwithout--leverage→ cost estimate doesn't match what the exchange applies. - Retrying a non-idempotent trade without checking
account positions→ opens a duplicate position. - Bridging without quoting first → user sees no fee/ETA and can't approve cleanly.
- Treating
bridge sendas instant → alwaysfunds bridge status <orderId>before depositing on the destination. - Manually adding
-PERPsuffix → CLI auto-resolves; let it.
For a full troubleshooting + non-interactive flow guide, read references/agent-operations.md.
Referrals (optional, ask once per setup)
perp --json --dry-run -e hyperliquid wallet manage referral set # preview (nothing signed)
perp --json -e hyperliquid wallet manage referral set [code] # signs + sends ONE referral action
perp --json -e lighter wallet manage referral set [code] # Lighter (needs an agent key)
Referral codes are never applied implicitly (adapter creation signs nothing). When the user first sets up a wallet, ask:
"perp-cli development is supported by optional referrals. Apply the referral code? It signs one referral action on the venue; no extra fees — only exchange rebates are used."
Builder fees (OFF by default — never enable on your own)
Builder fees are extra fees on the USER's perp orders, paid to a third-party builder. perp-cli attaches none unless the user explicitly set settings builder.<venue> AND the venue approval is confirmed. Do not configure or approve a builder unless the user asks for it.
perp --json wallet builder status [venue] # support, config, approval, attaches?
perp --json --dry-run wallet builder approve <venue> # plan only — show it to the user
perp --json wallet builder approve <venue> --yes # only after explicit user consent (master-signed)
perp --json --no-builder -e <ex> trade market BTC buy 0.1 # one run without the fee
qfex: builder.qfex <uuid> is a fee share (no extra fee, no approval; mainnet only). Unsupported: lighter, lighter-rh, arcus (CAPABILITY_UNSUPPORTED). An order whose approval is missing or unknown is sent without the fee (execution.notes); execution.builderFee records what was attached.
MCP Server
The package also ships a 30-tool MCP server (no API keys required for read-only market data — get_markets, get_orderbook, get_funding_rates, get_prices, get_outcome_markets, get_outcome_view, get_outcome_book, get_option_expiries, get_option_chain, get_option_quote (Derive options), the read-only Pacifica Print / vault tools pacifica_print_products, pacifica_print_quote, pacifica_print_positions, pacifica_vaults, plus 16 account/advisor tools, incl. keyless get_positions_by_address):
MCP portfolio totals (totalEquity, totalAvailable, totalMarginUsed, totalUnrealizedPnl, riskMetrics.marginUtilization) are null when no balance was read — check accountState ("ok" | "unread" = credentials but no balance read | "noAccount") and totalsCover (the venues the totals include) before quoting a total. The CLI portfolio shape differs: totals.{equity,marginUsed,marginPct,funding24h,fundingIncomplete}, risk.{level,marginPct}.
MCP network: PERP_NETWORK=mainnet|testnet (validated; unset = mainnet); every result's meta.network says which. The only write tools, trade_execute / trade_close, run the same local risk gate as perp trade (no override over MCP), refuse non-reduce-only orders on quarantined symbols, and log every order.
{
"mcpServers": {
"perp-cli": {
"command": "npx",
"args": ["-y", "-p", "perp-cli", "perp-mcp"]
}
}
}
perp-guardrail (third binary): not run by hand — the OWS Policy Engine spawns it before an agent API key signs anything; it allows / denies by chain + contract whitelist, per-tx and daily USD limits, withdrawal limits and blocked selectors. Set it up through perp wallet setup or perp wallet policy create --perp-defaults; it is a second line of defence, not a replacement for perp-cli's risk gate.
04 同仓库更多 Skills
troves
Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.
trade
Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".
staking
Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.
send
Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".
portfolio
View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".
multi-swap
Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.