BaseConvexStrategyPolygon
Overview
The BaseConvexStrategyPolygon contract serves as the foundation for Polygon-based strategies that interact with Convex protocols in the MaxAPY ecosystem. This contract provides core functionality for depositing assets, managing rewards, and handling withdrawals on Polygon network.
Errors
error ConvexPoolShutdown(); // Convex pool has been shut down
error InvalidCoinIndex(); // Invalid coin index provided
error NotEnoughFundsToInvest(); // Insufficient funds for investment
error InvalidZeroAddress(); // Zero address provided
error CurveWithdrawAdminFeesFailed(); // Failed to withdraw admin fees
error InvalidHarvestedProfit(); // Invalid profit amount reported
error MinOutputAmountNotReached(); // Minimum output not achieved
error InvalidZeroAmount(); // Zero amount provided
error MinExpectedBalanceAfterSwapNotReached(); // Minimum balance not reached after swapEvents
event Invested(address indexed strategy, uint256 amountInvested);
event Divested(address indexed strategy, uint256 amountDivested);
event MaxSingleTradeUpdated(uint256 maxSingleTrade);
event MinSwapCrvUpdated(uint256 newMinSwapCrv);
event RouterUpdated(address newRouter);State Variables
Functions
View Functions
stakedBalance
Returns the amount of Curve LP tokens staked in Convex.
Returns:
The amount of staked LP tokens
previewLiquidate
Calculates estimated withdrawal amount including potential losses.
Parameters:
requestedAmount: The amount of assets requested to withdraw
Returns:
The expected liquidated amount
previewLiquidateExact
Calculates the amount needed to request for desired withdrawal amount.
Parameters:
liquidatedAmount: The desired amount to receive
Returns:
The amount that needs to be requested
maxLiquidate
Returns maximum amount that can be withdrawn after losses.
Returns:
Maximum withdrawable amount
maxLiquidateExact
Returns maximum amount that can be withdrawn before losses.
Returns:
Maximum withdrawable amount before losses
Configuration Functions
setMaxSingleTrade
Sets maximum allowed size for a single trade.
Parameters:
_maxSingleTrade: New maximum trade size
setMinSwapCrv
Sets minimum amount for CRV token swaps.
Parameters:
_minSwapCrv: New minimum swap amount
Core Internal Functions
_prepareReturn
Prepares strategy returns and handles profits/losses.
Parameters:
debtOutstanding: Amount of debt to be repaidminExpectedBalance: Minimum balance expected after operations
Returns:
unrealizedProfit: Unrealized profit amountloss: Loss amountdebtPayment: Debt payment amount
_adjustPosition
Adjusts strategy position with available capital.
Parameters:
minOutputAfterInvestment: Minimum expected output after investment
_invest
Invests assets into Convex pool.
Parameters:
amount: Amount of assets to investminOutputAfterInvestment: Minimum expected output
Returns:
Amount of tokens received
_divest
Withdraws assets from Convex pool.
Parameters:
amount: Amount of LP tokens to withdraw
Returns:
Amount of underlying assets received
Internal Helper Functions
_crvBalance
Returns CRV token balance of strategy.
Returns:
CRV balance
_stakedBalance
Returns LP tokens staked in Convex.
Parameters:
rewardPool: Convex reward pool address
Returns:
Staked LP token amount
_lpValue
Calculates underlying value of LP tokens.
Parameters:
lp: Amount of LP tokens
Returns:
Underlying value
_lpForAmount
Calculates LP tokens needed for underlying amount.
Parameters:
amount: Amount of underlying assets
Returns:
Required LP tokens
Abstract Functions
_lpPrice
Returns estimated price of Convex LP token.
Returns:
LP token price
_estimatedTotalAssets
Returns total value of strategy's assets.
Returns:
Total assets value
_crv
Returns CRV token address.
Returns:
CRV token address
_unwindRewards
Claims and processes rewards from Convex.
Parameters:
rewardPool: Convex reward pool to claim from
Last updated