← Protocols
Hyperliquid
01Description

On-chain perps DEX with a fully on-chain orderbook running on its own L1 (HyperCore) plus an EVM execution layer (HyperEVM). Apps integrate via the JSON HTTP/WebSocket API and earn revenue through Builder Codes.

02Best for
  • 01perps trading UIs
  • 02high-frequency on-chain orderbook
  • 03builder-code revenue share
  • 04spot + perps in one venue
  • 05HyperEVM dApps
03Install
  • pnpm add @nktkas/hyperliquid
  • pip install hyperliquid-python-sdk
04Environment variables
VariableScopeDescription
HYPERLIQUID_API_URLClientBase API URL (https://api.hyperliquid.xyz for mainnet, https://api.hyperliquid-testnet.xyz for testnet).
HYPERLIQUID_BUILDER_ADDRESSClientEVM address registered as builder. Required to attach builder codes (`b` field) and earn fees on routed orders.
HYPERLIQUID_PRIVATE_KEYServerServer-side signer key for placing orders / API wallet. Never expose to the client — use API wallets, not the master key.
05Prompt snippet
Use Hyperliquid for on-chain perps with a real orderbook. Place orders by POSTing signed actions to `https://api.hyperliquid.xyz/exchange` (action type `order`); read state from `/info` (e.g. `clearinghouseState`, `l2Book`, `meta`). Subscribe to live fills/book updates over `wss://api.hyperliquid.xyz/ws`. To monetize, register a builder, have the user call `approveBuilderFee` once, then attach `{ b: BUILDER_ADDRESS, f: tenthsOfBps }` to each order — capped at 10 bps for perps and 100 bps for spot. For HyperEVM smart-contract calls, use chain ID 999 with standard viem/ethers and the precompiles for cross-layer reads.
06Gotchas
  • HyperCore is its own L1 — it is NOT EVM. Order placement, cancels and fills go through the JSON API with EIP-712 signed actions, not on-chain transactions. HyperEVM (chain id 999) is a separate execution layer that interoperates via precompiles and the system bridge.
  • Builder codes require the user to first call `approveBuilderFee` (one-time per builder) and the builder wallet must hold at least 100 USDC of perps account value. Fee `f` is in tenths of a basis point: `f: 10` = 1 bp; max is 100 (10 bps) for perps and 1000 (100 bps) for spot.
  • Use API wallets (sub-accounts with limited authority) for trading rather than the master account key. Master-key compromise drains the whole account; API wallets can be revoked.
  • Funding accrues hourly (not 8h like CEXs) and is paid continuously per block — backtests must use the per-hour funding history endpoint, not daily snapshots.
  • Liquidations are handled by the on-chain liquidator and can crossbook against the HLP vault; oracle-mark divergence and reduced-only orders behave differently from CEX semantics.
  • Mainnet and testnet are fully separate environments with different USDC bridges (Arbitrum -> HyperCore). Don't share keys between them and remember the testnet faucet only mints mock USDC on the testnet bridge.
07Alternatives