fix(perps): align decimal behavior and display parity cp-13.28.0#41853
Closed
abretonc7s wants to merge 28 commits into
Closed
fix(perps): align decimal behavior and display parity cp-13.28.0#41853abretonc7s wants to merge 28 commits into
abretonc7s wants to merge 28 commits into
Conversation
…CurrencyWithMinThreshold
Replace .toFixed(2) and formatNumber({min:2,max:2}) calls in perps UI
with formatCurrencyWithMinThreshold(value,'USD') for price fields and
formatTokenQuantity(value,symbol) for token quantities.
Affected: market detail page (header price, OHLCV bar, position entry/
liquidation/TP/SL/funding prices), order entry page (header price),
edit-margin modal (liquidation prices), reverse-position modal (est size).
Upgrade the perps controller to the published 3.1.0 formatter surface, switch the extension perps UI to the shared mobile/controller decimal helpers, and patch the published package so the missing MYXProvider files do not break extension builds. Constraint: Must reuse the controller-published formatter/range utilities from the TAT-2870 mobile/core work Constraint: Published @metamask/perps-controller@3.1.0 tarball omits MYXProvider files referenced by PerpsController, so the dependency is pinned through a local Yarn patch to keep builds working Rejected: Keep the interim useFormatters-based UI formatting | does not satisfy the ticket intent or mobile parity requirement Rejected: Reimplement mobile decimal logic locally in extension code | would duplicate controller behavior and drift again Confidence: medium Scope-risk: moderate Directive: Remove the Yarn patch once a corrected perps-controller package is published with MYXProvider assets included Tested: lint:changed; verify-locales; circular-deps:check; targeted perps/unit tests; before/after screenshot recipe validation Not-tested: Full end-to-end PR-wide coverage analyzer remains noisy because this checkout differs from main by hundreds of unrelated files
Merge origin/main into the perps decimal formatting branch and reconcile the overlapping perps UI/controller files so the controller-based formatter migration coexists with the newer close-position, margin, and order-entry fixes already on main. Constraint: Branch is already published, so conflict resolution must avoid history rewriting Constraint: Keep the temporary perps-controller patch until the corrected upstream package is published Rejected: Rebase the branch onto main | would require a force-push on a shared branch Rejected: Take either side wholesale in conflicted perps files | would drop either the controller formatter migration or newer mainline bug fixes Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Replace the patched perps-controller dependency and refresh screenshot evidence again once the upstream package is republished Tested: eslint on resolved perps files; targeted perps/unit tests (6 suites, 209 tests) Not-tested: Full repo CI gate after merge
Switch the extension off the temporary patched 3.1.0 tarball to the published 3.1.1 controller release, and keep the Sentry breadcrumb wiring in perps infrastructure so order failures no longer throw when the controller tracer records breadcrumbs. Constraint: Core has now published a fixed perps-controller release, so the extension should consume it directly instead of carrying a local package patch Constraint: The perps tracer must expose addBreadcrumb because controller code calls it during order flows Rejected: Keep the 3.1.0 Yarn patch in place | obsolete once 3.1.1 is published and increases maintenance drift Rejected: Delay breadcrumb wiring until after dependency bump | leaves the order flow broken on the current branch state Confidence: medium Scope-risk: moderate Reversibility: clean Directive: If 3.1.1 still requires extra consumer work, document it in the PR body rather than reintroducing a hidden package patch Tested: yarn install --mode=skip-build; npm view @metamask/perps-controller version Not-tested: branch not yet remerged with latest main or revalidated after dependency switch
…blish Reconcile the extension perps decimal formatting branch with current main after switching to the published perps-controller 3.1.1 release, keeping the direct controller formatter path intact across the newly changed perps files. Constraint: The branch must stay mergeable without force-pushes while tracking the freshly published controller release Rejected: Postpone the main merge until after dependency bump verification | leaves the PR in a conflicting state for reviewers Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Refresh PR text and screenshots again if this merge changes any visible perps output Tested: targeted perps/unit tests before finalizing merge Not-tested: full repo CI after the merge commit
This pushes the branch into a near-parity state for the key perps surfaces by replacing legacy local display/calculation paths with controller-backed logic, tightening refresh-isolated validation, and packaging a local PR description for rate-limited publishing paths. Constraint: Mobile remains the source of truth for perps display behavior Constraint: GitHub publishing from this environment is partially blocked by API rate limits / integration permissions Rejected: Treat long-flow hydration noise as proof parity is broken | refresh-isolated and same-window captures show BTC/ETH are effectively aligned Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Keep hydration/network issues separate from decimal-parity conclusions; validate value-shape parity from refreshed state when live streams are noisy Tested: Targeted Jest slice (6 suites / 208 tests), eslint on touched parity files, lsp diagnostics on key changed files, extension composed parity recipe passing 15/15, same-window BTC/ETH extension vs mobile comparison Not-tested: Full repo lint/CI, persistent non-BTC/ETH oracle hydration fix, GitHub PR body update from this environment
The root PR_DESC helper is useful for copy-paste and time-sensitive review prep, but it should not be part of the repository diff. The file remains available locally and is excluded from status noise, while the branch only contains the actual parity/code changes. Constraint: Local PR description helpers must not become part of the PR diff Rejected: Keep PR_DESC.md tracked | pollutes the review with non-product content Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep local review helpers untracked unless the user explicitly wants them versioned in the repo Tested: Verified PR_DESC.md still exists locally after git rm --cached Not-tested: GitHub PR body update from this environment (still rate-limited)
Two test cases called createPerpsInfrastructure() without the required InfrastructureDeps argument. Add getDeps() to both calls.
…s-decimal-logic # Conflicts: # ui/components/app/perps/perps-balance-dropdown/perps-balance-dropdown.test.tsx # ui/components/app/perps/perps-balance-dropdown/perps-balance-dropdown.tsx
Address the remaining perps review feedback with minimal behavioral change. The disk cache now writes under a perps-specific storage prefix while still reading legacy raw keys, the order fee fallback rates are centralized, and the market-detail funding assertion matches the rendered sign behavior. Constraint: Keep review fixes narrow and avoid changing unrelated workspace artifacts Rejected: Broader perps formatting refactor | outside the requested review-fix scope Confidence: high Scope-risk: narrow Reversibility: clean Directive: Preserve the disk-cache legacy read fallback unless storage migration is handled explicitly Tested: PR #41558 decimal formatting recipe via CDP (47/47); targeted Jest for perps review-fix files; ESLint on touched files Not-tested: Repo-wide lint and locale gates remain blocked by unrelated workspace artifacts and existing branch issues
Resolve the branch against current origin/main, keep the package baseline aligned with main, and reapply only the intended perps-controller 3.1.1 upgrade. Carry forward the perps disk-cache safety fix so legacy migration remains possible without probing arbitrary unprefixed storage keys. Constraint: Preserve current main dependency baselines while keeping the perps-controller upgrade and review fixes intact Rejected: Keep broad legacy raw-key fallback in disk cache | risks collisions with unrelated browser.storage.local entries Rejected: Hand-merge yarn.lock or policy files | regenerated outputs are safer after manifest resolution Confidence: medium Scope-risk: moderate Reversibility: clean Directive: If package dependencies change again on this branch, regenerate yarn.lock and LavaMoat policies from the merged manifest before replying to policy review threads Tested: yarn install --mode=skip-build; yarn lavamoat:auto; jest app/scripts/controllers/perps/infrastructure.test.ts app/scripts/messenger-client-init/assets/assets-controller-init.test.ts --no-coverage; eslint on touched perps/assets init files Not-tested: Full repo-wide lint/typecheck/test gates
The controller only performs disk hydration synchronously when diskCache.getItemSync is implemented. Extension storage is async-only, so exposing a sync reader backed only by in-memory state creates a false contract at startup. Drop sync support, keep the async legacy-key migration path, and retain the collision guard against arbitrary unprefixed keys. Constraint: Extension browser.storage.local has no synchronous read path Rejected: Keep getItemSync backed by memory only | breaks the controller's boot-time hydration expectations Confidence: high Scope-risk: narrow Reversibility: clean Directive: Reintroduce getItemSync only if extension gains a real synchronous persisted backing store Tested: jest app/scripts/controllers/perps/infrastructure.test.ts --no-coverage; eslint on app/scripts/controllers/perps/infrastructure.ts and app/scripts/controllers/perps/infrastructure.test.ts Not-tested: Full repo-wide lint/typecheck/test gates
Fix the real PR-owned perps regression by stripping HIP-3 dex prefixes from the close amount display, and clean up the perps test helpers so they satisfy the current lint/parser rules after the main merge. Constraint: Keep the CI fix limited to PR-owned perps files Rejected: Broaden the change into unrelated integration selector fixes | outside the requested scope and not attributable to this PR Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep follow-up CI work focused on failures that remain attributable to this PR after this push Tested: yarn eslint on affected perps files; yarn jest ui/components/app/perps/order-entry/components/close-amount-section/close-amount-section.test.tsx ui/hooks/perps/usePerpsOrderForm.test.ts ui/pages/perps/perps-order-entry-page.test.tsx --no-coverage Not-tested: Full repo-wide CI suite locally
The previous perps test helper cleanup left one stale Promise<T> cast in usePerpsOrderForm.test.ts. Replace it with the resolved generic name so the perps test file satisfies TypeScript in CI. Constraint: Keep the fix limited to the single failing perps test file Rejected: Broader follow-up changes while CI is still rerunning | unnecessary until fresh failures are known Confidence: high Scope-risk: narrow Reversibility: clean Directive: When patching generic helper names in .tsx test files, verify both lint and typecheck-sensitive syntax before pushing Tested: yarn eslint ui/hooks/perps/usePerpsOrderForm.test.ts; yarn jest ui/hooks/perps/usePerpsOrderForm.test.ts --no-coverage Not-tested: Full repo-wide CI suite locally
Mock the perps background request path in order-entry.test.tsx so the test uses an immediate resolved path instead of leaking async updates and background connection warnings into the console baseline. Constraint: Keep the fix limited to the noisy perps test harness Rejected: Update the console baseline file | hides a real test harness problem instead of fixing it Confidence: high Scope-risk: narrow Reversibility: clean Directive: When a component test exercises the real perps form hook, stub background requests in the test to avoid asynchronous console noise Tested: yarn eslint ui/components/app/perps/order-entry/order-entry.test.tsx; yarn jest ui/components/app/perps/order-entry/order-entry.test.tsx --no-coverage Not-tested: Full repo-wide CI suite locally
The perps-controller 3.1.1 upgrade brings in the HyperLiquid signing stack, which includes ESM packages under node_modules. Integration Jest was still ignoring all node_modules transforms, causing suites to abort at module-load time with "Cannot use import statement outside a module". Align the integration transform allowlist with the unit config for the perps/HyperLiquid dependency chain. Constraint: Keep the fix limited to the integration Jest transform path Rejected: Patch product/runtime code for a test-runner module-loading problem | wrong layer for this failure Confidence: high Scope-risk: narrow Reversibility: clean Directive: If the perps-controller dependency graph adds more ESM packages, update the integration Jest allowlist alongside the unit allowlist Tested: yarn webpack-cli build --config ./development/webpack/webpack.integration.tests.config.ts; yarn jest --config jest.integration.config.js test/integration/confirmations/transactions/alerts.test.tsx --runInBand Not-tested: Full integration matrix locally
The perps-controller upgrade needs the package and lockfile changes, but the regenerated attribution file is release-side noise and bloats review size without affecting behavior. Constraint: Attribution updates are handled separately from feature PRs in this repo Rejected: Keep attribution.txt alongside the dependency bump | unrelated generated churn and reviewer distraction Confidence: high Scope-risk: narrow Directive: Keep dependency diffs for this PR limited to the controller version bump and required lockfile changes Tested: Confirmed attribution.txt matches origin/main byte-for-byte before staging Not-tested: Repo-wide CI after this revert
The generic PopoverMenuItem component had a duplicate perps-market-detail-oracle-price test ID on its label Text element. The actual oracle price element already carries this ID.
…onventions Route the perps disk cache through StorageService-backed messenger actions and simplify liquidation price loading with useAsyncResult so the PR addresses the current extension review feedback without changing the underlying perps behavior. Constraint: Extension platform reviewers expect storage to flow through StorageService rather than raw browser.storage.local access Rejected: Keep raw browser.storage.local in perps infrastructure | violates local platform conventions and keeps the main review thread open Rejected: Add an extension-only abort suppression filter in the perps logger | masks noise without fixing the upstream cancellation classification Confidence: medium Scope-risk: moderate Directive: If historical candle abort noise is fixed later, do it in mobile/controller code first, then sync to core and extension Tested: Targeted Jest for perps infrastructure + perps-controller-init; ESLint on touched files; live perps recipe pr-41558-decimal-formatting (47/47) Not-tested: Full repo-wide lint/type/test suite
The test helper returned immediate promises but cast them to Promise<never>, which is unnecessary and misleading for reviewers even though it happened to type-check. Constraint: Keep the change scoped to the reviewer-requested test cleanup only Rejected: Leave the casts in place | incorrect typing noise with no behavioral value Confidence: high Scope-risk: narrow Directive: Keep these lightweight async test helpers typed to the values they actually resolve with Tested: Jest ui/hooks/perps/usePerpsOrderForm.test.ts --no-coverage; ESLint ui/hooks/perps/usePerpsOrderForm.test.ts Not-tested: Repo-wide test and lint suites
Move the page-local display-price parsing and fiat formatting helpers into the existing perps utils surface so formatting coercion stays centralized and the market detail page does not carry one-off helper copies. Constraint: Keep the change scoped to the reviewer-suggested helper extraction without widening into broader perps formatter refactors Rejected: Leave the helpers inline in perps-market-detail-page | duplicates generic display formatting logic in a single page Confidence: high Scope-risk: narrow Directive: If similar string-or-number perps display coercion appears elsewhere, reuse this util rather than cloning page-local helpers Tested: ESLint ui/components/app/perps/utils/formatPerpsDisplayPrice.ts ui/components/app/perps/utils/index.ts ui/pages/perps/perps-market-detail-page.tsx Not-tested: Targeted page-level Jest/recipe rerun after pure helper extraction
Revert the formatting/display-only perps changes from the current branch so the existing PR can focus on the controller update, decimal-calculation behavior, and required integration support while a stacked follow-up branch carries the UI formatting work. Constraint: Must split the already-pushed branch without force-pushing Rejected: Rewrite branch history to extract the formatting work | force-push is disallowed in this repo Confidence: high Scope-risk: moderate Directive: Formatting/display parity should now be carried only on the stacked follow-up branch based on this cleaned branch Tested: Structural split only; no source logic files changed in this commit Not-tested: Post-split branch validation will be run after both branches are created
Reapply the presentation-only perps formatting and display changes on top of the cleaned decimal-logic branch so formatting review can happen separately from the controller upgrade and calculation behavior. Constraint: This branch must stay stacked on fix/tat-2699-fix-perps-decimal-logic without reintroducing package, Jest, or LavaMoat churn Rejected: Keep formatting mixed into PR #41558 | too many responsibilities in one review surface Confidence: high Scope-risk: narrow Directive: Keep future changes on this branch limited to UI formatting/display parity and related tests only Tested: ESLint on touched formatting files Not-tested: Targeted UI Jest and recipe rerun after branch split
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 17, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
runway-github Bot
added a commit
that referenced
this pull request
Apr 18, 2026
## **Description** This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 ## **Manual testing steps** 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. ## **Screenshots/Recordings** ### **Before** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ### **After** N/A for this split PR. UI-facing screenshot evidence lives in stacked PR #41853. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
abretonc7s
added a commit
that referenced
this pull request
Apr 18, 2026
This PR is the base branch for the perps controller update and decimal-logic work in [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699). It upgrades the extension to `@metamask/perps-controller@3.1.1`, keeps the decimal/calculation logic changes, and includes the required extension integration support for that controller update (`StorageService` wiring, Jest support, and LavaMoat updates). A few perps UI files still appear here only where the retained hunks are logic-owned rather than presentation-only. The UI-facing display/formatting parity changes were split out into stacked PR [#41853](#41853). CHANGELOG entry: null Fixes: [TAT-2699](https://consensyssoftware.atlassian.net/browse/TAT-2699) Related: - [TAT-2870](https://consensyssoftware.atlassian.net/browse/TAT-2870) - MetaMask/core#8473 - MetaMask/metamask-mobile#28871 - MetaMask/metamask-mobile#28892 - Stacked UI/display follow-up: #41853 1. Open a perps market such as BTC or ETH in extension. 2. Verify order-entry calculations use the updated decimal logic for size, margin, liquidation, and fees. 3. Verify the perps controller initializes correctly and the relevant perps screens still load. 4. Run the extension perps validation recipe: `temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json`. N/A for this split PR. UI-facing screenshot evidence lives in stacked PR N/A for this split PR. UI-facing screenshot evidence lives in stacked PR - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2699]: https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TAT-2870]: https://consensyssoftware.atlassian.net/browse/TAT-2870?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it upgrades a core dependency and changes perps infrastructure wiring (formatting, Sentry breadcrumbs, and persistent cache via StorageService), which can affect order-entry calculations and cached market data behavior. > > **Overview** > Upgrades `@metamask/perps-controller` to `3.1.1` and updates perps infrastructure to use the package-provided `formatPerpsFiat`/`formatPercentage` and expose `PRICE_RANGES_UNIVERSAL`, aligning formatting behavior with the controller. > > Adds a `diskCache` implementation to `createPerpsInfrastructure` backed by `StorageService` (with an in-memory read-through cache) and wires the required `StorageService:getItem/setItem/removeItem` actions through the perps messenger/init path. > > Extends tracing to forward `addBreadcrumb` calls to Sentry, adds `perpsCalculateLiquidationPrice` to the background API wiring/tests, and updates LavaMoat policies to allow `Intl.NumberFormat` for the perps controller. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 428562d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
Contributor
Author
|
Superseded by #41855. Closing the duplicate split attempt. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
This PR is stacked on top of #41854.
It contains the user-facing perps decimal/display parity work that was split out of the non-UI controller-upgrade PR so the review surface stays focused. This is the PR where the decimal logic as experienced in extension UI, display formatting, and related UI tests should be reviewed.
Changelog
CHANGELOG entry: null
Related issues
Fixes: N/A (stacked UI/display follow-up for TAT-2699 on top of #41854)
Related:
Manual testing steps
temp/agentic/recipes/teams/perps/recipes/pr-41558-decimal-formatting.json.Screenshots/Recordings
Hosted asset folder:
https://github.com/abretonc7s/mm-extension-farm-artifacts/tree/main/reviews/41558/comparison-tableBefore
After
Pre-merge author checklist
Pre-merge reviewer checklist