> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/technical-architecture/pricing-engine.md).

# Pricing Engine

These guidelines ensure accurate pricing and informed decision-making in various market conditions.

**1. Volatility Considerations**

We monitor market volatility by comparing the reported price to the exponential moving average ([EMA](https://docs.pyth.network/documentation/how-pyth-works/ema-price-aggregation)) reported by Pyth's oracles. If the difference between these prices exceeds a predefined threshold, the **High Volatility Flag** is set for the asset. If it exceeds a greater threshold, **Close Only mode** activates — restricting all interactions except liquidations, closing positions, and removing liquidity.

**High Volatility Flag — threshold ranges by asset class:**

| Asset Class                             | EMA vs Spot Threshold |
| --------------------------------------- | --------------------- |
| Crypto majors (BTC, ETH, SOL, ZEC, BNB) | \~2%                  |
| Metals (Gold, Silver)                   | 0.66%                 |
| Forex (EUR, GBP, AUD, USDJPY, USDCNH)   | 0.33%                 |
| Crude Oil                               | 2.2%                  |
| Natural Gas                             | 0.6%                  |
| Solana DeFi & Meme assets               | \~5%                  |
| Tokenized Equities (xStocks)            | 11.7%                 |

{% hint style="info" %}
Exact thresholds are tuned per asset based on individual risk profile, and may change as the protocol gathers more market data. The current flag status for any market is visible in the trade UI.
{% endhint %}

***

**2. Wide Confidence Intervals**

In situations where Pyth's confidence interval is exceptionally wide — indicating potential variance in the reported price — the protocol enters Close Only mode. Prices reported by Pyth are considered invalid if the volatility flag is set **and** the confidence interval exceeds 1% of the reported price. To ensure continued functionality and consistent on-chain pricing during these periods, Flash uses a proprietary backup oracle system.

**Volatility-Based Fee**

During High Volatility Flag periods, a fixed fee is added to new position opens and size increases. This protects LPs and replicates the wider spreads that orderbook venues experience during volatile conditions.

* Applied only on **opening** a position or **increasing size** on an existing position
* Not applied on closes, liquidations, or stable conditions
* Specific bps vary by asset risk profile

{% hint style="info" %}
Live volatility fees are surfaced in the trade UI when the High Volatility Flag is active on the market you're opening into.
{% endhint %}

**Wide Confidence Intervals with Moderate Volatility**

If the volatility flag is **not** set but the Pyth confidence interval is wide (>1% of reported price), the protocol continues using Pyth's reported price. The wide confidence interval alone does not necessitate corrective action.

***

**3. Price Impact Fee**

Price Impact is an adjustment based on the deviation between entry price and the actual price reported by Pyth's pro feeds at the instant a position is opened. It accounts for potential latency in landing oracle update transactions and the discrete nature of sampling frequency used in recording published prices — preventing misuse of implicit latency by malicious actors and safeguarding the pool from offering stale prices.

More details [here](/flash-trade/flash-trade-protocol/technical-architecture/pricing-engine/price-impact-fee.md).

***

**4. Handling Stable Coins**

For stable coins, we assess the difference between the reported price and the $1 benchmark to flag volatility. If the difference exceeds the threshold, the High Volatility Flag is set and we compute the minimum price by discounting the confidence interval from the reported price — while the reported price is established as the maximum price.

Instructions involving conversions from nominal USD values to token amounts (swaps, removing liquidity) are calculated based on the $1 benchmark.

***

**5. Size-Based Spread**

As trade size scales from $1 toward $1,000,000, progressively wider spreads are applied to entry and exit prices. This compensates the pool for absorbing larger directional exposure and discourages outsized single-trade impact on pool health.

* Spread scales continuously with trade size
* Higher-liquidity markets see tighter spread ranges than thinner ones
* Spread is reflected directly in the quoted entry/exit price before order confirmation

{% hint style="info" %}
Live size-based spread for any trade is visible in the trade UI as part of the quoted price before you submit the order.
{% endhint %}

***

**Conclusion**

These guidelines outline our approach to managing price volatility and handling wide confidence intervals across diverse market conditions. The framework is intentionally parameter-driven — specific thresholds, fees, and spreads are tuned per asset and adjusted as the protocol gathers more market data. The trade UI is the authoritative source for current values applied to any open or pending position.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/technical-architecture/pricing-engine.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
