NFTXVaultUpgradeableV3
NFTXVaultUpgradeableV3.sol
The NFTX vault implementation used by the vault beacon proxy (and therefore all vaults).
Table of Contents
Constants
BASE
10^18.
WETH
WETH contract address.
CRYPTO_PUNKS
CryptoPunks contract address.
CRYPTO_KITTIES
CryptoKitties contract address.
assetAddress
Contract address of NFT collection that can enter the vault.
vaultFactory
Address of NFTX Vault Factory.
vaultId
The vault's ID number.
is1155
Whether the vault is for an ERC1155 NFT.
Variables
manager
Address of vault manager.
eligibilityStorage
Address of Eligibility Storage.
allowAllItems
Whether all NFT tokenIDs are eligible to enter this vault.
enableMint
Whether minting is enabled.
enableRedeem
Whether redeeming is enabled.
enableSwap
Whether swapping is enabled.
tokenDepositInfo
Timestamp and depositor address of each ERC721 deposit.
depositInfo1155
Quantity, depositor address, and timestamp of each ERC1155 deposit.
pointerIndex1155
Pointer index of oldest DepositInfo1155 object, for each ERC1155 tokenID.
Events
VaultInit
Emitted by __NFTXVault_init
function.
Parameters | Type | Description |
---|---|---|
vaultId |
| ID of vault initialized. |
assetAddress |
| NFT collection address associated with vault. |
is1155 |
| Whether the NFT collection uses ERC1155. |
allowAllItems |
| Whether all tokenIDs are allowed into vault. |
ManagerSet
Emitted by setManager
function.
Parameters | Type | Description |
---|---|---|
manager |
| New vault manager address. |
EligibilityDeployed
Emitted by deployEligibilityStorage
function.
Parameters | Type | Description |
---|---|---|
moduleIndex |
| Eligibility module number. |
eligibilityAddr |
| Address of eligibility contract just added. |
EnableMintUpdated
Emitted by setVaultFeatures
function.
Parameters | Type | Description |
---|---|---|
enabled |
| True if minting has just been enabled, false if minting has been disabled. |
EnableRedeemUpdated
Emitted by setVaultFeatures
function.
Parameters | Type | Description |
---|---|---|
enabled |
| True if redeeming has just been enabled, false if redeeming has been disabled. |
EnableSwapUpdated
Emitted by setVaultFeatures
function.
Parameters | Type | Description |
---|---|---|
enabled |
| True if NFT-to-NFT swapping has just been enabled, false if it has been disabled. |
Minted
Emitted by mint
function.
Parameters | Type | Description |
---|---|---|
nftIds |
| TokenIDs of NFTs added to vault. |
amounts |
| Amounts of each NFT tokenID (for ERC1155). |
to |
| Recipient address that vTokens were sent to. |
depositor |
| Depositor address that should receive premiums for the |
Redeemed
Emitted by redeem
function.
Parameters | Type | Description |
---|---|---|
specificIds |
| TokenIDs of redeemed NFTs. |
to |
| Recipient address that NFTs were sent to. |
Swapped
Emitted by swap
function.
Parameters | Type | Description |
---|---|---|
nftIds |
| TokenIDs of NFTs sent to vault. |
amounts |
| Amounts for NFT token IDs that entered the vault, and also for NFT tokenIDs that exited the vault. |
specificIds |
| TokenIDs of NFTs sent to recipient. |
to |
| Recipient address that NFTs were sent to. |
depositor |
| Depositor address that should receive premiums for the |
PremiumShared
Emitted by redeem
and swap
functions.
Parameters | Type | Description |
---|---|---|
depositor |
| NFT depositor who receives bulk of premium fee. |
wethPremium |
| WETH premium fee amount (total shared). |
FeesDistributed
Emitted by mint
, redeem
and swap
functions.
Parameters | Type | Description |
---|---|---|
wethFees |
| WETH fee amount distributed. |
VaultShutdown
Emitted by shutdown
.
Parameters | Type | Description |
---|---|---|
assetAddress |
| NFT collection address of shutdown vault. |
numItems |
| Number of NFTs in vault at time of shutdown. |
recipient |
| Recipient address where vault NFTs were sent. |
Write Functions
mint
Mints vault tokens in exchange for depositing NFTs. Mint fee is paid in ETH.
Parameters | Type | Description |
---|---|---|
tokenIds |
| Token IDs of NFTs being sent to vault. |
amounts |
| Quantity of each NFT. Ignored for ERC721 vaults. |
depositor |
| Address that should receive premium fees for |
to |
| Address to receive minted vToken. |
|
| Amount of ETH to send. |
Return values | Type | Description |
---|---|---|
vTokensMinted |
| The amount of vTokens minted. |
redeem
Redeems NFTs by burning vToken. Redeem fee is paid in ETH or WETH.
Parameters | Type | Description |
---|---|---|
idsOut |
| Token IDs of NFTs to redeem. |
to |
| Address to receive redeemed NFTs. |
wethAmount |
| Amount of WETH to send for fees. If set to zero, then ETH is used instead. |
vTokenPremiumLimit |
| Max total premium fees (denominated in vToken) that the user is willing to pay. |
forceFees |
| Whether to enforce fees even if caller is set as excludedFromFees. |
|
| Amount of ETH to send. |
Return values | Type | Description |
---|---|---|
ethFees |
| Total fees paid (in WETH or ETH). |
swap
Swap one or more NFTs (idsIn
) for other NFTs from the vault (idsOut
). Swap fee is paid in ETH.
Parameters | Type | Description |
---|---|---|
idsIn |
| Token IDs of NFTs going to vault. |
amounts |
| Quantity of each NFT going to vault. Ignored for ERC721. |
idsOut |
| Token IDs of NFTs leaving vault. |
depositor |
| Address that should receive premium fees for |
to |
| Address to receive NFTs from vault. |
vTokenPremiumLimit |
| Max total premium fees (denominated in vToken) that the user is willing to pay. |
forceFees |
| Whether to enforce fees even if caller is set as excludedFromFees. |
|
| Amount of ETH to send. |
Return values | Type | Description |
---|---|---|
ethFees |
| Total fees paid (in WETH or ETH). |
flashLoan
Performs a flash loan. New tokens are minted and sent to receiver
, who is required to implement the IERC3156FlashBorrower
interface. By the end of the flash loan, the receiver is expected to own amount
of tokens and have them approved back to the token contract itself so they can be burned and distributed.
The fee required to execute a flash loan is paid in ETH and is the highest of the vault's mint, redeem, and swap fees. All ETH proceeds are sent to the vault's inventory stakers.
Parameters | Type | Description |
---|---|---|
receiver |
| The receiver address of the flash loan. |
token |
| The token to be flash loaned. Only |
amount |
| The amount of tokens to be loaned. |
data |
| An arbitrary data field that is passed to the receiver. |
Return values | Type | Description |
---|---|---|
unnamed |
|
|
Privileged Functions
These functions can only be called by the vault manager or (if there is no vault manager) the contract owner.
finalizeVault
Removes the vault manager.
setVaultMetadata
Sets the name and symbol of the vault's ERC20 vToken.
Parameters | Type | Description |
---|---|---|
name_ |
| New name. |
symbol_ |
| New symbol. |
setVaultFeatures
Sets minting, redeeming, and swapping as either on or off.
Parameters | Type | Description |
---|---|---|
enableMint_ |
| Whether minting is enabled. |
enableRedeem_ |
| Whether redeeming is enabled. |
enableSwap_ |
| Whether swapping is enabled. |
setFees
Sets mint, redeem, and (NFT-to-NFT) swap fees. 1e16 = 1%.
Parameters | Type | Description |
---|---|---|
mintFee_ |
| New mint fee. |
redeemFee_ |
| New redeem fee. |
swapFee_ |
| New swap fee (for NFT swaps). |
disableVaultFees
Removes custom vault fee settings, reverting to the global/default vault fee settings.
deployEligibilityStorage
Deploys and initializes an eligibility module contract from the EligibilityManager.
Parameters | Type | Description |
---|---|---|
moduleIndex |
| Index of module to deploy. |
initData |
| ABI encoded parameters for module. |
Return values | Type | Description |
---|---|---|
unnamed |
| Address of deployed module. |
setManager
Sets the vault manager.
Parameters | Type | Description |
---|---|---|
manager_ |
| Address of new vault manager. |
Owner Functions
rescueTokens
Rescues ERC20, ERC721, or ERC1155 tokens.
Parameters | Type | Description |
---|---|---|
tt |
| Enum: |
token |
| Contract address of token to retrieve. |
ids |
| Token IDs for ERC721 or ERC1155 NFTs. Ignored for ERC20. |
amounts |
| Quantities for ERC1155 token IDs. Ignored for ERC20 and ERC721. |
shutdown
Shuts the vault down and sends its NFTs to recipient
. This function is meant to be used by the DAO when a vault has lost liquidity, and the vToken is too dispersed for any one user to redeem. When this happens, one or more users can request a shutdown, which is initiated by the DAO. The DAO then sells the assets for ETH and distributes the ETH to the vToken holders.
This function works for both ERC721 and ERC1155 vaults. For ERC1155, the total amount of each tokenID will be sent to the recipient.
Parameters | Type | Description |
---|---|---|
recipient |
| Address to receives NFTs. |
tokenIds |
| TokenIDs to send (should include all held by vault). |
Read Functions
nftIdAt
Retrieves the NFT token ID stored at a specified index in holdings.
Parameters | Type | Description |
---|---|---|
holdingsIndex |
| Index position of holdings data to retrieve. |
Return values | Type | Description |
---|---|---|
unnamed |
| NFT Token ID, if found. |
allHoldings
Returns an array of all NFT token IDs held by the vault.
Return values | Type | Description |
---|---|---|
unnamed |
| All token IDs in holdings. |
totalHoldings
Returns the number of distinct NFT token IDs in holdings.
Return values | Type | Description |
---|---|---|
unnamed |
| Number of distinct token IDs in holdings. |
holdingsContains
Returns whether an NFT tokenId is in the vault.
Return values | Type | Description |
---|---|---|
tokenId |
| NFT tokenID to check for. |
Return values | Type | Description |
---|---|---|
unnamed |
| Whether the tokenID is in the vault. |
vaultFees
The mint, redeem, and swap fees.
Return values | Type | Description |
---|---|---|
mintFee |
| Mint fee. |
redeemFee |
| Redeem fee. |
swapFee |
| Swap fee, for NFT-to-NFT swaps. |
allValidNFTs
Checks whether all NFT Token IDs inputed are valid for minting vToken.
Parameters | Type | Description |
---|---|---|
tokenIds |
| Token IDs of NFTs to check. |
Return values | Type | Description |
---|---|---|
unnamed |
| Whether all the NFT tokenIDs are valid to enter. |
vTokenToETH
Calculate ETH amount corresponding to a given vToken amount, calculated via the TWAP from the NFTX AMM.
Parameters | Type | Description |
---|---|---|
vTokenAmount |
| Amount of vToken to calculate in ETH. |
Return values | Type | Description |
---|---|---|
ethAmount |
| ETH amount that is equal in value to the vToken amount, based on TWAP. |
depositInfo1155Length
Returns length of the depositInfo1155
list for a given tokenID.
Parameters | Type | Description |
---|---|---|
tokenId |
| NFT tokenID to check. |
Return values | Type | Description |
---|---|---|
unnamed |
| Length of |
version
Returns the version of this contract.
Return values | Type | Description |
---|---|---|
unnamed |
| Contract version. |
Last updated