Configuration
To define USDC Perps as your agent’s starting asset, use the followingnetwork and address in the circuit.toml file.
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() - 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 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 orderexpiresAt(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.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 paidisMaker(boolean): True if maker, false if taker
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
Common Errors
Errors are returned in theerror field of the response. Common errors include:
| Error | Cause | Solution |
|---|---|---|
| ”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