Fee Distribution
Last updated
Last updated
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 setFeeExclusion
function. This will emit a FeeExclusion
event and update an internal mapping. This can then be queried by other contracts by performing a call along the lines of nftxVaultFactory.excludedFromFees(msg.sender)
.
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 feeDistributor
and 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 distribute
function, 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.
Array storage of fee receivers, accessed by index.
Contract address of the NFTX Inventory Staking contract.
Emitted when the treasury address is updated.
Name | Type | Description |
---|---|---|
newTreasury | address | The new address for the treasury contract |
Emitted when the LP Staking address is updated.
Name | Type | Description |
---|---|---|
newLPStaking | address | The new address for the LP Staking contract |
Emitted when the Inventory Staking address is updated.
Name | Type | Description |
---|---|---|
newInventoryStaking | address | The new address for the Inventory Staking contract |
Emitted when the NFTX Vault Factory address is updated.
Name | Type | Description |
---|---|---|
factory | address | The new address for the NFTX Vault Factory contract |
Emitted when this contract is paused or unpaused.
Name | Type | Description |
---|---|---|
paused | bool | Boolean value of if distribution has been paused ( |
Emitted when a contract or non-contract receiver is added as a FeeReceiver
.
Name | Type | Description |
---|---|---|
receiver | address | The address of the new fee recipient |
allocPoint | uint256 | The number of allocation points assigned to the receiver |
Emitted when a receiver's allocation is updated.
Name | Type | Description |
---|---|---|
receiver | address | The address of the updated fee recipient |
allocPoint | uint256 | The new number of allocation points assigned to the receiver |
Emitted when a receiver's address is updated.
Name | Type | Description |
---|---|---|
oldReceiver | address | The old address of the receiver |
newReceiver | address | The new address of the receiver |
Emitted when a receiver's address is removed.
Name | Type | Description |
---|---|---|
receiver | address | The address of the receiver that was removed |
Initialiser for the fee distributor, setting relevant staking and treasury addresses.
Allows for upgradable deployment
Name | Type | Description |
---|---|---|
_lpStaking | address | Address of our LP Staking contract |
_treasury | address | Address of our Treasury contract |
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 allocPoint
value that indicates the relative size of the allocation they will be eligible to receive. This is explained in greater depth on the addReceiver
method.
The vault ID will determine the ERC20 token that will be transferred._
Name | Type | Description |
---|---|---|
vaultId | uint256 | The vault ID that is to have its fees distributed |
Adds a receiver to the fee distributor. If a contract receiver is added, then they must a call to receiveRewards
as outlined in the _sendForReceiver
function. The receiver is given an allocPoint
value that defines their relative stake of the rewards.
_For the point allocation, if receiver A has 1 allocPoint
and receiver B has 3 allocPoint
then 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%._
Name | Type | Description |
---|---|---|
_allocPoint | uint256 | The point allocation applied to the receiver |
_receiver | address | The address of the receiver |
_isContract | bool | Flag to determine if the receiver is a contract, rather than a wallet address |
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.
Name | Type | Description |
---|---|---|
_vaultId | uint256 | The NFTX vault ID |
Allows receiver allocation to be updated.
Safe math is not implemented, so calculations must not exceed uint256 boundaries for allocTotal
.
Name | Type | Description |
---|---|---|
_receiverIdx | uint256 | The index value of the feeReceiver in our internally stored array |
_allocPoint | uint256 | The new allocation for the receiver |
Allows receiver address and isContract
state to be updated.
Name | Type | Description |
---|---|---|
_receiverIdx | uint256 | The index value of the feeReceiver in our internally stored array |
_address | address | The new address for the receiver |
_isContract | bool | The new |
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 feeReceivers
array 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.
Name | Type | Description |
---|---|---|
_receiverIdx | uint256 | The index value of the feeReceiver in our internally stored array |
Allows our treasury address to be updated.
Name | Type | Description |
---|---|---|
_treasury | address | Address of our new Treasury contract |
Allows our LP Staking address to be updated.
Name | Type | Description |
---|---|---|
_lpStaking | address | Address of our new LP Staking contract |
Allows our Inventory Staking address to be updated.
Name | Type | Description |
---|---|---|
_inventoryStaking | address | Address of our new Inventory Staking contract |
Allows our NFTX Vault Factory address to be updated.
Name | Type | Description |
---|---|---|
_factory | address | Address of our new NFTX Vault Factory contract |
Allows our fee distribution system to be paused or unpaused.
Name | Type | Description |
---|---|---|
_pause | bool | A boolean representation of if the distribution should be paused |
Allows tokens to be rescued from the contract to the sender. This will transfer the entire balance of the matching ERC20 token.
Name | Type | Description |
---|---|---|
_address | address | The address of the token to be rescued |
Adds a FeeReceiver
to our internally stored fee receivers array.
The new receiver will always be added to the end of the array.
Name | Type | Description |
---|---|---|
_allocPoint | uint256 | The new allocation for the receiver |
_receiver | address | The address of the receiver |
_isContract | bool | Flag to determine if the receiver is a contract, rather than a wallet address |
Sends the specified amount of tokens to a receiver from an NFTX vault.
If the receiver is a contract then they must implement receiveRewards
to handle the fee distribution.
Name | Type | Description |
---|---|---|
_receiver | struct INFTXSimpleFeeDistributor.FeeReceiver | Address of the receiver contract or wallet |
_vaultId | uint256 | The ID of the NFTX vault, provided to the external contract |
_vault | address | The address of the NFTX vault |
amountToSend | uint256 | The amount of tokens distributed to the receiver |
Name | Type | Description |
---|---|---|
[0] | bool | bool If the tokens were successfully transferred and there are no more tokens left to transfer |