IDepositVault

Git Source

Author: luoyhang003

Interface for a Deposit Vault contract that manages deposits of underlying assets and issues vault shares in return. Provides functionality to deposit, mint, preview conversions, and retrieve vault-related price information.

This interface defines the core vault operations and events to standardize how assets and shares are handled within the vault system.

Functions

deposit

Deposit an underlying asset and receive vault shares.

Equivalent to depositFor with msg.sender as receiver.

function deposit(address _asset, uint256 _amount) external returns (uint256 shares_);

Parameters

NameTypeDescription
_assetaddressAddress of the asset to deposit.
_amountuint256Amount of asset to deposit.

Returns

NameTypeDescription
shares_uint256Number of shares minted.

depositFor

Deposit an underlying asset on behalf of another account.

Reverts if receiver is zero address.

function depositFor(address _asset, uint256 _amount, address _receiver) external returns (uint256 shares_);

Parameters

NameTypeDescription
_assetaddressAddress of the asset to deposit.
_amountuint256Amount of asset to deposit.
_receiveraddressRecipient of the minted shares.

Returns

NameTypeDescription
shares_uint256Number of shares minted.

mint

Mint a specific number of shares by depositing assets.

Equivalent to mintFor with msg.sender as receiver.

function mint(address _asset, uint256 _shares) external returns (uint256 assets_);

Parameters

NameTypeDescription
_assetaddressAddress of the asset to deposit.
_sharesuint256Number of shares to mint.

Returns

NameTypeDescription
assets_uint256Amount of assets required.

mintFor

Mint a specific number of shares on behalf of another account.

Reverts if receiver is zero address.

function mintFor(address _asset, uint256 _shares, address _receiver) external returns (uint256 assets_);

Parameters

NameTypeDescription
_assetaddressAddress of the asset to deposit.
_sharesuint256Number of shares to mint.
_receiveraddressRecipient of the minted shares.

Returns

NameTypeDescription
assets_uint256Amount of assets required.

exchangePrice

Returns the cutoff vault token price (e.g. for settlement).

Fetches the cutoff price directly from the oracle register.

function exchangePrice() external view returns (uint256 price_);

Returns

NameTypeDescription
price_uint256Current vault token cutoff price.

convertToShares

Converts underlying assets to equivalent vault shares.

Normalizes _amount to 18 decimals before conversion. Uses floor rounding to avoid overestimating shares.

function convertToShares(address _asset, uint256 _amount)
    external
    view
    returns (uint256 shares_, uint256 underlyingPrice_, uint256 vaultTokenPrice_);

Parameters

NameTypeDescription
_assetaddressAddress of the underlying asset.
_amountuint256Amount of underlying asset.

Returns

NameTypeDescription
shares_uint256Equivalent vault shares.
underlyingPrice_uint256Price of the underlying asset.
vaultTokenPrice_uint256Price of the vault token.

convertToAssets

Converts vault shares to equivalent underlying assets.

Denormalizes values back from 18 decimals to asset decimals. Uses floor rounding to avoid overestimating asset returns.

function convertToAssets(address _asset, uint256 _shares)
    external
    view
    returns (uint256 assets_, uint256 underlyingPrice_, uint256 vaultTokenPrice_);

Parameters

NameTypeDescription
_assetaddressAddress of the underlying asset.
_sharesuint256Number of vault shares.

Returns

NameTypeDescription
assets_uint256Equivalent underlying asset amount.
underlyingPrice_uint256Price of the underlying asset.
vaultTokenPrice_uint256Price of the vault token.

previewDeposit

Previews deposit outcome including shares, fee, and prices.

Simulates deposit logic without state changes. Performs fee deduction, cap checks, and price fetches.

function previewDeposit(address _asset, uint256 _amount)
    external
    view
    returns (uint256 shares_, uint256 fee_, uint256 underlyingPrice_, uint256 vaultTokenPrice_);

Parameters

NameTypeDescription
_assetaddressAddress of the underlying asset.
_amountuint256Deposit amount.

Returns

NameTypeDescription
shares_uint256Number of shares minted.
fee_uint256Fee charged on deposit.
underlyingPrice_uint256Price of the underlying asset.
vaultTokenPrice_uint256Price of the vault token.

previewMint

Previews mint outcome including assets, fee, and prices.

Simulates mint logic without state changes. Performs fee addition, cap checks, and price fetches.

function previewMint(address _asset, uint256 _shares)
    external
    view
    returns (uint256 assets_, uint256 fee_, uint256 underlyingPrice_, uint256 vaultTokenPrice_);

Parameters

NameTypeDescription
_assetaddressAddress of the underlying asset.
_sharesuint256Number of shares to mint.

Returns

NameTypeDescription
assets_uint256Required underlying assets.
fee_uint256Fee charged on mint.
underlyingPrice_uint256Price of the underlying asset.
vaultTokenPrice_uint256Price of the vault token.

getUnderlyings

Returns list of all supported underlying assets.

Returns storage array directly; use cautiously in gas-sensitive contexts.

function getUnderlyings() external view returns (address[] memory underlyings);

Returns

NameTypeDescription
underlyingsaddress[]Array of supported assets.

Events

Deposit

Emitted when a deposit is made into the vault.

event Deposit(
    address indexed asset, uint256 amount, uint256 shares, uint256 fee, uint256 underlyingPrice, uint256 vaultTokenPrice
);

Parameters

NameTypeDescription
assetaddressThe address of the underlying asset being deposited.
amountuint256The amount of the underlying asset deposited.
sharesuint256The number of vault shares minted for the deposit.
feeuint256The fee charged during the deposit (if any).
underlyingPriceuint256The price of the underlying asset at the time of deposit.
vaultTokenPriceuint256The exchange rate of vault shares at the time of deposit.

UnderlyingAssetAdded

Emitted when a new underlying asset is added to the vault.

event UnderlyingAssetAdded(address asset);

Parameters

NameTypeDescription
assetaddressThe address of the underlying asset added.

UnderlyingAssetRemoved

Emitted when an underlying asset is removed from the vault.

event UnderlyingAssetRemoved(address asset);

Parameters

NameTypeDescription
assetaddressThe address of the underlying asset removed.

SetAssetsRouter

Emitted when the assets router is updated.

event SetAssetsRouter(address oldRouter, address newRouter);

Parameters

NameTypeDescription
oldRouteraddressThe address of the old assets router.
newRouteraddressThe address of the new assets router.