feat(perps): sync controller from mobile — balance split + mode-aware spot fold#8678
Merged
michalconsensys merged 4 commits intomainfrom May 4, 2026
Merged
feat(perps): sync controller from mobile — balance split + mode-aware spot fold#8678michalconsensys merged 4 commits intomainfrom
michalconsensys merged 4 commits intomainfrom
Conversation
Syncs app/controllers/perps/ from mobile commit 355c9b656b. Changes: - Rename AccountState.availableBalance → spendableBalance and availableToTradeBalance → withdrawableBalance for clearer semantics across HL abstraction modes (Unified, Standard, Portfolio) - Mode-aware spot fold: addSpotBalanceToAccountState now folds free spot USDC into spendableBalance and withdrawableBalance for Unified/Portfolio modes; Standard/DEX-abstraction modes keep spot separate - Add throttled WS-driven userAbstraction refresh so HL-web mode flips propagate back without restart or account switch
mcmire
reviewed
May 4, 2026
Contributor
mcmire
left a comment
There was a problem hiding this comment.
A couple of minor things.
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
gambinish
approved these changes
May 4, 2026
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.
Explanation
Syncs
app/controllers/perps/from MetaMask Mobile commit355c9b656btopackages/perps-controller/src/.Key changes
availableBalance→spendableBalance,availableToTradeBalance→withdrawableBalancefor clearer semantics across HL abstraction modes (Unified, Standard, Portfolio)addSpotBalanceToAccountStatenow folds free spot USDC into bothspendableBalanceandwithdrawableBalancefor Unified/Portfolio modes, while Standard/DEX-abstraction modes keep spot separateuserAbstractionrefresh — HL-web mode flips (Unified ↔ Standard) now propagate back without requiring a restart or account switchMobile PRs included
Files changed (12 source files)
constants/hyperLiquidConfig.ts— minor config tweakconstants/perpsConfig.ts— addABSTRACTION_MODE_REFRESH_THROTTLE_MSproviders/HyperLiquidProvider.ts— balance field renames, mode-aware foldproviders/MYXProvider.ts— balance field renamesservices/HyperLiquidSubscriptionService.ts— per-user abstraction mode maps, throttled WS refresh, balance renamestypes/hyperliquid-types.ts— new types for abstraction mode handlingtypes/index.ts—AccountStatefield renames with JSDocutils/accountUtils.ts—addSpotBalanceToAccountStaterefactor withresolveFoldedBalancehelperutils/hyperLiquidAdapter.ts— balance field renamesutils/hyperLiquidValidation.ts— balance field renamesutils/myxAdapter.ts— balance field renamesutils/orderCalculations.ts— balance field renamesSuppressions
1 new ESLint suppression:
@typescript-eslint/no-unused-varsinHyperLiquidSubscriptionService.ts— caused by core'sno-unnecessary-type-assertionrule removing aas Promise<UserAbstractionResponse>cast that mobile has, leaving the import unused. Total perps suppression count: 9.References
.sync-state.jsonupdated to mobile commit355c9b656bscripts/perps/validate-core-sync.shChangelog
See
packages/perps-controller/CHANGELOG.md— entries added under## [Unreleased].Note: CHANGELOG PR links use
#NNNNplaceholder — will be updated with this PR's number after creation.Made with Cursor
Note
Medium Risk
Medium risk because it introduces breaking changes to the
AccountStatecontract and adjusts HyperLiquid balance/withdraw validation and spot-collateral folding based on abstraction mode, which can directly affect displayed balances and allowed withdrawals/orders.Overview
BREAKING: Renames
AccountStatebalance fields tospendableBalanceandwithdrawableBalanceand updates all perps providers/adapters/calculations/validation to use the new semantics (including per-subaccount breakdown and cache hashing).Makes spot USDC folding mode-aware:
addSpotBalanceToAccountStatenow always impactstotalBalance, and only contributes tospendableBalance/withdrawableBalancewhenuserAbstractionindicates Unified/Portfolio mode; disk cache key is bumped toPERPS_DISK_CACHE_USER_DATA_V2to avoid stale legacy payloads.Improves live mode handling by adding a throttled, per-user WS-triggered
userAbstractionrefresh inHyperLiquidSubscriptionServiceso HL-web mode flips propagate without restart/account switch, and adds a guard inHyperLiquidProvider.updateIsolatedMarginto ensurespendableBalancecovers margin additions.Reviewed by Cursor Bugbot for commit a26383f. Bugbot is set up for automated code reviews on this repo. Configure here.