CurveFiAdapter_tricrypto2
Extends: BaseAdapter
The CurveFiAdapter_tricrypto2
is designed to interact with the Curve.fi USDT/WBTC/ETH Pool.
This adapter enables users to harness the power of Curve.fi USDT/WBTC/ETH trading capabilities and integrate them into their financial strategies.
Structs
InitializeData
Defines the necessary data for initializing the Adapter.
Members
Name | Type | Description |
---|---|---|
pool | address | The address of the Curve.fi USDT/WBTC/ETH Pool |
Layout
Used to store crucial data for the Adapter's functionality in a specific storage slot.
Members
Name | Type | Description |
---|---|---|
pool | ICurveFi_tricrypto2 | The interface representing the Curve.fi USDT/WBTC/ETH Pool instance |
lpToken | address | The address of the associated LP token (represents liquidity ownership in the Pool) |
coins | address[] | The addresses of the assets in the Pool (USDT/WBTC/ETH) |
State Variables
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored.
N_COINS
Constant value that defines the number of distinct assets (USDT/WBTC/ETH) that Curve.fi Pool handles.
Constructor
Sets the value of the STORAGE_SLOT state variable.
The value is computed as the keccak256 hash of the abi encoding of:
- The
Nexera-FI.CurveFiAdapter_tricrypto2
string literal - The address of this contract (CurveFiAdapter_tricrypto2)
Functions
initialize
Initializes the Adapter.
Parameters
Name | Type | Description |
---|---|---|
initData_ | bytes | The ABI encoded InitializeData |
_deposit
Internal function for handling Deposit Operations.
This function is responsible for adding liquidity to the Curve.fi USDT/WBTC/ETH Pool, via invoking the add_liquidity method of the Pool.
Called by executeAction function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send (up to N_COINS tokens) |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. It can either be empty or have one token (LP token) which will be used as the minimum amount to mint. |
extraData | bytes | Extra data parameter. Not used in this context. |
_withdraw
Internal function for handling Withdraw Operations.
This function is responsible for withdrawing liquidity from the Curve.fi USDT/WBTC/ETH Pool.
Called by executeAction function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Should only contain the LP token to burn. |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive (up to N_COINS tokens) |
extraData | bytes | Extra data parameter. Not used in this context. |
_withdrawOne
Helper function for withdrawing liquidity from the Curve.fi USDT/WBTC/ETH Pool when only a single expectedIn
token is provided.
This function invokes the remove_liquidity_one_coin method of the Pool.
Called by _withdraw function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Should only contain the LP token to burn. |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Should only contain one token (USDT, or WBTC, or ETH) |
_withdrawPoolProportions
Helper function for withdrawing liquidity from the Curve.fi USDT/WBTC/ETH Pool when more than a single expectedIn
token is provided.
This function invokes the remove_liquidity method of the Pool.
Called by _withdraw function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Should only contain the LP token to burn. |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive |
_swap
Internal function for handling Swap Operations.
This function is responsible for performing single-token swaps within the Curve.fi USDT/WBTC/ETH Pool via invoking the exchange method of the Pool.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Should contain only the token to exchange from. |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Should contain only the token to exchange to. |
extraData | bytes | Extra data parameter. Not used in this context. |
_collect
This function always raises the OPERATION_NOT_SUPPORTED error, as Collect is not an action supported within the Curve.fi USDT/WBTC/ETH Pool.
Called by executeAction function.
_operate
This function always raises the OPERATION_NOT_SUPPORTED error, as Operate is not an action supported within the Curve.fi USDT/WBTC/ETH Pool.
Called by executeAction function.
_approveOutTransfers
Private helper function used to approve token transfers to the the Curve.fi USDT/WBTC/ETH Pool.
Called by the following functions:
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send |
_fillAmountsArray
Private helper function used to extract the amount values of the provided token compositions.
Called by the following functions:
Parameters
Name | Type | Description |
---|---|---|
tokenAmounts | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to extract the respective amount values |
Returns
Name | Type | Description |
---|---|---|
amounts | uint256[N_COINS] | Array of lenght N_COINS with the amount values |
_poolTokenAddreses
Private helper function used to retrieve the addresses of the assets supported within the Curve.fi USDT/WBTC/ETH Pool.
Called by _fillAmountsArray and _findTokenIndex functions.
Returns
Name | Type | Description |
---|---|---|
poolTokens | address[N_COINS] | Array of lenght N_COINS with the addresses of the assets (USDT, WBTC, ETH) |
_findTokenIndex
Private helper function used to find the index of a given token within the array of the assets' addresses (USDT, WBTC, ETH) that the _poolTokenAddreses function returns.
Reverts if token
is not one of the supported assets : USDT, WBTC, ETH.
Called by withdrawOne and _swap functions.
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the token for which the index needs to be found |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The index of token within the array that _poolTokenAddreses returns |
_findAmount
Private helper function responsible for returning the amount associated with a specific token within an array of TokenAmount
structures.
Returns 0 if token
is not present in the tokenAmounts
array.
Called by _fillAmountsArray function.
Parameters
Name | Type | Description |
---|---|---|
tokenAmounts | IAdapter.TokenAmount[] | Array of TokenAmount structs with the token compositions to search |
token | address | The address of the token for which the associated amount needs to be found within the tokenAmounts array |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount associated with token within the tokenAmounts array, or 0 if token is not found within tokenAmounts |
layout
Retrieves a reference to the Layout struct stored at a specified storage slot.