# IFeeCalculator

Interface for a contract that calculates fees for a vault and protocol

## Functions

### registerVault

Register a new vault with the fee calculator

```solidity
function registerVault() external;
```

### claimFees

Process a fee claim for a specific vault

*Expected to be called by the vault only when claiming fees Only accrues fees and updates stored values; does not transfer tokens Caller must perform the actual transfers to avoid permanent fee loss*

```solidity
function claimFees(uint256 feeTokenBalance) external returns (uint256, uint256, address);
```

**Parameters**

| Name              | Type      | Description                               |
| ----------------- | --------- | ----------------------------------------- |
| `feeTokenBalance` | `uint256` | Available fee token balance to distribute |

**Returns**

| Name     | Type      | Description                                                                  |
| -------- | --------- | ---------------------------------------------------------------------------- |
| `<none>` | `uint256` | earnedFees The amount of fees to be claimed by the fee recipient             |
| `<none>` | `uint256` | protocolEarnedFees The amount of protocol fees to be claimed by the protocol |
| `<none>` | `address` | protocolFeeRecipient The address of the protocol fee recipient               |

### claimProtocolFees

Process a protocol fee claim for a vault

*Expected to be called by the vault only when claiming protocol fees Only accrues protocol fees and updates stored values; does not transfer tokens Caller must perform the actual transfers to avoid permanent protocol fee loss*

```solidity
function claimProtocolFees(uint256 feeTokenBalance) external returns (uint256, address);
```

**Parameters**

| Name              | Type      | Description                               |
| ----------------- | --------- | ----------------------------------------- |
| `feeTokenBalance` | `uint256` | Available fee token balance to distribute |

**Returns**

| Name     | Type      | Description                                                    |
| -------- | --------- | -------------------------------------------------------------- |
| `<none>` | `uint256` | accruedFees The amount of protocol fees claimed                |
| `<none>` | `address` | protocolFeeRecipient The address of the protocol fee recipient |

### previewFees

Returns the current claimable fees for the given vault, as if a claim was made now

```solidity
function previewFees(address vault, uint256 feeTokenBalance)
    external
    view
    returns (uint256 vaultFees, uint256 protocolFees);
```

**Parameters**

| Name              | Type      | Description                                                                                                                                                                               |
| ----------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `vault`           | `address` | The address of the vault to preview fees for                                                                                                                                              |
| `feeTokenBalance` | `uint256` | Available fee token balance to distribute If set to `type(uint256).max`, the function returns all accrued fees If set to an actual balance, the result is capped to that claimable amount |

**Returns**

| Name           | Type      | Description                                |
| -------------- | --------- | ------------------------------------------ |
| `vaultFees`    | `uint256` | The amount of claimable fees for the vault |
| `protocolFees` | `uint256` | The amount of claimable protocol fees      |

### protocolFeeRecipient

Returns the address that receives protocol fees

```solidity
function protocolFeeRecipient() external view returns (address);
```

**Returns**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `<none>` | `address` | The address that receives the protocol fees |

## Events

### VaultRegistered

Emitted when a new vault is registered

```solidity
event VaultRegistered(address indexed vault);
```

**Parameters**

| Name    | Type      | Description                         |
| ------- | --------- | ----------------------------------- |
| `vault` | `address` | The address of the registered vault |

## Errors

### Aera\_\_VaultAlreadyRegistered

Thrown when attempting to register an already registered vault

```solidity
error Aera__VaultAlreadyRegistered();
```


---

# 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.aera.finance/the-protocol/core/ifeecalculator.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.
