Section 4 of 18

Build
+15 Lynx

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) and liquidityNet (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 stores feeGrowthOutside, 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 in unchecked blocks; 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

Solution.sol
Solidity
Loading editor...

Requirements

Write your implementation, then click Run Tests. Tests execute on the server.

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 continue

Already have an account? Log in