fix(hyperliquid): fetchBalance reads spot account, drops hardcoded USDH label - #1280
Merged
Conversation
…DH label fetchBalance previously read crossMarginSummary (perp margin account) and labelled the result currency as 'USDH' regardless of what tokens the user actually held. This silently hid every spot balance — outcome markets quote against USDC on the spot account, so users with deposited funds saw 'USDH: 0' and assumed empty. Now reads spotClearinghouseState alongside the perp account: - Spot balances surface with their real currency (USDC, USDH, etc.), one Balance entry per non-zero coin. - Perp account, when funded, surfaces as 'USDC_PERP' so consumers can tell it apart from spot. Verified locally: wallet 0xcb85… ($14.90 USDC deposited on HL spot) now correctly returns USDC: total=14.9 avail=14.9 instead of USDH: 0.
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.
Summary
fetchBalancefor HL was readingcrossMarginSummary(the perp margin account) and labelling the result currency asUSDHregardless of what tokens the user actually held. This silently hid every spot balance — outcome markets quote against USDC on the spot account, so users with deposited funds sawUSDH: 0and assumed empty.Now reads
spotClearinghouseStatealongside the perp account:USDC,USDH, etc.), oneBalanceentry per non-zero coin.USDC_PERPso consumers can tell it apart from spot.Verified locally
Wallet
0xcb85…with $14.90 USDC deposited on HL spot:USDH: total=0 avail=0(wrong endpoint, wrong label)USDC: total=14.9 avail=14.9 locked=0Surfaced by ground-truth assertion testing during the HL audit — would not have shown up in shape-only smoke tests.