Repository navigation
fix(perps): handle inactive Lighter market metadata - #10110
Merged
Merged
Conversation
abretonc7s
force-pushed
the
fix/perps/lighter-inactive-market-metadata
branch
from
September 4, 2026 11:04
ef8dd5b to
445456c
Compare
abretonc7s
marked this pull request as ready for review
September 4, 2026 11:06
abretonc7s
temporarily deployed
to
default-branch
September 4, 2026 11:07 — with
GitHub Actions
Inactive
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 445456c. Configure here.
abretonc7s
enabled auto-merge
September 4, 2026 11:43
geositta
approved these changes
Sep 4, 2026
3 of 4 tasks
pull Bot
pushed a commit
to Reality2byte/core
that referenced
this pull request
Sep 8, 2026
## Explanation Lighter account discovery can return sparse balance fields, and API code `21100` authoritatively means the selected wallet has no venue account. The provider previously rejected funded accounts during discovery and left no-account subscribers waiting indefinitely. This change validates only identity fields during address discovery, queries all API-key slots so non-default registrations are found, emits empty account state only for confirmed no-account responses, and preserves existing state for transport, auth, and integrity failures. REST trade decoding now permits an omitted counterparty PnL while the fill adapter still requires the selected account's PnL. It also removes the per-frame Lighter price debug log. Validated with: - Full `@metamask/perps-controller` suite (89.48% line coverage) and full Core monorepo build - Focused Lighter service/adapter tests (`109/109`), targeted ESLint, Prettier, and package changelog validation - Mobile typecheck against yalc package `16.1.0` (`yalc.sig` `12ffef2527e5de1f35bb8b3cff91fa02`) - iOS `mm-1` no-account settlement on `dev7`: markets rendered with no balance, positions, orders, or activity - iOS funded Lighter testnet lifecycle on rebased Mobile `5beed0f35b` using published `mm-harness@0.47.1`: BTC order `242458746910186`, position `0.00012` at `81267.2`, close `68943931413978`, final state flat (`26/26` recipe nodes) ## References - Related to https://consensyssoftware.atlassian.net/browse/TAT-3766 - Follow-up to MetaMask#10110 - Unblocks MetaMask/metamask-mobile#34865 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation for new or updated code as appropriate - [x] I've communicated consumer-facing changes in the package changelog - [ ] I've introduced breaking changes — not applicable; this change is non-breaking <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Lighter account-binding, empty-state emission, and API-key discovery paths that affect trading readiness and live subscriptions; behavior is narrowed with tests but mistakes could show wrong balances or block registration. > > **Overview** > Fixes **Lighter account discovery and subscriber settlement** so wallets with funded venue accounts are not rejected on sparse discovery payloads, and UI no longer spins forever when the wallet truly has no Lighter account. > > **Account resolution:** `accountsByL1Address` now validates only identity fields (`AccountSummaryStruct` / `LighterAccountSummary`), while full `account` reads stay strict. API code **21100** and empty `subAccounts` map to `LighterAccountNotFoundError`. On channel setup, that case emits **authoritative empty** account/positions/orders; transport, auth, capability, and malformed responses **keep the last snapshot**. > > **Trading readiness:** Venue key checks call `getApiKeys(accountIndex)` (all slots) instead of probing a single unused slot, which previously returned `api key not found` and blocked first-time registration. > > **History / noise:** REST trade decoding allows omitted `askAccountPnl` / `bidAccountPnl`; the fill adapter still requires PnL for the **selected** account. Per-frame Lighter price-stream debug logging is removed. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dcf7cc6. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
pull Bot
pushed a commit
to Reality2byte/core
that referenced
this pull request
Sep 9, 2026
## Explanation Publishes `@metamask/perps-controller@16.2.0`. No other workspace packages are version-bumped. This is a minor, not a major. Expanding `PerpsErrorCode` with the margin-mode codes is additive; clients should handle unknown codes in a catch-all rather than an exhaustive map. Optional `OrderParams.marginMode` and `MarketInfo.marginMode` keep existing callers on the isolated-leverage path. Also includes the HyperLiquid TWAP terminal-record fix and Lighter account/market/log fixes. ## References - MetaMask#10136 - MetaMask#10122 - MetaMask#10119 - MetaMask#10110 ## 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) - [ ] 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 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > This PR only bumps versions and edits changelog/README/JSDoc; trading behavior ships in the referenced feature PRs, not in this diff. > > **Overview** > Cuts **release 1245.0.0**, publishing **`@metamask/perps-controller@16.2.0`** (monorepo root version bump only; no other workspace packages change). > > The diff is mostly release bookkeeping: **`package.json` versions**, a new **`[16.2.0]` changelog** section (margin-mode error codes and HyperLiquid `marginMode` API, TWAP terminal-record fix, Lighter account/market/logging fixes — already merged via linked PRs), and **consumer guidance** updates. > > **Policy clarification:** new **`PerpsErrorCode` values (including the four margin-mode codes) are documented as additive minors**, not breaking — the changelog drops the prior **BREAKING** wording. **`README.md`** adds an **Error codes** section and **`perpsErrorCodes.ts`** JSDoc now tells clients to use a **catch-all** for unknown codes instead of an exhaustive `Record<PerpsErrorCode, …>`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit add8f2d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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
Lighter retains inactive markets for historical identity and can zero their order minimums and margin fractions. The strict response decoder rejected those retired rows, which prevented otherwise valid active markets from loading.
This change accepts zero constraints only for inactive rows, omits retired markets whose risk metadata cannot produce canonical market data, and preserves inactive rows with valid metadata as delisted. Positions left on retired markets remain readable using their current position leverage as a non-tradable cap. Active markets remain strict and fail closed on zero or malformed constraints.
Validated with:
@metamask/perps-controllertest suite and Core build16.1.0(yalc.sigee73aeec8330f58ce0a6e9c6b4cf42a3)mm-1: live markets loaded and the invalid inactive-market metadata error was absentReferences
Checklist
Note
Low Risk
Scoped to Lighter public market-metadata parsing and listing; active markets remain fail-closed on bad constraints, with no changes to signing, deposits, or position operations.
Overview
Fixes Lighter market loading when the venue returns inactive perp rows with zeroed minimum order sizes or margin fractions—metadata Lighter keeps for history but that previously made the strict HTTP decoder reject the whole response and block active markets.
LighterClientServicenow allows zero minimums and margin fractions only whenstatus === 'inactive', withrefinevalidators still requiring positive values for active markets.LighterProvideraddsisInactiveMarketWithoutUsableRiskMetadatato drop those retired rows fromgetMarketDataWithPricesand margin caching, skips them ingetMarketswhen leverage metadata is omitted (instead of throwing), and still surfaces inactive markets with valid risk data as delisted. Tests cover both omission and preservation paths.Reviewed by Cursor Bugbot for commit 445456c. Bugbot is set up for automated code reviews on this repo. Configure here.