🐸
maxAPY for Devs
  • maxAPY ERC7540
    • MetaVault
      • Introduction
      • Architecture
      • Core Operations
      • State Management & Operations
      • Asset Management
      • Settlement Mechanics
      • Withdrawal Queue Mechanics
      • Deployed Addresses
  • Periphery
    • Hurdle Rate Oracle
    • SharePriceOracle
    • Deployed Addresses
  • maxAPY ERC4626
    • Introduction
    • Architecture
    • Vault
      • MaxApyFactory
      • MaxApyRouter
      • MaxApyVault
    • Periphery
      • MaxApyHarvester
    • Base Strategies
      • BaseStrategy
      • BaseSommelierStrategy
      • BaseYearnV3Strategy
      • BaseYearnV2Strategy
      • BaseConvexStrategy
      • BaseConvexStrategyPolygon
      • BaseBeefyStrategy
      • BaseHopStrategy
      • BaseBeefyCurveStrategy
    • Strategies
      • Ethereum - WETH
        • Convex
          • ConvexdETHFrxETHStrategy
        • Sommelier
          • SommelierMorphoEthMaximizerStrategy
          • SommelierStEthDepositTurboStEthStrategy
          • SommelierTurboDivEthStrategy
          • SommelierTurboEEthV2Strategy
          • SommelierTurboEthXStrategy
          • SommelierTurboEzEthStrategy
          • SommelierTurboRsEthStrategy
          • SommelierTurboStEthStrategy
          • SommelierTurboSwEthStrategy
        • Yearn
          • YearnAaveV3WETHLenderStrategy
          • YearnAjnaWETHStakingStrategy
          • YearnCompoundV3WETHLenderStrategy
          • YearnV3WETH2Strategy
          • YearnV3WETHStrategy
          • YearnWETHStrategy
      • Ethereum - USDC
        • Convex
          • ConvexCrvUSDWethCollateralStrategy
        • Sommelier
          • SommelierTurboGHOStrategy
        • Yearn
          • YearnAjnaDAIStakingStrategy
          • YearnDAIStrategy
          • YearnLUSDStrategy
          • YearnUSDCStrategy
          • YearnUSDTStrategy
      • Polygon - WETH
        • Hop
          • HopETHStrategy
      • Polygon - USDC.e
        • Convex
          • ConvexUSDCCrvUSDStrategy
          • ConvexUSDTCrvUSDStrategy
        • Beefy
          • BeefyCrvUSDUSDCeStrategy
          • BeefyMaiUSDCeStrategy
          • BeefyUSDCeDAIStrategy
        • Yearn
          • YearnAaveV3USDTLenderStrategy
          • YearnAjnaUSDCStrategy
          • YearnCompoundUSDCeLenderStrategy
          • YearnDAILenderStrategy
          • YearnDAIStrategy
          • YearnMaticUSDCStakingStrategy
          • YearnUSDCeLenderStrategy
          • YearnUSDCeStrategy
          • YearnUSDTStrategy
    • Subgraph
      • Overview
      • Schema
      • Query Guide
Powered by GitBook
On this page
  • Overview
  • Constants
  • Functions
  • Initialization Functions
  • Core Functions
  • View Functions
  • Internal Core Functions
  • Internal View Functions
  1. maxAPY ERC4626
  2. Strategies
  3. Polygon - USDC.e
  4. Yearn

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

ICurveAtriCryptoZapper constant zapper = ICurveAtriCryptoZapper(CURVE_AAVE_ATRICRYPTO_ZAPPER_POLYGON);  // Curve zapper
address public constant dai = DAI_POLYGON;                                                                // DAI address

Functions

Initialization Functions

initialize

function initialize(
    IMaxApyVault _vault,
    address[] calldata _keepers,
    bytes32 _strategyName,
    address _strategist,
    IYVaultV3 _yVault
) public virtual override initializer

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

function liquidateExact(uint256 amountNeeded) external override checkRoles(VAULT_ROLE) returns (uint256 loss)

Withdraws exact amount to vault with loss calculation.

Parameters:

  • amountNeeded: Amount to withdraw

Returns:

  • loss: Amount of realized loss

View Functions

previewLiquidate

function previewLiquidate(uint256 requestedAmount) public view override returns (uint256 liquidatedAmount)

Simulates withdrawal including losses.

Parameters:

  • requestedAmount: Amount to withdraw

Returns:

  • liquidatedAmount: Expected output amount

previewLiquidateExact

function previewLiquidateExact(uint256 liquidatedAmount) public view override returns (uint256 requestedAmount)

Calculates input needed with 1% buffer.

Parameters:

  • liquidatedAmount: Desired output amount

Returns:

  • requestedAmount: Required input amount

maxLiquidate

function maxLiquidate() public view override returns (uint256)

Returns maximum withdrawable amount after losses.

Returns:

  • Maximum withdrawable amount

maxLiquidateExact

function maxLiquidateExact() public view override returns (uint256)

Returns maximum withdrawable amount with 1% safety margin.

Returns:

  • Maximum withdrawable amount before losses

Internal Core Functions

_invest

function _invest(uint256 amount, uint256 minOutputAfterInvestment) internal override returns (uint256 depositedAmount)

Invests assets by:

  1. Scaling between 6 and 18 decimals

  2. Converting USDCe to DAI through zapper

  3. Depositing DAI into Yearn vault

Parameters:

  • amount: Amount to invest

  • minOutputAfterInvestment: Minimum expected shares

Returns:

  • depositedAmount: Amount of tokens received

_divest

function _divest(uint256 shares) internal override returns (uint256 withdrawn)

Withdraws assets by:

  1. Redeeming from Yearn vault

  2. Converting DAI to USDCe through zapper

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 _assets)

Calculates underlying value including conversion.

Parameters:

  • shares: Share amount

Returns:

  • Underlying asset value

_sharesForAmount

function _sharesForAmount(uint256 amount) internal view override returns (uint256 _shares)

Calculates shares needed including spot price.

Parameters:

  • amount: Asset amount

Returns:

  • Required shares

_spotPriceDy

function _spotPriceDy(uint256 i, uint256 amount) internal view returns (uint256 _spotDy)

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

PreviousYearnDAILenderStrategyNextYearnMaticUSDCStakingStrategy

Last updated 6 months ago