fix(perps-controller): keep open position margin mode on HyperLiquid orders - #10588
Merged
Merged
Conversation
abretonc7s
enabled auto-merge
September 30, 2026 00:28
Bigshmow
approved these changes
Sep 30, 2026
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Sep 30, 2026
## Explanation - Release major perps-controller 19.0.0 Breaking changes (see changelog): - `OrderFill.liquidation.liquidatedUser` is now optional - `FrontendOrder.orderType` union adds `Twap Slice`, `Vault Close`, `Spot Dust Conversion` - Removed `LighterPersonalSigner` and the `personalSigner` / `l1Address` fields of `LighterAuthConfig` ## References - #10414, #10437, #10464, #10559, #10588, #10589, #10591 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
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
TradingService.flipPositionsends leverage with nomarginMode.HyperLiquidProvider.#prepareAssetForTradingthen fell back to isolated and calledupdateLeverage({ isCross: false }). On a Cross position, HyperLiquid rejects that with "Cannot switch leverage type with open position". On Mobile, every one of these failures (64 events from 20 users over 30 days) was a position flip.When an order omits
marginMode, HyperLiquid now uses the open position's mode. It reads positions from the fresh WebSocket cache and falls back to one REST read. With no position, or if the read fails, it keeps the old isolated default. Orders that setmarginModeexplicitly are unchanged.The fix is in the HyperLiquid provider, not in
flipPosition: Lighter rejects any order that setsmarginMode, so passingposition.leverage.typefrom the shared service would break Lighter flips.References
Checklist