1/5
When we remove liquidity from a constant product AMM, we said that the price after removing liquidity must be equal to the price before removing liquidity. We want to figure out the amount of token X and the amount of token Y to remove so that the price remains the same. The math to find out the amount of token X and the amount of token Y to remove so that the price remains the same is exactly the same math as the math for adding liquidity. When we add liquidity, we said that the price after adding liquidity must be equal to the price before. And this was expressed using this equation: ``` (y0 + dy) / (x0 + dx) = y0 / x0 ``` To figure out what DX and DY are when we're removing liquidity, we consider when DY and DX are both negative and do the same math. In other words, the ratio of amount of tokens to remove must be equal to the spot price before removing. ``` dy / dx = y0 / x0 ```
A technical guide to removing liquidity from a Constant Product AMM - The lesson covers how removing liquidity from a Constant Product AMM can be represented mathematically, and how to apply the formula to determine the amounts of tokens to be removed in order to maintain the initial price.
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