In this lesson, we'll learn how to add liquidity to the Curve V1 pool. We'll need to call the addLiquidity function. To call this function, we'll navigate to the IStableSwap3Pool interface and copy the addLiquidity function. We'll then paste the function into our code. ```javascript add_liquidity(uint256[3] calldata coins, uint256 min_lp); ``` We'll need to pass in parameters for the function. We'll start by creating a uint256 array of size three with the balances of the coins to add liquidity. We'll call this array coins and set the first element to 1 million DAI. The other two elements will be zero, since we're only adding DAI. ```javascript uint256[3] memory coins = [uint256(1e6 * 1e18), uint256(0), uint256(0)]; ``` We'll also need to prepare a minimum LP (min_lp) parameter. This is the minimum amount of LP tokens we want to receive in return for the liquidity we provide. For simplicity, we'll set this value to one. ```javascript pool.add_liquidity(coins, 1); ``` Now we can call our function to add liquidity to the Curve V1 pool. In the terminal, we'll run the command: ```bash forge test --fork-url $FORK_URL --match-path test/curve-v1/exercises/CurveV1AddLiquidity.test.sol --vvv ``` This will run our test and show us any console logs that are printed.
In this lesson, we'll learn how to add liquidity to the Curve V1 pool.
We'll need to call the addLiquidity function. To call this function, we'll navigate to the IStableSwap3Pool interface and copy the addLiquidity function.
We'll then paste the function into our code.
We'll need to pass in parameters for the function. We'll start by creating a uint256 array of size three with the balances of the coins to add liquidity.
We'll call this array coins and set the first element to 1 million DAI. The other two elements will be zero, since we're only adding DAI.
We'll also need to prepare a minimum LP (min_lp) parameter. This is the minimum amount of LP tokens we want to receive in return for the liquidity we provide. For simplicity, we'll set this value to one.
Now we can call our function to add liquidity to the Curve V1 pool.
In the terminal, we'll run the command:
This will run our test and show us any console logs that are printed.
A practical Solidity lesson on adding liquidity to Curve Stableswap. The lesson covers how to call the addLiquidity function from the IStableSwap3Pool interface, prepare the coins array with appropriate balances, and set the minLp parameter to ensure successful liquidity provision.
Previous lesson
Previous
Next lesson
Next
Course Overview
About the course
AMM math for Curve Stableswap
How to calculate swap amount and liquidity
Curve Stableswap contracts
How to implement a swap function
How to implement the add and remove liquidity functions
How to quantify liquidity pools
How to control the flatness of the curve
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Last updated on August 11, 2025
Duration: 14min
Duration: 32min
Duration: 26min
Duration: 23min
Duration: 20min
Duration: 23min
Course Overview
About the course
AMM math for Curve Stableswap
How to calculate swap amount and liquidity
Curve Stableswap contracts
How to implement a swap function
How to implement the add and remove liquidity functions
How to quantify liquidity pools
How to control the flatness of the curve
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Last updated on August 11, 2025