The Pyth Network has launched Pyth Price Feeds (also known as Pythnet Price Feeds), a new highly accurate and scalable price oracle. The oracle is designed around a new on demand or pull-based price update model that eliminates some of the key cost tradeoffs that limit the performance of prior designs.
Most applications use a push oracle for price updates, in which the oracle operator or other privileged parties continuously push updates to each blockchain. Pyth's pull oracle empowers users to pull prices on-chain only when they are needed.
This pull oracle design improves on existing oracles by eliminating transaction costs paid by the oracle and data providers, which enables Pyth to scale in ways that traditional push oracles cannot. Consequently, Pythnet Price Feeds can support high-frequency price updates for thousands of price feeds across an unlimited number of blockchains. These price feeds are secure, highly available, and accurately track asset prices on centralized and decentralized exchanges at ultra-low latencies.
This post explores the design of Pythnet Price Feeds and empirically demonstrates that the oracle reduces price tracking error by 5–10x over competing oracles.
Push or Pull?
Most other oracles — including Pyth’s Solana Price Feeds — use a push oracle for price updates.
In this model, the oracle operator (or other privileged parties) continuously pushes price updates to each individual blockchain. The oracle operator must pay transaction fees for each price update, which is a fundamental tradeoff between cost and scalability. Increasing the number of price feeds, supporting additional blockchains, or pushing more frequent updates all incur additional transaction costs. Consequently, push oracles are limited to offer infrequent updates to a limited set of feeds on a small number of blockchains.
Pythnet Price Feeds eliminate this tradeoff by introducing a “pull” oracle for on-demand price updates. Instead of constantly pushing prices on-chain, Pythnet Price Feeds allow users to pull prices on-chain only when they are needed.
Pyth streams price updates off-chain, signing each update such that anyone can verify its authenticity. When an update is needed on-chain, users craft a single transaction that simultaneously updates the Pyth price and uses it in a downstream protocol. Off-chain price updates are nearly free, which enables the oracle to offer frequent updates to a large number of feeds across many blockchains. For more information on Pythnet Price Feeds, please see the relevant section of the documentation.
The following table shows how Pythnet Price Feeds compare to push oracles on several dimensions:
This new oracle improves existing applications and enables fundamentally new ones. It increases the security of existing protocols by eliminating the risk of delayed oracle updates during busy periods. It enables developers to build protocols that require oracle prices that closely track centralized exchanges. It massively expands the range of products and blockchains protocols can support interesting financial operations for. In a nutshell, it fundamentally reinvents the scope of what on-chain financial applications can do.
Pythnet Price Feeds
The diagram above shows the overall architecture of Pythnet Price Feeds. Data providers publish their prices on Pythnet, an application-specific blockchain dedicated to Pyth. The on-chain aggregation program then aggregates prices for a feed to obtain the aggregate price and confidence. Next, the attester program regularly attests to the most recently observed Pyth prices and creates a Wormhole message to be sent to the Wormhole contract on Pythnet. The Wormhole guardians then observe the attestation message and create a signed VAA for the message. The result of this entire process is a stream of signed Pyth price updates that can be verified on any blockchain.
The price service is a utility that helps users consume this stream of price updates. This service continuously listens to Wormhole for Pyth price update messages. It caches recent update messages in memory and exposes HTTP and WebSocket APIs for retrieving the latest update. (Anyone can run an instance of this web service, but the Pyth Data Association runs a public instance for convenience.) When users want to use a Pyth price in a transaction, they retrieve the latest update message (a signed VAA) from the price service and submit it in their transaction. The target chain Pyth contract will verify the validity of the price update message and, if it is valid, store the new price in its on-chain storage.
Finally, on-chain protocols integrate with the Pyth contract via a simple API that retrieves the current Pyth price from its on-chain storage. This API will return the current price as long as it has been updated sufficiently recently; this approach works because users will have updated the Pyth price earlier in the same transaction. Protocols can configure the recency threshold to suit their needs — e.g., latency-sensitive applications can set a lower threshold than the default.
Pyth prices can be incorporated into protocol logic in different ways, depending on the use case and constraints of the relevant protocol. For extremely latency-sensitive applications, it may be advisable to use Pyth in a different way than protocols that aren’t as latency-sensitive. For more details on this, we refer you to our docs.
The design of Pythnet Price Feeds is highly scalable because the oracle and its data providers do not pay any transaction costs. Note that, in the diagram above, every step of the process is free except for updating the price in the on-chain Pyth contract. However, this cost is not borne by the oracle itself but instead by the user who needs the price (where it is only a portion of their overall transaction cost). Avoiding these transaction costs is the fundamental driver behind the scalability of Pythnet Price Feeds. It enables it to offer frequent price updates for many price feeds on many blockchains.
Empirical Analysis
One of the critical benefits of Pythnet Price Feeds is that its scalability allows it to closely track the prices of assets on their primary trading venues. We showcase its accuracy via an in-depth analysis of the Pyth feeds for ETH/USD and AAVE/USD — two pairs where the quote tokens are of very different market caps and trade on very different sets of exchanges. We then compare Pyth to several significant competitor oracles on the chains on which they are deployed.
All of the analyses below use prices between November 17, 2022, through November 24, 2022 (except where explicitly noted). This week had significant price volatility, making it a good test for oracle accuracy. We compare Pyth, and competitor oracle feeds against the prices on the most liquid centralized exchange for the pair. In some cases, the most liquid pair is against USDT, in which case we converted to USD using the USDT/USD exchange rate.
ETH/USD
For the first analysis, we chose ETH/USD, a highly-liquid pair traded on many exchanges. The charts below compare Pyth’s prices for ETH/USD against Binance, the most liquid exchange for this pair:
The first chart is a plot of the time series for ETH/USD during the time period for both Pyth and the CEX.
The second plot shows the deviations between these two series over time, i.e., the absolute value of the difference between these two price series. The deviations are measured in basis points, which are 1/100th of a percent.
The third chart summarizes the second chart: it plots the cumulative density function (CDF) of deviations on the x-axis (in log scale) and the percentile on the y-axis. This chart allows us to determine the probability of observing a deviation up to any given size. To illustrate this property, the points annotated on the chart correspond to the 25th/50th/75th/95th percentiles of the probability distribution. The corresponding deviations can be read from the chart above and are summarized in the following table:
AAVE/USD
For the second analysis, we chose AAVE/USD to provide a representative example of Pyth’s performance for less-liquid tokens. While ETH is extremely liquid (~6.2B USD 24-hour volume), AAVE is relatively illiquid (~64M USD 24-hour volume) and is traded on fewer exchanges.
The charts below compare the Pyth price feed for AAVE/USD against the AAVE/USDT feed on Binance:
As the plots above show, the Pyth feed generally tracks the CEX price well, with occasional spikes during highly volatile periods. However, with the exception of these few spikes, the AAVE price is always tracked closely. Most of the time, the AAVE feed deviation is less than 10 bps, and it is almost always under 25 bps; summary stats of the distribution of deviations between Pyth and the CEX are shown in the table below.
The deviations for AAVE are higher than for ETH because the token is less liquid. This result is expected. Illiquid tokens generally have larger price discrepancies across exchanges because they are more difficult to arbitrage profitably. The magnitude of such discrepancies creates a fundamental limit on the tracking error of an oracle.
Comparison to Other Oracles
We also compared Pythnet Price Feeds’ accuracy against several other oracles on multiple blockchains:
Above, we display a grid of plots. Each row of the grid represents a different chain, and each column represents a different symbol. For a symbol on a particular chain, we plot the cumulative density functions (CDFs) of Pyth and some other notable oracles. In particular, we show performance for Chainlink, Band, the Uniswap V2 TWAP oracle, and the Uniswap V3 TWAP oracle (10-minute TWAP for both V2 and V3). Not every oracle provides prices for each product on each chain, so some plots have fewer CDFs shown.
When comparing two CDF curves, the curve to the left is better, indicating lower tracking error. As can be seen, the Pyth CDF is generally to the left of all other curves. Note that the x-axis is on a log scale. Thus, a difference of 1 tick represents an improvement by a factor of 10. The charts above show that Pyth typically outperforms other oracles by a factor of 2–10x.
The log scale of the x-axis tends to diminish the absolute magnitude of the difference between oracles. For example, consider the ETH/USD deviations on Ethereum (i.e., the top left plot). From the plot itself, it is clear that the relative order of oracles in terms of accuracy is Pyth > Chainlink/Uniswap V3 TWAP > Uniswap V2 TWAP > Band. However, the accuracy differences are quite stark when the numbers are considered. The following table reads off the deviations at various percentiles from the chart:
Pyth has a lower deviation by about an order of magnitude at each percentile along the CDF curve. Especially important is the 95th percentile as a good point proxy for right tail behavior, as the right tail dictates “worst-case behavior”. Protocols that choose to integrate with a particular oracle will need to set their parameters in line with that oracle’s right tail of deviations. For example, an oracle-based AMM might set its trading fee in line with some right-tail percentile deviation to protect its LPs from getting picked off due to oracle inaccuracy. For such an application, choosing an oracle with low right-tail deviations would enable them to reduce the fee and thereby increase trading volume.
The only case where another oracle is competitive with Pyth is the case of Chainlink for USDT/USD on the BNB chain, in the bottom right corner. In contrast to Ethereum, where Chainlink updated the USDT/USD price feed 7 times over the week, BNB features lower gas fees, so Chainlink updated 652 times. Moreover, during this time period, the USDT price was almost always $1, so a high-frequency feed was not necessary to track the price closely. In contrast, when stablecoins are more volatile and potentially depeg, a higher frequency oracle feed is more valuable. We see this in the case of the USDT/USD feed on November 9, 2022:
As the first plot shows, USDT/USD was indeed fairly volatile on this date. The Pyth oracle continued to track the CEX price closely, due to its high update frequency. As the lower two plots show, Pyth performed significantly better than the Chainlink feed during this period.
Conclusion
Pythnet Price Feeds use a new oracle design that improves on existing oracles in many dimensions. On-demand price updates eliminate the transaction costs paid by the oracle and data providers, which enables it to scale in ways that traditional push oracles cannot. Consequently, Pythnet Price Feeds support frequent price updates for thousands of price feeds across an unlimited number of blockchains.
Another benefit of scalability is that it enables the oracle to accurately track the prices of assets on centralized exchanges. Our empirical analysis shows that Pyth’s average deviation from the most liquid exchange — a proxy for oracle accuracy — is lower than the deviations of other oracles across multiple assets and blockchains. The accuracy improvement is most substantial in the right tails of deviation distribution, which is to say that Pyth’s worst-case deviations are much lower than those of other oracles; this is the most important metric for oracle accuracy, as the worst-case behavior determines how consumer protocols will integrate with the oracle.
Pythnet Price Feeds are live in mainnet on dozens of blockchains, including Ethereum, Optimism, Arbitrum, BNB Chain, Avalanche, and Polygon, offering price feeds for hundreds of assets across crypto, equities, ETF's, FX, and commodities.
Please see the developer documentation for more information on integrating Pyth into your application.
We can’t wait to hear what you think! You can join the Pyth Discord and Telegram, follow us on Twitter. You can also learn more about Pyth here.
Stay Updated with Pyth
Stay informed about Pyth network's development and upcoming events!