Order Book Data Structure

Simulate insert and cancel operations side by side. Drag or play the gas scaling chart to see costs diverge as book depth grows.

Operation Simulator

choose a book depth, then simulate insert or cancel
sorted tree: ⌈log₂ 10 000⌉ = 14 levels
Bit-Index Tree  ·  Perpl O(1) — always 3 words max
Gas (data structure writes) 0gas
Sorted Tree  ·  Others O(log N) — 14 levels deep
↓ Traversal — SLOAD × 14
↑ Rebalancing — SSTORE × 14
Gas (data structure writes) 0gas

Gas Scaling

how insert cost grows with book depth
Depth: 10,000
Perpl — Bit-Index Tree
Sorted Tree (others)
Uniswap V2 swap (reference)
Perpl insert gas
~50,000
Sorted tree insert gas
Perpl is cheaper by