Convex Protocol
Overview
Convex Finance is a DeFi protocol designed to enhance yields for CRV token holders and Curve liquidity providers. The protocol offers two reward-boosting strategies: staking CRV tokens for cvxCRV, and staking Curve LP tokens. Stakers receive additional rewards, including CVX tokens, while liquidity providers benefit from boosted incentives. Functioning as a bridge to Curve Finance, Convex facilitates user access to liquidity, trading fee earnings, and automated reward harvesting by integrating seamlessly with Curve's stablecoin pools.
The Nexera-Fi ConvexAdapter interacts with and utilizes the following two components of Convex:
- Booster contract
- BaseRewardPool contract instances
In the following sections, we'll provide an overview of these contracts and their methods that Nexera-Fi ConvexAdapter interacts with.
Interactions with ConvexAdapter
The ConvexAdapter interacts with Convex protocol by calling the methods presented in the diagram below. Each method serves a specific purpose within the Adapter, enabling strategies to seamlessly integrate liquidity provision, liquidity withdrawal, and staking/unstaking functionality via Convex.
Booster
The Booster serves as the central deposit contract for LP tokens and it is essentially the entry point for Convex pools. Through its interface users can deposit Curve LP tokens and receive convex tokenized deposit shares at a 1:1 ratio, or retrieve their Curve LP tokens by burning these deposit shares.
In the context of the Nexera-Fi ConvexAdapter, these three methods come into play:
Methods
poolInfo
Retrieve information for the pool specified by _pid
.
This method is invoked by the following ConvexAdapter functions:
- _deposit
- _withdraw
- _collect
- _stake → (called by _operate function on
OperateOperation.STAKE
) - _unstake → (called by _operate function on
OperateOperation.UNSTAKE
)
These functions leverage the poolInfo
method of the Booster contract to retrieve key details related to a targeted pool identified by the poolId
within the respective Deposit, Withdraw, Collect and Operate ExtraData structs.
Each function performs dedicated verification steps against the acquired pool information and the provided input to ensure consistency between the involved assets and the associated rewards contract. This validation process helps maintain the integrity of the operations, ensuring accurate interactions with the Convex protocol.
deposit
Deposit Curve LP tokens into Convex, receive a tokenized deposit, and optionally immediately stake the tokenized deposit.
This method is invoked by the following ConvexAdapter function:
This function invokes the deposit
method of the Booster contract to deposit the LP tokens specified in out
input parameter.
The poolId
and stake
fields within extraData
input parameter (ABI encoded DepositExtraData struct) indicate the targeted pool and whether to stake the received convex tokenized deposit.
withdraw
Withdraw deposited Curve LP tokens by burning the convex tokenized deposit _amount
.
This method is invoked by the following ConvexAdapter function:
This function invokes the withdraw
method of the Booster contract when the claimRewards
field within the extraData
input parameter (ABI encoded WithdrawExtraData struct) is set to false.
The LP tokens to be withdrawn are specified in expectedIn
input parameter and the convex tokenized deposit to burn is specified in the out
input parameter.
The poolId
field within extraData
indicates the targeted pool.
BaseRewardPool
Convex employes the Synthetix BaseRewardPool as the implementation reward contract for all LP pools.
Each LP pool is associated with a certain BaseRewardPool instance where the asset-to-share ratio is maintained at 1:1, ensuring that users' assets are closely aligned with their share in the pool. The chosen "asset" within such instances is a corresponding convex tokenized deposit, which represents a user's share of assets in the associated pool.
In the context of the Nexera-Fi ConvexAdapter, these four methods come into play:
Methods
getReward
Claim accrued rewards from staked tokenized liquidity.
This method is invoked by the following ConvexAdapter function:
This function invokes the getReward
method of the BaseRewardPool instance associated with the convex pool specified by poolId
field within extraData
input parameter (ABI encoded CollectExtraData struct).
stake
Stake a convex tokenized deposit.
This method is invoked by the following ConvexAdapter function:
This function invokes the stake
method of the BaseRewardPool instance associated with the convex pool specified by poolId
input parameter.
It is triggered within the context of the Adapter's _operate function when OperateOperation is configured as STAKE,
withdraw
Unstake to a convex tokenized deposit, and optionally claim accrued rewards.
This method is invoked by the following ConvexAdapter function:
This function invokes the withdraw
method of the BaseRewardPool instance associated with the convex pool specified by poolId
input parameter.
It is triggered within the context of the Adapter's _operate function when OperateOperation is configured as UNSTAKE,
withdrawAndUnwrap
Unstake directly to curve LP token, and optionally claim accrued rewards.
This method is invoked by the following ConvexAdapter function:
This function invokes the withdrawAndUnwrap
method of the BaseRewardPool instance associated with the convex pool specified by poolId
field within extraData
input parameter (ABI encoded WithdrawExtraData struct).
The execution occurs when the token specified in the out
input parameter aligns with the reward contract of the targeted pool.
Please note: For detailed information about Convex protocol, consult the official Convex documentation.