# VaultFactory

[Git Source](https://github.com/Ion-Protocol/ion-protocol/blob/88cc595825f1dc2eb738fb93e172a3e8ab7a5c43/src/vault/VaultFactory.sol)

**Author:** Molecular Labs

Factory contract for deploying Ion Lending Vaults.

### [Functions](https://docs.ionprotocol.io/devs/smart-contract-architecture/vault/broken-reference) <a href="#functions" id="functions"></a>

#### [createVault](https://docs.ionprotocol.io/devs/smart-contract-architecture/vault/broken-reference) <a href="#createvault" id="createvault"></a>

Deploys a new Ion Lending Vault. Transfers the `initialDeposit` amount of the base asset from the caller initiate the first deposit to the vault. The minimum `initialDeposit` is 1e3. If less, this call would underflow as it will always burn 1e3 shares of the total shares minted to defend against inflation attacks.

*The 1e3 initial deposit amount was chosen to defend against inflation attacks, referencing the UniV2 LP token implementation.*

```
function createVault(
    IERC20 baseAsset,
    address feeRecipient,
    uint256 feePercentage,
    string memory name,
    string memory symbol,
    uint48 initialDelay,
    address initialDefaultAdmin,
    bytes32 salt,
    Vault.MarketsArgs memory marketsArgs,
    uint256 initialDeposit
)
    external
    returns (Vault vault);
```

**Parameters**

| Name                  | Type                | Description                                         |
| --------------------- | ------------------- | --------------------------------------------------- |
| `baseAsset`           | `IERC20`            | The asset that is being lent out to IonPools.       |
| `feeRecipient`        | `address`           | Address that receives the accrued manager fees.     |
| `feePercentage`       | `uint256`           | Fee percentage to be set.                           |
| `name`                | `string`            | Name of the vault token.                            |
| `symbol`              | `string`            | Symbol of the vault token.                          |
| `initialDelay`        | `uint48`            | The initial delay for default admin transfers.      |
| `initialDefaultAdmin` | `address`           | The initial default admin for the vault.            |
| `salt`                | `bytes32`           | The salt used for CREATE2 deployment.               |
| `marketsArgs`         | `Vault.MarketsArgs` | Arguments for the markets to be added to the vault. |
| `initialDeposit`      | `uint256`           | The initial deposit to be made to the vault.        |

### [Events](https://docs.ionprotocol.io/devs/smart-contract-architecture/vault/broken-reference) <a href="#events" id="events"></a>

#### [CreateVault](https://docs.ionprotocol.io/devs/smart-contract-architecture/vault/broken-reference) <a href="#createvault-1" id="createvault-1"></a>

```
event CreateVault(
    address vault,
    IERC20 indexed baseAsset,
    address feeRecipient,
    uint256 feePercentage,
    string name,
    string symbol,
    address indexed initialDefaultAdmin
);
```


---

# 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.ionprotocol.io/devs/smart-contract-architecture/vault/vaultfactory.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.
