# MigratorZap

Migrates positions from NFTX V2 to V3.

## Table of Contents

<details>

<summary>Constants</summary>

[#deadline](#deadline "mention")\
[#dust\_threshold](#dust_threshold "mention")\
[#weth](#weth "mention")\
[#v2nftxfactory](#v2nftxfactory "mention")\
[#v2inventory](#v2inventory "mention")\
[#sushirouter](#sushirouter "mention")\
[#positionmanager](#positionmanager "mention")\
[#v3nftxfactory](#v3nftxfactory "mention")\
[#v3inventory](#v3inventory "mention")

</details>

<details>

<summary>Public Write Functions</summary>

[#sushitonftxamm](#sushitonftxamm "mention")\
[#v2inventorytoxnft](#v2inventorytoxnft "mention")\
[#v2vaulttoxnft](#v2vaulttoxnft "mention")

</details>

## Constants

#### DEADLINE

```solidity
uint256 private constant DEADLINE =
    0xf000000000000000000000000000000000000000000000000000000000000000
```

A sufficiently large value used for Uniswap V2's deadline.

#### DUST\_THRESHOLD

```solidity
uint256 private constant DUST_THRESHOLD = 0.005 ether
```

Threshold for what amount of V2 vTokens (left after redeeming) constitutes "dust." Used to determine whether to swap dust to WETH or not.

#### WETH

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

Address of WETH contract.

#### v2NFTXFactory

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

NFTX V2 vault factory address.

#### v2Inventory

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

NFTX V2 inventory staking address.

#### sushiRouter

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

Sushi router address.

#### positionManager

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

Address of NFTX V3's NonfungiblePositionManager contract.

#### v3NFTXFactory

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

Address of NFTXVaultFactoryUpgradeableV3 contract.

#### v3Inventory

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

Address of NFTXInventoryStakingV3Upgradeable contract.

## Write Functions

#### sushiToNFTXAMM

```solidity
function sushiToNFTXAMM(
    SushiToNFTXAMMParams calldata params
) external returns (uint256 positionId)
```

Migrates Sushi vToken liquidity to NFTX v3 AMM.

<table><thead><tr><th width="249.5">SushiToNFTXAMMParams</th><th width="131">Type</th><th>Description</th></tr></thead><tbody><tr><td>sushiPair</td><td><code>address</code></td><td>SLP token address.</td></tr><tr><td>lpAmount</td><td><code>uint256</code></td><td>SLP amount.</td></tr><tr><td>vTokenV2</td><td><code>address</code></td><td>vToken amount.</td></tr><tr><td>idsToRedeem</td><td><code>uint256[]</code></td><td>NFT tokenIDs to redeem.</td></tr><tr><td>is1155</td><td><code>bool</code></td><td>Whether NFTs use ERC1155.</td></tr><tr><td>permitSig</td><td><code>bytes</code></td><td>Signed UniV2 Permit.</td></tr><tr><td>vaultIdV3</td><td><code>uint256</code></td><td>NFTX v3 vault ID.</td></tr><tr><td>tickLower</td><td><code>int24</code></td><td>Lower tick for v3 liquidity.</td></tr><tr><td>tickUpper</td><td><code>int24</code></td><td>Upper tick for v3 liquidity.</td></tr><tr><td>fee</td><td><code>uint24</code></td><td>Fee tier of V3 AMM pool to be used.</td></tr><tr><td>sqrtPriceX96</td><td><code>uint160</code></td><td>Starting price, if pool is not initialized.</td></tr><tr><td>amount0Min</td><td><code>uint256</code></td><td>Minimum token0 amount to succeed.</td></tr><tr><td>amount1Min</td><td><code>uint256</code></td><td>Minimum token1 amount to succeed.</td></tr><tr><td>deadline</td><td><code>uint256</code></td><td>Dealine for transaction to succeed. Unix timestamp, in seconds.</td></tr></tbody></table>

<table><thead><tr><th width="249.33333333333331">Return values</th><th width="132">Type</th><th>Description</th></tr></thead><tbody><tr><td>positionId</td><td><code>uint256</code></td><td>ID number of newly created position.</td></tr></tbody></table>

#### v2InventoryToXNFT

```solidity
function v2InventoryToXNFT(
    uint256 vaultIdV2,
    uint256 shares,
    uint256[] calldata idsToRedeem,
    bool is1155,
    uint256 vaultIdV3,
    uint256 minWethToReceive
) external returns (uint256 xNFTId)
```

Migrates V2 inventory position to V3 xNFT inventory staking position.

<table><thead><tr><th width="192.5">Parameters</th><th width="138">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultIdV2</td><td><code>uint256</code></td><td>V2 vault ID.</td></tr><tr><td>shares</td><td><code>uint256</code></td><td>V2 xToken shares.</td></tr><tr><td>idsToRedeem</td><td><code>uint256[]</code></td><td>NFT tokenIDs to redeem.</td></tr><tr><td>is1155</td><td><code>bool</code></td><td>Whether NFT collection uses ERC1155.</td></tr><tr><td>vaultIdV3</td><td><code>uint256</code></td><td>V3 vault ID.</td></tr><tr><td>minWethToReceive</td><td><code>uint256</code></td><td>Minimum WETH to be received.</td></tr></tbody></table>

<table><thead><tr><th width="192.5">Return values</th><th width="141">Type</th><th>Description</th></tr></thead><tbody><tr><td>xNFTId</td><td><code>uint256</code></td><td>ID of newly created xNFT. </td></tr></tbody></table>

#### v2VaultToXNFT

```solidity
function v2VaultToXNFT(
    address vTokenV2,
    uint256 vTokenV2Balance,
    uint256[] calldata idsToRedeem,
    bool is1155,
    uint256 vaultIdV3,
    uint256 minWethToReceive
) external returns (uint256 xNFTId)
```

Migrates V2 vault token to V3 xNFT inventory staking position.

<table><thead><tr><th width="192.5">Parameters</th><th width="137">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultIdV2</td><td><code>uint256</code></td><td>V2 vault ID.</td></tr><tr><td>vTokenV2</td><td><code>address</code></td><td>V2 vault address.</td></tr><tr><td>shares</td><td><code>uint256</code></td><td>The amount of v2 vToken shares to withdraw.</td></tr><tr><td>idsToRedeem</td><td><code>uint256[]</code></td><td>TokenIDs of NFTs to redeem.</td></tr><tr><td>is1155</td><td><code>bool</code></td><td>Whether the NFT collection uses ERC1155.</td></tr><tr><td>vaultIdV3</td><td><code>uint256</code></td><td>V3 vault ID.</td></tr><tr><td>minWethToReceive</td><td><code>uint256</code></td><td>Minimum required WETH to receive.</td></tr></tbody></table>

<table><thead><tr><th width="192.5">Return values</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>xNFTId</td><td><code>uint256</code></td><td>ID of newly created xNFT inventory position.</td></tr></tbody></table>
