NFTXVaultFactoryUpgradeableV3

NFTXVaultFactoryUpgradeableV3.sol

Factory contract for creating NFTX vaults, and also managing general protocol settings.

Table of Contents

Constants
Variables
Events
Public Write Functions
Privileged Write Functions
Owner Write Functions
Read Functions

Constants

MAX_DEPOSITOR_PREMIUM_SHARE

uint256 constant MAX_DEPOSITOR_PREMIUM_SHARE = 1 ether

Max depositor premium fee share allowed. Set to 100%.

BEACON_CODE

bytes internal constant BEACON_CODE = type(Create2BeaconProxy).creationCode

Beacon proxy creation code.

Variables

feeDistributor

function feeDistributor() external view returns (address)

Address of NFTXFeeDistributorV3.

eligibilityManager

function eligibilityManager() external view returns (address)

Address of NFTXEligibilityManager.

excludedFromFees

function excludedFromFees(address addr) external view returns (bool)

Which addresses are excluded from fees.

factoryMintFee

function factoryMintFee() external view returns (uint64)

Global mint fee for vaults using default fee settings.

factoryRedeemFee

function factoryRedeemFee() external view returns (uint64)

Global redeem fee for vaults using default fee settings.

factorySwapFee

function factorySwapFee() external view returns (uint64)

Global (NFT-to-NFT) swap fee for vaults using default fee settings.

twapInterval

function twapInterval() external view returns (uint32)

The time-weighted average price interval. For example, if the twapInterval is set to 3600 seconds (1 hour), it would mean that you are interested in computing or observing the average price of an asset over the past hour.

premiumDuration

function premiumDuration() external view returns (uint256)

The time it takes for premium fees to decay from premiumMax to zero. In seconds.

premiumMax

function premiumMax() external view returns (uint256)

The starting (max) premium fee. 1e16 = 1%.

depositorPremiumShare

function depositorPremiumShare() external view returns (uint256)

Portion of premium fee that goes to depositor. 1e16 = 1%.

Events

NewFeeDistributor

event NewFeeDistributor(address oldDistributor, address newDistributor)

Emitted by setFeeDistributor().

ParametersTypeDescription

oldDistributor

address

Previous address of NFTXFeeDistributorV3.

newDistributor

address

New address of NFTXFeeDistributorV3.

FeeExclusion

event FeeExclusion(address feeExcluded, bool excluded)

Emitted by setFeeExclusion().

ParametersTypeDescription

feeExcluded

address

Address being excluded (or un-excluded).

excluded

bool

Whether the address is excluded from fees.

NewEligibilityManager

event NewEligibilityManager(address oldEligManager, address newEligManager)

Emitted by setEligibilityManager().

ParametersTypeDescription

oldEligManager

address

Previous address of NFTXEligibilityManager.

newEligManager

address

New address of NFTXEligibilityManager.

NewVault

event NewVault(
    uint256 indexed vaultId,
    address vaultAddress,
    address assetAddress,
    string name,
    string symbol
)

Emitted by createVault().

ParametersTypeDescription

vaultId

uint256

ID of vault.

vaultAddress

address

Contract address of vault.

assetAddress

address

NFT collection address linked to vault.

name

string

ERC20 vToken name.

symbol

string

ERC20 vToken symbol.

UpdateVaultFees

event UpdateVaultFees(
    uint256 vaultId,
    uint256 mintFee,
    uint256 redeemFee,
    uint256 swapFee
)

Emitted by setVaultFees(). Fees are calculated in vToken, but paid in ETH. 1e16 = 0.01 vToken = 1%.

ParametersTypeDescription

vaultId

uint256

ID of vault.

mintFee

address

New vault mint fee.

redeemFee

address

New vault redeem fee.

swapFee

string

New vault swap fee.

DisableVaultFees

event DisableVaultFees(uint256 vaultId)

Emitted by disableVaultFees().

ParametersTypeDescription

vaultId

uint256

ID of vault.

UpdateFactoryFees

event UpdateFactoryFees(
    uint256 mintFee,
    uint256 redeemFee,
    uint256 swapFee
)

Emitted by setFactoryFees(). Fees are calculated in vToken, but paid in ETH. 1e16 = 0.01 vToken = 1%.

ParametersTypeDescription

mintFee

address

New factory mint fee.

redeemFee

address

New factory redeem fee.

swapFee

string

New factory swap fee.

NewPremiumMax

event NewPremiumMax(uint256 premiumMax)

Emitted by setPremiumMax(). Fees are calculated in vToken, but paid in ETH. 1e16 = 0.01 vToken = 1%.

ParametersTypeDescription

premiumMax

uint256

New max premium fee.

NewPremiumDuration

event NewPremiumDuration(uint256 premiumDuration)

Emitted by setPremiumDuration(). In seconds.

ParametersTypeDescription

premiumDuration

uint256

New premium duration.

NewDepositorPremiumShare

event NewDepositorPremiumShare(uint256 depositorPremiumShare)

Emitted by setDepositorPremiumShare(). 1e16 = 1%.

ParametersTypeDescription

depositPremiumShare

uint256

New depositor share of premium fee.

NewTwapInterval

event NewTwapInterval(uint32 twapInterval)

Emitted by setTwapInterval().

ParametersTypeDescription

twapInterval

uint256

The time-weighted average price interval. For example, if the twapInterval is set to 3600 seconds (1 hour), it would mean that you are interested in computing or observing the average price of an asset over the past hour.

Write Functions

createVault

function createVault(
    string memory name,
    string memory symbol,
    address assetAddress,
    bool is1155,
    bool allowAllItems
) external returns (uint256 vaultId)

Creates a vault.

ParametersTypeDescription

name

string

ERC20 vToken name of vault.

symbol

string

ERC20 vToken symbol for vault.

assetAddress

address

Address of NFT contract.

is1155

bool

Whether the NFT uses ERC1155.

allowAllItems

bool

Whether all NFT token IDs are eligible to enter.

Return valuesTypeDescription

vaultId

uint256

ID of vault.

Privileged Functions

These functions can be called by vault contracts (on themselves) or by this contract's owner.

setVaultFees

function setVaultFees(
    uint256 vaultId,
    uint256 mintFee,
    uint256 redeemFee,
    uint256 swapFee
) external

Sets mint, redeem, and (NFT-to-NFT) swap fees for a vault. 1e16 = 1%.

ParametersTypeDescription

vaultId

uint256

ID of vault.

mintFee

uint256

New mint fee.

redeemFee

uint256

New redeem fee.

swapFee

uint256

New (NFT-to-NFT) swap fee.

disableVaultFees

function disableVaultFees(uint256 vaultId) external

Revert vault to global/default fee settings.

ParametersTypeDescription

vaultId

uint256

ID of vault.

Owner Functions

setFactoryFees

function setFactoryFees(
    uint256 mintFee,
    uint256 redeemFee,
    uint256 swapFee
) external

Sets global/default mint, redeem, and (NFT-to-NFT) swap fees. 1e16 = 1%.

ParametersTypeDescription

mintFee

uint256

New mint fee.

redeemFee

uint256

New redeem fee.

swapFee

uint256

New swap fee (for NFT-to-NFT swaps).

setFeeDistributor

function setFeeDistributor(
    address feeDistributor_
) external

Sets address of NFTXFeeDistributorV3.

ParametersTypeDescription

feeDistributor_

address

New address of NFTXFeeDistributorV3.

setFeeExclusion

function setFeeExclusion(
    address excludedAddr,
    bool excluded
) external

Sets whether an address is excluded from vault fees.

ParametersTypeDescription

excludedAddr

address

Address being set.

excluded

bool

Whether the address is excluded from vault fees.

setEligibilityManager

function setEligibilityManager(
    address eligibilityManager_
) external

Sets address of NFTXEligibilityManager.

ParametersTypeDescription

eligibilityManager_

address

New address of NFTXEligibilityManager.

setTwapInterval

function setTwapInterval(uint32 twapInterval_) external

Sets the TWAP interval duration. In seconds.

NameTypeDescription

twapInterval_

uint32

New TWAP interval.

setPremiumDuration

function setPremiumDuration(
    uint256 premiumDuration_
) external

Sets the time it takes, in seconds, for premium fees to decay from premiumMax to zero.

ParametersTypeDescription

premiumDuration_

uint256

New duration.

setPremiumMax

function setPremiumMax(uint256 premiumMax_) external

Sets the starting (max) premium fee.

ParametersTypeDescription

premiumMax_

uint256

New max premium. 1e16 = 1%.

setDepositorPremiumShare

function setDepositorPremiumShare(
    uint256 depositorPremiumShare_
) external

Sets the portion of premium fee that goes to depositor.

ParametersTypeDescription

depositorPremiumShare_

uint256

New depositor share. 1e16 = 1%.

Read Functions

vaultFees

function vaultFees(uint256 vaultId)
    external
    view
    returns (uint256 mintFee, uint256 redeemFee, uint256 swapFee)

Returns the mint, redeem, and (NFT-to-NFT) swap fees for a vault.

ParametersTypeDescription

vaultId

uint256

ID of vault.

Return valuesTypeDescription

mintFee

uint256

Mint fee.

redeemFee

uint256

Redeem fee.

swapFee

uint256

(NFT-to-NFT) swap fee.

isLocked

function isLocked(uint256 lockId) external view returns (bool)

Checks whether the NFTX protocol is locked (i.e., paused).

ParametersTypeDescription

lockId

uint256

The ID of the lock type.

Return valuesTypeDescription

unnamed

bool

Whether the lock type is active.

vaultsForAsset

function vaultsForAsset(
    address assetAddress
) external view returns (address[] memory)

Returns addresses for all vaults that are linked to an NFT address.

ParametersTypeDescription

assetAddress

address

Address of NFT contract.

Return valuesTypeDescription

unnamed

address[]

Array of vault addresses.

allVaults

function allVaults() external view returns (address[] memory)

Returns addresses of all vaults.

Return valuesTypeDescription

unnamed

address

Array of all vault addresses.

numVaults

function numVaults() external view returns (uint256)

Returns total number of NFTX V3 vaults.

Return valuesTypeDescription

unnamed

bool

Number of vaults.

vault

function vault(uint256 vaultId) external view returns (address)

Returns the address of a vault.

ParametersTypeDescription

vaultId

uint256

ID of vault.

Return valuesTypeDescription

unnamed

address

Vault address.

computeVaultAddress

function computeVaultAddress(
    address assetAddress,
    string memory name,
    string memory symbol
) external view returns (address)

Returns a deterministic address based on an assetAddress, name, and symbol.

getTwapX96

function getTwapX96(
    address pool
) external view returns (uint256 priceX96)

Returns the TWAP of the given pool, across the recent twapInterval. The returned value is in UniswapV3's 96-bit fixed point representation.

ParametersTypeDescription

pool

address

Address of AMM pool to check.

Return valuesTypeDescription

priceX96

uint256

TWAP represented as 96-bit FixedPoint.

getVTokenPremium721

function getVTokenPremium721(
    uint256 vaultId,
    uint256 tokenId
) external view returns (uint256 premium, address depositor)

Returns premium fee for redeeming or swapping an ERC721 NFT from a vault.

ParametersTypeDescription

vaultId

uint256

ID of vault.

tokenId

uint256

ID of NFT.

Return valuesTypeDescription

premium

uint256

Premium fee.

depositor

uint256

Address of NFT depositor.

getVTokenPremium1155

function getVTokenPremium1155(
    uint256 vaultId,
    uint256 tokenId,
    uint256 amount
)
    external
    view
    returns (
        uint256 netPremium,
        uint256[] memory premiums,
        address[] memory depositors
    )

Returns premium fee for redeeming or swapping for ERC1155 NFTs from a vault.

ParametersTypeDescription

vaultId

uint256

ID of vault.

tokenId

uint256

ID of NFT.

amount

uint256

Quantity of NFT.

Return valuesTypeDescription

netPremium

uint256

Total premium fee to purchase amount.

premiums

uint256[]

Premium fees.

depositors

uint256[]

Addresses of NFT depositors.

Last updated