Skip to content

fix(hyperliquid): fetchBalance reads spot account, drops hardcoded USDH label - #1280

Merged
realfishsam merged 1 commit into
mainfrom
fix/hl-fetchbalance-spot-account
Jun 22, 2026
Merged

fix(hyperliquid): fetchBalance reads spot account, drops hardcoded USDH label#1280
realfishsam merged 1 commit into
mainfrom
fix/hl-fetchbalance-spot-account

Conversation

@realfishsam

Copy link
Copy Markdown
Contributor

Summary

fetchBalance for HL was reading crossMarginSummary (the perp margin account) and labelling 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… with $14.90 USDC deposited on HL spot:

  • Before: USDH: total=0 avail=0 (wrong endpoint, wrong label)
  • After: USDC: total=14.9 avail=14.9 locked=0

Surfaced by ground-truth assertion testing during the HL audit — would not have shown up in shape-only smoke tests.

…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.
@realfishsam
realfishsam merged commit 4b5cef8 into main Jun 22, 2026
6 of 11 checks passed
@realfishsam
realfishsam deleted the fix/hl-fetchbalance-spot-account branch June 22, 2026 12:17
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.

1 participant