perp-cli 0.14.3 → 0.16.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 (363) hide show
  1. package/README.ja.md +243 -0
  2. package/README.ko.md +243 -0
  3. package/README.md +138 -405
  4. package/README.zh.md +243 -0
  5. package/dist/agent-wallet/store.d.ts +3 -2
  6. package/dist/agent-wallet/store.js +2 -2
  7. package/dist/api/public/hyperliquid.js +4 -0
  8. package/dist/api/public/lighter.d.ts +5 -0
  9. package/dist/api/public/lighter.js +5 -0
  10. package/dist/api/public/pacifica.js +85 -15
  11. package/dist/api/public/urls.d.ts +2 -0
  12. package/dist/api/public/urls.js +3 -0
  13. package/dist/arb/sizing.js +4 -2
  14. package/dist/arb/state.d.ts +6 -0
  15. package/dist/arb/utils.d.ts +1 -2
  16. package/dist/arb/utils.js +1 -2
  17. package/dist/balance-by-address.d.ts +39 -0
  18. package/dist/balance-by-address.js +44 -0
  19. package/dist/bot/apex/pulse.js +3 -0
  20. package/dist/bot/apex/radar.js +2 -1
  21. package/dist/bot/engine.d.ts +10 -1
  22. package/dist/bot/engine.js +14 -6
  23. package/dist/bot/indicators.d.ts +7 -0
  24. package/dist/bot/indicators.js +16 -0
  25. package/dist/bot/perp-order.d.ts +4 -4
  26. package/dist/bot/perp-order.js +5 -5
  27. package/dist/bot/quarantine.d.ts +1 -1
  28. package/dist/bot/quarantine.js +1 -1
  29. package/dist/bot/quote-rules.js +1 -1
  30. package/dist/bot/strategies/apex-strategy.js +3 -2
  31. package/dist/bot/strategies/engine-mm.js +6 -5
  32. package/dist/bot/strategies/funding-arb-strategy.js +12 -5
  33. package/dist/bot/strategies/funding-arb-utils.d.ts +15 -3
  34. package/dist/bot/strategies/funding-arb-utils.js +53 -20
  35. package/dist/bot/strategies/funding-auto.js +2 -2
  36. package/dist/bot/strategies/liquidation-mm.d.ts +1 -0
  37. package/dist/bot/strategies/liquidation-mm.js +8 -2
  38. package/dist/bot/strategies/momentum-breakout.d.ts +1 -0
  39. package/dist/bot/strategies/momentum-breakout.js +11 -3
  40. package/dist/bot/strategies/spot-perp-arb-strategy.d.ts +1 -1
  41. package/dist/bot/strategies/spot-perp-arb-strategy.js +6 -4
  42. package/dist/bot/strategies/spot-perp-executor.d.ts +1 -1
  43. package/dist/bot/strategies/spot-perp-executor.js +3 -3
  44. package/dist/bot/strategy-types.d.ts +2 -1
  45. package/dist/bot/tui/BotDashboard.d.ts +1 -1
  46. package/dist/bot/tui/BotDashboard.js +1 -1
  47. package/dist/cache.js +12 -6
  48. package/dist/cli-program.d.ts +15 -0
  49. package/dist/cli-program.js +126 -6
  50. package/dist/commands/account.js +168 -24
  51. package/dist/commands/agent-import.d.ts +7 -0
  52. package/dist/commands/agent-import.js +30 -1
  53. package/dist/commands/agent.d.ts +6 -3
  54. package/dist/commands/agent.js +160 -12
  55. package/dist/commands/arb/index.js +23 -81
  56. package/dist/commands/arb-auto.d.ts +24 -0
  57. package/dist/commands/arb-auto.js +175 -97
  58. package/dist/commands/arb.d.ts +20 -0
  59. package/dist/commands/arb.js +107 -163
  60. package/dist/commands/backtest.js +23 -21
  61. package/dist/commands/bot.js +1 -1
  62. package/dist/commands/builder.js +1 -1
  63. package/dist/commands/funds.js +113 -3
  64. package/dist/commands/init.d.ts +1 -1
  65. package/dist/commands/init.js +27 -7
  66. package/dist/commands/manage.js +23 -21
  67. package/dist/commands/market.d.ts +48 -0
  68. package/dist/commands/market.js +395 -100
  69. package/dist/commands/options.d.ts +14 -0
  70. package/dist/commands/options.js +151 -0
  71. package/dist/commands/pacifica-earn.d.ts +5 -0
  72. package/dist/commands/pacifica-earn.js +455 -0
  73. package/dist/commands/pacifica-orders.d.ts +14 -0
  74. package/dist/commands/pacifica-orders.js +142 -0
  75. package/dist/commands/portfolio.d.ts +16 -0
  76. package/dist/commands/portfolio.js +83 -55
  77. package/dist/commands/rebalance.d.ts +1 -0
  78. package/dist/commands/rebalance.js +15 -0
  79. package/dist/commands/risk.d.ts +11 -2
  80. package/dist/commands/risk.js +39 -44
  81. package/dist/commands/trade.d.ts +1 -0
  82. package/dist/commands/trade.js +67 -62
  83. package/dist/commands/wallet.js +1 -1
  84. package/dist/config.d.ts +2 -2
  85. package/dist/config.js +15 -4
  86. package/dist/constants.js +6 -0
  87. package/dist/cross-chain-margin.d.ts +3 -1
  88. package/dist/cross-chain-margin.js +4 -2
  89. package/dist/dashboard/server.js +3 -3
  90. package/dist/dashboard/ui.js +9 -6
  91. package/dist/errors.d.ts +29 -1
  92. package/dist/errors.js +35 -3
  93. package/dist/exchanges/address.d.ts +8 -0
  94. package/dist/exchanges/address.js +47 -0
  95. package/dist/exchanges/arcus/adapter.d.ts +16 -12
  96. package/dist/exchanges/arcus/adapter.js +45 -18
  97. package/dist/exchanges/arcus/agent.d.ts +1 -1
  98. package/dist/exchanges/arcus/agent.js +1 -1
  99. package/dist/exchanges/arcus/client.js +1 -1
  100. package/dist/exchanges/arcus/public.js +3 -2
  101. package/dist/exchanges/arcus/signing.d.ts +2 -3
  102. package/dist/exchanges/arcus/signing.js +1 -1
  103. package/dist/exchanges/arcus/spot-chain.d.ts +1 -1
  104. package/dist/exchanges/arcus/spot-chain.js +1 -1
  105. package/dist/exchanges/arcus/spot-router.d.ts +1 -1
  106. package/dist/exchanges/arcus/spot-router.js +2 -2
  107. package/dist/exchanges/arcus/spot.d.ts +2 -3
  108. package/dist/exchanges/arcus/spot.js +2 -3
  109. package/dist/exchanges/aster-spot.d.ts +3 -3
  110. package/dist/exchanges/aster-spot.js +6 -9
  111. package/dist/exchanges/aster-typed-data.d.ts +1 -1
  112. package/dist/exchanges/aster-typed-data.js +1 -1
  113. package/dist/exchanges/aster.d.ts +30 -10
  114. package/dist/exchanges/aster.js +153 -53
  115. package/dist/exchanges/builder-fee.d.ts +1 -1
  116. package/dist/exchanges/builder-fee.js +13 -2
  117. package/dist/exchanges/canonical-symbols.d.ts +8 -2
  118. package/dist/exchanges/canonical-symbols.js +46 -2
  119. package/dist/exchanges/capabilities.d.ts +2 -0
  120. package/dist/exchanges/capabilities.js +2 -1
  121. package/dist/exchanges/derive/client.d.ts +37 -0
  122. package/dist/exchanges/derive/client.js +135 -0
  123. package/dist/exchanges/derive/options.d.ts +73 -0
  124. package/dist/exchanges/derive/options.js +379 -0
  125. package/dist/exchanges/extended/adapter.d.ts +96 -0
  126. package/dist/exchanges/extended/adapter.js +241 -0
  127. package/dist/exchanges/extended/client.d.ts +38 -0
  128. package/dist/exchanges/extended/client.js +88 -0
  129. package/dist/exchanges/extended/public.d.ts +133 -0
  130. package/dist/exchanges/extended/public.js +436 -0
  131. package/dist/exchanges/grvt/adapter.d.ts +100 -0
  132. package/dist/exchanges/grvt/adapter.js +283 -0
  133. package/dist/exchanges/grvt/client.d.ts +25 -0
  134. package/dist/exchanges/grvt/client.js +86 -0
  135. package/dist/exchanges/grvt/public.d.ts +151 -0
  136. package/dist/exchanges/grvt/public.js +438 -0
  137. package/dist/exchanges/hyperliquid-outcome.d.ts +2 -0
  138. package/dist/exchanges/hyperliquid-outcome.js +29 -1
  139. package/dist/exchanges/hyperliquid-spot.d.ts +9 -1
  140. package/dist/exchanges/hyperliquid-spot.js +24 -16
  141. package/dist/exchanges/hyperliquid.d.ts +199 -22
  142. package/dist/exchanges/hyperliquid.js +550 -202
  143. package/dist/exchanges/index.d.ts +1 -1
  144. package/dist/exchanges/index.js +1 -1
  145. package/dist/exchanges/interface.d.ts +157 -13
  146. package/dist/exchanges/interface.js +47 -0
  147. package/dist/exchanges/ioc-outcome.d.ts +1 -1
  148. package/dist/exchanges/ioc-outcome.js +1 -1
  149. package/dist/exchanges/legacy-trading-v2.d.ts +2 -2
  150. package/dist/exchanges/legacy-trading-v2.js +7 -2
  151. package/dist/exchanges/lighter-public.d.ts +67 -12
  152. package/dist/exchanges/lighter-public.js +250 -82
  153. package/dist/exchanges/lighter-signer.d.ts +1 -1
  154. package/dist/exchanges/lighter-signer.js +1 -1
  155. package/dist/exchanges/lighter-spot.d.ts +10 -5
  156. package/dist/exchanges/lighter-spot.js +105 -97
  157. package/dist/exchanges/lighter.d.ts +80 -21
  158. package/dist/exchanges/lighter.js +312 -105
  159. package/dist/exchanges/ondo/adapter.d.ts +38 -13
  160. package/dist/exchanges/ondo/adapter.js +86 -27
  161. package/dist/exchanges/ondo/agent.d.ts +1 -1
  162. package/dist/exchanges/ondo/agent.js +1 -1
  163. package/dist/exchanges/ondo/client.d.ts +1 -1
  164. package/dist/exchanges/ondo/client.js +2 -2
  165. package/dist/exchanges/ondo/public.d.ts +35 -3
  166. package/dist/exchanges/ondo/public.js +75 -32
  167. package/dist/exchanges/ondo/spot.d.ts +2 -2
  168. package/dist/exchanges/ondo/spot.js +3 -3
  169. package/dist/exchanges/options-interface.d.ts +158 -0
  170. package/dist/exchanges/options-interface.js +17 -0
  171. package/dist/exchanges/options-venues.d.ts +12 -0
  172. package/dist/exchanges/options-venues.js +35 -0
  173. package/dist/exchanges/outcome-interface.d.ts +4 -0
  174. package/dist/exchanges/pacifica-atomic.d.ts +211 -0
  175. package/dist/exchanges/pacifica-atomic.js +440 -0
  176. package/dist/exchanges/pacifica-decimal.d.ts +10 -0
  177. package/dist/exchanges/pacifica-decimal.js +51 -0
  178. package/dist/exchanges/pacifica-presigned.d.ts +53 -0
  179. package/dist/exchanges/pacifica-presigned.js +141 -0
  180. package/dist/exchanges/pacifica-print.d.ts +200 -0
  181. package/dist/exchanges/pacifica-print.js +417 -0
  182. package/dist/exchanges/pacifica-spot.d.ts +8 -2
  183. package/dist/exchanges/pacifica-spot.js +26 -18
  184. package/dist/exchanges/pacifica-typed-data.d.ts +1 -1
  185. package/dist/exchanges/pacifica-typed-data.js +1 -1
  186. package/dist/exchanges/pacifica-vaults.d.ts +130 -0
  187. package/dist/exchanges/pacifica-vaults.js +277 -0
  188. package/dist/exchanges/pacifica.d.ts +108 -10
  189. package/dist/exchanges/pacifica.js +428 -171
  190. package/dist/exchanges/precision.d.ts +3 -1
  191. package/dist/exchanges/precision.js +9 -2
  192. package/dist/exchanges/public-balances.d.ts +25 -0
  193. package/dist/exchanges/public-balances.js +158 -0
  194. package/dist/exchanges/public-positions.d.ts +43 -0
  195. package/dist/exchanges/public-positions.js +154 -0
  196. package/dist/exchanges/qfex/adapter.d.ts +69 -13
  197. package/dist/exchanges/qfex/adapter.js +102 -17
  198. package/dist/exchanges/qfex/agent.d.ts +1 -1
  199. package/dist/exchanges/qfex/agent.js +1 -1
  200. package/dist/exchanges/qfex/client.d.ts +1 -1
  201. package/dist/exchanges/qfex/client.js +1 -1
  202. package/dist/exchanges/qfex/errors.d.ts +1 -1
  203. package/dist/exchanges/qfex/errors.js +2 -2
  204. package/dist/exchanges/qfex/public.d.ts +65 -12
  205. package/dist/exchanges/qfex/public.js +131 -25
  206. package/dist/exchanges/qfex/signing.d.ts +2 -2
  207. package/dist/exchanges/qfex/signing.js +4 -5
  208. package/dist/exchanges/qfex/ws-transport.d.ts +3 -3
  209. package/dist/exchanges/qfex/ws-transport.js +3 -3
  210. package/dist/exchanges/rate-limiter.d.ts +1 -1
  211. package/dist/exchanges/rate-limiter.js +5 -2
  212. package/dist/exchanges/registry.d.ts +1 -1
  213. package/dist/exchanges/registry.js +1 -1
  214. package/dist/exchanges/risex/adapter.d.ts +160 -0
  215. package/dist/exchanges/risex/adapter.js +842 -0
  216. package/dist/exchanges/risex/agent.d.ts +154 -0
  217. package/dist/exchanges/risex/agent.js +384 -0
  218. package/dist/exchanges/risex/client.d.ts +47 -0
  219. package/dist/exchanges/risex/client.js +174 -0
  220. package/dist/exchanges/risex/nonce.d.ts +43 -0
  221. package/dist/exchanges/risex/nonce.js +212 -0
  222. package/dist/exchanges/risex/public.d.ts +64 -0
  223. package/dist/exchanges/risex/public.js +150 -0
  224. package/dist/exchanges/risex/session.d.ts +71 -0
  225. package/dist/exchanges/risex/session.js +171 -0
  226. package/dist/exchanges/risex/typed-data.d.ts +173 -0
  227. package/dist/exchanges/risex/typed-data.js +240 -0
  228. package/dist/exchanges/risex/units.d.ts +29 -0
  229. package/dist/exchanges/risex/units.js +104 -0
  230. package/dist/exchanges/slippage.d.ts +1 -1
  231. package/dist/exchanges/slippage.js +1 -1
  232. package/dist/exchanges/spot-factory.d.ts +3 -3
  233. package/dist/exchanges/spot-factory.js +8 -8
  234. package/dist/exchanges/spot-interface.d.ts +5 -5
  235. package/dist/exchanges/spot-interface.js +2 -2
  236. package/dist/exchanges/spot-result.d.ts +3 -3
  237. package/dist/exchanges/spot-result.js +3 -3
  238. package/dist/exchanges/trading-v2.d.ts +3 -3
  239. package/dist/exchanges/trading-v2.js +9 -6
  240. package/dist/exchanges/txflow/adapter.d.ts +61 -0
  241. package/dist/exchanges/txflow/adapter.js +150 -0
  242. package/dist/exchanges/txflow/client.d.ts +47 -0
  243. package/dist/exchanges/txflow/client.js +155 -0
  244. package/dist/exchanges/txflow/public.d.ts +87 -0
  245. package/dist/exchanges/txflow/public.js +355 -0
  246. package/dist/exchanges/unknown-symbol.d.ts +34 -0
  247. package/dist/exchanges/unknown-symbol.js +56 -0
  248. package/dist/exchanges/variational/adapter.d.ts +67 -0
  249. package/dist/exchanges/variational/adapter.js +137 -0
  250. package/dist/exchanges/variational/client.d.ts +21 -0
  251. package/dist/exchanges/variational/client.js +66 -0
  252. package/dist/exchanges/variational/public.d.ts +126 -0
  253. package/dist/exchanges/variational/public.js +430 -0
  254. package/dist/exchanges/venue-types.d.ts +52 -10
  255. package/dist/exchanges/venue-types.js +82 -11
  256. package/dist/exchanges/venue.d.ts +150 -11
  257. package/dist/exchanges/venue.js +126 -4
  258. package/dist/exchanges/venues/arcus.d.ts +1 -2
  259. package/dist/exchanges/venues/arcus.js +5 -4
  260. package/dist/exchanges/venues/aster.d.ts +2 -2
  261. package/dist/exchanges/venues/aster.js +6 -4
  262. package/dist/exchanges/venues/create-helpers.d.ts +1 -1
  263. package/dist/exchanges/venues/create-helpers.js +3 -3
  264. package/dist/exchanges/venues/extended.d.ts +21 -0
  265. package/dist/exchanges/venues/extended.js +96 -0
  266. package/dist/exchanges/venues/grvt.d.ts +30 -0
  267. package/dist/exchanges/venues/grvt.js +98 -0
  268. package/dist/exchanges/venues/hyperliquid.d.ts +2 -2
  269. package/dist/exchanges/venues/hyperliquid.js +19 -8
  270. package/dist/exchanges/venues/index.d.ts +7 -2
  271. package/dist/exchanges/venues/index.js +8 -2
  272. package/dist/exchanges/venues/lighter-family.d.ts +7 -9
  273. package/dist/exchanges/venues/lighter-family.js +9 -11
  274. package/dist/exchanges/venues/lighter-rh.d.ts +2 -2
  275. package/dist/exchanges/venues/lighter-rh.js +20 -8
  276. package/dist/exchanges/venues/lighter.d.ts +1 -1
  277. package/dist/exchanges/venues/lighter.js +18 -6
  278. package/dist/exchanges/venues/ondo.d.ts +1 -1
  279. package/dist/exchanges/venues/ondo.js +5 -3
  280. package/dist/exchanges/venues/pacifica.d.ts +2 -2
  281. package/dist/exchanges/venues/pacifica.js +15 -4
  282. package/dist/exchanges/venues/qfex.d.ts +1 -1
  283. package/dist/exchanges/venues/qfex.js +4 -2
  284. package/dist/exchanges/venues/risex-release.d.ts +14 -0
  285. package/dist/exchanges/venues/risex-release.js +14 -0
  286. package/dist/exchanges/venues/risex.d.ts +31 -0
  287. package/dist/exchanges/venues/risex.js +131 -0
  288. package/dist/exchanges/venues/txflow.d.ts +18 -0
  289. package/dist/exchanges/venues/txflow.js +77 -0
  290. package/dist/exchanges/venues/variational.d.ts +21 -0
  291. package/dist/exchanges/venues/variational.js +85 -0
  292. package/dist/execution-log.d.ts +1 -1
  293. package/dist/funding/legacy-public.d.ts +6 -4
  294. package/dist/funding/legacy-public.js +42 -41
  295. package/dist/funding/normalize.d.ts +1 -1
  296. package/dist/funding/normalize.js +1 -1
  297. package/dist/funding/rates.d.ts +95 -6
  298. package/dist/funding/rates.js +99 -19
  299. package/dist/index.js +7 -6
  300. package/dist/jobs.d.ts +1 -0
  301. package/dist/jobs.js +25 -1
  302. package/dist/landing.d.ts +2 -0
  303. package/dist/landing.js +1 -1
  304. package/dist/liquidity.d.ts +3 -1
  305. package/dist/liquidity.js +8 -4
  306. package/dist/mcp-pacifica-earn.d.ts +9 -0
  307. package/dist/mcp-pacifica-earn.js +64 -0
  308. package/dist/mcp-server.js +211 -68
  309. package/dist/pacifica/client.d.ts +69 -5
  310. package/dist/pacifica/client.js +181 -8
  311. package/dist/pacifica/rate-limit.d.ts +144 -0
  312. package/dist/pacifica/rate-limit.js +267 -0
  313. package/dist/pacifica/types/order.d.ts +2 -1
  314. package/dist/plan-executor.js +7 -2
  315. package/dist/positions-by-address.d.ts +34 -0
  316. package/dist/positions-by-address.js +46 -0
  317. package/dist/rebalance.js +1 -1
  318. package/dist/risk.d.ts +2 -1
  319. package/dist/risk.js +2 -4
  320. package/dist/settings.d.ts +32 -3
  321. package/dist/signer/ows-evm.d.ts +1 -1
  322. package/dist/signer/ows-evm.js +1 -1
  323. package/dist/smart-order.d.ts +1 -1
  324. package/dist/smart-order.js +1 -1
  325. package/dist/strategies/funding-arb.d.ts +1 -1
  326. package/dist/strategies/funding-arb.js +36 -63
  327. package/dist/trade-validator.js +2 -2
  328. package/dist/utils.d.ts +22 -3
  329. package/dist/utils.js +11 -3
  330. package/dist/venue-health.d.ts +40 -0
  331. package/dist/venue-health.js +75 -0
  332. package/dist/withdraw-gate.d.ts +1 -1
  333. package/dist/withdraw-gate.js +1 -1
  334. package/dist/ws/arcus-market.d.ts +9 -0
  335. package/dist/ws/arcus-market.js +9 -0
  336. package/dist/ws/aster-market.d.ts +33 -0
  337. package/dist/ws/aster-market.js +30 -0
  338. package/dist/ws/index.d.ts +980 -0
  339. package/dist/ws/index.js +4460 -0
  340. package/dist/ws/lighter-market.d.ts +14 -0
  341. package/dist/ws/lighter-market.js +13 -0
  342. package/dist/ws/node.d.ts +996 -0
  343. package/dist/ws/node.js +4554 -0
  344. package/dist/ws/pacifica-instrument.d.ts +8 -0
  345. package/dist/ws/pacifica-instrument.js +8 -0
  346. package/dist/ws/unclassified.d.ts +16 -0
  347. package/dist/ws/unclassified.js +43 -0
  348. package/dist/ws-cli/credentials.d.ts +62 -0
  349. package/dist/ws-cli/credentials.js +126 -0
  350. package/package.json +71 -10
  351. package/skills/perp-cli/SKILL.md +153 -36
  352. package/skills/perp-cli/package.json +15 -2
  353. package/skills/perp-cli/references/agent-operations.md +22 -12
  354. package/skills/perp-cli/references/commands.md +143 -17
  355. package/skills/perp-cli/references/strategies.md +38 -3
  356. package/skills/perp-cli/references/ws-library.md +523 -0
  357. package/skills/perp-cli/scripts/arb-monitor.sh +13 -10
  358. package/skills/perp-cli/scripts/funding-analysis.sh +57 -29
  359. package/skills/perp-cli/scripts/preflight.sh +27 -19
  360. package/skills/perp-cli/scripts/spot-perp-scan.sh +58 -38
  361. package/skills/perp-cli/scripts/validate-arb.sh +56 -39
  362. package/dist/cli-spec.d.ts +0 -46
  363. package/dist/cli-spec.js +0 -81
@@ -1,20 +1,21 @@
1
- import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangeFundingPayment, ExchangeKline } from "./interface.js";
1
+ import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangePublicTrade, ExchangeFundingPayment, ExchangeKline, FundingHistoryRow } from "./interface.js";
2
2
  import type { ResolvedSlippage } from "./slippage.js";
3
3
  import type { EvmSigner } from "../signer/index.js";
4
4
  import type { AgentMeta } from "../settings.js";
5
+ import { PerpError } from "../errors.js";
5
6
  import { type BuilderApproval, type BuilderDecision, type BuilderFeeGate, type BuilderTarget } from "./builder-fee.js";
6
7
  /** HL native time-in-force values. */
7
8
  export type HlTif = "Gtc" | "Ioc" | "Alo";
8
9
  /**
9
- * Map a TIF input to HL's native value (design §13.3). Accepts the common names
10
+ * Map a TIF input to HL's native value. Accepts the common names
10
11
  * GTC/IOC/ALO and the native spellings case-insensitively. FOK is not offered by
11
- * HL (no FOK emulation, §13.3) → CAPABILITY_UNSUPPORTED; anything else likewise.
12
+ * HL (no FOK emulation) → CAPABILITY_UNSUPPORTED; anything else likewise.
12
13
  */
13
14
  export declare function hlTif(raw: string): HlTif;
14
15
  /** HL lot step implied by szDecimals ("1" for 0, "0.001" for 3) — sizes are floored to it (floorSize). */
15
16
  export declare function hlSizeStep(szDecimals: number): string;
16
17
  /**
17
- * Slippage-bounded IOC protection price (design §13.2, §13.10 #5).
18
+ * Slippage-bounded IOC protection price.
18
19
  *
19
20
  * `reference` × (1 ± bps/10000), then aligned TOWARD CROSSING (buy → up, sell →
20
21
  * down) on HL's price grid: at most 5 significant figures and at most
@@ -29,8 +30,8 @@ export declare function hlProtectionPrice(reference: number, side: "buy" | "sell
29
30
  appliedBps: number;
30
31
  };
31
32
  /**
32
- * A USER-SUPPLIED limit / trigger / modify price checked against HL's price grid (design §10.10:
33
- * an off-grid limit price is refused, never rounded — rounding to nearest can move a buy price UP).
33
+ * A USER-SUPPLIED limit / trigger / modify price checked against HL's price grid:
34
+ * an off-grid limit price is refused, never rounded — rounding to nearest can move a buy price UP.
34
35
  * HL docs (trading/tick-and-lot-size): "Prices can have up to 5 significant figures, but no more
35
36
  * than MAX_DECIMALS - szDecimals decimal places where MAX_DECIMALS is 6 for perps and 8 for spot.
36
37
  * Integer prices are always allowed, regardless of the number of significant figures."
@@ -59,7 +60,7 @@ export declare function hlAlignPriceToGrid(price: string, szDecimals: number, ma
59
60
  export declare function assertHlAppliedBps(appliedBps: number, what: string): Promise<void>;
60
61
  /**
61
62
  * Definite IOC outcome of a raw HL `order` response (shared contract with the
62
- * perp-order lane, design §13.10 #4). Reads `response.data.statuses[0]`:
63
+ * perp-order lane). Reads `response.data.statuses[0]`:
63
64
  * - `{ filled: { totalSz } }` with a plain decimal totalSz → that size, final;
64
65
  * - `{ error }` that is HL's IOC no-match cancel ("could not immediately match")
65
66
  * → the venue explicitly cancelled the IOC with nothing filled → "0", final;
@@ -127,6 +128,18 @@ export declare const HL_MARKET_META_TTL_MS: number;
127
128
  export declare const HL_ABSTRACTION_TTL_MS = 60000;
128
129
  /** Cache-key prefix of the abstraction mode for a network (invalidateCache prefix: every address). */
129
130
  export declare function hlAbstractionCachePrefix(network: string): string;
131
+ /**
132
+ * Margin tiers of a universe entry. Docs "Margin tiers": "For IDs less than 50, there is a single
133
+ * tier with max leverage equal to the ID" — those tables are not in `marginTables`, so the
134
+ * implicit tier is emitted instead of null. Unknown ids ≥ 50 → null.
135
+ */
136
+ export declare function hlMarginTiersOf(marginTableId: unknown, tierMap: ReadonlyMap<number, Array<{
137
+ lowerBound: number;
138
+ maxLeverage: number;
139
+ }>>): Array<{
140
+ lowerBound: number;
141
+ maxLeverage: number;
142
+ }> | null;
130
143
  /** Venue margin restriction of a universe entry: strictIsolated (no margin removal) / noCross; null = unrestricted. */
131
144
  export declare function hlMarginModeOf(asset: {
132
145
  marginMode?: string;
@@ -165,6 +178,101 @@ export declare function hlUserActionRejection(type: string, e: unknown): unknown
165
178
  * parse failures (no envelope) are returned unchanged.
166
179
  */
167
180
  export declare function hlL1ActionRejection(type: string, e: unknown): unknown;
181
+ /**
182
+ * candleSnapshot intervals (docs "Candle snapshot": "Supported intervals") with their nominal
183
+ * length. Anything else is answered 422 "Failed to deserialize" (live 2026-10-19, "7m"), so it is
184
+ * refused as INVALID_PARAMS before sending. "1M" buckets are 30 days, not calendar months
185
+ * (live: consecutive 1M opens 30 d apart); "1w" buckets open on Thursday 00:00 UTC.
186
+ */
187
+ export declare const HL_CANDLE_INTERVAL_MS: Readonly<Record<string, number>>;
188
+ /** Docs "Candle snapshot": "Only the most recent 5000 candles are available". */
189
+ export declare const HL_CANDLE_CAP = 5000;
190
+ /** Earliest candleSnapshot start (unix ms) for `interval` at `now`: now − 5000 × interval. Unknown interval → NaN. */
191
+ export declare function hlEarliestCandleStart(interval: string, now?: number): number;
192
+ /** recentTrades returns the last 10 trades, with no count parameter (live 2026-10-19). */
193
+ export declare const HL_RECENT_TRADES_CAP = 10;
194
+ /** l2Book returns at most 20 levels per side (docs l2Book; live 2026-10-19). */
195
+ export declare const HL_BOOK_LEVELS_CAP = 20;
196
+ /** Largest `market funding --limit` (hourly rows ≈ 208 days) and the page guard of one read. */
197
+ export declare const HL_FUNDING_HISTORY_MAX_LIMIT = 5000;
198
+ /**
199
+ * Open positions of one clearinghouseState (info `clearinghouseState` {user[, dex]}): rows with
200
+ * szi 0 dropped. The ONE mapper of the keyed `getPositions` and the public-address read
201
+ * (`account positions --address`); `symbolOf` names the row (keyed: the adapter's display name,
202
+ * public: the plain coin — "BTC", HIP-3 "xyz:GOLD").
203
+ */
204
+ export declare function hlPositionRows(state: Record<string, unknown>, symbolOf: (coin: string) => string): ExchangePosition[];
205
+ /** The user's account abstraction mode (info `userAbstraction`, see HyperliquidAdapter._getAbstractionMode). */
206
+ export type HlAbstractionMode = "unified" | "standard" | "portfolio" | "default" | "dexAbstraction";
207
+ /**
208
+ * info `userAbstraction` answer → mode. Per SSOT Rule #2: an unrecognized venue response throws —
209
+ * no silent default.
210
+ */
211
+ export declare function hlAbstractionModeOf(raw: unknown): HlAbstractionMode;
212
+ /** Reads hlBalanceOf() makes only when the mode needs them (the keyed adapter: cached; the public path: raw). */
213
+ export interface HlBalanceReads {
214
+ /** Spot balance row of the dex's collateral token (matched by token index); row null = none held. */
215
+ spotCollateralRow(): Promise<{
216
+ row: Record<string, unknown> | null;
217
+ balances: Record<string, unknown>[];
218
+ token: number;
219
+ portfolioMarginRatio?: unknown;
220
+ }>;
221
+ /** Collateral token index of the dex (info `meta{dex}.collateralToken`). */
222
+ collateralToken(): Promise<number>;
223
+ /** USDC price per spot token index (hlSpotUsdPricesOf over info `spotMetaAndAssetCtxs`); portfolio mode only. */
224
+ spotUsdPrices(): Promise<Map<number, number>>;
225
+ }
226
+ /**
227
+ * Portfolio-margin collateral rows: the venue returns an `ltv` on exactly the eligible collateral
228
+ * tokens (live 2026-10-26: USDC, HYPE, USDT0 carry it, memecoins do not; unified-mode rows never
229
+ * do), plus the dex's collateral token itself.
230
+ */
231
+ export declare function hlIsPortfolioCollateral(row: Record<string, unknown>, collateralToken: number): boolean;
232
+ /**
233
+ * USDC price of each spot token (index → price) from info `spotMetaAndAssetCtxs`: the mark of its
234
+ * USDC-quoted pair (quote token 0); several pairs for one token → the one with the larger 24h
235
+ * notional. USDC itself is 1. Malformed payload → EXCHANGE_ERROR (never a guessed price).
236
+ */
237
+ export declare function hlSpotUsdPricesOf(raw: unknown): Map<number, number>;
238
+ /**
239
+ * Balance of one perp dex ("" = native) from its clearinghouseState and the user's abstraction
240
+ * mode — the one implementation behind HyperliquidAdapter.getBalance() and the keyless
241
+ * `account balance --address`. `notes` are the human warnings getBalance() writes to stderr.
242
+ *
243
+ * Branch by the user's account abstraction mode (Rule #2: no silent fallback).
244
+ * - "unified" / "portfolio": per HL docs, API users see all balances and holds
245
+ * in the spot clearinghouse state; the dex's collateral token row (by token
246
+ * index from meta{dex}.collateralToken) is the equity. Adding perp margin
247
+ * would double-count.
248
+ * - "standard" / "default": perp clearinghouse (per dex) is the collateral source.
249
+ *
250
+ * Portfolio-margin mode: one portfolio of every eligible collateral token (HYPE, BTC, USDC,
251
+ * USDT — the rows the venue marks with `ltv`). The collateral token's `total` already moves with
252
+ * perp PnL (it can be negative = borrowed), so equity = Σ eligible `total` × spot USDC price —
253
+ * live 2026-10-26 this equals the venue's own `portfolio` account value minus vault equity.
254
+ * `available` stays the collateral token's total − hold. The balance carries `collateral` (the
255
+ * priced rows) and `portfolioMarginRatio` (liquidatable above 0.95, docs trading/portfolio-margin).
256
+ */
257
+ /** One priced portfolio-margin collateral row (HlPortfolioBalance.collateral). */
258
+ export interface HlPortfolioCollateral {
259
+ token: string;
260
+ total: string;
261
+ priceUsd: string;
262
+ valueUsd: string;
263
+ ltv: string | null;
264
+ borrowed: string | null;
265
+ supplied: string | null;
266
+ }
267
+ /** Portfolio-margin balance: the ExchangeBalance plus its priced collateral and margin ratio. */
268
+ export type HlPortfolioBalance = ExchangeBalance & {
269
+ collateral: HlPortfolioCollateral[];
270
+ portfolioMarginRatio: string | null;
271
+ };
272
+ export declare function hlBalanceOf(state: Record<string, unknown>, mode: HlAbstractionMode, dex: string, reads: HlBalanceReads): Promise<{
273
+ balance: ExchangeBalance | HlPortfolioBalance;
274
+ notes: string[];
275
+ }>;
168
276
  export declare class HyperliquidAdapter implements ExchangeAdapter {
169
277
  readonly name = "hyperliquid";
170
278
  readonly chain = "evm";
@@ -178,6 +286,8 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
178
286
  * semantics for accounts that have never opted in. Codex v0.12.12 final QA #1.
179
287
  */
180
288
  isUnifiedAccount: boolean;
289
+ /** The account abstraction mode resolved in init() (null until then / without an address). */
290
+ accountMode: HlAbstractionMode | null;
181
291
  private _address;
182
292
  private _privateKey;
183
293
  private _testnet;
@@ -203,9 +313,19 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
203
313
  * configured. Set by createHyperliquid — the adapter never reads settings.
204
314
  */
205
315
  builderFee: BuilderFeeGate | null;
316
+ /** recentTrades' fixed tape size (no paging): `market trades` defaults to min(20, this). */
317
+ readonly recentTradesCap = 10;
206
318
  constructor(privateKey?: string, testnet?: boolean);
207
319
  /** Set the HIP-3 deployed perp dex to query/trade on. */
208
320
  setDex(dex: string): void;
321
+ /**
322
+ * An independent adapter for HIP-3 dex `dex` ("" = native perps) with this adapter's account
323
+ * configuration (key / signers / address / network / builder gate) and its OWN market state
324
+ * (asset maps, markets cache, delisted sets, in-flight reads). Fan-outs over dexes use this:
325
+ * Object.create(adapter) + setDex() shared the prototype's maps, so setDex cleared the native
326
+ * adapter's asset map and the dex copies served the native markets cache.
327
+ */
328
+ forDex(dex: string): HyperliquidAdapter;
209
329
  get dex(): string;
210
330
  get address(): string;
211
331
  /**
@@ -269,11 +389,41 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
269
389
  /** Lot step of a market from the loaded `meta` szDecimals (precision.lotStepOf) — no metaAndAssetCtxs / allMids read per order. */
270
390
  lotStepOf(symbol: string): string;
271
391
  getAssetIndex(symbol: string): Promise<number>;
392
+ /** SYMBOL_NOT_FOUND for a coin the venue does not list (on this adapter's dex), with the listing command. */
393
+ private _unknownSymbol;
272
394
  getMarkets(): Promise<ExchangeMarketInfo[]>;
273
- getOrderbook(symbol: string): Promise<{
395
+ /** Display names of the delisted assets seen by the last getMarkets() (meta isDelisted). */
396
+ private _delisted;
397
+ /** Asset-map keys of the delisted assets in `meta` (_loadAssetMap): "MATIC-PERP"; HIP-3 "km:US500" and "US500". */
398
+ private _delistedAssets;
399
+ /**
400
+ * Why `symbol` is not in getMarkets(): it is delisted (message), or null when it is not a
401
+ * delisted asset. Read after getMarkets() (or once the asset map is loaded). `market info` uses
402
+ * it to say "delisted" rather than "not found" — the asset map still resolves it for orders /
403
+ * positions / history. A HIP-3 bare name ("US500" on --dex km) is matched by its venue coin.
404
+ */
405
+ delistedMessage(symbol: string): string | null;
406
+ /** SYMBOL_NOT_FOUND (details.reason "delisted") for a delisted `symbol`, with a dex-aware remediation; null when listed. */
407
+ delistedError(symbol: string): PerpError | null;
408
+ /**
409
+ * Per-symbol MARKET-DATA reads (trades, funding, book, klines): the symbol must resolve
410
+ * (SYMBOL_NOT_FOUND) and must not be delisted — HL keeps serving a delisted coin's last tape
411
+ * (MATIC: trades from 2024-09-09) and zero-rate funding rows stamped every hour (live
412
+ * 2026-10-19), which read as a live market. Orders / positions / history do not call this.
413
+ */
414
+ private _listedMarket;
415
+ /**
416
+ * Public order-book read (`market book`, bots, MCP): l2Book serves at most HL_BOOK_LEVELS_CAP
417
+ * (20) levels per side and cannot be paged, so a `depth` above it is INVALID_PARAMS naming the
418
+ * cap. Refuses delisted markets (_listedMarket). Order paths use _l2Book (no delisted gate):
419
+ * a reduce-only close of a delisted asset must still get its reference price.
420
+ */
421
+ getOrderbook(symbol: string, depth?: number): Promise<{
274
422
  bids: [string, string][];
275
423
  asks: [string, string][];
276
424
  }>;
425
+ /** l2Book of `symbol` (native or this adapter's dex), no listing gate. Unlisted coin → SYMBOL_NOT_FOUND. */
426
+ private _l2Book;
277
427
  /**
278
428
  * Venue coin for a symbol: native perps drop the "-PERP" display suffix ("BTC-PERP" →
279
429
  * "BTC"); HIP-3 coins carry the dex prefix ("US500" → "km:US500").
@@ -305,7 +455,7 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
305
455
  */
306
456
  _getAbstractionMode(opts?: {
307
457
  fresh?: boolean;
308
- }): Promise<"unified" | "standard" | "portfolio" | "default" | "dexAbstraction">;
458
+ }): Promise<HlAbstractionMode>;
309
459
  /** Collateral token index of this adapter's perp dex (info `meta{dex}.collateralToken`; 0 = USDC on native perps). */
310
460
  private _collateralTokenIdx;
311
461
  _getCollateralToken(): Promise<number>;
@@ -367,11 +517,11 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
367
517
  */
368
518
  private _validateOrderFill;
369
519
  /**
370
- * Market order = slippage-bounded IOC limit (design §13.2, §13.10 #1/#5) for
520
+ * Market order = slippage-bounded IOC limit for
371
521
  * native perps and HIP-3 dexes alike. Replaces the SDK's marketOpen/marketClose
372
522
  * (hidden built-in slippage) and the former HIP-3 5% constant.
373
523
  *
374
- * Reference price (the single declared source, §13.10 #5): the l2Book mid
524
+ * Reference price (the single declared source): the l2Book mid
375
525
  * (best bid + best ask) / 2 of this coin — see referencePrice(). No runtime
376
526
  * substitute (mark, allMids, last trade): a missing side → PRICE_STALE before
377
527
  * anything is sent. Protection = reference ± opts.slippage.bps, aligned toward
@@ -396,7 +546,8 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
396
546
  /**
397
547
  * The single declared reference price for market-type protection prices:
398
548
  * l2Book mid = (best bid + best ask) / 2. Works for native perps and HIP-3
399
- * (getOrderbook passes the dex). Either side missing / non-positive → PRICE_STALE.
549
+ * (_l2Book passes the dex). Either side missing / non-positive → PRICE_STALE. Not gated on
550
+ * delisting: a reduce-only market close of a delisted asset is sent (the venue decides).
400
551
  */
401
552
  referencePrice(symbol: string): Promise<number>;
402
553
  /**
@@ -483,7 +634,7 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
483
634
  cancelOrder(symbol: string, orderId: string): Promise<unknown>;
484
635
  cancelAllOrders(symbol?: string): Promise<unknown[]>;
485
636
  /**
486
- * Amend (design §13.4, §13.10 #10) via HL native batchModify. `size` = the NEW
637
+ * Amend via HL native batchModify. `size` = the NEW
487
638
  * open (unfilled) size — native-modify semantics, not the original total. The
488
639
  * order's own tif (Gtc/Alo) and reduceOnly are read from frontendOpenOrders
489
640
  * and preserved; nothing is hardcoded.
@@ -494,8 +645,24 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
494
645
  limitPrice?: string;
495
646
  reduceOnly?: boolean;
496
647
  }): Promise<unknown>;
497
- getRecentTrades(symbol: string, limit?: number): Promise<ExchangeTrade[]>;
498
- getKlines(symbol: string, interval: string, startTime: number, endTime: number): Promise<ExchangeKline[]>;
648
+ /**
649
+ * recentTrades: the venue's last HL_RECENT_TRADES_CAP (10) trades — no count parameter, no
650
+ * paging. `limit` undefined = the venue max (10); an explicit `limit` above 10 is INVALID_PARAMS
651
+ * naming the cap (never fewer rows than asked, silently). Row `symbol` is the raw venue coin
652
+ * ("BTC", "km:US500"), as in the WS codec — not the "BTC-PERP" display name of `market list`.
653
+ */
654
+ getRecentTrades(symbol: string, limit?: number): Promise<ExchangePublicTrade[]>;
655
+ /**
656
+ * candleSnapshot. Only the most recent HL_CANDLE_CAP (5000) candles of an interval exist (docs)
657
+ * and older ones cannot be paged to: a `startTime` before hlEarliestCandleStart() is refused
658
+ * up front (INVALID_PARAMS naming the earliest allowed start) — never a silently shortened
659
+ * range. `closed` (additive) is false on the in-progress candle (close time `T`, or open +
660
+ * interval when `T` is absent, still in the future). "1M" = 30-day buckets; "1w" opens
661
+ * Thursday 00:00 UTC.
662
+ */
663
+ getKlines(symbol: string, interval: string, startTime: number, endTime: number): Promise<Array<ExchangeKline & {
664
+ closed: boolean;
665
+ }>>;
499
666
  /**
500
667
  * Order history: POST /info {type:"historicalOrders"} ("Retrieve a user's historical orders",
501
668
  * at most 2000 most recent; live 2026-10-13: newest first, each order listed once per status —
@@ -529,16 +696,20 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
529
696
  * adapter keeps "<dex>:…" coins, the native adapter keeps native perp coins only.
530
697
  */
531
698
  private _inHistoryScope;
532
- getFundingHistory(symbol: string, limit?: number): Promise<{
533
- time: number;
534
- rate: string;
535
- price: string | null;
536
- }[]>;
699
+ /**
700
+ * The last `limit` hourly funding settlements. HL funding is hourly, so the window starts
701
+ * `limit + 1` hours back (one spare hour for a settlement not yet published), and fundingHistory
702
+ * pages are read forward from the last row's time (docs: at most 500 elements per response;
703
+ * "use the last returned timestamp as the next startTime") — deduped by time, oldest first.
704
+ */
705
+ getFundingHistory(symbol: string, limit?: number): Promise<FundingHistoryRow[]>;
706
+ /** Every fundingHistory row of `coin` since `startTime`, paged forward (500 per response), deduped by time, oldest first. */
707
+ private _fundingHistorySince;
537
708
  /**
538
709
  * Place a trigger order (stop loss / take profit).
539
710
  * Python SDK: order() with trigger type {"trigger": {triggerPx, isMarket, tpsl: "tp"|"sl"}}
540
711
  *
541
- * Pricing (design §13.10 #3):
712
+ * Pricing:
542
713
  * - isMarket (default): HL native market trigger; `p` = trigger ± 10 % (the venue's documented
543
714
  * market TP/SL slippage tolerance, HL_MARKET_TPSL_SLIPPAGE_BPS), aligned toward crossing.
544
715
  * - limit trigger with an explicit `limitPrice`: that price, rounded to HL's grid.
@@ -696,12 +867,18 @@ export declare class HyperliquidAdapter implements ExchangeAdapter {
696
867
  */
697
868
  claimRewards(): Promise<unknown>;
698
869
  /**
699
- * List all available HIP-3 deployed perp dexes.
870
+ * List the HIP-3 deployed perp dexes: allPerpMetas (universe per dex; index 0 = native perps)
871
+ * joined by index with perpDexs (name, deployer — live 2026-10-19 both list the dexes in the
872
+ * same order). `assets` holds the LIVE (non-delisted) assets only; `delistedAssets` the rest and
873
+ * `delisted` is true when every asset of the dex is delisted (km, flx, hyna, cash, vntl, abcd on
874
+ * 2026-10-19). Delisted dexes stay listed: accounts may still hold positions there.
700
875
  */
701
876
  listDeployedDexes(): Promise<{
702
877
  name: string;
703
878
  deployer: string;
704
879
  assets: string[];
880
+ delistedAssets: string[];
881
+ delisted: boolean;
705
882
  }[]>;
706
883
  /**
707
884
  * Get referral info.