Skip to content

Commit 07c5506

Browse files
committed
tiny improvements
1 parent 4a75897 commit 07c5506

File tree

1 file changed

+9
-25
lines changed
  • pages/price-feeds/use-real-time-data

1 file changed

+9
-25
lines changed

pages/price-feeds/use-real-time-data/sui.mdx

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide explains how to use real-time Pyth data in Sui applications.
66

77
## Install Pyth SDK
88

9-
Use the following dependency in your `Move.toml` file to use the latest Pyth Sui package and its dependencies.
9+
Use the following dependency in your `Move.toml` file to use the latest Pyth Sui package and its dependencies:
1010

1111
<Tabs items={['Mainnet', 'Testnet']}>
1212
<Tabs.Tab>
@@ -21,6 +21,8 @@ git = "https://github.com/wormhole-foundation/wormhole.git"
2121
subdir = "sui/wormhole"
2222
rev = "sui-upgrade-mainnet"
2323

24+
# Pyth is locked into this specific `rev` because our package depends on Wormhole and is pinned to this version.
25+
2426
[dependencies.Sui]
2527
git = "https://github.com/MystenLabs/sui.git"
2628
subdir = "crates/sui-framework/packages/sui-framework"
@@ -40,6 +42,7 @@ git = "https://github.com/wormhole-foundation/wormhole.git"
4042
subdir = "sui/wormhole"
4143
rev = "sui-upgrade-testnet"
4244
45+
# Pyth is locked into this specific `rev` because our package depends on Wormhole and is pinned to this version.
4346
[dependencies.Sui]
4447
git = "https://github.com/MystenLabs/sui.git"
4548
subdir = "crates/sui-framework/packages/sui-framework"
@@ -49,7 +52,7 @@ rev = "041c5f2bae2fe52079e44b70514333532d69f4e6"
4952
</Tabs.Tab>
5053
</Tabs>
5154
52-
Pyth provides a javascript SDK to construct transaction blocks that update price feeds.
55+
Pyth also provides a javascript SDK to construct transaction blocks that update price feeds:
5356
5457
<Tabs items={["npm", "yarn"]}>
5558
<Tabs.Tab>
@@ -64,7 +67,7 @@ Pyth provides a javascript SDK to construct transaction blocks that update price
6467
6568
Your Sui Move module **should NOT** have a hard-coded call to `pyth::update_single_price_feed.` In other words, a contract should **never call** the Sui Pyth `pyth::update_single_price_feed` entry point. Instead, it should be called directly from client code (e.g., Typescript or Rust).
6669
67-
This is because the new address differs from the original when a Sui contract is [upgraded](https://docs.sui.io/build/package-upgrades). If your module has a hard-coded call to `pyth::update_single_price_feed` living at a fixed call-site, it may eventually get bricked due to how Pyth upgrades are implemented. (We only allow users to interact with the most recent package version for security reasons).
70+
When Sui contracts are [upgraded](<(https://docs.sui.io/build/package-upgrades)>), the address changes, which makes the old address no longer valid. If your module has a hard-coded call to `pyth::update_single_price_feed` living at a fixed call-site, it may eventually get bricked due to how Pyth upgrades are implemented. (We only allow users to interact with the most recent package version for security reasons).
6871
6972
Therefore, you should build a [Sui programmable transaction](https://docs.sui.io/build/prog-trans-ts-sdk) that first updates the price by calling `pyth::update_single_price_feed` at the latest call-site from the client-side and then call a function in your contract that invokes `pyth::get_price` on the `PriceInfoObject` to get the recently updated price.
7073
You can use `SuiPythClient` to build such transactions and handle all the complexity of updating the price feeds.
@@ -187,27 +190,8 @@ You may find these additional resources helpful for developing your Sui applicat
187190
188191
### Contract Addresses
189192
190-
Developers will need the Pyth package IDs to use Pyth.
191-
Please consult [Sui Contract Addresses](../contract-addresses/sui) to find the package IDs for your blockchain.
192-
193-
## Common Questions on How to Integrate with Pyth on Sui
194-
195-
### What is up with the "sui rev"? Why does it point to a specific commit hash instead of "main" or "devnet"?
196-
197-
Our Pyth `Move.toml` depends on specific versions of the [Sui Framework](https://github.com/MystenLabs/sui) as well as [Wormhole](https://github.com/wormhole-foundation/wormhole).
198-
To make your Sui package compatible, you must also specify the following dependencies verbatim in your `Move.toml` file. We are locked in to this specific `rev` because our package depends on Wormhole and it is pinned to this
199-
version.
200-
201-
```sh copy
202-
[dependencies.Sui]
203-
git = "https://github.com/MystenLabs/sui.git"
204-
subdir = "crates/sui-framework/packages/sui-framework"
205-
rev = "041c5f2bae2fe52079e44b70514333532d69f4e6"
206-
```
207-
208-
### How do I find the Sui Object ID of a PriceInfoObject for a Pyth Price Feed?
193+
Consult [Sui Contract Addresses](../contract-addresses/sui) to find the package IDs.
209194
210-
You can use the `getPriceFeedObjectId` function in the js sdk to fetch the object ids.
211-
This mapping is also stored on-chain, and can be queried on-chain using the getter function `pyth::state::get_price_info_object_id` defined in the Pyth package.
195+
### Pyth Price Feed IDs
212196
213-
Also recall that the list of Pyth price feed IDs can be found [here](https://pyth.network/developers/price-feed-ids).
197+
Consult [Pyth Price Feed IDs](https://pyth.network/developers/price-feed-ids) to find Pyth price feed IDs for various assets.

0 commit comments

Comments
 (0)