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

Empty constructor marked as initializer.

initialize

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

Updates the router used for token swaps.

Parameters:

  • _newRouter: New router address

Core Functions

_invest

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

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

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

Simulates withdrawal including potential losses.

Parameters:

  • requestedAmount: Amount to withdraw

Returns:

  • Expected output amount

Internal View Functions

_lpValue

Calculates underlying value of LP tokens using TWAP.

Parameters:

  • lp: LP token amount

Returns:

  • Underlying value

_lpForAmount

Calculates LP tokens needed for amount using TWAP.

Parameters:

  • amount: Asset amount

Returns:

  • Required LP tokens

_lpPrice

Calculates LP token price.

Returns:

  • LP token price

_estimateAmountOut

Calculates swap output using TWAP oracle.

Parameters:

  • tokenIn: Input token

  • tokenOut: Output token

  • amountIn: Input amount

  • secondsAgo: TWAP period

Returns:

  • Estimated output amount

_crv

Returns CRV token address.

_crvUsdBalance

Returns strategy's crvUSD balance.

_simulateHarvest

Simulates harvest operation and reverts with simulation data.

Last updated