perp-cli 0.12.15 → 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.
Files changed (361) hide show
  1. package/README.md +278 -31
  2. package/dist/_stderr-filter.js +0 -1
  3. package/dist/agent-wallet/lighter-keystore.d.ts +11 -0
  4. package/dist/agent-wallet/lighter-keystore.js +92 -10
  5. package/dist/agent-wallet/passphrase.d.ts +1 -1
  6. package/dist/agent-wallet/passphrase.js +16 -3
  7. package/dist/agent-wallet/store.d.ts +37 -4
  8. package/dist/agent-wallet/store.js +132 -0
  9. package/dist/agent-wallet/venue-keystore.d.ts +14 -0
  10. package/dist/agent-wallet/venue-keystore.js +121 -0
  11. package/dist/api/public/hyperliquid.js +4 -4
  12. package/dist/api/public/lighter.js +5 -5
  13. package/dist/api/public/pacifica.d.ts +0 -1
  14. package/dist/api/public/pacifica.js +4 -13
  15. package/dist/api/public/urls.d.ts +9 -1
  16. package/dist/api/public/urls.js +35 -13
  17. package/dist/arb/file-lock.d.ts +11 -0
  18. package/dist/arb/file-lock.js +74 -0
  19. package/dist/arb/index.d.ts +2 -2
  20. package/dist/arb/index.js +2 -2
  21. package/dist/arb/pending-entry.d.ts +32 -0
  22. package/dist/arb/pending-entry.js +77 -0
  23. package/dist/arb/sizing.d.ts +6 -13
  24. package/dist/arb/sizing.js +12 -51
  25. package/dist/arb/state.d.ts +45 -12
  26. package/dist/arb/state.js +214 -42
  27. package/dist/arb/utils.d.ts +20 -6
  28. package/dist/arb/utils.js +43 -39
  29. package/dist/bot/conditions.d.ts +4 -4
  30. package/dist/bot/conditions.js +11 -6
  31. package/dist/bot/config.d.ts +17 -1
  32. package/dist/bot/config.js +48 -12
  33. package/dist/bot/engine.d.ts +61 -2
  34. package/dist/bot/engine.js +610 -144
  35. package/dist/bot/fill-size.d.ts +7 -0
  36. package/dist/bot/fill-size.js +18 -0
  37. package/dist/bot/index.d.ts +1 -1
  38. package/dist/bot/index.js +1 -1
  39. package/dist/bot/perp-order.d.ts +99 -0
  40. package/dist/bot/perp-order.js +299 -0
  41. package/dist/bot/presets.d.ts +7 -0
  42. package/dist/bot/presets.js +17 -0
  43. package/dist/bot/quarantine.d.ts +75 -0
  44. package/dist/bot/quarantine.js +190 -0
  45. package/dist/bot/quote-rules.d.ts +23 -0
  46. package/dist/bot/quote-rules.js +69 -0
  47. package/dist/bot/strategies/avellaneda-mm.d.ts +32 -2
  48. package/dist/bot/strategies/avellaneda-mm.js +72 -70
  49. package/dist/bot/strategies/basis-arb.js +2 -0
  50. package/dist/bot/strategies/dca-strategy.d.ts +2 -0
  51. package/dist/bot/strategies/dca-strategy.js +5 -0
  52. package/dist/bot/strategies/funding-arb-strategy.d.ts +43 -3
  53. package/dist/bot/strategies/funding-arb-strategy.js +571 -380
  54. package/dist/bot/strategies/funding-arb-utils.d.ts +48 -23
  55. package/dist/bot/strategies/funding-arb-utils.js +159 -195
  56. package/dist/bot/strategies/funding-arb-v2.d.ts +32 -0
  57. package/dist/bot/strategies/funding-arb-v2.js +258 -47
  58. package/dist/bot/strategies/funding-auto.js +215 -194
  59. package/dist/bot/strategies/spot-perp-arb-strategy.d.ts +14 -0
  60. package/dist/bot/strategies/spot-perp-arb-strategy.js +217 -50
  61. package/dist/bot/strategies/spot-perp-executor.d.ts +73 -19
  62. package/dist/bot/strategies/spot-perp-executor.js +319 -120
  63. package/dist/bot/strategies/spot-perp-state.d.ts +43 -0
  64. package/dist/bot/strategies/spot-perp-state.js +70 -0
  65. package/dist/bot/strategy-types.d.ts +6 -0
  66. package/dist/bot/tui/BotDashboard.d.ts +7 -2
  67. package/dist/bot/tui/BotDashboard.js +6 -3
  68. package/dist/bridge-engine.d.ts +120 -19
  69. package/dist/bridge-engine.js +710 -422
  70. package/dist/bridge-signers.d.ts +54 -0
  71. package/dist/bridge-signers.js +161 -0
  72. package/dist/cache.d.ts +4 -1
  73. package/dist/cache.js +11 -0
  74. package/dist/cli-flags.d.ts +50 -0
  75. package/dist/cli-flags.js +104 -0
  76. package/dist/cli-program.d.ts +35 -0
  77. package/dist/cli-program.js +286 -0
  78. package/dist/cli-spec.js +1 -1
  79. package/dist/client-id-tracker.js +11 -2
  80. package/dist/commands/account.d.ts +7 -1
  81. package/dist/commands/account.js +74 -84
  82. package/dist/commands/agent-import.d.ts +114 -0
  83. package/dist/commands/agent-import.js +794 -0
  84. package/dist/commands/agent.d.ts +232 -2
  85. package/dist/commands/agent.js +1858 -955
  86. package/dist/commands/alerts.d.ts +1 -0
  87. package/dist/commands/alerts.js +31 -28
  88. package/dist/commands/arb/index.d.ts +60 -1
  89. package/dist/commands/arb/index.js +381 -384
  90. package/dist/commands/arb-auto.d.ts +132 -4
  91. package/dist/commands/arb-auto.js +1474 -967
  92. package/dist/commands/arb.d.ts +3 -1
  93. package/dist/commands/arb.js +62 -30
  94. package/dist/commands/bot.js +127 -47
  95. package/dist/commands/bridge.d.ts +2 -1
  96. package/dist/commands/bridge.js +339 -192
  97. package/dist/commands/builder.d.ts +55 -0
  98. package/dist/commands/builder.js +387 -0
  99. package/dist/commands/funds-onchain.d.ts +32 -0
  100. package/dist/commands/funds-onchain.js +286 -0
  101. package/dist/commands/funds.d.ts +25 -0
  102. package/dist/commands/funds.js +939 -245
  103. package/dist/commands/history.js +72 -45
  104. package/dist/commands/init.d.ts +107 -15
  105. package/dist/commands/init.js +1116 -249
  106. package/dist/commands/jobs.d.ts +2 -1
  107. package/dist/commands/jobs.js +77 -15
  108. package/dist/commands/manage.js +136 -91
  109. package/dist/commands/market.d.ts +4 -1
  110. package/dist/commands/market.js +35 -32
  111. package/dist/commands/outcome.d.ts +10 -0
  112. package/dist/commands/outcome.js +396 -0
  113. package/dist/commands/plan.js +52 -12
  114. package/dist/commands/portfolio.d.ts +1 -0
  115. package/dist/commands/portfolio.js +60 -72
  116. package/dist/commands/rebalance.d.ts +2 -1
  117. package/dist/commands/rebalance.js +33 -43
  118. package/dist/commands/risk.js +46 -19
  119. package/dist/commands/settings.d.ts +1 -0
  120. package/dist/commands/settings.js +246 -51
  121. package/dist/commands/trade.d.ts +50 -0
  122. package/dist/commands/trade.js +1943 -695
  123. package/dist/commands/wallet.d.ts +30 -1
  124. package/dist/commands/wallet.js +316 -337
  125. package/dist/config.d.ts +60 -9
  126. package/dist/config.js +252 -82
  127. package/dist/constants.d.ts +29 -4
  128. package/dist/constants.js +62 -20
  129. package/dist/dashboard/server.d.ts +2 -0
  130. package/dist/dashboard/server.js +9 -6
  131. package/dist/dashboard/ui.js +6 -4
  132. package/dist/dashboard/ws-feeds.js +20 -8
  133. package/dist/dex-asset-map.js +5 -3
  134. package/dist/errors.d.ts +122 -0
  135. package/dist/errors.js +194 -0
  136. package/dist/event-stream.js +75 -19
  137. package/dist/evm-master-tx.d.ts +59 -0
  138. package/dist/evm-master-tx.js +154 -0
  139. package/dist/exchanges/adapter-network.d.ts +10 -0
  140. package/dist/exchanges/adapter-network.js +10 -0
  141. package/dist/exchanges/arcus/adapter.d.ts +196 -0
  142. package/dist/exchanges/arcus/adapter.js +1092 -0
  143. package/dist/exchanges/arcus/agent.d.ts +55 -0
  144. package/dist/exchanges/arcus/agent.js +188 -0
  145. package/dist/exchanges/arcus/client.d.ts +63 -0
  146. package/dist/exchanges/arcus/client.js +285 -0
  147. package/dist/exchanges/arcus/public.d.ts +65 -0
  148. package/dist/exchanges/arcus/public.js +138 -0
  149. package/dist/exchanges/arcus/signing.d.ts +176 -0
  150. package/dist/exchanges/arcus/signing.js +288 -0
  151. package/dist/exchanges/arcus/spot-chain.d.ts +60 -0
  152. package/dist/exchanges/arcus/spot-chain.js +241 -0
  153. package/dist/exchanges/arcus/spot-router.d.ts +177 -0
  154. package/dist/exchanges/arcus/spot-router.js +183 -0
  155. package/dist/exchanges/arcus/spot.d.ts +109 -0
  156. package/dist/exchanges/arcus/spot.js +645 -0
  157. package/dist/exchanges/aster-funds.d.ts +127 -0
  158. package/dist/exchanges/aster-funds.js +252 -0
  159. package/dist/exchanges/aster-nonce.d.ts +2 -0
  160. package/dist/exchanges/aster-nonce.js +107 -0
  161. package/dist/exchanges/aster-spot.d.ts +117 -0
  162. package/dist/exchanges/aster-spot.js +686 -0
  163. package/dist/exchanges/aster-typed-data.d.ts +133 -7
  164. package/dist/exchanges/aster-typed-data.js +121 -7
  165. package/dist/exchanges/aster.d.ts +219 -6
  166. package/dist/exchanges/aster.js +1023 -153
  167. package/dist/exchanges/builder-fee.d.ts +254 -0
  168. package/dist/exchanges/builder-fee.js +421 -0
  169. package/dist/exchanges/canonical-symbols.d.ts +32 -0
  170. package/dist/exchanges/canonical-symbols.js +96 -0
  171. package/dist/exchanges/capabilities.d.ts +7 -1
  172. package/dist/exchanges/capabilities.js +7 -0
  173. package/dist/exchanges/hl-signing.d.ts +165 -0
  174. package/dist/exchanges/hl-signing.js +158 -0
  175. package/dist/exchanges/hyperliquid-outcome.d.ts +211 -0
  176. package/dist/exchanges/hyperliquid-outcome.js +646 -0
  177. package/dist/exchanges/hyperliquid-spot.d.ts +44 -5
  178. package/dist/exchanges/hyperliquid-spot.js +308 -117
  179. package/dist/exchanges/hyperliquid.d.ts +462 -57
  180. package/dist/exchanges/hyperliquid.js +1575 -449
  181. package/dist/exchanges/index.d.ts +6 -0
  182. package/dist/exchanges/index.js +4 -0
  183. package/dist/exchanges/interface.d.ts +63 -10
  184. package/dist/exchanges/interface.js +18 -3
  185. package/dist/exchanges/ioc-outcome.d.ts +44 -0
  186. package/dist/exchanges/ioc-outcome.js +57 -0
  187. package/dist/exchanges/legacy-trading-v2.d.ts +39 -0
  188. package/dist/exchanges/legacy-trading-v2.js +940 -0
  189. package/dist/exchanges/lighter-public.d.ts +43 -0
  190. package/dist/exchanges/lighter-public.js +276 -0
  191. package/dist/exchanges/lighter-rh-deposit.d.ts +62 -0
  192. package/dist/exchanges/lighter-rh-deposit.js +185 -0
  193. package/dist/exchanges/lighter-signer.d.ts +123 -0
  194. package/dist/exchanges/lighter-signer.js +215 -0
  195. package/dist/exchanges/lighter-spot.d.ts +91 -13
  196. package/dist/exchanges/lighter-spot.js +595 -233
  197. package/dist/exchanges/lighter.d.ts +611 -39
  198. package/dist/exchanges/lighter.js +1890 -649
  199. package/dist/exchanges/ondo/adapter.d.ts +166 -0
  200. package/dist/exchanges/ondo/adapter.js +835 -0
  201. package/dist/exchanges/ondo/agent.d.ts +31 -0
  202. package/dist/exchanges/ondo/agent.js +101 -0
  203. package/dist/exchanges/ondo/client.d.ts +60 -0
  204. package/dist/exchanges/ondo/client.js +297 -0
  205. package/dist/exchanges/ondo/funds.d.ts +122 -0
  206. package/dist/exchanges/ondo/funds.js +290 -0
  207. package/dist/exchanges/ondo/public.d.ts +95 -0
  208. package/dist/exchanges/ondo/public.js +214 -0
  209. package/dist/exchanges/ondo/spot.d.ts +127 -0
  210. package/dist/exchanges/ondo/spot.js +392 -0
  211. package/dist/exchanges/outcome-interface.d.ts +140 -0
  212. package/dist/exchanges/outcome-interface.js +16 -0
  213. package/dist/exchanges/pacifica-spot.d.ts +83 -0
  214. package/dist/exchanges/pacifica-spot.js +324 -0
  215. package/dist/exchanges/pacifica-typed-data.d.ts +30 -13
  216. package/dist/exchanges/pacifica-typed-data.js +57 -9
  217. package/dist/exchanges/pacifica.d.ts +288 -4
  218. package/dist/exchanges/pacifica.js +1013 -76
  219. package/dist/exchanges/precision.d.ts +47 -0
  220. package/dist/exchanges/precision.js +209 -0
  221. package/dist/exchanges/qfex/adapter.d.ts +341 -0
  222. package/dist/exchanges/qfex/adapter.js +1383 -0
  223. package/dist/exchanges/qfex/agent.d.ts +58 -0
  224. package/dist/exchanges/qfex/agent.js +188 -0
  225. package/dist/exchanges/qfex/client.d.ts +54 -0
  226. package/dist/exchanges/qfex/client.js +138 -0
  227. package/dist/exchanges/qfex/errors.d.ts +70 -0
  228. package/dist/exchanges/qfex/errors.js +236 -0
  229. package/dist/exchanges/qfex/public.d.ts +122 -0
  230. package/dist/exchanges/qfex/public.js +268 -0
  231. package/dist/exchanges/qfex/signing.d.ts +160 -0
  232. package/dist/exchanges/qfex/signing.js +283 -0
  233. package/dist/exchanges/qfex/ws-transport.d.ts +294 -0
  234. package/dist/exchanges/qfex/ws-transport.js +798 -0
  235. package/dist/exchanges/rate-limiter.d.ts +12 -0
  236. package/dist/exchanges/rate-limiter.js +64 -0
  237. package/dist/exchanges/registry.d.ts +14 -2
  238. package/dist/exchanges/registry.js +20 -32
  239. package/dist/exchanges/slippage.d.ts +37 -0
  240. package/dist/exchanges/slippage.js +70 -0
  241. package/dist/exchanges/spot-factory.d.ts +166 -0
  242. package/dist/exchanges/spot-factory.js +431 -0
  243. package/dist/exchanges/spot-interface.d.ts +98 -4
  244. package/dist/exchanges/spot-interface.js +27 -1
  245. package/dist/exchanges/spot-result.d.ts +79 -0
  246. package/dist/exchanges/spot-result.js +273 -0
  247. package/dist/exchanges/trading-v2.d.ts +117 -0
  248. package/dist/exchanges/trading-v2.js +301 -0
  249. package/dist/exchanges/venue-types.d.ts +231 -0
  250. package/dist/exchanges/venue-types.js +87 -0
  251. package/dist/exchanges/venue.d.ts +211 -0
  252. package/dist/exchanges/venue.js +132 -0
  253. package/dist/exchanges/venues/arcus.d.ts +8 -0
  254. package/dist/exchanges/venues/arcus.js +109 -0
  255. package/dist/exchanges/venues/aster.d.ts +49 -0
  256. package/dist/exchanges/venues/aster.js +176 -0
  257. package/dist/exchanges/venues/create-helpers.d.ts +18 -0
  258. package/dist/exchanges/venues/create-helpers.js +199 -0
  259. package/dist/exchanges/venues/hyperliquid.d.ts +23 -0
  260. package/dist/exchanges/venues/hyperliquid.js +126 -0
  261. package/dist/exchanges/venues/index.d.ts +16 -0
  262. package/dist/exchanges/venues/index.js +26 -0
  263. package/dist/exchanges/venues/lighter-family.d.ts +92 -0
  264. package/dist/exchanges/venues/lighter-family.js +166 -0
  265. package/dist/exchanges/venues/lighter-rh.d.ts +7 -0
  266. package/dist/exchanges/venues/lighter-rh.js +58 -0
  267. package/dist/exchanges/venues/lighter.d.ts +6 -0
  268. package/dist/exchanges/venues/lighter.js +55 -0
  269. package/dist/exchanges/venues/ondo.d.ts +34 -0
  270. package/dist/exchanges/venues/ondo.js +140 -0
  271. package/dist/exchanges/venues/pacifica.d.ts +8 -0
  272. package/dist/exchanges/venues/pacifica.js +95 -0
  273. package/dist/exchanges/venues/qfex.d.ts +28 -0
  274. package/dist/exchanges/venues/qfex.js +132 -0
  275. package/dist/execution-log.js +10 -2
  276. package/dist/funding/legacy-public.d.ts +31 -0
  277. package/dist/funding/legacy-public.js +369 -0
  278. package/dist/funding/normalize.d.ts +28 -16
  279. package/dist/funding/normalize.js +61 -29
  280. package/dist/funding/rates.d.ts +46 -11
  281. package/dist/funding/rates.js +228 -277
  282. package/dist/guardrail/perp-guardrail.js +0 -0
  283. package/dist/index.js +157 -682
  284. package/dist/jobs.d.ts +84 -6
  285. package/dist/jobs.js +239 -41
  286. package/dist/landing.d.ts +14 -0
  287. package/dist/landing.js +36 -0
  288. package/dist/mcp-server.d.ts +14 -4
  289. package/dist/mcp-server.js +820 -402
  290. package/dist/mcp-trade-guard.d.ts +16 -0
  291. package/dist/mcp-trade-guard.js +59 -0
  292. package/dist/pacifica/client.d.ts +41 -10
  293. package/dist/pacifica/client.js +167 -63
  294. package/dist/pacifica/constants.d.ts +0 -1
  295. package/dist/pacifica/constants.js +0 -5
  296. package/dist/pacifica/deposit.d.ts +30 -3
  297. package/dist/pacifica/deposit.js +119 -2
  298. package/dist/pacifica/faucet.d.ts +29 -0
  299. package/dist/pacifica/faucet.js +100 -0
  300. package/dist/pacifica/sign-tx.d.ts +15 -0
  301. package/dist/pacifica/sign-tx.js +41 -0
  302. package/dist/pacifica/types/account.d.ts +28 -4
  303. package/dist/pacifica/types/lake.d.ts +20 -5
  304. package/dist/pacifica/types/lake.js +4 -0
  305. package/dist/pacifica/types/market.d.ts +5 -0
  306. package/dist/pacifica/types/order.d.ts +4 -1
  307. package/dist/pacifica/types/position.d.ts +9 -1
  308. package/dist/plan-executor.d.ts +10 -5
  309. package/dist/plan-executor.js +165 -54
  310. package/dist/position-history.js +13 -0
  311. package/dist/rebalance.d.ts +26 -2
  312. package/dist/rebalance.js +86 -7
  313. package/dist/relay-swap.d.ts +232 -0
  314. package/dist/relay-swap.js +630 -0
  315. package/dist/risk.js +5 -1
  316. package/dist/secret-env.d.ts +15 -0
  317. package/dist/secret-env.js +36 -0
  318. package/dist/settings.d.ts +169 -6
  319. package/dist/settings.js +219 -38
  320. package/dist/signer/ows-evm.d.ts +13 -0
  321. package/dist/signer/ows-evm.js +22 -0
  322. package/dist/smart-order.d.ts +9 -0
  323. package/dist/smart-order.js +53 -8
  324. package/dist/strategies/dca.d.ts +6 -2
  325. package/dist/strategies/dca.js +66 -26
  326. package/dist/strategies/funding-arb.d.ts +11 -1
  327. package/dist/strategies/funding-arb.js +202 -89
  328. package/dist/strategies/grid.d.ts +31 -0
  329. package/dist/strategies/grid.js +89 -11
  330. package/dist/strategies/pending-stop.d.ts +8 -0
  331. package/dist/strategies/pending-stop.js +12 -0
  332. package/dist/strategies/split-order.d.ts +45 -17
  333. package/dist/strategies/split-order.js +157 -91
  334. package/dist/strategies/trailing-stop.d.ts +2 -1
  335. package/dist/strategies/trailing-stop.js +52 -6
  336. package/dist/strategies/twap.d.ts +6 -1
  337. package/dist/strategies/twap.js +39 -11
  338. package/dist/trade-validator.d.ts +22 -0
  339. package/dist/trade-validator.js +119 -15
  340. package/dist/utils/numeric.d.ts +46 -0
  341. package/dist/utils/numeric.js +79 -0
  342. package/dist/utils.d.ts +19 -0
  343. package/dist/utils.js +96 -19
  344. package/dist/withdraw-gate.d.ts +49 -0
  345. package/dist/withdraw-gate.js +131 -0
  346. package/package.json +15 -6
  347. package/skills/perp-cli/SKILL.md +338 -134
  348. package/skills/perp-cli/references/agent-operations.md +181 -92
  349. package/skills/perp-cli/references/commands.md +475 -132
  350. package/skills/perp-cli/references/strategies.md +44 -38
  351. package/skills/perp-cli/scripts/arb-monitor.sh +22 -17
  352. package/skills/perp-cli/scripts/funding-analysis.sh +20 -10
  353. package/skills/perp-cli/scripts/preflight.sh +21 -14
  354. package/skills/perp-cli/scripts/spot-perp-scan.sh +12 -7
  355. package/skills/perp-cli/scripts/validate-arb.sh +33 -16
  356. package/vendor/lighter-signer/SHA256SUMS +2 -0
  357. package/vendor/lighter-signer/VERSION +8 -0
  358. package/vendor/lighter-signer/lighter-signer.wasm +0 -0
  359. package/vendor/lighter-signer/wasm_exec.js +575 -0
  360. package/dist/bot/strategies/funding-arb-v2-strategy.d.ts +0 -42
  361. package/dist/bot/strategies/funding-arb-v2-strategy.js +0 -864
@@ -2,74 +2,183 @@
2
2
 
3
3
  All commands support `--json` for structured output. Always use `--json` when calling from an agent.
4
4
 
5
+ ## Global Flags
6
+
7
+ `--json` (required for agents) | `-e <venue>` | `-n mainnet|testnet` | `--dry-run` (only commands whose `--help` says "supports --dry-run"; others refuse with `INVALID_PARAMS`) | `--fields <f1,f2>` | `--ndjson` | `-w, --wallet <name>` | `--ows <name>` (OWS wallet) | `--no-agent` (skip agent-key routing) | `--no-builder` | `--dex <name>` (HIP-3, Hyperliquid)
8
+
9
+ Venues (`-e`, id | aliases): `pacifica|pac`, `hyperliquid|hl`, `lighter|lt`, `lighter-rh|lrh|rh`, `aster|ast`, `ondo|ondo-perps`, `arcus`, `qfex|qf`. Default = `settings.defaultExchange`, else `pacifica` — always pass `-e`.
10
+ `-k <key>` is rejected (keys only via stdin / OWS vault). `--passphrase` is deprecated → `OWS_PASSPHRASE` env or stdin.
11
+
5
12
  ## Market Data (read-only, safe)
6
13
  ```bash
7
- perp --json market list # all markets with prices, funding, volume
8
- perp --json market prices # cross-exchange price comparison
9
- perp --json market mid <SYMBOL> # mid price (fast)
10
- perp --json market info <SYMBOL> # mark/index price, funding, volume, OI, max leverage
11
- perp --json market book <SYMBOL> # orderbook (bids/asks)
12
- perp --json market trades <SYMBOL> # recent trades
13
- perp --json market funding <SYMBOL> # funding rate history
14
- perp --json market kline <SYM> <INTERVAL> # OHLCV candles (1m,5m,15m,1h,4h,1d)
15
- perp --json market hip3 # list HIP-3 deployed perp dexes (Hyperliquid only)
14
+ perp --json -e <EX> market list # all markets with prices, funding, volume
15
+ perp --json market prices # cross-exchange price comparison
16
+ perp --json -e <EX> market mid <SYMBOL> # mid price (fast)
17
+ perp --json -e <EX> market info <SYMBOL> # mark/index price, funding, volume, OI, max leverage
18
+ perp --json -e <EX> market book <SYMBOL> # orderbook (bids/asks)
19
+ perp --json -e <EX> market trades <SYMBOL> # recent trades
20
+ perp --json -e <EX> market funding <SYMBOL> # funding rate history
21
+ perp --json -e <EX> market kline <SYM> <INT> # OHLCV candles (1m,5m,15m,1h,4h,1d)
22
+ perp --json market hip3 # list HIP-3 deployed perp dexes (Hyperliquid)
16
23
  ```
17
24
 
18
25
  ## Account (read-only, safe)
19
26
  ```bash
20
- perp --json account balance # perp balance + spot holdings + 24h funding (alias: account balance)
21
- perp --json account positions # open positions
22
- perp --json account orders # open/pending orders
23
- perp --json account history # order history
24
- perp --json account trades # trade fill history
25
- perp --json account funding-history # funding payments
26
- perp --json account pnl # profit & loss
27
- perp --json account margin <SYMBOL> # position margin info
28
- perp --json portfolio # cross-exchange unified view
27
+ perp --json portfolio -e <VENUE_ID> # perp balance + spot holdings + 24h funding; full venue id only (hl → INVALID_PARAMS)
28
+ perp --json -e <EX> account positions # open positions
29
+ perp --json -e <EX> account orders # open/pending orders
30
+ perp --json -e <EX> account history # order history
31
+ perp --json -e <EX> account trades # trade fill history
32
+ perp --json -e <EX> account funding-history # funding payments
33
+ perp --json -e <EX> account settings # per-market leverage & margin mode
34
+ perp --json -e <EX> account margin <SYMBOL> # position margin info
35
+ perp --json -e <EX> account pnl # realized + unrealized + funding
36
+ perp --json -e <EX> account twap-orders # active TWAP orders
37
+ perp --json portfolio # cross-exchange unified view
38
+ perp --json portfolio --arb # full dashboard with arb top 5
29
39
  ```
30
40
 
31
41
  ## Trading (requires user confirmation)
32
42
  ```bash
33
43
  # Market orders
34
- perp --json trade market <SYMBOL> <buy|sell> <SIZE>
35
- perp --json trade buy <SYMBOL> <SIZE> # shorthand market buy
36
- perp --json trade sell <SYMBOL> <SIZE> # shorthand market sell
44
+ perp --json -e <EX> trade market <SYMBOL> <buy|sell> <SIZE>
45
+ perp --json -e <EX> trade buy <SYMBOL> <SIZE> # shorthand market buy
46
+ perp --json -e <EX> trade sell <SYMBOL> <SIZE> # shorthand market sell
47
+ perp --json -e <EX> trade buy <SYM> <SIZE> --smart # IOC limit at best ask + 1 tick — pacifica/hyperliquid/lighter/aster only; not with --tp/--sl or a client id
48
+ perp --json -e <EX> trade buy <SYM> <SIZE> --client-id <id> # reused id → ok:true, data.duplicate:true (local ~/.perp/client-ids.jsonl; nothing sent)
49
+ # id formats: pacifica full UUID; hyperliquid 0x+32 hex; lighter(-rh) integer; qfex refuses --client-id (use --auto-id)
50
+ # Opening orders: --force bypasses the local risk limits (user consent only; never quarantine)
37
51
 
38
- # Limit orders
39
- perp --json trade limit <SYMBOL> <buy|sell> <PRICE> <SIZE>
52
+ # Split execution (orderbook-aware, for large orders)
53
+ perp --json -e <EX> trade split <SYMBOL> <buy|sell> <USD>
54
+ perp --json -e <EX> trade split <SYM> buy 5000 --max-slippage 0.5 --max-slices 5 --delay 2000 --min-slice 200
55
+ perp --json -e <EX> trade market <SYM> buy <SIZE> --split # split via flag
40
56
 
41
- # Stop orders
42
- perp --json trade stop <SYMBOL> <SIDE> <STOP_PRICE> <SIZE>
43
- perp --json trade tpsl <SYMBOL> <SIDE> --tp <PRICE> --sl <PRICE>
57
+ # Limit / stop / TPSL
58
+ perp --json -e <EX> trade limit <SYMBOL> <buy|sell> <PRICE> <SIZE> [--tif GTC|IOC|FOK|ALO] # default GTC on every venue; off-grid price → INVALID_TICK (never rounded)
59
+ perp --json -e <EX> trade stop <SYMBOL> <SIDE> <SIZE> <STOP_PRICE> # reduce-only by default; --no-reduce-only to open (refused on ondo / qfex)
60
+ perp --json -e <EX> trade tpsl <SYMBOL> <long|short> --tp <P> --sl <P> # positionSide = the open position's side
61
+ perp --json -e <EX> trade buy <SYMBOL> <SIZE> --tp <P> --sl <P> # entry protected by TP/SL (verified fill)
44
62
 
45
63
  # Order management
46
- perp --json trade edit <SYMBOL> <ORDER_ID> <PRICE> <SIZE>
47
- perp --json trade cancel <SYMBOL> <ORDER_ID>
48
- perp --json trade cancel-all
49
- perp --json trade check <SYMBOL> <SIDE> <SIZE> # pre-flight validation (no execution)
50
- perp --json trade check <SYM> <SIDE> <SIZE> --leverage 3 # check with specific leverage
64
+ perp --json -e <EX> trade edit <SYMBOL> <ORDER_ID> <PRICE> <SIZE>
65
+ perp --json -e <EX> trade cancel <SYMBOL_OR_ORDER_ID> [orderId]
66
+ perp --json -e <EX> trade cancel-all
67
+ perp --json -e <EX> trade cancel-stop <SYMBOL> <STOP_ORDER_ID> # pacifica / qfex only; other venues: trade cancel
68
+ perp --json -e <EX> trade cancel-twap <SYMBOL> <TWAP_ORDER_ID>
69
+ perp --json -e <EX> trade status <ORDER_ID|c:<CLIENT_ID>> [--symbol <SYM>]
70
+ # --symbol required on ondo / arcus / qfex, and for c:<id> on lighter / lighter-rh / aster
71
+ perp --json -e <EX> trade fills [SYMBOL] # recent fills
72
+
73
+ # Pre-flight validation
74
+ perp --json -e <EX> trade check <SYMBOL> <SIDE> <SIZE>
75
+ perp --json -e <EX> trade check <SYM> <SIDE> <SIZE> --leverage 3
51
76
  # NOTE: trade check does NOT read exchange-set leverage. Always pass --leverage explicitly.
52
77
 
53
78
  # Position management
54
- perp --json trade close <SYMBOL> # close single position
55
- perp --json trade close-all # close all positions
56
- perp --json trade flatten # cancel all orders + close all positions
57
- perp --json trade reduce <SYMBOL> <PCT> # reduce position by percentage
58
- perp --json trade leverage <SYMBOL> <N> # set leverage
79
+ perp --json -e <EX> trade close <SYMBOL> # close single position
80
+ perp --json -e <EX> trade close-all # close all positions
81
+ perp --json -e <EX> trade flatten # cancel all orders + close all positions
82
+ perp --json -e <EX> trade reduce <SYMBOL> <PCT> # reduce by percentage
83
+ perp --json -e <EX> trade leverage <SYMBOL> <N> [--isolated]
59
84
 
60
85
  # Advanced orders
61
- perp --json trade scale-tp <SYMBOL> --levels '<PRICE1>:<PCT>,<PRICE2>:<PCT>'
62
- perp --json trade scale-in <SYMBOL> <SIDE> --levels '<PRICE1>:<SIZE>,<PRICE2>:<SIZE>'
63
- perp --json trade pnl-track # real-time PnL tracker
86
+ perp --json -e <EX> trade scale-tp <SYMBOL> --levels '<P1>:<PCT>,<P2>:<PCT>'
87
+ perp --json -e <EX> trade scale-in <SYMBOL> <SIDE> --levels '<P1>:<PCT>,<P2>:<PCT>' (--size-usd <USD> | --size <BASE>) # percents sum to 100
88
+ perp --json -e <EX> trade pnl-track # real-time PnL tracker
89
+ perp --json -e <EX> trade twap <SYMBOL> <SIDE> <SIZE> <DURATION> # Pacifica: seconds (native), HL: minutes (native, min $100); others client-side: --background [--slices <n>]
90
+
91
+ # Spot helpers (any venue with spot)
92
+ perp --json -e <EX> trade spot-buy <SYMBOL> <SIZE>
93
+ perp --json -e <EX> trade spot-sell <SYMBOL> <SIZE>
94
+ perp --json -e <EX> trade spot-limit <SYMBOL> <SIDE> <PRICE> <SIZE> [--tif <tif>]
95
+ perp --json -e <EX> trade spot-cancel <SYMBOL> <ORDER_ID>
96
+ perp --json -e <EX> trade spot-orders [SYMBOL]
97
+ perp --json -e <EX> trade spot-transfer <to-spot|to-perp> <AMOUNT>
98
+ perp --json -e <EX> trade spot-balance
64
99
 
65
- # Split execution (orderbook-aware)
66
- perp --json trade split <SYMBOL> <buy|sell> <USD> # split large order into depth-based slices
67
- perp --json trade split <SYM> buy 5000 --max-slippage 0.5 --max-slices 5 --delay 2000 --min-slice 200
68
- perp --json trade market <SYM> buy <SIZE> --split # split via market command flag
69
- perp --json trade market <SYM> buy <SIZE> --split --max-slippage 0.5
100
+ # Multi-leg execution (legs exchange:symbol:side:size; failed legs rolled back; unconfirmed leg → quarantined; no --dry-run)
101
+ perp --json trade multi <legs...>
70
102
  ```
71
103
 
72
- ## Funds (Deposit, Withdraw, Transfer, Bridge, Rebalance)
104
+ ## Outcome Markets (Hyperliquid HIP-4)
105
+
106
+ Fully-collateralized binary/range contracts on Hyperliquid. Each outcome's quote token comes from `outcomeMeta.quoteToken` (`outcome list` shows it; USDC on every listed outcome as of 2026-10-12), held on Hyperliquid spot. No leverage / no liquidation. Minimum order value 10 quote tokens (price × shares ≥ 10). Sizes are whole shares.
107
+
108
+ ```bash
109
+ # List active outcome markets — parses the description string into
110
+ # class / underlying / expiry / targetPrice / period and lists each side
111
+ # with mid + assetId.
112
+ perp --json outcome list
113
+
114
+ # COMBINED VIEW — all sides' books in parallel + underlying mark price
115
+ # (HL perp mid for `description.underlying`) + gap vs targetPrice + ms
116
+ # until expiry + per-side implied probability. For a binary market the
117
+ # symmetric structure means Yes BID + No ASK ≈ 1.0; this is the
118
+ # preferred entry point for agents that need a single snapshot.
119
+ perp --json outcome view <outcome> [--depth N=10]
120
+
121
+ # Orderbook for ONE side only (use `view` if you want both at once).
122
+ # <side> accepts: 0/1, Yes/No, or #<enc> / +<enc> (the encoded form
123
+ # must match the outcome arg — mismatch throws INVALID_PARAMS).
124
+ perp --json outcome book <outcome> <side> [--depth N=10]
125
+
126
+ # Holdings + open orders.
127
+ perp --json outcome positions
128
+ perp --json outcome orders
129
+
130
+ # Place orders. ALWAYS dry-run first. [usd] = notional in the quote token, or --size <shares>; sell also --all.
131
+ perp --json --dry-run outcome buy <outcome> <side> <usd>
132
+ perp --json --dry-run outcome sell <outcome> <side> --all
133
+
134
+ # Live execution. --limit makes it GTC; without --limit it's IoC at best ask +5% (cap 1) / best bid -5%.
135
+ perp --json outcome buy <outcome> <side> [<usd> | --size <shares>] [--limit <px>] [--tif gtc|ioc|alo]
136
+ perp --json outcome sell <outcome> <side> [<usd> | --size <shares> | --all] [--limit <px>] [--tif gtc|ioc|alo]
137
+
138
+ # Cancel a resting order.
139
+ perp --json outcome cancel <outcome> <side> <oid>
140
+ ```
141
+
142
+ ### Identifier model
143
+
144
+ Same outcome side can be referenced 5 ways — the CLI normalises:
145
+
146
+ | Form | Example (BTC daily Yes) |
147
+ |---|---|
148
+ | `<outcome>, <side>` integer | `1, 0` |
149
+ | `<outcome>, <side>` name | `1, yes` |
150
+ | `#<enc>` (l2Book / candle / allMids coin) | `#10` |
151
+ | `+<enc>` (spotClearinghouseState balance coin) | `+10` |
152
+ | asset id (HL `/exchange` payload) | `100000010` |
153
+
154
+ Encoding formula: `enc = 10 * outcome + side`; asset id = `100,000,000 + enc`.
155
+
156
+ ### Foot-guns enforced (Rule #2)
157
+
158
+ - **Min notional:** `price * size < 10` quote tokens → `INVALID_PARAMS`. Enforced in dry-run too. A trade leaving a remainder worth < 10 warns (it cannot be sold alone — use `sell --all`); selling more than held → `SIZE_TOO_LARGE`.
159
+ - **Encoded-side mismatch:** `outcome buy 2 #10` (where `#10` decodes to outcome=1) → `INVALID_PARAMS`, never silently routes to outcome 2.
160
+ - **Insufficient quote token:** pre-checked before order send → `INSUFFICIENT_BALANCE` (hold the outcome's quote token on Hyperliquid spot).
161
+ - **Venue rejection:** HL returns HTTP 200 with `statuses[0].error` even when an order is rejected; the CLI raises `ORDER_REJECTED` (or `INSUFFICIENT_BALANCE`) so a "placed" message never masks a failure.
162
+
163
+ ### Agent workflow recommendation
164
+
165
+ ```
166
+ 1. perp --json outcome list # discover markets, parse description
167
+ 2. perp --json outcome view <outcome> # full snapshot: both books +
168
+ # underlying mark + gap vs target +
169
+ # implied probabilities + time to expiry
170
+ 3. perp --json --dry-run outcome buy <outcome> <side> <usd>
171
+ # validate notional, get user approval
172
+ 4. perp --json outcome buy <outcome> <side> <usd> [--limit <px>] [--tif ...]
173
+ # execute (only after explicit user OK)
174
+ 5. perp --json outcome positions # confirm fill / monitor
175
+ ```
176
+
177
+ `outcome view` replaces the old multi-call pattern (separate `book` + `market mid` lookups). One round-trip returns everything an agent needs to decide direction.
178
+
179
+ Settlement at `expiryMs` is venue-side: winning side → 1 quote token per share, losing → 0. Decide before expiry whether to self-close or let the venue settle.
180
+
181
+ ## Funds (deposit, withdraw, transfer, bridge, rebalance)
73
182
 
74
183
  All fund movement lives under `perp funds`.
75
184
 
@@ -80,126 +189,360 @@ perp --json funds deposit hyperliquid <AMOUNT>
80
189
  perp --json funds deposit lighter ethereum <AMOUNT> # L1 direct (min 1 USDC)
81
190
  perp --json funds deposit lighter cctp arbitrum <AMOUNT> # CCTP (min 5 USDC)
82
191
  perp --json funds deposit lighter info # all Lighter deposit routes
83
- perp --json funds withdraw pacifica <AMOUNT>
84
- perp --json funds withdraw hyperliquid <AMOUNT>
85
- perp --json funds withdraw lighter <AMOUNT>
86
- perp --json funds transfer <AMOUNT> <ADDRESS> # HL internal transfer (instant)
192
+ perp --json funds withdraw pacifica <AMOUNT> # to your own Solana wallet
193
+ perp --json funds withdraw hyperliquid <AMOUNT> [--chain arbitrum|ethereum|base] [--to <allowlisted addr>]
194
+ # CCTP (native USDC) to your wallet (default arbitrum; 0.2 USDC forwarding fee on Arbitrum).
195
+ # --to another address only if it is on settings withdraw.hyperliquid (else POLICY_DENIED).
196
+ perp --json funds withdraw lighter <AMOUNT> # -e lighter: USDC → Ethereum; -e lighter-rh: USDG → Robinhood Chain
197
+ perp --json funds deposit lighter-rh <AMOUNT> # USDG on Robinhood Chain (min 1, mainnet only)
198
+ perp --json funds withdraw ondo <AMOUNT> --to <ADDRESS> # USDC → Ethereum (address-book destination)
199
+ perp --json funds withdraw arcus <AMOUNT> # USDG → the account owner (min 1)
200
+ perp --json funds deposit qfex # prints the USDC / Arbitrum One deposit address (sends nothing)
201
+ perp --json --dry-run funds withdraw qfex <AMOUNT> --to <0x> # plan + local gate verdict (settings withdraw.qfex; user-only, terminal)
202
+ perp --json -e qfex funds transfer <AMOUNT> primary --from <account-uuid> # between your QFEX accounts
203
+ perp --json funds deposit aster <AMOUNT> [--chain bsc|arbitrum] [--asset USDT|USDC] # vault approve + deposit (mainnet; default BNB Chain USDT)
204
+ perp --json funds withdraw aster <AMOUNT> [--chain bsc|arbitrum] [--asset USDT|USDC] # → the account's own address (default USDT; mainnet; agent approved with --can-withdraw --ip-whitelist)
205
+ perp --json funds deposit ondo <AMOUNT> [--chain arbitrum|ethereum] [--probe <AMT>] # USDC transfer to the account's funding address (mainnet)
206
+ perp --json funds address-book add ondo <MASTER_ADDRESS> # SIWE challenge → Ondo withdrawal address book (own address only)
207
+ perp --json funds transfer <AMOUNT> <ADDRESS> # HL internal transfer (instant); destination must be on settings withdraw.hyperliquid
208
+ # settings withdraw.<venue> (allowlist + limits) is set ONLY by the user in an interactive terminal
209
+ # (--json / piped → POLICY_DENIED). Agents never set or change it.
87
210
  perp --json funds info # combined routes & limits
88
211
  ```
89
212
 
90
213
  ### Cross-chain bridge (multi-provider router: cctp / relay / debridge — auto-cheapest)
91
214
  ```bash
92
- perp --json funds bridge chains # supported chains
215
+ perp --json funds bridge chains # supported chains
93
216
  perp --json funds bridge quote --from <CHAIN> --to <CHAIN> --amount <AMT>
94
- perp --json funds bridge send --from <CHAIN> --to <CHAIN> --amount <AMT> # auto-cheapest
95
- perp --json funds bridge send --from <CHAIN> --to <CHAIN> --amount <AMT> --provider cctp
96
- perp --json funds bridge exchange --from <EX> --to <EX> --amount <AMT> # between exchanges
217
+ perp --json funds bridge send --from <CHAIN> --to <CHAIN> --amount <AMT>
218
+ perp --json funds bridge send --from <CHAIN> --to <CHAIN> --amount <AMT> --provider cctp [--fast]
219
+ # exactly --amount leaves the wallet; deBridge nativeFee (ETH/SOL) is shown separately;
220
+ # Solana-origin deBridge → NO_BRIDGE_ROUTE (use --provider cctp)
221
+ # Relay swaps (chains: robinhood, arbitrum, bsc, base, solana as destination; EVM origin; OWS master signs; recipient = your own address)
222
+ perp --json --dry-run funds bridge send --from robinhood --to arbitrum --from-asset USDG --to-asset USDC --amount <AMT> # verified quote only
223
+ perp --json funds bridge send --from robinhood --to solana --from-asset USDG --to-asset SOL --amount <AMT> --min-out <SOL> # stable → native needs --min-out
224
+ perp --json funds bridge send --from arbitrum --to robinhood --from-asset ETH --to-asset ETH --amount <ETH> # native gas to Robinhood Chain
225
+ perp --json funds bridge exchange --from <EX> --to <EX> --amount <AMT> # pacifica|hyperliquid|lighter
226
+ # wallet → wallet: bridges the master's OWN USDC between the venues' chains (pacifica → solana,
227
+ # lighter → arbitrum); no venue withdraw/deposit. hyperliquid: --from spends HyperCore spot USDC,
228
+ # --to credits HyperCore perps. HyperCore → Solana → NO_BRIDGE_ROUTE.
97
229
  perp --json funds bridge status <ORDER_ID>
98
230
  ```
99
231
 
100
- ### Inter-exchange rebalance (orchestrated withdraw → bridge → deposit)
232
+ ### Inter-exchange rebalance (withdraw → bridge; deposit is manual)
101
233
  ```bash
102
234
  perp --json funds rebalance check # balances across exchanges
103
235
  perp --json funds rebalance plan # compute optimal moves
104
- perp --json funds rebalance execute --auto-bridge # withdraw → bridge → deposit
236
+ perp --json --dry-run funds rebalance execute --auto-bridge # status "simulated" (moves[].status "dry_run") or "balanced"
237
+ perp --json funds rebalance execute --auto-bridge # withdraw → bridge only (NO deposit)
105
238
  perp --json funds rebalance execute --withdraw-only # only withdraw, manual rest
106
239
  ```
240
+ `ok:true` even if a move failed — check every `moves[].status`: `withdrawn` | `bridged` | `same_chain` | `needs_bridge` | `withdraw_failed` | `bridge_failed`. Then deposit by hand after arrival (`funds deposit <venue> <amt>`).
107
241
 
108
242
  ## Arbitrage
243
+
244
+ All scan modes are routed through `arb scan`. Legacy aliases (`arb rates`, `arb prices`, `arb dex`, `arb spot-exec`, `arb spot-close`) are removed.
245
+
109
246
  ```bash
110
- # Perp-Perp arb
111
- perp --json arb scan --min <BPS> # find opportunities (>N bps spread) — PRIMARY command
112
- perp --json arb exec <SYM> <longEx> <shortEx> <$> # execute perp-perp arb
113
- perp --json arb close <SYM> # close perp-perp arb
114
- perp --json arb status # monitor open arb positions
115
- perp --json arb funding-earned # actual funding payments
247
+ # Scan (read-only, safe)
248
+ perp --json arb scan # default --mode all (perp-perp + spot-perp)
249
+ perp --json arb scan --mode perp-perp --min 10 # perp-only with min annual %
250
+ perp --json arb scan --mode spot-perp --min 10 # spot+perp only
251
+ perp --json arb scan --rates # funding rates across exchanges
252
+ perp --json arb scan --basis [SYMBOL] # cross-exchange basis
253
+ perp --json arb scan --gaps # cross-exchange price gaps
254
+ perp --json arb scan --hip3 # HIP-3 cross-dex spreads
255
+ perp --json arb scan --history [SYMBOL] # historical funding
256
+ perp --json arb scan --compare <SYMBOL> # compare a symbol across exchanges
257
+ perp --json arb scan --positions # position funding impact
258
+ perp --json arb scan --live --interval 60 # continuous monitoring
259
+ perp --json arb scan --top 10 --hold-days 7 --bridge-cost 0 --size 100 # cost-aware filtering
260
+ perp --json arb scan --rates --include-unverified # also show QFEX (unverified funding; display only, never ranked)
261
+ # netSpread / grossSpread = annualized % (netSpread = gross minus round-trip costs amortized over --hold-days)
262
+ # spot-perp rows: netSpreadPct / grossSpreadPct, spotExchanges[], perpExchange, direction
263
+
264
+ # Execute (perp-perp or spot+perp via spot:<venue>; spot venues: hl, lt, lrh, aster, ondo)
265
+ # Sequential: long first, then the short sized to the verified long fill; reconcile always on;
266
+ # an unconfirmed leg quarantines the symbol. Supports --dry-run.
267
+ perp --json arb exec <SYM> <longEx> <shortEx> <USD> # perp-perp dual-leg entry
268
+ perp --json arb exec <SYM> spot:hl hl <USD> # spot+perp via HL spot
269
+ perp --json arb exec <SYM> spot:lt pac <USD> # spot+perp via LT spot
270
+ perp --json arb exec <SYM> <longEx> <shortEx> <USD> \
271
+ --leverage 2 --isolated --smart --max-slippage 0.5
116
272
 
117
- # Spot+Perp arb (spot funding = 0, spread = |perp funding|)
118
- perp --json arb scan --mode spot-perp # scan spot+perp opportunities
119
- perp --json arb scan --mode all # both perp-perp + spot-perp
120
- perp --json arb spot-exec <SYM> <spotEx> <perpEx> <$> # execute spot+perp arb
121
- perp --json arb spot-close <SYM> --spot-exch <hl|lt> # close spot+perp arb
122
- # spotEx: hl (Hyperliquid) or lt (Lighter). perpEx: hl, lt, pac.
123
- # HL spot uses U-tokens: BTC→UBTC, ETH→UETH, SOL→USOL (auto-resolved)
273
+ # Close
274
+ perp --json arb close <SYM> # close perp-perp arb
275
+ perp --json arb close <SYM> --pair <longEx>:<shortEx> # disambiguate by pair
276
+ perp --json arb close <SYM> --spot-exch hl --perp-exch hl # close spot+perp legs
277
+ perp --json arb close <SYM> --smart # IOC limits at best price
278
+ perp --json arb close <SYM> --force # quarantined symbol — only after the user checked positions
279
+ perp --json arb close <SYM> --state-only --yes # drop a stale state entry (no order sent)
124
280
 
125
- # Other arb tools
126
- perp --json arb rates # funding rates across all DEXs (detailed)
127
- perp --json arb prices # cross-exchange price gaps
128
- perp --json arb dex # HIP-3 cross-dex arb (Hyperliquid)
129
- # Deprecated: 'gap show' → use 'arb prices'; 'funding rates/spread' → use 'arb rates/scan'
281
+ # Status / history / config / rebalance
282
+ perp --json arb status # open arb positions + PnL + funding; check unconfirmedPairs, staleStateEntries
283
+ perp --json arb status --period 7 --symbol BTC # filter funding lookback / symbol
284
+ perp --json arb history # alias: arb log
285
+ perp --json arb history --period 30 # past arb trade performance
286
+ perp --json arb config # show arb defaults
287
+ perp --json arb rebalance --check # cross-exchange balance distribution (read-only)
288
+ perp --json arb rebalance --target 50:50 --amount 1000 # plan only; execute with funds rebalance execute
289
+
290
+ # Auto-execute daemon
291
+ perp --json arb auto --min-spread 30 --close-spread 5 --size 100 --max-positions 5
292
+ perp --json arb auto --background # tmux session
293
+ perp --json arb auto --hip3 --min-oi 50000 --min-grade C # HIP-3 mode
294
+ perp --json --dry-run arb auto # simulate (--background inherits it)
130
295
  ```
131
296
 
132
297
  ## Wallet Management
133
298
  ```bash
134
- perp --json wallet set hl <KEY> # set Hyperliquid key
135
- perp --json wallet set pac <KEY> # set Pacifica key
136
- perp --json wallet set lt <KEY> # set Lighter key
137
- perp --json wallet set hl <KEY> --default # set key + make default exchange
138
- perp --json wallet show # show configured wallets (public addresses)
139
- perp --json wallet generate evm # generate new EVM wallet
140
- perp --json wallet generate solana # generate new Solana wallet
141
- perp --json wallet balance # on-chain balance
299
+ perp --json wallet generate evm # generate EVM wallet
300
+ perp --json wallet generate solana # generate Solana wallet
301
+ printf '%s' "$KEY" | OWS_PASSPHRASE=<pp> perp --json wallet import --name <n> [--chain evm|solana|dual] [--mnemonic] # import a key (stdin / hidden prompt; argv key, --evm/--solana <key>, --legacy rejected)
302
+ printf '%s' "$KEY" | OWS_PASSPHRASE=<pp> perp --json wallet set hl # import key (stdin / hidden prompt; argv key rejected) into OWS vault → active wallet
303
+ perp --json wallet set pac --name pac # Solana key, hidden prompt (TTY)
304
+ perp --json wallet set hl --default # also make hyperliquid the default exchange
305
+ perp --json wallet show # public addresses for active wallet
306
+ perp --json wallet list # all named wallets
307
+ perp --json wallet use <name> # set active wallet
308
+ perp --json wallet rename <old> <new>
309
+ perp --json wallet remove <name>
310
+ perp --json wallet balance # on-chain USDC balances
311
+ perp --json wallet solana <address> # check arbitrary Solana address
312
+ perp --json wallet arbitrum <address> # check arbitrary Arbitrum address
313
+ perp --json wallet migrate # migrate legacy ~/.perp/.env config
314
+ perp --json wallet rotate --from <name> --to <name> [--chain evm] # MUTATING: new wallet + transfers assets; no --dry-run — only on explicit user request
315
+ perp --json wallet backup # encrypted backup
316
+ perp --json wallet restore <file> # restore from backup
317
+ perp --json wallet deposit <walletName> [--for <ex>|-c <chain>] # MoonPay multi-chain deposit (auto-converts to USDC)
318
+ perp --json wallet setup --name <n> --max-tx-usd <usd> --max-daily-usd <usd> [--skip-key]
319
+ # one-click: wallet + policy + agent key.
320
+ # Passphrase prompt unless OWS_PASSPHRASE env is set.
321
+ ```
322
+
323
+ ### Agent wallet (DEX-side delegation)
324
+ ```bash
325
+ # Register an agent (master-signed: user consent; passphrase via OWS_PASSPHRASE / stdin; no --dry-run).
326
+ # Default expires-in is 90d — then AGENT_EXPIRED; pass --expires-in 1y / 180d / etc to extend.
327
+ perp --json wallet agent approve <exchange> \
328
+ [--master <name>] \
329
+ [--agent-name <name>] \
330
+ [--expires-in 30d|90d|180d|1y|<ISO-8601>] \
331
+ [--can-perp|--no-perp] [--can-spot|--no-spot] [--can-withdraw|--no-withdraw] \
332
+ [--rotate] \
333
+ [--ip-whitelist <list>] \
334
+ [--account-index <0-9|255>] # Arcus subaccount
335
+ [--api-key-index <n>] # Lighter slot 4-254 (default: first slot free locally AND on-chain)
336
+ [--force] # Lighter: overwrite an --api-key-index slot that already holds an on-chain key
337
+
338
+ # Import a key the USER created on the exchange WEBSITE (master wallet not needed here).
339
+ # Key on stdin only (one line; ondo: key id + secret; qfex: public key + secret) — an argv key is rejected (INVALID_PARAMS).
340
+ # Verified against the venue before storing (refused → nothing stored); pacifica → "unverified".
341
+ printf '%s' "$AGENT_KEY" | perp --json wallet agent import <exchange> \
342
+ [--master-address <addr>] # aster / pacifica / arcus: required; hyperliquid / lighter: cross-check
343
+ [--account-index <n>] [--api-key-index <n>] # lighter / lighter-rh: required (arcus: optional cross-check)
344
+ [--account-id <uuid>] # qfex: the account the key trades (default primary; required when piped — it confirms the binding)
345
+ [--agent-name <name>] [--expires-in <dur>] [--replace]
346
+ # → data: { source: "imported", masterAddress, agentAddress|publicKey, accountIndex, apiKeyIndex,
347
+ # expiresAt|null, storage, verification: { status: "verified"|"unverified", method } }
348
+
349
+ perp --json wallet agent list [exchange] # rows carry source: "approved" | "imported"
350
+ perp --json wallet agent revoke <exchange> <agentName> [--local-only]
351
+ # imported key: refused unless --local-only (deletes local key + record; still authorized on the
352
+ # exchange — revoke it on the website). --local-only on an approved agent = --force.
353
+ perp --json wallet agent rotate <exchange> [oldAgentName]
354
+ # imported key: refused — create a new key on the website, then import --agent-name <name> --replace
355
+ # verify: --master (Aster/PAC; passphrase via OWS_PASSPHRASE) / --master-address (HL only) / --account-index (Lighter only).
356
+ # Aster: NOT_IMPLEMENTED (no venue endpoint lists agents) — use wallet agent list aster.
357
+ perp --json wallet agent verify [exchange] [agentName] \
358
+ [--master <name>] [--master-address <addr>] [--account-index <n>]
359
+ ```
360
+
361
+ ### Builder fees (`wallet builder`) — OFF by default
362
+ ```bash
363
+ # Nothing is attached unless the user configures it explicitly (strict: format, cap, increment):
364
+ perp --json settings set builder.<venue> <address|code>,<feeBps> --yes # hyperliquid/aster: address; pacifica/ondo: code; --yes required non-interactively
365
+ perp --json settings unset builder.<venue>
366
+ perp --json wallet builder status [venue] # support, config, venue approval, attaches?
367
+ perp --json [--dry-run] wallet builder approve <venue> [--master <name>] [--yes] # master-signed; y/N or --yes
368
+ perp --json [--dry-run] wallet builder revoke <venue> [--master <name>] [--yes] # pacifica / aster
369
+ perp --json --no-builder -e <EX> trade market BTC buy 0.1 # never attach on this run
370
+ # Caps: hyperliquid 10 bps (never HIP-3), pacifica 10 bps max (perp-cli cap; never spot), aster 10 bps (mainnet),
371
+ # ondo 10 bps (no approval; also on position stops). lighter / lighter-rh / arcus → CAPABILITY_UNSUPPORTED.
372
+ # Approval missing/unknown → order sent WITHOUT the fee; execution.notes says why. execution.builderFee records it.
373
+ # No master on this computer → NO_SIGNER_AVAILABLE: approve on the venue website.
374
+ ```
375
+
376
+ ### Exchange settings (`wallet manage`)
377
+ ```bash
378
+ perp --json -e <EX> wallet manage margin <SYMBOL> <cross|isolated>
379
+ perp --json wallet manage account-mode [unified|standard|portfolio] # Hyperliquid only; no arg = show current
380
+ perp --json wallet manage sub create <name> # not supported (CAPABILITY_UNSUPPORTED): the subaccount wallet must co-sign — use the web app
381
+ perp --json wallet manage sub list
382
+ perp --json wallet manage sub transfer <from> <to> <amount> # <from> must be the signing account
383
+ perp --json wallet manage lake create [--manager <address>] [--nickname <name>] [--initial-deposit <amount>]
384
+ perp --json wallet manage lake deposit <lake> <amount> # <lake> = vault address
385
+ perp --json wallet manage lake withdraw <lake> <shares> # shares to redeem, not USDC
386
+ perp --json wallet manage builder overview # Pacifica builder-OWNER tools only (user approvals: wallet builder)
387
+ perp --json wallet manage builder trades <code>
388
+ perp --json wallet manage builder leaderboard <code>
389
+ perp --json wallet manage builder update-fee <code> <feeRate>
390
+ perp --json wallet manage referral claim <code> # Pacifica
391
+ perp --json -e hyperliquid wallet manage referral set [code] # HL / Lighter (-e lighter): signs + sends one referral action; supports --dry-run
392
+ perp --json wallet manage apikey create
393
+ perp --json wallet manage apikey list
394
+ perp --json wallet manage apikey revoke <key>
395
+ ```
396
+
397
+ ### OWS (Open Wallet Standard) API key + policy — optional, scoped agent tokens
398
+ ```bash
399
+ perp --json wallet key create
400
+ perp --json wallet key list
401
+ perp --json wallet key revoke <id>
402
+ perp --json wallet policy create
403
+ perp --json wallet policy list
404
+ perp --json wallet policy show <id>
405
+ perp --json wallet policy delete <id>
142
406
  ```
143
407
 
144
408
  ## Risk & Analytics
145
409
  ```bash
146
- perp --json risk status # portfolio risk overview (level, violations, canTrade)
147
- perp --json risk liquidation-distance # % distance from liquidation for ALL positions
148
- perp --json risk limits # view current risk limits
149
- perp --json risk limits --min-liq-distance 30 --max-leverage 5 # set risk limits
150
- perp --json risk check --notional 1000 --leverage 3 # pre-trade risk check
151
- perp --json history summary # trading performance
152
- perp --json history pnl # P&L breakdown by exchange
153
- perp --json history funding # funding payment aggregation
154
- perp --json history report # full performance report (summary + pnl + funding)
155
- perp --json history perf --period daily # daily PnL breakdown (replaces daily-pnl)
156
- perp --json history perf --period weekly # weekly PnL breakdown (replaces weekly-pnl)
157
- perp --json history perf --period summary # performance summary stats
158
- perp --json history list # execution audit trail
159
- ```
160
-
161
- ## Automated Strategies (strategy — 19 algorithms + nested scripted plans)
162
- ```bash
163
- perp --json strategy list-strategies # list all 19 strategies
164
- perp --json strategy run <STRATEGY> [SYMBOL] # run any registered strategy
165
- perp --json strategy run funding-auto # multi-exchange funding arb (no symbol needed)
166
- perp --json strategy apex [SYMBOL] # APEX autonomous orchestrator (Radar+Pulse+Guard)
167
- perp --json strategy reflect # trading performance analysis (win rate, fees, PnL)
168
- perp --json strategy preset-list # list strategy presets
169
- perp --json strategy preset <NAME> [SYMBOL] # run from preset
170
- perp --json strategy twap <SYMBOL> <SIDE> <SIZE> <DURATION> # TWAP execution
171
- perp --json strategy grid <SYMBOL> --range <PCT> --grids <N> --size <USD>
410
+ perp --json risk status # portfolio risk overview (level, violations, canTrade)
411
+ perp --json health # adapter health: ping venue REST endpoints (connectivity + latency)
412
+ perp --json risk liquidation-distance # % distance from liquidation for ALL positions
413
+ perp --json risk limits # view current risk limits
414
+ perp --json risk limits --min-liq-distance 30 --max-leverage 5 # set risk limits (also --max-position[-pct], --max-exposure[-pct], --max-positions, --daily-loss[-pct], --max-drawdown[-pct], --max-margin, --reset)
415
+ # The order gate (trade market/buy/sell/limit/split/scale-in/twap/multi, stop --no-reduce-only) enforces
416
+ # max position / total exposure / max positions; reduce-only exempt; --force bypasses (user consent only).
417
+ perp --json risk check --notional 1000 --leverage 3 # pre-trade risk check
418
+ ```
419
+
420
+ ## History (execution log + analytics)
421
+ ```bash
422
+ perp --json history list # execution audit trail
423
+ perp --json history positions # position lifetime tracking
424
+ perp --json history prune # purge old entries
425
+ perp --json history summary # trading performance summary (replaces former 'stats')
426
+ perp --json history pnl # P&L breakdown by exchange
427
+ perp --json history funding # funding payment aggregation
428
+ perp --json history report # full performance report (summary + pnl + funding)
429
+ perp --json history compare # compare strategies / accounts
430
+ perp --json history snapshot # equity snapshot
431
+ perp --json history track # PnL tracking helper
432
+ perp --json history perf --period daily # daily PnL breakdown
433
+ perp --json history perf --period weekly # weekly PnL breakdown
434
+ perp --json history perf --period summary # performance summary stats
435
+ ```
436
+
437
+ ## Strategies (`perp strategy` — 20 algorithms + nested scripted plans)
438
+ ```bash
439
+ perp --json strategy list-strategies # list all 20 strategies
440
+ perp --json strategy run <STRATEGY> [SYMBOL] [--exchanges <list>] # multi-venue strategies: --exchanges must include the -e venue
441
+ perp --json --dry-run strategy run <STRATEGY> [SYMBOL] # simulate (actions logged, never sent)
442
+ perp --json strategy run funding-auto # multi-exchange funding arb
443
+ perp --json strategy apex [SYMBOL] # APEX orchestrator
444
+ perp --json strategy reflect # performance analysis
445
+ perp --json strategy preset-list
446
+ perp --json strategy preset <NAME> [SYMBOL] [--size <n>] # grid: total base; DCA: base per order; arb: $ per leg
447
+ perp --json strategy start <CONFIG.yaml> # YAML/JSON config-driven
448
+ perp --json strategy quick-grid <SYMBOL>
449
+ perp --json strategy quick-dca <SYMBOL> <SIDE> <AMOUNT> <INTERVAL_SEC> [--orders <n>] # 0 = unlimited
450
+ perp --json strategy quick-arb
451
+ perp --json strategy delta-neutral
452
+ perp --json strategy twap <SYMBOL> <SIDE> <SIZE> <DURATION>
453
+ perp --json strategy grid <SYMBOL> --upper <PRICE> --lower <PRICE> --grids <N> --size <BASE> [--close-on-stop]
454
+ # at stop: orders cancelled; the grid's inventory stays OPEN (warning) unless --close-on-stop
172
455
  perp --json strategy dca <SYMBOL> <SIDE> <AMOUNT> <INTERVAL>
173
- perp --json strategy trailing-stop <SYMBOL> # trailing stop with callback %
174
- perp --json strategy funding-arb # auto funding arb
175
- perp --json strategy quick-grid <SYMBOL> # quick grid bot
176
- perp --json strategy quick-arb # quick arb bot
456
+ perp --json strategy trailing-stop <SYMBOL>
457
+ perp --json strategy funding-arb [--auto-execute] # monitor only unless --auto-execute
458
+
459
+ # Quarantine (unknown / unhedged outcome): global per symbol, network-scoped; blocks opening orders,
460
+ # arb exec / arb auto and bots (reduce-only passes). Clear only after the USER verified positions.
461
+ perp --json strategy quarantine
462
+ perp --json strategy quarantine-clear <SYMBOL> [--strategy <source>]
177
463
 
178
464
  # Scripted execution plans (one-shot multi-step)
179
- perp --json strategy plan example # show plan format
180
- perp --json strategy plan validate <FILE> # validate plan
181
- perp --json strategy plan execute <FILE> --dry-run # dry-run plan
465
+ perp --json strategy plan example
466
+ perp --json strategy plan validate <FILE>
467
+ perp --json --dry-run strategy plan execute <FILE>
468
+ # No --dry-run (refused with INVALID_PARAMS): strategy start / preset / quick-* / grid / dca / twap / funding-arb / apex
469
+ ```
470
+
471
+ ### Available Strategies (20)
472
+ - **Market Making:** `simple-mm`, `engine-mm`, `avellaneda-mm`, `regime-mm`, `grid-mm`, `liquidation-mm`
473
+ - **Signal/Directional:** `momentum-breakout`, `mean-reversion`, `aggressive-taker`
474
+ - **Arbitrage:** `funding-arb`, `funding-arb-v2`, `funding-auto`, `basis-arb`, `spot-perp-arb`
475
+ - **Infrastructure:** `hedge-agent`, `rfq-agent`, `claude-agent`
476
+ - **Classic:** `grid`, `dca`, `apex`
477
+
478
+ ## Background Process Supervisor (tmux)
479
+ ```bash
480
+ perp --json background list # list running jobs (default subcommand)
481
+ perp --json background stop <ID> [--timeout <sec>] # graceful: SIGINT (job cancels its orders, saves state), waits (default 90s), then kills; reports what is left on the venue
482
+ perp --json background logs <ID> # view logs (use -f to follow)
483
+ perp --json background remove <ID> # remove a job entry
484
+ perp --json background clean # purge all stopped/done jobs
485
+ ```
182
486
 
183
- # Background process supervisor (tmux)
184
- perp --json background list # list running jobs
185
- perp --json background stop <ID> # stop a job
186
- perp --json background logs <ID> # view job logs
187
- perp --json background remove <ID> # remove a job entry
188
- perp --json background clean # remove all stopped/done jobs
487
+ ## Backtest
488
+ ```bash
489
+ perp --json backtest funding-arb # backtest funding arb on historical data
490
+ perp --json backtest grid # backtest grid strategy
491
+ ```
492
+
493
+ ## Alerts (Telegram / Discord)
494
+ ```bash
495
+ perp alerts setup # interactive setup wizard
496
+ perp --json alerts test # send test message
497
+ perp --json alerts add <SYMBOL> <PCT> [--exchange <venue>] [--below] # annual funding % threshold (default: above)
498
+ perp --json alerts add --all <PCT> # alert for any symbol
499
+ perp --json alerts list # list active rules
500
+ perp --json alerts remove <SYMBOL|all> # remove a rule
501
+ perp alerts start [--background] # run daemon (tmux for background)
502
+ perp alerts stop # stop background daemon
189
503
  ```
190
504
 
191
- ### Available Strategies
192
- Market Making: `simple-mm`, `engine-mm`, `avellaneda-mm`, `regime-mm`, `grid-mm`, `liquidation-mm`
193
- Signal/Directional: `momentum-breakout`, `mean-reversion`, `aggressive-taker`
194
- Arbitrage: `funding-arb`, `funding-auto`, `basis-arb`
195
- Infrastructure: `hedge-agent`, `rfq-agent`, `claude-agent`
196
- Classic: `grid`, `dca`, `twap`, `apex`
505
+ ## Settings
506
+ ```bash
507
+ perp --json settings show # show current CLI settings
508
+ perp --json settings set <key> <value> # set a CLI default
509
+ # keys: default-exchange, defaultSlippageBps, slippageBps.<venue>, referralCodes.{hyperliquid,lighter},
510
+ # builder.<venue> "<address|code>,<feeBps>" (off unless set), bridge.debridgeAffiliate.{referralCode,fee}
511
+ perp --json settings unset <key> # slippageBps.<venue> | defaultSlippageBps | builder.<venue> | withdraw.<venue> | bridge.debridgeAffiliate
512
+ # withdraw.<venue> (withdraw / HL transfer allowlist + limits): USER ONLY, interactive terminal; agents never set it (POLICY_DENIED)
513
+ perp --json settings fees show # cached exchange fee table
514
+ perp --json settings fees sync # refresh fee cache
515
+ perp --json settings env show # show ~/.perp/.env values
516
+ perp --json settings env set <name> <value> # non-secret values only (keys / *_PRIVATE_KEY / secrets → INVALID_PARAMS; use wallet set)
517
+ perp --json settings env remove <name>
518
+ perp --json settings env path # config file path
519
+ ```
197
520
 
198
- ## Agent Wallet Management
521
+ ## Init / Setup
199
522
  ```bash
200
- perp wallet agent approve <exchange> [--master <name>] # Register an agent wallet
201
- perp wallet agent list [exchange] # List registered agents
202
- perp wallet agent revoke <exchange> <agentName> # Revoke an agent
203
- perp wallet agent rotate <exchange> [agentName] # Revoke + re-approve same name
204
- perp wallet agent verify [exchange] [agentName] # Verify via DEX query API
523
+ # Interactive default — DO NOT use from agent without flags (will hang on prompts).
524
+ perp setup # alias: perp init
525
+ perp init
526
+
527
+ # Agent-safe non-interactive variant (writes settings; signs nothing by default):
528
+ OWS_PASSPHRASE=<pp> perp --json [-n testnet] setup --non-interactive \
529
+ (--wallet <existing-ows-wallet> | --wallet-name <new-name>) \
530
+ [--venues <list>] [--default-venue <venue>] \
531
+ [--slippage-bps <n>] [--slippage <venue>=<bps> ...]
532
+ # Agent registration (signs with the master wallet — get user consent first):
533
+ # --approve-agents --yes [--aster-can-spot] [--lighter-api-key-index <n>]
534
+ # [--lighter-rh-api-key-index <n>] [--arcus-account-index <0-9|255>]
535
+ # [--ondo-secret-stdin] # Ondo key id + secret as 2 stdin lines; passphrase then via OWS_PASSPHRASE
536
+ # Keys created on the exchange WEBSITES (no master wallet needed when every venue is imported —
537
+ # then omit --wallet / --wallet-name; owsActiveWallet is left unchanged):
538
+ # --import-agents <venues> --yes # subset of --venues; keys on stdin, ONE LINE PER VENUE IN THIS ORDER
539
+ # # (ondo: 2 lines — key id, then secret; qfex: 2 lines — public key, then secret)
540
+ # [--master-address <venue>=<addr> ...] # required for aster, pacifica, arcus
541
+ # [--allow-unverified pacifica] # required for pacifica (no read-only check exists)
542
+ # [--qfex-account-id <uuid>] # required for qfex (confirms the bound account)
543
+ # [--lighter-account-index <n>] [--lighter-api-key-index <n>]
544
+ # [--lighter-rh-account-index <n>] [--lighter-rh-api-key-index <n>] [--arcus-account-index <n>]
545
+ # agents[] entries: { venue, status: "imported", agentName, verification }
205
546
  ```
547
+
548
+ For per-exchange key registration without the wizard, use `printf '%s' "$KEY" | OWS_PASSPHRASE=<pp> perp wallet set <ex>` — also agent-safe (key on stdin, never argv).