# NFTXFeeDistributorV3

Fee distributor contract for distributing vault fees.&#x20;

## Table of Contents

<details>

<summary>Constants</summary>

[#nftxvaultfactory](#nftxvaultfactory "mention")\
[#ammfactory](#ammfactory "mention")\
[#inventorystaking](#inventorystaking "mention")\
[#weth](#weth "mention")\
[#pool\_default\_alloc](#pool_default_alloc "mention")\
[#inventory\_default\_alloc](#inventory_default_alloc "mention")

</details>

<details>

<summary>Variables</summary>

[#rewardfeetier](#rewardfeetier "mention")\
[#nftxrouter](#nftxrouter "mention")\
[#treasury](#treasury "mention")\
[#alloctotal](#alloctotal "mention")\
[#feereceivers](#feereceivers "mention")\
[#distributionpaused](#distributionpaused "mention")

</details>

<details>

<summary>Events</summary>

[#updatetreasuryaddress](#updatetreasuryaddress "mention")\
[#pausedistribution](#pausedistribution "mention")\
[#newrewardfeetier](#newrewardfeetier "mention")\
[#newnftxrouter](#newnftxrouter "mention")\
[#wethdistributedtoinventory](#wethdistributedtoinventory "mention")\
[#wethdistributedtopool](#wethdistributedtopool "mention")

</details>

<details>

<summary>Public Write Functions</summary>

[#distribute](#distribute "mention")\
[#distributevtokenstopool](#distributevtokenstopool "mention")

</details>

<details>

<summary>Owner Write Functions</summary>

[#setreceivers](#setreceivers "mention")\
[#changerewardfeetier](#changerewardfeetier "mention")\
[#settreasuryaddress](#settreasuryaddress "mention")\
[#setnftxrouter](#setnftxrouter "mention")\
[#pausefeedistribution](#pausefeedistribution "mention")\
[#rescuetokens](#rescuetokens "mention")

</details>

## Constants

#### nftxVaultFactory

```solidity
function nftxVaultFactory() external view returns (address)
```

Address of NFTX vault factory.

#### ammFactory

```solidity
function ammFactory() external view returns (address)
```

Address of NFTX AMM pool factory.&#x20;

#### inventoryStaking

```solidity
function inventoryStaking() external view returns (address)
```

Address of NFTX inventory staking contract.&#x20;

#### WETH

```solidity
function WETH() external view returns (address)
```

Address of WETH contract.&#x20;

#### POOL\_DEFAULT\_ALLOC

```solidity
uint256 constant POOL_DEFAULT_ALLOC = 0.8 ether
```

Global liquidity provider vault fee percentage, set to 80%.

#### INVENTORY\_DEFAULT\_ALLOC

```solidity
uint256 constant INVENTORY_DEFAULT_ALLOC = 0.2 ether
```

Global inventory staker vault fee percentage, set to 20%.

## Variables

#### rewardFeeTier

```solidity
function rewardFeeTier() external view returns (uint24)
```

AMM pool fee tier that receives vault fees for liquidity providers.

#### nftxRouter

```solidity
function nftxRouter() external view returns (address)
```

Contract address of NFTX router.

#### treasury

```solidity
function treasury() external view returns (address)
```

Treasury address.

#### allocTotal

```solidity
function allocTotal() external view returns (uint256)
```

Total allocation across all `feeReceivers`.

#### feeReceivers

```solidity
function feeReceivers(
    uint256
)
    external
    view
    returns (
        address receiver,
        uint256 allocPoint,
        ReceiverType receiverType
    )
    
enum ReceiverType {
    INVENTORY,
    POOL,
    ADDRESS
}
```

List of fee receivers.

#### distributionPaused

```solidity
function distributionPaused() external view returns (bool)
```

Whether fee distribution has been paused.

## Events

#### UpdateTreasuryAddress

```solidity
event UpdateTreasuryAddress(address oldTreasury, address newTreasury)
```

Emitted by `setTreasuryAddress()`.

<table><thead><tr><th width="182.33333333333331">Parameters</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>oldTreasury</td><td><code>address</code></td><td>Previous treasury address.</td></tr><tr><td>newTreasury</td><td><code>address</code></td><td>New treasury address.</td></tr></tbody></table>

#### PauseDistribution

```solidity
event PauseDistribution(bool paused)
```

Emitted by `pauseFeeDistribution()`.

<table><thead><tr><th width="182.33333333333331">Parameters</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>paused</td><td><code>bool</code></td><td>Whether the contract was paused or unpaused.</td></tr></tbody></table>

#### NewRewardFeeTier

```solidity
event NewRewardFeeTier(uint24 rewardFeeTier)
```

Emitted by `changeRewardFeeTier()`.

<table><thead><tr><th width="182.33333333333331">Parameters</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>rewardFeeTier</td><td><code>address</code></td><td>The new reward fee tier that determins which AMM pools receive vault rewards .</td></tr></tbody></table>

#### NewNFTXRouter

```solidity
event NewNFTXRouter(address nftxRouter)
```

Emitted by `setNFTXRouter()`.

<table><thead><tr><th width="182.33333333333331">Parameters</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>nftxRouter</td><td><code>address</code></td><td>New NFTXRouter address.</td></tr></tbody></table>

#### WethDistributedToInventory

```solidity
event WethDistributedToInventory(uint256 vaultId, uint256 amount)
```

Emitted by `distribute()`.

<table><thead><tr><th width="182.33333333333331">Parameters</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultId</td><td><code>uint256</code></td><td>ID of vault.</td></tr><tr><td>amount</td><td><code>uin256</code></td><td>Amount of WETH.</td></tr></tbody></table>

#### WethDistributedToPool

```solidity
event WethDistributedToPool(uint256 vaultId, uint256 amount)
```

Emitted by `distribute()`.

<table><thead><tr><th width="182.33333333333331">Parameters</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultId</td><td><code>uint256</code></td><td>ID number of vault.</td></tr><tr><td>amount</td><td><code>uin256</code></td><td>Amount of WETH.</td></tr></tbody></table>

## Write Functions

#### distribute

```solidity
function distribute(uint256 vaultId) external
```

Distributes current WETH balance to `feeReceivers` for `vaultId.`

<table><thead><tr><th width="170.5">Parameters</th><th width="129">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultId</td><td><code>uint256</code></td><td>ID of vault.</td></tr></tbody></table>

#### distributeVTokensToPool

```solidity
function distributeVTokensToPool(
    address pool,
    address vToken,
    uint256 vTokenAmount
) external
```

Distributes vTokens to NFTX AMM pool. Can only be called by NFTXRouter when vTokens have been paid as part of an early withdrawal penalty.

<table><thead><tr><th width="170.5">Parameters</th><th width="129">Type</th><th>Description</th></tr></thead><tbody><tr><td>pool</td><td><code>address</code></td><td>Address of pool.</td></tr><tr><td>vToken</td><td><code>address</code></td><td>Address of vToken.</td></tr><tr><td>vTokenAmount</td><td><code>uint256</code></td><td>Amount of vToken.</td></tr></tbody></table>

## Owner Functions

#### setReceivers

```solidity
function setReceivers(
    FeeReceiver[] memory feeReceivers_
) external

struct FeeReceiver {
    address receiver;
    uint256 allocPoint;
    ReceiverType receiverType; // NOTE: receiver address is ignored for `POOL` type, as each vaultId has different pool address
}

enum ReceiverType {
    INVENTORY,
    POOL,
    ADDRESS
}
```

Sets fee receivers.

<table><thead><tr><th width="201.5">Parameters</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td>feeReceivers_</td><td><code>FeeReceiver[]</code></td><td>New fee receivers array.</td></tr></tbody></table>

#### changeRewardFeeTier

```solidity
function changeRewardFeeTier(uint24 rewardFeeTier_) external
```

Sets new reward fee tier (determining which AMM pool receives vault fees).&#x20;

Updating the reward fee tier here won't change the cardinality of existing AMM pools already deployed with `rewardFeeTier_`. That has to be increased externally for each pool. If the new rewardFeeTier pool doesn't exist for a vToken, then the corresponding vault fees immediately become 0 until liquidity is provided in the new pool.

<table><thead><tr><th width="206.5">Parameters</th><th width="122">Type</th><th>Description</th></tr></thead><tbody><tr><td>rewardFeeTier_</td><td><code>uint24</code></td><td>New reward fee tier. </td></tr></tbody></table>

#### setTreasuryAddress

```solidity
function setTreasuryAddress(address treasury_) external
```

Sets new treasury address.&#x20;

<table><thead><tr><th width="210.5">Parameters</th><th width="120">Type</th><th>Description</th></tr></thead><tbody><tr><td>treasury_</td><td><code>address</code></td><td>New treasury address.</td></tr></tbody></table>

#### setNFTXRouter

```solidity
function setNFTXRouter(INFTXRouter nftxRouter_) external
```

Sets NFTXRouter address.

<table><thead><tr><th width="210.5">Parameters</th><th width="148">Type</th><th>Description</th></tr></thead><tbody><tr><td>nftxRouter_</td><td><code>INFTXRouter</code></td><td>New NFTXRouter address.</td></tr></tbody></table>

#### pauseFeeDistribution

```solidity
function pauseFeeDistribution(bool pause) external
```

Pauses (or resumes) fee distribution.

<table><thead><tr><th width="210.5">Parameters</th><th width="148">Type</th><th>Description</th></tr></thead><tbody><tr><td>pause</td><td><code>bool</code></td><td>Whether the contract is being paused or un-paused.</td></tr></tbody></table>

#### rescueTokens

```solidity
function rescueTokens(IERC20 token) external
```

Rescues ERC20 token.

<table><thead><tr><th width="210.5">Name</th><th width="148">Type</th><th>Description</th></tr></thead><tbody><tr><td>token</td><td><code>IERC20</code></td><td>Address of token being rescued.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nftx.io/core-contracts/nftxfeedistributorv3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
