# Pricing Engine

This document outlines our operational guidelines for handling price volatility and wide confidence intervals when utilizing the reported price provided by Pyth as our primary pricing reference. 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 said asset. If it exceeds a greater threshold, then Close Only mode will be active restricting all interactions except liquidations, closing position, and removing liquidity.

**Thresholds for "High Volatility Flag"**

* Pool 1 assets: \~2% difference between EMA and Spot.
* Metals: 0.66% difference between EMA and Spot.
* Currencies: 0.33% difference between EMA and Spot.
* Pool 3, 4, 5 asset: \~5% difference between EMA and Spot.

**Crypto Assets**

| Asset | Threshold |
| ----- | --------- |
| BTC   | 2.1%      |
| ETH   | 2.5%      |
| SOL   | 3.5%      |
| JITO  | 5%        |
| JUP   | 5%        |
| PYTH  | 4.5%      |
| W     | 5%        |
| BONK  | 6.3%      |

#### **2. Wide Confidence Intervals**

In situations where Pyth's confidence interval is exceptionally wide, indicating potential variance in the reported price, the protocol goes in Close Only mode. Prices reported by Pyth are considered invalid if the volatility flag is set and the value of confidence interval exceeds 1% of the reported price. To ensure functionality of the protocol during these times and consistent on-chain pricing, Flash will use proprietary backup oracle system to ensure protocol is functional.

**Volatility based fee** *(Subject to volatility of the asset)*

During periods of the High Volatility Flag threshold being active, flash's margin adds a fixed fee to new position opening to protect LPs and imitate an orderbook spread that happens during volatile times. This fee is only added on opening a position and increasing size on a existing position when the High Volatility flag is active.&#x20;

| Market   | Volatility fee |
| -------- | -------------- |
| Bitcoin  | 8bps           |
| Ethereum | 11bps          |
| Solana   | 15bps          |

{% hint style="info" %}
Detailed fee table which is subject to change according to risk profile of markets can be found [here](https://www.notion.so/flash-trade/Volatility-threshold-009d90d906a74b658b50588b4dcb48b6#18e1d77c7290806b9973dcf3d30cd18f)
{% endhint %}

**Wide Confidence Intervals with Moderate Volatility**

If the volatility flag is not set but the confidence interval reported by pyth is wide (>1% of reported price), we continue relying on Pyth's reported price. In such cases, the wide confidence interval itself does not necessitate corrective action.

#### **3. Price impact fee**

Price Impact fee is an adjustment based on a function of deviation in entry price from actual price reported by pyth pro feeds corresponding to the asset at the instant when you open a position. It accounts for potential latency in landing oracle update transactions and the discrete nature of sampling frequency used in recording the price published by the oracle, preventing misuse of the implicit latency by malicious actors and safeguarding the pool from offering prices that might be older than the actual price of that time.&#x20;

More details [here](https://docs.flash.trade/flash-trade/~/revisions/xKAncpdYLJG7bPOyq6YW/flash-trade-protocol/technical-architecture/pricing-engine/price-impact-fee).

#### **4. Handling Stable Coins**

For stable coins, we assess the difference between the reported price and the benchmark of $1 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 maximum price. Instructions involving actions that convert nominal usd values to token amounts like swaps and removing liquidity are calculated based on the $1 benchmark.

#### **5. Size Based Spread**

As traders increase their trade size from $1 to $1,000,000, there will be progressively wider spreads applied to their entry and exit prices. The specific spread amounts correspond to the values detailed in the table below.

| Market   | Spread Ranges |
| -------- | ------------- |
| Bitcoin  | 0%-0.04%      |
| Ethereum | 0%-0.06%      |
| Solana   | 0%-0.12%      |

#### **Conclusion**

These guidelines outline our approach to managing price volatility and handling wide confidence intervals in our operations. By adhering to these guidelines, we ensure accurate pricing and well-informed decisions across diverse market conditions. We will continue adapt our strategies to changing market dynamics, maintaining the reliability and effectiveness of our price management practices.


---

# 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.flash.trade/flash-trade/flash-trade-protocol/technical-architecture/pricing-engine.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.
