# CreateVaultZap

This contract is a zap for creating and setting up a vault.&#x20;

## Table of Contents

<details>

<summary>Constants</summary>

[#minimum\_inventory\_liquidity](#minimum_inventory_liquidity "mention")\
[#weth](#weth "mention")\
[#vaultfactory](#vaultfactory "mention")\
[#nftxrouter](#nftxrouter "mention")\
[#ammfactory](#ammfactory "mention")\
[#inventorystaking](#inventorystaking "mention")\
[#positionmanager](#positionmanager "mention")

</details>

<details>

<summary>Public Write Functions</summary>

[#createvault](#createvault "mention")

</details>

## Constants

#### MINIMUM\_INVENTORY\_LIQUIDITY

```solidity
uint256 internal immutable MINIMUM_INVENTORY_LIQUIDITY
```

Set to NFTX inventory staking contract's `MINIMUM_LIQUIDITY`.

#### WETH

```solidity
function WETH() external view returns (address)
```

Address of WETH contract.

#### vaultFactory

```solidity
function vaultFactory() external view returns (address)
```

Address of NFTXVaultFactoryUpgradeableV3.

#### nftxRouter

```solidity
function nftxRouter() external view returns (address)
```

Address of NFTXRouter contract.

#### ammFactory

```solidity
function ammFactory() external view returns (address)
```

Address of NFTX AMM's UniswapV3FactoryUpgradeable contract.

#### inventoryStaking

```solidity
function inventoryStaking() external view returns (address)
```

Address of NFTXInventoryStakingV3Upgradeable contract.

#### positionManager

```solidity
function positionManager() external view returns (address)
```

Address of the NFTX AMM's NonfungiblePositionManager contract.

## Write Functions

#### createVault

```solidity
function createVault(
    CreateVaultParams calldata params
) external payable returns (uint256 vaultId)
```

Sells one or more ERC721 NFTs for ETH.&#x20;

<table><thead><tr><th width="218">Parameters</th><th width="212">Type</th><th>Description</th></tr></thead><tbody><tr><td>params</td><td><code>CreateVaultParams</code></td><td>See table below.</td></tr><tr><td><code>msg.value</code></td><td><code>uint256</code></td><td>Amount of ETH to send. </td></tr></tbody></table>

<table><thead><tr><th width="214.5">CreateVaultParams</th><th width="191">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultInfo</td><td><code>VaultInfo</code></td><td>See table below.</td></tr><tr><td>eligibilityStorage</td><td><code>VaultEligibilityStorage</code></td><td>See table below.</td></tr><tr><td>nftIds</td><td><code>uint256[]</code></td><td>TokenIDs of NFTs to deposit.</td></tr><tr><td>nftAmounts</td><td><code>uint256[]</code></td><td>Amounts of NFTs.</td></tr><tr><td>vaultFeaturesFlag</td><td><code>uint256</code></td><td>Packed booleans in the order: <code>enableMint</code>, <code>enableRedeem</code>, <code>enableSwap.</code></td></tr><tr><td>vaultFees</td><td><code>VaultFees</code></td><td>See table below.</td></tr><tr><td>liquidityParams</td><td>LiquidityParams</td><td>See table below.</td></tr></tbody></table>

<table><thead><tr><th width="216">VaultInfo</th><th width="192">Type</th><th>Description</th></tr></thead><tbody><tr><td>assetAddress</td><td><code>address</code></td><td>NFT collection address.</td></tr><tr><td>is1155</td><td><code>bool</code></td><td>Whether the collection uses ERC1155.</td></tr><tr><td>allowAllItems</td><td><code>bool</code></td><td>Whether all token IDs from the collection are allowed in vault.</td></tr><tr><td>name</td><td><code>string</code></td><td>ERC20 vToken name.</td></tr><tr><td>symbol</td><td><code>string</code></td><td>ERC20 vToken symbol.</td></tr></tbody></table>

<table><thead><tr><th width="218">VaultEligibilityStorage</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>moduleIndex</td><td><code>uint256</code></td><td>Module index number.</td></tr><tr><td>initData</td><td><code>bytes</code></td><td>Module initialization data.</td></tr></tbody></table>

<table><thead><tr><th width="218">VaultFees</th><th width="195">Type</th><th>Description</th></tr></thead><tbody><tr><td>mintFee</td><td><code>uint256</code></td><td>Vault mint fee. 1e16 = 1%.</td></tr><tr><td>redeemFee</td><td><code>uint256</code></td><td>Vault redeem fee. 1e16 = 1%.</td></tr><tr><td>swapFee</td><td><code>uint256</code></td><td>Vault swap fee. 1e16 = 1%.</td></tr></tbody></table>

<table><thead><tr><th width="218">LiquidityParams</th><th width="134">Type</th><th>Description</th></tr></thead><tbody><tr><td>lowerNFTPriceInETH</td><td><code>uint256</code></td><td>Lower vToken price bound of liquidity.</td></tr><tr><td>upperNFTPriceInETH</td><td><code>uint256</code></td><td>Upper vToken price bound of liquidity.</td></tr><tr><td>fee</td><td><code>uint24</code></td><td>Fee tier of AMM pool.</td></tr><tr><td>currentNFTPriceInETH</td><td><code>uint256</code></td><td>Current vToken price. Only used if the AMM pool is new and must be initialized.</td></tr><tr><td>vTokenMin</td><td><code>uint256</code></td><td>Minimum required vToken amount to be added.</td></tr><tr><td>wethMin</td><td><code>uint256</code></td><td>Minimum required WETH amount to be added.</td></tr><tr><td>deadline</td><td><code>uint256</code></td><td>Deadline for transaction to succeed, expressed as a Unix timestamp in seconds.</td></tr></tbody></table>

<table><thead><tr><th width="218">Return values</th><th width="191">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultId</td><td><code>uint256</code></td><td>ID number of newly deployed vault.</td></tr></tbody></table>
