# General ERC-4626 Vault Interface

Generic interface for [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) vaults.

## Contract Interface

### Events

#### Deposit

```solidity
event Deposit(address sender, address receiver, uint256 assets, uint256 shares)
```

#### Withdraw

```solidity
event Withdraw(address sender, address receiver, address owner, uint256 assets, uint256 shares)
```

### Functions

#### asset

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

The address of the underlying token used by the Vault for valuing, depositing, and withdrawing.

#### totalAssets

```solidity
function totalAssets() external view returns (uint256 totalManagedAssets)
```

Total amount of the underlying asset that is “managed” by vault.

#### convertToShares

```solidity
function convertToShares(uint256 assets) external view returns (uint256 shares)
```

The amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.

**Parameters**

<table><thead><tr><th width="101.33333333333331">Name</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets to be convert to vault shares.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="118.33333333333331">Name</th><th width="97">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares converted from the underlying assets.</td></tr></tbody></table>

#### convertToAssets

```solidity
function convertToAssets(uint256 shares) external view returns (uint256 assets)
```

The amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.

**Parameters**

<table><thead><tr><th width="106.33333333333331">Name</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares to be converted to the underlying assets.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="106.33333333333331">Name</th><th width="94">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets converted from the vault shares.</td></tr></tbody></table>

#### maxDeposit

```solidity
function maxDeposit(address caller) external view returns (uint256 maxAssets)
```

The maximum number of underlying assets that caller can deposit.

**Parameters**

<table><thead><tr><th width="107.33333333333331">Name</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>caller</td><td>address</td><td>Account that the assets will be transferred from.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="132.33333333333331">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td>maxAssets</td><td>uint256</td><td>The maximum amount of underlying assets the caller can deposit.</td></tr></tbody></table>

#### previewDeposit

```solidity
function previewDeposit(uint256 assets) external view returns (uint256 shares)
```

Allows an on-chain or off-chain user to simulate the effects of their deposit at the current transaction, given current on-chain conditions.

**Parameters**

<table><thead><tr><th width="106.33333333333331">Name</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets to be transferred.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="115.33333333333331">Name</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares that will be minted.</td></tr></tbody></table>

#### deposit

```solidity
function deposit(uint256 assets, address receiver) external returns (uint256 shares)
```

Mint vault shares to receiver by transferring exact amount of underlying asset tokens from the caller.

**Parameters**

<table><thead><tr><th width="123.33333333333331">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets to be transferred to the vault.</td></tr><tr><td>receiver</td><td>address</td><td>The account that the vault shares will be minted to.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="125.33333333333331">Name</th><th width="126">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares that were minted.</td></tr></tbody></table>

#### maxMint

```solidity
function maxMint(address caller) external view returns (uint256 maxShares)
```

The maximum number of vault shares that caller can mint.

**Parameters**

<table><thead><tr><th width="127.33333333333331">Name</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td>caller</td><td>address</td><td>Account that the underlying assets will be transferred from.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="136.33333333333331">Name</th><th>Type</th><th width="502.66666666666674">Description</th></tr></thead><tbody><tr><td>maxShares</td><td>uint256</td><td>The maximum amount of vault shares the caller can mint.</td></tr></tbody></table>

#### previewMint

```solidity
function previewMint(uint256 shares) external view returns (uint256 assets)
```

Allows an on-chain or off-chain user to simulate the effects of their mint at the current transaction, given current on-chain conditions.

**Parameters**

<table><thead><tr><th width="118.33333333333331">Name</th><th width="91">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares to be minted.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="112.33333333333331">Name</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assests that will be transferred from the caller.</td></tr></tbody></table>

#### mint

```solidity
function mint(uint256 shares, address receiver) external returns (uint256 assets)
```

Mint exact amount of vault shares to the receiver by transferring enough underlying asset tokens from the caller.

**Parameters**

<table><thead><tr><th width="121.33333333333331">Name</th><th width="94">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares to be minted.</td></tr><tr><td>receiver</td><td>address</td><td>The account the vault shares will be minted to.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="106.33333333333331">Name</th><th width="94">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets that were transferred from the caller.</td></tr></tbody></table>

#### maxWithdraw

```solidity
function maxWithdraw(address owner) external view returns (uint256 maxAssets)
```

The maximum number of underlying assets that owner can withdraw.

**Parameters**

<table><thead><tr><th width="141.33333333333331">Name</th><th width="138">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>address</td><td>Account that owns the vault shares.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="137.33333333333331">Name</th><th width="105">Type</th><th>Description</th></tr></thead><tbody><tr><td>maxAssets</td><td>uint256</td><td>The maximum amount of underlying assets the owner can withdraw.</td></tr></tbody></table>

#### previewWithdraw

```solidity
function previewWithdraw(uint256 assets) external view returns (uint256 shares)
```

Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current transaction, given current on-chain conditions.

**Parameters**

<table><thead><tr><th width="124.33333333333331">Name</th><th width="114">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets to be withdrawn.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="120.33333333333331">Name</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares that will be burnt.</td></tr></tbody></table>

#### withdraw

```solidity
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares)
```

Burns enough vault shares from owner and transfers the exact amount of underlying asset tokens to the receiver.

**Parameters**

<table><thead><tr><th width="113.33333333333331">Name</th><th width="112">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets to be withdrawn from the vault.</td></tr><tr><td>receiver</td><td>address</td><td>The account that the underlying assets will be transferred to.</td></tr><tr><td>owner</td><td>address</td><td>Account that owns the vault shares to be burnt.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="122.33333333333331">Name</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares that were burnt.</td></tr></tbody></table>

#### maxRedeem

```solidity
function maxRedeem(address owner) external view returns (uint256 maxShares)
```

The maximum number of shares an owner can redeem for underlying assets.

**Parameters**

<table><thead><tr><th width="129.33333333333331">Name</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>address</td><td>Account that owns the vault shares.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="141.33333333333331">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td>maxShares</td><td>uint256</td><td>The maximum amount of shares the owner can redeem.</td></tr></tbody></table>

#### previewRedeem

```solidity
function previewRedeem(uint256 shares) external view returns (uint256 assets)
```

Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current transaction, given current on-chain conditions.

**Parameters**

<table><thead><tr><th width="115.33333333333331">Name</th><th width="97">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares to be burnt.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="108.33333333333331">Name</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assests that will transferred to the receiver.</td></tr></tbody></table>

#### redeem

```solidity
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets)
```

Burns exact amount of vault shares from owner and transfers the underlying asset tokens to the receiver.

**Parameters**

<table><thead><tr><th width="121.33333333333331">Name</th><th width="104">Type</th><th>Description</th></tr></thead><tbody><tr><td>shares</td><td>uint256</td><td>The amount of vault shares to be burnt.</td></tr><tr><td>receiver</td><td>address</td><td>The account the underlying assets will be transferred to.</td></tr><tr><td>owner</td><td>address</td><td>The account that owns the vault shares to be burnt.</td></tr></tbody></table>

**Return Values**

<table><thead><tr><th width="104.33333333333331">Name</th><th width="97">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>uint256</td><td>The amount of underlying assets that were transferred to the receiver.</td></tr></tbody></table>


---

# 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://developers.mstable.org/meta-vaults/general-erc-4626-vault-interface.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.
