ConvexAdapter
Extends: BaseAdapter
Custom Errors
WRONG_BOOSTER_ADDRESS
Raised when zero address is provided for Booster in the initialize function.
WRONG_TOKEN_COUNT
Raised when the length of expectedIn
& out
parameters, defining token compositions, do not match the expected length required for an operation.
WRONG_TOKEN_ADDRESS
Raised when an invalid address is provided for a token.
WRONG_TOKEN_AMOUNT
Raised when the amount specified in input or output token compositions is wrong with respect to the requested operation.
UNKNOWN_OPERATE_OPERATION
Raised when an enum key not defined in OperateOperation is provided as the operation code for _operate function.
Enums
OperateOperation
Defines the actions available with respect to Operate Operations:
STAKE
: Stake a convex tokenized depositUNSTAKE
: Unstake to a convex tokenized deposit
Structs
DepositExtraData
Defines the necessary data required for performing deposit actions.
Members
Name | Type | Description |
---|---|---|
poolId | uint256 | The ID of the target pool to supply liquidity via Convex |
stake | bool | A flag to indicate whether to stake the convex tokenized deposit (true), or not (false) |
WithdrawExtraData
Defines the necessary data required for performing withdraw actions.
Members
Name | Type | Description |
---|---|---|
poolId | uint256 | The ID of the target pool to withdraw liquidity via Convex |
claimRewards | bool | A flag indicating whether to claim rewards when withdrawing a staked convex tokenized deposit |
CollectExtraData
Defines the necessary data required for performing collect actions.
Members
Name | Type | Description |
---|---|---|
poolId | uint256 | The ID of the target pool to claim rewards via Convex |
OperateExtraData
Used to indicate the appropriate action of an Operate Operation.
Members
Name | Type | Description |
---|---|---|
operateOperation | OperateOperation | The action to conduct |
poolId | uint256 | The ID of the target pool |
claimRewards | bool | A flag to indicate whether to claim rewards on UNSTAKE (irrelevant for STAKE) |
Layout
Used to store crucial data for the Adapter's functionality in a specific storage slot.
Members
Name | Type | Description |
---|---|---|
booster | IBooster | The address of Convex's Booster contract |
State Variables
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored.
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.ConvexAdapter
string literal - The address of this contract (ConvexAdapter)
Functions
initialize
Initializes the Adapter.
Parameters
Name | Type | Description |
---|---|---|
initData_ | bytes | The ABI encoded Layout data |
_swap
This function always raises the OPERATION_NOT_SUPPORTED error, as SWAP is not an action supported within Convex.
Called by executeAction function.
_deposit
Internal function for handling Deposit Operations.
This function is responsible for depositing LP tokens of a protocol (e.g. Curve) to Convex.
Called by executeAction function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Notes: - The length of the array must equal one. - The token field should match the target pool's underlying token (i.e. the pool's LP token). |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Note: - The token field should hold either the address of the tokenized deposit if no stake is applied, or the reward token if stake is applied (see extraData.stake ). - The amount field should match the amount defined in the out token composition as the tokenized deposit represents the LP deposit at a 1:1 ratio. |
extraData | bytes | ABI encoded data of type DepositExtraData indicating the target pool, and whether to stake the convex tokenized deposit |
_withdraw
Internal function for handling Withdraw Operations.
This function is responsible for withdrawing LP tokens of an underlying protocol (e.g. Curve) from Convex.
Called by executeAction function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Notes: - The length of the array must equal one. - The token field should either match the target pool's convex tokenized deposit if deposit was not staked, or the target pool's reward contract if deposit was staked. |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Note: - The token fields should hold the address of the LP token, and the reward tokens (if rewards are to be claimed). |
extraData | bytes | ABI encoded data of type WithdrawExtraData indicating the target pool, and whether to claim rewards |
_collect
Internal function for handling Collect Operations.
This function is responsible for collecting rewards from staked tokenized liquidity.
Called by executeAction function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Notes: - Should be zero-length array (nothing is deposited) |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Note: - The token fields should hold the address of the expected reward tokens |
extraData | bytes | ABI encoded data of type CollectExtraData indicating the target pool |
_operate
Internal function for handling Operate Operations.
This function is used for:
- Staking a convex tokenized deposit
- Unstaking to a convex tokenized deposit
Called by executeAction function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Notes:If STAKE:- The token field should hold the address of the convex tokenized deposit -If UNSTAKE:The token field should hold the address of the target pool's reward contract |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Notes:If STAKE:- The token field should hold the address of the target pool's reward contractIf UNSTAKE: - The token field should hold the address of the convex tokenized deposit |
extraData | bytes | ABI encoded data of type OperateExtraData indicating the action to conduct (i.e. stake or unstake), the target pool, and whether to claim rewards on unstake |
_stake
Internal helper function for staking a convex tokenized deposit, by invoking the stake
function of the respective Convex Reward contract.
Called by _operate function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Notes: - The token field should hold the address of the convex tokenized deposit |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Notes:- The token field should hold the address of the target pool's reward contract |
poolId | uint256 | The ID of the target pool |
_unstake
Internal helper function for unstaking to a convex tokenized deposit, by invoking the withdraw
function of the respective Convex Reward contract.
Called by _operate function.
Parameters
Name | Type | Description |
---|---|---|
out | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the token compositions to send. Notes:The token field should hold the address of the target pool's reward contract |
expectedIn | IAdapter.TokenAmount[] | Array of TokenAmount structs defining the expected token compositions to receive. Notes: - The token field should hold the address of the convex tokenized deposit |
poolId | uint256 | The ID of the target pool |
claimRewards | bool | A flag indicating whether to claim rewards |
layout
Retrieves a reference to the Layout struct stored at the storage slot specified by STORAGE_SLOT.