Section 7 of 18

Build
+10 Lynx

Pool: State, Slot0, and Initialization

Key takeaway: UniswapV3Pool packs every value the swap hot path reads — price, tick, oracle indices, protocol fee, and the reentrancy flag — into a single storage slot called Slot0, so one SLOAD serves the whole swap preamble. The reentrancy lock lives inside that slot and is mandatory, not defensive decoration: V3 verifies payment with balance checks, and a reentrant call between "compute owed" and "check balance" would let one deposit satisfy two debts. initialize converts a starting sqrtPriceX96 into a tick via TickMath.getTickAtSqrtRatio, may run exactly once ('AI'), and is the only door into an otherwise-locked contract.

What You Are Building

Part 1 gave you the math libraries. Now you assemble the machine that uses them. This section builds the UniswapV3Pool skeleton: the immutable configuration, the packed Slot0 struct, fee-growth globals, the tick/bitmap/position mappings, the lock modifier, tick validation, raw balance reads, and initialize. Everything you write in sections 8 through 11 lives inside this contract.

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