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

fix(pricefeed) Update Sui Guide #495

Merged
merged 1 commit into from
Nov 8, 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
7 changes: 2 additions & 5 deletions pages/price-feeds/use-real-time-data/sui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,12 @@ Pyth also provides a javascript SDK to construct transaction blocks that update

The code snippet below provides a general template for what your contract code should look like:

```rust {20} copy
```rust {18} copy
module pyth_example::main {
use sui::clock::Clock;
use pyth::price_info;
use pyth::price_identifier;
use pyth::price;
use pyth::state::{State as PythState};
use pyth::pyth;
use pyth::price_info::PriceInfoObject;

Expand All @@ -110,12 +109,11 @@ module pyth_example::main {
public fun use_pyth_price(
// Other arguments
clock: &Clock,
pyth_state: &PythState,
price_info_object: &PriceInfoObject,
){
let max_age = 60;
// Make sure the price is not older than max_age seconds
let price_struct = pyth::get_price(pyth_state,price_info_object, clock);
let price_struct = pyth::get_price_no_older_than(price_info_object,clock, max_age);

// Check the price feed ID
let price_info = price_info::get_price_info_from_price_info_object(price_info_object);
Expand Down Expand Up @@ -168,7 +166,6 @@ tx.moveCall({
target: `pyth_example::main::use_pyth_price`,
arguments: [
..., // other arguments needed for your contract
tx.object(pythStateId),
tx.object(priceInfoObjectIds[0]),
],
});
Expand Down
Loading