MaxApyStrategy

MaxApyStrategy.sol is a contract that defines a strategy for managing funds and interacting with the MaxApy Vault within the Unlockd Protocol. It implements the IStrategy interface and provides functions for supplying funds to the MaxApy Vault, withdrawing funds from the vault, and calculating the optimal investment amount based on the strategy's configuration.

Key functions:

function asset() external view returns (address)

Returns the address of the underlying asset managed by the strategy.


function getConfig() 
external view returns (StrategyConfig memory)

Returns the configuration of the MaxApy strategy.


function balanceOf(address owner) 
external view returns (uint256)

Returns the balance of the specified owner in the MaxApy Vault.

Parameters:

owner: The address of the owner.


function calculateAmountToSupply(
    uint256 totalSupplyNotInvested, 
    address from_, 
    uint256 amount_
) external view returns (uint256)

Calculates the amount to supply to the MaxApy Vault based on the current state.

Parameters:

totalSupplyNotInvested: The total supply not invested in the vault.

from_: The address supplying the funds.

amount_: The amount being supplied.

Returns:

The amount to supply to the MaxApy Vault.


function supply(
    address vault_, 
    address asset_, 
    address from_, 
    uint256 amount_
) external returns (uint256)

Supplies funds to the MaxApy Vault.

Parameters:

vault_: The address of the MaxApy Vault.

asset_: The address of the asset being supplied.

from_: The address supplying the funds.

amount_: The amount being supplied.

Returns:

The actual amount supplied to the vault.


function calculateAmountToWithdraw(
    uint256 totalSupplyNotInvested_, 
    address from_, 
    uint256 amount_
) external view returns (uint256)

Calculates the amount to withdraw from the MaxApy Vault based on the current state.

Parameters:

totalSupplyNotInvested_: The total supply not invested in the vault.

from_: The address withdrawing the funds.

amount_: The amount being withdrawn.

Returns:

The amount to withdraw from the MaxApy Vault.


function withdraw(
    address vault_, 
    address to_, 
    uint256 amount_
) external returns (uint256)

Withdraws funds from the MaxApy Vault.

Parameters:

vault_: The address of the MaxApy Vault.

to_: The address to receive the withdrawn funds.

amount_: The amount being withdrawn.

Returns:

The actual amount withdrawn from the vault.


function updateDeepConfig(
    uint256 minAmountToInvest_, 
    uint256 ratio_
) external onlyAdmin

Updates the deep configuration of the strategy.

Parameters:

minAmountToInvest_: The minimum amount to invest in the MaxApy Vault.

ratio_: The ratio used for calculating the amount to withdraw.

Only callable by the admin role.


function updateStrategyConfig(
    uint256 minCap_, 
    uint256 percentageToInvest_
) external onlyAdmin

Updates the strategy configuration.

Parameters:

minCap_: The minimum cap for the strategy.

percentageToInvest_: The percentage of funds to invest in the MaxApy Vault.

Only callable by the admin role.

Last updated