Skip to content

fix(perps-controller): sync latest mobile state and restore MYX publish safety#8473

Merged
abretonc7s merged 4 commits into
mainfrom
fix/perps/myx-webpack-ignore-restore-clean
Apr 15, 2026
Merged

fix(perps-controller): sync latest mobile state and restore MYX publish safety#8473
abretonc7s merged 4 commits into
mainfrom
fix/perps/myx-webpack-ignore-restore-clean

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Explanation

This branch syncs the latest mobile perps-controller state into Core before the next controller publish. It keeps the myxModulePath workaround for the MYXProvider dynamic import so the built package preserves webpackIgnore, and it also carries the recently merged mobile perps updates such as the HTTP candle snapshot / DEX discovery changes from MetaMask/metamask-mobile#28865.

That combination is what the extension needs next: one corrected controller publication that includes both the publish-safety fix and the latest mobile perps behavior, so downstream PRs can rebase once instead of twice.

References

Checklist

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

Restore the myxModulePath workaround in PerpsController so built dist preserves the webpackIgnore safeguard for extension consumers while MYXProvider remains excluded from published package files.

Constraint: The published package intentionally omits dist/providers/MYXProvider*, so the dynamic import must remain bundler-safe in dist output
Rejected: Leave the direct string-literal import from the last mobile sync | reintroduces the extension consumer failure fixed in #8424
Confidence: medium
Scope-risk: narrow
Directive: Once a new core PR is opened, replace the temporary changelog PR placeholder with the actual pull request number before merge
Tested: changelog:validate in a clean core worktree
Not-tested: Full perps-controller package build in this clean checkout still depends on broader monorepo reference builds outside the scope of this narrow fix
Replace the temporary changelog placeholder with the real core PR number so the release note is valid if this package is published.

Constraint: Perps-controller changelog entries must link to the introducing PR before release
Rejected: Leave PR_NUMBER placeholder in place | invalid changelog reference for release consumers
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep the changelog entry aligned with the narrow MYX publish fix until the broader mobile sync lands
Tested: yarn workspace @metamask/perps-controller changelog:validate
Not-tested: Package build remains blocked by existing perps-controller typing errors on main
@abretonc7s abretonc7s changed the title Restore MYX webpackIgnore workaround in perps-controller dist fix(perps-controller): restore MYX webpackIgnore workaround Apr 15, 2026
@abretonc7s abretonc7s marked this pull request as ready for review April 15, 2026 15:54
@abretonc7s abretonc7s requested review from a team as code owners April 15, 2026 15:54
Bring the core perps-controller branch forward to the latest mobile perps implementation so the republish includes both the MYX webpackIgnore safeguard and the recently merged candle snapshot / DEX discovery fixes from mobile.

Constraint: Mobile is the source of truth for perps controller code, so the core publish branch must be synced from the updated mobile branch before release
Constraint: Keep the MYX publish workaround intact until the package ships with safe dist behavior for extension consumers
Rejected: Publish only the narrow MYX fix | would force another controller release immediately after for the already-merged mobile perps changes
Confidence: medium
Scope-risk: moderate
Reversibility: clean
Directive: Re-run the extension evidence capture after the new controller package is published and adopted, then remove the extension-side Yarn patch
Tested: mobile validate-core-sync through copy/build/lint/changelog gates (publish-artifact check still fails due known validator issue); yarn workspace @metamask/perps-controller changelog:validate
Not-tested: Full core package test/build publish path remains blocked by the validator's artifact expectation mismatch

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3430560. Configure here.

Comment thread packages/perps-controller/src/providers/HyperLiquidProvider.ts
@abretonc7s abretonc7s enabled auto-merge April 15, 2026 17:02
@abretonc7s abretonc7s added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit d059110 Apr 15, 2026
345 checks passed
@abretonc7s abretonc7s deleted the fix/perps/myx-webpack-ignore-restore-clean branch April 15, 2026 17:59
@abretonc7s abretonc7s changed the title fix(perps-controller): restore MYX webpackIgnore workaround fix(perps-controller): sync latest mobile state and restore MYX publish safety Apr 16, 2026
github-merge-queue Bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Apr 16, 2026
## **Description**

This restores the `myxModulePath` workaround in mobile `PerpsController`
so the mobile source of truth matches the safe Core pattern from
`core#8424`, and it hardens `scripts/perps/validate-core-sync.sh` plus
the `perps-core-sync` skill so future syncs fail if the built Core
publish artifact loses the `webpackIgnore` safeguard again.

This branch has been refreshed onto a `main` that already includes
#28865, so no separate follow-up is still
pending for the historical candle transport fix.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes:
- Related to MetaMask/core#8424
- Related to MetaMask/core#8460
- Related to MetaMask/core#8473
- Related to MetaMask/metamask-extension#41558
- Refreshed onto `main` after #28865 merged

## **Manual testing steps**

```gherkin
Feature: preserve MYX publish safety during mobile-to-core sync

  Scenario: validate the sync guard on a clean Core checkout
    Given mobile is on this branch and Core is checked out locally
    When I run `bash scripts/perps/validate-core-sync.sh --core-path <core-path> --skip-test`
    Then the copied-source validation reaches the publish-artifact gate
    And the run fails if the built Core artifact does not preserve the MYX webpackIgnore safeguard

  Scenario: validate the perps historical candle transport coverage that is already present on main
    When I run `yarn jest app/controllers/perps/services/HyperLiquidClientService.test.ts --no-coverage`
    Then the TAT-2954 historical candle HTTP transport coverage passes
```

## **Screenshots/Recordings**

### **Before**

N/A - controller/source-sync change only.

### **After**

N/A - controller/source-sync change only.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

#### Performance checks (if applicable)

- [ ] I've tested on Android
- [ ] I've tested with a power user scenario
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics

## **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.
github-merge-queue Bot pushed a commit to MetaMask/metamask-extension 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>
github-merge-queue Bot pushed a commit to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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>
vinnyhoward pushed a commit to MetaMask/metamask-mobile that referenced this pull request Apr 17, 2026
## **Description**

This restores the `myxModulePath` workaround in mobile `PerpsController`
so the mobile source of truth matches the safe Core pattern from
`core#8424`, and it hardens `scripts/perps/validate-core-sync.sh` plus
the `perps-core-sync` skill so future syncs fail if the built Core
publish artifact loses the `webpackIgnore` safeguard again.

This branch has been refreshed onto a `main` that already includes
#28865, so no separate follow-up is still
pending for the historical candle transport fix.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes:
- Related to MetaMask/core#8424
- Related to MetaMask/core#8460
- Related to MetaMask/core#8473
- Related to MetaMask/metamask-extension#41558
- Refreshed onto `main` after #28865 merged

## **Manual testing steps**

```gherkin
Feature: preserve MYX publish safety during mobile-to-core sync

  Scenario: validate the sync guard on a clean Core checkout
    Given mobile is on this branch and Core is checked out locally
    When I run `bash scripts/perps/validate-core-sync.sh --core-path <core-path> --skip-test`
    Then the copied-source validation reaches the publish-artifact gate
    And the run fails if the built Core artifact does not preserve the MYX webpackIgnore safeguard

  Scenario: validate the perps historical candle transport coverage that is already present on main
    When I run `yarn jest app/controllers/perps/services/HyperLiquidClientService.test.ts --no-coverage`
    Then the TAT-2954 historical candle HTTP transport coverage passes
```

## **Screenshots/Recordings**

### **Before**

N/A - controller/source-sync change only.

### **After**

N/A - controller/source-sync change only.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

#### Performance checks (if applicable)

- [ ] I've tested on Android
- [ ] I've tested with a power user scenario
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics

## **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.
runway-github Bot added a commit to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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 to MetaMask/metamask-extension 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>
chloeYue pushed a commit to MetaMask/metamask-extension that referenced this pull request Apr 20, 2026
#41914)

- fix(perps): update perps controller 3.1.1 cp-13.28.0 (#41558)

## **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>
[97ee416](97ee416)

[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
[TAT-2699]:
https://consensyssoftware.atlassian.net/browse/TAT-2699?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: abretonc7s <107169956+abretonc7s@users.noreply.github.com>
Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
Co-authored-by: Arthur Breton <arthur.breton@consensys.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants