ConvexUSDCCrvUSDStrategy

Overview

The ConvexUSDCCrvUSDStrategy contract is a strategy that supplies USDC into the crvUSD-USDC pool in Curve on Polygon, then stakes the curve LP tokens in Convex to maximize yield. It handles multiple token conversions and uses TWAP oracles for price calculations.

Constants

address public constant crvUsd = CRV_USD_POLYGON;                                 // CRVUSD token address
address public constant wpol = WPOL_POLYGON;                                      // Wrapped MATIC address
address public constant crv = CRV_POLYGON;                                        // CRV token address
address public constant usdc = USDC_POLYGON;                                      // USDC token address
uint256 public constant CRVUSD_USDC_CONVEX_POOL_ID = CRVUSD_USDC_CONVEX_POOL_ID_POLYGON;  // Convex pool ID
address public constant pool = UNISWAP_V3_USDC_USDCE_POOL_POLYGON;              // Uniswap V3 pool
address public constant triCryptoPool = TRI_CRYPTO_POOL_POLYGON;                 // CrvTricrypto pool

State Variables

IRouter public router;                           // Router for swaps
ICurveLpPool public curveLpPool;                // Main Curve pool
IConvexBoosterPolygon public constant convexBooster = IConvexBoosterPolygon(CONVEX_BOOSTER_POLYGON);  // Convex booster
ICurveAtriCryptoZapper public constant zapper = ICurveAtriCryptoZapper(CURVE_CRV_ATRICRYPTO_ZAPPER_POLYGON);  // Curve zapper

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,
    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: Curve LP pool address

  • _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

Core Functions

_invest

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

Invests assets through:

  1. Swapping base asset to USDC

  2. Adding liquidity to crvUSD-USDC pool

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

  1. Withdrawing from Convex

  2. Removing liquidity from Curve

  3. Swapping USDC to base asset

Parameters:

  • amount: LP tokens to divest

Returns:

  • Amount received after withdrawals and swaps

_unwindRewards

function _unwindRewards(IConvexRewardsPolygon rewardPool) internal override

Claims and converts rewards:

  1. Claims CRV rewards

  2. Swaps CRV through TriCrypto pool

  3. Swaps crvUSD through multiple hops

Parameters:

  • rewardPool: Convex rewards pool

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

Internal View Functions

_lpValue

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

Calculates underlying value of LP tokens using TWAP.

Parameters:

  • lp: LP token amount

Returns:

  • Underlying value

_lpForAmount

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

Calculates LP tokens needed for amount using TWAP.

Parameters:

  • amount: Asset amount

Returns:

  • Required LP tokens

_lpPrice

function _lpPrice() internal view override returns (uint256)

Calculates LP token price.

Returns:

  • LP token price

_estimateAmountOut

function _estimateAmountOut(address tokenIn, address tokenOut, uint128 amountIn, uint32 secondsAgo) internal view returns (uint256)

Calculates swap output using TWAP oracle.

Parameters:

  • tokenIn: Input token

  • tokenOut: Output token

  • amountIn: Input amount

  • secondsAgo: TWAP period

Returns:

  • Estimated output amount

_crv

function _crv() internal pure override returns (address)

Returns CRV token address.

_crvUsdBalance

function _crvUsdBalance() internal view returns (uint256)

Returns strategy's crvUSD balance.

_simulateHarvest

function _simulateHarvest() public override

Simulates harvest operation and reverts with simulation data.

Last updated