Curve 3Pool
Overview
The Curve 3Pool, commonly known as the 3Pool, is an integral component of the Curve protocol, a decentralized finance (DeFi) platform distinguished for its plain pools, which pair two or more stablecoins. As a plain pool, the 3Pool specializes in stablecoin exchange, combining DAI, USDC, and USDT to create a balanced pool, ensuring efficient trading, swapping, and liquidity provision while reducing slippage and transaction costs.
Users can become Liquidity Providers (LPs) by supplying the associated stablecoins to the 3Pool. By doing so, they receive LP tokens that represent their share of the pool's liquidity. These LP tokens entitle users to a portion of the trading fees generated within the 3Pool, rewarding them for their contribution to the platform's liquidity.
The Nexera-Fi CurveFiAdapter_3pool interacts with and utilizes the following two integral components of 3Pool:
- StableSwap3Pool contract (the 3Pool)
- CurveTokenV2 contract (the Curve LP token associated with the 3Pool)
In the following sections, we'll provide an overview of these contracts and their methods that Nexera-Fi CurveFiAdapter_3pool interacts with.
Note: Curve develops its smart contracts in Vyper, a Python-based programming language. For convenience, we'll present the method interfaces in both Vyper and Solidity syntax.
Interactions with CurveFiAdapter_3pool
The CurveFiAdapter_3pool interacts with Curve's 3Pool by calling the methods presented in the diagram below. Each method serves a specific purpose within the Adapter, enabling strategies to seamlessly integrate deposits, withdrawals, and swaps of the associated stablecoins in the 3Pool.
StableSwap3Pool
The StableSwap3Pool is the contract that implements Curve's AMM stablecoin plain pool of DAI, USDC and USDT, commonly known as 3Pool or Tri-Pool. Through its interface, users can deposit, withdraw and exchange between the supported stablecoins.
In the context of the Nexera-Fi CurveFiAdapter_3pool, these six methods come into play:
coins
: Retrieves the addresses of the stablecoins (DAI, USDC, USDT) in the pool.add_liquidity
: Deposits stablecoins to the pool and mints the associated amount of LP tokens in return.remove_liquidity_one_coin
: Withdraws a single specific stablecoin from the pool.remove_liquidity
: Withdraws stablecoins from the pool.remove_liquidity_imbalance
: Withdraws stablecoins from the pool in an imbalanced amount.exchange
: Performs an exchange between two stablecoins of the pool.
Methods
coins
Retrieves the address of the stablecoin specified by its index (0 for DAI, 1 for USDC, and 2 for USDT).
Vyper syntax:
Solidity syntax:
This method is invoked by the following CurveFiAdapter_3pool function:
The coins
method is invoked within the initialize function to fetch the addresses of the stablecoins in the 3Pool and store them in the coins array of the storage layout.
add_liquidity
Adds liquidity to the pool by depositing stablecoins, and mints the associated amount of LP tokens in return.
Vyper syntax:
Solidity syntax:
This method is invoked by the following CurveFiAdapter_3pool function:
The add_liquidity
method is called within the CurveFiAdapter_3pool's _deposit
function, using the amounts
and min_mint_amount
arguments from the out
and expectedIn
input arguments, respectively.
remove_liquidity_one_coin
Withdraws a single stablecoin from the pool. Returns the amount of coin i
received.
Vyper syntax:
Solidity syntax:
This method is invoked by the following CurveFiAdapter_3pool function:
This function triggers the remove_liquidity_one_coin
method on the StableSwap3Pool contract with arguments as defined in the out
and expectedIn
input arguments.
It is executed in the context of the Adapter's _withdraw
function when the expectedIn
input argument defines only a single token composition.
remove_liquidity
Withdraws stablecoins (up to N_COINS==3
) from the pool.
Vyper syntax:
Solidity syntax:
This method is invoked by the following CurveFiAdapter_3pool function:
This function triggers the remove_liquidity
method on the StableSwap3Pool contract with arguments as defined in the out
and expectedIn
input arguments.
It is executed in the context of the Adapter's _withdraw
function when the expectedIn
input argument defines more (up to N_COINS == 3
) than a single token composition.
remove_liquidity_imbalance
Reduces liquidity in the pool by withdrawing stablecoins (up to N_COINS==3
) in an imbalanced amount.
Vyper syntax:
Solidity syntax:
This method is invoked by the following CurveFiAdapter_3pool function:
This function triggers the remove_liquidity_imbalance
method on the StableSwap3Pool contract with arguments as defined in the out
and expectedIn
input arguments.
It is executed in the context of the Adapter's _withdraw
function when the imbalance
property defined in
WithdrawExtraData
is set to true
.
exchange
Performs an exchange between two stablecoins (i
& j
) against the pool.
Vyper syntax:
Solidity syntax:
This method is invoked by the following CurveFiAdapter_3pool function:
The exchange
method is called within the CurveFiAdapter_3pool's _swap
function, with arguments as defined in the out
and expectedIn
input arguments, respectively.
CurveTokenV2
The CurveTokenV2 contract is the LP token associated with the 3Pool within the Curve protocol. It plays a crucial role in incentivizing and rewarding liquidity providers.
LP Token Minting
LP tokens are minted and allocated to the Adapter when liquidity is added to the 3Pool via the _deposit function.
This allocation takes place when the add_liquidity
method of the StableSwap3pool is invoked in the context of the Adapter's _deposit
function.
LP Token Burning
When liquidity is withdrawn from the 3Pool via the _withdraw function, the associated amount of LP tokens is burnt. This takes place when the following methods of StableSwap3pool:
are respectively invoked in the context of the Adapter's _withdraw
function.
Please note: For detailed information about Curve protocol, consult the official Curve documentation.