Section 8 of 18

Build
+20 Lynx

Pool: Adding Liquidity (mint)

Key takeaway: mint is a thin shell around two private workhorses. _updatePosition does the bookkeeping — updates both boundary ticks, flips bitmap bits when a tick's liquidity appears or disappears, settles accumulated fees into the position via getFeeGrowthInside, and clears dead ticks. _modifyPosition does the economics — the current price sits below, inside, or above the range, and that alone decides whether the depositor owes token0, both tokens, or token1, with the pool's active liquidity updated only in the inside case. Payment is V3's signature move: compute what is owed first, call uniswapV3MintCallback on the sender, then verify the pool's balances actually grew ('M0'/'M1'). The pool never calls transferFrom.

What You Are Building

Three functions that together let anyone deposit liquidity into a tick range: _updatePosition (state bookkeeping), _modifyPosition (amount computation), and mint (the external entry point with the callback payment flow). burn in section 9 reuses the first two with a negated sign — write them well once and removal comes almost free.

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