Skip to content

Conversation

aditya520
Copy link
Member

Summary

Rationale

How has this been tested?

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

@vercel
Copy link

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
api-reference Ready Ready Preview Comment Oct 17, 2025 1:31pm
component-library Ready Ready Preview Comment Oct 17, 2025 1:31pm
developer-hub Ready Ready Preview Comment Oct 17, 2025 1:31pm
entropy-explorer Ready Ready Preview Comment Oct 17, 2025 1:31pm
insights Ready Ready Preview Comment Oct 17, 2025 1:31pm
proposals Ready Ready Preview Comment Oct 17, 2025 1:31pm
staking Ready Ready Preview Comment Oct 17, 2025 1:31pm

Copy link
Contributor

@tejasbadadare tejasbadadare left a comment

Choose a reason for hiding this comment

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

Parsing logic LGTM! Would be great to see some positive and negative tests

Comment on lines +249 to +253
function hasPrice(
PythLazerStructs.Feed memory feed
) public pure returns (bool) {
return (feed.existsFlags & PythLazerStructs.PRICE_EXISTS) != 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we create getters for the properties that enforce checking existence? It would ensure users dont assume a property like price always exists. Something like getPrice(feed) -> (bool, int64), it could return (exists, value). It's an alternative to storing the type as Option<Option<PropertyType>>.

Copy link
Member Author

@aditya520 aditya520 Oct 17, 2025

Choose a reason for hiding this comment

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

There are chances that user can ignore the exist flag. Plus returning a bool will consume more gas.

Copy link
Contributor

Choose a reason for hiding this comment

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

As it stands they would have to first call hasPrice before using the price, which to me sounds like a greater chance of being missed by implementors since they would have to know about that method and intentionally use it. On the other hand, the exists flag more clearly signals the possibility that the field may not exist, and one would have to acknowledge this to ignore it. But that's just my opinion

Copy link
Member Author

Choose a reason for hiding this comment

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

They can just call getPrice(). It will return an error if price is zero.

properties[3] = buildProperty(3, encodeUint16(5)); // publisherCount
properties[4] = buildProperty(4, encodeInt16(-8)); // exponent
properties[5] = buildProperty(5, encodeInt64(50000)); // confidence
properties[6] = buildProperty(6, encodeInt64(123456)); // fundingRate
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not correct because there is a presence byte (as noted above).

It would be good to fetch real price and funding rate updates from Lazer staging and parse them in the tests.

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

This is great, i'd like to see the field names changing to increase the clarity of the code.

Comment on lines +122 to +123
bytes calldata payload,
address signer,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a need to return these?

struct Feed {
// Slot 1: 4 + 4 + 8 + 8 + 8 = 32 bytes (fully packed)
uint32 feedId;
uint32 existsFlags; // Bitmap: bit 0-31 for up to 32 properties
Copy link
Collaborator

Choose a reason for hiding this comment

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

just want to raise that exceeding this might break our upgradability for Feed struct.

Comment on lines +28 to +38
int64 price;
int64 bestBidPrice;
int64 bestAskPrice;
// Slot 2: 8 + 8 + 8 + 8 = 32 bytes (fully packed)
int64 confidence;
int64 fundingRate;
uint64 fundingTimestamp;
uint64 fundingRateInterval;
// Slot 3: 2 + 2 = 4 bytes (28 bytes wasted, but unavoidable)
uint16 publisherCount;
int16 exponent;
Copy link
Collaborator

Choose a reason for hiding this comment

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

people can directly use these right? i recommend you rename it to maybe<field> to make it clear for people that this is an optional field (and they should use a getter)

if (property == PythLazerStructs.PriceFeedProperty.Price) {
(feed.price, pos) = parseFeedValueInt64(payload, pos);
if (feed.price != 0)
feed.existsFlags |= PythLazerStructs.PRICE_EXISTS;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to be clear, it seems you do not distinguish between lack of a property vs the property being None (as in Lazer doesn't know the price). Is that intentional?


// Safe getter functions (revert if property doesn't exist)

/// @notice Get price (reverts if not exists)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please update the comments on the failure modes. what does "not exists" mean?

FundingRateInterval
}

struct Feed {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add comments either here on what it is and how it should be used.

int64 bestBidPrice;
int64 bestAskPrice;
// Slot 2: 8 + 8 + 8 + 8 = 32 bytes (fully packed)
int64 confidence;
Copy link
Collaborator

Choose a reason for hiding this comment

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

confidence is always positive, uint64

property == PythLazerStructs.PriceFeedProperty.Confidence
) {
(feed.confidence, pos) = parseFeedValueInt64(payload, pos);
if (feed.confidence != 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

it can be 0 too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i recommend adding testing via some fixtures from Lazer as well to make sure everything works properly cross-environment.

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

There are some comments that need to be resolved before merging this change in.

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