Kata 05

Apply Delta

Exchanges do not send the whole order book on every tick. They send deltas: small updates like “bid 2340.1 → size 8.4”. Your UI must turn each delta into the next book state.

applyDelta(book, delta) is the single function that does that. It uses your Kata 4 Side trees and returns a new book so the old one is never mutated — required for replay, debugging, and Kata 6 snapshot sync.

  • size: "0" removes that price level
  • Same price again overwrites size
  • Bids and asks stay independent
closedlive l2Book · last tick 0 deltas

applyDelta = one change. diffSnapshot = array of changes from two snapshots. applyDeltas(book, deltas) = apply that array.

Spread: — · bids 0 · asks 0

Bids

  • Waiting for book…

Asks

  • Waiting for book…

Delta log

  • Connecting to Hyperliquid l2Book…