# Vaults (coming soon)

## Introduction

The `MysticVaults` contract is a core component of the Mystic Finance protocol, designed to manage asset allocation across multiple pools, as well as handle user deposits, withdrawals, and borrowing. Curators, who are responsible for optimizing liquidity, can add or remove assets and pools, adjust allocations, and manage liquidity flows in vaults.

The contract interacts with the Mystic `Pools` to support various liquidity strategies and complies with the ERC4626 standard for vaults, allowing seamless integrations with other DeFi protocols.

## Methods

### **addCurator**

`function addCurator(`

&#x20;   `address curator`

`) external;`

Curators in `MysticVaults` have the authority to manage assets, reallocate resources, and update pool configurations. These curators ensure that the vault’s allocations are optimized for risk-adjusted returns. This method adds a new curator who can manage asset allocations.

Input Parameters:

| Name    | Type    | Description                                                                                                          |
| ------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
| curator | address | The address of the curator to be added. This address will gain the right to modify allocations and manage the vault. |

&#x20;

### **removeCurator**

`function removeCurator(`

&#x20;   `address curator`

`) external;`<br>

This method removes an existing curator and prevents them from managing the vault.

Input Parameters:

| Name    | Type    | Description                               |
| ------- | ------- | ----------------------------------------- |
| curator | address | The address of the curator to be removed. |

### **addMysticPool**<br>

`function addMysticPool(`

&#x20;   `address newAsset,`&#x20;

&#x20;   `address oracle,`&#x20;

&#x20;   `uint256 allocationPercentage,`&#x20;

&#x20;   `address mysticPoolAddress`

`) external;`<br>

This method adds a new Mystic Pool to the vault's portfolio.

Input Parameters:

| Name                 | Type    | Description                                                               |
| -------------------- | ------- | ------------------------------------------------------------------------- |
| newAsset             | address | The address of the new asset that will be allocated to this pool.         |
| oracle               | address | The address of the oracle that provides price data for the new asset.     |
| allocationPercentage | uint256 | The percentage of the vault’s assets that will be allocated to this pool. |
| mysticPoolAddress    | address | The address of the Mystic Pool to which the new asset will be allocated.  |

### **updateAssetAllocation**<br>

`function updateAssetAllocation(`

&#x20;   `address updateAsset,`&#x20;

&#x20;   `address mysticPoolAddress,`&#x20;

&#x20;   `uint256 newAllocationPercentage`

`) external;`<br>

This method updates the asset allocation for a specific pool.

Input Parameters:

| Name                    | Type    | Description                                                                  |
| ----------------------- | ------- | ---------------------------------------------------------------------------- |
| updateAsset             | address | The address of the asset to be reallocated.                                  |
| mysticPoolAddress       | address | The address of the pool for which the allocation will be updated.            |
| newAllocationPercentage | uint256 | The new percentage of the total assets to be allocated to the updated asset. |

### **reallocate**

`function reallocate(`

&#x20;   `address asset,`&#x20;

&#x20;   `address mysticPoolAddress,`&#x20;

&#x20;   `uint256 newAllocationPercentage`

`) external;`<br>

This method rebalances assets deposited between Mystic Pools.

Input Parameters:

| Name                    | Type    | Description                                                        |
| ----------------------- | ------- | ------------------------------------------------------------------ |
| asset                   | address | The address of the asset being reallocated.                        |
| mysticPoolAddress       | address | The address of the pool where the asset will be reallocated.       |
| newAllocationPercentage | uint256 | The new allocation percentage for the asset in the specified pool. |

### **maxDeposit**

`function maxDeposit(`

&#x20;   `address user) external view`

`returns (uint256);`<br>

This method returns the maximum amount a user can deposit in the vault.

Input Parameters:

| Name | Type    | Description                                    |
| ---- | ------- | ---------------------------------------------- |
| user | address | The address of the user attempting to deposit. |

### **maxWithdrawal**

`function maxWithdrawal(`

&#x20;   `address owner) external view`

`returns (uint256);`<br>

This method returns the maximum amount a user can withdraw from the vault.

Input Parameters:

| Name  | Type    | Description                                     |
| ----- | ------- | ----------------------------------------------- |
| owner | address | The address of the user attempting to withdraw. |

### **borrow**

`function borrow(`

&#x20;   `address collateralAsset,`&#x20;

&#x20;   `uint256 collateralAmount,`&#x20;

&#x20;   `uint256 amount,`&#x20;

&#x20;   `address mysticPoolAddress,`&#x20;

&#x20;   `address receiver,`&#x20;

&#x20;   `bool receiveShares`

`) external;`<br>

This method allows users to borrow against their collateral from a specific Mystic Pool.

Input Parameters:

| Name              | Type    | Description                                                                               |
| ----------------- | ------- | ----------------------------------------------------------------------------------------- |
| collateralAsset   | address | The address of the asset being used as collateral for the loan.                           |
| collateralAmount  | uint256 | The amount of the collateral asset to lock.                                               |
| amount            | uint256 | The amount of the asset to be borrowed.                                                   |
| mysticPoolAddress | address | The address of the Mystic Pool from which the asset will be borrowed.                     |
| receiver          | address | The address that will receive the borrowed asset.                                         |
| receiveShares     | bool    | Indicates whether the borrower wants to receive the vault shares or the underlying asset. |

### **withdraw**

`function withdraw(`

&#x20;   `uint256 amount,`&#x20;

&#x20;   `address receiver,`&#x20;

&#x20;   `address owner`

`) external returns (uint256);`<br>

This method withdraws a specified amount of assets from the vault.

Input Parameters:

| Name     | Type    | Description                                                     |
| -------- | ------- | --------------------------------------------------------------- |
| amount   | uint256 | The amount of the asset to be withdrawn.                        |
| receiver | address | The address that will receive the withdrawn asset.              |
| owner    | address | The address of the user withdrawing their asset from the vault. |

### **redeem**

`function redeem(`

&#x20;   `uint256 amount,`&#x20;

&#x20;   `address receiver,`&#x20;

&#x20;   `address owner`

`) external returns (uint256);`<br>

Redeems a specified amount of assets from the vault in exchange for vault tokens.

Input Parameters:

| Name     | Type    | Description                                       |
| -------- | ------- | ------------------------------------------------- |
| amount   | uint256 | The amount of the asset to redeem.                |
| receiver | address | The address that will receive the redeemed asset. |
| owner    | address | The address of the user redeeming the asset.      |

### **requestWithdrawal**

`function requestWithdrawal(`

`uint256 assets`

`) external;`

This method allows users to request a withdrawal, which is queued for processing.

Input Parameters:

| Name   | Type    | Description                                       |
| ------ | ------- | ------------------------------------------------- |
| assets | uint256 | The amount of assets the user wishes to withdraw. |

### **repay**

`function repay(`

&#x20;   `uint256 amount,`&#x20;

&#x20;   `address mysticPoolAddress,`&#x20;

&#x20;   `address onBehalfOf`

`) external;`

<br>

Repays a borrowed amount on behalf of a user, reducing their outstanding debt.

Input Parameters:

| Name              | Type    | Description                                               |
| ----------------- | ------- | --------------------------------------------------------- |
| amount            | uint256 | The amount to repay.                                      |
| mysticPoolAddress | address | The address of the pool from which the debt was borrowed. |
| onBehalfOf        | address | The address of the borrower whose debt is being repaid.   |

### **totalAssets**

`function totalAssets(`

`) external view returns (uint256);`

<br>

Returns the total amount of assets currently held in the vault.

### **totalAssetsInUsd**

`function totalAssetsInUsd(`

`) external view returns (uint256);`

Returns the total value of the assets in USD, based on the latest price data from oracles.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mysticfinance.xyz/contracts/vaults-coming-soon.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
