Skip to content

fix(perps): expose spot usdc balance in account state#8535

Draft
geositta wants to merge 1 commit intomainfrom
perps/fix-spot-usdc-funded-state-core-wt
Draft

fix(perps): expose spot usdc balance in account state#8535
geositta wants to merge 1 commit intomainfrom
perps/fix-spot-usdc-funded-state-core-wt

Conversation

@geositta
Copy link
Copy Markdown

Explanation

This change fixes a controller gap in @metamask/perps-controller for HyperLiquid accounts that have spot USDC available for trading but zero perps withdrawable balance. The controller already exposed availableBalance, but that field maps to HyperLiquid withdrawable, which is not enough on its own for consumers to determine whether the account is funded enough to trade in this spot-backed flow.

The improvement is a narrow controller update that adds raw spotUsdcBalance to perps account state and populates it in both account fetches and live account updates. This keeps availableBalance unchanged as the withdrawable only value while giving consumers the missing input they need to decide funded state without changing withdraw behavior, order sizing, or other trading calculations.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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