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
Bit-Index Tree · Perpl
O(1) — always 3 words max
Sorted Tree · Others
O(log N) — 14 levels deep
↓ Traversal — SLOAD × 14
↑ Rebalancing — SSTORE × 14
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
—