BaseYearnV3Strategy

The BaseYearnV3Strategy the contract is another specialized implementation of the BaseStrategy contract, specifically designed for interacting with Yearn V3 Vaults. Similar to the BaseSommelierStrategy, it extends the functionality of the BaseStrategy contract to handle the specific requirements of Yearn V3 Vaults.

This contract mainly aims to enable the maxAPY Protocol to invest funds in Yearn V3 Vaults and earn yield. It provides functions for depositing underlying assets into the Yearn Vault, withdrawing funds, and managing the strategy's position.

The BaseYearnV3Strategy the contract includes additional functions specific to Yearn V3 Vaults, such as setting maximum and minimum trade amounts, calculating share values, and estimating total assets.

By integrating with Yearn V3 Vaults, the BaseYearnV3Strategy the contract allows the MaxAPY Protocol to diversify its yield-generating strategies and provide users access to the benefits and opportunities offered by the Yearn ecosystem.

Functions

initialize()

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

Initializes the BaseYearnV3Strategy with the specified vault, keepers, strategy name, strategist, and Yearn V3 Vault.

Parameters:

_vault: The address of the MaxApy Vault associated with the strategy

_keepers: The addresses of the keepers to be added as valid keepers to the strategy

_strategyName: The name of the strategy

_strategist: The address of the strategist

_yVault: The address of the Yearn V3 Vault that the strategy will interact with


setMaxSingleTrade()

function setMaxSingleTrade(uint256 _maxSingleTrade) external checkRoles(ADMIN_ROLE)

Sets the maximum single trade amount allowed.

Parameters:

_maxSingleTrade: The new maximum single trade value


setMinSingleTrade()

function setMinSingleTrade(uint256 _minSingleTrade) external checkRoles(ADMIN_ROLE)

Sets the minimum single trade amount allowed.

Parameters:

_minSingleTrade: The new minimum single trade value


_invest()

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

Invests amount of underlying, depositing it in the Yearn Vault.

Parameters:

amount: The amount of underlying to be deposited in the vault

minOutputAfterInvestment: Minimum expected output after _invest() (designated in Yearn receipt tokens)

Returns:

depositedAmount: The amount of shares received, in terms of underlying


_divest()

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

Divests amount shares from Yearn Vault.

Parameters:

shares: The amount of shares to divest

Returns:

withdrawn: The total amount divested, in terms of underlying asset


_shareValue()

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

Determines the current value of shares.

Parameters:

shares: The number of shares to calculate the value for

Returns:

_assets: The estimated amount of underlying computed from the shares


_sharesForAmount()

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

Determines how many shares a depositor of amount of underlying would receive.

Parameters:

amount: The amount of underlying assets

Returns:

_shares: The estimated amount of shares computed in exchange for the underlying amount


_shareBalance()

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

Returns the current strategy's amount of Yearn vault shares.

Returns:

_balance: The strategy's balance of Yearn vault shares


_estimatedTotalAssets()

function _estimatedTotalAssets() internal view virtual override returns (uint256)

Returns the real-time estimation of the value in assets held by the strategy.

Returns:

The strategy's total assets (idle + investment positions)

Last updated