YearnDAIStrategy
Overview
The YearnDAIStrategy contract is a strategy that supplies DAI into a Yearn V2 Vault to earn yield. It handles conversions between the underlying asset and DAI through Curve's 3pool.
Constants
ICurveTriPool public constant triPool = ICurveTriPool(CURVE_3POOL_POOL_MAINNET); // Curve's 3pool
address constant dai = DAI_MAINNET; // DAI token address
Functions
Initialization Functions
initialize
function initialize(
IMaxApyVault _vault,
address[] calldata _keepers,
bytes32 _strategyName,
address _strategist,
IYVault _yVault
) public virtual override initializer
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
Internal Core Functions
_invest
function _invest(uint256 amount, uint256 minOutputAfterInvestment) internal override returns (uint256 depositedAmount)
Invests assets by:
Swapping underlying to DAI through Curve
Depositing DAI into Yearn vault
Parameters:
amount
: Amount to investminOutputAfterInvestment
: Minimum expected shares
Returns:
depositedAmount
: Amount of tokens received
_divest
function _divest(uint256 shares) internal override returns (uint256 withdrawn)
Withdraws assets by:
Withdrawing DAI from Yearn vault
Swapping DAI to underlying through Curve
Parameters:
shares
: Amount of shares to withdraw
Returns:
withdrawn
: Amount of assets received
Internal View Functions
_shareValue
function _shareValue(uint256 shares) internal view override returns (uint256)
Calculates underlying value of shares including Curve conversion rate.
Parameters:
shares
: Share amount
Returns:
Underlying value
_sharesForAmount
function _sharesForAmount(uint256 amount) internal view override returns (uint256 shares)
Calculates shares needed for amount including Curve conversion rate.
Parameters:
amount
: Asset amount
Returns:
Required shares
Key Features:
Uses Curve's 3pool for token conversions
Sets 1M DAI maximum trade size
Sets minimum trade size to 0.01 token units
Handles token conversions during deposits and withdrawals
Last updated