Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 16, 2025

Pyth Examples Contribution

Type of Contribution

  • New Example Project (Adding a new example to demonstrate Pyth integration)
  • Bug Fix (Fixing an issue in existing examples)
  • Documentation Update (Improving README, comments, or guides)
  • Enhancement (Improving existing functionality or adding features)
  • Hackathon Submission (Submitting a project from a hackathon)

Project Information

Project/Example Name: Pyth Lazer EVM Example

Pyth Product Used:

  • Pyth Price Feeds
  • Pyth Entropy
  • Multiple Products
  • Other: Pyth Lazer

Blockchain/Platform:

  • Ethereum/EVM
  • Solana
  • Aptos
  • Sui
  • Fuel
  • Starknet
  • TON
  • Other: ___________

Description

What does this contribution do?

Updates the Pyth Lazer EVM example to use the new PythLazerLib struct-based parsing approach with parseUpdateFromPayload() instead of manual low-level parsing. This provides a cleaner, more maintainable integration pattern.

Key changes:

  • Refactored ExampleReceiver.sol to use PythLazerStructs.Update and Feed structs
  • Added helper function pattern for memory-to-calldata conversion (required by the library)
  • Added safe getter functions (hasPrice(), getPrice(), etc.) for property extraction
  • Updated tests to use TransparentUpgradeableProxy for proper PythLazer initialization
  • Comprehensive README documentation with integration guide and troubleshooting

How does it integrate with Pyth?

The contract receives signed Pyth Lazer updates, verifies them via the PythLazer contract, and parses the payload using PythLazerLib.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

  • Single-line output format: Updated console.log statements to display signed integers inline using console.log("Price:", int256(price)) instead of separate lines
  • Updated README expected output to match the new format

Testing & Verification

How to Test This Contribution

Prerequisites

  • Foundry installed

Setup & Run Instructions

cd lazer/evm
forge install
forge build
forge test -vvv

Both tests pass:

  • test_updatePrice_parseAndLog() - Tests parsing and logging price data
  • test_revert_insufficientFee() - Verifies fee requirement

Checklist

Code Quality

  • Code follows existing patterns in the repository
  • Proper error handling implemented
  • No hardcoded values (use environment variables where appropriate)

Testing

  • Tested locally and works as expected
  • All existing functionality still works (no breaking changes)

Additional Context

Notes for Reviewers

  1. Memory-to-calldata conversion: The parsePayload() helper function is needed because PythLazerLib.parseUpdateFromPayload() expects bytes calldata but verifyUpdate() returns bytes memory. The external call pattern (this.parsePayload()) converts memory to calldata.

  2. Submodule update: Updated lib/pyth-crosschain to include the new PythLazerStructs.sol file.

Human Review Checklist

  • Verify the README integration guide example is consistent with actual contract implementation (note: README shows direct call to parseUpdateFromPayload but contract uses helper)
  • Confirm the README expected output matches actual test output
  • Check that the parsePayload helper pattern is clearly explained

Link to Devin run: https://app.devin.ai/sessions/0fee8f43574b4c9198b0dd65fe9de258
Requested by: aditya@dourolabs.xyz

…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-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring


**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.
Copy link
Contributor

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.

Comment on lines 124 to 127
Price:
100000000
Exponent:
-8
Copy link
Contributor

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.

devin-ai-integration bot and others added 2 commits January 6, 2026 20:40
…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>
- 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>
@aditya520 aditya520 merged commit 3b73d41 into main Jan 8, 2026
4 of 5 checks passed
@aditya520 aditya520 deleted the devin/1765900200-update-lazer-evm-example branch January 8, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants