2/5
## Remove Liquidity We're going to look at how to remove liquidity from a Uniswap V2 pair contract. In Uniswap V2, when we add liquidity, we are essentially minting pool shares which are represented by an ERC20 contract. To remove liquidity, we will need to call the `removeLiquidity` function on the Uniswap V2 Router contract. For example, we will remove liquidity from the DAI/WETH pair contract. When we call `removeLiquidity`, the router will first call `transferFrom` to move our pool shares from our wallet to the pair contract. Before we can call `removeLiquidity`, we need to approve the Router contract to spend our pool shares. After transferring the pool shares to the pair contract, the router will call the `burn` function on the pair contract which will burn the pool shares we provided. This will then transfer WETH and DAI back to us. ## Diagram ```mermaid graph LR A[User] --> B{Router} B --> C[DAI/WETH] A --> C B --> D{Burn} D --> C ```
A comprehensive guide to removing liquidity from a Uniswap V2 pair contract. The lesson covers the steps involved in removing liquidity from a pair contract, including calling the removeLiquidity function, transferring pool shares back to the pair contract, and burning the shares to receive the underlying tokens back.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
How to use Uniswap v2 dex and contracts
Interacting with the Uniswap v2 router and factory
How to create Uniswap v2 liquidity pools
How to add liquidity to Uniswap v2 pools
Swaps, flash swaps, flash swap arbitrage, and time-weighted average price (TWAP)
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on October 9, 2024
Solidity Developer
Uniswap V2Duration: 14min
Duration: 1h 20min
Duration: 10min
Duration: 54min
Duration: 25min
Duration: 26min
Duration: 1h 03min
Duration: 59min
Course Overview
About the course
How to use Uniswap v2 dex and contracts
Interacting with the Uniswap v2 router and factory
How to create Uniswap v2 liquidity pools
How to add liquidity to Uniswap v2 pools
Swaps, flash swaps, flash swap arbitrage, and time-weighted average price (TWAP)
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on October 9, 2024
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar