> ## Documentation Index
> Fetch the complete documentation index at: https://omo-89a50a4e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Omo Beacon Vault Factory

> Overview of the Omo Beacon Vault Factory contract for creating and managing Omo Beacon Vaults

> [tab] Overview
>
> # Omo Beacon Vault Factory
>
> The Omo Beacon Vault Factory contract is a crucial component of the Omo Protocol, responsible for creating and managing instances of OmoBeaconVault. This factory pattern allows for efficient deployment and tracking of multiple beacon vaults within the ecosystem.
>
> ## Key Features
>
> > [accordion] Beacon Vault Creation
> >
> > The primary function of Omo Beacon Vault Factory is to create new OmoBeaconVault instances. It provides a streamlined process for deploying vaults with custom parameters.
> >
> > * Users can specify the vault asset, name, and symbol
> > * Each new vault is associated with an AgentSetter
> > * Newly created beacon vaults are automatically tracked within the factory
>
> > [accordion] Beacon Vault Management
> >
> > Omo Beacon Vault Factory maintains a registry of all created beacon vaults, enabling easy access and management.
> >
> > * Keeps an array of all deployed beacon vault addresses
> > * Provides functions to query the total number of vaults and access individual vault addresses
>
> > [accordion] Event Emission
> >
> > The contract emits events to provide transparency and enable off-chain tracking of beacon vault creation.
> >
> > * VaultCreated event is emitted upon successful beacon vault deployment
> > * Event includes the new vault's address, owner, and vault asset address
>
> ## Beacon Vault Creation Process
>
> ![Omo Beacon Vault Factory Workflow](https://mintcdn.com/omo-89a50a4e/ycZMjmbgDP3Seizg/diagrams/omobeaconvaultfactory.svg?fit=max\&auto=format\&n=ycZMjmbgDP3Seizg\&q=85\&s=7dedf8d7b49f1026beda79b4dfa03400)
>
> Omo Beacon Vault Factory Workflow
>
> **1. User Calls createVault**
>
> A user calls the `createVault` function with the required parameters.
>
> **2. Deploy New OmoBeaconVault**
>
> Omo Beacon Vault Factory deploys a new `OmoBeaconVault` instance with the
> specified parameters.
>
> **3. Add to Vaults Array**
>
> The new beacon vault address is added to the internal `vaults` array.
>
> **4. Emit VaultCreated Event**
>
> A `VaultCreated` event is emitted with the details of the new beacon vault.
>
> **5. Return New Vault Address**
>
> The address of the newly created beacon vault is returned to the caller.
>
> ## Usage and Integration
>
> The Omo Beacon Vault Factory contract serves as the entry point for users and protocols looking to create customized Omo Beacon Vaults. It ensures consistency in vault deployment and provides a central registry for all Omo Beacon Vaults in the ecosystem.
>
> > [!NOTE]
> >
> > While the Omo Beacon Vault Factory simplifies beacon vault creation, users
> > should ensure they understand the parameters and implications of creating a
> > new vault before proceeding.

> [tab] Advanced
>
> # OmoBeaconVaultFactory.sol
>
> ## Overview
>
> OmoBeaconVaultFactory is a contract responsible for deploying and managing OmoBeaconVault instances. It allows for the creation of new vaults with specific parameters and keeps track of all deployed vaults.
>
> ## Key Components
>
> ### State Variables
>
> 1. `address[] public vaults`: An array storing addresses of all deployed OmoBeaconVault instances.
> 2. `mapping(address => bool) public isVault`: A mapping to quickly check if an address is a deployed vault.
> 3. `address public immutable agentSetter`: The address of the AgentSetter contract used for all vaults.
>
> ### Events
>
> 1. `VaultCreated(address indexed vault, address indexed asset, string name, string symbol)`
>
> ### Custom Errors
>
> 1. `InvalidAsset(address asset)`
> 2. `InvalidName(string name)`
> 3. `InvalidSymbol(string symbol)`
>
> ## Functions
>
> ### Constructor
>
> ```solidity theme={null}
> constructor(address _agentSetter)
> ```
>
> | Name | Type | Description |
> | - | - | - |
> | \_agentSetter | address | Address of the AgentSetter contract |
>
> Initializes the factory with the address of the AgentSetter contract.
>
> ### createVault
>
> ```solidity theme={null}
> function createVault(
>     address asset,
>     string memory name,
>     string memory symbol
> ) external returns (address)
> ```
>
> | Name | Type | Description |
> | - | - | - |
> | asset | address | Address of the underlying asset token |
> | name | string | Name of the new vault |
> | symbol | string | Symbol of the new vault |
>
> Creates a new OmoBeaconVault instance. Requirements:
>
> * `asset` must be a valid ERC20 token address
> * `name` and `symbol` must not be empty
>   Returns the address of the newly created vault.
>
> ### getVaults
>
> ```solidity theme={null}
> function getVaults() external view returns (address[] memory)
> ```
>
> Returns an array of all deployed vault addresses.
>
> ### getVaultCount
>
> ```solidity theme={null}
> function getVaultCount() external view returns (uint256)
> ```
>
> Returns the total number of deployed vaults.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.