Skip to content
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

feat: add new pyth API endpoint #2322

Merged
merged 1 commit into from
Nov 20, 2024
Merged
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
13 changes: 4 additions & 9 deletions docs/2.build/5.primitives/oracles.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,11 @@ Update the Pyth Oracle contract with new price feed data in two main steps:

#### 1) Fetching off-chain price feed

You can obtain an off-chain price feed using Pyth's [Hermes API](https://docs.pyth.network/price-feeds/how-pyth-works/hermes) `/get_vaa` endpoint.
You can obtain an off-chain price feed using Pyth's [Hermes API](https://hermes-beta.pyth.network/docs/).

There are several steps to this process:
To use these endpoints, you will need to provide a Price Feed ID and ensure you are targeting the correct network. See [Getting Started](#getting-started) for more information.

- Determine which network you are targeting
- Create a publish time and account for network latency
- Fetch price feed from appropriate endpoint
- Convert response to hex for use on NEAR

`Example:`
Here is a node.js example of fetching the latest price feed using `/v2/updates/price/latest` endpoint:

<Language value="js" language="js">
<Github
Expand All @@ -213,7 +208,7 @@ There are several steps to this process:

#### 2) Update Pyth Oracle Contract Price Feed

After [fetching an off-chain price feed](#1-fetching-off-chain-price-feed), you can now perform a contract call to the Pyth Oracle contract to update.
After [fetching an off-chain price feed](#1-fetching-off-chain-price-feed), you can now perform a contract call to the Pyth Oracle to update the price feed on-chain.

Call `update_price_feeds` on the Pyth Oracle contract with `data` as your arguments.

Expand Down
Loading