> For the complete documentation index, see [llms.txt](https://devs.unlockd.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devs.unlockd.finance/adapters-and-strategies/maxapystrategy.md).

# 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:

```solidity
function asset() external view returns (address)
```

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

***

```solidity
function getConfig() 
external view returns (StrategyConfig memory)
```

Returns the configuration of the MaxApy strategy.

***

```solidity
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.

***

```solidity
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:&#x20;

The amount to supply to the MaxApy Vault.

***

```solidity
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:&#x20;

The actual amount supplied to the vault.

***

```solidity
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:&#x20;

The amount to withdraw from the MaxApy Vault.

***

```solidity
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:&#x20;

The actual amount withdrawn from the vault.

***

<pre class="language-solidity"><code class="lang-solidity"><strong>function updateDeepConfig(
</strong><strong>    uint256 minAmountToInvest_, 
</strong><strong>    uint256 ratio_
</strong><strong>) external onlyAdmin
</strong></code></pre>

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.

***

```solidity
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.
