Section 2 of 18

Build
+10 Lynx

The Coordinate System: Ticks and sqrtPriceX96

Key takeaway: V3 stores price as sqrtPriceX96 — the square root of price in Q64.96 fixed point — because swap math is linear in sqrt(P) (Δy = L * Δ(sqrt(P))), and it indexes price space with ticks, where tick i means price 1.0001^i. TickMath converts between the two with hardcoded magic constants (provided; you use it, you do not retype it). You implement the safety rails around the coordinate system: LiquidityMath.addDelta with V3's terse 'LS'/'LA' overflow checks inside an unchecked block, tickSpacingToMaxLiquidityPerTick which caps per-tick liquidity so the pool-wide uint128 can never overflow, and checkTicks with the 'TLU'/'TLM'/'TUM' range validation every mint and burn passes through.

What You Are Building

Before you can build pools, you need V3's coordinate system: how price is stored, how price space is indexed, and the invariants that keep both inside safe bounds. In this section the heavy artillery — TickMath, with its 20 magic constants — is provided in full. Your job is the surrounding safety layer: LiquidityMath.addDelta, tickSpacingToMaxLiquidityPerTick, and tick-range validation. Small functions, but every mint, burn, and swap in the rest of the module runs through them.

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 10 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