Skip to content

feat: Install perps-controller v1, remove local mocked alias#40767

Merged
gambinish merged 8 commits intomainfrom
feat/integrate-perps-controller
Mar 11, 2026
Merged

feat: Install perps-controller v1, remove local mocked alias#40767
gambinish merged 8 commits intomainfrom
feat/integrate-perps-controller

Conversation

@gambinish
Copy link
Copy Markdown
Member

@gambinish gambinish commented Mar 10, 2026

Description

Installs perps-controller v1 package as a dependency, removes aliased local mock. Update import paths as necessary to satisfy lint configuartions related to local vs imported modules.

Broken out from feature branch for easier review: #40078

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Install perps-controller v1, remove local mocked alias

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

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

Medium Risk
Adds a new core dependency (@metamask/perps-controller) plus multiple ESM/transpilation and Yarn resolution changes, which can impact build/test bundling behavior. Risk is mainly around module resolution/compatibility rather than runtime logic changes.

Overview
This PR switches Perps UI integration from a locally-aliased mock @metamask/perps-controller to the real published @metamask/perps-controller@^1.0.0, updating TypeScript/Jest/webpack path mappings accordingly.

To support the controller’s ESM-heavy dependency tree, it expands the build transpilation allowlist (e.g., valibot, @nktkas/*, @myx-trade/*, lodash-es, wretch) and adds Yarn pinning/age-gate exceptions (including a temporary preapproval for @myx-trade/sdk). It also introduces MM_PERPS_BLOCKED_REGIONS as a build-time env var for a perps geoblock fallback.

Written by Cursor Bugbot for commit 59ddb67. This will update automatically on new commits. Configure here.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 10, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​perps-controller@​1.0.1721008392100
Addedws@​8.19.09810010086100
Updatedviem@​2.44.4 ⏵ 2.47.098 -1100100 +197100

View full report

@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 10, 2026

Caution

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Block High
Obfuscated code: npm @myx-trade/sdk is 98.0% likely obfuscated

Confidence: 0.98

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/@myx-trade/sdk@0.1.267

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@myx-trade/sdk@0.1.267. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
System shell access: npm @inquirer/external-editor in module child_process

Module: child_process

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/@inquirer/external-editor@2.0.3

ℹ Read more on: This package | This alert | What is shell access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should avoid accessing the shell which can reduce portability, and make it easier for malicious shell access to be introduced.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@inquirer/external-editor@2.0.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm @metamask/perps-controller in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: package.jsonnpm/@metamask/perps-controller@1.0.1

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@metamask/perps-controller@1.0.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm @nktkas/hyperliquid in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/@nktkas/hyperliquid@0.30.3

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@nktkas/hyperliquid@0.30.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm ethers in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/ethers@6.16.0

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ethers@6.16.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm ethers in module net

Module: net

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/ethers@6.16.0

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ethers@6.16.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm ethers in module http

Module: http

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/ethers@6.16.0

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ethers@6.16.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm ethers in module https

Module: https

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/ethers@6.16.0

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ethers@6.16.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm micro-eth-signer in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/micro-eth-signer@0.18.1

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/micro-eth-signer@0.18.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Network access: npm wretch in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: ?npm/@metamask/perps-controller@1.0.1npm/wretch@2.11.1

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/wretch@2.11.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Potential code anomaly (AI signal): npm ethers is 100.0% likely to have a medium risk anomaly

Notes: The analyzed code fragment appears to be a conventional ABI interface utility (likely from a library like ethers.js) used to parse, encode, and decode Ethereum function calls, events, and errors. There is no evidence of malicious behavior such as data exfiltration, remote control, or code injection. Minor anomalies (typo in an error message and a partially commented/unfinished block) are present but do not constitute malicious activity. Overall security risk from this fragment is low, assuming it is used as intended within a trusted library context.

Confidence: 1.00

Severity: 0.60

From: ?npm/@metamask/perps-controller@1.0.1npm/ethers@6.16.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ethers@6.16.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 10, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/extension-platform (1 files, +2 -0)
  • 📄 .yarnrc.yml +2 -0

🕵️ @MetaMask/extension-privacy-reviewers (1 files, +1 -1)
  • 📄 privacy-snapshot.json +1 -1

👨‍🔧 @MetaMask/perps (21 files, +44 -44)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 perps/
          • 📁 perps-candlestick-chart/
            • 📄 perps-candlestick-chart.tsx +1 -1
          • 📁 position-card/
            • 📄 position-card.test.tsx +1 -1
            • 📄 position-card.tsx +1 -1
          • 📁 utils/
            • 📄 transactionTransforms.test.ts +6 -6
            • 📄 transactionTransforms.ts +6 -6
            • 📄 mocks.ts +6 -6
    • 📁 hooks/
      • 📁 perps/
        • 📁 stream/
          • 📄 index.mock.ts +9 -9
          • 📄 usePerpsLiveAccount.ts +1 -1
          • 📄 usePerpsLiveCandles.ts +1 -1
          • 📄 usePerpsLiveFills.ts +1 -1
          • 📄 usePerpsLiveMarketData.ts +1 -1
          • 📄 usePerpsLiveOrderBook.ts +1 -1
          • 📄 usePerpsLiveOrders.ts +1 -1
          • 📄 usePerpsLivePositions.ts +1 -1
          • 📄 usePerpsLivePrices.ts +1 -1
          • 📄 usePerpsMarginCalculations.ts +1 -1
          • 📄 usePerpsOrderForm.ts +1 -1
          • 📄 usePerpsTransactionHistory.test.ts +1 -1
          • 📄 useUserHistory.test.ts +1 -1
          • 📄 useUserHistory.ts +1 -1
    • 📁 pages/
      • 📁 perps/
        • 📁 market-list/
          • 📄 index.tsx +1 -1

aganglada
aganglada previously approved these changes Mar 10, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 10, 2026

Builds ready [2278e59]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account28926034432307344
total28926034432307344
Confirm Txconfirm_tx6039600460662260536066
total6039600460662260536066
Bridge User Actionsbridge_load_page25121728623263286
bridge_load_asset_picker16614819419181194
bridge_search_token71470472710725727
total1130110411612211451161
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14891256193710815141694
load1229102416319512651390
domContentLoaded1222101616119412601382
domInteractive291898182681
firstPaint210751416226224373
backgroundConnect21719926813220245
firstReactRender2113144132133
initialActions1013213
loadScripts102181313849310631179
setupStore1575571827
numNetworkReqs362791192789
Power User HomeuiStartup61312365178602829681012564
load14291123219316114991747
domContentLoaded14091118217515714521714
domInteractive46223174640153
firstPaint236831813223283401
backgroundConnect247536714830257133556620
firstReactRender29205363338
initialActions105113
loadScripts1162919189114311851456
setupStore208282271932
numNetworkReqs1767135347200263
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212202211221221
srpButtonToSrpForm94929519495
confirmSrpToPwForm21212202122
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen16151711617
doneButtonToHomeScreen60258761512611615
openAccountMenuToAccountListLoaded290929072911129112911
total3872382538992638903899
Onboarding New WalletcreateWalletToSocialScreen2182172180218218
srpButtonToPwForm1091051133112113
createPwToRecoveryScreen889099
skipBackupToMetricsScreen35343503535
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList60149369287689692
total98987810898910751089
Asset DetailsassetClickToPriceChart1241191284128128
total1241191284128128
Solana Asset DetailsassetClickToPriceChart88829659096
total88829659096
Import Srp HomeloginToHomeScreen2298226423332422982333
openAccountMenuAfterLogin62576746567
homeAfterImportWithNewWallet2375235423881523882388
total4731458148279547954827
Send TransactionsopenSendPageFromHome26173563135
selectTokenToSendFormLoaded18181901819
reviewTransactionToConfirmationPage85584387914853879
total89788492718888927
SwapopenSwapPageFromHome27203352933
fetchAndDisplaySwapQuotes268626822692426902692
total271227112713127132713
🌐 Dapp Page Load Benchmarks

Current Commit: 2278e59 | Date: 3/10/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±41ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 726ms (±39ms) 🟢 | historical mean value: 736ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±14ms) 🟢 | historical mean value: 84ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 41ms 1.01s 1.35s 1.07s 1.35s
domContentLoaded 726ms 39ms 708ms 1.02s 747ms 1.02s
firstPaint 78ms 14ms 60ms 208ms 88ms 208ms
firstContentfulPaint 78ms 14ms 60ms 208ms 88ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 4.41 KiB (0.08%)
  • ui: -24.23 KiB (-0.28%)
  • common: 154 Bytes (0%)

@github-actions github-actions bot added size-M and removed size-S labels Mar 10, 2026
@gambinish gambinish marked this pull request as ready for review March 10, 2026 20:18
@gambinish gambinish requested review from a team as code owners March 10, 2026 20:18
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 10, 2026

Builds ready [f637c4f]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2732652826278282
total2732652826278282
Confirm Txconfirm_tx6007599660241060106024
total6007599660241060106024
Bridge User Actionsbridge_load_page2082002125209212
bridge_load_asset_picker23521724511238245
bridge_search_token7587427659765765
total120011891210812051210
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14701246205612715011673
load12171008165411112461411
domContentLoaded12111002163610912421386
domInteractive3118151232589
firstPaint166711230168199331
backgroundConnect21719631616222238
firstReactRender21134962233
initialActions107114
loadScripts1009812141110410371188
setupStore157148151725
numNetworkReqs362794192787
Power User HomeuiStartup59872228181183315681912222
load13161153171612413391598
domContentLoaded12971140169711813201584
domInteractive3521204263081
firstPaint211821305145268364
backgroundConnect237432514388272135017868
firstReactRender291810293139
initialActions105114
loadScripts1068917146411110921331
setupStore1664571931
numNetworkReqs1456728440159241
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2182172201219220
srpButtonToSrpForm95959509595
confirmSrpToPwForm22212202222
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen16151711717
doneButtonToHomeScreen68859182688722826
openAccountMenuToAccountListLoaded2928290329461529362946
total3984389341138040074113
Onboarding New WalletcreateWalletToSocialScreen2202192211219221
srpButtonToPwForm1091081101109110
createPwToRecoveryScreen888088
skipBackupToMetricsScreen35343503535
agreeButtonToOnboardingSuccess16151711617
doneButtonToAssetList51549453919537539
total91188196632928966
Asset DetailsassetClickToPriceChart1161091204119120
total1161091204119120
Solana Asset DetailsassetClickToPriceChart86809148891
total86809148891
Import Srp HomeloginToHomeScreen2241219223134422322313
openAccountMenuAfterLogin564375125775
homeAfterImportWithNewWallet24192259258813025572588
total46734607485810746194858
Send TransactionsopenSendPageFromHome22172742427
selectTokenToSendFormLoaded19192002020
reviewTransactionToConfirmationPage86084587613870876
total90188392316911923
SwapopenSwapPageFromHome24212732527
fetchAndDisplaySwapQuotes268626852686026862686
total2719270727431327232743
🌐 Dapp Page Load Benchmarks

Current Commit: f637c4f | Date: 3/10/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±41ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 731ms (±39ms) 🟢 | historical mean value: 736ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±10ms) 🟢 | historical mean value: 84ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 41ms 1.02s 1.35s 1.09s 1.35s
domContentLoaded 731ms 39ms 711ms 1.03s 772ms 1.03s
firstPaint 80ms 10ms 64ms 168ms 84ms 168ms
firstContentfulPaint 80ms 10ms 64ms 168ms 84ms 168ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 4.41 KiB (0.08%)
  • ui: -24.23 KiB (-0.28%)
  • common: 154 Bytes (0%)

@gambinish gambinish requested a review from aganglada March 10, 2026 20:47
@gambinish gambinish enabled auto-merge March 10, 2026 21:13
aganglada
aganglada previously approved these changes Mar 10, 2026
test: /\.mjs$/u,
include: /node_modules[\\/]@myx-trade[\\/]sdk/u,
resolve: {
fullySpecified: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Going to need an explanation for this :-) I recently removed the last of the code that needed to allow for broken JS like this.


But I'm also concerned with @myx-trade/sdk itself.

It only has unknown authors on npm, and before this perps integration, has very few weekly downloads. It has zero documentation and no README.MD, and no links back to its repo on npm.

It ships @types/ws as a regular dependency, and ships invalid mjs as well (if fullySpecified is actually required). Quality, absent of a reputation, might be questionable.

Its about as sketchy as can be, especially with the initial attempt at landing this being over 12000 lines of of changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did some digging myself, and it looks like their SDK imports from crypto-js, which is not even maintained anymore (and hasn't been for a while).

If the @myx-trade/sdk is required here, which I'm sure it is, perhaps we should patch @myx-trade/sdk to do things The Right Way, instead of bail out of strict parsing via fullySpecified: false here.

I can submit the patch for it to this PR if you're okay with that.

If not, this isn't the right way to do this. This build system uses swc via our npmLoader, which is about 10x faster than webpack's default, so we'd need to figure out how to get this block into the "vendor javascript" oneOf section below, and likely use the npmLoader for it.

Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s Mar 11, 2026

Choose a reason for hiding this comment

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

Thanks @davidmurdoch , I have mentioned it to MYX directly for urgent fix. Their product hasnt launched hence the limited usage and download but we have a signed partnership with them to implement their protocol. I previously flagged the package with security but we allowed as we are partnering with them to unblock the implementation.

Copy link
Copy Markdown
Member Author

@gambinish gambinish Mar 11, 2026

Choose a reason for hiding this comment

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

Will follow up with the team tomorrow morning, and we will align on the best path forward 👍

It sounds like patching it is probably the way to go for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MYX just shipped 0.1.267 which addresses this directly: crypto-js replaced with crypto-es (maintained ESM fork), @types/ws removed from runtime deps, and the MJS is now a single bundle with zero bare relative imports. Bumped the resolution and removed the fullySpecified: false workaround in this commit — should be clean now. Added a temporary npmPreapprovedPackages bypass (same pattern as serialize-javascript) to clear the 3-day age gate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

amazing! thank you!

test: /\.mjs$/u,
include: /node_modules[\\/]@myx-trade[\\/]sdk/u,
resolve: {
fullySpecified: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did some digging myself, and it looks like their SDK imports from crypto-js, which is not even maintained anymore (and hasn't been for a while).

If the @myx-trade/sdk is required here, which I'm sure it is, perhaps we should patch @myx-trade/sdk to do things The Right Way, instead of bail out of strict parsing via fullySpecified: false here.

I can submit the patch for it to this PR if you're okay with that.

If not, this isn't the right way to do this. This build system uses swc via our npmLoader, which is about 10x faster than webpack's default, so we'd need to figure out how to get this block into the "vendor javascript" oneOf section below, and likely use the npmLoader for it.

…rkaround

- Force resolution to @myx-trade/sdk@0.1.267 via package.json resolutions
- Remove fullySpecified: false webpack rule (no longer needed — 0.1.267 ships
  a single bundled MJS with no bare relative imports)
- Add @myx-trade/sdk to npmPreapprovedPackages to bypass 3-day age gate
  (temporary; remove once package is >3 days old)
- 0.1.267 replaces crypto-js with crypto-es (maintained ESM fork) and removes
  @types/ws from runtime deps

Addresses review feedback from @davidmurdoch on PR #40767
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

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.

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

'./**/node_modules/@nktkas',
'./**/node_modules/@noble/hashes',
'./**/node_modules/@noble/curves',
'./**/node_modules/@scure',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Broad ESM globs affect existing crypto library builds

Medium Severity

The glob patterns ./**/node_modules/@noble/hashes, ./**/node_modules/@noble/curves, and ./**/node_modules/@scure match ALL versions of these packages at any nesting depth, not just the v2 versions brought in by @nktkas/hyperliquid (a transitive dependency of @metamask/perps-controller). These packages (@noble/hashes@1.8.0, @noble/curves@1.x, @scure/bip32, @scure/bip39) are already used extensively throughout MetaMask for core crypto operations and were not previously in this ESM transform list. Applying ESM handling to all versions project-wide could subtly change how the existing v1 packages are bundled by browserify. Narrower patterns scoped to the perps dependency subtree (e.g., targeting only the v2 paths) would be safer.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fine. It may slow the build process down a bit though, however, it actually leads to more "technically correct" builds that properly target are supported browser range by "transpiling" modern JS features into polyfills. In an ideal world we would always do this (we do for webpack), but I believe (this was before my time) the reason we don't is that the build time performance hit was too much (and it hasn't been enough of an actual production problem enough us).

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 11, 2026

Builds ready [59ddb67]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account27226328810272288
total27226328810272288
Confirm Txconfirm_tx6015600160351260236035
total6015600160351260236035
Bridge User Actionsbridge_load_page2092012218211221
bridge_load_asset_picker19817324227216242
bridge_search_token72670276429760764
total1144107712477512231247
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup15041252186611115421678
load12451021163510012801398
domContentLoaded1238101916269812761380
domInteractive3118164222780
firstPaint177721343137224287
backgroundConnect22420028014230255
firstReactRender22144062336
initialActions2011224
loadScripts103082214089610681178
setupStore1474171626
numNetworkReqs362788182784
Power User HomeuiStartup5339207415135239059059668
load13711140371534613761747
domContentLoaded13501127370434313381646
domInteractive3421126193466
firstPaint2008847492273364
backgroundConnect228431912682224631906856
firstReactRender28184773143
initialActions108113
loadScripts1122902346333911031402
setupStore1764582038
numNetworkReqs2097839153222312
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202162284222228
srpButtonToSrpForm93919629496
confirmSrpToPwForm22212412324
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen16151811618
doneButtonToHomeScreen5955856057598605
openAccountMenuToAccountListLoaded2924290429391529352939
total389338873901638963901
Onboarding New WalletcreateWalletToSocialScreen2192182211219221
srpButtonToPwForm1091041143110114
createPwToRecoveryScreen989099
skipBackupToMetricsScreen36363703637
agreeButtonToOnboardingSuccess16161701617
doneButtonToAssetList5044955148507514
total89688591512898915
Asset DetailsassetClickToPriceChart1361341392139139
total1361341392139139
Solana Asset DetailsassetClickToPriceChart82719078490
total82719078490
Import Srp HomeloginToHomeScreen2249217523316622932331
openAccountMenuAfterLogin543966106466
homeAfterImportWithNewWallet2296224323986022782398
total47624504498017949304980
Send TransactionsopenSendPageFromHome28194083040
selectTokenToSendFormLoaded27193463434
reviewTransactionToConfirmationPage1211849147829414391478
total1280891157231815391572
SwapopenSwapPageFromHome29263222932
fetchAndDisplaySwapQuotes2714268827673127302767
total2749271528003127582800
🌐 Dapp Page Load Benchmarks

Current Commit: 59ddb67 | Date: 3/11/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±66ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 745ms (±64ms) 🟢 | historical mean value: 734ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±12ms) 🟢 | historical mean value: 85ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 66ms 1.02s 1.36s 1.28s 1.36s
domContentLoaded 745ms 64ms 712ms 1.02s 964ms 1.02s
firstPaint 81ms 12ms 68ms 188ms 96ms 188ms
firstContentfulPaint 81ms 12ms 68ms 188ms 96ms 188ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 4.41 KiB (0.08%)
  • ui: -9.69 KiB (-0.11%)
  • common: 724 Bytes (0.01%)

# Temporary bypass for serialize-javascript@7.0.3 CVE fix; remove once older than age gate.
- 'serialize-javascript'
# Temporary bypass for @myx-trade/sdk@0.1.267 — fixes ESM/crypto-js issues flagged in PR #40767; remove once >3 days old.
- '@myx-trade/sdk'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is not a change request. just an FYI!

I was recently informed that if you add the package to this list locally, run yarn install, then commit the package.json and yarn.lock files, you can then remove the package from this list and things will work.

@gambinish gambinish added this pull request to the merge queue Mar 11, 2026
Merged via the queue into main with commit 9198cdb Mar 11, 2026
183 of 184 checks passed
@gambinish gambinish deleted the feat/integrate-perps-controller branch March 11, 2026 15:42
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2026
@metamaskbot metamaskbot added the release-13.23.0 Issue or pull request that will be included in release 13.23.0 label Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.23.0 Issue or pull request that will be included in release 13.23.0 size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants