0/5
### Exercise 2 Solution To increase liquidity, we will call the function `increaseLiquidity` on the `Nonfungible Position Manager`. So in our code we will start with: ```javascript manager.increaseLiquidity ``` We need to pass in a struct, which is defined inside the interface `INonfungiblePositionManager` as `IncreaseLiquidityParams`. We will copy the struct and include it in our code as: ```javascript INonfungiblePositionManager.increaseLiquidityParams { tokenId, amount0Desired, amount1Desired, amount0Min, amount1Min, deadline } ``` For the `tokenId`, we'll pass in the token id that is provided. For the `amount0Desired`, we'll pass in the DAI balance from the contract, but for simplicity, we will use a number: ```javascript amount0Desired: 500 * 1e18, ``` For `amount1Desired` we can pass in: ```javascript amount1Desired: 1e18, ``` For both `amount0Min` and `amount1Min` we will put 0, and for the `deadline` we will put: ```javascript deadline: block.timestamp ``` This completes Exercise 2. We can execute this test with the command: ```bash forge test --fork-url $FORK_URL --match-path test/uniswap-v3/exercises/UniswapV3Liquidity.test.sol --match-test test_increaseLiquidity -vvv ``` This runs our test and shows the console log. The test passes, and we added approximately 499 DAI, and 0.12 ETH.
A comprehensive guide to increasing liquidity to an existing position. This lesson dives into the process of increasing liquidity, which involves calling the increase liquidity function of the NonFungiblePositionManager contract and passing in the relevant parameters such as tokenId, amount0Desired, amount1Desired, amount0Min, amount1Min, and deadline. The lesson also demonstrates how to execute this test in the terminal using the correct commands.
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