Skip to content

fix(perps): recover registered Lighter trading keys - #10618

Closed
abretonc7s wants to merge 44 commits into
mainfrom
fix/lighter-device-key-recovery
Closed

abretonc7s wants to merge 44 commits into
mainfrom
fix/lighter-device-key-recovery

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #10638, which contains this complete recovery change and now targets main. Review and delivery continue there.

Explanation

Lighter can show a balance after a reinstall but reject trades because the app lost its local trading key. Recover a key for the selected wallet without replacing another device's key. Preserve pending registrations across reconnects so delayed visibility cannot allocate another slot.

Reject stale actions after account or network changes and retain uncertain order outcomes for reconciliation. Regression tests, build and static checks pass. Final Mobile and testnet validation are pending.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and prepared draft consumer PRs

Base automatically changed from fix/lighter-omitted-fill-context to main September 30, 2026 12:55
@abretonc7s
abretonc7s marked this pull request as ready for review September 30, 2026 16:33
@abretonc7s
abretonc7s requested review from a team as code owners September 30, 2026 16:33
@abretonc7s
abretonc7s deployed to default-branch September 30, 2026 16:34 — with GitHub Actions Active

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/perps-controller/src/providers/LighterProvider.ts
@abretonc7s
abretonc7s force-pushed the fix/lighter-device-key-recovery branch from 797e923 to fc726f1 Compare October 1, 2026 06:42
@abretonc7s
abretonc7s marked this pull request as ready for review October 1, 2026 06:55
@abretonc7s
abretonc7s deployed to default-branch October 1, 2026 06:55 — with GitHub Actions Active

@geositta geositta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because automatic key migration can bypass an unfinished TP/SL settlement. The account wide nonce checks preserve dispatch obligations, but accepted protection orders can leave the nonce ledger while their settlement journal remains unresolved. Please preserve that journal's blocking behavior across migration so a successful removal or replacement reflects all outstanding protection orders for the symbol.

Comment thread packages/perps-controller/src/providers/LighterProvider.ts
@abretonc7s
abretonc7s requested a review from geositta October 2, 2026 06:30

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 bb1ee15. Configure here.

Comment thread packages/perps-controller/src/providers/LighterProvider.ts
@abretonc7s
abretonc7s marked this pull request as draft October 2, 2026 06:58
geositta
geositta previously approved these changes Oct 2, 2026
@abretonc7s
abretonc7s requested a review from geositta October 2, 2026 15:23
@abretonc7s
abretonc7s requested review from geositta and removed request for geositta October 2, 2026 19:25
@abretonc7s abretonc7s closed this Oct 2, 2026
@abretonc7s abretonc7s mentioned this pull request Oct 6, 2026
4 tasks done
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants