Skip to main content

Documentation Index

Fetch the complete documentation index at: https://hypernode-docs.polynode.dev/llms.txt

Use this file to discover all available pages before exploring further.

Complete reference for HyperLiquid’s order book mechanics, covering order structure, all supported order types, trigger orders (TP/SL), order relationships, and every known cancel and rejection reason.

Order Types

HyperLiquid supports the following order types:
Order TypeDescription
LimitStandard limit order at a specified price
MarketExecutes immediately at the best available price
StopMarketTriggers a market order when the trigger price is hit
StopLimitTriggers a limit order when the trigger price is hit
TakeProfitLimitTriggers a limit order at take-profit price
Two additional internal order types exist: CloseForVaultWithdrawal (used when vaults process withdrawals) and SpotDustConversion (converts small residual spot balances).

Time-in-Force

Every order carries a time-in-force (TIF) setting that determines its lifecycle:
TIFNameBehavior
GtcGood Till CancelRests on the book until filled or cancelled
IocImmediate or CancelFills what it can immediately, cancels the rest
AloAdd Liquidity OnlyPost-only. Rejected if it would cross the spread and take liquidity
FrontendMarketFrontend MarketMarket order variant used by the frontend UI

BookOrder Structure

Each resting order on the book contains:
BookOrder {
  timestamp       — order creation time
  sz              — size (quantity)
  reduce_only     — reduce-only flag
  relationships   — parent/sibling/child order links
  cloid           — client order ID
  builder         — builder attribution
  description     — order description
}
OrderCore holds the shared core fields (price, side, asset) that are common across all order types.

Trigger Orders (TP/SL)

Trigger orders sit in a separate untriggered_orders pool until their trigger condition is met.
TriggerOrder {
  triggerPx       — trigger price threshold
  isTrigger       — identifies this as a trigger order
  isPositionTpsl  — whether this is a TP/SL attached to a position
  origSz          — original size before any partial fills
  triggered       — whether the trigger has fired
}
When the mark price crosses triggerPx, the trigger fires and the order enters the active book as its underlying type (market or limit). Position-level TP/SL orders (isPositionTpsl: true) are tied to the position itself rather than being standalone orders. They automatically cancel if the position is closed by other means.

Order Relationships

Orders can be linked through parent, sibling, and child relationships via the relationships field on BookOrder.
RelationshipDescription
ParentThe originating order that spawned this one
SiblingLinked orders where filling one cancels the other (OCO)
ChildOrders spawned by a parent (e.g., TP/SL attached to a limit fill)

One-Cancels-Other (OCO)

Sibling relationships implement OCO behavior. When one sibling order fills, all other siblings are automatically cancelled with reason siblingFilledCanceled. A common pattern: a take-profit limit and a stop-loss market order are placed as siblings. Whichever triggers first cancels the other.

Cancel and Rejection Taxonomy

HyperLiquid distinguishes between cancellations (order was on the book and removed) and rejections (order never made it onto the book).

User-Initiated Cancellations

ReasonDescription
marginCanceledInsufficient margin to maintain the order
scheduledCancelA scheduled cancellation was triggered
internalCancelInternal system cancel

System-Enforced Cancellations

ReasonDescription
perpMaxPositionCanceledOrder would exceed maximum position size
vaultWithdrawalCanceledCancelled due to vault withdrawal processing
openInterestCapCanceledOpen interest cap for the asset was reached
selfTradeCanceledSelf-trade prevention triggered
reduceOnlyCanceledReduce-only constraint violated (position already closed or flipped)
siblingFilledCanceledA sibling order filled, triggering OCO cancellation
liquidatedCanceledThe position was liquidated, cancelling all related orders
outcomeSettledCanceledHIP-4 prediction market outcome settled

Order Rejections

ReasonDescription
tickRejectedPrice is not on a valid tick increment
minTradeNtlRejectedOrder is below the minimum notional value
perpMarginRejectedInsufficient margin to place the perp order
perpMaxPositionRejectedOrder would exceed the maximum position size
reduceOnlyRejectedReduce-only order is invalid (no position to reduce)
iocCancelRejectedIOC order could not be filled at all
badTriggerPxRejectedTrigger price is invalid for the current market state
marketOrderNoLiquidityRejectedNo liquidity available to fill the market order
positionIncreaseAtOpenInterestCapRejectedOI cap prevents position increase
positionFlipAtOpenInterestCapRejectedOI cap prevents position flip
tooAggressiveAtOpenInterestCapRejectedOrder too aggressive near OI cap
openInterestIncreaseRejectedGeneral OI increase rejected
insufficientSpotBalanceRejectedNot enough spot balance for the order
oracleRejectedOracle price check failed
outcomeSettledRejectedPrediction market outcome already settled

Order Book State

The exchange maintains order book state within each perp DEX:
perp_dexs[]:
  books                 — order books per asset
  funding_tracker       — funding rate tracking
  user_balances         — per-user balance state
  book_order_keys       — index of active orders
  untriggered_orders    — trigger orders waiting for price conditions

spot_books              — separate order books for spot trading
allowed_liquidators     — addresses authorized to liquidate
Each block produces execution data including:
OutputDescription
node_tradesExecuted trades
node_fillsFill events
node_raw_book_diffsRaw order book changes
node_order_statusesOrder status updates
These outputs are available through the streaming API for real-time order book reconstruction.

TWAP Engine

HyperLiquid includes a native TWAP (Time-Weighted Average Price) engine for executing large orders over time. TWAP is used both by users directly (twapOrder/twapCancel actions) and internally by the liquidation system.

TWAP State

TwapState:
  asset           — asset being traded
  isBuy           — direction
  params          — execution parameters
  slices          — individual execution slices

TwapSchedule:
  start_time      — execution start
  duration        — total duration (max 1,440 minutes / 24 hours)
  randomize       — add jitter to slice timing (reduces predictability)

Execution

Each TWAP order is split into time-weighted slices. The WindowUpdate tracks progress:
WindowUpdate:
  size_increment  — amount to execute in current window
Slices execute as regular limit or market orders. If a slice cannot fill within its window, it carries forward to the next window.

Constraints

ParameterValue
Maximum duration1,440 minutes (24 hours)
RandomizationOptional jitter on slice timing
Reduce-onlySupported
TWAP orders produce node_twap_statuses in each block’s execution data, and fills appear as UserTwapSliceFills in the indexer.
TWAP is also used by the BOLE lending system for liquidations, where large positions are unwound gradually to minimize market impact. See Lending and Liquidation for details.