The BaseBeefyStrategy contract serves as the foundation for strategies that interact with Beefy Finance protocols in the MaxAPY ecosystem. It provides core functionality for depositing assets into Beefy vaults, managing positions, and handling withdrawals.
Errors
errorNotEnoughFundsToInvest(); // Insufficient funds for investmenterrorInvalidZeroAddress(); // Zero address provided
IBeefyVault public beefyVault; // Beefy vault contract referenceuint256public maxSingleTrade; // Maximum size for a single tradeuint256public minSingleTrade; // Minimum size for a single trade
Functions
Initialization Functions
initialize
Initializes the strategy with required parameters.
Parameters:
_vault: MaxApy vault address
_keepers: Array of keeper addresses
_strategyName: Name of the strategy
_strategist: Strategist address
_beefyVault: Beefy vault address
Configuration Functions
setMinSingleTrade
Sets minimum trade size for the strategy.
Parameters:
_minSingleTrade: New minimum trade size
setMaxSingleTrade
Sets maximum trade size for the strategy.
Parameters:
_maxSingleTrade: New maximum trade size
View Functions
previewLiquidate
Calculates expected output for a withdrawal.
Parameters:
requestedAmount: Amount requested to withdraw
Returns:
Expected liquidated amount
previewLiquidateExact
Calculates input needed for desired withdrawal amount.
Parameters:
liquidatedAmount: Desired output amount
Returns:
Required input amount
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
Internal Functions
_prepareReturn
Prepares strategy returns and handles profits/losses.
Parameters:
debtOutstanding: Outstanding debt amount
minExpectedBalance: Minimum expected balance after operations
Returns:
unrealizedProfit: Unrealized profit amount
loss: Loss amount
debtPayment: Debt payment amount
_adjustPosition
Adjusts strategy position with available capital.
Parameters:
minOutputAfterInvestment: Minimum expected output after investment