Skip to content

Conversation

tejasbadadare
Copy link
Contributor

@tejasbadadare tejasbadadare commented Sep 12, 2025

Summary

  • This PR adds a symbols: Option<Vec<String>> optional request parameter to SubscriptionParams, LatestPriceRequest, PriceRequest and makes price_feed_ids an Option instead of being required. This enables specifying feeds by symbol rather than ID if desired.
    • From an API standpoint this change should be backward compatible.
  • ignore_price_feed_ids is backward-compatibly renamed to ignore_price_feeds so that it can be used regardless of whether the feeds are specified by symbols or price_feed_ids.
  • Once this lands in the protocol crate, i'll add support for resolving the symbols into IDs in the router.

Rationale

We want to support fetching latest price/subscribing to feeds via symbols, not just IDs. This is more user friendly for people trying out the system, as it eliminates the need to look up the mapping from symbol to ID. Paired with the new symbology, users should be able to discover feeds predictably.

How has this been tested?

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

Copy link

vercel bot commented Sep 12, 2025

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

7 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
api-reference Skipped Skipped Sep 16, 2025 11:21pm
component-library Skipped Skipped Sep 16, 2025 11:21pm
developer-hub Skipped Skipped Sep 16, 2025 11:21pm
entropy-explorer Skipped Skipped Sep 16, 2025 11:21pm
insights Skipped Skipped Sep 16, 2025 11:21pm
proposals Skipped Skipped Sep 16, 2025 11:21pm
staking Skipped Skipped Sep 16, 2025 11:21pm

return Err("no price feed ids specified");
if value.price_feed_ids.is_none() && value.symbols.is_none() {
return Err("either price feed ids or symbols must be specified");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also forbid passing both feed ids and symbols at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah makes sense. I was debating between this and union-ing them in the server. But yeah i'll go ahead forbid passing both feed ids and symbols at the same time.

Comment on lines +203 to +205
// "ignoreInvalidFeedIds" was renamed to "ignoreInvalidFeeds". "ignoreInvalidFeedIds" is still supported for compatibility.
#[serde(default, alias = "ignoreInvalidFeedIds")]
pub ignore_invalid_feeds: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

So this can be omitted altogether (defaulting to false) or one of ignoreInvalidFeedIds or ignoreInvalidFeeds can be specified? What about both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this applies to the deserializer (e.g., from a JSON payload). Fields named ignoreInvalidFeedIds (the old name) will still be accepted, and will be aliased/renamed to the new ignoreInvalidFeeds. I'm actually not sure what happens if both are provided -- i assume serde would fail to deserialize the payload with some kind of "duplicate keys" error.

@merolish
Copy link
Contributor

No objections. Guess there's no way around being messy with an API change that needs to retain compatibility.

Riateche
Riateche previously approved these changes Sep 16, 2025
danimhr
danimhr previously approved these changes Sep 16, 2025
pub price_feed_ids: Vec<PriceFeedId>,
// Either price feed ids or symbols must be specified.
pub price_feed_ids: Option<Vec<PriceFeedId>>,
pub symbols: Option<Vec<String>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a new field here. Shouldn't we add default value to None, to make sure api is backward compatible?
Maybe it's okay by default but I just wanna make sure if that's the case

Copy link
Contributor

Choose a reason for hiding this comment

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

serde_json already defaults to None for an Option field if it's absent, so there is no need for #[serde(default)] in this case.

@vercel vercel bot temporarily deployed to Preview – proposals September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – insights September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – component-library September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – staking September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – developer-hub September 16, 2025 23:10 Inactive
@vercel vercel bot temporarily deployed to Preview – proposals September 16, 2025 23:21 Inactive
@vercel vercel bot temporarily deployed to Preview – component-library September 16, 2025 23:21 Inactive
@vercel vercel bot temporarily deployed to Preview – staking September 16, 2025 23:21 Inactive
@vercel vercel bot temporarily deployed to Preview – entropy-explorer September 16, 2025 23:21 Inactive
@vercel vercel bot temporarily deployed to Preview – developer-hub September 16, 2025 23:21 Inactive
@vercel vercel bot temporarily deployed to Preview – insights September 16, 2025 23:21 Inactive
@vercel vercel bot temporarily deployed to Preview – api-reference September 16, 2025 23:21 Inactive
@tejasbadadare tejasbadadare merged commit 6b1d6c6 into main Sep 17, 2025
10 checks passed
@tejasbadadare tejasbadadare deleted the tb/pyth-lazer-protocol/subscribe-by-symbols branch September 17, 2025 00:12
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