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 poolState 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 zapperFunctions
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:
Swapping base asset to USDC
Adding liquidity to crvUSD-USDC pool
Staking LP tokens in Convex
Parameters:
amount: Amount to investminOutputAfterInvestment: Minimum expected LP tokens
Returns:
Amount of tokens received
_divest
Withdraws assets through:
Withdrawing from Convex
Removing liquidity from Curve
Swapping USDC to base asset
Parameters:
amount: LP tokens to divest
Returns:
Amount received after withdrawals and swaps
_unwindRewards
Claims and converts rewards:
Claims CRV rewards
Swaps CRV through TriCrypto pool
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 tokentokenOut: Output tokenamountIn: Input amountsecondsAgo: 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