IDepositVault
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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the asset to deposit. |
_amount | uint256 | Amount of asset to deposit. |
Returns
| Name | Type | Description |
|---|---|---|
shares_ | uint256 | Number 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the asset to deposit. |
_amount | uint256 | Amount of asset to deposit. |
_receiver | address | Recipient of the minted shares. |
Returns
| Name | Type | Description |
|---|---|---|
shares_ | uint256 | Number 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the asset to deposit. |
_shares | uint256 | Number of shares to mint. |
Returns
| Name | Type | Description |
|---|---|---|
assets_ | uint256 | Amount 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the asset to deposit. |
_shares | uint256 | Number of shares to mint. |
_receiver | address | Recipient of the minted shares. |
Returns
| Name | Type | Description |
|---|---|---|
assets_ | uint256 | Amount 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
| Name | Type | Description |
|---|---|---|
price_ | uint256 | Current 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the underlying asset. |
_amount | uint256 | Amount of underlying asset. |
Returns
| Name | Type | Description |
|---|---|---|
shares_ | uint256 | Equivalent vault shares. |
underlyingPrice_ | uint256 | Price of the underlying asset. |
vaultTokenPrice_ | uint256 | Price 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the underlying asset. |
_shares | uint256 | Number of vault shares. |
Returns
| Name | Type | Description |
|---|---|---|
assets_ | uint256 | Equivalent underlying asset amount. |
underlyingPrice_ | uint256 | Price of the underlying asset. |
vaultTokenPrice_ | uint256 | Price 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the underlying asset. |
_amount | uint256 | Deposit amount. |
Returns
| Name | Type | Description |
|---|---|---|
shares_ | uint256 | Number of shares minted. |
fee_ | uint256 | Fee charged on deposit. |
underlyingPrice_ | uint256 | Price of the underlying asset. |
vaultTokenPrice_ | uint256 | Price 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
| Name | Type | Description |
|---|---|---|
_asset | address | Address of the underlying asset. |
_shares | uint256 | Number of shares to mint. |
Returns
| Name | Type | Description |
|---|---|---|
assets_ | uint256 | Required underlying assets. |
fee_ | uint256 | Fee charged on mint. |
underlyingPrice_ | uint256 | Price of the underlying asset. |
vaultTokenPrice_ | uint256 | Price 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
| Name | Type | Description |
|---|---|---|
underlyings | address[] | 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
| Name | Type | Description |
|---|---|---|
asset | address | The address of the underlying asset being deposited. |
amount | uint256 | The amount of the underlying asset deposited. |
shares | uint256 | The number of vault shares minted for the deposit. |
fee | uint256 | The fee charged during the deposit (if any). |
underlyingPrice | uint256 | The price of the underlying asset at the time of deposit. |
vaultTokenPrice | uint256 | The 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
| Name | Type | Description |
|---|---|---|
asset | address | The address of the underlying asset added. |
UnderlyingAssetRemoved
Emitted when an underlying asset is removed from the vault.
event UnderlyingAssetRemoved(address asset);
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The address of the underlying asset removed. |
SetAssetsRouter
Emitted when the assets router is updated.
event SetAssetsRouter(address oldRouter, address newRouter);
Parameters
| Name | Type | Description |
|---|---|---|
oldRouter | address | The address of the old assets router. |
newRouter | address | The address of the new assets router. |