back18 Jul 20226 min read
blog post image

Pyth Primer: Confidence Intervals

TL;DR:

Confidence intervals are powerful tools unique to Pyth which protect our data users and empower their protocols to make safer and more-informed decisions.

  • Confidence intervals measure the uncertainty in the reported price. This is critical information for protocols!
  • Every Pyth price feed provides an accompanying confidence interval.
  • This blog post provides some examples of how developers using Pyth can integrate confidence intervals to improve their protocols’ safety and decision-making.

Built Different

Not all oracles are built the same. The Pyth Network takes a unique approach to designing a financial oracle network. More specifically, Pyth is the largest and premier Publisher Oracle Network: all of Pyth’s data sources are first-party sources, meaning they own and create the data that they submit to the network, instead of purchasing or collecting it from other sources.

The result? Data middlemen costs are eliminated; data is timely and licensed; the network is maximally scalable; and — the focus of today’s blog post — Pyth can source additional information from all of its market data providers beyond just the price.

On the Pyth Network, all data providers are required to submit not only price quotes, but also accompanying confidence intervals — an informative metric reflecting the provider's estimation uncertainty of their submitted price.

Pyth’s on-chain program then aggregates the price quote and confidence interval input to generate the (aggregate) price and confidence interval feeds. Hence, Pyth’s BTC/USD feed will look something like $19,405.19 ± $9.907 instead of just $19,405.19. This supplementary metric is extremely beneficial for applications looking for additional safety rails and deeper context on the data they’re using.

Pyth is the only oracle solution offering a confidence interval metric for every data feed. This primer will focus on Pyth’s unique confidence interval design and how it benefits Pyth’s data users. We also offer some real-world example applications of confidence intervals, which we hope can inspire the developer community!


How Do Confidence Intervals Work?

By way of quick review, the Pyth Network confidence interval represents the estimated uncertainty of the price. As discussed in a previous deep-dive post:

"In scientific and engineering fields, an observation or measurement is almost always accompanied by a measurement uncertainty. Measurement uncertainty indicates how much precision or uncertainty there is in a single observation…the observer’s best estimate of how far off from the 'true' value their measurement is likely to be."

The distance between two points might be measured to be 10.12m ± 0.01m. The time it took for a car to travel that distance might be 1.23s ± 0.05s. In the context of the Pyth Network, a BTC/USD price feed might read $19,405.19 ± $9.907, indicating high conviction in the aggregate price with less than $10 of uncertainty ($9.907/$19,405.19 0.05%).

One can visualize the confidence measure of ±$9.907 measures as a “band” around the aggregate price action. A widening of the band indicates greater uncertainty, and narrower bands indicate greater certainty.

Where Does Estimation Uncertainty Come From?

It is important to remember that there is no “one price” or “true price” for an asset: instead, there are (at a simplified view) multiple venues or exchanges which have their own best bid and best ask prices, or venues reporting a sequence of previously transacted prices. In the case of a price feed like BTC/USD, one will encounter different prices at various venues at any given time.

Prices between these data providers may diverge because of differences in liquidity or due to extreme events such as suspended withdrawals or halted trading. In different markets (equities, FX, crypto, etc.), measurements of confidence (uncertainty) will vary due to market structure. An exchange, for example, could represent its confidence as the bid-ask spread on that venue; and a data provider that focuses on multiple venues could represent confidence as a function of where they expect trades to occur.

The Pyth Network recognizes that there are real-world circumstances in which prices across venues disagree: the oracle should reflect those circumstances.

Aggregating Every Data Provider's Estimations

In order to capture a broad snapshot of the markets, the Pyth Network requires there to be multiple data providers (currently up to 32) supporting every price feed. Pyth data providers submit both their price quotes and calculated confidence intervals at every Solana slot (every 400ms).

Pyth’s on-chain program then aggregates every data provider's inputs into a single price stream (which closely estimates the “true price”) plus the accompanying streaming confidence feed. The aggregate confidence feed reflects the variation between those data providers’ prices. Periods of high volatility or low liquidity, for example, may bring about large price divergences across different exchanges.


Why Confidence Matters

By continuously streaming a consolidated estimate of these important price dislocations, the Pyth Network empowers downstream data consumers. Developers can specify how their protocols will handle potential variations in confidence (that is, unusual and extreme market conditions) for safer and more precise operations.

One common use case of Pyth’s confidence intervals relates to borrow-lending protocols and their liquidation functions. Borrow-lending platforms must constantly monitor the “health” of their borrowers’ positions: should the market value of their collateral fall below a predefined liquidation threshold, the protocol must liquidate that user. If the protocol receives an inaccurate oracle price, however, users can be incorrectly liquidated.

Confidence intervals enable developers to better deal with this difficulty by treating the confidence reading as a conviction metric. For example, if the oracle price falls but the confidence bands simultaneously widen, the borrow-lending protocol can acknowledge this increased price uncertainty and delay action (liquidation) until the next block or until certainty stabilizes. Once data providers'’ conviction in the accuracy of their reported price is restored, the protocol can reassess the collateral value and act accordingly.


Confidence Interval Case Studies

Below are some examples of mainnet applications and how they leverage the Pyth confidence interval feature:

Borrowing and Lending

Borrow/lending protocols like Solend or Jet Protocol utilize Pyth prices and confidence intervals to ensure that the platform does not enable any bad debt. Accordingly, they must actively identify and liquidate unhealthy user positions.

Both Solend and Jet use Pyth’s confidence intervals to ensure that prices are accurate when calculating user account health. In the case of Jet Protocol, the Pyth confidence interval allows for more precise liquidation operations. When an unhealthy position is detected, the protocol compares the reported confidence interval of the collateral assets to Jet’s hourly TWAP.

In Jet's case, the protocol utilizes a threshold of greater than five percent: if the confidence interval at that moment exceeds that hourly TWAP by more than five percent in either direction, Jet Protocol rejects the price and withholds liquidating for that moment.

Automated Market Makers (AMMs)

DeltaFi is an AMM DEX on Solana focused on efficient pool prices, sustainable yield for LPs, and cross-chain compatibility. DeltaFi utilizes Pyth’s real-time prices in their pricing algorithm to minimize impermanent loss for liquidity providers.

DeltaFi uses Pyth confidence intervals to protect liquidity providers from price volatility. To further ensure price accuracy, DeltaFi first checks if the market is stable or unstable. (When markets are more stable, the confidence interval will be closer to 0). In cases of more volatile markets, the price displayed to traders will increase based on the confidence interval to allow for more conservative trades.

Derivatives

Zeta Markets is an under-collateralized DeFi options and derivatives platform on Solana. Zeta is a consumer of Pyth’s price feeds, and moreover, Pyth’s confidence value enables Zeta to provide short-term binary options without worrying about whether the oracle price has a large candle on the last second of trading.

"Zeta’s binary options settle to half their payout for both longs and shorts if the strike is within this uncertainty interval. This allows us to provide tradeable, short-term products whilst preventing the risk of random price disagreements close to expiry!"

You can read Zeta’s thread and Pyth’s thread on this topic to learn more.


We can’t wait to hear what you think! Feel free to join the Pyth Discord, follow Pyth on Twitter, and join the Telegram to learn more and ask any questions. Take fate into your own hands.

Stay Updated with Pyth

Stay informed about Pyth network's development and upcoming events!

Recommended For You

all posts