fix(perps-controller): add typed position-not-found error - #10083
Merged
Conversation
abretonc7s
marked this pull request as ready for review
September 3, 2026 07:26
abretonc7s
temporarily deployed
to
default-branch
September 3, 2026 07:26 — with
GitHub Actions
Inactive
abretonc7s
enabled auto-merge
September 3, 2026 07:47
michalconsensys
approved these changes
Sep 3, 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
Adds
PERPS_ERROR_CODES.POSITION_NOT_FOUNDand returns it from HyperLiquid close, TP/SL update, and margin update when the requested position no longer exists. Clients can now distinguish an out-of-band close from unrelated provider failures without matching error text.References
Testing
yarn workspace @metamask/perps-controller testyarn buildChecklist
Note
Low Risk
Localized error-shape change on HyperLiquid position operations; widens
PerpsErrorCodeand may break callers that matched the previous error text instead of a code.Overview
Introduces
PERPS_ERROR_CODES.POSITION_NOT_FOUNDas a provider-neutral code when close, TP/SL update, or margin adjustment target a symbol the venue no longer holds.HyperLiquid now returns this code instead of free-text messages like
No position found for BTC, so clients can tell an out-of-band close from other failures without parsing error strings. Tests assert the exact code; the changelog documents the new export.Consumers with exhaustive
PerpsErrorCodemaps or UI that matched the old message should handlePOSITION_NOT_FOUND(e.g. mobile translatePerpsError).Reviewed by Cursor Bugbot for commit 23440a0. Bugbot is set up for automated code reviews on this repo. Configure here.