Section 13 of 16
Router: Removing Liquidity
Key takeaway: Uniswap V2's
removeLiquidityfollows the same transfer-first pattern asmint/burn: LP tokens are sent to the pair,burn(to)is called, and the pair reads its own LP balance to determine the redemption amount. The Router adds slippage protection (amountAMin/amountBMin), deadline enforcement, ETH unwrapping for the ETH variants, and a permit-based variant that combines EIP-2612 signature approval with removal in one transaction. A subtle detail: the pair returns(amount0, amount1)in canonical token order, so the Router must remap to the user'stokenA/tokenBorder before validating against the minimums.
What You Are Building
Removing liquidity is the reverse of adding it. The user sends LP tokens back to the pair, the pair burns them, and the underlying tokens are returned proportionally. But the Router does not just forward the call. It adds slippage protection, deadline enforcement, ETH unwrapping, and gasless approval via EIP-2612 permit. Each of these protections exists because without it, users lose funds in predictable ways.
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