# StabilityFeeCollector

The `StabilityFeeCollector` is a contract responsible for collecting stability fees from various collateral pools within a FXD system. These fees are used to manage the stability of FXD by compensating for volatility in the collateral's value and ensuring the system's solvency. The contract provides functionality to calculate and accrue stability fees over time, ensuring they are consistently applied and collected.

#### Storage Variables

* `bookKeeper`: Reference to the `IBookKeeper` contract, managing the accounting of collateral and debts within the system.
* `systemDebtEngine`: Address of the contract responsible for handling system debts and stability fees accumulation.

#### Functions

* `pause()`: Pauses fee collection, preventing new fees from being accumulated.
* `unpause()`: Resumes fee collection, allowing fees to be accumulated again.
* `setSystemDebtEngine(address _systemDebtEngine)`: Updates the address of the system debt engine used for fee collection.
* `collect(bytes32 _collateralPool)`: Public function that anyone can call to trigger the collection of stability fees for a specific collateral pool. It updates the accumulated rate of fees for the pool.
* `_collect(bytes32 _collateralPoolId)`: Internal function that performs the actual calculation and collection of fees, updating the necessary state in the `bookKeeper` and collateral pool configuration.

#### Events

* `LogSetSystemDebtEngine(address indexed _caller, address _data)`: Emitted when the system debt engine address is updated.


---

# 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.fathom.fi/fxd-stablecoin/interfaces/stabilityfeecollector.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.
