Repository navigation
feat(perps): add reliable Lighter trading and advanced orders - #10638
Merged
Merged
Conversation
abretonc7s
force-pushed
the
feat/lighter-advanced-orders
branch
from
October 1, 2026 06:42
10e9a4e to
4e2f2cd
Compare
abretonc7s
force-pushed
the
feat/lighter-native-trigger-orders
branch
from
October 1, 2026 06:42
4753870 to
70b6057
Compare
This was referenced Oct 1, 2026
abretonc7s
changed the base branch from
fix/lighter-device-key-recovery
to
main
October 2, 2026 23:15
abretonc7s
marked this pull request as ready for review
October 3, 2026 00:08
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e3d7a4c. Configure here.
abretonc7s
enabled auto-merge
October 5, 2026 09:57
geositta
approved these changes
Oct 5, 2026
geositta
left a comment
Contributor
There was a problem hiding this comment.
Approve, the three findings are resolved: protection obligations survive key slot migration, trigger support excludes spot markets, and recovery cannot continue a guarded removal after its position precondition fails.
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 5, 2026
Naz-Ovh
pushed a commit
to 0x-fork/metamask-core
that referenced
this pull request
Oct 7, 2026
## Explanation Releases `@metamask/perps-controller` **19.0.0 → 20.0.0**. The monorepo version goes **1314.0.0 → 1315.0.0**. No other package is being published. Perps-controller has no in-monorepo dependents that need a workspace range bump. The bump is **major**. Public unions and Lighter order validation change: - **BREAKING:** Lighter `placeOrder` / `validateOrder` accept supported native attached TP/SL instead of refusing all attachments. Gate forwarding on `attachedTpsl`. ([MetaMask#10638](MetaMask#10638)) - **BREAKING:** Grouped Lighter signer calls require grouping/count `1/2` or `2/2` with two orders, or `3/3` with three orders. ([MetaMask#10638](MetaMask#10638)) - **BREAKING:** `ScaleOrderChild.state` adds `canceled`. ([MetaMask#10638](MetaMask#10638)) - **BREAKING:** `DirectProviderOrderCapabilitiesUnavailableReason` and `OrderCapabilitiesUnavailableReason` add `order_market_unsupported`. ([MetaMask#10638](MetaMask#10638)) - **BREAKING:** Stray `triggerPrice` on Lighter basic market/limit orders is refused with `ORDER_TRIGGER_PRICE_NOT_SUPPORTED`. ([MetaMask#10638](MetaMask#10638)) - **BREAKING:** Lighter position TP/SL replacement and removal preserve independent partial triggers. ([MetaMask#10638](MetaMask#10638)) - **BREAKING:** `OrderFill.pnl` is optional when the venue omits realized PnL. Treat missing as unknown, not zero. ([MetaMask#10605](MetaMask#10605)) Also ships Lighter Scale/Chase/TWAP probe work, fee quote attribution (`feeSource`, `metamaskFeeDiscountBips`), HyperLiquid agent/signing fixes, quieter optional-messenger failures, and watchlist hydration/write races. ## Changelog Moved Unreleased entries in `packages/perps-controller/CHANGELOG.md` under `[20.0.0]`. Removed Uncategorized monorepo release markers (1311–1314) that do not affect package consumers. Dropped a duplicate Chase probe summary already covered by more specific entries. ## References - Source PRs: [MetaMask#10638](MetaMask#10638), [MetaMask#10618](MetaMask#10618), [MetaMask#10605](MetaMask#10605), [MetaMask#10643](MetaMask#10643), [MetaMask#10650](MetaMask#10650), [MetaMask#10651](MetaMask#10651), [MetaMask#10665](MetaMask#10665), [MetaMask#10670](MetaMask#10670), [MetaMask#10683](MetaMask#10683) - No in-monorepo consumer packages to bump. Mobile and Extension exhaustive union matches need the new members on upgrade. Lighter attached TP/SL stays gated on `attachedTpsl` and client rollout. ## 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) - [x] 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 Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com>
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
Recover Lighter trading access for the selected wallet after restore, preserve other devices' keys, and isolate account/network changes.
Add supported trigger orders, position protection, Scale, post-only limits, order editing and isolated-margin updates. Reconcile uncertain submissions without replay. Preserve accepted orders and cancellations through response loss, restart and account changes. Delayed Chase cancellation confirmation uses observation-only reconciliation, preventing another cancellation dispatch.
Tests, build and Mobile integration pass. Basic testnet trading, restart and reconnect are validated; final advanced-order and reinstall validation remain pending. TWAP is unavailable, Chase is a bounded testnet probe, and further TP/SL work is deferred.
References
Checklist
Note
High Risk
Large, breaking changes to Lighter order placement, protection, and financial dispatch with new recovery/Chase reconciliation paths; incorrect settlement or lifecycle fencing could block trading or mishandle ambiguous venue state.
Overview
Expands
perps-controllerwith durable Lighter trading, recovery, and advanced order flows, plus controller/messenger APIs and monorepo test wiring so clients can observe and reconcile without blind replay.Controller & aggregation adds lifecycle-fenced actions:
getChaseOrderOwnershipandreconcileChaseOrderCancellation(read/settle only—no new cancel dispatch), attached and Scale group list/review,reviewRecoveryVenue,reconcileRecoveredDispatches, andresolveRecoveryProtection.placeOrder/validateOrdersnapshot Scale intent viacaptureScaleOrderParams; testnet Lighter can opt intochaseTestnetProbefrom client config. Aggregated subscriptions tag order/fill callbacks withproviderIdand forward optionalonError.Lighter & HyperLiquid behavior (documented heavily in README/CHANGELOG) includes explicit margin mode and
updateMargin, standalone triggers, partial/independent position TP/SL withexpectedPosition, native attached OTO/OTOCO, Scale preview/placement/cancel withexpectedScaleLadder, post-only limits, same-ordereditOrdersettlement, multi-slot key recovery and dispatch reconciliation, and default-off testnet Chase/TWAP probes (LighterTwapService, Chase utilities/constants). Breaking Lighter changes: attached TP/SL onplaceOrder, stricter grouped-signer shapes, new capability/Scale states, and rejecting straytriggerPriceon basic orders. HyperLiquid gains guarded post-sign dispatch (createGuardedHyperLiquidClient) and richerHYPERLIQUID_ORDER_CAPABILITIES.Tooling maps
@metamask/perps-controller/constants/*andutils/*to source in Jest; package Jest compiles selected ESM SDK deps on Node 22.Reviewed by Cursor Bugbot for commit 1ffc52a. Bugbot is set up for automated code reviews on this repo. Configure here.