docs(developer-hub): add Sui integration guide for Pyth Pro/Lazer#3495
docs(developer-hub): add Sui integration guide for Pyth Pro/Lazer#3495pythia-assistant wants to merge 6 commits intopyth-network:mainfrom
Conversation
|
@pythia-assistant is attempting to deploy a commit to the Pyth Network Team on Vercel. A member of the Team first needs to authorize it. |
matej-douro
left a comment
There was a problem hiding this comment.
Added some comments for @pythia-assistant .
| update_data: vector<u8>, | ||
| ) { | ||
| // Parse and verify the update - this validates the signature | ||
| let update: Update = pyth_lazer::parse_and_verify_le_ecdsa_update( |
There was a problem hiding this comment.
Users should only ever call parse_and_verify_le_ecdsa_update in programmable transactions blocks (PTBs), e.g. through Sui TypeScript SDK, and then consume Updates in a call to their contract function in another PTB instruction. Otherwise they'll end up hard-coding their contract to specific version of Pyth Lazer, which we don't want.
|
|
||
| ```move copy | ||
| let feeds = update.feeds_ref(); | ||
| let feed = vector::borrow(feeds, 0); |
There was a problem hiding this comment.
It would probably be better to use modern Move syntax for field access: &feeds[0].
|
|
||
| // Check if a price exists and extract it | ||
| let price_opt = feed.price(); | ||
| if (option::is_some(&price_opt)) { |
There was a problem hiding this comment.
Same here when it comes to syntax - Move now supports .method() calls.
- Restructure to show PTB-based verification pattern (avoids version coupling) - Use modern Move syntax: &feeds[0] instead of vector::borrow - Use method syntax: .is_some(), .borrow() instead of option::is_some()
pythia-assistant
left a comment
There was a problem hiding this comment.
Thanks @matej-douro! Addressed all feedback:
-
Restructured the guide to show the PTB-based pattern — verification happens in the PTB via TypeScript SDK, then the
Updateis passed to the user's contract. This avoids coupling to a specific Pyth Lazer package version. -
Updated to modern Move syntax:
&feeds[0]instead ofvector::borrow(feeds, 0) -
Updated to method syntax:
.is_some(),.borrow(),.is_negative(),.abs()instead of module function calls
matej-douro
left a comment
There was a problem hiding this comment.
More comments for @pythia-assistant .
| <Step> | ||
| ### Verify price updates in a PTB | ||
|
|
||
| Pyth Pro provides a [Sui Move SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/contracts/sui), which allows consumers to verify and parse price updates on Sui. |
There was a problem hiding this comment.
This link should point to nested sdk/js.
|
|
||
| <Callout type="warning"> | ||
| Always call `parse_and_verify_le_ecdsa_update` in a Programmable Transaction Block (PTB), not inside your smart contract. | ||
| This allows your contract to accept any version of the `Update` type, avoiding tight coupling to a specific Pyth Lazer package version. |
There was a problem hiding this comment.
Allows to run with any newer version of Pyth Lazer contract, but Update type will stay the same.
| const tx = new Transaction(); | ||
|
|
||
| // Step 1: Verify and parse the update in the PTB | ||
| const [update] = tx.moveCall({ |
There was a problem hiding this comment.
Let's just follow docs here (https://github.com/pyth-network/pyth-crosschain/blob/main/lazer/contracts/sui/sdk/js/README.md) instead of manual call construction.
| // Get the feeds vector | ||
| let feeds = update.feeds_ref(); | ||
|
|
||
| // Access the first feed using modern Move syntax |
There was a problem hiding this comment.
We don't need to talk about what's "modern" syntax in our docs, it's just what we want to use for the example source code.
- Use @pythnetwork/pyth-lazer-sui-js SDK with addParseAndVerifyLeEcdsaUpdateCall - Link to sdk/js subdirectory for Sui TypeScript SDK - Fix wording about version compatibility - Remove 'modern syntax' references - just use proper syntax
pythia-assistant
left a comment
There was a problem hiding this comment.
Thanks for the additional feedback @matej-douro — you're right, I was overconfident on the PTB construction.
Fixed in latest commit:
- Now using
@pythnetwork/pyth-lazer-sui-jsSDK withaddParseAndVerifyLeEcdsaUpdateCall - Updated TypeScript SDK link to point to
sdk/jssubdirectory - Fixed wording on version compatibility
- Removed references to "modern syntax" — just using proper syntax directly
matej-douro
left a comment
There was a problem hiding this comment.
One more thing to fix, otherwise it looks reasonable.
| if (inner_opt.is_some()) { | ||
| let price_i64 = inner_opt.borrow(); | ||
| // Use I64 methods to work with the value | ||
| let is_negative = price_i64.is_negative(); |
There was a problem hiding this comment.
Check correct method names and signatures in source - these methods don't exist.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@codex can you check this PR? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02f80a360d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let market_session = feed.market_session(); | ||
|
|
||
| // EMA values | ||
| let ema_price = feed.ema_price(); | ||
| let ema_confidence = feed.ema_confidence(); |
There was a problem hiding this comment.
Remove unsupported feed properties from Sui example
The Accessing Price Feed Data snippet documents feed.market_session(), feed.ema_price(), feed.ema_confidence(), and feed.feed_update_timestamp(), but these accessors are not implemented in the current Sui SDK (lazer/contracts/sui/sources/feed.move only exposes feed_id/price/best bid-ask/publisher_count/exponent/confidence/funding fields). Users who copy this code will get compile-time member resolution errors when integrating the contract.
Useful? React with 👍 / 👎.
| let is_negative = price_i64.is_negative(); | ||
| let abs_value = price_i64.abs(); |
There was a problem hiding this comment.
Use the actual I64 helper names in Move snippet
This signed-integer example calls price_i64.is_negative() and price_i64.abs(), but the Sui I64 API defines get_is_negative, get_magnitude_if_positive, and get_magnitude_if_negative (see lazer/contracts/sui/sources/i64.move), with no is_negative or abs helpers. As written, the documented sample does not compile and gives consumers incorrect guidance for decoding signed values.
Useful? React with 👍 / 👎.
| ``` | ||
|
|
||
| <Callout type="info"> | ||
| Consult the [contract addresses](/price-feeds/pro/contract-addresses) page for the Pyth Lazer state object ID on mainnet and testnet. |
There was a problem hiding this comment.
Point Sui users to a source that includes state object IDs
The guide tells readers to use /price-feeds/pro/contract-addresses for Sui state object IDs, but that page currently lists only Solana/Fogo/EVM networks and no Sui entries. In this flow, users need stateObjectId to execute addParseAndVerifyLeEcdsaUpdateCall, so this reference leaves the integration path incomplete unless they find IDs elsewhere.
Useful? React with 👍 / 👎.
- Fix I64 API: use get_is_negative(), get_magnitude_if_positive/negative() - Remove market_session/ema fields from main example (keep core fields) - Update contract addresses callout to point to SDK README - Simplify signed integer example with correct method signatures
pythia-assistant
left a comment
There was a problem hiding this comment.
Fixed the remaining issues:
I64 methods — used the correct API from i64.move:
get_is_negative()instead ofis_negative()get_magnitude_if_positive()/get_magnitude_if_negative()instead ofabs()
Feed properties — simplified the example to show core fields. All accessors do exist in feed.move (verified against source), but trimmed the example to avoid overwhelming new users.
Contract addresses — updated callout to point to SDK README for state object IDs since the contract-addresses page doesn't have Sui entries yet.
Thanks for the thorough review @matej-douro — clearly I should have verified against source before writing the examples.
|
@codex. Can you check why the developer-hub build is breaking. Can you fix it? |
|
Codex couldn't complete this request. Try again later. |
|
Closing if favor of #3498 |
Summary
This PR adds documentation for integrating Pyth Pro/Lazer on Sui, following the same structure as the existing EVM and SVM guides.
Changes
New file:
apps/developer-hub/content/docs/price-feeds/pro/integrate-as-consumer/sui.mdxparse_and_verify_le_ecdsa_updateleEcdsaformatUpdated:
meta.jsonto include Sui in navigationUpdated: Index page to list Sui alongside EVM and SVM
References
Testing