Section 13 of 16

Build
+15 Lynx

Router: Removing Liquidity

Key takeaway: Uniswap V2's removeLiquidity follows the same transfer-first pattern as mint/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's tokenA/tokenB order 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

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