Skip to main content
Glama
hyperliquid-preflight

hyperliquid-preflight

by PTone111
README.md
# hyperliquid-preflight

![hyperliquid-preflight](docs/banner.png)

[![CI](https://github.com/PTone111/hyperliquid-preflight/actions/workflows/ci.yml/badge.svg)](https://github.com/PTone111/hyperliquid-preflight/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![MCP](https://img.shields.io/badge/MCP-streamable%20HTTP-6e56cf)](examples/mcp-config.md)
[![x402](https://img.shields.io/badge/x402-Base%20USDC%20%7C%20BNB%20USDT-0052ff)](https://x402.org)

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](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

```bash
# 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/`](skill/hyperliquid-preflight/SKILL.md) 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](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](examples/check_then_trade.py) gates your own order code behind the check, using the standard library only.

Pricing via [x402](https://x402.org), 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.