Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ slug: /price-feeds/core/best-practices
This page provides some technical details about Pyth price feeds that are necessary to use them safely and correctly.
Please read this page before using Pyth price feeds in your application.

<UpgradeCallout chain="index" />

## Fixed-Point Numeric Representation

Price feeds represent numbers in a fixed-point format. The same exponent is used for both the price and confidence interval. The integer representation of these values can be computed by multiplying by `10^exponent`. As an example, imagine Pyth reported the following values for AAPL/USD:
Expand Down Expand Up @@ -64,7 +66,7 @@ Derivative protocols are encouraged to consider the following strategies to miti

1. **Use Delayed Settlement**: Derivative protocols can introduce a delay between the time an order is created and the time it is executed. This delay gives the protocol time to observe price changes and reject trades/transactions that profit over latency.
Suppose a user submits a trade transaction at a time `t`. The protocol should execute the trade by using the price at the time `t`, which will be available to the protocol after a short delay.
The protocol can fetch this price update of a specific timestamp from [Hermes](https://hermes.pyth.network/docs/#/rest/timestamp_price_updates) and can use [`parsePriceFeedUpdates()`](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates) to parse the prices and submit to prevent price frontrunning.
The protocol can fetch this price update of a specific timestamp from [Hermes](https://pyth.dourolabs.app/hermes/docs/#/rest/timestamp_price_updates) and can use [`parsePriceFeedUpdates()`](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates) to parse the prices and submit to prevent price frontrunning.

1. **Use a Spread**: Pyth provides a confidence interval for each price update. Derivative protocols can use this confidence interval to determine the range in which the true price probably lies.
By using the lower bound of the confidence interval, derivative protocols can protect themselves from price manipulation that drives the price down. By using the upper bound of the confidence interval, derivative protocols can protect themselves from price manipulation that drives the price up.
Expand All @@ -89,7 +91,7 @@ Protocols offering executable prices are encouraged to consider the following ri
1. **Staleness in Executable Prices**: Adversaries may see price updates before your protocol does, or they may select favorable historical price updates that satisfy staleness constraints.
This latency advantage allows sophisticated traders to exploit price differences.
**Use `getPriceNoOlderThan()` with strict staleness thresholds** when filling orders.
For delayed execution models, fetch the price at the order timestamp from [Hermes](https://hermes.pyth.network/docs/#/rest/timestamp_price_updates) and parse it using [`parsePriceFeedUpdates()`](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates).
For delayed execution models, fetch the price at the order timestamp from [Hermes](https://pyth.dourolabs.app/hermes/docs/#/rest/timestamp_price_updates) and parse it using [`parsePriceFeedUpdates()`](https://api-reference.pyth.network/price-feeds/evm/parsePriceFeedUpdates).

1. **High Volatility and Wide Confidence Intervals**: During periods of high volatility, large price moves widen confidence intervals and can cause significant slippage relative to your executable quote.
The executable price you quote may not reflect the true market price when confidence intervals are wide.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CopyAddress from "../../../../../src/components/CopyAddress";

Pyth is currently deployed on Aptos Mainnet, Aptos Testnet, and Movement devnet.

<UpgradeCallout chain="aptos" />

When deploying contracts using Pyth, the [named addresses](https://diem.github.io/move/address.html#named-addresses) `pyth`, `wormhole` and `deployer` need to be defined at compile time. These addresses are the same across both Aptos Mainnet and Testnet:

| Named Address | Value |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ slug: /price-feeds/core/contract-addresses/cosmwasm

Pyth is currently available on the following cosmwasm chains:

<UpgradeCallout chain="cosmwasm" />

### Stable

| Network | Contract address |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CopyAddress from "../../../../../src/components/CopyAddress";

Pyth is currently available on the EVM networks below using Pyth Stable price sources that are accessible via Hermes Stable.

<UpgradeCallout chain="evm" />

## Mainnets

| Network | Contract address |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CopyAddress from "../../../../../src/components/CopyAddress";

Pyth is currently deployed on Fuel Mainnet and Fuel Testnet.

<UpgradeCallout chain="fuel" />

| Network | Contract address |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Fuel Mainnet | <CopyAddress address={`0x1c86fdd9e0e7bc0d2ae1bf6817ef4834ffa7247655701ee1b031b52a24c523da`} url="https://app.fuel.network/contract/0x1c86fdd9e0e7bc0d2ae1bf6817ef4834ffa7247655701ee1b031b52a24c523da" /> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ slug: /price-feeds/core/contract-addresses
The following sections list the addresses of deployed Pyth Price Feed contracts across blockchains.
The contracts are split by ecosystem into several different documents:

<UpgradeCallout chain="index" />

- [EVM](/price-feeds/core/contract-addresses/evm)
- [Solana/SVM](/price-feeds/core/contract-addresses/solana)
- [Aptos](/price-feeds/core/contract-addresses/aptos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ slug: /price-feeds/core/contract-addresses/iota

Pyth is currently deployed on IOTA mainnet and testnet.

<UpgradeCallout chain="iota" />

#### IOTA mainnet

| Name | Address |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ slug: /price-feeds/core/contract-addresses/movement

import CopyAddress from "../../../../../src/components/CopyAddress";

<UpgradeCallout chain="movement" />

## Mainnet

Use the following addresses for the Movement Mainnet and testnets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: List of Pyth price feed contract addresses on NEAR networks
slug: /price-feeds/core/contract-addresses/near
---

<UpgradeCallout chain="near" />

| Network | Contract address |
| ------------ | --------------------- |
| NEAR Mainnet | `pyth-oracle.near` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CopyAddress from "../../../../../src/components/CopyAddress";

The Pyth Oracle consists of two different programs.

<UpgradeCallout chain="solana" />

The **Solana receiver program** is deployed at the following addresses:

| Network | Program address |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CopyAddress from "../../../../../src/components/CopyAddress";

Pyth is deployed on both Starknet Mainnet and Testnet.

<UpgradeCallout chain="starknet" />

| Network | Contract address |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Starknet Mainnet | <CopyAddress address={`0x062ab68d8e23a7aa0d5bf4d25380c2d54f2dd8f83012e047851c3706b53d64d1`} url="https://starkscan.co/contract/0x062ab68d8e23a7aa0d5bf4d25380c2d54f2dd8f83012e047851c3706b53d64d1" /> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ slug: /price-feeds/core/contract-addresses/sui

Pyth is currently available on the following sui-based chains:

<UpgradeCallout chain="sui" />

### Stable channel

#### Sui Mainnet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CopyAddress from "../../../../../src/components/CopyAddress";

Pyth is currently deployed on TON Mainnet and TON Testnet. If you are using the deprecated TON Mainnet deployment, please migrate to the new address.

<UpgradeCallout chain="ton" />

| Network | Contract address |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| TON Mainnet (deprecated) | <CopyAddress address={`EQBU6k8HH6yX4Jf3d18swWbnYr31D3PJI7PgjXT-flsKHqql`} url="https://tonscan.org/address/EQBU6k8HH6yX4Jf3d18swWbnYr31D3PJI7PgjXT-flsKHqql" /> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This part of the tutorial will conver the following:
before continuing.
</Callout>

<UpgradeCallout chain="evm" />

## Deploy the contract

Now, let's deploy the contract to a test network.
Expand Down Expand Up @@ -99,10 +101,26 @@ Let's try out the deployed contract.
In order to do so, we will need to get a price update to pass to the `updateAndMint` function.
We can fetch this update from Hermes:

<Tabs items={["Upgraded endpoint", "Current endpoint"]}>
<Tab value="Upgraded endpoint">

```bash copy
curl -s -H "Authorization: Bearer $PYTH_API_KEY" \
"https://pyth.dourolabs.app/hermes/v2/updates/price/latest?&ids[]=$ETH_USD_ID" | jq -r ".binary.data[0]" > price_update.txt
```

</Tab>
<Tab value="Current endpoint">

```bash copy
curl -s "https://hermes.pyth.network/v2/updates/price/latest?&ids[]=$ETH_USD_ID" | jq -r ".binary.data[0]" > price_update.txt
# Authentication becomes required on July 31, 2026.
curl -s -H "Authorization: Bearer $PYTH_API_KEY" \
"https://hermes.pyth.network/v2/updates/price/latest?&ids[]=$ETH_USD_ID" | jq -r ".binary.data[0]" > price_update.txt
```

</Tab>
</Tabs>

This command will fetch a fresh price update from Hermes and save it in the file `price_update.txt`.
The update is a binary payload represented as a hexadecimal string.

Expand Down Expand Up @@ -242,7 +260,9 @@ async function run() {
client,
});

const connection = new HermesClient("https://hermes.pyth.network");
const connection = new HermesClient("https://pyth.dourolabs.app/hermes", {
accessToken: process.env.PYTH_API_KEY,
});
const priceIds = [process.env["ETH_USD_ID"] as string];
const priceFeedUpdateData = await connection.getLatestPriceUpdates(priceIds);
console.log("Retrieved Pyth price update:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The following guide explains how to fetch price updates.
Price updates can be submitted to the Pyth Price Feeds contract to update the on-chain price.
Please see [What is a Pull Oracle?](/price-feeds/core/pull-updates) to learn more.

<UpgradeCallout chain="index" />

Price updates are served from [Hermes](/price-feeds/core/how-pyth-works/hermes), which
provides three different ways to fetch price updates:

Expand All @@ -36,11 +38,28 @@ Use the `/v2/updates/price/latest` endpoint to fetch the latest price update for
This endpoint allows you to fetch the latest price updates for multiple feeds in a single request.
For example, the following command retrieves the latest price updates for BTC/USD and ETH/USD:

<Tabs items={["Upgraded endpoint", "Current endpoint"]}>
<Tab value="Upgraded endpoint">

```bash copy
curl -X 'GET' \
-H "Authorization: Bearer $PYTH_API_KEY" \
'https://pyth.dourolabs.app/hermes/v2/updates/price/latest?ids%5B%5D=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43&ids%5B%5D=0xc96458d393fe9deb7a7d63a0ac41e2898a67a7750dbd166673279e06c868df0a'
```

</Tab>
<Tab value="Current endpoint">

```bash copy
# Authentication becomes required on July 31, 2026.
curl -X 'GET' \
-H "Authorization: Bearer $PYTH_API_KEY" \
'https://hermes.pyth.network/v2/updates/price/latest?ids%5B%5D=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43&ids%5B%5D=0xc96458d393fe9deb7a7d63a0ac41e2898a67a7750dbd166673279e06c868df0a'
```

</Tab>
</Tabs>

The output will be similar to the following containing the requested price update:

```bash
Expand Down Expand Up @@ -96,7 +115,7 @@ The output will be similar to the following containing the requested price updat
}
```

Hermes offers several other endpoints for retrieving price updates. For more information, see the [Hermes API Reference](https://hermes.pyth.network/docs/#/).
Hermes offers several other endpoints for retrieving price updates. For more information, see the [Hermes API Reference](https://pyth.dourolabs.app/hermes/docs/#/).

## Streaming

Expand All @@ -108,7 +127,8 @@ The connection will automatically close after 24 hours to prevent resource leaks
For example, to stream price updates for BTC/USD, run:

```bash copy
curl -N 'https://hermes.pyth.network/v2/updates/price/stream?ids[]=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43'
curl -N -H "Authorization: Bearer $PYTH_API_KEY" \
'https://pyth.dourolabs.app/hermes/v2/updates/price/stream?ids[]=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43'
```

The output is a stream of events containing the requested price updates, similar to the following:
Expand All @@ -125,7 +145,9 @@ Pyth provides a typescript SDK for Hermes to fetch price updates.
The [`HermesClient`](https://github.com/pyth-network/pyth-crosschain/blob/main/apps/hermes/client/js/src/HermesClient.ts#L41) class in this [SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/apps/hermes/client/js) connects to Hermes to fetch and stream price updates.

```typescript copy
const connection = new HermesClient("https://hermes.pyth.network", {});
const connection = new HermesClient("https://pyth.dourolabs.app/hermes", {
accessToken: process.env.PYTH_API_KEY,
});

const priceIds = [
// You can find the ids of prices at https://docs.pyth.network/price-feeds/price-feeds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Callout } from "fumadocs-ui/components/callout";

This guide explains how to use real-time Pyth data in Aptos applications.

<UpgradeCallout chain="aptos" />

## Configuring the `Move.toml` file

Add the Pyth Contract to your project dependencies in the `Move.toml` file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ slug: /price-feeds/core/use-real-time-data/pull-integration/cosmwasm
Cosmwasm contracts can update and fetch the Pyth prices using the Pyth Cosmwasm Contract, deployed on their network.
The documented source code can be found [here](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/cosmwasm/contracts/pyth).

<UpgradeCallout chain="cosmwasm" />

## Update Price Feeds

The mechanism by which price feeds are updated on Cosmwasm is explained [here](../../pull-updates). The [@pythnetwork/price-service-client](https://github.com/pyth-network/pyth-crosschain/tree/main/price_service/client/js) typescript package can be used to fetch the latest price feed data which then can be passed to the contract as the `UpdatePriceFeeds` ExecuteMsg.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Tab, Tabs } from "fumadocs-ui/components/tabs";

This guide explains how to use real-time Pyth data in Fuel contracts.

<UpgradeCallout chain="fuel" />

## Install the Pyth SDK

Use the following dependency in your `Forc.toml` file to use the latest Pyth Fuel package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Tab, Tabs } from "fumadocs-ui/components/tabs";

This guide explains how to use real-time Pyth data in IOTA applications.

<UpgradeCallout chain="iota" />

## Install Pyth SDK

Use the following dependency in your `Move.toml` file to use the latest Pyth IOTA package and its dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: Consume Pyth Network prices in Near applications
slug: /price-feeds/core/use-real-time-data/pull-integration/near
---

<UpgradeCallout chain="near" />

Comment on lines +7 to +8
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 NEAR integration guide still references old hermes endpoints without upgrade tabs

The NEAR integration guide (near.mdx) adds <UpgradeCallout chain="near" /> at the top but still contains hardcoded references to hermes.pyth.network and hermes-beta.pyth.network in the code examples at apps/developer-hub/content/docs/price-feeds/core/use-real-time-data/pull-integration/near.mdx:83-84. Unlike other integration guides (EVM, Solana, Sui) which were updated to show tabbed "Upgraded endpoint" / "Current endpoint" examples, the NEAR guide's code samples still point only to the old endpoints. This is inconsistent with the migration pattern applied elsewhere in this PR.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

## Pyth on NEAR

Pyth price feeds on NEAR are managed through the main NEAR Pyth smart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Callout } from "fumadocs-ui/components/callout";

This guide explains how to use real-time Pyth data in Solana applications.

<UpgradeCallout chain="solana" />

## Install Pyth SDKs

Pyth provides two SDKs for Solana applications to cover the on- and off-chain portions of the integration:
Expand Down Expand Up @@ -155,18 +157,37 @@ To use price update accounts, the frontend code needs to perform two different t

#### Fetch price updates

Use `PriceServiceConnection` from `@pythnetwork/hermes-client` to fetch Pyth price updates from Hermes:
Use `HermesClient` from `@pythnetwork/hermes-client` to fetch Pyth price updates from Hermes. The new endpoint `pyth.dourolabs.app/hermes` is the upgraded backend (recommended); the current `hermes.pyth.network` keeps working until cutover and requires an API key from July 31, 2026:

<Tabs items={["Upgraded endpoint", "Current endpoint"]}>
<Tab value="Upgraded endpoint">

```typescript copy
import { HermesClient } from "@pythnetwork/hermes-client";

const priceServiceConnection = new HermesClient(
"https://pyth.dourolabs.app/hermes",
{ accessToken: process.env.PYTH_API_KEY },
);
```

</Tab>
<Tab value="Current endpoint">

```typescript copy
import { HermesClient } from "@pythnetwork/hermes-client";

// The URL below is a public Hermes instance operated by the Pyth Data Association.
// Hermes is also available from several third-party providers listed here:
// https://docs.pyth.network/price-feeds/api-instances-and-providers/hermes
// Authentication becomes required on July 31, 2026.
const priceServiceConnection = new HermesClient(
"https://hermes.pyth.network/",
{},
"https://hermes.pyth.network",
{ accessToken: process.env.PYTH_API_KEY },
);
```

</Tab>
</Tabs>

```typescript copy

// Hermes provides other methods for retrieving price updates. See
// https://hermes.pyth.network/docs for more information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { Callout } from "fumadocs-ui/components/callout";

This guide explains how to use real-time Pyth data in [Clarity](https://clarity-lang.org/) smart contracts on Stacks.

<UpgradeCallout chain="stacks" />

## Write Contract Code

The Pyth protocol integration for Stacks is available as a Beta on both testnet and mainnet networks, to help developers test, give feedback, and ensure the reliability and stability of the integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Tab, Tabs } from "fumadocs-ui/components/tabs";

This guide explains how to use real-time Pyth data in Starknet contracts.

<UpgradeCallout chain="starknet" />
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.

## Install the Pyth SDK

Use the following dependency in your `Scarb.toml` file to use the latest Pyth Starknet package:
Expand Down
Loading
Loading