ConvexCrvUSDWethCollateralStrategy

Overview

The ConvexCrvUSDWethCollateralStrategy contract is a sophisticated strategy that supplies CrvUSD into the CrvUSD(WETH Collateral) lending pool in Curve, then stakes the curve LP tokens in Convex to maximize yield. It manages multiple token conversions and interactions between Curve lending pools and Convex staking.

Constants

address public constant weth = WETH_MAINNET;                   // WETH token address
address public constant crv = CRV_MAINNET;                     // CRV token address
address public constant cvx = CVX_MAINNET;                     // CVX token address
address public constant crvUsd = CRVUSD_MAINNET;              // crvUSD token address
uint256 public constant CRVUSD_WETH_COLLATERAL_POOL_ID = CONVEX_CRVUSD_WETH_COLLATERAL_POOL_ID_MAINNET;  // Convex pool ID
IRouter public constant router = IRouter(UNISWAP_V3_ROUTER_MAINNET);  // Uniswap V3 router
IConvexBooster public constant convexBooster = IConvexBooster(CONVEX_BOOSTER_MAINNET);  // Convex booster

State Variables

ICurveLendingPool public curveLendingPool;      // Main Curve lending pool
ICurveLpPool public curveUsdcCrvUsdPool;        // Curve's USDC-crvUSD pool

Functions

Initialization Functions

constructor

constructor() initializer

Empty constructor marked as initializer.

initialize

function initialize(
    IMaxApyVault _vault,
    address[] calldata _keepers,
    bytes32 _strategyName,
    address _strategist,
    ICurveLendingPool _curveLendingPool,
    ICurveLpPool _curveUsdcCrvUsdPool
) 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

  • _curveLendingPool: Curve lending pool address

  • _curveUsdcCrvUsdPool: Curve USDC-crvUSD pool address

Internal Core Functions

_invest

function _invest(uint256 amount, uint256 minOutputAfterInvestment) internal override returns (uint256)

Invests assets through multiple steps:

  1. Swaps USDC for crvUSD

  2. Adds liquidity to lending pool

  3. Stakes LP tokens in Convex

Parameters:

  • amount: Amount to invest

  • minOutputAfterInvestment: Minimum expected LP tokens

Returns:

  • Amount of tokens received

_divest

function _divest(uint256 amount) internal override returns (uint256)

Withdraws assets through multiple steps:

  1. Withdraws from Convex

  2. Removes liquidity from lending pool

  3. Swaps crvUSD for USDC

Parameters:

  • amount: Amount of LP tokens to divest

Returns:

  • Amount of USDC received

_unwindRewards

function _unwindRewards(IConvexRewards rewardPool) internal override

Claims and converts rewards to underlying:

  1. Claims CRV and CVX rewards

  2. Swaps CVX for CRV

  3. Swaps CRV for USDC through WETH

Parameters:

  • rewardPool: Convex rewards pool

View Functions

previewLiquidate

function previewLiquidate(uint256 requestedAmount) public view virtual override returns (uint256)

Simulates withdrawal including losses.

Parameters:

  • requestedAmount: Amount to withdraw

Returns:

  • Expected output amount

Internal View Functions

_lpValue

function _lpValue(uint256 lp) internal view override returns (uint256)

Calculates underlying value of LP tokens.

Parameters:

  • lp: Amount of LP tokens

Returns:

  • Underlying value

_lpForAmount

function _lpForAmount(uint256 amount) internal view override returns (uint256)

Calculates LP tokens needed for given amount.

Parameters:

  • amount: Amount of underlying

Returns:

  • Required LP tokens

_lpPrice

function _lpPrice() internal view override returns (uint256)

Empty implementation for LP price.

_crv

function _crv() internal pure override returns (address)

Returns CRV token address.

_cvx

function _cvx() internal pure override returns (address)

Returns CVX token address.

_simulateHarvest

function _simulateHarvest() public override

Simulates harvest operation with detailed result reporting.

Last updated