fix(perps): handle partial Scale order acceptance - #9989
Open
abretonc7s wants to merge 7 commits into
Open
Conversation
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.
Description
Upstreams the Scale partial-acceptance behavior temporarily carried by MetaMask Mobile #35176. Accepted Scale rungs remain live, successful results include accepted resting and filled IDs, and returned exposure plus analytics reflect accepted rungs.
Core's pinned @nktkas/hyperliquid 0.33.1 throws mixed bulk responses as ApiRequestError. This PR narrowly recovers only complete, genuinely mixed Scale responses. Malformed, waiting, invalid-ID, hybrid, top-level, unrelated, and all-rejected errors remain on the existing failure path.
Mobile temporarily carries this behavior as a compiled @metamask/perps-controller v13 Yarn patch until the next Core release. This PR does not publish or bump a version.
Changes
Validation
Related issues
Note
Medium Risk
Changes live HyperLiquid Scale order placement and success semantics when batches partially reject; incorrect parsing could mis-report success or leave unexpected orders, though behavior is narrowly scoped and heavily tested.
Overview
Scale placement no longer treats a partially rejected ladder as a full failure. When HyperLiquid accepts some rungs and rejects others, accepted resting and filled orders stay on the book and the call returns success with exposure limited to what actually landed.
#placeScaleOrdernow unwraps mixed bulk responses that the pinned SDK throws asApiRequestError, validates them strictly, and only then treats them like a normalokresponse. All-rejected, malformed, or unrelated errors still follow the existing failure and error-mapping paths (including multi-sig). Successful results expose all accepted child IDs (resting and filled), while the scale group handle still tracks resting IDs for cancellation.submittedSizeandaveragePricereflect the accepted rungs’ total size and value-weighted price.Trade analytics prefer
submittedSize(thenfilledSize) fororder_sizeandorder_value, and typed Scale event property, interaction, and setting constants are added for clients.Reviewed by Cursor Bugbot for commit 8f617b6. Bugbot is set up for automated code reviews on this repo. Configure here.