YearnAjnaWETHStakingStrategy

Overview

The YearnAjnaWETHStakingStrategy contract is a strategy that supplies WETH into a Yearn V3 Vault and stakes the vault shares to earn additional AJNA rewards. It manages the conversion of AJNA rewards back to WETH through Uniswap V3.

Constants

address public constant ajna = AJNA_MAINNET;                                   // AJNA token address
IRouter public constant router = IRouter(UNISWAP_V3_ROUTER_MAINNET);          // Uniswap V3 router
IStakingRewardsMulti public constant yearnStakingRewards =                    // Yearn staking rewards contract
    IStakingRewardsMulti(0x0Ed535037c013c3628512980C169Ed59Eb805B49);

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

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 and stakes the received shares.

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 from vault.

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

_unwindRewards

function _unwindRewards(IStakingRewardsMulti _yearnStakingRewards) internal

Claims AJNA rewards and converts them to WETH.

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

Last updated