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:

  1. Unwraps WETH

  2. Swaps ETH for frxETH

  3. Adds liquidity to dETH-frxETH pool

  4. Stakes LP tokens in Convex

Parameters:

  • amount: Amount to invest

  • minOutputAfterInvestment: 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:

  1. Withdraws from Convex

  2. Removes liquidity from Curve

  3. Swaps frxETH back to ETH

  4. 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:

  1. Claims CRV and CVX rewards

  2. Swaps CRV for WETH

  3. 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:

  1. Investment/divestment amounts

  2. Profit/loss calculations

  3. Debt management

  4. Balance changes

Last updated