N
N
NFTX
Search…
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

1
function createVault(
2
string memory name,
3
string memory symbol,
4
address _assetAddress,
5
bool _isD2Vault
6
) public virtual nonReentrant returns (uint256 vaultId);
Copied!
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

1
function mint(uint256 vaultId, uint256[] memory nftIds, uint256 d2Amount) external;
Copied!
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

1
function redeem(uint256 vaultId, uint256 amount) external;
Copied!
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.

xStore

Using the vault ID, you can access vault information from xStore using the following view functions:

Reading the vaults parameters

1
function xTokenAddress(uint256 vaultId) external view returns (address);
2
function assetAddress(uint256 vaultId) external view returns (address);
Copied!
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

1
function reservesLength(uint256 vaultId) external view returns (uint256);
2
function reservesContains(uint256 vaultId, uint256 elem) external view returns (bool);
3
function reservesAt(uint256 vaultId, uint256 index) external view returns (uint256);
Copied!
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

1
modifier onlyOwner()
Copied!
Only the owner can execute the functions with this modifier.

onlyOwnerIfPaused

1
function onlyOwnerIfPaused(uint256 pauserId) public view virtual;
Copied!
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:
1
function createVault(string memory name, string memory symbol, address _assetAddress, bool _isD2Vault) public virtual nonReentrant returns (uint256 vaultId);
2
function requestMint(uint256 vaultId, uint256[] memory nftIds) public payable virtual override nonReentrant;
3
function mint(uint256 vaultId, uint256[] memory nftIds, uint256 d2Amount) public payable virtual override nonReentrant;
4
function redeem(uint256 vaultId, uint256 amount) public payable virtual nonReentrant;
Copied!

onlyPrivileged

1
function onlyPrivileged(uint256 vaultId) internal view;
Copied!
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:
1
// Configuration
2
function setIs1155(uint256 vaultId, bool _boolean) public virtual;
3
function setNegateEligibility(uint256 vaultId, bool shouldNegate) public virtual override;
4
function setRange(uint256 vaultId, uint256 start, uint256 end) public virtual;
5
function setIsEligible(uint256 vaultId, uint256[] memory nftIds, bool _boolean) public virtual;
6
function setMintFees(uint256 vaultId, uint256 _ethBase, uint256 _ethStep) public virtual;
7
function setBurnFees(uint256 vaultId, uint256 _ethBase, uint256 _ethStep) public virtual;
8
function setSupplierBounty(uint256 vaultId, uint256 ethMax, uint256 length) public virtual;
9
function setAllowMintRequests(uint256 vaultId, bool isAllowed) public virtual;
10
function setFlipEligOnRedeem(uint256 vaultId, bool flipElig) public virtual;
11
function setNegateEligibility(uint256 vaultId, bool shouldNegate) public virtual;
12
function approveMintRequest(uint256 vaultId, uint256[] memory nftIds) public virtual;
13
14
// Management
15
function changeTokenName(uint256 vaultId, string memory newName) public virtual;
16
function changeTokenSymbol(uint256 vaultId, string memory newSymbol) public virtual;
17
function setManager(uint256 vaultId, address newManager) public virtual;
18
function finalizeVault(uint256 vaultId) public virtual;
19
function closeVault(uint256 vaultId) public virtual;)
Copied!
Last modified 6mo ago