Section 6 of 16
Pair: Removing Liquidity (burn)
Key takeaway: Uniswap V2's
burn()is the mirror ofmint(): liquidity providers transfer LP tokens to the pair contract, thenburn(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()andsync()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
Requirements
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 continueAlready have an account? Log in