-
Notifications
You must be signed in to change notification settings - Fork 278
feat(hermes): Add ignore_invalid_price_ids
flag to Hermes v2 REST APIs
#2091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tejasbadadare
merged 14 commits into
main
from
tb/hermes/add_flag_ignore_invalid_price_ids
Nov 6, 2024
Merged
feat(hermes): Add ignore_invalid_price_ids
flag to Hermes v2 REST APIs
#2091
tejasbadadare
merged 14 commits into
main
from
tb/hermes/add_flag_ignore_invalid_price_ids
Nov 6, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…b/hermes/add_flag_ignore_invalid_price_ids
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
ignore_invalid_price_ids
flag to Hermes v2 APIsignore_invalid_price_ids
flag to Hermes v2 HTTP APIs
ignore_invalid_price_ids
flag to Hermes v2 HTTP APIsignore_invalid_price_ids
flag to Hermes v2 REST APIs
ali-behjati
approved these changes
Nov 5, 2024
ignore_invalid_price_ids
flag to Hermes v2 REST APIsignore_invalid_price_ids
flag to Hermes v2 REST APIs
cctdaniel
approved these changes
Nov 6, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to bump the version here otherwise when you release a new version it will fail
ali-behjati
approved these changes
Nov 6, 2024
keyvankhademi
approved these changes
Nov 6, 2024
…b/hermes/add_flag_ignore_invalid_price_ids
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
Today when a user requests latest price updates with a list of price_ids, the request returns an error if any of those IDs is non-existent. Since price feeds come and go, some protocols want different behavior to avoid 404s when a price feed is delisted. The fix is to provide a
ignore_invalid_price_ids
flag (default false) to the v2 APIs that ignores invalid provided price IDs and only returns data for the valid ones. This only applies to the v2 REST APIs (not websockets), which will continue to reject a subscription request that contains invalid price IDs.Implementation details
The price ID validation is currently done by the
rest::verify_price_ids_exist(state, price_ids)
function, which is used by both deprecated v1 APIs and v2 APIs.This PR modifies the function to something like
validate_price_ids(state, price_ids, remove_invalid) -> valid_price_ids
. Now the function returns a Vec of valid IDs that the caller can operate on.remove_invalid
is true (sourced fromparams.ignore_invalid_price_ids
for v2 APIs, and alwaysfalse
for v1 APIs), then the resulting Vec won't contain any invalid price IDs.remove_invalid
is false and there are invalid IDs in the passed inprice_ids
, then an Error will be returned, just like the original function would.I took this approach to minimize disruption to the existing codebase, since the APIs are written in a way that expects the code to return early if
verify_price_ids_exist
returns an Error. With the newvalidate_price_ids
function, downstream code can always operate on the resulting list without worrying about invalid IDs, like before.Updated
HermesClient.ts
to reflect the new param.Misc: Fixed some small gotchas I encountered following the setup guide in the README
Testing
Created unit tests for
validate_price_ids