Skip to content

Conversation

@ayushboss
Copy link
Contributor

Summary

Implemented the get prices functions of the pyth stylus contract.

Rationale

Important for getting most recent prices, and has an important function definition for making sure that an update is no older than a certain specified age (is_no_older_than).

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Get prices can only be evaluated when other parts of the contract are completed (i.e. initialization). Until then, cargo build is the main system by which I'm verifying things work.

ayushboss and others added 2 commits June 20, 2025 14:20
- Replace incorrect .try_read().ok_or() with proper .get() method calls
- Add zero-value check for publish_time to determine if price data exists
- Contract now compiles successfully without StorageGuard errors

Co-Authored-By: [email protected] <[email protected]>
@vercel
Copy link

vercel bot commented Jun 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
entropy-debugger ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
entropy-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 1:27pm

@ayushboss ayushboss changed the base branch from main to initialize-pyth-stylus June 20, 2025 13:27
@ayushboss ayushboss marked this pull request as ready for review June 26, 2025 23:48

pub fn get_price_no_older_than(&self, _id: [u8; 32], _age: u64) -> PriceInfoReturn {
(U64::ZERO, I32::ZERO, I64::ZERO, U64::ZERO, I64::ZERO, U64::ZERO)
pub fn get_price_no_older_than(&self, _id: [u8; 32], _age: u64) -> Result<PriceInfoReturn, PythReceiverError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary right now (you can do this in a future PR,) but let's move the public components that users will consume like structs and errors into an SDK. That way they can import just the public SDK to consume prices and use the contracts. The private impls will stay in the contract, but will implement the public SDK interfaces. Example here.

Base automatically changed from initialize-pyth-stylus to main June 30, 2025 22:40
@ayushboss ayushboss merged commit 941027f into main Jun 30, 2025
9 checks passed
@ayushboss ayushboss deleted the pyth-stylus-get-prices branch June 30, 2025 22:42
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