feat(lazer/evm): update example to use new PythLazerLib struct-based parsing #92
+378
−144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 extractiongetCurrentPrice(),getSpread(),isPriceFresh(),setTargetFeedId()TransparentUpgradeableProxyfor 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.
Testing & Verification
How to Test This Contribution
Prerequisites
Setup & Run Instructions
All 5 tests pass:
test_updatePrice_structBased()- Main price update flowtest_revert_insufficientFee()- Fee validationtest_nonTargetFeed_noUpdate()- Non-target feed handlingtest_setTargetFeedId()- Feed ID configurationtest_helperFunctions()- Utility functionsChecklist
Code Quality
Testing
Additional Context
Notes for Reviewers
Memory-to-calldata conversion: The
_parsePayload()+parsePayloadExternal()pattern is needed becausePythLazerLib.parseUpdateFromPayload()expectsbytes calldatabutverifyUpdate()returnsbytes memory. This external call pattern converts memory to calldata.Type change:
pricechanged fromuint64toint64to match the new library's return types.Submodule update: Updated
lib/pyth-crosschainto include the newPythLazerStructs.solfile.No access control on
setTargetFeedId(): This is intentional for the example to keep it simple.Link to Devin run: https://app.devin.ai/sessions/0fee8f43574b4c9198b0dd65fe9de258
Requested by: [email protected]