Overview
NFTX Contracts
Structure Summary
At the core of NFTX is the NFTX Fund contract which holds all NFTs stored by all various NFTX funds. The NFTX Fund contract maintains a vault per NFT address identified with a vault ID. Using the vault ID, the NFTX Fund contract accesses all fund/vault related storage through the xStore contract.
For every vault, there is a fund token (vToken) deployed for it, which is eligible for redeeming a pseudorandom NFT from the fund.
Vault Creation
Anyone can create a vault by calling createVault
. When a vault is made, a fund token (vToken) is deployed, and the vault ID is returned.
Minting
The mint function allows you to mint an vToken for each NFT provided to the fund.
This function expects the contract to have approval of the NFTs or set as an operator from msg.sender
.
Redeeming
The redeem function allows users to use their NFTX Fund tokens to redeem NFTs pseudorandomly from the proper vault.
This function expects the contract to have approval of the NFTX Fund token by the msg.sender
.
vToken (Fund Tokens)
For every fund on NFTX, an vToken proxy clone contract is deployed to serve as the means of minting/redeeming through that fund. Every vToken is a standard ERC20.
Using the vault ID, you can access vault information from xStore using the following view functions:
Reading the vaults parameters
The vToken address represents the token that is minted/redeemed for the assets in that vault ID. This is also referred to as the fund token.
The asset address is the asset used to mint fund tokens, and what is given back to the user when they redeem their fund tokens.
Reading the vaults contents and information
A reserve defines the vault's contents, which consists of ERC721s.
You can view the total amount of assets in a vault; if an asset is present in a vault; and which asset is located at a given index.
Permissioning
Currently there are 2 distinct roles which the permission checks are based on.
Owner: the address who initialized the NFTX contract, the owner of the NFTX Fund contract. Manager: the address who created the vault. (Note: every vault has its own manager.)
There is 1 modifier and 2 functions that are used as a permission check.
onlyOwner
Only the owner can execute the functions with this modifier.
onlyOwnerIfPaused
It takes an ID as an argument which corresponds to an action and checks if the specific action is paused or not.
If the action is paused only the owner can call the function. If it isn’t paused, it is permissionless.
As of now the actions that can be “paused” are createVault()
, mint()
, redeem()
.
The functions that use this access control are:
onlyPrivileged
It takes as argument a vaultId and it checks if the vault is finalized or not, if it's finalized only the owner can continue forward otherwise only the manager can call it.
The functions that use this access control are:
Last updated