@reefclaw/connect 0.1.12 → 0.1.14
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.
- package/assets/plugin/audit/mode-transition-audit.d.ts +11 -0
- package/assets/plugin/audit/mode-transition-audit.js +29 -0
- package/assets/plugin/balance-utils.d.ts +36 -0
- package/assets/plugin/balance-utils.js +98 -0
- package/assets/plugin/ccxt/binance-ban-gate.d.ts +47 -0
- package/assets/plugin/ccxt/binance-ban-gate.js +420 -0
- package/assets/plugin/ccxt/binance-private.d.ts +346 -0
- package/assets/plugin/ccxt/binance-private.js +1525 -0
- package/assets/plugin/ccxt/binance-public.d.ts +34 -0
- package/assets/plugin/ccxt/binance-public.js +180 -0
- package/assets/plugin/ccxt/intel-public.d.ts +25 -0
- package/assets/plugin/ccxt/intel-public.js +80 -0
- package/assets/plugin/ccxt/public-market-data-api.d.ts +26 -0
- package/assets/plugin/ccxt/public-market-data-api.js +23 -0
- package/assets/plugin/config/agent-config-client.d.ts +77 -0
- package/assets/plugin/config/agent-config-client.js +188 -0
- package/assets/plugin/config/agent-config-poller.d.ts +32 -0
- package/assets/plugin/config/agent-config-poller.js +101 -0
- package/assets/plugin/config/brackets-config.d.ts +22 -0
- package/assets/plugin/config/brackets-config.js +58 -0
- package/assets/plugin/config/entitlement-gate.d.ts +51 -0
- package/assets/plugin/config/entitlement-gate.js +137 -0
- package/assets/plugin/config/gate-store.d.ts +18 -0
- package/assets/plugin/config/gate-store.js +61 -0
- package/assets/plugin/config/plugin-config-io.d.ts +222 -0
- package/assets/plugin/config/plugin-config-io.js +126 -0
- package/assets/plugin/config/position-review-config.d.ts +35 -0
- package/assets/plugin/config/position-review-config.js +105 -0
- package/assets/plugin/config/tool-gate.d.ts +53 -0
- package/assets/plugin/config/tool-gate.js +128 -0
- package/assets/plugin/config/user-data-stream-config.d.ts +89 -0
- package/assets/plugin/config/user-data-stream-config.js +239 -0
- package/assets/plugin/connector-supervisor.d.ts +36 -0
- package/assets/plugin/connector-supervisor.js +149 -0
- package/assets/plugin/exchange-adapter.d.ts +65 -0
- package/assets/plugin/exchange-adapter.js +4 -0
- package/assets/plugin/index.d.ts +30 -0
- package/assets/plugin/index.js +2763 -0
- package/assets/plugin/ingest/pending-entry-metadata.d.ts +74 -0
- package/assets/plugin/ingest/pending-entry-metadata.js +236 -0
- package/assets/plugin/ingest/position-auto-capture.d.ts +171 -0
- package/assets/plugin/ingest/position-auto-capture.js +709 -0
- package/assets/plugin/ingest/position-decisions-client.d.ts +327 -0
- package/assets/plugin/ingest/position-decisions-client.js +306 -0
- package/assets/plugin/ingest/readiness-reporter.d.ts +42 -0
- package/assets/plugin/ingest/readiness-reporter.js +163 -0
- package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +51 -0
- package/assets/plugin/ingest/reconcile-db-vs-exchange.js +170 -0
- package/assets/plugin/ingest/reconciler-cleanup.d.ts +37 -0
- package/assets/plugin/ingest/reconciler-cleanup.js +147 -0
- package/assets/plugin/ingest/rest-gap-filler.d.ts +191 -0
- package/assets/plugin/ingest/rest-gap-filler.js +565 -0
- package/assets/plugin/ingest/touched-symbols-store.d.ts +25 -0
- package/assets/plugin/ingest/touched-symbols-store.js +96 -0
- package/assets/plugin/ingest/trade-store-client.d.ts +40 -0
- package/assets/plugin/ingest/trade-store-client.js +125 -0
- package/assets/plugin/ingest/ws-ingest.d.ts +43 -0
- package/assets/plugin/ingest/ws-ingest.js +126 -0
- package/assets/plugin/learning/setup-family.d.ts +21 -0
- package/assets/plugin/learning/setup-family.js +103 -0
- package/assets/plugin/lifecycle/install-signal-handlers.d.ts +33 -0
- package/assets/plugin/lifecycle/install-signal-handlers.js +112 -0
- package/assets/plugin/lifecycle/shutdown-coordinator.d.ts +43 -0
- package/assets/plugin/lifecycle/shutdown-coordinator.js +131 -0
- package/assets/plugin/lifecycle/trading-operation-lock.d.ts +17 -0
- package/assets/plugin/lifecycle/trading-operation-lock.js +14 -0
- package/assets/plugin/live/bracket-id.d.ts +26 -0
- package/assets/plugin/live/bracket-id.js +112 -0
- package/assets/plugin/live/bracket-ledger.d.ts +54 -0
- package/assets/plugin/live/bracket-ledger.js +267 -0
- package/assets/plugin/live/bracket-manager.d.ts +82 -0
- package/assets/plugin/live/bracket-manager.js +478 -0
- package/assets/plugin/live/bracket-params.d.ts +22 -0
- package/assets/plugin/live/bracket-params.js +124 -0
- package/assets/plugin/live/bracket-reconciler.d.ts +95 -0
- package/assets/plugin/live/bracket-reconciler.js +573 -0
- package/assets/plugin/live/bracket-types.d.ts +102 -0
- package/assets/plugin/live/bracket-types.js +8 -0
- package/assets/plugin/live/deposit-tracker.d.ts +62 -0
- package/assets/plugin/live/deposit-tracker.js +97 -0
- package/assets/plugin/live/emergency-controls.d.ts +32 -0
- package/assets/plugin/live/emergency-controls.js +226 -0
- package/assets/plugin/live/exchange-errors.d.ts +12 -0
- package/assets/plugin/live/exchange-errors.js +130 -0
- package/assets/plugin/live/exchange-info-cache.d.ts +37 -0
- package/assets/plugin/live/exchange-info-cache.js +134 -0
- package/assets/plugin/live/fact-subscriber.d.ts +78 -0
- package/assets/plugin/live/fact-subscriber.js +182 -0
- package/assets/plugin/live/fill-price.d.ts +13 -0
- package/assets/plugin/live/fill-price.js +37 -0
- package/assets/plugin/live/intent-journal.d.ts +42 -0
- package/assets/plugin/live/intent-journal.js +122 -0
- package/assets/plugin/live/listen-key-manager.d.ts +70 -0
- package/assets/plugin/live/listen-key-manager.js +169 -0
- package/assets/plugin/live/live-adapter.d.ts +319 -0
- package/assets/plugin/live/live-adapter.js +1906 -0
- package/assets/plugin/live/live-balance-enricher.d.ts +32 -0
- package/assets/plugin/live/live-balance-enricher.js +104 -0
- package/assets/plugin/live/live-bracket-api.d.ts +13 -0
- package/assets/plugin/live/live-bracket-api.js +20 -0
- package/assets/plugin/live/live-state-store.d.ts +194 -0
- package/assets/plugin/live/live-state-store.js +450 -0
- package/assets/plugin/live/local-signal-service.d.ts +57 -0
- package/assets/plugin/live/local-signal-service.js +151 -0
- package/assets/plugin/live/local-strategy-evaluator.d.ts +62 -0
- package/assets/plugin/live/local-strategy-evaluator.js +131 -0
- package/assets/plugin/live/microstructure-assembler.d.ts +54 -0
- package/assets/plugin/live/microstructure-assembler.js +148 -0
- package/assets/plugin/live/order-poller.d.ts +29 -0
- package/assets/plugin/live/order-poller.js +125 -0
- package/assets/plugin/live/position-state-store.d.ts +87 -0
- package/assets/plugin/live/position-state-store.js +237 -0
- package/assets/plugin/live/proposal-decision-listener.d.ts +70 -0
- package/assets/plugin/live/proposal-decision-listener.js +292 -0
- package/assets/plugin/live/proposal-manager.d.ts +76 -0
- package/assets/plugin/live/proposal-manager.js +140 -0
- package/assets/plugin/live/rate-limiter.d.ts +47 -0
- package/assets/plugin/live/rate-limiter.js +159 -0
- package/assets/plugin/live/reconciler.d.ts +39 -0
- package/assets/plugin/live/reconciler.js +175 -0
- package/assets/plugin/live/setup-buckets.d.ts +7 -0
- package/assets/plugin/live/setup-buckets.js +33 -0
- package/assets/plugin/live/slippage-tracker.d.ts +45 -0
- package/assets/plugin/live/slippage-tracker.js +78 -0
- package/assets/plugin/live/stop-watcher.d.ts +67 -0
- package/assets/plugin/live/stop-watcher.js +218 -0
- package/assets/plugin/live/user-data-active-probe.d.ts +54 -0
- package/assets/plugin/live/user-data-active-probe.js +180 -0
- package/assets/plugin/live/user-data-stream-controller.d.ts +200 -0
- package/assets/plugin/live/user-data-stream-controller.js +579 -0
- package/assets/plugin/live/user-data-stream-ws.d.ts +22 -0
- package/assets/plugin/live/user-data-stream-ws.js +63 -0
- package/assets/plugin/live/user-data-stream.d.ts +243 -0
- package/assets/plugin/live/user-data-stream.js +704 -0
- package/assets/plugin/logger.d.ts +2 -0
- package/assets/plugin/logger.js +2 -0
- package/assets/plugin/mfe.d.ts +21 -0
- package/assets/plugin/mfe.js +68 -0
- package/assets/plugin/onboarding/mode-ladder.d.ts +1 -0
- package/assets/plugin/onboarding/mode-ladder.js +3 -0
- package/assets/plugin/onboarding/runtime.d.ts +102 -0
- package/assets/plugin/onboarding/runtime.js +215 -0
- package/assets/plugin/openclaw.plugin.json +92 -0
- package/assets/plugin/paper-adapter.d.ts +24 -0
- package/assets/plugin/paper-adapter.js +91 -0
- package/assets/plugin/persistence/state-manager.d.ts +66 -0
- package/assets/plugin/persistence/state-manager.js +222 -0
- package/assets/plugin/pinned-plan.d.ts +9 -0
- package/assets/plugin/pinned-plan.js +23 -0
- package/assets/plugin/portfolio/reentry-tracker.d.ts +36 -0
- package/assets/plugin/portfolio/reentry-tracker.js +127 -0
- package/assets/plugin/portfolio/wave9-admission.d.ts +67 -0
- package/assets/plugin/portfolio/wave9-admission.js +262 -0
- package/assets/plugin/portfolio/wave9-policy.d.ts +36 -0
- package/assets/plugin/portfolio/wave9-policy.js +183 -0
- package/assets/plugin/risk/pre-trade-check.d.ts +38 -0
- package/assets/plugin/risk/pre-trade-check.js +345 -0
- package/assets/plugin/risk/pre-trade-types.d.ts +60 -0
- package/assets/plugin/risk/pre-trade-types.js +3 -0
- package/assets/plugin/shadow/shadow-tracker.d.ts +36 -0
- package/assets/plugin/shadow/shadow-tracker.js +151 -0
- package/assets/plugin/shadow/types.d.ts +42 -0
- package/assets/plugin/shadow/types.js +20 -0
- package/assets/plugin/shared/indicators-extended.d.ts +52 -0
- package/assets/plugin/shared/indicators-extended.js +291 -0
- package/assets/plugin/shared/indicators.d.ts +15 -0
- package/assets/plugin/shared/indicators.js +114 -0
- package/assets/plugin/signals/conditions/registry.d.ts +16 -0
- package/assets/plugin/signals/conditions/registry.js +1333 -0
- package/assets/plugin/signals/conditions/types.d.ts +1 -0
- package/assets/plugin/signals/conditions/types.js +4 -0
- package/assets/plugin/signals/direction-rules.d.ts +3 -0
- package/assets/plugin/signals/direction-rules.js +24 -0
- package/assets/plugin/signals/entry-rules.d.ts +6 -0
- package/assets/plugin/signals/entry-rules.js +33 -0
- package/assets/plugin/signals/serialize-context.d.ts +4 -0
- package/assets/plugin/signals/serialize-context.js +39 -0
- package/assets/plugin/signals/stop-rules.d.ts +3 -0
- package/assets/plugin/signals/stop-rules.js +48 -0
- package/assets/plugin/signals/strategy-adapter.d.ts +47 -0
- package/assets/plugin/signals/strategy-adapter.js +209 -0
- package/assets/plugin/signals/types.d.ts +1 -0
- package/assets/plugin/signals/types.js +8 -0
- package/assets/plugin/simulator/exchange-simulator.d.ts +105 -0
- package/assets/plugin/simulator/exchange-simulator.js +759 -0
- package/assets/plugin/simulator/fill-engine.d.ts +53 -0
- package/assets/plugin/simulator/fill-engine.js +280 -0
- package/assets/plugin/simulator/paper-market-feed.d.ts +26 -0
- package/assets/plugin/simulator/paper-market-feed.js +104 -0
- package/assets/plugin/simulator/realistic-fills.d.ts +59 -0
- package/assets/plugin/simulator/realistic-fills.js +175 -0
- package/assets/plugin/simulator/types.d.ts +228 -0
- package/assets/plugin/simulator/types.js +43 -0
- package/assets/plugin/strategy/builtin-strategies.d.ts +2 -0
- package/assets/plugin/strategy/builtin-strategies.js +113 -0
- package/assets/plugin/strategy/condition-registry.d.ts +3 -0
- package/assets/plugin/strategy/condition-registry.js +153 -0
- package/assets/plugin/strategy/evaluator.d.ts +70 -0
- package/assets/plugin/strategy/evaluator.js +98 -0
- package/assets/plugin/tools/assessment-validation.d.ts +141 -0
- package/assets/plugin/tools/assessment-validation.js +473 -0
- package/assets/plugin/tools/attach-brackets.d.ts +39 -0
- package/assets/plugin/tools/attach-brackets.js +564 -0
- package/assets/plugin/tools/audit-bracket-protection.d.ts +49 -0
- package/assets/plugin/tools/audit-bracket-protection.js +683 -0
- package/assets/plugin/tools/bracket-control.d.ts +12 -0
- package/assets/plugin/tools/bracket-control.js +35 -0
- package/assets/plugin/tools/cancel-all-orders.d.ts +9 -0
- package/assets/plugin/tools/cancel-all-orders.js +8 -0
- package/assets/plugin/tools/cancel-order.d.ts +14 -0
- package/assets/plugin/tools/cancel-order.js +60 -0
- package/assets/plugin/tools/check-position-health.d.ts +46 -0
- package/assets/plugin/tools/check-position-health.js +194 -0
- package/assets/plugin/tools/clear-exchange-credentials.d.ts +24 -0
- package/assets/plugin/tools/clear-exchange-credentials.js +70 -0
- package/assets/plugin/tools/close-position.d.ts +45 -0
- package/assets/plugin/tools/close-position.js +722 -0
- package/assets/plugin/tools/create-order.d.ts +89 -0
- package/assets/plugin/tools/create-order.js +1555 -0
- package/assets/plugin/tools/exit-gate.d.ts +58 -0
- package/assets/plugin/tools/exit-gate.js +162 -0
- package/assets/plugin/tools/fetch-balance.d.ts +5 -0
- package/assets/plugin/tools/fetch-balance.js +4 -0
- package/assets/plugin/tools/fetch-ohlcv.d.ts +11 -0
- package/assets/plugin/tools/fetch-ohlcv.js +8 -0
- package/assets/plugin/tools/fetch-open-orders.d.ts +7 -0
- package/assets/plugin/tools/fetch-open-orders.js +4 -0
- package/assets/plugin/tools/fetch-positions.d.ts +7 -0
- package/assets/plugin/tools/fetch-positions.js +4 -0
- package/assets/plugin/tools/fetch-ticker.d.ts +11 -0
- package/assets/plugin/tools/fetch-ticker.js +5 -0
- package/assets/plugin/tools/get-agent-profile.d.ts +4 -0
- package/assets/plugin/tools/get-agent-profile.js +6 -0
- package/assets/plugin/tools/get-analytics.d.ts +6 -0
- package/assets/plugin/tools/get-analytics.js +7 -0
- package/assets/plugin/tools/get-backtest.d.ts +12 -0
- package/assets/plugin/tools/get-backtest.js +91 -0
- package/assets/plugin/tools/get-basis.d.ts +7 -0
- package/assets/plugin/tools/get-basis.js +7 -0
- package/assets/plugin/tools/get-bracket-config.d.ts +11 -0
- package/assets/plugin/tools/get-bracket-config.js +24 -0
- package/assets/plugin/tools/get-cascade-risk.d.ts +7 -0
- package/assets/plugin/tools/get-cascade-risk.js +8 -0
- package/assets/plugin/tools/get-crypto-metrics.d.ts +18 -0
- package/assets/plugin/tools/get-crypto-metrics.js +62 -0
- package/assets/plugin/tools/get-cvd.d.ts +6 -0
- package/assets/plugin/tools/get-cvd.js +6 -0
- package/assets/plugin/tools/get-divergences.d.ts +6 -0
- package/assets/plugin/tools/get-divergences.js +6 -0
- package/assets/plugin/tools/get-funding-context.d.ts +6 -0
- package/assets/plugin/tools/get-funding-context.js +16 -0
- package/assets/plugin/tools/get-liquidation-levels.d.ts +7 -0
- package/assets/plugin/tools/get-liquidation-levels.js +7 -0
- package/assets/plugin/tools/get-liquidation-pulse.d.ts +9 -0
- package/assets/plugin/tools/get-liquidation-pulse.js +22 -0
- package/assets/plugin/tools/get-market-breadth.d.ts +6 -0
- package/assets/plugin/tools/get-market-breadth.js +8 -0
- package/assets/plugin/tools/get-market-intel.d.ts +19 -0
- package/assets/plugin/tools/get-market-intel.js +116 -0
- package/assets/plugin/tools/get-market-structure.d.ts +47 -0
- package/assets/plugin/tools/get-market-structure.js +198 -0
- package/assets/plugin/tools/get-my-mined-patterns.d.ts +20 -0
- package/assets/plugin/tools/get-my-mined-patterns.js +61 -0
- package/assets/plugin/tools/get-my-proposed-learnings.d.ts +20 -0
- package/assets/plugin/tools/get-my-proposed-learnings.js +55 -0
- package/assets/plugin/tools/get-my-recent-reviews.d.ts +22 -0
- package/assets/plugin/tools/get-my-recent-reviews.js +66 -0
- package/assets/plugin/tools/get-orderbook.d.ts +21 -0
- package/assets/plugin/tools/get-orderbook.js +32 -0
- package/assets/plugin/tools/get-pattern-scan.d.ts +7 -0
- package/assets/plugin/tools/get-pattern-scan.js +8 -0
- package/assets/plugin/tools/get-regime.d.ts +6 -0
- package/assets/plugin/tools/get-regime.js +7 -0
- package/assets/plugin/tools/get-relevant-learnings.d.ts +21 -0
- package/assets/plugin/tools/get-relevant-learnings.js +65 -0
- package/assets/plugin/tools/get-resting-liquidity.d.ts +6 -0
- package/assets/plugin/tools/get-resting-liquidity.js +11 -0
- package/assets/plugin/tools/get-risk-scenario.d.ts +29 -0
- package/assets/plugin/tools/get-risk-scenario.js +47 -0
- package/assets/plugin/tools/get-risk-summary.d.ts +51 -0
- package/assets/plugin/tools/get-risk-summary.js +118 -0
- package/assets/plugin/tools/get-sentiment.d.ts +4 -0
- package/assets/plugin/tools/get-sentiment.js +6 -0
- package/assets/plugin/tools/get-session-review.d.ts +7 -0
- package/assets/plugin/tools/get-session-review.js +8 -0
- package/assets/plugin/tools/get-setup-detail.d.ts +7 -0
- package/assets/plugin/tools/get-setup-detail.js +322 -0
- package/assets/plugin/tools/get-signals.d.ts +15 -0
- package/assets/plugin/tools/get-signals.js +54 -0
- package/assets/plugin/tools/get-sizing.d.ts +6 -0
- package/assets/plugin/tools/get-sizing.js +6 -0
- package/assets/plugin/tools/get-trade-feedback.d.ts +7 -0
- package/assets/plugin/tools/get-trade-feedback.js +8 -0
- package/assets/plugin/tools/get-trade-flow.d.ts +7 -0
- package/assets/plugin/tools/get-trade-flow.js +7 -0
- package/assets/plugin/tools/get-volume-analysis.d.ts +21 -0
- package/assets/plugin/tools/get-volume-analysis.js +74 -0
- package/assets/plugin/tools/get-volume-profile.d.ts +7 -0
- package/assets/plugin/tools/get-volume-profile.js +7 -0
- package/assets/plugin/tools/get-wave9-status.d.ts +127 -0
- package/assets/plugin/tools/get-wave9-status.js +796 -0
- package/assets/plugin/tools/helpers.d.ts +26 -0
- package/assets/plugin/tools/helpers.js +39 -0
- package/assets/plugin/tools/intel-api.d.ts +34 -0
- package/assets/plugin/tools/intel-api.js +119 -0
- package/assets/plugin/tools/intel-cache.d.ts +25 -0
- package/assets/plugin/tools/intel-cache.js +148 -0
- package/assets/plugin/tools/list-strategies.d.ts +17 -0
- package/assets/plugin/tools/list-strategies.js +23 -0
- package/assets/plugin/tools/modify-stop.d.ts +21 -0
- package/assets/plugin/tools/modify-stop.js +120 -0
- package/assets/plugin/tools/modify-target.d.ts +21 -0
- package/assets/plugin/tools/modify-target.js +110 -0
- package/assets/plugin/tools/propose-learning.d.ts +22 -0
- package/assets/plugin/tools/propose-learning.js +65 -0
- package/assets/plugin/tools/query-review-outcomes.d.ts +30 -0
- package/assets/plugin/tools/query-review-outcomes.js +64 -0
- package/assets/plugin/tools/query-trades.d.ts +21 -0
- package/assets/plugin/tools/query-trades.js +37 -0
- package/assets/plugin/tools/record-position-reviews.d.ts +38 -0
- package/assets/plugin/tools/record-position-reviews.js +147 -0
- package/assets/plugin/tools/save-strategy.d.ts +16 -0
- package/assets/plugin/tools/save-strategy.js +46 -0
- package/assets/plugin/tools/scan-pairs.d.ts +22 -0
- package/assets/plugin/tools/scan-pairs.js +234 -0
- package/assets/plugin/tools/score-setup.d.ts +31 -0
- package/assets/plugin/tools/score-setup.js +268 -0
- package/assets/plugin/tools/set-bracket-requirement.d.ts +18 -0
- package/assets/plugin/tools/set-bracket-requirement.js +81 -0
- package/assets/plugin/tools/set-exchange-credentials.d.ts +25 -0
- package/assets/plugin/tools/set-exchange-credentials.js +80 -0
- package/assets/plugin/tools/set-trading-mode.d.ts +26 -0
- package/assets/plugin/tools/set-trading-mode.js +152 -0
- package/assets/plugin/tools/test-exchange-credentials.d.ts +16 -0
- package/assets/plugin/tools/test-exchange-credentials.js +100 -0
- package/assets/plugin/tools/toggle-strategy.d.ts +8 -0
- package/assets/plugin/tools/toggle-strategy.js +15 -0
- package/assets/plugin/trading-params-cache.d.ts +26 -0
- package/assets/plugin/trading-params-cache.js +52 -0
- package/assets/plugin/types.d.ts +134 -0
- package/assets/plugin/types.js +7 -0
- package/assets/plugin/util/plugin-paths.d.ts +3 -0
- package/assets/plugin/util/plugin-paths.js +15 -0
- package/assets/plugin/venues/hyperliquid/hl-balance.d.ts +116 -0
- package/assets/plugin/venues/hyperliquid/hl-balance.js +145 -0
- package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.d.ts +123 -0
- package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.js +533 -0
- package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +102 -0
- package/assets/plugin/venues/hyperliquid/hl-brackets.js +172 -0
- package/assets/plugin/venues/hyperliquid/hl-cloid.d.ts +22 -0
- package/assets/plugin/venues/hyperliquid/hl-cloid.js +82 -0
- package/assets/plugin/venues/hyperliquid/hl-info-cache.d.ts +46 -0
- package/assets/plugin/venues/hyperliquid/hl-info-cache.js +125 -0
- package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +146 -0
- package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +728 -0
- package/assets/plugin/venues/hyperliquid/hl-precision.d.ts +61 -0
- package/assets/plugin/venues/hyperliquid/hl-precision.js +176 -0
- package/assets/plugin/venues/hyperliquid/hl-private.d.ts +88 -0
- package/assets/plugin/venues/hyperliquid/hl-private.js +357 -0
- package/assets/plugin/venues/hyperliquid/hl-public.d.ts +79 -0
- package/assets/plugin/venues/hyperliquid/hl-public.js +436 -0
- package/assets/plugin/venues/hyperliquid/hl-rate-gate.d.ts +57 -0
- package/assets/plugin/venues/hyperliquid/hl-rate-gate.js +220 -0
- package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +90 -0
- package/assets/plugin/venues/hyperliquid/hl-user-stream.js +220 -0
- package/assets/plugin/venues/registry.d.ts +38 -0
- package/assets/plugin/venues/registry.js +46 -0
- package/assets/plugin/venues/symbols.d.ts +43 -0
- package/assets/plugin/venues/symbols.js +107 -0
- package/assets/plugin/wave9/live-account-capture.d.ts +67 -0
- package/assets/plugin/wave9/live-account-capture.js +435 -0
- package/assets/plugin/wave9/live-autonomous-protection.d.ts +39 -0
- package/assets/plugin/wave9/live-autonomous-protection.js +112 -0
- package/assets/plugin/wave9/live-durable-reconciliation-scheduler.d.ts +33 -0
- package/assets/plugin/wave9/live-durable-reconciliation-scheduler.js +115 -0
- package/assets/plugin/wave9/live-execution-ledger.d.ts +107 -0
- package/assets/plugin/wave9/live-execution-ledger.js +498 -0
- package/assets/plugin/wave9/live-position-confirmation.d.ts +18 -0
- package/assets/plugin/wave9/live-position-confirmation.js +111 -0
- package/assets/plugin/wave9/live-residual-protection.d.ts +18 -0
- package/assets/plugin/wave9/live-residual-protection.js +250 -0
- package/assets/plugin/wave9/live-startup-reconciliation.d.ts +38 -0
- package/assets/plugin/wave9/live-startup-reconciliation.js +454 -0
- package/assets/plugin/wave9/live-symbol-ownership.d.ts +20 -0
- package/assets/plugin/wave9/live-symbol-ownership.js +132 -0
- package/assets/plugin/wave9/paper-admission-guard.d.ts +199 -0
- package/assets/plugin/wave9/paper-admission-guard.js +650 -0
- package/assets/plugin/wave9/usdm-evidence-provider.d.ts +42 -0
- package/assets/plugin/wave9/usdm-evidence-provider.js +133 -0
- package/dist/plugin.js +24 -15
- package/package.json +1 -1
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// Hyperliquid signed-action client — the HL mirror of `ccxt/binance-private.ts`.
|
|
2
|
+
//
|
|
3
|
+
// CONTRACTS THIS FILE INHERITS FROM THE BINANCE SIDE (non-negotiable — the shared
|
|
4
|
+
// adapter-contract suite runs against both):
|
|
5
|
+
// ★ null ≠ empty. EVERY read returns `null` on a FAILED fetch, never `[]`.
|
|
6
|
+
// `[]` means "the exchange said: nothing". Callers make destructive decisions
|
|
7
|
+
// (cancel a bracket, close a position, trust a snapshot) on that difference.
|
|
8
|
+
// ★ Reads are pre-gated (`assertNotLimited`), order/cancel paths are NOT (an
|
|
9
|
+
// exit must never be blocked by our own pacer) but every path arms the gate
|
|
10
|
+
// via `noteError`.
|
|
11
|
+
//
|
|
12
|
+
// HYPERLIQUID-SPECIFIC LANDMINES (all verified live on testnet 2026-07-12):
|
|
13
|
+
// ★ ccxt AUTO-MONETIZES an authed HL client — `initializeClient()` enrolls
|
|
14
|
+
// CCXT's own builder fee (1bp/order) + referral code on the first signed call.
|
|
15
|
+
// `options.{builderFee:false, refSet:true}` disables both. A test pins this.
|
|
16
|
+
// ★ Market orders REQUIRE a reference price (ccxt derives the slippage cap from
|
|
17
|
+
// it) — `createOrder(sym,'market',side,size)` with no price THROWS client-side.
|
|
18
|
+
// There is no native market order on HL: it is an IOC limit at a bounded price.
|
|
19
|
+
// ★ Signed actions carry a NONCE (epoch ms) and HL keeps only the 100 highest
|
|
20
|
+
// per signer. Two actions signed in the same millisecond can collide → every
|
|
21
|
+
// signed action goes through a monotonic-nonce MUTEX (one in-flight at a time,
|
|
22
|
+
// strictly increasing ms). This is why `submitOrders` batches a bracket pair
|
|
23
|
+
// into ONE action rather than firing two.
|
|
24
|
+
// ★ Agent (API) wallets can only TRADE. `usdClassTransfer`/withdraw are
|
|
25
|
+
// user-signed actions and fail with "Must deposit before performing actions"
|
|
26
|
+
// when signed by an agent. We never call them.
|
|
27
|
+
import { createRequire } from 'node:module';
|
|
28
|
+
import { logger } from '../../logger.js';
|
|
29
|
+
import { toCcxtSymbol } from '../symbols.js';
|
|
30
|
+
import { assertNotLimited, noteError, noteSuccess, exchangeIpWeight, updateAddressBudget, } from './hl-rate-gate.js';
|
|
31
|
+
import { isValidHlCloid } from './hl-cloid.js';
|
|
32
|
+
// ccxt via CJS require — OpenClaw's ESM loader yields the wrong module shape
|
|
33
|
+
// (same rationale as binance-private.ts / hl-public.ts).
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
let ccxtCjs;
|
|
36
|
+
try {
|
|
37
|
+
const _require = createRequire(import.meta.url);
|
|
38
|
+
ccxtCjs = _require('ccxt');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
42
|
+
ccxtCjs = require('ccxt');
|
|
43
|
+
}
|
|
44
|
+
const TAG = 'hl-private';
|
|
45
|
+
/** The CCXT options that MUST be present on every authed HL client. Exported so
|
|
46
|
+
* `hl-private.test.ts` can assert them — if a future ccxt bump changes the
|
|
47
|
+
* option names, the test fails rather than the users paying a silent 1bp. */
|
|
48
|
+
export const HL_REQUIRED_OPTIONS = {
|
|
49
|
+
builderFee: false,
|
|
50
|
+
refSet: true,
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Serializes every signed action behind a monotonic nonce.
|
|
54
|
+
*
|
|
55
|
+
* HL keeps the 100 highest nonces per signer and rejects repeats; two actions
|
|
56
|
+
* signed inside the same millisecond can therefore collide and one is silently
|
|
57
|
+
* lost. Rather than hand-rolling nonces (ccxt owns that), we guarantee that no
|
|
58
|
+
* two signed actions are ever *issued* in the same millisecond from this process:
|
|
59
|
+
* each waits for the previous to settle AND for the clock to advance.
|
|
60
|
+
*/
|
|
61
|
+
class NonceMutex {
|
|
62
|
+
chain = Promise.resolve();
|
|
63
|
+
lastIssuedMs = 0;
|
|
64
|
+
run(fn) {
|
|
65
|
+
const next = this.chain.then(async () => {
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
if (now <= this.lastIssuedMs) {
|
|
68
|
+
// Same-ms collision guard: wait out the millisecond.
|
|
69
|
+
await new Promise((r) => setTimeout(r, this.lastIssuedMs - now + 1));
|
|
70
|
+
}
|
|
71
|
+
this.lastIssuedMs = Date.now();
|
|
72
|
+
return fn();
|
|
73
|
+
});
|
|
74
|
+
// Keep the chain alive even when a link rejects (otherwise one failed action
|
|
75
|
+
// would poison every later one).
|
|
76
|
+
this.chain = next.then(() => undefined, () => undefined);
|
|
77
|
+
return next;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export class HyperliquidPrivateApi {
|
|
81
|
+
creds;
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
exchange;
|
|
84
|
+
mutex = new NonceMutex();
|
|
85
|
+
marketsLoaded = false;
|
|
86
|
+
constructor(creds) {
|
|
87
|
+
this.creds = creds;
|
|
88
|
+
if (!creds.walletAddress || !creds.agentPrivateKey) {
|
|
89
|
+
throw new Error('HyperliquidPrivateApi requires walletAddress + agentPrivateKey');
|
|
90
|
+
}
|
|
91
|
+
this.exchange = new ccxtCjs.hyperliquid({
|
|
92
|
+
walletAddress: creds.walletAddress,
|
|
93
|
+
privateKey: creds.agentPrivateKey,
|
|
94
|
+
options: { ...HL_REQUIRED_OPTIONS },
|
|
95
|
+
enableRateLimit: true,
|
|
96
|
+
});
|
|
97
|
+
if (creds.testnet) {
|
|
98
|
+
this.exchange.setSandboxMode(true);
|
|
99
|
+
const url = JSON.stringify(this.exchange.urls?.api ?? '');
|
|
100
|
+
if (!url.includes('testnet')) {
|
|
101
|
+
throw new Error(`HL testnet requested but sandbox URL is not testnet: ${url.slice(0, 80)}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
logger.info(TAG, `Hyperliquid private API initialized (${creds.testnet ? 'TESTNET' : 'MAINNET'}, master ${creds.walletAddress.slice(0, 8)}…)`);
|
|
105
|
+
}
|
|
106
|
+
/** Exposed for the options-pin test + diagnostics. */
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
getExchange() {
|
|
109
|
+
return this.exchange;
|
|
110
|
+
}
|
|
111
|
+
async loadMarkets() {
|
|
112
|
+
try {
|
|
113
|
+
assertNotLimited('meta');
|
|
114
|
+
await this.exchange.loadMarkets();
|
|
115
|
+
noteSuccess('meta');
|
|
116
|
+
this.marketsLoaded = true;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
noteError(err, 'loadMarkets');
|
|
121
|
+
logger.error(TAG, `loadMarkets failed: ${msg(err)}`);
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// ---- Reads (null on failure — NEVER []) ----
|
|
126
|
+
/** Positions for the MASTER account. `null` = fetch failed (state unknown);
|
|
127
|
+
* `[]` = the exchange confirmed flat. */
|
|
128
|
+
async fetchPositions(symbol) {
|
|
129
|
+
try {
|
|
130
|
+
assertNotLimited('clearinghouseState');
|
|
131
|
+
const symbols = symbol ? [toCcxtSymbol('hyperliquid', symbol)] : undefined;
|
|
132
|
+
const raw = await this.exchange.fetchPositions(symbols);
|
|
133
|
+
noteSuccess('clearinghouseState');
|
|
134
|
+
if (!Array.isArray(raw))
|
|
135
|
+
return null;
|
|
136
|
+
return raw.filter((p) => Math.abs(Number(p.contracts ?? 0)) > 0);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
noteError(err, 'fetchPositions');
|
|
140
|
+
logger.error(TAG, `fetchPositions failed: ${msg(err)}`);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Open orders INCLUDING trigger/TPSL legs. CCXT's HL `fetchOpenOrders`
|
|
145
|
+
* defaults to `frontendOpenOrders`, which is the only endpoint that returns
|
|
146
|
+
* trigger orders (plan §3.6) — the analog of Binance's merged algo endpoints. */
|
|
147
|
+
async fetchOpenOrders(symbol) {
|
|
148
|
+
try {
|
|
149
|
+
assertNotLimited('frontendOpenOrders');
|
|
150
|
+
const s = symbol ? toCcxtSymbol('hyperliquid', symbol) : undefined;
|
|
151
|
+
const raw = await this.exchange.fetchOpenOrders(s);
|
|
152
|
+
noteSuccess('frontendOpenOrders');
|
|
153
|
+
return Array.isArray(raw) ? raw : null;
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
noteError(err, 'fetchOpenOrders');
|
|
157
|
+
logger.error(TAG, `fetchOpenOrders failed: ${msg(err)}`);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async fetchBalance() {
|
|
162
|
+
try {
|
|
163
|
+
assertNotLimited('clearinghouseState');
|
|
164
|
+
const raw = await this.exchange.fetchBalance();
|
|
165
|
+
noteSuccess('clearinghouseState');
|
|
166
|
+
return raw ?? null;
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
noteError(err, 'fetchBalance');
|
|
170
|
+
logger.error(TAG, `fetchBalance failed: ${msg(err)}`);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** Per-order status — the liveness resolver's REST tier (Tier 2 of the
|
|
175
|
+
* 3-tier rule). Weight 2. `null` = lookup FAILED (unknown), which callers
|
|
176
|
+
* must treat as "do not act", NOT as "gone". */
|
|
177
|
+
async fetchOrder(orderId, symbol) {
|
|
178
|
+
try {
|
|
179
|
+
assertNotLimited('orderStatus');
|
|
180
|
+
const s = symbol ? toCcxtSymbol('hyperliquid', symbol) : undefined;
|
|
181
|
+
const raw = await this.exchange.fetchOrder(orderId, s);
|
|
182
|
+
noteSuccess('orderStatus');
|
|
183
|
+
return raw ?? null;
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
noteError(err, 'fetchOrder');
|
|
187
|
+
logger.warn(TAG, `fetchOrder(${orderId}) failed: ${msg(err)}`);
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** Own fills. WS is the authoritative ingress (plan + the audit-trail rule);
|
|
192
|
+
* this is the gap-fill/truth-check path. NOTE: only the 10,000 most recent
|
|
193
|
+
* fills exist server-side — deep history is NOT queryable on HL, which is why
|
|
194
|
+
* the `trades` table must be WS-first. */
|
|
195
|
+
async fetchMyTrades(symbol, since, limit = 100) {
|
|
196
|
+
try {
|
|
197
|
+
assertNotLimited('userFills');
|
|
198
|
+
const s = symbol ? toCcxtSymbol('hyperliquid', symbol) : undefined;
|
|
199
|
+
const raw = await this.exchange.fetchMyTrades(s, since, limit);
|
|
200
|
+
noteSuccess('userFills');
|
|
201
|
+
return Array.isArray(raw) ? raw : null;
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
noteError(err, 'fetchMyTrades');
|
|
205
|
+
logger.error(TAG, `fetchMyTrades failed: ${msg(err)}`);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** Refresh the ADDRESS action budget (the starvation guard). Weight 20 — call
|
|
210
|
+
* every ~5 min, never per-heartbeat. */
|
|
211
|
+
async refreshAddressBudget() {
|
|
212
|
+
try {
|
|
213
|
+
assertNotLimited('userRateLimit');
|
|
214
|
+
const res = await this.rawInfo({ type: 'userRateLimit', user: this.creds.walletAddress });
|
|
215
|
+
noteSuccess('userRateLimit');
|
|
216
|
+
const used = Number(res?.nRequestsUsed);
|
|
217
|
+
const cap = Number(res?.nRequestsCap);
|
|
218
|
+
if (Number.isFinite(used) && Number.isFinite(cap)) {
|
|
219
|
+
updateAddressBudget({ nRequestsUsed: used, nRequestsCap: cap });
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
noteError(err, 'userRateLimit');
|
|
224
|
+
logger.warn(TAG, `refreshAddressBudget failed: ${msg(err)}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** Raw `POST /info` — for the handful of reads CCXT doesn't expose
|
|
228
|
+
* (userRateLimit, userNonFundingLedgerUpdates, portfolio). Never used for
|
|
229
|
+
* signed actions. */
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
|
+
async rawInfo(body) {
|
|
232
|
+
const base = this.creds.testnet
|
|
233
|
+
? 'https://api.hyperliquid-testnet.xyz'
|
|
234
|
+
: 'https://api.hyperliquid.xyz';
|
|
235
|
+
const res = await fetch(`${base}/info`, {
|
|
236
|
+
method: 'POST',
|
|
237
|
+
headers: { 'content-type': 'application/json' },
|
|
238
|
+
body: JSON.stringify(body),
|
|
239
|
+
signal: AbortSignal.timeout(15_000),
|
|
240
|
+
});
|
|
241
|
+
if (!res.ok)
|
|
242
|
+
throw new Error(`POST /info ${String(body.type)} → ${res.status}`);
|
|
243
|
+
return res.json();
|
|
244
|
+
}
|
|
245
|
+
// ---- Signed actions (NEVER pre-gated; always nonce-serialized) ----
|
|
246
|
+
/** Submit one order. Market orders are IOC-limit emulated — `price` is
|
|
247
|
+
* MANDATORY (ccxt throws without it) and the caller must already have applied
|
|
248
|
+
* the slippage bound + HL rounding (hl-precision). */
|
|
249
|
+
async submitOrder(req) {
|
|
250
|
+
if (req.cloid && !isValidHlCloid(req.cloid)) {
|
|
251
|
+
throw new Error(`Invalid HL cloid ${req.cloid} — must be 0x + 32 hex chars`);
|
|
252
|
+
}
|
|
253
|
+
return this.mutex.run(async () => {
|
|
254
|
+
try {
|
|
255
|
+
const params = this.buildParams(req);
|
|
256
|
+
const order = await this.exchange.createOrder(toCcxtSymbol('hyperliquid', req.symbol), req.type === 'market' ? 'market' : 'limit', req.side, req.amount, req.price, // ★ always passed — ccxt needs it even for 'market'
|
|
257
|
+
params);
|
|
258
|
+
noteSuccess('exchange', { ipWeight: exchangeIpWeight(1), addressActions: 1 });
|
|
259
|
+
return order ?? null;
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
noteError(err, 'submitOrder');
|
|
263
|
+
// Order paths RETHROW (the caller must see a rejection) — unlike reads,
|
|
264
|
+
// which collapse to null.
|
|
265
|
+
throw err;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/** Submit N orders as ONE signed action (one nonce, one `/exchange` call).
|
|
270
|
+
* This is how a bracket pair (SL+TP) is placed: atomic-ish, and it costs 1 IP
|
|
271
|
+
* weight unit but N address actions. */
|
|
272
|
+
async submitOrders(reqs) {
|
|
273
|
+
if (reqs.length === 0)
|
|
274
|
+
return [];
|
|
275
|
+
for (const r of reqs) {
|
|
276
|
+
if (r.cloid && !isValidHlCloid(r.cloid)) {
|
|
277
|
+
throw new Error(`Invalid HL cloid ${r.cloid} — must be 0x + 32 hex chars`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return this.mutex.run(async () => {
|
|
281
|
+
try {
|
|
282
|
+
const ccxtReqs = reqs.map((r) => ({
|
|
283
|
+
symbol: toCcxtSymbol('hyperliquid', r.symbol),
|
|
284
|
+
type: r.type === 'market' ? 'market' : 'limit',
|
|
285
|
+
side: r.side,
|
|
286
|
+
amount: r.amount,
|
|
287
|
+
price: r.price,
|
|
288
|
+
params: this.buildParams(r),
|
|
289
|
+
}));
|
|
290
|
+
const orders = await this.exchange.createOrders(ccxtReqs);
|
|
291
|
+
noteSuccess('exchange', {
|
|
292
|
+
ipWeight: exchangeIpWeight(reqs.length),
|
|
293
|
+
addressActions: reqs.length, // ★ batches cost n against the ADDRESS budget
|
|
294
|
+
});
|
|
295
|
+
return Array.isArray(orders) ? orders : null;
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
noteError(err, 'submitOrders');
|
|
299
|
+
throw err;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
async cancelOrder(orderId, symbol) {
|
|
304
|
+
return this.mutex.run(async () => {
|
|
305
|
+
try {
|
|
306
|
+
const res = await this.exchange.cancelOrder(orderId, toCcxtSymbol('hyperliquid', symbol));
|
|
307
|
+
noteSuccess('exchange', { ipWeight: exchangeIpWeight(1), addressActions: 1 });
|
|
308
|
+
return res ?? null;
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
noteError(err, 'cancelOrder');
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
/** Cancel by cloid — the bracket path's cancel (we always know our own cloid,
|
|
317
|
+
* and it survives a restart because it is derived, not stored). */
|
|
318
|
+
async cancelOrderByCloid(cloid, symbol) {
|
|
319
|
+
return this.mutex.run(async () => {
|
|
320
|
+
try {
|
|
321
|
+
const res = await this.exchange.cancelOrder(cloid, toCcxtSymbol('hyperliquid', symbol), { clientOrderId: cloid });
|
|
322
|
+
noteSuccess('exchange', { ipWeight: exchangeIpWeight(1), addressActions: 1 });
|
|
323
|
+
return res ?? null;
|
|
324
|
+
}
|
|
325
|
+
catch (err) {
|
|
326
|
+
noteError(err, 'cancelOrderByCloid');
|
|
327
|
+
throw err;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
332
|
+
buildParams(req) {
|
|
333
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
334
|
+
const params = {};
|
|
335
|
+
if (req.reduceOnly)
|
|
336
|
+
params.reduceOnly = true;
|
|
337
|
+
if (req.postOnly)
|
|
338
|
+
params.postOnly = true; // → ALO
|
|
339
|
+
if (req.cloid)
|
|
340
|
+
params.clientOrderId = req.cloid;
|
|
341
|
+
if (req.trigger) {
|
|
342
|
+
// HL trigger orders fire on MARK price only (no workingType choice).
|
|
343
|
+
params.triggerPrice = req.trigger.triggerPrice;
|
|
344
|
+
if (req.trigger.tpsl === 'tp')
|
|
345
|
+
params.takeProfitPrice = req.trigger.triggerPrice;
|
|
346
|
+
else
|
|
347
|
+
params.stopLossPrice = req.trigger.triggerPrice;
|
|
348
|
+
}
|
|
349
|
+
return params;
|
|
350
|
+
}
|
|
351
|
+
get isMarketsLoaded() {
|
|
352
|
+
return this.marketsLoaded;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function msg(err) {
|
|
356
|
+
return err instanceof Error ? err.message : String(err);
|
|
357
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
}
|