Navigate to the NftVaultFactory's createVault function
Enter an array of CollectionData type objects
VaultCreated
event, and the value in Topics[0]
is the newly created vault’s contract address. For the examples below, we will use the Common Zee Items vault created at 0x8D5d711340047f9e855BBe86Ee0D8d7e7412585aMint 1,000 MAGIC
Approve the MagicswapV2Router address as a spender of 1,000 MAGIC
Approve the MagicswapV2Router address as an operator on the Zeeverse Zee Items
Navigate to the MagicswapV2Router's addLiquidityNFT function and enter the following parameters:
Price the assets
token0
: 0x23BE0504127475387A459FE4b01E54f1E336fFae
(VEE)token1
: 0x8D5d711340047f9e855BBe86Ee0D8d7e7412585a
(Common Zee Items Vault)Approve the assets for transfer
Add liquidity
MagicswapV2Router
contract, call addLiquidityNFT
with the following params:_vault
is a tuple of type NftVaultLiquidityData
token
is the NFT’s vault addresscollection
is a list of the NFT addressestokenId
is a list of the NFT token IDsamount
is a list of the number of NFT tokens. The lists all need to have the same lengths for a transaction to be valid_tokenB
is the ERC-20 token address_amountBDesired
is the amount of _tokenB
that we are expecting to deposit to the pool_amountBMin
is the minimum amount of _tokenB
we are willing to deposit after slippage_to
is the address that should receive the resulting LP tokens_deadline
is any future timestamp, in secondsOn the LP token contract
approve
with the MagicswapV2Router
(0xd0A4FbCc5cDe863A2BE50C75b564Efd942b03154
) as spender and the amount of tokeLP ns you will remoburnl getReserves to get the latest reserve infoOn the MagicswapV2Router contract, call removeLiquidityNFT with the following params:
_vault
follows the same format as _addLiquidityNFT
_tokenB
is the ERC-20 token address_lpAmount
is the amount of LP token to burn_amountAMin
the amount of NFTs we want to receive_amountBMin
is the minimum amount of _tokenB
we are willing to receive after slippage_to
is the address that should receive the resulting LP tokens_deadline
is any future timestamp, in seconds_swapLeftover
is true if we want to swap any leftover NFT dust into _tokenB
instead of receiving a fractional NFT Vault token_amountInMax
, the maximum amount of ERC-20 tokens the user is willing to pay for the trade after fees and slippage.
Calculate _amountInMax
getReserves
functionUniswapV2Factory
contract, call getTotalFee
with the pool address as the parameter to receive the total fees set for this pair with base 10,000:amountIn
and a straight trade based on current reserves:Approve the assets for transfer
approve
with the MagicswapV2Router
(0xd0A4FbCc5cDe863A2BE50C75b564Efd942b03154
) as spender and an amount of 1042622482722649889964
Swap
_collection
is a list of the NFT addresses_tokenId
is a list of the NFT token IDs_amount
is a list of the number of NFT tokens
_amountInMax
from the previous step_path
is a list of addresses that this swap route will take. For a single pool, this will just be both sides of the pool (e.g., Common Zee Item to VEE swap will be the Common Zee Items vault and the VEE token address). Specifying more than two addresses in this path allows you to route through multiple pools, for example doing a trade from Common Zee Items to MAGIC, when only the VEE-Common Zee Items and MAGIC-VEE pools exist._to
is the address that should receive the resulting ERC-20 tokens_deadline
is any future timestamp, in secondsApprove the assets for transfer
setApprovalForAll
with the MagicswapV2Router
(0xd0A4FbCc5cDe863A2BE50C75b564Efd942b03154
) as operator and approved with a value of trueCalculate _amountOutMin
_amountOutMin
, the minimum amount of ERC-20 tokens the user is willing to receive for the trade after fees and slippage.getTotalFee
with the pool address as the parameter to receive the total fees set for this pair with base 10,000:amountOut
and a straight trade based on current reserves:Swap
swapNftForTokens
with the following params:_collection
is a list of the NFT addresses_tokenId
is a list of the NFT token IDs_amount
is a list of the number of NFT tokens
_amountOutMin
from the previous step_path
is a list of addresses that this swap route will take. For a single pool, this will just be both sides of the pool (e.g., Common Zee Item to VEE swap will be the Common Zee Items vault and the VEE token address). Specifying more than two addresses in this path allows you to route through multiple pools, for example doing a trade from Common Zee Items to MAGIC, when only the VEE-Common Zee Items and MAGIC-VEE pools exist._to
is the address that should receive the resulting ERC-20 tokens_deadline
is any future timestamp, in seconds