Skip to content

fix(perps): leverage not displayed in position details#41535

Merged
abretonc7s merged 7 commits intomainfrom
fix/tat-2796-leverage-display
Apr 10, 2026
Merged

fix(perps): leverage not displayed in position details#41535
abretonc7s merged 7 commits intomainfrom
fix/tat-2796-leverage-display

Conversation

@abretonc7s
Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s commented Apr 8, 2026

Description

Fix TAT-2796 — leverage was not visible on the perps position details page despite being available on the position object.

This PR replaces #41469, which was opened against the wrong base branch (fix/metamask-metamask-extension-41350) due to a corrupted local origin/HEAD symbolic-ref. That made it diff 968 files even though only 4 files were actually changed. Recreating cleanly here against main.

The fix has two commits:

  1. Add the leverage row to PerpsMarketDetailPage's Details Section, plus a perpsInjectPositions test hook on window.stateHooks (gated by METAMASK_DEBUG/IN_TEST) for recipe-based E2E validation.
  2. Combine direction + leverage into a single row to match the mobile PerpsPositionCard pattern ("Long 3x" / "Short 3x" instead of two separate rows).

Changelog

CHANGELOG entry: null

Fixed

  • Leverage now displays on the perps position details page, combined with direction as "Long Nx" / "Short Nx" matching mobile UX

Added

  • window.stateHooks.perpsInjectPositions debug-only test hook for E2E recipe validation

Related issues

Fixes: TAT-2796

Manual testing steps

  1. Open the extension on a perps-enabled testnet account with at least one open position
  2. Navigate to the position details page for any open position
  3. Confirm the Details Section shows a row reading "Long Nx" or "Short Nx" (where N is the position's leverage value, e.g. "Long 3x")
  4. Confirm the row has data-testid="perps-position-leverage" for automation

Screenshots/Recordings

Evidence available in task artifacts — will be added by reviewer if needed.

Pre-merge author checklist

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.

Note

Low Risk
Low risk UI-only change that appends position.leverage.value to the Direction row; main risk is formatting/undefined leverage causing incorrect display.

Overview
Fixes perps position Details to display leverage alongside direction as Long/Short Nx, and adds data-testid="perps-position-leverage" for automation.

Adds a unit test asserting the leverage label renders (e.g., Long 3x) in PerpsMarketDetailPage.

Reviewed by Cursor Bugbot for commit 0765400. Bugbot is set up for automated code reviews on this repo. Configure here.

Add leverage row to the Details Section of PerpsMarketDetailPage.
The row was missing despite leverage data being available on the
Position object. Uses existing perpsLeverage i18n key and
position.leverage.value with data-testid for recipe validation.

Also adds perpsInjectPositions test hook to window.stateHooks
(gated by METAMASK_DEBUG/IN_TEST) for recipe-based E2E validation.
Matches mobile PerpsPositionCard pattern — "Long 3x" / "Short 3x" on
one row instead of separate Direction and Leverage rows.

Moves data-testid="perps-position-leverage" to the direction value text.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

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.

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 Bot commented Apr 8, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/perps (2 files, +17 -1)
  • 📁 ui/
    • 📁 pages/
      • 📁 perps/
        • 📄 perps-market-detail-page.test.tsx +14 -0
        • 📄 perps-market-detail-page.tsx +3 -1

@github-actions github-actions Bot added the size-M label Apr 8, 2026
@abretonc7s abretonc7s marked this pull request as ready for review April 10, 2026 02:43
@abretonc7s abretonc7s requested a review from a team as a code owner April 10, 2026 02:43
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

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

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 2c89a39. Configure here.

Comment thread ui/pages/perps/perps-market-detail-page.test.tsx Outdated
@abretonc7s
Copy link
Copy Markdown
Contributor Author

Field Value
Run 3181689d
Duration
Model sonnet
Nudges 0
Grade ungraded
Cost $1.1935
Worker report

No report available.

Comment thread test/e2e/playwright/llm-workflow/launcher/state-inspector.js Outdated
Comment thread ui/index.js Outdated
Remove state-inspector.js and perpsInjectPositions hook that were
accidentally included. These are test infrastructure changes unrelated
to the leverage display fix.
…-display

# Conflicts:
#	ui/pages/perps/perps-market-detail-page.test.tsx
…etamask-extension into fix/tat-2796-leverage-display
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 Bot commented Apr 10, 2026

Builds ready [52b21e2]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): f34f804 | Date: 9/10/58222 | Pipeline: 24236213540 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-browserify
loadNewAccount
🟡 load_new_account
[Show logs]
confirmTx🟡 [Show logs]
bridgeUserActions🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: +19%
  • loadNewAccount/total: +19%
  • bridgeUserActions/bridge_load_asset_picker: -42%
  • bridgeUserActions/bridge_search_token: -25%
  • bridgeUserActions/total: -23%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 2.5s
  • 🟡 confirmTx/FCP: p75 2.4s
  • 🟡 bridgeUserActions/FCP: p75 2.5s
Startup Benchmarks · Samples: 100
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -14%
  • startupStandardHome/load: -16%
  • startupStandardHome/domContentLoaded: -18%
  • startupStandardHome/firstReactRender: -13%
  • startupStandardHome/initialActions: -38%
  • startupStandardHome/loadScripts: -21%
  • startupStandardHome/numNetworkReqs: -18%
  • startupPowerUserHome/domInteractive: -15%
  • startupPowerUserHome/backgroundConnect: +120%
  • startupPowerUserHome/numNetworkReqs: -48%
  • startupStandardHome/uiStartup: -13%
  • startupStandardHome/load: -12%
  • startupStandardHome/domContentLoaded: -12%
  • startupStandardHome/backgroundConnect: -30%
  • startupStandardHome/firstReactRender: -24%
  • startupStandardHome/loadScripts: -12%
  • startupStandardHome/setupStore: -14%
  • startupStandardHome/numNetworkReqs: -29%
  • startupPowerUserHome/domInteractive: -24%
  • startupPowerUserHome/numNetworkReqs: +42%
  • startupStandardHome/domInteractive: -59%
  • startupStandardHome/initialActions: -38%
  • startupStandardHome/numNetworkReqs: -16%
  • startupPowerUserHome/backgroundConnect: -20%
  • startupPowerUserHome/setupStore: +51%
  • startupStandardHome/domInteractive: -32%
  • startupStandardHome/backgroundConnect: -12%
  • startupStandardHome/initialActions: -44%
  • startupStandardHome/setupStore: -60%
  • startupStandardHome/numNetworkReqs: -18%
  • startupPowerUserHome/backgroundConnect: -37%
  • startupPowerUserHome/setupStore: -25%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🔴 startupPowerUserHome/INP: p75 720ms
  • 🔴 startupPowerUserHome/INP: p75 672ms
  • 🟡 startupPowerUserHome/LCP: p75 3.9s
  • 🟡 startupPowerUserHome/LCP: p75 3.7s
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟡 [Show logs]
solanaAssetDetails🟡 [Show logs]
importSrpHome🟡 [Show logs]
sendTransactions🟡 [Show logs]
swap🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: -87%
  • onboardingImportWallet/confirmSrpToPwForm: -22%
  • onboardingImportWallet/pwFormToMetricsScreen: -25%
  • onboardingImportWallet/metricsToWalletReadyScreen: -47%
  • onboardingImportWallet/doneButtonToHomeScreen: -80%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +21%
  • onboardingImportWallet/total: -47%
  • onboardingNewWallet/srpButtonToPwForm: -77%
  • onboardingNewWallet/skipBackupToMetricsScreen: -68%
  • onboardingNewWallet/doneButtonToAssetList: -27%
  • onboardingNewWallet/total: -28%
  • assetDetails/assetClickToPriceChart: -43%
  • assetDetails/total: -43%
  • solanaAssetDetails/assetClickToPriceChart: -70%
  • solanaAssetDetails/total: -70%
  • importSrpHome/openAccountMenuAfterLogin: -65%
  • importSrpHome/homeAfterImportWithNewWallet: -69%
  • importSrpHome/total: -60%
  • sendTransactions/selectTokenToSendFormLoaded: -26%
  • sendTransactions/reviewTransactionToConfirmationPage: +34%
  • sendTransactions/total: +31%
  • swap/openSwapPageFromHome: -96%
  • swap/fetchAndDisplaySwapQuotes: +31%
  • swap/total: +11%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/INP: p75 224ms
  • 🟡 assetDetails/FCP: p75 2.5s
  • 🟡 solanaAssetDetails/FCP: p75 2.5s
  • 🟡 importSrpHome/INP: p75 224ms
  • 🟡 importSrpHome/FCP: p75 2.6s
  • 🟡 sendTransactions/INP: p75 232ms
  • 🟡 sendTransactions/FCP: p75 2.5s
  • 🟡 swap/FCP: p75 2.5s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-browserify
dappPageLoad🟢 [Show logs]
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 71 Bytes (0%)
  • common: 20 Bytes (0%)

@abretonc7s
Copy link
Copy Markdown
Contributor Author

Automated pr-complete run — #41535

Metric Value
Run 9d14c0e9
Duration ?
Model claude/sonnet
Nudges 0
Cost estimate $10.53

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 Bot commented Apr 10, 2026

Builds ready [0765400]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): 71bd826 | Date: 10/14/58243 | Pipeline: 24245893685 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-browserify
loadNewAccount🟡 [Show logs]
confirmTx🟡 [Show logs]
bridgeUserActions🟡 [Show logs]

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 2.7s
  • 🟡 confirmTx/FCP: p75 2.5s
  • 🟡 bridgeUserActions/FCP: p75 2.5s
Startup Benchmarks · Samples: 100
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/load: -10%
  • startupStandardHome/domContentLoaded: -12%
  • startupStandardHome/domInteractive: +13%
  • startupStandardHome/backgroundConnect: +14%
  • startupStandardHome/firstReactRender: -10%
  • startupStandardHome/initialActions: -33%
  • startupStandardHome/loadScripts: -15%
  • startupStandardHome/numNetworkReqs: -11%
  • startupPowerUserHome/uiStartup: -15%
  • startupPowerUserHome/domInteractive: -10%
  • startupPowerUserHome/backgroundConnect: +58%
  • startupPowerUserHome/setupStore: +15%
  • startupPowerUserHome/numNetworkReqs: +18%
  • startupStandardHome/uiStartup: -10%
  • startupStandardHome/load: -12%
  • startupStandardHome/domContentLoaded: -11%
  • startupStandardHome/domInteractive: +13%
  • startupStandardHome/firstPaint: -12%
  • startupStandardHome/backgroundConnect: -27%
  • startupStandardHome/firstReactRender: -16%
  • startupStandardHome/loadScripts: -11%
  • startupStandardHome/numNetworkReqs: -29%
  • startupPowerUserHome/domInteractive: -15%
  • startupPowerUserHome/firstPaint: -15%
  • startupPowerUserHome/numNetworkReqs: +47%
  • startupStandardHome/domInteractive: -60%
  • startupStandardHome/initialActions: +33%
  • startupStandardHome/numNetworkReqs: -16%
  • startupPowerUserHome/backgroundConnect: -32%
  • startupStandardHome/domInteractive: -30%
  • startupStandardHome/backgroundConnect: -13%
  • startupStandardHome/initialActions: +14%
  • startupStandardHome/setupStore: -47%
  • startupStandardHome/numNetworkReqs: -11%
  • startupPowerUserHome/domInteractive: -13%
  • startupPowerUserHome/backgroundConnect: -13%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🔴 startupPowerUserHome/INP: p75 752ms
  • 🔴 startupPowerUserHome/INP: p75 688ms
  • 🟡 startupPowerUserHome/LCP: p75 3.6s
  • 🟡 startupPowerUserHome/LCP: p75 3.6s
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟡 [Show logs]
solanaAssetDetails🟡 [Show logs]
importSrpHome🟡 [Show logs]
sendTransactions🟡 [Show logs]
swap🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: -85%
  • onboardingImportWallet/metricsToWalletReadyScreen: -35%
  • onboardingImportWallet/doneButtonToHomeScreen: -77%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +26%
  • onboardingImportWallet/total: -43%
  • onboardingNewWallet/srpButtonToPwForm: -79%
  • onboardingNewWallet/skipBackupToMetricsScreen: -67%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: -22%
  • onboardingNewWallet/doneButtonToAssetList: -38%
  • onboardingNewWallet/total: -37%
  • assetDetails/assetClickToPriceChart: -21%
  • assetDetails/total: -21%
  • solanaAssetDetails/assetClickToPriceChart: -73%
  • solanaAssetDetails/total: -73%
  • importSrpHome/openAccountMenuAfterLogin: -69%
  • importSrpHome/homeAfterImportWithNewWallet: -71%
  • importSrpHome/total: -61%
  • sendTransactions/openSendPageFromHome: -30%
  • sendTransactions/selectTokenToSendFormLoaded: -31%
  • sendTransactions/reviewTransactionToConfirmationPage: +34%
  • sendTransactions/total: +31%
  • swap/openSwapPageFromHome: -97%
  • swap/fetchAndDisplaySwapQuotes: +32%
  • swap/total: +11%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/FCP: p75 2.5s
  • 🟡 solanaAssetDetails/FCP: p75 2.4s
  • 🟡 importSrpHome/INP: p75 224ms
  • 🟡 importSrpHome/FCP: p75 2.5s
  • 🟡 sendTransactions/INP: p75 224ms
  • 🟡 sendTransactions/FCP: p75 2.5s
  • 🟡 swap/FCP: p75 2.5s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-browserify
dappPageLoad🟢 [Show logs]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 2.7 KiB (0.04%)
  • ui: -6.73 KiB (-0.08%)
  • common: 253 Bytes (0%)

@abretonc7s abretonc7s added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit e11e1b1 Apr 10, 2026
210 of 212 checks passed
@abretonc7s abretonc7s deleted the fix/tat-2796-leverage-display branch April 10, 2026 14:55
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 10, 2026
@metamaskbot metamaskbot added the release-13.28.0 Issue or pull request that will be included in release 13.28.0 label Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

agentic release-13.28.0 Issue or pull request that will be included in release 13.28.0 size-S team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants