-
Notifications
You must be signed in to change notification settings - Fork 40
feat(lazer/evm): update example to use new PythLazerLib struct-based parsing #92
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
Conversation
…parsing - Update ExampleReceiver.sol to use parseUpdateFromPayload() for high-level struct-based parsing - Add helper function pattern for memory-to-calldata conversion - Use safe getter functions (hasPrice, getPrice, etc.) for property extraction - Add utility functions: getCurrentPrice(), getSpread(), isPriceFresh(), setTargetFeedId() - Update tests to use TransparentUpgradeableProxy for PythLazer initialization - Add comprehensive test cases for struct-based parsing, fee validation, and helper functions - Update README with detailed documentation on contract architecture, tri-state property system, and integration guide - Update pyth-crosschain submodule to include PythLazerStructs.sol Co-Authored-By: aditya@dourolabs.xyz <aditya@dourolabs.xyz>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
||
| **PythLazer.sol** is the main contract that verifies ECDSA signatures from trusted signers. It manages trusted signer keys with expiration times and collects verification fees for each update. | ||
|
|
||
| **PythLazerLib.sol** is a library that provides parsing functions for Lazer payloads. It includes both low-level parsing functions like `parsePayloadHeader()` and `parseFeedHeader()`, as well as a high-level `parseUpdateFromPayload()` function that returns a structured `Update` object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we emphasize in the README that how these 3 functions differs and in which use case we have to use them, currently it is not so clear imo.
lazer/evm/README.md
Outdated
| Price: | ||
| 100000000 | ||
| Exponent: | ||
| -8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have the "value" in front of the tag ? like how we had earlier.
…e output - Add table explaining differences between parseUpdateFromPayload, parsePayloadHeader, parseFeedHeader, and parseFeedProperty - Update console.log output to show values inline (e.g., 'Price: 100000000' instead of separate lines) - Add parsePayload helper function for memory-to-calldata conversion - Update README integration guide to include the helper function pattern Co-Authored-By: aditya@dourolabs.xyz <aditya@dourolabs.xyz>
…nd inline output" This reverts commit 0306984.
- Changed console.log('Price:') + console.logInt(price) to console.log('Price:', int256(price))
- Same for Exponent, Best bid price, and Best ask price
- Updated README expected output to match new format
Co-Authored-By: aditya@dourolabs.xyz <aditya@dourolabs.xyz>
Pyth Examples Contribution
Type of Contribution
Project Information
Project/Example Name: Pyth Lazer EVM Example
Pyth Product Used:
Blockchain/Platform:
Description
What does this contribution do?
Updates the Pyth Lazer EVM example to use the new
PythLazerLibstruct-based parsing approach withparseUpdateFromPayload()instead of manual low-level parsing. This provides a cleaner, more maintainable integration pattern.Key changes:
ExampleReceiver.solto usePythLazerStructs.UpdateandFeedstructshasPrice(),getPrice(), etc.) for property extractionTransparentUpgradeableProxyfor proper PythLazer initializationHow does it integrate with Pyth?
The contract receives signed Pyth Lazer updates, verifies them via the
PythLazercontract, and parses the payload usingPythLazerLib.parseUpdateFromPayload()to extract structured price feed data.What problem does it solve or demonstrate?
Demonstrates the recommended approach for integrating Pyth Lazer price feeds using the new struct-based parsing API, which is cleaner and less error-prone than manual byte parsing.
Updates Since Last Revision
console.logstatements to display signed integers inline usingconsole.log("Price:", int256(price))instead of separate linesTesting & Verification
How to Test This Contribution
Prerequisites
Setup & Run Instructions
Both tests pass:
test_updatePrice_parseAndLog()- Tests parsing and logging price datatest_revert_insufficientFee()- Verifies fee requirementChecklist
Code Quality
Testing
Additional Context
Notes for Reviewers
Memory-to-calldata conversion: The
parsePayload()helper function is needed becausePythLazerLib.parseUpdateFromPayload()expectsbytes calldatabutverifyUpdate()returnsbytes memory. The external call pattern (this.parsePayload()) converts memory to calldata.Submodule update: Updated
lib/pyth-crosschainto include the newPythLazerStructs.solfile.Human Review Checklist
parseUpdateFromPayloadbut contract uses helper)parsePayloadhelper pattern is clearly explainedLink to Devin run: https://app.devin.ai/sessions/0fee8f43574b4c9198b0dd65fe9de258
Requested by: aditya@dourolabs.xyz