
hyperliquid-preflight
io.github.PTone111/hyperliquid-preflight
Pre-trade risk check for Hyperliquid perps incl. HIP-3 stock perps. Read-only, pay-per-call (x402).
Documentation
hyperliquid-preflight

Check a Hyperliquid perp trade before you place it. Built for AI agents, and it works from a plain script too.
HIP-3 stock perps (xyz:NVDA, xyz:TSLA, ...) keep trading when the US stock market is closed. During a closure the price comes only from the on-chain book, inside per-market discovery bounds. A 10x position can be liquidated on a thin weekend book while the stock itself hasn't moved. See data/weekend-backtest-20261205.md: 12 markets, May to Nov 2026. At 5x there were no weekend liquidations. At 10x, the volatile names were liquidated several times, and the price was often back by the Monday reopen.
The check returns risk_level low, medium or high with reasons, covering:
- leverage tier
- market session and upcoming closures (trade[XYZ] official schedule and holidays)
- discovery bounds and weekend book depth
- mark/oracle deviation
- funding cost
- slippage
- approximate liquidation distance
- fees
It is read-only: it never places orders and never needs keys.
Quick start
# free: which listing of NVDA should I trade?
curl -A my-agent https://x402-bsc-tools.x402-bsc-tools.workers.dev/v1/hl/market-verify?symbol=NVDA
# Claude Code: add the MCP server
claude mcp add --transport http preflight https://x402-bsc-tools.x402-bsc-tools.workers.dev/mcp
Use it
- Agent Skill: copy
skill/hyperliquid-preflight/into your agent's skills folder. - MCP server (streamable HTTP):
https://x402-bsc-tools.x402-bsc-tools.workers.dev/mcp. See examples/mcp-config.md. - HTTP:
GET /v1/hl/pretrade-check?coin=xyz:NVDA&side=long&size_usd=1000&leverage=5&hold_hours=24 - Python: examples/check_then_trade.py gates your own order code behind the check, using the standard library only.
Pricing via x402, per call, USDC on Base or USDT on BNB Chain.
hl_pretrade_check costs $0.02, hl_account_audit (builder fee approvals, agent wallets, positions near liquidation) $0.01, and hl_market_verify is free.
You are not charged if Hyperliquid data cannot be fetched.
Machine-readable: /openapi.json, /llms.txt.
Limits
- Liquidation figures are approximations: isolated margin, with fees and funding ignored.
- Published trade[XYZ] parameters carry
params_verified_at. - The backtest uses 1h traded candles as a stand-in for the mark price.
- Risk information only, not financial advice.
License
MIT for the code and the Skill in this repository. The hosted API is a separate paid service.
No installation packages available.