YearnDAIStrategy
Overview
The YearnDAIStrategy contract is a strategy that supplies DAI into a Yearn V3 Vault. It manages conversions between USDCe and DAI through Curve's AtriCrypto zapper and handles decimal scaling between the 6-decimal USDCe and 18-decimal DAI tokens.
Constants
Functions
Initialization Functions
initialize
Initializes the strategy with trading limits.
Parameters:
_vault
: MaxApy vault address_keepers
: Array of keeper addresses_strategyName
: Name of the strategy_strategist
: Strategist address_yVault
: Yearn V3 vault address
Core Functions
liquidateExact
Withdraws exact amount to vault with loss calculation.
Parameters:
amountNeeded
: Amount to withdraw
Returns:
loss
: Amount of realized loss
View Functions
previewLiquidate
Simulates withdrawal including losses.
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
maxLiquidate
Returns maximum withdrawable amount after losses.
Returns:
Maximum withdrawable amount
maxLiquidateExact
Returns maximum withdrawable amount with 1% safety margin.
Returns:
Maximum withdrawable amount before losses
Internal Core Functions
_invest
Invests assets by:
Scaling between 6 and 18 decimals
Converting USDCe to DAI through zapper
Depositing DAI into Yearn vault
Parameters:
amount
: Amount to investminOutputAfterInvestment
: Minimum expected shares
Returns:
depositedAmount
: Amount of tokens received
_divest
Withdraws assets by:
Redeeming from Yearn vault
Converting DAI to USDCe through zapper
Parameters:
shares
: Amount of shares to withdraw
Returns:
withdrawn
: Amount of assets received
Internal View Functions
_shareValue
Calculates underlying value including conversion.
Parameters:
shares
: Share amount
Returns:
Underlying asset value
_sharesForAmount
Calculates shares needed including spot price.
Parameters:
amount
: Asset amount
Returns:
Required shares
_spotPriceDy
Calculates spot price conversion without slippage.
Parameters:
i
: Direction (0: DAI->USDC, 1: USDC->DAI)amount
: Amount to convert
Returns:
Converted amount at spot price
Last updated