Section 9 of 18

Build
+15 Lynx

Pool: Removing Liquidity (burn and collect)

Key takeaway: Removing liquidity from V3 is a two-phase exit. burn is mint with the sign flipped — it calls _modifyPosition with a negative liquidity delta, and instead of transferring the freed tokens it credits them (principal plus any settled fees) to position.tokensOwed. collect is the only function in the entire pool through which position funds leave: it clamps the requested amounts to what is actually owed, decrements first, transfers second. The split gives the protocol one auditable exit door and gives LPs a free primitive: burn(tickLower, tickUpper, 0) — the "poke" — forces fee settlement without touching liquidity.

What You Are Building

Two functions: burn, which un-does what mint did and accrues what you are owed, and collect, which pays it out. _modifyPosition and _updatePosition from section 8 are included as working code — burn's entire job is to call them with a negative sign and book the result.

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