Order Book Mechanics

dYdX uses a central limit order book (CLOB) model - matching orders directly between traders rather than routing through a pool. This means tighter spreads, deeper liquidity for large orders, and maker rebates for providing liquidity.

Order Book Architecture

Price-time priority Maker/taker fees Priority fee auctions

Order Book Visualization

The live order book shows all resting buy (bid) and sell (ask) orders. Depth is shown in BTC. Price improves as you go up the book.

Price (USD) Size (BTC) Total Side
Spread: $25 (0.04%) Mid: $62,125

Fee Calculator

Calculate your trading costs based on order size and fee tier.

Fee Breakdown
Notional Value$62,125
Fee Rate0.05%
Fee Amount$31.06
Priority Fee (est.)~$2.50
Total Cost$33.56
Break-even move needed to cover fees
0.054%
On 10x leveraged position: need price to move 0.54% just to break even

Order Types Deep Dive

Limit Order
Place at a specific price. Rests on book until filled or cancelled. You control the price.
OK Price certainty
OK Maker rebate
X No fill guarantee
X Price may move away
*
Market Order
Execute immediately at best available price. Fills against resting orders on book.
OK Instant fill
OK No price risk
X Taker fee (higher cost)
X Slippage possible
Stop Order
Triggers a market order when price crosses your threshold. Used for risk management.
OK Automatic risk cut
OK Hands-off management
X Slippage on trigger
X Market order fees
Post-Only Order
If it would fill immediately, cancel instead. Guarantees you pay maker fee if filled.
OK Never pays taker fee
OK Builds maker history
X May cancel unfilled
X No immediate execution

Priority Fee Auction System

How Priority Fees Work

When the order book has many resting orders, the matching engine uses priority fees to determine execution order among same-price orders. Higher priority fee = faster matching. This prevents spam and incentivizes efficient ordering.

Standard Priority
$0-$2.50. Included by default. Good for most orders.
Fast Lane
$2.50-$10. Processed before standard. For time-sensitive orders.
Express Lane
$10-$50. Nearly instant. HFT and arbitrageurs use this.
Auction Block
$50+. Reserved for special conditions. Rare.

Matching Engine: Price-Time Priority

1
Order Received

New order arrives. Validated (balance, position limits, margin). Placed in queue.

2
Match Price Selection

Best available price selected from opposite book side. Best bid meets best ask.

3
Priority Ordering

At same price, orders ranked by: (1) Priority fee (highest first), (2) Time (oldest first). FIFO within fee tier.

4
Fill Execution

Orders filled in priority order. Partial fills proceed down the queue. Mark price updated.

Example: 3 orders at same price $62,000
Order A
1 BTC
$5 priority
1st (high fee)
Order B
2 BTC
$1 priority
2nd (standard)
Order C
0.5 BTC
$1 priority
3rd (same fee, older)

Resting Orders & Time-in-Force

GTT (Good-Til-Time)
Rests until the specified timestamp. Most common for position entry.
Example: Place limit order that expires in 4 hours
GTT (Good-Til-Timeout)
Similar to GTT but measures in minutes/seconds from placement.
Example: Place order with 30-minute timeout
IOC (Immediate-Or-Cancel)
Fill whatever possible immediately, cancel the rest. No resting.
Example: Get partial fill, cancel remaining
FOK (Fill-Or-Kill)
Entire order fills completely or not at all. No partial fills.
Example: Must fill 10 BTC - if only 5 available, order cancelled
Resting orders cost nothing while waiting - no gas (StarkEx), no margin used beyond position requirement. Only when filled does the order consume gas and potentially add to position.

dYdX vs GMX: Order Book vs Pool Model

Feature
dYdX (Order Book)
GMX (Pool Model)
Price Discovery
Excellent (CLOB)
Good (TWAP oracle)
Large Order Impact
Low slippage
High slippage
Maker Rebates
Yes (-0.01% to -0.02%)
N/A (no makers)
Liquidity Source
Traders (CLOB)
GLP Pool
Funding Rate
Market-driven (tight)
Protocol-set (variable)
Execution Speed
~100ms (StarkEx)
Instant (on-chain)
Best For
Large orders, scalping, HFT
Retail, simpler UX, leverage farming