Use the Hyperliquid integration to build agents that trade perpetual futures and spot markets. Common strategies include market making, momentum trading, and delta-neutral farming.Documentation Index
Fetch the complete documentation index at: https://docs.circuit.org/llms.txt
Use this file to discover all available pages before exploring further.
Configuration
To define USDC Perps as your agent’s starting asset, use the followingnetwork and address in the circuit.toml file.
minimumAmount for hypercore:perp / USDC is in Circuit raw units with 8 decimal places, matching Hyperliquid’s weiDecimals for USDC in spot metadata (not EVM USDC’s 6 decimals).
Asset Allocation Notes
Circuit restricts users from running multiple Hyperliquid agents per wallet. This enables your agent to safely manage margin requirements on open perpetual positions without potential interference from other agents. This also introduces a few quirks to be aware of.- For Hyperliquid agents, your entire wallet balance is available to the agent when you start a session.
- The
minimumAmountwill still ensure that anyone running the agent will at least have that amount. - Your agent should use the below methods to pull available balances/positions directly from Hyperliquid, as opposed to the
agent.currentPositionsproperty.- Balances:
agent.platforms.hyperliquid.balances() - Positions:
agent.platforms.hyperliquid.positions(dex?) - IMPORTANT: Be careful with your usage of these methods in loops (avoid entirely if possible), Hyperliquid will rate limit if too many requests are sent.
-
Note: Hyperliquid balances are not yet included in
agent.currentPositions. This will be added in a future release once Circuit’s Hyperliquid indexing is complete.
- Balances:
Units
When querying via Hyperliquid’s API (viaagent.platforms.hyperliquid), all values will be returned in their formatted value, as opposed to the rest of Circuit which returns values in their raw units (wei/lamports)
Place Order
If you are unfamiliar with placing orders via Hyperliquid’s API, please see these docs for information regarding tick/lot sizes, as well as decimals.symbol(string): Trading pair symbol. For perps:"BTC". For builder DEX perps:"xyz:GOLD","cash:GOLD", or"vntl:MAG7"(currentlyxyz,cash, andvntlare supported; unsupported builder DEX prefixes are rejected). For spot:"BTC/USDC".side(string): “buy” or “sell”size(number): Order sizeprice(number): Order price. For market orders, acts as slippage limit (maximum acceptable execution price). For limit orders, the limit price.market(string): “perp” or “spot”type(string, optional): “market”, “limit”, “stop”, “take_profit”triggerPrice(number, optional): Trigger price for stop/take-profit ordersreduceOnly(boolean, optional): Whether this is a reduce-only orderpostOnly(boolean, optional): Whether this is a post-only ordermessage(string, optional): Short human-readable message for this order, max 250 characters. Stored verbatim and rendered as the Activity-feed caption for this trade. When omitted, the caption is synthesized from recent agent logs.expiresAt(string | null, optional): ISO 8601 timestamp. In manual mode, the suggestion expires at this time. If omitted, no time-based expiry is set (suggestions are auto-cleared at eachrunstart).
success(boolean): Whether the operation succeededdata(object): Order information (on success)orderId(string): Order IDsymbol(string): Trading pair symbolside(string): “buy” or “sell”price(number): Order pricesize(number): Order sizefilled(number): Filled amountstatus(string): Order statusmarket(string): “perp” or “spot”
error(string | null): Error message (on failure)
Balances
Get account balances.success(boolean): Whether the operation succeededdata.perp(object): Perp account balanceaccountValue(string): Total account valuetotalMarginUsed(string): Total margin usedwithdrawable(string): Withdrawable amount
data.spot(array): Spot token balancescoin(string): Token symboltotal(string): Total balancehold(string): Amount on hold (in open orders)
error(string | null): Error message (on failure)
Positions
Get open positions. By default this returns positions across Hyperliquid’s main perp venue and any supported builder DEXes. Currently the supported builder DEXes arexyz, cash, and vntl. Pass dex to scope the response to a specific builder DEX.
dex(string, optional): Builder DEX name to filter positions for a specific venue, such as"xyz","cash", or"vntl". If omitted, positions are returned across the default venue and supported builder DEXes. Currently that supported builder DEX set is"xyz","cash", and"vntl", and unsupported builder DEX names are rejected.
success(boolean): Whether the operation succeededdata(array): Array of open positionssymbol(string): Trading pair symbolside(string): “long” or “short”size(string): Position sizeentryPrice(string): Average entry pricemarkPrice(string): Current mark priceliquidationPrice(string | null): Liquidation priceunrealizedPnl(string): Unrealized profit/lossleverage(string): Current leveragemarginUsed(string): Margin allocated to position
error(string | null): Error message (on failure)
Order
Get order information by order ID.success(boolean): Whether the operation succeededdata(object): Order information (same shape asplaceOrderresponse)orderId(string): Order IDsymbol(string): Trading pair symbolside(string): “buy” or “sell”price(number): Order pricesize(number): Order sizefilled(number): Filled amountstatus(string): Order statusmarket(string): “perp” or “spot”
error(string | null): Error message (on failure)
Delete Order
Cancel an order.Open Orders
Get all open orders.success(boolean): Whether the operation succeededdata(array): Array of open orders (same shape asplaceOrderresponse —orderId,symbol,side,price,size,filled,status,market)error(string | null): Error message (on failure)
Orders
Get historical orders.status: “open”, “filled”, “canceled”, “triggered”, “rejected”, “marginCanceled”, “liquidatedCanceled”orderType: “Market”, “Limit”, “Stop Market”, “Stop Limit”, “Take Profit Market”, “Take Profit Limit”timestamp: Order creation timestampstatusTimestamp: Status update timestamp
Order Fills
Get order fill history.price(string): Fill pricesize(string): Fill sizefee(string): Trading fee paid
Transfer
Transfer between spot and perp accounts.amount(number): Amount to transfertoPerp(boolean):trueto transfer to perp account,falseto transfer to spotexpiresAt(string | null, optional): ISO 8601 timestamp for suggestion expiry in manual mode.
Liquidations
Get liquidation events.startTime(number, optional): Unix timestamp in milliseconds to filter liquidations from
timestamp(number): Liquidation timestampliquidatedPositions(array): Liquidated positionstotalNotional(string): Total notional value liquidatedaccountValue(string): Account value at liquidationleverageType(string): “Cross” or “Isolated”txHash(string): Transaction hash
Midpoint Price
Get the current midpoint price for one or more Hyperliquid coins. The return shape mirrors the input shape: pass a single coin to get a single object, or pass an array to get an array (one entry per coin that has data). Prices are streamed from Hyperliquid’sallMids feed and written at most once per second per coin. The response includes an isStale flag that is true when the most recent tick is older than ~90 seconds.
coin(string | string[]): Coin ticker(s), e.g."BTC"or["BTC", "ETH"]. For spot pairs use the"BASE/QUOTE"format (e.g."HYPE/USDC"). For builder-DEX coins, pass just the base ticker (e.g."GOLD").dex(string, optional): Hyperliquid market suffix. Defaults to"perp"(main perp DEX). Use"spot"for spot or a builder-DEX name like"xyz","cash", or"vntl". Internally translated tohypercore:<dex>.
coin(string): The coin ticker that was matched.network(string): Full market identifier — alwayshypercore:<dex>(e.g."hypercore:perp").priceUsd(string): Midpoint price in USD as a decimal string (preserve precision).timestamp(string): ISO 8601 timestamp of the most recent midpoint tick.isStale(boolean):truewhen the latest tick is older than ~90 seconds.
coin is a single string and no row exists for the requested (coin, dex), success is false and error describes the miss. When coin is an array, missing coins are silently omitted from the response array.
Example:
Common Errors
Errors are returned in theerror field of the response. Common errors include:
| Error | Cause | Solution |
|---|---|---|
| ”Unsupported builder DEX: . Supported builder DEXes: xyz, cash, vntl” | Builder DEX prefix is not in the supported set | Use a supported builder DEX prefix (currently xyz, cash, or vntl) |
| “Unknown perp asset: . Available assets: …” | Symbol not found in available perps | Use a valid perp symbol like "BTC", "ETH" |
| ”Unknown spot pair: . Available pairs: …” | Symbol not found in available spot pairs | Use a valid spot pair like "BTC/USDC", "ETH/USDC" |
| ”Invalid coin format: “ | Invalid symbol format | Ensure symbol matches expected format (perps: “BTC”, spot: “BTC/USDC”) |
| ” order requires triggerPrice” | Stop or take_profit order missing triggerPrice | Provide triggerPrice parameter for stop/take_profit orders |
| ”Order not found” | Order ID doesn’t exist | Verify order ID is correct |
| ”Failed to place order” | Order submission failed | Check order parameters and account balance |
error field in the response for specific details.
Notes
- All balance and position amounts are strings to preserve precision.
- Market orders use
priceas a slippage limit (maximum acceptable execution price). - Transfer operations return void responses (no
dataon success). - Spot symbols use the format
"BTC/USDC", while perp symbols use just the base asset like"BTC". - Hyperliquid rate-limits aggressively. Avoid calling
balances()orpositions()in loops.
See Also
- Hyperliquid Agent Example — Full working trading agent
- Wallets & Asset Allocation — Why Hyperliquid agents get the full wallet balance
- Suggestions — Control suggestion expiry with
expiresAtin manual mode