hyperliquid

Trade perp futures, spot, and RWA on Hyperliquid DEX with up to asset max leverage. Use when placing perp or spot orders, setting TP/SL, or moving funds on Hyperliquid (e.g. long BTC 5x, sell ETH, deposit USDC, set stop).

By starchild-ai-agent · 8,599 installs

npx skills add starchild-ai-agent/official-skills --skill hyperliquid

Source repository · Upstream listing

Hyperliquid Trading Trade perpetual futures and spot tokens on Hyperliquid, a fully on chain decentralized exchange. Orders are signed using this agent's EVM wallet and submitted directly to the Hyperliquid L1. Prerequisites Before trading, the wallet policy must be active. Load the wallet policy skill and propose the standard wildcard policy (deny key export + allow ). This covers all Hyperliquid operations — USDC deposits, EIP 712 order signing, and withdrawals. Runtime Model: How to Call Hyperliquid (Read This First) This skill is script delivery . It registers no hl agent tools — calling hl deposit , hl order , or any other hl name as a tool will always fail with "not found in registry". That is by design, not a bug or a missing install. There are exactly two working lanes: Lane 1 — Read only queries ( exports.py ) Any wallet, not just your own. Every user scoped function takes an optional address . Omit it for the agent's own wallet; pass a 0x address to inspect a third party. This is what makes "analyse this wallet's Hyperliquid PnL" answerable — Hyperliquid is an off chain order book, so a DeBank style chain scan cannot see any of it. 32 functions, grouped: Group Functions Account hl account hl balances hl total balance hl user role hl user fees hl rate limit hl sub accounts hl referral hl extra agents PnL & history hl portfolio hl fills hl fills by time hl historical orders hl ledger hl funding payments hl twap fills hl vault equities Orders hl open orders hl open orders full hl order status Market hl market hl orderbook hl candles hl funding hl predicted funding hl meta hl meta ctxs hl spot meta hl spot meta ctxs hl perp dexs Staking hl staking hl staking delegations hl staking rewards Read only only — no writes on this lane. Answering "what is this wallet's PnL?" hl portfolio returns 8 windows — day , week , month , allTime and the perp equivalents — each with accountValueHistory and pnlHistory as [epoch ms, value] pairs. pnlHistory restarts at 0 at the start of each window, so read allTime for lifetime PnL. For a cost basis reconstruction, combine three sources: hl ledger (capital in/out — deposits, withdrawals, vault moves), hl fills by time (realized closedPnl per fill, 2000 max per call — page by passing the last fill's time as the next start ), and hl funding payments (funding paid/received). Check hl user role first: role "missing" means the address never traded here, which is not the same as "no positions". Lane 2 — Writes: orders, cancels, transfers, deposits ( client.py ) Every write goes through HyperliquidClient , which owns the EIP 712 signing pipeline. It is an async class — await every call. Prerequisite for Lane 2: the wallet policy must be active — load the wallet policy skill and propose the standard wildcard policy (deny key export + allow ). That covers deposits, EIP 712 order signing, and withdrawals. Naming note: the rest of this document refers to operations by their historical hl names (e.g. " hl deposit "). Those are labels for the operation , not callable tools — always reach them via Lane 1 or Lane 2 above. Available Tools Account & Market Info Tool What it does hl total balance Check how much you can trade with (use this for balance checks!) hl account Open positions and unrealized PnL hl balances Token holdings (USDC, HYPE, etc.) hl portfolio PnL and account value over time — day/week/month/allTime hl ledger Deposits, withdrawals, transfers — the capital in/out record hl fills by time Fills within a date range, for cost basis work hl market Get current prices for crypto or stocks hl meta ctxs Market wide scan: markPx, funding, OI, volume per asset hl orderbook Check order book depth and liquidity hl fills See recent trade fills and execution prices hl candles Get price charts (1m, 5m, 1h, 4h, 1d) hl funding Check funding rates for perps hl open orders See pending orders hl open orders full Pending orders with stop loss / take profit detail All of the above accept address="0x..." to inspect any wallet, not just the agent's own. Trading Tool What it does hl order Buy or sell perps (crypto/stocks) hl spot order Buy or sell spot tokens hl tpsl order Place stop loss or take profit orders hl leverage Set leverage (1x to asset max) hl cancel Cancel a specific order hl cancel all Cancel all open orders hl modify Change order price or size Funds Tool What it does hl deposit Add USDC from Arbitrum (min $5) hl withdraw Send USDC to Arbitrum (1 USDC fee, ~5 min) hl transfer usd Move USDC between spot/perp (rarely needed) Platform Tool What it does hl approve builder Approve Starchild builder fee collection (auto done on first order) hl builder status Check builder approval status and collected rewards Quick Start Just tell the agent what you want to trade it handles everything automatically. Examples: You don't need to: Understand account modes or fund transfers Check balances manually (agent does it) Calculate position sizes (agent does it) Verify fills (agent does it) Just say what you want, the agent handles the rest. Agent Behavior Guidelines 🤖 As the agent, you should ALWAYS do these automatically (never ask the user): 1. Check available funds Use hl total balance before EVERY trade to see total available margin 2. Detect asset type Recognize if user wants crypto (BTC, ETH, SOL) or stocks/RWA (NVIDIA→xyz:NVDA, TESLA→xyz:TSLA) 3. Set leverage Always call hl leverage before placing orders (unless user specifies not to) 4. Verify fills After placing ANY order, immediately call hl fills to check if it filled 5. Report results Tell user the outcome: filled price, size, and any PnL 6. Suggest risk management For leveraged positions, remind users about stop losses or offer to set them 🎯 User just says: "buy X" or "sell Y" or "long Z with $N" 🔧 You figure out: Current balance (hl total balance) Asset resolution (crypto vs RWA) Leverage settings (hl leverage) Order sizing (calculate from user's $ amount or size) Execution (hl order) Verification (hl fills) Final report to user 📊 Balance checking hierarchy: ✅ Use hl total balance shows ACTUAL available margin regardless of account mode ❌ Don't use hl account for balance may show $0 even if funds available ❌ Don't use hl balances for margin only shows spot tokens 🚀 Be proactive, not reactive: Don't wait for user to ask "did it fill?" check automatically Don't ask "should I check your balance?" just do it Don't explain account modes user doesn't care, just execute Tool Usage Examples Check Account State Returns marginSummary (accountValue, totalMarginUsed, withdrawable) and assetPositions array with each position's coin, szi (signed size), entryPx, unrealizedPnl, leverage. Important: Builder perps (xyz:NVDA, xyz:TSLA, etc.) have separate clearinghouses. Always check the correct dex when trading RWA/stock perps. Check Spot Balances Returns balances array with coin, hold, total for USDC and all spot tokens. Check Market Prices Side Parameter Convention (read this first) All order tools ( hl order , hl spot order , hl tpsl order , hl modify ) use the same side parameter. Use "buy" or "sell" — these are the documented values and should be your default. For safety, the tools also accept these aliases so a model guess doesn't reverse direction on a leveraged order: Buy family: "buy" , "B" , "bid" , "long" , "L" , 1 , true Sell family: "sell" , "S" , "A" , "ask" , "short" , 0 , false An unrecognized value will fail the call with a clear error — the tool never defaults to sell (or buy) when side is ambiguous. This is intentional: silently reversing direction on a leveraged position is the worst failure mode. Note: Hyperliquid's L1 wire protocol uses "B" and "A" internally, but the tool interface here is buy / sell . Stick to buy / sell in your calls and you will never be surprised. Place a Perp Limit Order Places a GTC limit buy for 0.01 BTC at $95,000. Place a Perp Market Order Omitting price submits an IoC order at mid price +/ 3% slippage. Parameter format behavior: Preferred: pass correct JSON types ( size as number, reduce only as boolean) Hyperliquid tools now include tolerant coercion for common LLM formatting mistakes: numeric strings like "0.01" → 0.01 boolean strings like "true"/"false" → true/false integer strings like "5" / "5.0" → 5 Invalid/empty/non finite values still fail with explicit validation errors Place a Post Only Order ALO (Add Liquidity Only) = post only. Rejected if it would immediately fill. Practical guardrail for bots: If your ALO price is too close to mid (often within ~0.1% on liquid pairs), Hyperliquid may reject it. For market making/grid bots, compute current mid first and skip or shift levels that sit inside your no cross buffer zone. Place a Stop Loss Order Automatically sells 0.01 BTC if the price drops to $90,000. Executes as market order when triggered. For a limit order when triggered (instead of market): Place a Take Profit Order Automatically sells 0.5 ETH if the price rises to $3,500. Executes as market order when triggered. Close a Perp Position Use reduce only=true to ensure it only closes, never opens a new position. Place a Spot Order Spot orders use the same interface — just specify the token name. Cancel an Order Get order id from hl open orders . Cancel All Orders Modify an Order Set Leverage Transfer USDC (rarely needed) Note: Usually not needed funds are automatically shared. Only use if you get an error saying you need to transfer. Withdraw USDC to Arbitrum Fee: 1 USDC deducted by Hyperliquid. Processing takes ~5 minutes. Deposit USDC from Arbitrum Sends USDC from the agent's Arbitrum wallet to the Hyperliquid bridge contract. Minimum deposit: 5 USDC. Requires USDC balance on Arbitrum. Get Candles Intervals: 1m , 5m , 15m , 1h , 4h , 1d . Lookback in hours. Check Funding Rates Get Recent Fills Coin vs RWA Resolution When a user asks to trade a ticker, you need to determine whether it's a native crypto perp (use plain name) or an RWA/stock perp (use xyz:TICKER prefix). Decision Workflow 1. Known crypto → use plain name: "BTC" , "ETH" , "SOL" , "DOGE" , "HYPE" , etc. 2. Known stock/commodity/forex → use xyz: prefix: "xyz:NVDA" , "xyz:TSLA" , "xyz:GOLD" , etc. 3. Unsure → resolve with tool calls: First try hl market(coin="X") — if it returns a price, it's a crypto perp If not found, try hl market(dex="xyz") to list all RWA markets and search the results Use whichever returns a match Common RWA Categories (all use xyz: prefix) Category Examples US Stocks xyz:NVDA , xyz:TSLA , xyz:AAPL , xyz:MSFT , xyz:AMZN , xyz:GOOG , xyz:META , xyz:TSM Commodities — Metals xyz:GOLD , xyz:SILVER , xyz:COPPER , xyz:PLATINUM , xyz:PALLADIUM , xyz:ALUMINIUM Commodities — Energy xyz:CL (WTI), xyz:BRENTOIL , xyz:NATGAS , xyz:TTF (EU Gas) Commodities — Agriculture xyz:CORN , xyz:WHEAT Commodities — Other xyz:URANIUM Indices xyz:SPY Forex xyz:EUR , xyz:GBP , xyz:JPY If a user says "buy NVDA" or "trade GOLD", use xyz:NVDA / xyz:GOLD . These are real world assets, not crypto. ⚠️ H