Skip to content

Chore(benchmark) remove #808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
"type": "page"
},

"benchmarks": {
"title": "Benchmarks",
"type": "page"
},

"express-relay": {
"title": "Express Relay",
"type": "page"
Expand Down
33 changes: 0 additions & 33 deletions pages/benchmarks/_meta.json

This file was deleted.

38 changes: 0 additions & 38 deletions pages/benchmarks/index.mdx

This file was deleted.

5 changes: 0 additions & 5 deletions pages/home/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
"href": "/lazer"
},

"Benchmarks": {
"title": "Benchmarks →",
"href": "/benchmarks"
},

"Express Relay": {
"title": "Express Relay →",
"href": "/express-relay"
Expand Down
3 changes: 1 addition & 2 deletions pages/home/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ Pyth's market data is contributed by over [120+ first-party publishers](https://

Pyth Network offers several products for developers:

- [Price Feeds](../price-feeds) provide real-time prices for [1500+ assets](https://insights.pyth.network/price-feeds?utm_source=docs) on [100+ blockchain ecosystems](../price-feeds/contract-addresses), including Solana, many EVM chains,
- [Price Feeds](../price-feeds) provide **real-time and historical prices** for [2000+ assets](https://insights.pyth.network/price-feeds?utm_source=docs) on [100+ blockchain ecosystems](../price-feeds/contract-addresses), including Solana, many EVM chains,
Aptos, Sui, NEAR, and several Cosmos chains.
- [Lazer](../lazer) provides low-latency, highly customizable price feeds on Solana and EVM chains.
- [Benchmarks](../benchmarks) provides historical Pyth prices for both on- and off-chain use.
- [Express Relay](../express-relay/) enables protocols to eliminate their MEV while gaining access to active searchers and liquidators.
- [Entropy](../entropy) allows developers to generate secure random numbers on the blockchain.

Expand Down
2 changes: 2 additions & 0 deletions pages/price-feeds/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
},

"use-real-time-data": "Use Real-Time Price Data",
"use-historic-price-data": "Use Historic Price Data",
"fetch-price-updates": "Fetch Price Updates",
"schedule-price-updates": "Schedule Price Updates",
"create-tradingview-charts": "Create TradingView Charts",
"derive-cross-rate": "Derive Cross Rate",
"migrate-an-app-to-pyth": "Migrate an App to Pyth",
"use-pyth-for-morpho": "Use Pyth for Morpho Markets",
Expand Down
1 change: 1 addition & 0 deletions pages/price-feeds/api-instances-and-providers/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"hermes": "Hermes",
"benchmarks": "Benchmarks / Historical Prices",
"pythnet-rpc": "Pythnet RPC"
}
1 change: 1 addition & 0 deletions pages/price-feeds/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ The following on-chain contracts are documented in the API reference:
Hermes also has interactive API documentation hosted by the service itself:

- [Hermes](https://hermes.pyth.network/docs/)
- [Benchmarks / Historical Prices](https://benchmarks.pyth.network/docs)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tab, Tabs } from "nextra-theme-docs";

# TradingView Integration
# How to Create TradingView Charts

The TradingView integration allows users to view Pyth prices on their own website. All Pyth prices made available through the TradingView integration are originating from [Pythnet](/price-feeds/how-pyth-works/pythnet).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rate Limits

In order to maximize the reliability of the Pyth Benchmarks API, a request rate limit is enforced.
In order to maximize the reliability of the Pyth Hermes and Benchmarks APIs, a request rate limit is enforced.
All endpoints limits are set at 30 requests every 10 seconds per IP address.

One exception: the TradingView endpoint will allow 90 requests every 10 seconds. Clients issuing request above the limit will receive a 429 (Too Many Requests) response for the subsequent 60-second period.
Users can access benchmark prices in several different ways, depending on the use case:
111 changes: 111 additions & 0 deletions pages/price-feeds/use-historic-price-data.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { Callout, Steps } from "nextra/components";

# Use Historic Price Data (Benchmarks) on EVM Chains

This guide shows you how to integrate **Pyth Benchmarks to access historical price data** for your applications.
The Pyth Benchmarks API is available on all Pythnet chains.

<Callout type="info" emoji="ℹ️">
This guide uses the term **Benchmarks** to refer to the historical price data
service.
</Callout>

## Overview

Pyth Benchmarks allows you to query historical prices at specific points in time. This is useful for:

- **Contract Settlement**: Use historical prices for options, futures, or other derivative settlements.
- **Backtesting**: Test trading strategies with historical market data.
- **Audit & Compliance**: Verify past prices for regulatory requirements.
- **Analytics**: Analyze price movements and market behavior over time.

Pyth Benchmarks can be used in two ways to fetch historical prices:

1. Fetching historical prices from Benchmarks API
2. Verifying historical prices on-chain

<Steps>

### 1. Fetching Historical Prices

Fetching historical prices from the Benchmarks API is the most straightforward way to get historical prices.
Moreover, [Hermes also extends the Benchmarks API to allow you to fetch historical prices](https://hermes.pyth.network/docs/#/rest/timestamp_price_updates).

Benchmarks APIs expose two endpoints to fetch historical prices:

- [`/v1/updates/price/{timestamp}`](https://benchmarks.pyth.network/docs#/): Returns the price for all price feeds passed as query parameters at a given time.
- [`/v1/updates/price/{timestamp}/{interval}`](https://benchmarks.pyth.network/docs#/): Returns the price for the price feed passed as query parameter at a given time and with the specified interval.

<Callout type="info" emoji="ℹ️">

Time interval in seconds added to the provided timestamp for the requested price updates.
For example, if the timestamp is 1716400000 and the **interval is 60,** this function will return price updates from time 1716400000 to 1716400060, inclusive of both. **The time interval should not exceed 60 seconds.**

</Callout>

### Verifying Historical Prices on-chain

Verifying Historical Prices on-chain is very similar to verifying real-time prices on-chain.
After fetching the price updates in the previous step, you need to pass the price update to the [`parsePriceFeedUpdates`](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates) function on the Pyth contract instead of the [`updatePriceFeeds`](https://api-reference.pyth.network/price-feeds/evm/updatePriceFeeds) function.

```solidity copy
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";

contract HistoricalPriceConsumer {
IPyth public pyth;

constructor(address _pyth) {
pyth = IPyth(_pyth);
}

function settleWithHistoricalPrice(
bytes[] calldata priceUpdate,
uint256 priceId,
uint256 minPublishTime,
uint256 maxPublishTime,
) external {
// The parsePriceFeedUpdates function requires a fee to be paid.
// The fee is the same as the fee for the updatePriceFeeds function.
uint fee = pyth.getUpdateFee(priceUpdate);
PythStructs.Price memory price = pyth.parsePriceFeedUpdates{value: fee}(
priceUpdate,
priceId,
minPublishTime,
maxPublishTime,
);

// Use the historical price for settlement
uint256 settlementPrice = uint256(price.price);
// ... settlement logic
}
}
```

The code snippet above does the following things differently from the [verifying real-time prices on-chain](./use-real-time-data.mdx):

- It calls the `parsePriceFeedUpdates` function instead of the `updatePriceFeeds` function.
- It passes the price id to the `parsePriceFeedUpdates` function as well. The price feed id is needed to identify if the price update belongs to the price feed.
- It passes the **min publish time** and **max publish time** to the `parsePriceFeedUpdates` function. The min publish time and max publish time are the time range of the price update. If the price update is not within the time range, the function will revert with `PriceFeedNotFoundWithinRange`.

Refer to the [parsePriceFeedUpdates](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates) function for more details.

</Steps>

## Additional Resources

### API Reference

- [Benchmark API Documentation](https://benchmarks.pyth.network/docs)
- Explore the [Pyth on-chain API documentation](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates) to learn more about parsing price updates on EVM chains.

### TradingView Integration

- [TradingView integration](../benchmarks/how-to-create-tradingview-charts) for visualization.

### Rate Limits

- Benchmarks API has the same rate limits as the [Hermes API](./rate-limits).
Loading