Section 6 of 16

Build
+15 Lynx

Pair: Removing Liquidity (burn)

Key takeaway: Uniswap V2's burn() is the mirror of mint(): liquidity providers transfer LP tokens to the pair contract, then burn(to) reads the pair's own LP balance to determine the redemption amount. The function reads actual token balances rather than stored reserves, which absorbs donated tokens into LP redemptions. skim() and sync() exist as donation-handling escape hatches; skim() sweeps the surplus to a target, sync() resyncs stored reserves up to the new actual balance.

What You Are Building

The burn() function is the reverse of mint(). A liquidity provider sends their LP tokens back to the pair contract, then calls burn(). The function calculates how much of each token the LP tokens represent, destroys the LP tokens, and transfers the proportional share of both tokens to the recipient.

If mint() is how value enters the pool, burn() is how it leaves. The two functions share the same interaction pattern and the same accounting guardrails, but burn() has its own design subtleties worth understanding in detail.

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