feat(perps): add decimal parity recipe coverage#28892
Conversation
Store the successful parity workflow on the branch so reviewers can rerun the same mobile screens that were used to compare extension formatting against mobile. Constraint: Review evidence needs a branch-local recipe path, not a temp file or prose-only instructions Rejected: Keep the recipe only under /tmp | reviewers cannot rerun the exact workflow from the PR branch Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep this recipe focused on review parity surfaces unless a broader mobile smoke suite explicitly adopts it Tested: validate-recipe.sh scripts/perps/agentic/teams/perps/recipes/mobile-decimal-parity.json --dry-run; live mobile recipe run 26/26 pass using equivalent content Not-tested: Additional mobile markets beyond ETH
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Extend the dedicated mobile recipe branch with a structured decimal matrix recipe that captures header price formatting across representative perps symbols spanning multiple decimal buckets. Constraint: Recipe work lives on its own branch so it can evolve independently from controller sync PRs Rejected: Keep only screenshot-only parity capture | less reusable for future formatting verification and weaker as a recipe architecture demo Confidence: medium Scope-risk: narrow Reversibility: clean Directive: Keep expanding this recipe with additional stable fields/screens rather than folding the work back into sync guard PRs Tested: validate-recipe.sh .../mobile-decimal-matrix.json --dry-run; live run on mm-1 (21/21 passed) Not-tested: Order-entry header extraction for SOL/FARTCOIN/PUMP remains omitted pending a stable direct-route setup
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - draft PR All E2E tests pre-selected. |
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 fd8b335. Configure here.
| "expression": "(function(){ function flat(v,out){ if(v===null||v===undefined)return; if(typeof v==='string'||typeof v==='number'){ var s=String(v).trim(); if(s) out.push(s); return; } if(Array.isArray(v)){ for(var i=0;i<v.length;i++) flat(v[i],out); return; } if(v&&v.props&&v.props.children!==undefined){ flat(v.props.children,out); } } function find(testId){ var hook=globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__; if(!hook||!hook.renderers||!hook.getFiberRoots)return null; var found=null; function walk(f){ if(!f||found)return; var p=f.memoizedProps; if(p&&p.testID===testId){ found=f; return; } walk(f.child); walk(f.sibling); } var it=hook.renderers.entries(); var step=it.next(); while(!step.done){ var roots=hook.getFiberRoots(step.value[0]); if(roots){ roots.forEach(function(r){ if(!found&&r.current) walk(r.current); }); } if(found) break; step=it.next(); } return found; } function collect(root){ var out=[]; function walk(f){ if(!f)return; var p=f.memoizedProps; if(p&&p.children!==undefined) flat(p.children,out); walk(f.child); walk(f.sibling); } walk(root); return out; } function firstMatch(arr,re){ for(var i=0;i<arr.length;i++){ if(re.test(arr[i])) return arr[i]; } return null; } var header=collect(find('perps-market-header')); return JSON.stringify({symbol:'SOL',screen:'market_detail',title:header[0]||null,price:firstMatch(header,/^\\$/),change:firstMatch(header,/%$/),header:header.slice(0,12)}); })()", | ||
| "save_as": "sol_market", | ||
| "assert": { "operator": "not_null", "field": "price" }, | ||
| "next": "fartcoin-nav-market" |
There was a problem hiding this comment.
SOL/FARTCOIN/PUMP missing order entry coverage in matrix
Medium Severity
The matrix recipe captures both market_detail and order_entry data for BTC and ETH (via *-open-order → *-wait-order → *-order-data nodes), but SOL, FARTCOIN, and PUMP skip directly from *-market-data to the next symbol's *-nav-market, omitting order entry entirely. The PR's manual testing scenario states the recipe "emits structured market-detail and order-entry values for representative symbols," implying all five symbols get both, creating a gap between documented and actual coverage.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit fd8b335. Configure here.
| }, | ||
| "btc-market-data": { | ||
| "action": "eval_sync", | ||
| "expression": "(function(){ function flat(v,out){ if(v===null||v===undefined)return; if(typeof v==='string'||typeof v==='number'){ var s=String(v).trim(); if(s) out.push(s); return; } if(Array.isArray(v)){ for(var i=0;i<v.length;i++) flat(v[i],out); return; } if(v&&v.props&&v.props.children!==undefined){ flat(v.props.children,out); } } function find(testId){ var hook=globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__; if(!hook||!hook.renderers||!hook.getFiberRoots)return null; var found=null; function walk(f){ if(!f||found)return; var p=f.memoizedProps; if(p&&p.testID===testId){ found=f; return; } walk(f.child); walk(f.sibling); } var it=hook.renderers.entries(); var step=it.next(); while(!step.done){ var roots=hook.getFiberRoots(step.value[0]); if(roots){ roots.forEach(function(r){ if(!found&&r.current) walk(r.current); }); } if(found) break; step=it.next(); } return found; } function collect(root){ var out=[]; function walk(f){ if(!f)return; var p=f.memoizedProps; if(p&&p.children!==undefined) flat(p.children,out); walk(f.child); walk(f.sibling); } walk(root); return out; } function firstMatch(arr,re){ for(var i=0;i<arr.length;i++){ if(re.test(arr[i])) return arr[i]; } return null; } var header=collect(find('perps-market-header')); return JSON.stringify({symbol:'BTC',screen:'market_detail',title:header[0]||null,price:firstMatch(header,/^\\$/),change:firstMatch(header,/%$/),header:header.slice(0,12)}); })()", |
There was a problem hiding this comment.
Massive duplicated eval expressions across seven nodes
Medium Severity
Seven eval_sync nodes contain nearly identical ~1000-character inline JavaScript expressions, varying only in the symbol string and the testId argument (perps-market-header vs perps-order-header). The framework already supports parameterized call + flow files and eval_ref for shared expressions, either of which would consolidate this into a single reusable definition and avoid inconsistent fixes if the extraction logic ever needs updating.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit fd8b335. Configure here.
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
## **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>
|
Superseded by #28992 (consolidated single recipe + testIDs + AgenticService scraping helpers). |





Description
This adds a dedicated perps decimal recipe branch so recipe/evidence work stays separate from controller sync work. It includes both the original mobile parity screenshot recipe and a new multi-symbol decimal matrix recipe that captures structured price output across representative perps markets.
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
N/A - recipe/tooling change.
After
Recipe paths:
scripts/perps/agentic/teams/perps/recipes/mobile-decimal-parity.jsonscripts/perps/agentic/teams/perps/recipes/mobile-decimal-matrix.jsonSymbol coverage in the matrix recipe:
Pre-merge author checklist
Performance checks (if applicable)
Pre-merge reviewer checklist
Note
Low Risk
Adds new JSON-based validation recipes only; no production app logic is modified, with risk limited to recipe flakiness or brittle UI selectors.
Overview
Adds new Perps agentic recipe coverage for mobile decimal/price validation.
Introduces
mobile-decimal-parity.json, a workflow that sets up a fixture account on testnet, walks through key ETH perps surfaces (home, market detail, order entry, adjust margin, close) and captures screenshots, with setup/teardown ensuring an ETH position is cleared.Introduces
mobile-decimal-matrix.json, a multi-symbol workflow that navigates through several markets (BTC/ETH/SOL/FARTCOIN/PUMP), captures structured header values from market detail and order entry viaeval_sync, and asserts extracted prices are non-null.Reviewed by Cursor Bugbot for commit fd8b335. Bugbot is set up for automated code reviews on this repo. Configure here.