BaseBeefyStrategy
Overview
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
Events
State Variables
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 amountminExpectedBalance
: Minimum expected balance 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
Deposits assets into Beefy vault.
Parameters:
amount
: Amount to investminOutputAfterInvestment
: Minimum expected output
Returns:
Amount of tokens received
_divest
Withdraws assets from Beefy vault.
Parameters:
shares
: Amount of shares to withdraw
Returns:
Amount of underlying assets received
_liquidatePosition
Liquidates position to meet withdrawal request.
Parameters:
amountNeeded
: Amount requested to liquidate
Returns:
liquidatedAmount
: Amount actually liquidatedloss
: Any losses incurred
Internal View Functions
_shareValue
Calculates underlying value of vault shares.
Parameters:
shares
: Amount of shares
Returns:
Underlying asset value
_sharesForAmount
Calculates shares needed for given amount.
Parameters:
amount
: Amount of underlying assets
Returns:
Required shares amount
_shareBalance
Returns strategy's Beefy vault share balance.
Returns:
Current share balance
_estimatedTotalAssets
Calculates total assets under management.
Returns:
Total assets value
Last updated