openfin-hyperliquid
Complete Hyperliquid playbook — perpetuals and spot trading, margin/leverage, TWAP, real-time WebSocket data, and historical candles. Use for any Hyperliquid task. Trading triggers: place perp/spot orders (Gtc/Ioc/Alo), market-like fills, take-profit/stop-loss grouping, modify or cancel orders, batch cancels, TWAP orders (place/track fills/terminate), change leverage (cross vs isolated), adjust isolated margin, transfer USDC between spot and perp accounts (usd_class_transfer), get the EVM deposit address to fund Hyperliquid. Data triggers: read account summary (perp margin, positions, liquidation price, unrealized PnL), spot balances, portfolio, open orders, historical orders, single order status, fills (latest or by time window), funding history, rate limits, market metas (perp + spot, szDecimals), perp-only metas, spot-only metas, mid prices for all coins, L2 orderbook per coin, spot token details, allDexsAssetCtxs snapshot (funding/OI/mark prices across assets). Real-time WebSocket: wss://api.hyperliquid.xyz/ws with channels allMids, allDexsAssetCtxs (backend manages a shared subscription — agent can subscribe/unsubscribe and read the cached snapshot), l2Book, trades, candle, orderUpdates, userFills, userFundings. Historical OHLCV candles via direct POST https://api.hyperliquid.xyz/info {type: 'candleSnapshot'} — supports 1m/3m/5m/15m/30m/1h/2h/4h/8h/12h/1d/3d/1w/1M intervals up to 5000 candles. Covers all routes under /agent/trading/* (market/metas|mids|perp-metas|spot-metas|l2-book|token|all-dexs-asset-ctxs, deposit-address, account, account/spot, portfolio, rate-limit, orders, orders/details, orders/history, orders/:oid/status, twap, twap/fills, twap/:id, fills, fills/by-time, funding, leverage, margin, transfer). Triggers on mentions of Hyperliquid, "HL", perp, perpetual, funding rate, TWAP, isolated margin, cross margin, "deposit to Hyperliquid", "HIP-3", "HLP", or "HL vault". Prerequisite: openfin-setup.
NPX Install
npx skill4agent add openfinance-tech/skills openfin-hyperliquidTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Hyperliquid Perps & Spot
Prerequisite
- User completed (API key + EVM wallet delegation).
openfin-setup - For trading: USDC in the user's wallet, then deposit USDC into the
Hyperliquid account via (send USDC to that deposit address; chain routing is handled automatically).
GET /agent/trading/deposit-address - For perp orders specifically: margin must be in the perp account, not
spot. Transfer with .
POST /agent/trading/transfer
Accounts & funding
- — Perpetual account summary. Returns
GET /agent/trading/account(accountValue, totalMarginUsed, totalNtlPos, totalRawUsd, withdrawable) and a list of open positions withmarginSummary,entryPx,positionValue,returnOnEquity,unrealizedPnl,liquidationPx, andleveragefor each asset.size - — Spot account summary. Returns a list of token balances with
GET /agent/trading/account/spotname, token ID, hold amount, total amount, and entry notional value per token held.coin - — Full portfolio view combining perp positions and spot balances in a single response (margin + equity + PnL + positions + token holdings with amounts and values).
GET /agent/trading/portfolio - — Current Hyperliquid API rate-limit status for the wallet. Returns cumulative volume traded, API calls used, and remaining allowed calls in the window.
GET /agent/trading/rate-limit - — Deposit address mapped to the authenticated wallet's Hyperliquid account. Send USDC to this address to fund the Hyperliquid account; chain routing to Hyperliquid is handled automatically.
GET /agent/trading/deposit-address - body
POST /agent/trading/transfer— Transfer USDC between the perp and spot accounts. Required before spot trading (funds must be in spot wallet to buy tokens) or before perp trading (funds in perp wallet).{amount, toPerp}= spot → perp;toPerp: true= perp → spot.false
Market data (REST)
- — Mid prices (midpoint between best bid and ask) for every listed asset. Returns a map of asset symbol → mid price string (e.g.
GET /agent/trading/market/mids).{"BTC": "70939.5", "ETH": "2500.0"} - (
GET /agent/trading/market/metas) — Market metadata and asset contexts: funding rates, open interest, mark/mid/oracle prices, impact prices, 24h base and notional volume, premium, previous day price. Pass?dex=for DEX-specific data.dex - — Perpetual contract metadata only. Returns
GET /agent/trading/market/perp-metasarray with each asset's name,universe(size precision),szDecimals,maxLeverage, andmarginTableIdflag. Use this to look up asset indices (isDelisted) andabefore placing orders — place-order body requires these.szDecimals - (
GET /agent/trading/market/spot-metas) — Spot market metadata and asset contexts. Returns?dex=(token pairs, names, indices, isCanonical) and context per pair (universe,prevDayPx,dayNtlVlm,dayBaseVlm,markPx,midPx,circulatingSupply,totalSupply).coin - — L2 orderbook for a coin (e.g.
GET /agent/trading/market/l2-book/:coin). Returns coin name, timestamp, and a two-level array of bids and asks, each withBTC(price),px(size), andsz(number of orders at that level).n - — Detailed spot token info by token ID. Returns name, maxSupply, totalSupply, circulatingSupply, szDecimals, weiDecimals, midPx, markPx, prevDayPx, deployer, deployTime, seededUsdc, futureEmissions.
GET /agent/trading/market/token/:tokenIdmust be the full hex hash from:tokenId(e.g.spot-metas), NOT a simple number.0xc1fb593aeffbeb02f85e0308e9956a90 - — Asset contexts across all DEXs on Hyperliquid: funding rate, open interest, mark/mid/ oracle prices, 24h volume, impact prices, premium, prev day price. Snapshot equivalent of the
GET /agent/trading/market/all-dexs-asset-ctxsWS channel.allDexsAssetCtxs
Historical candles (OHLCV)
POST https://api.hyperliquid.xyz/info
Content-Type: application/json
{
"type": "candleSnapshot",
"req": {
"coin": "BTC",
"interval": "1h", // 1m,3m,5m,15m,30m,1h,2h,4h,8h,12h,1d,3d,1w,1M
"startTime": 1706659200000, // ms
"endTime": 1706745600000 // ms, optional (defaults to now)
}
}"xyz:XYZ100"Market data (WebSocket)
wss://api.hyperliquid.xyz/ws{ "method": "subscribe", "subscription": { "type": "<channel>" } }- — funding rate, mark price, OI, 24h volume per asset
allDexsAssetCtxs - — real-time mid prices for every coin
allMids - (
l2Book) — orderbook updates{type, coin: "BTC"} - (
trades) — trade tape{type, coin} - (
candle) — streaming candles{type, coin, interval: "1m"} - /
orderUpdates/userFills— user-scoped; requires signinguserFundings
Backend-managed WS
wss://api.hyperliquid.xyz/ws- — start the shared backend subscription
subscribe_all_dexs_asset_ctxs - — stop it
unsubscribe_all_dexs_asset_ctxs - — read the latest cached snapshot
get_all_dexs_asset_ctxs - — is the backend's connection alive
get_ws_status
allDexsAssetCtxsuniverseGET /agent/trading/market/metas/market/metasDirect WS from the client
wss://api.hyperliquid.xyz/wsOrders
Placing orders
-
— Place one or more orders. Each order needs
POST /agent/trading/orders(asset index froma),perp-metas(true=buy),b(price as string),p(size as string),s(reduce only),r(order type object withtorlimit). Body:triggerjson{ "orders": [{ "coin": "BTC", "is_buy": true, "sz": 0.01, "limit_px": 65000, "order_type": { "limit": { "tif": "Gtc" } }, "reduce_only": false }], "grouping": "na" // "na" | "normalTpsl" | "positionTpsl" }(time-in-force):tif- — good-till-cancelled (resting limit)
"Gtc" - — immediate-or-cancel (market-ish; cross the book for a fill)
"Ioc" - — add-liquidity-only (post-only; rejects if would be taker)
"Alo"
Grouping:groups take-profit/stop-loss child orders with a primary;"normalTpsl"attaches them to an existing position. Fetch market metas first to get correct asset indices and szDecimals."positionTpsl"
Reading orders
- — All currently open orders (compact). Returns array with
GET /agent/trading/orders,coin(B/A),side,limitPx,sz(order ID),oid,timestampper order.orderType - — Same but with full details:
GET /agent/trading/orders/details(original size),origSz,triggerPx,triggerCondition(client order ID),cloidflag.reduceOnly - — Historical orders (filled, cancelled, rejected). Adds
GET /agent/trading/orders/history(e.g.statusMsg,"filled"),"cancelled",filledSz,avgFillPx.cloid - — Single order's current status (
GET /agent/trading/orders/:oid/status,open,filled),cancelled,filledSz, remaining size.avgFillPx
Cancel / modify
- body
DELETE /agent/trading/orders— Cancel one or more open orders.{cancels: [{a, o}]}= asset index (from market metas),a= order ID. Batch-cancellable.o - body
PUT /agent/trading/orders/:oid— Modify an existing open order by ID. Same order shape as place.{order: {...}}
TWAP (Time-Weighted Average Price)
- — Place a TWAP order that splits a large trade into smaller market-order slices over a specified duration to minimize price impact. Returns
POST /agent/trading/twapto track or terminate.twapId - — Get individual slice executions for all TWAPs. Returns fills with
GET /agent/trading/twap/fills,coin,side,fillPx,fillSz,feeUsdc, and the parenttimestamp.twapId - — Terminate an active TWAP. Stops further slices; already-filled slices remain settled.
DELETE /agent/trading/twap/:twapId
Leverage & margin
- body
POST /agent/trading/leverage— Set leverage + margin mode for an asset. Must be set BEFORE placing leveraged orders.{asset, isCross, leverage}= coin index,asset= cross margin (shared pool),isCross: true= isolated (per-position),false= max multiplier.leverage - body
POST /agent/trading/margin— Add or remove margin from an isolated-margin position. Positive{asset, isBuy, ntli}adds (lowers liquidation risk), negative removes (raises leverage). Only works on positions using isolated margin mode.ntli
Fills & funding
- (
GET /agent/trading/fills) — Trade fill history. Returns fills with?aggregateByTime=false,coin(B/A),side(fill price),px,sz,feeUsdc,timestamp,oid,cloid(taker/maker),crossedflag.liquidation - (
GET /agent/trading/fills/by-time) — Same fill data, filtered by time window (Unix ms).?startTime=<ms>&endTime=<ms>optional (defaults to now).endTime - — Funding payment history for perp positions. Returns payments with
GET /agent/trading/funding,coin,fundingRateamount (positive = received, negative = paid),usdc, and position size at the time of payment.timestamp
Order-sizing gotchas
- is in base asset (e.g. BTC, ETH), not USD. For BTC at $65k, 0.01 = $650 notional.
sz - ticks differ per asset — check
limit_pxforperp-metasand useszDecimals/formatHyperliquidPriceconventions.formatHyperliquidSize - Hyperliquid rejects prices too far from mid (price bands, ~5-10%). For aggressive fills cross the book but stay in-band.
Margin modes
- Cross margin: all positions share one margin pool. Default.
- Isolated margin: margin pinned per position via .
POST /margin
isCross: true/falsePOST /leverageDon't
- Don't use for "buy now" — use
GtcorIocwith cross-book price.Alo - Don't expect the WS cache to be populated instantly on server boot — the backend auto-subscribes on startup but first message can take a few seconds.
- Don't put raw USD amounts in . It's base-asset.
sz - Don't forget to USDC from spot to perp before placing perp orders — they're separate balances.
transfer
MCP note
hyperliquid_place_orderhyperliquid_cancel_orderhyperliquid_get_account_summaryhyperliquid_get_all_midshyperliquid_usd_class_transfer