0/5
### Exercise 3: Decreasing Liquidity for a Position In this lesson, we will learn how to decrease liquidity for a position. The position is created using a helper function called `mint`, which assigns a token ID. The objective is to decrease the liquidity, and the method to do so is at our discretion. We can get the current amount of liquidity for the position using the `getPosition` function, which stores it in a struct named `position`. This liquidity amount represents the maximum amount we can decrease. We can decrease any amount up to and including the current amount of liquidity. To decrease liquidity, we must call the `decreaseLiquidity` function on the `NonfungiblePositionManager`. If we need a refresher on the `decreaseLiquidity` function, we can find it in the `INonfungiblePositionManager` interface. The function signature and struct definitions are: ```javascript function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1); ``` ```javascript struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } ``` The struct `DecreaseLiquidityParams` shows the parameters that we need to pass to the `decreaseLiquidity` function.
A comprehensive guide to decreasing liquidity in a Uniswap V3 position using the nonfungible position manager. The lesson covers the basics of decreasing liquidity, including the helper function mint, the get position function, the decrease liquidity function, and the nonfungible position manager interface.
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