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

# Fee book

> The on-chain accounting behind the profit fee.

Every vault keeps its own fee accounting in contract storage — the **fee book**. It is the mechanical implementation of the [high-water mark](/fees/high-water-mark), and because it lives on-chain, you can audit your own fee state without trusting our servers.

## The three accumulators

| Accumulator   | Updated when            | Meaning                                                 |
| ------------- | ----------------------- | ------------------------------------------------------- |
| `contributed` | every deposit           | Cumulative capital in, valued at feed price at arrival  |
| `withdrawn`   | every outbound transfer | Cumulative value out, valued at feed price at departure |
| `taxed`       | every charged fee       | Cumulative profit that has already been charged         |

All three are monotonic — they only grow — which is what makes the accounting simple to verify and impossible to game by cycling funds.

## The fee rule

At each outbound transfer, the vault computes **new profit**:

```
newProfit = max(0, (withdrawn_after_this − contributed) − taxed)
fee       = newProfit × feeRate
```

In words: you're only charged when your *cumulative* withdrawals exceed your *cumulative* contributions, and only on the slice that hasn't been charged before. Principal first, profit once, losses never — see the [worked examples](/fees/worked-examples).

## Properties

* **`feeRate` is immutable** — set at deployment, capped by the vault generation, no setter exists.
* **Event-time valuation.** Every accumulator update uses the accepted price feed at that moment and emits an event, so the entire fee history is reconstructable from the chain.
* **Stale feed ⇒ waiver.** If a required feed is stale at the gate, the fee is zero and a waiver event is emitted — the book never records a guessed number.
* **Failed fee transfer ⇒ deferral.** The owed amount is booked per token and retried; the owner's payout is never held hostage by the treasury leg.
* **In-kind exits pay from loose balances.** When positions leave intact, the fee is collected from the vault's loose token balances; if they're insufficient, the exact shortfall is quoted to the owner up front rather than discovered mid-transaction.
