ConvexdETHFrxETHStrategy
Overview
The ConvexdETHFrxETHStrategy contract is a specialized strategy that supplies ETH into the dETH-frxETH pool in Curve, then stakes the curve LP tokens in Convex to maximize yield. It handles the complex interactions between Curve pools and Convex staking.
Constants
address public constant crv = CRV_MAINNET; // Ethereum mainnet's CRV Token
address public constant cvx = CVX_MAINNET; // Ethereum mainnet's CVX Token
address public constant frxETH = FRXETH_MAINNET; // Ethereum mainnet's frxETH Token
uint256 public constant DETH_FRXETH_CONVEX_POOL_ID = CONVEX_DETH_FRXETH_CONVEX_POOL_ID_MAINNET; // Convex pool identifier
State Variables
IConvexBooster public constant convexBooster; // Main Convex's deposit contract
IRouter public router; // Router for CRV-WETH swaps
ICurveLpPool public constant cvxWethPool; // CVX-WETH pool in Curve
ICurveLpPool public curveLpPool; // Main Curve pool for Strategy
ICurveLpPool public curveEthFrxEthPool; // Curve's ETH-frxETH pool
Functions
Initialization Functions
constructor
constructor() initializer
Empty constructor marked as initializer.
initialize
function initialize(
IMaxApyVault _vault,
address[] calldata _keepers,
bytes32 _strategyName,
address _strategist,
ICurveLpPool _curveLpPool,
ICurveLpPool _curveEthFrxEthPool,
IRouter _router
) public initializer
Initializes the strategy with required components.
Parameters:
_vault
: MaxApy vault address_keepers
: Array of keeper addresses_strategyName
: Name of the strategy_strategist
: Strategist address_curveLpPool
: Address of main Curve pool (dETH-frxETH)_curveEthFrxEthPool
: Address of Curve's ETH-frxETH pool_router
: Router address for swaps
Configuration Functions
setRouter
function setRouter(address _newRouter) external checkRoles(ADMIN_ROLE)
Updates the router used for token swaps.
Parameters:
_newRouter
: New router address
Internal Core Functions
_invest
function _invest(uint256 amount, uint256 minOutputAfterInvestment) internal override returns (uint256)
Invests ETH into the Convex pool through a series of steps:
Unwraps WETH
Swaps ETH for frxETH
Adds liquidity to dETH-frxETH pool
Stakes LP tokens in Convex
Parameters:
amount
: Amount to investminOutputAfterInvestment
: Minimum expected LP tokens Returns:Amount of tokens received in underlying terms
_divest
function _divest(uint256 amount) internal override returns (uint256)
Withdraws assets from Convex and Curve pools:
Withdraws from Convex
Removes liquidity from Curve
Swaps frxETH back to ETH
Wraps ETH to WETH
Parameters:
amount
: LP tokens to divest Returns:Amount of WETH received
_unwindRewards
function _unwindRewards(IConvexRewards rewardPool) internal override
Claims and converts reward tokens to underlying asset:
Claims CRV and CVX rewards
Swaps CRV for WETH
Swaps CVX for WETH
Parameters:
rewardPool
: Convex rewards pool to claim from
View Functions
previewLiquidate
function previewLiquidate(uint256 requestedAmount) public view virtual override returns (uint256)
Simulates withdrawal including potential losses.
Parameters:
requestedAmount
: Amount to withdraw Returns:Expected output amount after losses
Internal View Functions
_lpPrice
function _lpPrice() internal view override returns (uint256)
Calculates the estimated price for the strategy's Convex LP token.
Returns:
Estimated LP token price
_crv
function _crv() internal pure override returns (address)
Returns the CRV token address.
Returns:
CRV token address
_cvx
function _cvx() internal pure override returns (address)
Returns the CVX token address.
Returns:
CVX token address
Receive Function
receive() external payable
Enables the contract to receive ETH.
Simulation Functions
_simulateHarvest
function _simulateHarvest() public override
Internal simulation function that calculates expected outcomes of harvesting operations including:
Investment/divestment amounts
Profit/loss calculations
Debt management
Balance changes
Last updated