0/5
### Exercise 2: Increasing Liquidity In this exercise, we will be increasing liquidity for a position. The position is created by calling a helper function, `mint`, which assigns a variable called `tokenID`. Our goal is to increase liquidity using this `tokenID`. The contract was initially given 3000 DAI and 3 WETH. Some of these tokens were used to mint a new position by calling the `mint` function. To get the remaining tokens in the contract, we can call `balanceOf` on ERC20. We need to use an amount of tokens that is less than or equal to the remaining tokens inside the contract to increase liquidity. To increase liquidity, we need to call the `increaseLiquidity` function on the non-fungible position manager. To find this function, you can navigate to `foundry`, `source`, `interfaces`, `uniswap-v3`, and open `INonfungiblePositionManager.sol`. Scrolling down, you will find the `increaseLiquidity` function. ```javascript function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1); ``` This function takes a single struct parameter. These parameters need to be passed in when we use this function. ```javascript struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } ```
A comprehensive guide to increasing liquidity in a Uniswap V3 position. This lesson covers the process of increasing liquidity for a specific token ID, including the use of the mint function to create a position, the role of the increase liquidity function, and how to call the increase liquidity function in a non-fungible position manager.
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