# AlphaProVaultFactory

### createVault <a href="#createpool" id="createpool"></a>

{% code fullWidth="false" %}

```solidity
function createVault(
  VaultParams calldata params,
) external returns (address vaultAddress)
```

{% endcode %}

Creates a vault for a given set of vault parameters.

#### Parameters:

<table><thead><tr><th width="146.33333333333331">Varible</th><th width="170">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>params</code></td><td>VaultParams</td><td>The custom data structure containing the  <a href="/pages/aEo9rKIix4wDtKy2SwLF">Vault Parameters'</a> variables and assigned values.</td></tr></tbody></table>

#### Returns:

<table><thead><tr><th width="188.33333333333331">Variable</th><th width="125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>vaultAddress</code></td><td>address</td><td>The address of the new vault after it is created.</td></tr></tbody></table>

### numVaults

{% code fullWidth="false" %}

```solidity
function numVaults() external view returns (uint256)
```

{% endcode %}

#### Return Value:

<table><thead><tr><th width="188.33333333333331">Variable</th><th width="178">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>vaults.length</code></td><td>uint256</td><td>The number of vaults created by the factory.</td></tr></tbody></table>

### setProtocolFee

{% code fullWidth="false" %}

```solidity
function setProtocolFee(uint256 _protocolFee) external onlyGovernance
```

{% endcode %}

Sets the protocol fee as a % of fees received from Uniswap. Can only be called by Charm Governance.

#### Parameters:

<table><thead><tr><th width="188.33333333333331">Variale</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td><pre><code>_protocolFee
</code></pre></td><td>uint256</td><td><p>The amount of protocol fees as a % of fees earned by the vault, with 1 unit of fees = 1e-4 % of fees earned.</p><p></p><p>The maximum protocol fee is 20000 units (20%).</p></td></tr></tbody></table>

### setGovernance

```solidity
function setGovernance(address _governance) external onlyGovernance
```

The first step to change the address of Charm Governance. Can only called by Charm Governance.

#### Parameters:

<table><thead><tr><th width="222.33333333333331">Variable</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td><pre><code>_governance
</code></pre></td><td>address</td><td>The new address of Charm Governance. The changes will not take effect until the new address calls <a href="/pages/1tEAYS1RCAyqaq2OzBUQ#acceptgovernance"><code>accepGovernance</code></a></td></tr></tbody></table>

### acceptGovernance

```solidity
function acceptGovernance() external
```

The second step to to change the address of Charm Governance. Can only be called by the address assigned to `_governance`.

#### State Changes:

<table data-full-width="false"><thead><tr><th width="188">Variable</th><th width="176">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>governance</code></td><td>address</td><td>Setting the value of <code>_governance</code> as the new Charm Governance address.</td></tr></tbody></table>

### **Getter functions for public variables**

Getter functions are automatically generated for the following public variables:

<table data-full-width="false"><thead><tr><th width="238">Variable</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>template</code></td><td>address</td><td>The address of the template vault used by <a href="/pages/1tEAYS1RCAyqaq2OzBUQ#createpool">createVault</a> to clone and create LP vaults.</td></tr><tr><td><code>vaults</code></td><td>array</td><td>The array that contains the address of all the vaults created by Alpha Vaults.</td></tr><tr><td><code>isVault</code></td><td>mapping</td><td>The mapping used to check whether a vault have been created by Alpha Vaults.</td></tr><tr><td><code>governance</code></td><td>address</td><td>The address of Charm Governance.</td></tr><tr><td><code>pendingGovernance</code></td><td>address</td><td>The provisional address of Charm Governance. Not finalised until it calls calls <a href="/pages/1tEAYS1RCAyqaq2OzBUQ#acceptgovernance"><code>accepGovernanc</code></a></td></tr><tr><td><code>protocolFee</code></td><td>uint256</td><td>The protocol fee applied to all vaults created using Alpha Vaults.</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://learn.charm.fi/charm/technical-references/core/alphaprovaultfactory.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.
