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
A Hyperliquid session is allocated a slice of the wallet’s USDC collateral, just like a spot agent is allocated a slice of a token. Multiple Hyperliquid agents can run on one wallet, each drawing from the unallocated remainder. Because the account nets all positions, agents on the same wallet share liquidation risk — size and monitor positions accordingly. A few quirks to be aware of:- You allocate a portion of the wallet’s available Hyperliquid USDC to the session (not the whole wallet). The
minimumAmountstill ensures anyone running the agent allocates at least that amount. - Your agent should use the below methods to pull live balances/positions directly from Hyperliquid for time-sensitive logic.
agent.portfoliocaptures perp exposures inagent.portfolio.positionsat execution start, but these methods read live from the clearinghouse and reflect the latest state.- 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.
- 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.coin(string): Asset identifier. 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.idempotencyKey(string, optional): Durable retry key for auto-mode orders. SDKs generate one automatically; provide a stable key only when retrying the same logical order after a process restart.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).
idempotencyKey within the current agent run. Duplicate active or already-submitted attempts are rejected; only failures before any external side effect can retry under the same key.
Response:
success(boolean): Whether the operation succeededdata(object): Order information (on success)orderId(string): Order IDcoin(string): Asset identifierside(string): “buy” or “sell”price(number): Order pricesize(number): Order sizefilled(number): Filled amountstatus(string): Order statusmarket(string): “perp” or “spot”clientOrderId(string, optional): Client order ID (hex), when present
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 symbolfullName(string | null): Full token nametokenId(string): Hyperliquid token identifiertotal(string): Total balancehold(string): Amount on hold (in open orders)priceUsd(string): Current price per token in USDvalueUsd(string): Total USD value of the balancedecimals(number): Token decimals
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 positionscoin(string): Asset identifierside(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)
dex argument filters the response to one builder DEX, so positions(dex="xyz") is a subset of positions().
Order
Get order information by order ID.success(boolean): Whether the operation succeededdata(object): Order information (same shape asplaceOrderresponse)orderId(string): Order IDcoin(string): Asset identifierside(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.idempotencyKey(string, optional): Durable retry key for auto-mode cancels. SDKs generate one automatically; provide a stable key only when retrying the same logical cancel after a process restart.
data is then a suggestion envelope ({ suggested: true, suggestionId }). See Manual vs Auto Mode.
Example:
Open Orders
Get all open orders.success(boolean): Whether the operation succeededdata(array): Array of open orders (same shape asplaceOrderresponse —orderId,coin,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.orderId(string): Order IDcoin(string): Asset identifierside(string): “buy” or “sell”direction(string): Whether the fill opened or closed a positionprice(string): Fill pricesize(string): Fill sizefee(string): Trading fee paidtimestamp(number): Fill timestamp in millisecondsisCrossed(boolean):truefor cross margin,falsefor isolated
Transfer
Transfer between spot and perp accounts.amount(number): Amount to transfertoPerp(boolean):trueto transfer to perp account,falseto transfer to spotidempotencyKey(string, optional): Durable retry key for auto-mode transfers. SDKs generate one automatically; provide a stable key only when retrying the same logical transfer after a process restart.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).
data is then a suggestion envelope ({ suggested: true, suggestionId }). See Manual vs Auto Mode.
Example:
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: …” | Coin not found in available perps | Use a valid perp coin like "BTC", "ETH" |
| ”Unknown spot pair: . Available pairs: …” | Coin not found in available spot pairs | Use a valid spot pair like "BTC/USDC", "ETH/USDC" |
| ”Invalid coin format: “ | Invalid coin format | Ensure coin 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 coins use the format
"BTC/USDC", while perp coins 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 — How Hyperliquid collateral is allocated per session
- Suggestions — Control suggestion expiry for manual-mode order suggestions