@reefclaw/connect 0.1.10 → 0.1.12

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 (396) hide show
  1. package/assets/bridge/gateway/event-parser.d.ts +6 -1
  2. package/assets/bridge/gateway/event-parser.js +19 -2
  3. package/assets/bridge/gateway/heartbeat-cron.d.ts +27 -0
  4. package/assets/bridge/gateway/heartbeat-cron.js +85 -0
  5. package/assets/bridge/gateway/poller.d.ts +1 -0
  6. package/assets/bridge/gateway/poller.js +14 -2
  7. package/assets/bridge/providers/gateway.d.ts +24 -2
  8. package/assets/bridge/providers/gateway.js +124 -25
  9. package/assets/bridge/setup.js +6 -51
  10. package/assets/shared/signals/conditions/registry.js +11 -2
  11. package/assets/shared/signals/strategy-adapter.js +17 -7
  12. package/assets/skill/SKILL.md +2 -0
  13. package/dist/deps.js +2 -2
  14. package/dist/plugin.js +35 -7
  15. package/package.json +1 -1
  16. package/assets/plugin/audit/mode-transition-audit.d.ts +0 -11
  17. package/assets/plugin/audit/mode-transition-audit.js +0 -29
  18. package/assets/plugin/balance-utils.d.ts +0 -36
  19. package/assets/plugin/balance-utils.js +0 -98
  20. package/assets/plugin/ccxt/binance-ban-gate.d.ts +0 -47
  21. package/assets/plugin/ccxt/binance-ban-gate.js +0 -420
  22. package/assets/plugin/ccxt/binance-private.d.ts +0 -346
  23. package/assets/plugin/ccxt/binance-private.js +0 -1525
  24. package/assets/plugin/ccxt/binance-public.d.ts +0 -34
  25. package/assets/plugin/ccxt/binance-public.js +0 -180
  26. package/assets/plugin/ccxt/intel-public.d.ts +0 -25
  27. package/assets/plugin/ccxt/intel-public.js +0 -80
  28. package/assets/plugin/ccxt/public-market-data-api.d.ts +0 -12
  29. package/assets/plugin/ccxt/public-market-data-api.js +0 -9
  30. package/assets/plugin/config/agent-config-client.d.ts +0 -77
  31. package/assets/plugin/config/agent-config-client.js +0 -188
  32. package/assets/plugin/config/agent-config-poller.d.ts +0 -32
  33. package/assets/plugin/config/agent-config-poller.js +0 -101
  34. package/assets/plugin/config/brackets-config.d.ts +0 -22
  35. package/assets/plugin/config/brackets-config.js +0 -58
  36. package/assets/plugin/config/entitlement-gate.d.ts +0 -51
  37. package/assets/plugin/config/entitlement-gate.js +0 -137
  38. package/assets/plugin/config/gate-store.d.ts +0 -18
  39. package/assets/plugin/config/gate-store.js +0 -61
  40. package/assets/plugin/config/plugin-config-io.d.ts +0 -215
  41. package/assets/plugin/config/plugin-config-io.js +0 -111
  42. package/assets/plugin/config/position-review-config.d.ts +0 -35
  43. package/assets/plugin/config/position-review-config.js +0 -105
  44. package/assets/plugin/config/tool-gate.d.ts +0 -53
  45. package/assets/plugin/config/tool-gate.js +0 -128
  46. package/assets/plugin/config/user-data-stream-config.d.ts +0 -89
  47. package/assets/plugin/config/user-data-stream-config.js +0 -239
  48. package/assets/plugin/connector-supervisor.d.ts +0 -36
  49. package/assets/plugin/connector-supervisor.js +0 -149
  50. package/assets/plugin/exchange-adapter.d.ts +0 -65
  51. package/assets/plugin/exchange-adapter.js +0 -4
  52. package/assets/plugin/index.d.ts +0 -30
  53. package/assets/plugin/index.js +0 -2678
  54. package/assets/plugin/ingest/pending-entry-metadata.d.ts +0 -74
  55. package/assets/plugin/ingest/pending-entry-metadata.js +0 -236
  56. package/assets/plugin/ingest/position-auto-capture.d.ts +0 -103
  57. package/assets/plugin/ingest/position-auto-capture.js +0 -411
  58. package/assets/plugin/ingest/position-decisions-client.d.ts +0 -322
  59. package/assets/plugin/ingest/position-decisions-client.js +0 -296
  60. package/assets/plugin/ingest/readiness-reporter.d.ts +0 -42
  61. package/assets/plugin/ingest/readiness-reporter.js +0 -163
  62. package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +0 -13
  63. package/assets/plugin/ingest/reconcile-db-vs-exchange.js +0 -114
  64. package/assets/plugin/ingest/reconciler-cleanup.d.ts +0 -37
  65. package/assets/plugin/ingest/reconciler-cleanup.js +0 -147
  66. package/assets/plugin/ingest/rest-gap-filler.d.ts +0 -191
  67. package/assets/plugin/ingest/rest-gap-filler.js +0 -565
  68. package/assets/plugin/ingest/touched-symbols-store.d.ts +0 -25
  69. package/assets/plugin/ingest/touched-symbols-store.js +0 -96
  70. package/assets/plugin/ingest/trade-store-client.d.ts +0 -40
  71. package/assets/plugin/ingest/trade-store-client.js +0 -125
  72. package/assets/plugin/ingest/ws-ingest.d.ts +0 -43
  73. package/assets/plugin/ingest/ws-ingest.js +0 -126
  74. package/assets/plugin/learning/setup-family.d.ts +0 -21
  75. package/assets/plugin/learning/setup-family.js +0 -103
  76. package/assets/plugin/lifecycle/install-signal-handlers.d.ts +0 -33
  77. package/assets/plugin/lifecycle/install-signal-handlers.js +0 -112
  78. package/assets/plugin/lifecycle/shutdown-coordinator.d.ts +0 -43
  79. package/assets/plugin/lifecycle/shutdown-coordinator.js +0 -131
  80. package/assets/plugin/lifecycle/trading-operation-lock.d.ts +0 -17
  81. package/assets/plugin/lifecycle/trading-operation-lock.js +0 -14
  82. package/assets/plugin/live/bracket-id.d.ts +0 -26
  83. package/assets/plugin/live/bracket-id.js +0 -112
  84. package/assets/plugin/live/bracket-ledger.d.ts +0 -54
  85. package/assets/plugin/live/bracket-ledger.js +0 -267
  86. package/assets/plugin/live/bracket-manager.d.ts +0 -82
  87. package/assets/plugin/live/bracket-manager.js +0 -478
  88. package/assets/plugin/live/bracket-params.d.ts +0 -22
  89. package/assets/plugin/live/bracket-params.js +0 -124
  90. package/assets/plugin/live/bracket-reconciler.d.ts +0 -95
  91. package/assets/plugin/live/bracket-reconciler.js +0 -573
  92. package/assets/plugin/live/bracket-types.d.ts +0 -102
  93. package/assets/plugin/live/bracket-types.js +0 -8
  94. package/assets/plugin/live/deposit-tracker.d.ts +0 -62
  95. package/assets/plugin/live/deposit-tracker.js +0 -97
  96. package/assets/plugin/live/emergency-controls.d.ts +0 -32
  97. package/assets/plugin/live/emergency-controls.js +0 -226
  98. package/assets/plugin/live/exchange-errors.d.ts +0 -12
  99. package/assets/plugin/live/exchange-errors.js +0 -130
  100. package/assets/plugin/live/exchange-info-cache.d.ts +0 -37
  101. package/assets/plugin/live/exchange-info-cache.js +0 -134
  102. package/assets/plugin/live/fact-subscriber.d.ts +0 -78
  103. package/assets/plugin/live/fact-subscriber.js +0 -182
  104. package/assets/plugin/live/intent-journal.d.ts +0 -42
  105. package/assets/plugin/live/intent-journal.js +0 -122
  106. package/assets/plugin/live/listen-key-manager.d.ts +0 -70
  107. package/assets/plugin/live/listen-key-manager.js +0 -169
  108. package/assets/plugin/live/live-adapter.d.ts +0 -287
  109. package/assets/plugin/live/live-adapter.js +0 -1777
  110. package/assets/plugin/live/live-balance-enricher.d.ts +0 -32
  111. package/assets/plugin/live/live-balance-enricher.js +0 -104
  112. package/assets/plugin/live/live-bracket-api.d.ts +0 -13
  113. package/assets/plugin/live/live-bracket-api.js +0 -20
  114. package/assets/plugin/live/live-state-store.d.ts +0 -194
  115. package/assets/plugin/live/live-state-store.js +0 -450
  116. package/assets/plugin/live/local-signal-service.d.ts +0 -57
  117. package/assets/plugin/live/local-signal-service.js +0 -151
  118. package/assets/plugin/live/local-strategy-evaluator.d.ts +0 -62
  119. package/assets/plugin/live/local-strategy-evaluator.js +0 -131
  120. package/assets/plugin/live/microstructure-assembler.d.ts +0 -54
  121. package/assets/plugin/live/microstructure-assembler.js +0 -148
  122. package/assets/plugin/live/order-poller.d.ts +0 -29
  123. package/assets/plugin/live/order-poller.js +0 -125
  124. package/assets/plugin/live/position-state-store.d.ts +0 -83
  125. package/assets/plugin/live/position-state-store.js +0 -237
  126. package/assets/plugin/live/proposal-decision-listener.d.ts +0 -70
  127. package/assets/plugin/live/proposal-decision-listener.js +0 -292
  128. package/assets/plugin/live/proposal-manager.d.ts +0 -76
  129. package/assets/plugin/live/proposal-manager.js +0 -140
  130. package/assets/plugin/live/rate-limiter.d.ts +0 -47
  131. package/assets/plugin/live/rate-limiter.js +0 -159
  132. package/assets/plugin/live/reconciler.d.ts +0 -39
  133. package/assets/plugin/live/reconciler.js +0 -175
  134. package/assets/plugin/live/setup-buckets.d.ts +0 -7
  135. package/assets/plugin/live/setup-buckets.js +0 -33
  136. package/assets/plugin/live/slippage-tracker.d.ts +0 -45
  137. package/assets/plugin/live/slippage-tracker.js +0 -78
  138. package/assets/plugin/live/stop-watcher.d.ts +0 -60
  139. package/assets/plugin/live/stop-watcher.js +0 -215
  140. package/assets/plugin/live/user-data-active-probe.d.ts +0 -54
  141. package/assets/plugin/live/user-data-active-probe.js +0 -180
  142. package/assets/plugin/live/user-data-stream-controller.d.ts +0 -200
  143. package/assets/plugin/live/user-data-stream-controller.js +0 -579
  144. package/assets/plugin/live/user-data-stream-ws.d.ts +0 -22
  145. package/assets/plugin/live/user-data-stream-ws.js +0 -63
  146. package/assets/plugin/live/user-data-stream.d.ts +0 -243
  147. package/assets/plugin/live/user-data-stream.js +0 -704
  148. package/assets/plugin/logger.d.ts +0 -2
  149. package/assets/plugin/logger.js +0 -2
  150. package/assets/plugin/mfe.d.ts +0 -21
  151. package/assets/plugin/mfe.js +0 -68
  152. package/assets/plugin/onboarding/mode-ladder.d.ts +0 -1
  153. package/assets/plugin/onboarding/mode-ladder.js +0 -3
  154. package/assets/plugin/onboarding/runtime.d.ts +0 -84
  155. package/assets/plugin/onboarding/runtime.js +0 -173
  156. package/assets/plugin/openclaw.plugin.json +0 -92
  157. package/assets/plugin/paper-adapter.d.ts +0 -24
  158. package/assets/plugin/paper-adapter.js +0 -91
  159. package/assets/plugin/persistence/state-manager.d.ts +0 -66
  160. package/assets/plugin/persistence/state-manager.js +0 -222
  161. package/assets/plugin/pinned-plan.d.ts +0 -9
  162. package/assets/plugin/pinned-plan.js +0 -23
  163. package/assets/plugin/portfolio/wave9-admission.d.ts +0 -67
  164. package/assets/plugin/portfolio/wave9-admission.js +0 -262
  165. package/assets/plugin/portfolio/wave9-policy.d.ts +0 -36
  166. package/assets/plugin/portfolio/wave9-policy.js +0 -183
  167. package/assets/plugin/risk/pre-trade-check.d.ts +0 -38
  168. package/assets/plugin/risk/pre-trade-check.js +0 -345
  169. package/assets/plugin/risk/pre-trade-types.d.ts +0 -60
  170. package/assets/plugin/risk/pre-trade-types.js +0 -3
  171. package/assets/plugin/shadow/shadow-tracker.d.ts +0 -36
  172. package/assets/plugin/shadow/shadow-tracker.js +0 -151
  173. package/assets/plugin/shadow/types.d.ts +0 -42
  174. package/assets/plugin/shadow/types.js +0 -20
  175. package/assets/plugin/shared/indicators-extended.d.ts +0 -52
  176. package/assets/plugin/shared/indicators-extended.js +0 -291
  177. package/assets/plugin/shared/indicators.d.ts +0 -15
  178. package/assets/plugin/shared/indicators.js +0 -114
  179. package/assets/plugin/signals/conditions/registry.d.ts +0 -16
  180. package/assets/plugin/signals/conditions/registry.js +0 -1324
  181. package/assets/plugin/signals/conditions/types.d.ts +0 -1
  182. package/assets/plugin/signals/conditions/types.js +0 -4
  183. package/assets/plugin/signals/direction-rules.d.ts +0 -3
  184. package/assets/plugin/signals/direction-rules.js +0 -24
  185. package/assets/plugin/signals/entry-rules.d.ts +0 -6
  186. package/assets/plugin/signals/entry-rules.js +0 -33
  187. package/assets/plugin/signals/serialize-context.d.ts +0 -4
  188. package/assets/plugin/signals/serialize-context.js +0 -39
  189. package/assets/plugin/signals/stop-rules.d.ts +0 -3
  190. package/assets/plugin/signals/stop-rules.js +0 -48
  191. package/assets/plugin/signals/strategy-adapter.d.ts +0 -47
  192. package/assets/plugin/signals/strategy-adapter.js +0 -199
  193. package/assets/plugin/signals/types.d.ts +0 -1
  194. package/assets/plugin/signals/types.js +0 -8
  195. package/assets/plugin/simulator/exchange-simulator.d.ts +0 -93
  196. package/assets/plugin/simulator/exchange-simulator.js +0 -689
  197. package/assets/plugin/simulator/fill-engine.d.ts +0 -53
  198. package/assets/plugin/simulator/fill-engine.js +0 -280
  199. package/assets/plugin/simulator/paper-market-feed.d.ts +0 -26
  200. package/assets/plugin/simulator/paper-market-feed.js +0 -104
  201. package/assets/plugin/simulator/realistic-fills.d.ts +0 -59
  202. package/assets/plugin/simulator/realistic-fills.js +0 -175
  203. package/assets/plugin/simulator/types.d.ts +0 -224
  204. package/assets/plugin/simulator/types.js +0 -43
  205. package/assets/plugin/strategy/builtin-strategies.d.ts +0 -2
  206. package/assets/plugin/strategy/builtin-strategies.js +0 -113
  207. package/assets/plugin/strategy/condition-registry.d.ts +0 -3
  208. package/assets/plugin/strategy/condition-registry.js +0 -153
  209. package/assets/plugin/strategy/evaluator.d.ts +0 -70
  210. package/assets/plugin/strategy/evaluator.js +0 -98
  211. package/assets/plugin/tools/assessment-validation.d.ts +0 -120
  212. package/assets/plugin/tools/assessment-validation.js +0 -415
  213. package/assets/plugin/tools/attach-brackets.d.ts +0 -39
  214. package/assets/plugin/tools/attach-brackets.js +0 -399
  215. package/assets/plugin/tools/audit-bracket-protection.d.ts +0 -49
  216. package/assets/plugin/tools/audit-bracket-protection.js +0 -527
  217. package/assets/plugin/tools/cancel-all-orders.d.ts +0 -9
  218. package/assets/plugin/tools/cancel-all-orders.js +0 -8
  219. package/assets/plugin/tools/cancel-order.d.ts +0 -14
  220. package/assets/plugin/tools/cancel-order.js +0 -60
  221. package/assets/plugin/tools/check-position-health.d.ts +0 -46
  222. package/assets/plugin/tools/check-position-health.js +0 -194
  223. package/assets/plugin/tools/clear-exchange-credentials.d.ts +0 -24
  224. package/assets/plugin/tools/clear-exchange-credentials.js +0 -70
  225. package/assets/plugin/tools/close-position.d.ts +0 -45
  226. package/assets/plugin/tools/close-position.js +0 -722
  227. package/assets/plugin/tools/create-order.d.ts +0 -82
  228. package/assets/plugin/tools/create-order.js +0 -1516
  229. package/assets/plugin/tools/exit-gate.d.ts +0 -58
  230. package/assets/plugin/tools/exit-gate.js +0 -162
  231. package/assets/plugin/tools/fetch-balance.d.ts +0 -5
  232. package/assets/plugin/tools/fetch-balance.js +0 -4
  233. package/assets/plugin/tools/fetch-ohlcv.d.ts +0 -11
  234. package/assets/plugin/tools/fetch-ohlcv.js +0 -8
  235. package/assets/plugin/tools/fetch-open-orders.d.ts +0 -7
  236. package/assets/plugin/tools/fetch-open-orders.js +0 -4
  237. package/assets/plugin/tools/fetch-positions.d.ts +0 -7
  238. package/assets/plugin/tools/fetch-positions.js +0 -4
  239. package/assets/plugin/tools/fetch-ticker.d.ts +0 -11
  240. package/assets/plugin/tools/fetch-ticker.js +0 -5
  241. package/assets/plugin/tools/get-agent-profile.d.ts +0 -4
  242. package/assets/plugin/tools/get-agent-profile.js +0 -6
  243. package/assets/plugin/tools/get-analytics.d.ts +0 -6
  244. package/assets/plugin/tools/get-analytics.js +0 -7
  245. package/assets/plugin/tools/get-backtest.d.ts +0 -12
  246. package/assets/plugin/tools/get-backtest.js +0 -91
  247. package/assets/plugin/tools/get-basis.d.ts +0 -7
  248. package/assets/plugin/tools/get-basis.js +0 -7
  249. package/assets/plugin/tools/get-bracket-config.d.ts +0 -11
  250. package/assets/plugin/tools/get-bracket-config.js +0 -24
  251. package/assets/plugin/tools/get-cascade-risk.d.ts +0 -7
  252. package/assets/plugin/tools/get-cascade-risk.js +0 -8
  253. package/assets/plugin/tools/get-crypto-metrics.d.ts +0 -18
  254. package/assets/plugin/tools/get-crypto-metrics.js +0 -62
  255. package/assets/plugin/tools/get-cvd.d.ts +0 -6
  256. package/assets/plugin/tools/get-cvd.js +0 -6
  257. package/assets/plugin/tools/get-divergences.d.ts +0 -6
  258. package/assets/plugin/tools/get-divergences.js +0 -6
  259. package/assets/plugin/tools/get-funding-context.d.ts +0 -6
  260. package/assets/plugin/tools/get-funding-context.js +0 -16
  261. package/assets/plugin/tools/get-liquidation-levels.d.ts +0 -7
  262. package/assets/plugin/tools/get-liquidation-levels.js +0 -7
  263. package/assets/plugin/tools/get-liquidation-pulse.d.ts +0 -9
  264. package/assets/plugin/tools/get-liquidation-pulse.js +0 -22
  265. package/assets/plugin/tools/get-market-breadth.d.ts +0 -6
  266. package/assets/plugin/tools/get-market-breadth.js +0 -8
  267. package/assets/plugin/tools/get-market-intel.d.ts +0 -19
  268. package/assets/plugin/tools/get-market-intel.js +0 -116
  269. package/assets/plugin/tools/get-market-structure.d.ts +0 -47
  270. package/assets/plugin/tools/get-market-structure.js +0 -198
  271. package/assets/plugin/tools/get-my-mined-patterns.d.ts +0 -20
  272. package/assets/plugin/tools/get-my-mined-patterns.js +0 -61
  273. package/assets/plugin/tools/get-my-proposed-learnings.d.ts +0 -20
  274. package/assets/plugin/tools/get-my-proposed-learnings.js +0 -55
  275. package/assets/plugin/tools/get-my-recent-reviews.d.ts +0 -22
  276. package/assets/plugin/tools/get-my-recent-reviews.js +0 -66
  277. package/assets/plugin/tools/get-orderbook.d.ts +0 -21
  278. package/assets/plugin/tools/get-orderbook.js +0 -32
  279. package/assets/plugin/tools/get-pattern-scan.d.ts +0 -7
  280. package/assets/plugin/tools/get-pattern-scan.js +0 -8
  281. package/assets/plugin/tools/get-regime.d.ts +0 -6
  282. package/assets/plugin/tools/get-regime.js +0 -7
  283. package/assets/plugin/tools/get-relevant-learnings.d.ts +0 -21
  284. package/assets/plugin/tools/get-relevant-learnings.js +0 -65
  285. package/assets/plugin/tools/get-resting-liquidity.d.ts +0 -6
  286. package/assets/plugin/tools/get-resting-liquidity.js +0 -11
  287. package/assets/plugin/tools/get-risk-scenario.d.ts +0 -29
  288. package/assets/plugin/tools/get-risk-scenario.js +0 -47
  289. package/assets/plugin/tools/get-risk-summary.d.ts +0 -51
  290. package/assets/plugin/tools/get-risk-summary.js +0 -118
  291. package/assets/plugin/tools/get-sentiment.d.ts +0 -4
  292. package/assets/plugin/tools/get-sentiment.js +0 -6
  293. package/assets/plugin/tools/get-session-review.d.ts +0 -7
  294. package/assets/plugin/tools/get-session-review.js +0 -8
  295. package/assets/plugin/tools/get-setup-detail.d.ts +0 -7
  296. package/assets/plugin/tools/get-setup-detail.js +0 -311
  297. package/assets/plugin/tools/get-signals.d.ts +0 -15
  298. package/assets/plugin/tools/get-signals.js +0 -54
  299. package/assets/plugin/tools/get-sizing.d.ts +0 -6
  300. package/assets/plugin/tools/get-sizing.js +0 -6
  301. package/assets/plugin/tools/get-trade-feedback.d.ts +0 -7
  302. package/assets/plugin/tools/get-trade-feedback.js +0 -8
  303. package/assets/plugin/tools/get-trade-flow.d.ts +0 -7
  304. package/assets/plugin/tools/get-trade-flow.js +0 -7
  305. package/assets/plugin/tools/get-volume-analysis.d.ts +0 -21
  306. package/assets/plugin/tools/get-volume-analysis.js +0 -74
  307. package/assets/plugin/tools/get-volume-profile.d.ts +0 -7
  308. package/assets/plugin/tools/get-volume-profile.js +0 -7
  309. package/assets/plugin/tools/get-wave9-status.d.ts +0 -127
  310. package/assets/plugin/tools/get-wave9-status.js +0 -796
  311. package/assets/plugin/tools/helpers.d.ts +0 -26
  312. package/assets/plugin/tools/helpers.js +0 -39
  313. package/assets/plugin/tools/intel-api.d.ts +0 -34
  314. package/assets/plugin/tools/intel-api.js +0 -119
  315. package/assets/plugin/tools/intel-cache.d.ts +0 -25
  316. package/assets/plugin/tools/intel-cache.js +0 -148
  317. package/assets/plugin/tools/list-strategies.d.ts +0 -17
  318. package/assets/plugin/tools/list-strategies.js +0 -23
  319. package/assets/plugin/tools/modify-stop.d.ts +0 -21
  320. package/assets/plugin/tools/modify-stop.js +0 -120
  321. package/assets/plugin/tools/modify-target.d.ts +0 -21
  322. package/assets/plugin/tools/modify-target.js +0 -110
  323. package/assets/plugin/tools/propose-learning.d.ts +0 -22
  324. package/assets/plugin/tools/propose-learning.js +0 -65
  325. package/assets/plugin/tools/query-review-outcomes.d.ts +0 -30
  326. package/assets/plugin/tools/query-review-outcomes.js +0 -64
  327. package/assets/plugin/tools/query-trades.d.ts +0 -21
  328. package/assets/plugin/tools/query-trades.js +0 -37
  329. package/assets/plugin/tools/record-position-reviews.d.ts +0 -38
  330. package/assets/plugin/tools/record-position-reviews.js +0 -147
  331. package/assets/plugin/tools/save-strategy.d.ts +0 -16
  332. package/assets/plugin/tools/save-strategy.js +0 -46
  333. package/assets/plugin/tools/scan-pairs.d.ts +0 -18
  334. package/assets/plugin/tools/scan-pairs.js +0 -231
  335. package/assets/plugin/tools/score-setup.d.ts +0 -31
  336. package/assets/plugin/tools/score-setup.js +0 -268
  337. package/assets/plugin/tools/set-bracket-requirement.d.ts +0 -18
  338. package/assets/plugin/tools/set-bracket-requirement.js +0 -81
  339. package/assets/plugin/tools/set-exchange-credentials.d.ts +0 -25
  340. package/assets/plugin/tools/set-exchange-credentials.js +0 -80
  341. package/assets/plugin/tools/set-trading-mode.d.ts +0 -26
  342. package/assets/plugin/tools/set-trading-mode.js +0 -135
  343. package/assets/plugin/tools/test-exchange-credentials.d.ts +0 -16
  344. package/assets/plugin/tools/test-exchange-credentials.js +0 -100
  345. package/assets/plugin/tools/toggle-strategy.d.ts +0 -8
  346. package/assets/plugin/tools/toggle-strategy.js +0 -15
  347. package/assets/plugin/trading-params-cache.d.ts +0 -26
  348. package/assets/plugin/trading-params-cache.js +0 -52
  349. package/assets/plugin/types.d.ts +0 -134
  350. package/assets/plugin/types.js +0 -7
  351. package/assets/plugin/util/plugin-paths.d.ts +0 -3
  352. package/assets/plugin/util/plugin-paths.js +0 -15
  353. package/assets/plugin/venues/hyperliquid/hl-balance.d.ts +0 -116
  354. package/assets/plugin/venues/hyperliquid/hl-balance.js +0 -145
  355. package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +0 -102
  356. package/assets/plugin/venues/hyperliquid/hl-brackets.js +0 -172
  357. package/assets/plugin/venues/hyperliquid/hl-cloid.d.ts +0 -22
  358. package/assets/plugin/venues/hyperliquid/hl-cloid.js +0 -82
  359. package/assets/plugin/venues/hyperliquid/hl-info-cache.d.ts +0 -46
  360. package/assets/plugin/venues/hyperliquid/hl-info-cache.js +0 -125
  361. package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +0 -88
  362. package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +0 -353
  363. package/assets/plugin/venues/hyperliquid/hl-precision.d.ts +0 -61
  364. package/assets/plugin/venues/hyperliquid/hl-precision.js +0 -176
  365. package/assets/plugin/venues/hyperliquid/hl-private.d.ts +0 -88
  366. package/assets/plugin/venues/hyperliquid/hl-private.js +0 -357
  367. package/assets/plugin/venues/hyperliquid/hl-public.d.ts +0 -79
  368. package/assets/plugin/venues/hyperliquid/hl-public.js +0 -429
  369. package/assets/plugin/venues/hyperliquid/hl-rate-gate.d.ts +0 -57
  370. package/assets/plugin/venues/hyperliquid/hl-rate-gate.js +0 -220
  371. package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +0 -90
  372. package/assets/plugin/venues/hyperliquid/hl-user-stream.js +0 -220
  373. package/assets/plugin/venues/registry.d.ts +0 -38
  374. package/assets/plugin/venues/registry.js +0 -46
  375. package/assets/plugin/venues/symbols.d.ts +0 -43
  376. package/assets/plugin/venues/symbols.js +0 -107
  377. package/assets/plugin/wave9/live-account-capture.d.ts +0 -67
  378. package/assets/plugin/wave9/live-account-capture.js +0 -435
  379. package/assets/plugin/wave9/live-autonomous-protection.d.ts +0 -39
  380. package/assets/plugin/wave9/live-autonomous-protection.js +0 -112
  381. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.d.ts +0 -33
  382. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.js +0 -115
  383. package/assets/plugin/wave9/live-execution-ledger.d.ts +0 -107
  384. package/assets/plugin/wave9/live-execution-ledger.js +0 -498
  385. package/assets/plugin/wave9/live-position-confirmation.d.ts +0 -18
  386. package/assets/plugin/wave9/live-position-confirmation.js +0 -111
  387. package/assets/plugin/wave9/live-residual-protection.d.ts +0 -18
  388. package/assets/plugin/wave9/live-residual-protection.js +0 -250
  389. package/assets/plugin/wave9/live-startup-reconciliation.d.ts +0 -38
  390. package/assets/plugin/wave9/live-startup-reconciliation.js +0 -454
  391. package/assets/plugin/wave9/live-symbol-ownership.d.ts +0 -20
  392. package/assets/plugin/wave9/live-symbol-ownership.js +0 -132
  393. package/assets/plugin/wave9/paper-admission-guard.d.ts +0 -199
  394. package/assets/plugin/wave9/paper-admission-guard.js +0 -650
  395. package/assets/plugin/wave9/usdm-evidence-provider.d.ts +0 -42
  396. package/assets/plugin/wave9/usdm-evidence-provider.js +0 -133
@@ -1,79 +0,0 @@
1
- import type { CcxtTicker, CcxtOHLCV } from '../../types.js';
2
- import type { OrderBookDepth } from '../../simulator/types.js';
3
- import type { PublicMarketDataApi } from '../../ccxt/public-market-data-api.js';
4
- export interface HyperliquidPublicApiOptions {
5
- testnet?: boolean;
6
- /** Test seam — injected ccxt exchange instance. */
7
- exchange?: any;
8
- fetchImpl?: typeof fetch;
9
- }
10
- export declare class HyperliquidPublicApi implements PublicMarketDataApi {
11
- private exchange;
12
- private readonly testnet;
13
- private readonly fetchImpl;
14
- private readonly tickerTtlMs;
15
- /** One upstream fetchTickers call serves every symbol within the TTL. */
16
- private tickersCache;
17
- private tickersInflight;
18
- /** Coin → mid from one weight-2 allMids call (fetchTicker's price source). */
19
- private midsCache;
20
- private midsInflight;
21
- constructor(opts?: HyperliquidPublicApiOptions);
22
- private baseUrl;
23
- /** Canonical/ccxt symbol → this venue's ccxt symbol, or null (logged) when
24
- * the symbol isn't a Hyperliquid USDC perp — a caller bug we surface
25
- * loudly rather than silently translating quote assets. */
26
- private venueSymbol;
27
- /** Fetch-all-tickers with a short TTL + inflight dedup. Returns a map keyed
28
- * by ccxt symbol, or null on failure. */
29
- private getTickers;
30
- /** Coin → mid price from one weight-2 `allMids` call (TTL-cached, inflight-
31
- * deduped; docs: hyperliquid.gitbook.io → Info endpoint → "Retrieve mids
32
- * for all coins"). Null on ANY failure — callers fall back to the full
33
- * snapshot path. Spot entries (`@<idx>` keys) parse fine and are simply
34
- * never looked up (we key by perp coin name). */
35
- private getMids;
36
- /** Fire-and-forget full-snapshot refresh once it ages past
37
- * FULL_SNAPSHOT_REFRESH_MS — fetchTicker must never block on the heavy
38
- * fetchTickers call when a fresh mid is available. getTickers' own
39
- * inflight dedup + error handling make this safe to kick repeatedly. */
40
- private maybeRefreshSnapshot;
41
- fetchTickerRaw(symbol: string): Promise<Record<string, any> | null>;
42
- /** Price from the weight-2 allMids fast path; volume/change context from
43
- * the last full snapshot (background-refreshed). Hyperliquid's asset
44
- * contexts carry mark/mid rather than a trade-tape bid/ask; absent fields
45
- * fall back to `last` with zero modeled spread — the paper fill engine
46
- * models slippage itself (same convention as IntelPublicApi). Falls back
47
- * to the original blocking full-snapshot path when allMids fails. */
48
- fetchTicker(symbol: string): Promise<CcxtTicker | null>;
49
- fetchFundingRate(symbol: string): Promise<Record<string, any> | null>;
50
- fetchOpenInterest(symbol: string): Promise<Record<string, any> | null>;
51
- /** l2Book — Hyperliquid serves at most 20 levels/side (plan §3.6). */
52
- fetchOrderBook(symbol: string, limit?: number): Promise<OrderBookDepth | null>;
53
- /** candleSnapshot — only the most recent 5000 candles exist per (coin,
54
- * interval) (plan §3.6); requests inside that window behave like Binance. */
55
- fetchOHLCV(symbol: string, timeframe?: string, limit?: number): Promise<CcxtOHLCV[] | null>;
56
- /** Probe Hyperliquid reachability from this host — the readiness gate's
57
- * venue signal, mirroring BinancePublicApi.probeReachability's outcome
58
- * shape. Hand-rolled POST /info `exchangeStatus` (weight 2) so the probe
59
- * has zero ccxt-method-shape dependence; the response's `time` field
60
- * (verified live 2026-07-11: `{"specialStatuses":null,"time":…}`) doubles
61
- * as the clock-drift source. Geo classification is best-effort — HL's
62
- * API-level geo behavior is UNVERIFIED (plan §3.9); a 403/451 maps to
63
- * geo_blocked, anything else non-2xx/network maps to unreachable. */
64
- probeReachability(): Promise<{
65
- outcome: 'reachable' | 'geo_blocked' | 'unreachable' | 'unknown';
66
- driftMs: number | null;
67
- }>;
68
- /** `meta` — the asset universe (szDecimals, maxLeverage, positional assetIndex).
69
- * Keyless info read, weight 20. Feeds HyperliquidInfoCache. Returns null on any
70
- * failure (never a partial universe — a half-loaded rules table would silently
71
- * reject orders). */
72
- fetchMeta(): Promise<any | null>;
73
- /** ★ MARK price — the price HL trigger orders fire on (there is no workingType
74
- * choice on this venue). Stop-distance validation and every trigger MUST use
75
- * this, never `last`: the mark is a CEX-composite median that can diverge from
76
- * HL's own last trade. Sourced from `metaAndAssetCtxs` (one weight-20 call
77
- * covers every asset). Returns null on failure — never a stale guess. */
78
- fetchMarkPrice(symbol: string): Promise<number | null>;
79
- }
@@ -1,429 +0,0 @@
1
- // Hyperliquid public market-data source (keyless) — Phase 1 of
2
- // docs/HYPERLIQUID_INTEGRATION_PLAN.md. Implements PublicMarketDataApi so
3
- // PAPER mode on venue='hyperliquid' prices the simulator, the stop-watcher,
4
- // and every market-data tool from Hyperliquid instead of Binance. Live
5
- // trading does NOT use this class (the Phase 3 adapter owns its own reads).
6
- //
7
- // Protocol facts (verified 2026-07-11, plan §3 + live probe):
8
- // - REST is POST-only: /info on api.hyperliquid.xyz (testnet:
9
- // api.hyperliquid-testnet.xyz). CCXT@4.5.37 wraps everything we need.
10
- // - `exchangeStatus` (weight 2) returns `{specialStatuses, time}` — the
11
- // reachability probe AND a clock-drift source in one call.
12
- // - `allMids` (weight 2) returns the mid price for EVERY coin in one call —
13
- // the docs' recommended price read (plan §3: ccxt fetchTicker is
14
- // 'emulated' — prefer allMids). fetchTicker serves its PRICE from one
15
- // TTL-cached allMids call; volume/change context rides the last full
16
- // fetchTickers snapshot, refreshed in the background at most every
17
- // FULL_SNAPSHOT_REFRESH_MS. Why the split: ccxt@4.5.37's hyperliquid
18
- // fetchTickers() literally calls fetchMarkets() — the full perp+spot
19
- // meta/ctx pipeline — measured ~13s on the first HL soak box, which
20
- // starved every 10s-timeout skill-poller call 100% of the time. allMids
21
- // measured ~1.4s on the same box. The full address/IP rate gate is a
22
- // Phase 3 concern (live cadences); paper-mode cadence here is bounded by
23
- // the caches: ≤ (60s/TTL) weight-2 calls/min + ≤ weight-20 every 5 min.
24
- // - CCXT auto-monetization landmine (plan §3.8): initializeClient() only
25
- // fires on AUTHENTICATED clients, and this class is keyless — but we pin
26
- // `builderFee:false, refSet:true` in options anyway so a future
27
- // credentialed refactor can never silently enroll CCXT's builder fee or
28
- // referral code. hl-public.test.ts asserts these options forever.
29
- //
30
- // Error contract mirrors BinancePublicApi/IntelPublicApi: null on ANY failure,
31
- // never throw to consumers. Binance-shaped symbols (…/USDT) are a caller bug
32
- // on this venue — logged clearly, null returned (never silently translated).
33
- import { createRequire } from 'node:module';
34
- import { logger } from '../../logger.js';
35
- import { toCcxtSymbol, toHyperliquidCoin } from '../symbols.js';
36
- const TAG = 'hl-public';
37
- // Load ccxt via CJS require — OpenClaw's ESM loader gives wrong module shape
38
- // (same pattern as binance-public.ts / binance-private.ts).
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- let ccxtCjs;
41
- try {
42
- const _require = createRequire(import.meta.url);
43
- ccxtCjs = _require('ccxt');
44
- }
45
- catch {
46
- // eslint-disable-next-line @typescript-eslint/no-require-imports
47
- ccxtCjs = require('ccxt');
48
- }
49
- /** Base URLs verified against the official docs + pinned ccxt source (plan §3.1). */
50
- const HL_MAINNET_API = 'https://api.hyperliquid.xyz';
51
- const HL_TESTNET_API = 'https://api.hyperliquid-testnet.xyz';
52
- const DEFAULT_TICKER_TTL_MS = 4_000;
53
- /** How stale the full fetchTickers snapshot (volume/change context) may get
54
- * before fetchTicker kicks a background refresh. Deliberately long: the
55
- * snapshot's ccxt call re-runs the whole fetchMarkets pipeline (weight ~60,
56
- * ~13s on a slow host) and nothing price-critical reads these fields. */
57
- const FULL_SNAPSHOT_REFRESH_MS = 300_000;
58
- function resolveTickerTtlMs() {
59
- const raw = Number(process.env.RC_HL_TICKER_TTL_MS);
60
- if (!Number.isFinite(raw) || raw < 500)
61
- return DEFAULT_TICKER_TTL_MS;
62
- return raw;
63
- }
64
- export class HyperliquidPublicApi {
65
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- exchange;
67
- testnet;
68
- fetchImpl;
69
- tickerTtlMs = resolveTickerTtlMs();
70
- /** One upstream fetchTickers call serves every symbol within the TTL. */
71
- tickersCache = null;
72
- tickersInflight = null;
73
- /** Coin → mid from one weight-2 allMids call (fetchTicker's price source). */
74
- midsCache = null;
75
- midsInflight = null;
76
- constructor(opts = {}) {
77
- this.testnet = opts.testnet === true;
78
- this.fetchImpl = opts.fetchImpl ?? fetch;
79
- if (opts.exchange) {
80
- this.exchange = opts.exchange;
81
- }
82
- else {
83
- const HlClass = ccxtCjs.hyperliquid ?? ccxtCjs.default?.hyperliquid;
84
- if (!HlClass) {
85
- throw new Error('CCXT hyperliquid class not found — check ccxt version');
86
- }
87
- this.exchange = new HlClass({
88
- enableRateLimit: true,
89
- options: {
90
- // ★ Never let CCXT enroll its own builder fee / referral code —
91
- // plan §3.8. Keyless clients can't sign those actions anyway, but
92
- // the pin is deliberate defense-in-depth for future refactors.
93
- builderFee: false,
94
- refSet: true,
95
- },
96
- });
97
- if (this.testnet) {
98
- this.exchange.setSandboxMode(true);
99
- }
100
- }
101
- logger.info(TAG, `Hyperliquid public API initialized (no auth${this.testnet ? ', TESTNET' : ''})`);
102
- }
103
- baseUrl() {
104
- return this.testnet ? HL_TESTNET_API : HL_MAINNET_API;
105
- }
106
- /** Canonical/ccxt symbol → this venue's ccxt symbol, or null (logged) when
107
- * the symbol isn't a Hyperliquid USDC perp — a caller bug we surface
108
- * loudly rather than silently translating quote assets. */
109
- venueSymbol(symbol, ctx) {
110
- try {
111
- return toCcxtSymbol('hyperliquid', symbol);
112
- }
113
- catch (err) {
114
- logger.warn(TAG, `${ctx}(${symbol}) — not a Hyperliquid symbol (${err instanceof Error ? err.message : String(err)}); use USDC pairs like BTC/USDC`);
115
- return null;
116
- }
117
- }
118
- /** Fetch-all-tickers with a short TTL + inflight dedup. Returns a map keyed
119
- * by ccxt symbol, or null on failure. */
120
- async getTickers() {
121
- const now = Date.now();
122
- if (this.tickersCache && now - this.tickersCache.at < this.tickerTtlMs) {
123
- return this.tickersCache.bySymbol;
124
- }
125
- if (this.tickersInflight)
126
- return this.tickersInflight;
127
- this.tickersInflight = (async () => {
128
- try {
129
- const raw = await this.exchange.fetchTickers();
130
- const bySymbol = new Map(Object.entries(raw ?? {}));
131
- this.tickersCache = { at: Date.now(), bySymbol };
132
- return bySymbol;
133
- }
134
- catch (err) {
135
- logger.error(TAG, `fetchTickers failed: ${err instanceof Error ? err.message : String(err)}`);
136
- return null;
137
- }
138
- finally {
139
- this.tickersInflight = null;
140
- }
141
- })();
142
- return this.tickersInflight;
143
- }
144
- /** Coin → mid price from one weight-2 `allMids` call (TTL-cached, inflight-
145
- * deduped; docs: hyperliquid.gitbook.io → Info endpoint → "Retrieve mids
146
- * for all coins"). Null on ANY failure — callers fall back to the full
147
- * snapshot path. Spot entries (`@<idx>` keys) parse fine and are simply
148
- * never looked up (we key by perp coin name). */
149
- async getMids() {
150
- const now = Date.now();
151
- if (this.midsCache && now - this.midsCache.at < this.tickerTtlMs) {
152
- return this.midsCache.byCoin;
153
- }
154
- if (this.midsInflight)
155
- return this.midsInflight;
156
- this.midsInflight = (async () => {
157
- try {
158
- const raw = await this.exchange.publicPostInfo({ type: 'allMids' });
159
- const byCoin = new Map();
160
- for (const [coin, mid] of Object.entries(raw ?? {})) {
161
- const n = Number(mid);
162
- if (Number.isFinite(n) && n > 0)
163
- byCoin.set(coin, n);
164
- }
165
- if (byCoin.size === 0) {
166
- logger.warn(TAG, 'allMids returned no parseable mids');
167
- return null;
168
- }
169
- this.midsCache = { at: Date.now(), byCoin };
170
- return byCoin;
171
- }
172
- catch (err) {
173
- logger.error(TAG, `allMids failed: ${err instanceof Error ? err.message : String(err)}`);
174
- return null;
175
- }
176
- finally {
177
- this.midsInflight = null;
178
- }
179
- })();
180
- return this.midsInflight;
181
- }
182
- /** Fire-and-forget full-snapshot refresh once it ages past
183
- * FULL_SNAPSHOT_REFRESH_MS — fetchTicker must never block on the heavy
184
- * fetchTickers call when a fresh mid is available. getTickers' own
185
- * inflight dedup + error handling make this safe to kick repeatedly. */
186
- maybeRefreshSnapshot() {
187
- const at = this.tickersCache?.at ?? 0;
188
- if (Date.now() - at < FULL_SNAPSHOT_REFRESH_MS)
189
- return;
190
- if (this.tickersInflight)
191
- return;
192
- void this.getTickers();
193
- }
194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
- async fetchTickerRaw(symbol) {
196
- const vs = this.venueSymbol(symbol, 'fetchTickerRaw');
197
- if (!vs)
198
- return null;
199
- const tickers = await this.getTickers();
200
- return tickers?.get(vs) ?? null;
201
- }
202
- /** Price from the weight-2 allMids fast path; volume/change context from
203
- * the last full snapshot (background-refreshed). Hyperliquid's asset
204
- * contexts carry mark/mid rather than a trade-tape bid/ask; absent fields
205
- * fall back to `last` with zero modeled spread — the paper fill engine
206
- * models slippage itself (same convention as IntelPublicApi). Falls back
207
- * to the original blocking full-snapshot path when allMids fails. */
208
- async fetchTicker(symbol) {
209
- const vs = this.venueSymbol(symbol, 'fetchTicker');
210
- if (!vs)
211
- return null;
212
- const coin = toHyperliquidCoin(symbol);
213
- const mids = await this.getMids();
214
- const mid = mids?.get(coin);
215
- if (mid !== undefined) {
216
- this.maybeRefreshSnapshot();
217
- const base = this.tickersCache?.bySymbol.get(vs);
218
- const timestamp = this.midsCache?.at ?? Date.now();
219
- return {
220
- symbol,
221
- last: mid,
222
- bid: mid,
223
- ask: mid,
224
- baseVolume: Number(base?.baseVolume ?? 0) || 0,
225
- quoteVolume: Number(base?.quoteVolume ?? 0) || 0,
226
- change: Number(base?.change ?? 0) || 0,
227
- percentage: Number(base?.percentage ?? 0) || 0,
228
- timestamp,
229
- datetime: new Date(timestamp).toISOString(),
230
- };
231
- }
232
- const tickers = await this.getTickers();
233
- const raw = tickers?.get(vs);
234
- if (!raw) {
235
- if (tickers)
236
- logger.warn(TAG, `fetchTicker(${symbol}) — ${vs} not in Hyperliquid universe`);
237
- return null;
238
- }
239
- const last = Number(raw.last ?? raw.close ?? raw.markPrice ?? NaN);
240
- if (!Number.isFinite(last) || last <= 0) {
241
- logger.warn(TAG, `fetchTicker(${symbol}) — no usable price on ticker`);
242
- return null;
243
- }
244
- const timestamp = Number.isFinite(raw.timestamp) ? Number(raw.timestamp) : Date.now();
245
- return {
246
- // Key on the symbol the CALLER used so per-symbol maps line up.
247
- symbol,
248
- last,
249
- bid: Number(raw.bid ?? NaN) > 0 ? Number(raw.bid) : last,
250
- ask: Number(raw.ask ?? NaN) > 0 ? Number(raw.ask) : last,
251
- baseVolume: Number(raw.baseVolume ?? 0) || 0,
252
- quoteVolume: Number(raw.quoteVolume ?? 0) || 0,
253
- change: Number(raw.change ?? 0) || 0,
254
- percentage: Number(raw.percentage ?? 0) || 0,
255
- timestamp,
256
- datetime: raw.datetime ?? new Date(timestamp).toISOString(),
257
- };
258
- }
259
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
260
- async fetchFundingRate(symbol) {
261
- const vs = this.venueSymbol(symbol, 'fetchFundingRate');
262
- if (!vs)
263
- return null;
264
- try {
265
- const r = await this.exchange.fetchFundingRate(vs);
266
- return r ?? null;
267
- }
268
- catch (err) {
269
- logger.error(TAG, `fetchFundingRate(${symbol}) failed: ${err instanceof Error ? err.message : String(err)}`);
270
- return null;
271
- }
272
- }
273
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
274
- async fetchOpenInterest(symbol) {
275
- const vs = this.venueSymbol(symbol, 'fetchOpenInterest');
276
- if (!vs)
277
- return null;
278
- try {
279
- const r = await this.exchange.fetchOpenInterest(vs);
280
- return r ?? null;
281
- }
282
- catch (err) {
283
- logger.error(TAG, `fetchOpenInterest(${symbol}) failed: ${err instanceof Error ? err.message : String(err)}`);
284
- return null;
285
- }
286
- }
287
- /** l2Book — Hyperliquid serves at most 20 levels/side (plan §3.6). */
288
- async fetchOrderBook(symbol, limit = 20) {
289
- const vs = this.venueSymbol(symbol, 'fetchOrderBook');
290
- if (!vs)
291
- return null;
292
- try {
293
- const raw = await this.exchange.fetchOrderBook(vs, Math.min(limit, 20));
294
- return {
295
- bids: (raw.bids ?? []).map((l) => [l[0], l[1]]),
296
- asks: (raw.asks ?? []).map((l) => [l[0], l[1]]),
297
- timestamp: raw.timestamp ?? Date.now(),
298
- };
299
- }
300
- catch (err) {
301
- logger.error(TAG, `fetchOrderBook(${symbol}) failed: ${err instanceof Error ? err.message : String(err)}`);
302
- return null;
303
- }
304
- }
305
- /** candleSnapshot — only the most recent 5000 candles exist per (coin,
306
- * interval) (plan §3.6); requests inside that window behave like Binance. */
307
- async fetchOHLCV(symbol, timeframe = '1h', limit = 100) {
308
- const vs = this.venueSymbol(symbol, 'fetchOHLCV');
309
- if (!vs)
310
- return null;
311
- try {
312
- const raw = await this.exchange.fetchOHLCV(vs, timeframe, undefined, limit);
313
- const valid = [];
314
- for (const candle of raw) {
315
- if (candle.length >= 6 &&
316
- typeof candle[0] === 'number' &&
317
- typeof candle[1] === 'number' &&
318
- typeof candle[2] === 'number' &&
319
- typeof candle[3] === 'number' &&
320
- typeof candle[4] === 'number' &&
321
- typeof candle[5] === 'number') {
322
- valid.push(candle);
323
- }
324
- }
325
- return valid;
326
- }
327
- catch (err) {
328
- logger.error(TAG, `fetchOHLCV(${symbol}, ${timeframe}) failed: ${err instanceof Error ? err.message : String(err)}`);
329
- return null;
330
- }
331
- }
332
- /** Probe Hyperliquid reachability from this host — the readiness gate's
333
- * venue signal, mirroring BinancePublicApi.probeReachability's outcome
334
- * shape. Hand-rolled POST /info `exchangeStatus` (weight 2) so the probe
335
- * has zero ccxt-method-shape dependence; the response's `time` field
336
- * (verified live 2026-07-11: `{"specialStatuses":null,"time":…}`) doubles
337
- * as the clock-drift source. Geo classification is best-effort — HL's
338
- * API-level geo behavior is UNVERIFIED (plan §3.9); a 403/451 maps to
339
- * geo_blocked, anything else non-2xx/network maps to unreachable. */
340
- async probeReachability() {
341
- const ac = new AbortController();
342
- const tid = setTimeout(() => ac.abort(), 10_000);
343
- try {
344
- const res = await this.fetchImpl(`${this.baseUrl()}/info`, {
345
- method: 'POST',
346
- headers: { 'content-type': 'application/json' },
347
- body: JSON.stringify({ type: 'exchangeStatus' }),
348
- signal: ac.signal,
349
- });
350
- if (res.status === 451 || res.status === 403) {
351
- logger.warn(TAG, `probeReachability: HTTP ${res.status} (geo/policy block)`);
352
- return { outcome: 'geo_blocked', driftMs: null };
353
- }
354
- if (res.status < 200 || res.status >= 300) {
355
- logger.warn(TAG, `probeReachability: HTTP ${res.status}`);
356
- return { outcome: 'unreachable', driftMs: null };
357
- }
358
- const body = (await res.json());
359
- const serverTime = Number(body?.time);
360
- const driftMs = Number.isFinite(serverTime) ? serverTime - Date.now() : null;
361
- return { outcome: 'reachable', driftMs };
362
- }
363
- catch (err) {
364
- logger.warn(TAG, `probeReachability failed: ${err instanceof Error ? err.message : String(err)}`);
365
- return { outcome: 'unreachable', driftMs: null };
366
- }
367
- finally {
368
- clearTimeout(tid);
369
- }
370
- }
371
- /** `meta` — the asset universe (szDecimals, maxLeverage, positional assetIndex).
372
- * Keyless info read, weight 20. Feeds HyperliquidInfoCache. Returns null on any
373
- * failure (never a partial universe — a half-loaded rules table would silently
374
- * reject orders). */
375
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
376
- async fetchMeta() {
377
- try {
378
- const res = await this.fetchImpl(`${this.baseUrl()}/info`, {
379
- method: 'POST',
380
- headers: { 'content-type': 'application/json' },
381
- body: JSON.stringify({ type: 'meta' }),
382
- signal: AbortSignal.timeout(15_000),
383
- });
384
- if (!res.ok) {
385
- logger.warn(TAG, `fetchMeta: HTTP ${res.status}`);
386
- return null;
387
- }
388
- return await res.json();
389
- }
390
- catch (err) {
391
- logger.warn(TAG, `fetchMeta failed: ${err instanceof Error ? err.message : String(err)}`);
392
- return null;
393
- }
394
- }
395
- /** ★ MARK price — the price HL trigger orders fire on (there is no workingType
396
- * choice on this venue). Stop-distance validation and every trigger MUST use
397
- * this, never `last`: the mark is a CEX-composite median that can diverge from
398
- * HL's own last trade. Sourced from `metaAndAssetCtxs` (one weight-20 call
399
- * covers every asset). Returns null on failure — never a stale guess. */
400
- async fetchMarkPrice(symbol) {
401
- try {
402
- const res = await this.fetchImpl(`${this.baseUrl()}/info`, {
403
- method: 'POST',
404
- headers: { 'content-type': 'application/json' },
405
- body: JSON.stringify({ type: 'metaAndAssetCtxs' }),
406
- signal: AbortSignal.timeout(15_000),
407
- });
408
- if (!res.ok) {
409
- logger.warn(TAG, `fetchMarkPrice: HTTP ${res.status}`);
410
- return null;
411
- }
412
- const body = (await res.json());
413
- const universe = body?.[0]?.universe ?? [];
414
- const ctxs = body?.[1] ?? [];
415
- const coin = toHyperliquidCoin(symbol);
416
- const idx = universe.findIndex((u) => u?.name === coin);
417
- if (idx < 0) {
418
- logger.warn(TAG, `fetchMarkPrice: ${coin} not in meta.universe`);
419
- return null;
420
- }
421
- const mark = Number(ctxs[idx]?.markPx);
422
- return Number.isFinite(mark) && mark > 0 ? mark : null;
423
- }
424
- catch (err) {
425
- logger.warn(TAG, `fetchMarkPrice failed: ${err instanceof Error ? err.message : String(err)}`);
426
- return null;
427
- }
428
- }
429
- }
@@ -1,57 +0,0 @@
1
- /** Info-request weights, from the docs (§3.3). Anything unlisted defaults to 20 —
2
- * the conservative side. `/exchange` actions are `1 + floor(batch/40)`. */
3
- export declare const HL_INFO_WEIGHTS: Record<string, number>;
4
- export declare class HyperliquidRateLimitedError extends Error {
5
- constructor(message: string);
6
- }
7
- /** Thrown by the proactive pacer BEFORE a call goes out. Subclass so every
8
- * existing `catch (HyperliquidRateLimitedError)` absorbs it — the same
9
- * relationship `BinanceWeightPacedError` has to `BinanceBannedError`. */
10
- export declare class HyperliquidPacedError extends HyperliquidRateLimitedError {
11
- constructor(message: string);
12
- }
13
- /** Current 60s IP-weight estimate. */
14
- export declare function currentIpWeight(now?: number): number;
15
- /** Weight for an info context (defaults to the conservative 20). */
16
- export declare function infoWeight(ctx: string): number;
17
- /** `/exchange` IP weight for a batch of n actions: 1 + floor(n/40). */
18
- export declare function exchangeIpWeight(batchLen: number): number;
19
- /** FIRST LINE of every gated read's try-block.
20
- *
21
- * Throws when:
22
- * - a 429 backoff is active (hard stop — like an active Binance ban), or
23
- * - the IP weight window is over its soft ceiling (proactive pacing), or
24
- * - the address budget is below the floor AND this context is shed-able.
25
- *
26
- * Order/cancel/close paths must NOT call this — they arm the gate via
27
- * `noteError` only, so a limit can never block an exit. */
28
- export declare function assertNotLimited(ctx: string): void;
29
- /** Record a successful call's cost. `addressActions` is 0 for pure info reads
30
- * (they cost IP weight only) and n for an `/exchange` batch of n actions. */
31
- export declare function noteSuccess(ctx: string, cost?: {
32
- ipWeight?: number;
33
- addressActions?: number;
34
- }): void;
35
- /** Arm the gate from a caught error. Called in EVERY catch — including on the
36
- * order/cancel paths that are never pre-gated (so a burst of rejects still
37
- * backs the gate off). */
38
- export declare function noteError(err: unknown, ctx?: string): void;
39
- /** HL surfaces rate limiting as HTTP 429 and/or a text body; match on shape, not
40
- * on a venue flag, so the skill-side breaker can reuse this predicate. */
41
- export declare function isRateLimitError(err: unknown): boolean;
42
- /** Feed the address budget from info `userRateLimit` (`nRequestsCap −
43
- * nRequestsUsed`). Poll it every ~5 min — it costs weight 20. */
44
- export declare function updateAddressBudget(args: {
45
- nRequestsUsed: number;
46
- nRequestsCap: number;
47
- }): void;
48
- /** Snapshot for tests + the readiness/diagnostic surfaces. */
49
- export declare function getGateState(): {
50
- ipWeight60s: number;
51
- weightCeiling: number;
52
- addressRemaining?: number;
53
- limited: boolean;
54
- limitedForMs: number;
55
- };
56
- /** Test-only reset. */
57
- export declare function __resetGateForTests(): void;