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(

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.

removeCurator

function removeCurator(

address curator

) external;

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

function addMysticPool(

address newAsset,

address oracle,

uint256 allocationPercentage,

address mysticPoolAddress

) external;

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

function updateAssetAllocation(

address updateAsset,

address mysticPoolAddress,

uint256 newAllocationPercentage

) external;

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(

address asset,

address mysticPoolAddress,

uint256 newAllocationPercentage

) external;

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(

address user) external view

returns (uint256);

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(

address owner) external view

returns (uint256);

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(

address collateralAsset,

uint256 collateralAmount,

uint256 amount,

address mysticPoolAddress,

address receiver,

bool receiveShares

) external;

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(

uint256 amount,

address receiver,

address owner

) external returns (uint256);

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(

uint256 amount,

address receiver,

address owner

) external returns (uint256);

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(

uint256 amount,

address mysticPoolAddress,

address onBehalfOf

) external;

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);

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.

Last updated