Section 4 of 18
Tick: Liquidity Bookkeeping at the Boundaries
Key takeaway: Each initialized tick stores
liquidityGross(how many positions reference it — decides when the tick can be deleted) andliquidityNet(signed liquidity change applied when price crosses it — added at a position's lower tick, subtracted at its upper). Fees use the "fee growth outside" trick: each tick storesfeeGrowthOutside, the fee growth on the other side of the tick relative to the current price, and flips its meaning (outside = global - outside) every crossing. From two such values,feeGrowthInside = global - below - above— an O(1) computation for any range, at any time, no loops. The subtractions intentionally underflow, so in 0.8 they live inuncheckedblocks; only differences of these accumulators are meaningful, never their absolute values.
What You Are Building
The Tick library: the bookkeeping that lives at every range boundary. Four functions — getFeeGrowthInside, update, cross, clear — over a provided Tick.Info struct. This section contains the hardest mental model in V3. Budget your focus for getFeeGrowthInside; everything else in the protocol leans on it.
Your Code
Requirements
Sign up free — keep reading + earn 15 Lynx
Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.
Sign up free to continueAlready have an account? Log in