You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pyth-sdk-solana/README.md
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Applications can obtain the content of these accounts in two different ways:
26
26
* On-chain programs should pass these accounts to the instructions that require price feeds.
27
27
* Off-chain programs can access these accounts using the Solana RPC client (as in the [eth price example program](examples/eth_price.rs)).
28
28
29
-
The pyth.network website can be used to identify the public keys of the various Pyth Network accounts (e.g., [Crypto.BTC/USD accounts](https://pyth.network/markets/#Crypto.BTC/USD)).
29
+
The pyth.network website can be used to identify the public keys of each price feed's price account (e.g., [Crypto.BTC/USD accounts](https://pyth.network/developers/price-feed-ids#solana-mainnet-beta)).
30
30
31
31
### On-chain
32
32
@@ -37,9 +37,11 @@ The `load_price_feed_from_account_info` function will construct a `PriceFeed` st
Copy file name to clipboardExpand all lines: pyth-sdk/README.md
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Pyth Network Common Rust SDK
2
2
3
3
This crate contains Pyth Network data structures that are shared across all Rust-based consumers of Pyth Network data.
4
-
This crate is typically used in combination with a platform-specific crate such as [pyth-sdk-solana](../pyth-sdk-solana) or [pyth-sdk-cw](../pyth-sdk-cw).
4
+
This crate is typically used in combination with a platform-specific crate such as [pyth-sdk-solana](../pyth-sdk-solana).
5
5
6
6
## Usage
7
7
@@ -19,7 +19,9 @@ Once you have a `PriceFeed`, you can call one of the methods below to get the pr
19
19
Get the current price of the product from its `PriceFeed`:
20
20
21
21
```rust
22
-
letcurrent_price:Price=price_feed.get_current_price().ok_or(StdError::not_found("Current price is not available"))?;
22
+
constSTALENESS_THRESHOLD:u64=60; // staleness threshold in seconds
23
+
letcurrent_timestamp=...;
24
+
letcurrent_price:Price=price_feed.get_price_no_older_than(current_timestamp, STALENESS_THRESHOLD).ok_or(StdError::not_found("Current price is not available"))?;
23
25
println!("price: ({} +- {}) x 10^{}", current_price.price, current_price.conf, current_price.expo);
24
26
```
25
27
@@ -35,7 +37,9 @@ Please see the [consumer best practices guide](https://docs.pyth.network/consume
35
37
The EMA price can be retrieved as follows:
36
38
37
39
```rust
38
-
letema_price:Price=price_feed.get_ema_price().ok_or(StdError::not_found("EMA price is not available"))?;
40
+
constSTALENESS_THRESHOLD:u64=60; // staleness threshold in seconds
41
+
letcurrent_timestamp=...;
42
+
letema_price:Price=price_feed.get_ema_price_no_older_than(current_timestamp, STALENESS_THRESHOLD).ok_or(StdError::not_found("EMA price is not available"))?;
39
43
println!("price: ({} +- {}) x 10^{}", ema_price.price, ema_price.conf, ema_price.expo);
0 commit comments