YearnAjnaDAIStakingStrategy

Overview

The YearnAjnaDAIStakingStrategy contract is a strategy that supplies DAI into a Yearn V3 Vault and stakes the vault shares to earn additional AJNA rewards. It manages token conversions through Curve's 3pool and Uniswap V3.

Constants

address public constant ajna = AJNA_MAINNET;                                      // AJNA token address
address public constant weth = WETH_MAINNET;                                      // WETH token address
address public constant dai = DAI_MAINNET;                                        // DAI token address
IRouter public constant router = IRouter(UNISWAP_V3_ROUTER_MAINNET);             // Uniswap V3 router
ICurveTriPool public constant triPool = ICurveTriPool(CURVE_3POOL_POOL_MAINNET); // Curve 3pool
IStakingRewardsMulti public constant yearnStakingRewards =                       // Yearn staking rewards
    IStakingRewardsMulti(0x54C6b2b293297e65b1d163C3E8dbc45338bfE443);

State Variables

uint256 public minSwapAjna;    // Minimum amount of AJNA to swap

Functions

Constructor

Empty constructor marked as initializer.

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 V3 vault address

Core Functions

liquidateExact

Withdraws exact amount to vault and re-stakes any remaining shares.

Parameters:

  • amountNeeded: Amount to withdraw

Returns:

  • loss: Amount of realized loss

maxLiquidateExact

Returns maximum withdrawable amount before losses.

Returns:

  • Maximum withdrawable amount

Internal Core Functions

_beforePrepareReturn

Claims and processes staking rewards before preparing return.

_invest

Invests assets by swapping to DAI and staking in Yearn.

Parameters:

  • amount: Amount to invest

  • minOutputAfterInvestment: Minimum expected shares

Returns:

  • depositedAmount: Amount of tokens received

_divest

Unstakes and withdraws assets, converting back to underlying.

Parameters:

  • shares: Amount of shares to withdraw

Returns:

  • withdrawn: Amount of assets received

_liquidatePosition

Liquidates position up to requested amount.

Parameters:

  • amountNeeded: Amount to liquidate

Returns:

  • liquidatedAmount: Amount actually liquidated

  • loss: Amount of losses incurred

_liquidateAllPositions

Liquidates all positions during emergency exit.

Returns:

  • amountFreed: Amount freed

_unwindRewards

Claims AJNA rewards and converts them to underlying.

Parameters:

  • _yearnStakingRewards: Staking rewards contract

Internal View Functions

_ajnaBalance

Returns strategy's AJNA token balance.

Returns:

  • Current AJNA balance

_shareBalance

Returns strategy's staked vault share balance.

Returns:

  • Current staked share balance

_shareValue

Calculates underlying value of shares including conversion rates.

Parameters:

  • shares: Share amount

Returns:

  • Underlying value

_sharesForAmount

Calculates shares needed for amount including conversion rates.

Parameters:

  • amount: Asset amount

Returns:

  • Required shares

Last updated