Benchmarks
Introduction

Benchmarks

Pyth benchmarks allows users to query a historical archive of prices from Price Feeds. For example, applications can retrieve the price of BTC/USD as of last Friday at 8:00 AM UTC. This price can be used for contract settlement or any other application that requires historical price data. Benchmarks data is signed and verifiable on-chain with the same trust assumptions as Price Feeds.

TradingView Integration

There is a how-to guide for integrating Pyth Benchmarks with TradingView.

Manual Browsing

The benchmarks page (opens in a new tab) of the pyth.network website allows users to search the archive of benchmark prices. It also provides default options for common settlement dates and times. Users can select a time and see all of the Pyth prices that were active at that time. Technically, each displayed price corresponds to the Pyth price update published just before the selected time; this ensures that the displayed price is the one a user would have seen if they observed the Pyth price at that time.

On-Chain Contracts

On-chain contracts can consume benchmark prices using the same pull model as Pythnet Price Feeds. Integrators can follow these three steps:

  1. Use the Hermes endpoint /v2/updates/price/{price_time} to retrieve a signed price update for the desired price feed and time. This endpoint will return a signed price update, specifically the price update immediately after the queried time. This step can be done in either a web frontend or a backend process, depending on who is expected to initiate the transaction.
  2. Pass this price update to your on-chain contract as part of the transaction that needs the benchmark data.
  3. In your on-chain contract, pass the price update to the parsePriceFeedUpdates function on the Pyth contract. This function will check the validity of the update and return the price of the requested asset (if valid). The price update will only be valid if the signatures are correct and the update falls within a user-configured time interval; integrators should set this time interval such that it matches their desired time.

Note that this process is similar to the standard process for consuming pull updates. The main differences are that users call the /v2/updates/price/{price_time} endpoint instead of /v2/updates/price/latest, and the on-chain contract calls parsePriceFeedUpdates instead of updatePriceFeeds. The pyth-crosschain repo has example code (opens in a new tab) for an integration along the lines above for EVM chains.

API Documentation

For a detailed overview of the API endpoints and their usage, please refer to the documentation available at https://benchmarks.pyth.network/docs (opens in a new tab).

Last updated on