feat: integrate Hyperliquid builder fee wallet address overrides#41356
feat: integrate Hyperliquid builder fee wallet address overrides#41356abretonc7s wants to merge 31 commits intomainfrom
Conversation
Add MM_PERPS_HL_BUILDER_ADDRESS_MAINNET and MM_PERPS_HL_BUILDER_ADDRESS_TESTNET env vars so the extension can override the default builder fee wallet addresses from @metamask/perps-controller. Bump perps-controller to v2.0.0 which exposes the clientConfig.providerCredentials.hyperliquid override API.
|
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (2 files, +15 -113)
🕵️ @MetaMask/extension-privacy-reviewers (1 files, +2 -7)
👨🔧 @MetaMask/perps (2 files, +9 -1)
📜 @MetaMask/policy-reviewers (8 files, +644 -8)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (1 files, +2 -7)
👨🔧 @itsyoboieltr (2 files, +15 -113)
|
…rage Replace no-op tracer stubs with real Sentry delegation via globalThis.sentry (startSpanManual, setMeasurement, addBreadcrumb). Gracefully no-ops when Sentry is unavailable. Add 17 new tests covering logger, metrics, performance, tracer (with/without Sentry), and streamManager.
Move Sentry integration (pendingSpans, globalThis.sentry delegation, expanded test coverage) to a follow-up PR. Keep only the addBreadcrumb stub needed for perps-controller v2.0.0 type compatibility.
4c34c70
- Replace ignoreWarnings approach with IgnorePlugin to suppress the build error for the dynamic import() of MYXProvider.mjs in @metamask/perps-controller v2.0.0 dist. MYX is intentionally excluded; if its init path is triggered at runtime the error is expected. - Update webpack test: replace warning-based guard with IgnorePlugin presence check + file-existence guard (fails when package ships the file) - Fix selectPerpsCachedMarketData/Positions/Orders to use selectPerpsActiveProvider() so the 'hyperliquid' default is applied even when activeProvider is undefined in state - Fix selectPerpsCachedAccountState to read from cachedUserDataByProvider[provider].accountState (v2.0.0 state shape) - Update selector test for selectPerpsCachedAccountState accordingly
Builds ready [f53c300]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [a110405]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Main already handles the missing MYXProvider.mjs via ignoreWarnings. The IgnorePlugin was added in 7874d3a without realizing main had already shipped the simpler fix. Revert to match main's approach.
# Conflicts: # app/scripts/messenger-client-init/perps-controller-init.ts
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 4f17403. Configure here.
- webpack: IgnorePlugin is required for the missing MYXProvider.mjs dynamic import; ignoreWarnings alone only suppresses warnings, not the hard 'Module not found' error in perps-controller v2.0.0. - test: update getDefaultPerpsControllerState mock to v2 state shape (cachedMarketDataByProvider / cachedUserDataByProvider) to match the rest of the PR's v1->v2 migration.
…rkaround Core source uses /* webpackIgnore: true */ correctly but ts-bridge strips the magic comment during JS emit. Update the comment to reflect the actual root cause, not a missing-comment assumption.
|
Worker reportNo report available. |
Builds ready [60e6145]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|




Description
The
@metamask/perps-controllerpackage has hardcoded default builder wallet addresses. The extension needs its own builder fee wallet address (0xea2c82b5aba243ab631c0ce151763d5e38df75b3) different from the package defaults.This PR adds
MM_PERPS_HL_BUILDER_ADDRESS_MAINNETandMM_PERPS_HL_BUILDER_ADDRESS_TESTNETenv vars so the extension can override builder fee wallet addresses viaclientConfig.providerCredentials.hyperliquid. Bumps@metamask/perps-controllerto v2.0.0 which exposes this override API.Mirrors the mobile implementation from PR #27899.
Why the extra changes
The v2.0.0 bump of
@metamask/perps-controlleris a major upgrade and forces a few cascading changes in this PR. None of them are new features — they're all consequences of adopting the new package version:@myx-trade/sdk). Policies are auto-regenerated viayarn lavamoat:auto.IgnorePluginforMYXProvider.mjs— temporary workaround for a bug in the@metamask/perps-controllerpublish pipeline. The core source atpackages/perps-controller/src/PerpsController.ts:1698correctly uses/* webpackIgnore: true */on the dynamicMYXProviderimport, butts-bridgestrips the magic comment during JS emit, so the published dist ends up with a plainimport("./providers/MYXProvider.mjs")pointing at a file that's intentionally excluded fromfilesin the package. Webpack sees this as a hardModule not founderror (not a warning — soignoreWarningsalone is not enough).IgnorePluginwill be removed once core fixes its build to preserve the magic comment.ui/selectors/perps-controller.ts) — v2.0.0 replaces flat cache keys (cachedMarketData,cachedAccountState, etc.) with provider-keyed maps (cachedMarketDataByProvider,cachedUserDataByProvider). Selectors now read viaselectPerpsActiveProvider(state).errors-after-init-opt-in-ui-state.json,state-logs.json) — Sentry state snapshot tests compare actual controller state against JSON fixtures, so they had to be updated to the v2 shape.lastError: nullis preserved (still in the v2 state despiteusedInUi: false).perps-controller-init.test.ts) —getDefaultPerpsControllerStatemock updated to match v2 shape for consistency with the rest of the migration.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2397
Manual testing steps
PERPS_ENABLED=trueandMM_PERPS_HL_BUILDER_ADDRESS_MAINNET=0xea2c82b5aba243ab631c0ce151763d5e38df75b3in.metamaskrcyarn dist)clientConfig.providerCredentials.hyperliquidScreenshots/Recordings
N/A — configuration-only change, no UI impact.
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Bumps
@metamask/perps-controllerto a new major version and adjusts build/policy configuration, which can affect bundling and runtime behavior even though functional changes are mostly config/state-shape updates.Overview
Enables overriding Hyperliquid builder fee wallet addresses via new env vars (
MM_PERPS_HL_BUILDER_ADDRESS_MAINNET/TESTNET) and wires them into Perps initialization throughclientConfig.providerCredentials.hyperliquid.Upgrades
@metamask/perps-controllerto^2.0.0, updates Perps cached-state selectors/tests/snapshots to the new provider-keyed cache shape, and hardens a UI transform against missing fundingratevalues.Updates build/runtime plumbing for the new dependency set: adds a webpack
IgnorePluginworkaround for missingMYXProvider.mjs, regenerates LavaMoat policies (including new@myx-trade/sdkallowances), and adds a stubaddBreadcrumbto the Perps tracer interface.Reviewed by Cursor Bugbot for commit 60e6145. Bugbot is set up for automated code reviews on this repo. Configure here.