1/5
Before diving into the code of Uniswap V2, let's walk through the different smart contracts that are involved in adding liquidity. We'll use the example of adding liquidity to the DAI/WETH pool. 1. The user will call the `addLiquidity` function of the router contract. 2. The router contract will determine if the DAI/WETH pool exists. 3. If the DAI/WETH pair contract does not exist, the factory contract will deploy the pair contract using the `createPair` function. 4. The router contract will then transfer DAI and WETH from the user to the pair contract. 5. The router contract will call the `mint` function of the pair contract. 6. The pair contract will determine how many liquidity provider (LP) tokens to mint based on the amount of DAI and WETH that was deposited. The pair contract will then return the LP tokens to the user.
A visual overview of Uniswap V2's add liquidity process. This lesson covers the steps that are taken when an individual provides liquidity to a Uniswap trading pool. The lesson covers how the router, factory, and pair contracts interact during the add liquidity process and explains how the router contract transfers tokens directly to the pair contract before a mint function is called on the pair contract.
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