The Pyth Network Rust SDK provides utilities for reading price feeds from the pyth.network oracle in on- and off-chain applications.
Key features of this SDK include:
- Get the current price of over 50 products, including cryptocurrencies, US equities, forex and more.
- Combine listed products to create new price feeds, e.g., for baskets of tokens or non-USD quote currencies.
- Consume prices in Solana programs or off-chain applications.
Please see the pyth.network documentation for more information about pyth.network.
This repository is divided into several crates focused on specific use cases:
- Pyth SDK provides common data types and interfaces for that are shared across different blockchains.
- Pyth SDK Solana provides an interface for reading Pyth price feeds in Solana programs. This crate may also be used in off-chain applications that read prices from the Solana blockchain.
Please see the documentation for the relevant crate to get started using Pyth Network.
All crates in this repository can be built for either your native platform or blockchain-specific platforms.
Use cargo build
/ cargo test
to build and test natively.
JSON Schema files are provided to allow others to work with the various Pyth structures in languages other than Rust. These are also used within Pyth’s own repositories, for example within the pyth-sdk-js repo. Every time these structures change, new Schema’s must be generated and committed via the cargo run --example schema command.
There is currently a CI check which ensures the schema files remain up-to-date.
To release a new version of any of these crates, perform the following steps within the crate being released:
- Increment the version number in
Cargo.toml
. You may use a version number with a-beta.x
suffix such as0.0.1-beta.0
to create opt-in test versions. - Merge your change into
main
on github. - Create and publish a new github release with the structure of
package:vx.y.z
such aspyth-sdk-solana:v1.3.2
. It will trigger a github action and publishes the released package in crates.io
pre-commit is a tool that checks and fixes simple issues (formatting, ...) before each commit. You can install it by following their website. In order to enable checks for this repo run pre-commit install
from command-line in the root of this repo.
The checks are also performed in the CI to ensure the code follows consistent formatting.