1/5
### Exercise 4: Removing Liquidity and Transferring Tokens In this exercise, we will be covering how to remove all liquidity from a position. To transfer tokens out, we must first call the function `decreaseLiquidity` and then call the function `collect`. Both of these functions are inside of the `INonfungiblePositionManager`. The parameters for the `collect` function are: ```javascript tokenId recipient amount0Max amount1Max ``` In this exercise, a position is minted and the `tokenId` is assigned to a variable of the same name. The liquidity for this position is stored inside a struct called `position`. To remove the liquidity and transfer the tokens out, we need to call the function `decreaseLiquidity` on the `INonfungiblePositionManager` and then call the function `collect` on the position manager.
A comprehensive guide to removing liquidity from a position using Uniswap V3. The lesson covers how to use the `decreaseLiquidity` and `collect` functions to remove all liquidity (including fees) from a position.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Concentrated liquidity and derive its equations
Uniswap V3 math
How to calculate the spot price of tokens
Single and multi position swapping
Factory contract architecture
How to calculate liquidity requirements
Uniswap V3 fee algorithm
Flash loans
TWAP price oracle
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,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 May 15, 2025
DeFi Developer
Uniswap V3Duration: 3min
Duration: 35min
Duration: 25min
Duration: 22min
Duration: 1h 43min
Duration: 11min
Duration: 1h 03min
Duration: 12min
Duration: 51min
Duration: 41min
Duration: 10min
Duration: 7min
Course Overview
About the course
Concentrated liquidity and derive its equations
Uniswap V3 math
How to calculate the spot price of tokens
Single and multi position swapping
Factory contract architecture
How to calculate liquidity requirements
Uniswap V3 fee algorithm
Flash loans
TWAP price oracle
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,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 May 15, 2025