Contracts and wallets can be excluded from fees through the VaultFactoryUpgradable contract. The owner of the contract can add an address, along with a boolean representation of their exclusion from paying fees, to the
setFeeExclusionfunction. This will emit a
FeeExclusionevent and update an internal mapping. This can then be queried by other contracts by performing a call along the lines of
Fees are charged and distributed when an NFT is minted, redeemed or swapped in an NFTX vault. If a user is excluded from fees in this manner then no fees will be send to the
feeDistributorand no tokens will be transferred via the NFTX Vault contract.
This is used for NFTX zaps to allow for additional transactions to take place before, or instead of, incurring fees.
If fees are not excluded then:
- The amount of fee owed is determined by checking the vault fees that are assigned by it’s creator
- The fee is then transferred to the fee distributor contract attached to the vault
- This distributor is required during initialisation and its implementation is validated.
- At this point the fee amount is also sense checked
- The distributor contract then calls the
distributefunction, along with the corresponding vaultId that is calling it
- Distribution logic will vary depending on the contract that is implemented. The different distribution contracts should have ample documentation and commenting to understand.
Flags if distribution is currently paused
Contract address of the NFTX Vault Factory contract.
Contract address of the LP Staking contract.
Contract address of the NFTX Treasury contract.
Total allocation points per vault.
struct INFTXSimpleFeeDistributor.FeeReceiver feeReceivers
Array storage of fee receivers, accessed by index.
Contract address of the NFTX Inventory Staking contract.
event UpdateTreasuryAddress(address newTreasury)
Emitted when the treasury address is updated.
event UpdateLPStakingAddress(address newLPStaking)
Emitted when the LP Staking address is updated.
event UpdateInventoryStakingAddress(address newInventoryStaking)
Emitted when the Inventory Staking address is updated.
event UpdateNFTXVaultFactory(address factory)
Emitted when the NFTX Vault Factory address is updated.
event PauseDistribution(bool paused)
Emitted when this contract is paused or unpaused.
event AddFeeReceiver(address receiver, uint256 allocPoint)
Emitted when a contract or non-contract receiver is added as a
event UpdateFeeReceiverAlloc(address receiver, uint256 allocPoint)
Emitted when a receiver's allocation is updated.
event UpdateFeeReceiverAddress(address oldReceiver, address newReceiver)
Emitted when a receiver's address is updated.
event RemoveFeeReceiver(address receiver)
Emitted when a receiver's address is removed.
function __SimpleFeeDistributor__init__(address _lpStaking, address _treasury) public
Initialiser for the fee distributor, setting relevant staking and treasury addresses.
Allows for upgradable deployment
function distribute(uint256 vaultId) external virtual
Distributes fees to receivers. All receivers will be iterated over to distribute their relative allocation of the total number of tokens.
The total balance of the token on the contract will be distributed.
Any dust balance remaining on the contract is transferred to the treasury.
_If distribution is paused or we have no receivers added (defined by allocTotal) then the entire token balance will be sent to the treasury.
When our receivers are set up by the contract owner they are assigned an
allocPointvalue that indicates the relative size of the allocation they will be eligible to receive. This is explained in greater depth on the
The vault ID will determine the ERC20 token that will be transferred._
function addReceiver(uint256 _allocPoint, address _receiver, bool _isContract) external virtual
Adds a receiver to the fee distributor. If a contract receiver is added, then they must a call to
receiveRewardsas outlined in the
_sendForReceiverfunction. The receiver is given an
allocPointvalue that defines their relative stake of the rewards.
_For the point allocation, if receiver A has 1
allocPointand receiver B has 3
allocPointthen when rewards are distributed they will each receive a percentage based on the relative value.
For example, in this case receiver B would receive 75% of the rewards and receiver A would receive the remaining 25%._
function initializeVaultReceivers(uint256 _vaultId) external
Allows the NFTX Vault Factory contract caller to add a pool vault for LP Staking and, if an inventory staking address is set, then deploys an xToken for the vault.
function changeReceiverAlloc(uint256 _receiverIdx, uint256 _allocPoint) public virtual
Allows receiver allocation to be updated.
Safe math is not implemented, so calculations must not exceed uint256 boundaries for
function changeReceiverAddress(uint256 _receiverIdx, address _address, bool _isContract) public virtual
Allows receiver address and
isContractstate to be updated.
function removeReceiver(uint256 _receiverIdx) external virtual
Removes the receiver from our internal array so that they will no longer be included in our fee distribution.
This removal changes the index order of the
feeReceiversarray by moving the last element to that of the removed value. External sources will need to reflect this change for future updates before making subsequent calls.
function setTreasuryAddress(address _treasury) public
Allows our treasury address to be updated.
function setLPStakingAddress(address _lpStaking) public
Allows our LP Staking address to be updated.
function setInventoryStakingAddress(address _inventoryStaking) public
Allows our Inventory Staking address to be updated.
function setNFTXVaultFactory(address _factory) external
Allows our NFTX Vault Factory address to be updated.
function pauseFeeDistribution(bool _pause) external
Allows our fee distribution system to be paused or unpaused.
function rescueTokens(address _address) external
Allows tokens to be rescued from the contract to the sender. This will transfer the entire balance of the matching ERC20 token.
function _addReceiver(uint256 _allocPoint, address _receiver, bool _isContract) internal virtual
FeeReceiverto our internally stored fee receivers array.
The new receiver will always be added to the end of the array.
function _sendForReceiver(struct INFTXSimpleFeeDistributor.FeeReceiver _receiver, uint256 _vaultId, address _vault, uint256 amountToSend) internal virtual returns (bool)
Sends the specified amount of tokens to a receiver from an NFTX vault.
If the receiver is a contract then they must implement
receiveRewardsto handle the fee distribution.