> For the complete documentation index, see [llms.txt](https://docs.mento.org/mento-v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mento.org/mento-v3/build/smart-contracts/breakerbox.md).

# BreakerBox

**BreakerBox** is an on-chain circuit breaker for oracle feeds. It maintains a state per price feed (e.g. trading allowed or suspended) and supports modular addition of price feeds and breaker logic. In **Mento V3**, the **OracleAdapter** reads from BreakerBox when supplying the FPMM pool with a valid rate; if a breaker has tripped, the adapter returns invalid and swaps revert. This protects pools from trading on stale or out-of-bounds oracle data.

For **FX pairs**, Mento also uses a **MarketHoursBreaker**. This aligns on-chain trading with reference FX market hours: Chainlink FX feeds typically stop updating on weekends and certain holidays, so Mento can reject FX trading even if the last reported rate is still recent enough by timestamp.

**Contract:** [mento-protocol/mento-core](https://github.com/mento-protocol/mento-core) — `contracts/oracles/BreakerBox.sol`

Integrators typically **do not** call BreakerBox directly; the [OracleAdapter](/mento-v3/build/smart-contracts/oracleadapter.md) uses it. If you need to check trading mode (e.g. for a status UI), use the adapter’s `getRate(rateFeedID)` and inspect `tradingMode`, or call `getTradingMode(rateFeedID)` on the adapter if exposed.

### MedianDeltaBreaker

**MedianDeltaBreaker** is a circuit breaker that trips when the current median oracle rate compared to an exponential moving average over previous median rates exceeds a configured relative threshold.

{% embed url="<https://github.com/mento-protocol/mento-core/blob/main/contracts/oracles/breakers/MedianDeltaBreaker.sol>" %}
MedianDeltaBreaker.sol
{% endembed %}

### ValueDeltaBreaker

**ValueDeltaBreaker** is a circuit breaker that trips when the current median oracle rate compared to a fixed reference rate exceeds a configured relative threshold.

{% embed url="<https://github.com/mento-protocol/mento-core/blob/main/contracts/oracles/breakers/ValueDeltaBreaker.sol>" %}
ValueDeltaBreaker.sol
{% endembed %}

### MarketHoursBreaker

**MarketHoursBreaker** is a special breaker for **FX market-hours gating**. Instead of comparing prices, it checks whether the current block timestamp falls inside the configured FX trading window. The current implementation treats the FX market as closed:

* from **Friday 21:00 UTC** until **Sunday 23:00 UTC**
* on **Christmas Day (Dec 25)** and **New Year's Day (Jan 1)**
* after **22:00 UTC** on **Dec 24** and **Dec 31**

When this breaker says the FX market is closed, `OracleAdapter.getFXRateIfValid()` reverts and FX-priced FPMM swaps revert too. This is especially relevant for GBP/USD, EUR/USD, and similar fiat FX feeds, whose Chainlink rates generally do not update during those closure windows.

{% embed url="<https://github.com/mento-protocol/mento-core/blob/main/contracts/oracles/breakers/MarketHoursBreaker.sol>" %}
MarketHoursBreaker.sol
{% endembed %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mento.org/mento-v3/build/smart-contracts/breakerbox.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
