fix(hypercore): accept null venue payloads in predicted_fundings - #83
Merged
ifdario merged 1 commit intoAug 31, 2026
Merged
Conversation
The exchange sends null for a venue's payload when the coin is not listed
there, which aborts deserialization of the whole response:
invalid type: null, expected struct PredictedFundingVenue
at line 1 column 1998
The first null lands on coin AI, venue BybitPerp, the 4th of 232 coins, so
predicted_fundings fails on every mainnet call. On mainnet 69 of 696 venue
slots are null: BybitPerp 45, BinPerp 24.
Model the venue payload as Option<PredictedFundingVenue>. None means the coin
is not listed on that venue, which is distinct from a zero funding rate --
collapsing the two invents a funding spread against the venues that did
report one.
Add funding_interval_hours, which the exchange sends but the struct lacked.
Optional: 19 of 627 non-null payloads omit it.
Cover the endpoint in test_http_undocumented_typed_responses, which is the
test for this failure mode but never included predicted_fundings. Asserting
a null exists makes reverting the Option a compile error rather than a silent
regression.
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
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.
Fix
predicted_fundingsdeserialization failure on unlisted coinsHttpClient::predicted_fundingsfails on every call against mainnet. The endpoint is currently unusable.Cause
The exchange sends
nullfor a venue's payload when the coin is not listed on that venue.predicted_fundingsmodels the payload as a barePredictedFundingVenue, so the first null aborts the whole response.The first one lands at byte 1995 — coin
AI, venueBybitPerp, the 4th of 232 coins:Nulls are not an edge case. Measured against live mainnet:
BybitPerp45,BinPerp24.HlPerpnever nullfundingIntervalHoursChanges
Option<PredictedFundingVenue>per venue in the return type.Nonemeans the coin is not listed there — real information, and distinct from a zero funding rate. A consumer that collapses the two invents a funding spread against the venues that did report one, so the distinction is worth the signature change.PredictedFundingVenue::funding_interval_hours: Option<u32>— sent by the exchange, absent from the struct.Optionbecause 19 of 627 payloads omit it, withskip_serializing_ifperCLAUDE.md. (This is a response type, never signed, so it is unrelated to theActionRequestsigning concern in c395da8.)test_http_undocumented_typed_responses, which is the testCLAUDE.mdnames for exactly this failure mode but which never included this endpoint. Asserting a null exists means reverting theOptionis a compile error, not a silent regression:Why it shipped broken
The struct arrived in 4757e9d, "align SDK with Hyperliquid API docs" — modelled from documentation, which shows the happy-path shape and does not mention that a venue payload is nullable. The only existing test asserts the request serializes to
{"type":"predictedFundings"}; nothing checked the response. This is the gapCLAUDE.mdalready describes:Breaking
The signature change breaks callers that destructure the venue tuple. Scope is small: 3 references in the lib, none in
hypecliorexamples/, so nocd hypecli && cargo checkfallout. Warrants0.3.0. No version bump in this branch — left tocargo release.Verification
cargo fmt— cleancargo clippy -p hypersdk --all-targets— no new warnings (the 4too many argumentsare pre-existing)cargo test --lib— 158 passed, 0 failed232 coins, 696 venue slots, 69 nulls, 608 with fundingIntervalHoursNote: the new assertion makes
test_http_undocumented_typed_responseshit live mainnet for one more endpoint, consistent with the nine already there.