perp-cli 0.12.17 → 0.14.0

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