> ## Documentation Index
> Fetch the complete documentation index at: https://docs.redpotion.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Fee Manager

> FeeManager holds the fund's fee configuration and fee-accounting state, and computes fee accrual at each settlement. It never holds assets or mints shares itself—it returns amounts

> Source: [`src/FeeManager.sol`](https://github.com/zentryHQ/red-potion-contract/blob/main/src/FeeManager.sol)

## Responsibility

`FeeManager` holds the fund's **fee configuration and fee-accounting state**, and computes fee accrual at each settlement. It never holds assets or mints shares itself—it returns amounts and recipients, and the [Fund](/developers/contract-reference/fund) does the minting.

All fees are paid **in newly minted shares** (diluting existing holders), never in assets:

| Fee             | Accrues at                        | Formula                                                               | Paid to                                                                               |
| --------------- | --------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| **Entry**       | Deposit batch settlement          | `totalShares × entryFeeBps / 10000` withheld from minted shares       | `feeRecipient`                                                                        |
| **Exit**        | Redeem batch settlement           | `redeemShares × exitFeeBps / 10000` re-minted; payout uses net shares | `feeRecipient`                                                                        |
| **Management**  | Report acceptance (time-based)    | `totalSupply × managementFeeBps × elapsed / (10000 × 365 days)`       | `feeRecipient`                                                                        |
| **Performance** | Report acceptance, only above HWM | `totalSupply × (price − HWM) × performanceFeeBps / (price × 10000)`   | `feeRecipient`                                                                        |
| **Protocol**    | Report acceptance (time-based)    | Same shape as management, at `protocolFeeBps`                         | protocol fee recipient (resolved live via `Fund → FundManager → FundManagerDeployer`) |

<Info>
  **High-water mark (HWM)** is tracked on the fee-base-asset share price. First accrual initializes it; afterwards, performance fee only accrues when the new price exceeds the HWM, which ratchets up to the new price.
</Info>

<Info>
  **Fee base asset:** management, performance, and protocol fees accrue on the base asset's report, which is why the Fund always includes `feeBaseAsset` in the reported asset set.
</Info>

<Info>
  **Protocol fee recipient** is not stored here—it is read from the [FundManagerDeployer](/developers/contract-reference/fund-manager-deployer) at accrual time. If the resolved recipient is zero, the protocol fee is skipped.
</Info>

<Info>
  All bps values are capped at 10000 (100%).
</Info>

Admin functions authorize against the **Fund's** access control (spoke pattern).

## Function reference

### Fund-only

| Function                            | Access     | Description                                                                                                                                                                                                                                                                  |
| ----------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accrueFees(totalSupply, newPrice)` | `onlyFund` | Computes management, performance, and protocol fee shares since `lastFeeAccrual`, updates HWM and `lastFeeAccrual`, and returns `(recipient, feeShares, protocolRecipient, protocolFeeShares)` for the Fund to mint. Called once per accepted report, on the fee base asset. |

### Admin setters

Roles are checked on the Fund.

| Function                 | Role                      | Description                                                                                               |
| ------------------------ | ------------------------- | --------------------------------------------------------------------------------------------------------- |
| `setFeeConfig(config)`   | `SET_FEES_ROLE`           | Set all five bps values at once (`entry`, `exit`, `management`, `performance`, `protocol`), each ≤ 10000. |
| `setFeeRecipient(addr)`  | `SET_FEE_RECIPIENT_ROLE`  | Where fund-level fee shares are minted. Non-zero.                                                         |
| `setFeeBaseAsset(asset)` | `SET_FEE_BASE_ASSET_ROLE` | The asset whose reported price drives HWM/mgmt/perf/protocol accrual and risk valuation. Non-zero.        |

### Views

`getFeeConfig()`, `entryFeeBps`, `exitFeeBps`, `managementFeeBps`, `performanceFeeBps`, `protocolFeeBps`, `feeBaseAsset`, `feeRecipient`, `highWaterMark`, `lastFeeAccrual`, `fund()`.

## Related

[Fund](/developers/contract-reference/fund) · [FundManagerDeployer](/developers/contract-reference/fund-manager-deployer) · [Fees (user guide)](/using-redpotion/fees)
