> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/reserve-protocol/reserve-index-dtf/llms.txt
> Use this file to discover all available pages before exploring further.

# Fee Structure

> Learn about TVL fees, mint fees, and how DAO revenue sharing works in Reserve Folio

## Overview

Reserve Folio implements a dual-fee system designed to sustain both individual Folios and the broader protocol ecosystem. All fees include a mandatory DAO component that supports protocol development.

## Fee Types

Folios support two primary fee mechanisms:

<CardGroup cols={2}>
  <Card title="TVL Fee" icon="chart-line">
    **Continuous fee on assets under management**

    Charged per second on total Folio value. Manifests as supply inflation, discretely applied once per day.

    * Max: 10% annually
    * DAO floor: 15 bps annually
  </Card>

  <Card title="Mint Fee" icon="coins">
    **One-time fee on minting**

    Charged when users mint new Folio shares. Deducted from shares issued.

    * Max: 5%
    * DAO floor: 15 bps
  </Card>
</CardGroup>

## TVL Fee (Time-Based)

A continuous fee on assets under management, charged per second.

### How It Works

1. **Accrual**: Fee accrues every second based on total supply
2. **Discretization**: Applied in full-day increments (every 24 hours)
3. **Supply Inflation**: Creates new shares rather than transferring existing ones
4. **Distribution**: Split between DAO and fee recipients

### Fee Calculation

```solidity theme={null}
// TVL fee is stored as per-second rate
tvlFee = annualFee * ONE_OVER_YEAR; // D18{1/s}

// Fee shares calculation
function computeFeeShares(uint256 supply, uint256 elapsed) returns (uint256) {
    // {share} = {share} * D18{1/s} * {s} / D18
    return supply * tvlFee * elapsed / D18;
}
```

<CodeGroup>
  ```solidity Example: 2% Annual TVL Fee theme={null}
  // 2% annual = 0.02e18
  folio.setTVLFee(0.02e18);

  // Internally stored as per-second rate:
  // tvlFee = 0.02e18 * 31709791983 / 1e18
  //        = 634195839 (per second)

  // For 1M shares over 1 day:
  // feeShares = 1_000_000e18 * 634195839 * 86400 / 1e18
  //           ≈ 54.79e18 (0.0055% daily)
  ```
</CodeGroup>

### Setting TVL Fee

Only `DEFAULT_ADMIN_ROLE` can modify:

```solidity theme={null}
/// @param _newFee D18{1} Annual percentage (e.g. 0.02e18 for 2%)
function setTVLFee(uint256 _newFee) external onlyRole(DEFAULT_ADMIN_ROLE)
```

<Warning>
  TVL fees below the DAO fee floor (typically 15 bps) result in 100% of the fee going to the DAO.
</Warning>

## Mint Fee (One-Time)

A percentage fee charged when minting new shares.

### How It Works

1. **Calculation**: Percentage of shares to be minted
2. **Deduction**: Fee shares are NOT given to the minter
3. **Distribution**: Split between DAO and fee recipients
4. **No Supply Inflation**: Total shares minted equals `shares` parameter

### Mint Shares Distribution

When minting with a mint fee:

```solidity theme={null}
// User wants to mint 1000 shares with 1% mint fee
totalShares = 1000e18;

// Mint fee calculation (see FolioLib.computeMintFees)
feeShares = totalShares * mintFee / (D18 + mintFee);

// Distribution:
sharesOut = totalShares - feeShares - folioFeeForSelfAmount;
daoFeeShares = daoFee;
feeRecipientShares = feeShares - daoFee - folioFeeForSelfAmount;
```

<Info>
  The user deposits assets for `totalShares` but receives fewer due to fees.
</Info>

### Setting Mint Fee

Only `DEFAULT_ADMIN_ROLE` can modify:

```solidity theme={null}
/// @param _newFee D18{1} Percentage (e.g. 0.01e18 for 1%)
function setMintFee(uint256 _newFee) external onlyRole(DEFAULT_ADMIN_ROLE)
```

<CodeGroup>
  ```solidity Example: 0.5% Mint Fee theme={null}
  // Set 0.5% mint fee
  folio.setMintFee(0.005e18);

  // When user mints 1000 shares:
  // - Fee shares: ~4.975 shares
  // - User receives: ~995.025 shares (after all fees)
  // - DAO receives: ≥0.746 shares (15 bps minimum)
  // - Fee recipients: remainder
  ```
</CodeGroup>

## DAO Fee Floor

The protocol enforces a minimum fee that goes to the DAO.

### Default Floor: 15 bps

By default, the DAO receives at least 15 basis points from all fees:

```solidity theme={null}
// If Folio sets TVL fee to 0.15% (15 bps):
// → 100% goes to DAO
// → 0% goes to fee recipients

// If Folio sets TVL fee to 1%:
// → 15 bps goes to DAO
// → 85 bps goes to fee recipients

// If Folio sets TVL fee to 0.10% (below floor):
// → DAO still receives 15 bps worth
// → Fee recipients receive 0
```

### Adjustable Floor

The DAO can adjust the fee floor:

<CardGroup cols={2}>
  <Card title="Global Floor" icon="globe">
    DAO can lower the universal 15 bps floor for all Folios via `FolioDAOFeeRegistry.setDefaultFeeFloor()`.
  </Card>

  <Card title="Per-Folio Floor" icon="building">
    DAO can set lower floors for specific Folios via `FolioDAOFeeRegistry.setTokenFeeFloor()`.
  </Card>
</CardGroup>

<Note>
  The DAO can only lower the fee floor, never raise it above 15 bps without protocol upgrade.
</Note>

## Folio Self Fee

Folios can burn a portion of fee-recipient shares to reduce supply inflation.

### How It Works

Instead of distributing all fee-recipient shares, a percentage can be burned:

```solidity theme={null}
/// @param _newFee D18{1} Fraction of fee-recipient shares to burn (0 to 1e18)
function setFolioSelfFee(uint256 _newFee) external onlyRole(DEFAULT_ADMIN_ROLE)
```

<CodeGroup>
  ```solidity Example: 50% Self Fee theme={null}
  // Set 50% of fee-recipient shares to be burned
  folio.setFolioSelfFee(0.5e18);

  // When fees are distributed:
  // - DAO receives: full DAO amount
  // - Fee recipients receive: 50% of their amount
  // - Burned: 50% of fee-recipient amount
  ```
</CodeGroup>

<Info>
  Burning fee shares reduces inflation for all holders, effectively distributing value to existing shareholders.
</Info>

## Fee Recipients

Folios can configure multiple fee recipients with custom allocations.

### Fee Recipient Structure

```solidity theme={null}
struct FeeRecipient {
    address recipient;  // Address to receive fees
    uint96 portion;     // D18{1} Fraction of total (must sum to 1e18)
}
```

### Configuring Recipients

```solidity theme={null}
/// @dev Fee recipients must be unique, sorted by address, and sum to 1e18
function setFeeRecipients(
    FeeRecipient[] calldata _newRecipients
) external onlyRole(DEFAULT_ADMIN_ROLE)
```

<CodeGroup>
  ```solidity Example: Three Fee Recipients theme={null}
  FeeRecipient[] memory recipients = new FeeRecipient[](3);

  recipients[0] = FeeRecipient({
      recipient: address(0x123...),
      portion: 0.5e18  // 50%
  });

  recipients[1] = FeeRecipient({
      recipient: address(0x456...),
      portion: 0.3e18  // 30%
  });

  recipients[2] = FeeRecipient({
      recipient: address(0x789...),
      portion: 0.2e18  // 20%
  });

  folio.setFeeRecipients(recipients);
  ```
</CodeGroup>

<Warning>
  Recipients must:

  * Be sorted by address (ascending)
  * Have unique addresses
  * Have portions that sum to exactly 1e18
  * Not exceed 64 recipients (MAX\_FEE\_RECIPIENTS)
</Warning>

### Empty Fee Recipients

If no fee recipients are configured:

```solidity theme={null}
// Empty array → 100% of fees go to DAO
FeeRecipient[] memory empty = new FeeRecipient[](0);
folio.setFeeRecipients(empty);
```

## Fee Distribution

Fees are distributed when `distributeFees()` is called or automatically during certain operations.

### Manual Distribution

```solidity theme={null}
/// Distribute all pending fee shares
function distributeFees() external
```

### Automatic Distribution

Fees are automatically distributed during:

* `setTVLFee()`
* `setMintFee()`
* `setFolioSelfFee()`
* `setFeeRecipients()`

### Pending Fee Shares

Fee shares accrue but are not minted until distribution:

```solidity theme={null}
/// @return {share} Total pending fee shares (DAO + fee recipients)
function getPendingFeeShares() external view returns (uint256)

/// Includes pending shares in total supply
function totalSupply() public view override returns (uint256)
```

<Note>
  Pending fee shares are already reflected in `totalSupply()` even before distribution. This ensures accurate accounting for minting and redemption.
</Note>

## Fee Examples

### Example 1: Standard Folio (2% TVL, 0.25% Mint)

<Steps>
  <Step title="Fee Configuration">
    ```solidity theme={null}
    folio.setTVLFee(0.02e18);    // 2% annual
    folio.setMintFee(0.0025e18); // 0.25%
    ```
  </Step>

  <Step title="Annual Fees">
    For a Folio with \$10M TVL:

    * TVL fee: \$200,000/year
    * DAO receives: ≥\$15,000 (15 bps minimum)
    * Fee recipients: ≤\$185,000
  </Step>

  <Step title="Mint Fees">
    User mints \$100,000 worth:

    * Mint fee: \$250
    * DAO receives: ≥\$15 (15 bps minimum)
    * Fee recipients: ≤\$235
  </Step>
</Steps>

### Example 2: Low-Fee Folio (0.15% TVL, 0.15% Mint)

<Steps>
  <Step title="Fee Configuration">
    ```solidity theme={null}
    folio.setTVLFee(0.0015e18);  // 0.15% annual
    folio.setMintFee(0.0015e18); // 0.15%
    ```
  </Step>

  <Step title="Fee Distribution">
    Both fees are at the DAO floor (15 bps):

    * **100% of all fees go to DAO**
    * Fee recipients receive 0
  </Step>
</Steps>

### Example 3: High-Fee Active Folio (5% TVL, 2% Mint)

<Steps>
  <Step title="Fee Configuration">
    ```solidity theme={null}
    folio.setTVLFee(0.05e18);    // 5% annual
    folio.setMintFee(0.02e18);   // 2%
    folio.setFolioSelfFee(0.3e18); // Burn 30%
    ```
  </Step>

  <Step title="Fee Distribution">
    For \$10M TVL:

    * TVL fee: \$500,000/year
    * DAO receives: ≥\$15,000
    * Fee recipients: $339,500 (70% of $485,000)
    * Burned: $145,500 (30% of $485,000)
  </Step>
</Steps>

## Fee Limits

The protocol enforces hard caps on fees:

```solidity theme={null}
MAX_TVL_FEE = 0.1e18;   // 10% annually (D18{1/year})
MAX_MINT_FEE = 0.05e18;  // 5% (D18{1})
MAX_FOLIO_FEE = 1e18;    // 100% (D18{1})
```

<Warning>
  Attempting to set fees above these limits will revert the transaction.
</Warning>

## DAO Fee Registry

The `FolioDAOFeeRegistry` contract manages DAO fee configuration.

### Key Functions

```solidity theme={null}
interface IFolioDAOFeeRegistry {
    /// Get fee details for a Folio
    /// @return recipient DAO fee recipient address
    /// @return feeNumerator Numerator for DAO share calculation
    /// @return feeDenominator Denominator for DAO share calculation  
    /// @return feeFloor Minimum fee floor (D18)
    function getFeeDetails(address folio) external view returns (
        address recipient,
        uint256 feeNumerator,
        uint256 feeDenominator,
        uint256 feeFloor
    );
}
```

### DAO Fee Calculation

The DAO's share is calculated as:

```solidity theme={null}
// DAO share of fee-recipient allocation
daoShare = feeRecipientAmount * feeNumerator / feeDenominator;

// Ensure minimum floor
daoFee = max(daoShare, totalShares * feeFloor / D18);
```

## Best Practices

<AccordionGroup>
  <Accordion title="Setting Appropriate Fees">
    **Consider:**

    * Active vs passive management style
    * Competitor fee rates
    * Value provided to holders
    * DAO minimum requirements

    **Guidelines:**

    * Passive indices: 0.25% - 1% TVL fee
    * Active strategies: 1% - 5% TVL fee
    * Low mint fees (0.1% - 0.5%) encourage usage
    * Higher mint fees (1% - 5%) for exclusive strategies
  </Accordion>

  <Accordion title="Fee Recipient Configuration">
    **Best Practices:**

    * Document recipient purposes transparently
    * Use multi-sigs for team allocations
    * Consider time-locked vesting contracts
    * Review and adjust periodically
    * Ensure recipients can handle share transfers
  </Accordion>

  <Accordion title="Fee Distribution Timing">
    **TVL Fees:**

    * Automatically accrue and apply daily
    * No manual intervention needed
    * Consider calling distributeFees() before major announcements

    **Mint Fees:**

    * Applied immediately on mint
    * Shares remain pending until distribution
    * Automatically distributed when fee parameters change
  </Accordion>

  <Accordion title="DAO Fee Floor">
    **For New Folios:**

    * Accept 15 bps DAO floor as standard
    * Set fees above floor to keep some revenue
    * Request per-Folio floor reduction if needed

    **For Established Folios:**

    * Build track record before requesting floor reduction
    * Demonstrate value to ecosystem
    * Engage with DAO governance
  </Accordion>
</AccordionGroup>

## Fee Transparency

All fees are fully transparent and queryable on-chain:

```solidity theme={null}
// Current fee configuration
uint256 tvlFee = folio.tvlFee();     // D18{1/s} per-second rate
uint256 mintFee = folio.mintFee();   // D18{1} percentage
uint256 selfFee = folio.folioFeeForSelf(); // D18{1} burn fraction

// Fee recipients
uint256 recipientCount = folio.feeRecipients(0).length;
FeeRecipient memory recipient = folio.feeRecipients(0);

// Pending fees
uint256 pending = folio.getPendingFeeShares();
```
