YearnLUSDStrategy
Overview
The YearnLUSDStrategy contract is a strategy that supplies LUSD into a Yearn V2 Vault to earn yield. It handles conversions between USDC and LUSD through Uniswap V3, using TWAP oracles for price calculations.
Constants
Functions
Initialization Functions
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_yVault
: Yearn V2 vault address
View Functions
previewLiquidate
Simulates withdrawal with 1% safety margin.
Parameters:
requestedAmount
: Amount to withdraw
Returns:
liquidatedAmount
: Expected output amount
previewLiquidateExact
Calculates input needed with 1% buffer.
Parameters:
liquidatedAmount
: Desired output amount
Returns:
requestedAmount
: Required input amount
Internal Core Functions
_invest
Invests assets by:
Swapping USDC to LUSD
Depositing LUSD into Yearn vault
Parameters:
amount
: Amount to investminOutputAfterInvestment
: Minimum expected shares
Returns:
depositedAmount
: Amount of tokens received
_divest
Withdraws assets by:
Withdrawing LUSD from Yearn vault
Swapping LUSD to USDC
Parameters:
shares
: Amount of shares to withdraw
Returns:
withdrawn
: Amount of assets received
Internal View Functions
_shareValue
Calculates underlying value using TWAP oracle.
Parameters:
shares
: Share amount
Returns:
Underlying value
_sharesForAmount
Calculates shares needed using TWAP oracle.
Parameters:
amount
: Asset amount
Returns:
Required shares
_lusdBalance
Returns strategy's LUSD balance.
Returns:
Current LUSD balance
_estimateAmountOut
Estimates swap output using Uniswap V3 TWAP.
Parameters:
tokenIn
: Input token addresstokenOut
: Output token addressamountIn
: Input amountsecondsAgo
: TWAP interval in seconds
Returns:
Estimated output amount
Last updated