Skip to main content
agent.hyperliquid.orders.create(order, options?) takes the order shape every venue shares, the one Ask Circuit reviews use: { kind: "perpOpen", asset, side: "long" | "short", amount, leverage?, marginMode? }, { kind: "perpReduce", asset, expectedSide?, amount }, { kind: "spotBuy", asset, amount } or { kind: "spotSell", asset, amount }, each with optional execution and message. asset names the market as its allocation holding does. amount is { size } in base units or { value }, the order’s notional in the market’s quote asset, never margin; perpReduce and spotSell sizes and spotBuy values may be "max". leverage (1 to the market’s maximum) first sets the market’s account-wide leverage as its own operation, with marginMode "cross" or "isolated"; omit marginMode for the mode the market requires, isolated on markets Hyperliquid lists as isolated-only, such as HIP-3 markets like xyz:TSLA, and cross elsewhere. Omit execution for a market order within 1% of the mid, or pass { kind: "market", slippage }, { kind: "limit", price, timeInForce: "ioc" | "gtc" | "alo" }, or on perpOpen and perpReduce { kind: "takeProfit" | "stopLoss", triggerPrice } or { kind: "takeProfitLimit" | "stopLossLimit", triggerPrice, price }. "ioc" fills what crosses now and cancels the rest, "gtc" rests until filled or canceled and "alo" rests as maker only. A perpReduce pinning expectedSide fails against an opposite live position; omit it to reduce either side. perpReduce and "max" measure the session’s own holding, never the account: a reduce is a plain opposite order capped at the session’s position, and only trigger orders on perpReduce are reduce-only. The engine reads the mid and sizes the order; the optional second argument takes a once name. Results are the venue order every venue returns: orderId (here the client order ID Circuit assigns before sending, which cancel takes), asset, side, size, type, triggerPrice, reduceOnly, limitPrice, filled, averageFillPrice and state (open, filled or canceled); operations.retrieve and operations.list report their current values. limitPrice is the worst price the order accepts; averageFillPrice is the size-weighted average price of the fills Circuit recorded for the order, before fees, to 18 decimals truncated toward zero, never rounded to a price tick; it is null when nothing filled or the recorded fills do not yet account for filled, and its SDK type is optional, so treat a missing value as null. Paper and live accounts derive it from the same recorded fills. Circuit keeps observing a resting order, attributes later fills to the placing operation and session, and updates filled and averageFillPrice together. Orders never automatically resubmit. A market or limit perpOpen may carry takeProfit and stopLoss, each { triggerPrice, price? }; the same fields work on Hyperliquid and Lighter. Circuit sends the entry and its exits as one venue order. Each exit is a reduce-only take profit or stop loss for the entry’s size: at market within 10% of the mark, or a limit at price when given. A long’s take profit must trigger above the entry price (the limit price, or the mid for a market entry) and its stop loss below; a short’s the reverse. Exits are open orders from placement, listed by listOpen() with reduceOnly: true entryOperationId set to the entry’s operation and entryOrderId set to the entry’s order id while that entry still rests, and each can be canceled on its own. A market entry’s exits take its fill; a resting entry’s exits activate only once it fills completely. Canceling a partly filled entry cancels its exits and leaves the filled part unprotected, so manage an unfilled entry by reading it, canceling it, and placing a new entry with new exits. When one exit fills, the venue cancels the other. One venue exception: if Hyperliquid cancels a partly filled resting entry for insufficient margin, it places the exits at the entry’s full size. Trigger orders wait until the mark price crosses triggerPrice. Take-profit and stop-loss orders then execute at market, and the venue accepts fills within 10% of the mark; take-profit-limit and stop-loss-limit orders then rest as a limit order at price. Direction follows the order’s side: a sell’s take profit sits above the mark and its stop loss below, a buy’s the reverse, so a buy stop loss on perpOpen enters a breakout. Preparation rejects a trigger that would fire immediately. Results and listOpen() rows carry type and triggerPrice, which is null for limit orders; the order stays open until it fills or is canceled. Engine preparation rounds prices to the precision the venue allows: buys round down, sells round up, tightening the requested limit. Sizes round down to the market’s sizeStep; a size that rounds to zero fails preparation. Preparation rejects a limit order whose rounded value is below the market’s minimumNotional in quote units with BELOW_MINIMUM, before anything is sent, valuing a buy at the lower of its limit and the best ask and a sell at the higher of its limit and the best bid, where it would trade. Closes and reduce-only orders get no exemption, matching Hyperliquid, except an order that closes the whole perp position, which Circuit sends reduce-only, or sells the whole spot balance rounded to the market’s sizeStep; Hyperliquid accepts those at any value. Take-profit and stop-loss orders keep the venue’s own rule. Perps use catalog coins such as BTC or DEX-prefixed symbols. Spot uses catalog coins such as @107 or PURR/USDC; buys spend quote tokens, sells spend base tokens. Outcome markets (HIP-4) trade through spotBuy and spotSell with the #<encoding> coin from hyperliquid.outcomes.list(), whose rows name each outcome, its side (0 or 1), sideName, name, description, question and current mid; shares buy and sell in whole units for USDC, settle to between 0 and 1 USDC each, and carry no Circuit-side minimum order value. Circuit charges no builder fee. HyperCore starting assets require an existing account. Orders, outgoing transfers and HyperCore-source swaps require unified mode, which Circuit enables on every wallet; incoming funding remains available. The engine rechecks precision and mode; the venue atomically enforces balances and margin. Use data.markets and data.assets for perp identities, volume, open interest and each market’s order rules: minimumNotional, minimumSize, sizeStep, priceTick, maximumLeverage and marginRule, the values preparation enforces. Main perps use dex main and bare symbols; builder-DEX markets retain their prefix and dex. hyperliquid.spotMarkets.list() returns live spot coins and their base/quote indices; their order rules are on data.markets rows. Pass catalog identities unchanged. Size from session collateral and the kind: "perp" rows of allocation.holdings, not whole-account balances. Close with { kind: "perpReduce", amount: { size: "max" } }. hyperliquid.orders.listOpen() returns the session’s resting orders from Circuit’s order record, refreshed about once a minute; hyperliquid.orders.cancel({ orderId }) cancels one the session placed and completes with the order’s state if it already closed. A perp holding publishes priceUsd, entryPriceUsd, valueUsd and unrealizedPnlUsd in USD, and adds collateralAsset, collateralSymbol, marginMode, marginUsedInCollateralHolding, liquidationPrice, returnOnEquity and cumFundingSinceOpenCollateral in collateral units; margin stays inside the session’s collateral token holding, so equity is that holding’s valueUsd plus each perp’s unrealizedPnlUsd, and new orders spend from its availableQuantity, which leaves out that margin and open losses; an unknown price or entry basis remains null. Never substitute zero or a live mark for missing basis. Allocation guides sizing; live venue facts authorize execution. Human-reviewed account operations own their execution options. hyperliquid.account.update(account) changes the account: { kind: "isolatedMargin", asset, change: "add" | "remove", amountUsdc } moves isolated margin on an open isolated position of a USDC-margined market, and strict-isolated markets never release margin; { kind: "staking", change: "deposit" | "withdraw", amount } moves HYPE between HyperCore spot and staking, a withdrawal reaching spot after Hyperliquid’s 7-day queue; { kind: "delegation", change: "delegate" | "undelegate", validator, amount } moves staked HYPE; { kind: "vault", vault, change: "deposit" | "withdraw", amountUsdc } moves USDC into or out of a vault such as HLP, subject to its lockup; owner reviews alone may also schedule Hyperliquid’s cancel of every resting order on the account, which agent sessions cannot, as they cannot cancel "all". Each is its own reviewed operation, never part of an order, that completes once Hyperliquid records the action, with any HYPE or USDC it moved; paper accounts apply leverage and isolatedMargin, each isolated position holding its own margin and liquidating alone, and reject the rest. hyperliquid.staking.retrieve() returns the wallet’s staking (delegated, undelegated and pendingWithdrawal HYPE) and vaults (vault, equityUsdc and lockedUntil per vault); they are not session holdings.