0/5
The code for the Uniswap V2 protocol is split into two repos, V2 core and V2 periphery. V2 periphery contains the router contract, which we'll take a look at later. We'll use the router contract to add and remove liquidity, as well as swap tokens. The actual contract that handles liquidity and token swaps is in V2 core. We can open this repo and navigate to contracts, where we'll find the contract `Uniswap V2 Pair`. You might be wondering why Uniswap V2 is split into two repos rather than having a single contract for the AMM. One reason is that they have different responsibilities. The main purpose of the `Uniswap V2 Pair` contract is to manage token pairs and swap tokens. If we want to perform multiple swaps, we'll need another contract beyond the `Uniswap V2 Pair` contract, which is where the router contract comes in. It's useful for multi-hop swaps. Another reason we have a router contract is for utility. We can use the `Uniswap V2 Pair` contract to add and remove liquidity and swap tokens. However, this contract is not intended for direct user interaction. If we directly interacted with the `Uniswap V2 Pair` contract, we could make mistakes and lose tokens. The router contract automates function calls to the `Uniswap V2 Pair` contract, helping us swap tokens without making errors. These are some of the reasons why the Uniswap V2 protocol is split into two repos.
A thorough breakdown of the Uniswap V2 protocol - Learn how the Uniswap V2 protocol is split into two repos: 'v2-core' and 'v2-periphery'. This lesson dives into the responsibilities of the periphery, including the 'Uniswap V2 Router 02' contract, which handles swapping tokens and adding/removing liquidity.
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