Skip to main content
Execution: venue.trade() in chat code, strategy.execute() in strategy agents. Available in live (HYPERLIQUID) and paper (HYPERLIQUID_PAPER) modes. Data reference: Hyperliquid Data.

Overview

Hyperliquid is an on-chain exchange for perpetual futures and spot pairs. Scalar Field connects to it as a tradable venue: market data is read from Hyperliquid’s public API, and orders are placed against an exchange account funded with USDC bridged from your Arbitrum wallet. A paper account (HYPERLIQUID_PAPER) is also available with virtual USDC and fills simulated against the live order book — see Paper Trading.

Order Semantics

  • Symbols use the H: prefix: H:BTC for perps, canonical internal pair ids like H:@142 for spot. The symbol on every surface — trade input, trade responses, positions, history — is this same canonical id, so always match on it; the readable pair is display-only, carried separately as display_symbol (with base_asset/quote_asset). Never construct a pair name yourself — major-asset spot tokens are Unit-wrapped (BTC spot is UBTC, shown as H:UBTC/USDC; H:BTC/USDC does not exist). Discover markets with screenHyperliquidMarkets(): its coin column is the canonical id and name is the readable pair.
  • Quantity is in the base asset (e.g. 0.01 for H:BTC), not USD. To size from a dollar budget, use round(budget / price, sz_decimals). sz_decimals is returned by screenHyperliquidMarkets(); quantities that round to zero are rejected.
  • Selling more than the current position opens a short. Perp positions carry signed quantities — negative means short.
  • Orders below $10 notional are rejected on the live account (no minimum on paper).
  • Fills are synchronous: venue.trade() blocks until the order fills or is rejected. Fill records include Hyperliquid-specific fields direction (e.g. "Open Short") and closed_pnl.

Account Structure

Unlike wallet-funded venues, Hyperliquid holds its own USDC:
  • cash on the account equals main-dex perps free collateral (withdrawable) — this is the buying power for new perp positions.
  • Spot and perp balances are separate. venue.balances(account="HYPERLIQUID") returns one row per balance class, tagged "perp" or "spot".
  • account_value, margin_used, and portfolio_value include equity held on HIP-3 builder-deployed perp dexs (markets with symbols like H:xyz:AAPL). Each HIP-3 dex holds its own USDC collateral; its perp balance rows carry an extra dex key with the dex name.
  • Perp positions carry additional fields: leverage, leverage_type (cross/isolated), liq_price, and margin_used.

Paper Trading

HYPERLIQUID_PAPER is a simulated Hyperliquid account with virtual USDC. Order calls have the same shape as live — pass account="HYPERLIQUID_PAPER" — so strategy code validated on paper runs unchanged against the live account.
  • No setup. The paper account is provisioned automatically on first use (or with one click from the portfolio page). No wallet, bridging, deposits, or transfers are ever needed.
  • Pre-funded balances. Every USDC bucket — perp, spot, and each HIP-3 dex — is pre-funded with $10M virtual USDC. HIP-3 buckets are seeded on first trade, so HIP-3 symbols (H:xyz:AAPL) trade immediately without moving collateral.
  • Realistic fills. Market orders are simulated against the live Hyperliquid L2 order book: the fill price is the volume-weighted average of consumed book levels within the slippage limit (slippage_bps, default 50). Real taker fees (4.5 bps) are charged on every fill. Orders that cannot fill within the slippage limit are rejected with NO_LIQUIDITY.
  • Full perp mechanics. Shorts, cross leverage (venue.set_leverage()), real hourly funding rates, and cross-margin liquidations are all simulated. Spot is long-only.
Differences vs live:

Connecting and Funding

Paper: no setup — HYPERLIQUID_PAPER is provisioned automatically on first use. Live:
  1. Connect Hyperliquid from the portfolio page.
  2. Fund your Arbitrum wallet (WALLET_ARB) with USDC.
  3. Bridge USDC from WALLET_ARB to Hyperliquid from the portfolio page. Moving USDC between spot and perp balances is also done from the UI.

Usage

In strategy agents, use strategy.execute(symbol, target_qty) instead — see Strategies.

Data Functions

All functions read Hyperliquid’s public API; positions and fills are public on-chain data for any address, no authentication needed. Full parameter and schema documentation: Hyperliquid Data.

Notes

  • Order sizes are rounded to the market’s sz_decimals; very small quantities may round to zero and be rejected.
  • Funding accrues hourly on perp positions; funding_since_open on a position shows cumulative funding paid (negative = received).
  • Daily OHLCV bars are aligned to UTC midnight, which appears as 19:00/20:00 New York time in ts_recv.

Related