fix: reuse adaptOrderFromSDK for historical orders - #9982
Open
geositta wants to merge 4 commits into
Open
Conversation
geositta
marked this pull request as ready for review
August 27, 2026 04:52
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Harden shared order adaptation so a malformed exchange row cannot erase the user's full activity history, while simplifying historical field normalization. Co-authored-by: Cursor <cursoragent@cursor.com>
geositta
force-pushed
the
fix/perps-history-trigger-prices
branch
from
August 27, 2026 15:07
ad622f4 to
7fead61
Compare
michalconsensys
approved these changes
Aug 27, 2026
abretonc7s
reviewed
Aug 27, 2026
| const historicalOrderType = order.orderType | ||
| ?.toLowerCase() | ||
| .includes('limit') | ||
| ? 'limit' |
Contributor
There was a problem hiding this comment.
I wonder if we should now match the full order type here or if there could be issue with includes
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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
Hyperliquid historical orders were mapped through a separate inline path that dropped
triggerPxand the normalized trigger order type. Consumers therefore received trigger orders withoutOrder.triggerPrice, preventing clients such as MetaMask Mobile from displaying the trigger price in order history.This change reuses the existing
adaptOrderFromSDKmapping used for open orders, then overlays historical lifecycle fields such as status, timestamps, and filled/remaining size. It also preserves ordinary historical market-order classification when Hyperliquid supplies a non-emptylimitPxas a slippage cap.Provider tests now cover distinct trigger and limit prices for Take Profit Limit and Stop Market orders, plus a regular market order carrying a slippage-cap price. There are no public type changes or breaking changes.
Validation:
yarn workspace @metamask/perps-controller run testyarn eslint packages/perps-controller/src/providers/HyperLiquidProvider.ts packages/perps-controller/tests/src/providers/HyperLiquidProvider.history.test.tsyarn buildReferences
Checklist
Note
Low Risk
Mapping refactor in historical order fetch only; no API or auth changes, with expanded tests guarding trigger and edge-case behavior.
Overview
HyperLiquid order history no longer uses a separate inline mapper that dropped
triggerPriceandtriggerOrderType.getOrdersnow builds each row throughadaptOrderFromSDK(same as open orders), then overlays lifecycle fields—status, timestamps, andremainingSizefrom the exchange snapshot.Historical
orderTypestill treats a non-emptylimitPxon plain market orders as a slippage cap only: classification follows the exchangeorderTypestring (limitvsmarket), not the cap price.adaptOrderFromSDKis slightly more defensive for sparse history payloads (missingoidororderType).Tests and the changelog cover TP/SL history rows, stop/take-profit trigger metadata, and malformed records.
Reviewed by Cursor Bugbot for commit 7fead61. Bugbot is set up for automated code reviews on this repo. Configure here.