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

constructor() initializer

Empty constructor marked as initializer.

Initialization Functions

initialize

function initialize(
    IMaxApyVault _vault,
    address[] calldata _keepers,
    bytes32 _strategyName,
    address _strategist,
    IYVaultV3 _yVault
) public 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 V3 vault address

Core Functions

liquidateExact

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

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

Parameters:

  • amountNeeded: Amount to withdraw

Returns:

  • loss: Amount of realized loss

maxLiquidateExact

function maxLiquidateExact() public view virtual override returns (uint256)

Returns maximum withdrawable amount before losses.

Returns:

  • Maximum withdrawable amount

Internal Core Functions

_beforePrepareReturn

function _beforePrepareReturn() internal override

Claims and processes staking rewards before preparing return.

_invest

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

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

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

Unstakes and withdraws assets, converting back to underlying.

Parameters:

  • shares: Amount of shares to withdraw

Returns:

  • withdrawn: Amount of assets received

_liquidatePosition

function _liquidatePosition(uint256 amountNeeded) internal override returns (uint256 liquidatedAmount, uint256 loss)

Liquidates position up to requested amount.

Parameters:

  • amountNeeded: Amount to liquidate

Returns:

  • liquidatedAmount: Amount actually liquidated

  • loss: Amount of losses incurred

_liquidateAllPositions

function _liquidateAllPositions() internal override returns (uint256 amountFreed)

Liquidates all positions during emergency exit.

Returns:

  • amountFreed: Amount freed

_unwindRewards

function _unwindRewards(IStakingRewardsMulti _yearnStakingRewards) internal

Claims AJNA rewards and converts them to underlying.

Parameters:

  • _yearnStakingRewards: Staking rewards contract

Internal View Functions

_ajnaBalance

function _ajnaBalance() internal view returns (uint256)

Returns strategy's AJNA token balance.

Returns:

  • Current AJNA balance

_shareBalance

function _shareBalance() internal view override returns (uint256 _balance)

Returns strategy's staked vault share balance.

Returns:

  • Current staked share balance

_shareValue

function _shareValue(uint256 shares) internal view override returns (uint256)

Calculates underlying value of shares including conversion rates.

Parameters:

  • shares: Share amount

Returns:

  • Underlying value

_sharesForAmount

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

Calculates shares needed for amount including conversion rates.

Parameters:

  • amount: Asset amount

Returns:

  • Required shares

Last updated