feat: integrate Hyperliquid builder fee wallet address overrides#41356
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, +0 -116)
🕵️ @MetaMask/extension-privacy-reviewers (1 files, +4 -7)
👨🔧 @MetaMask/perps (2 files, +9 -1)
📜 @MetaMask/policy-reviewers (8 files, +4 -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, +4 -7)
👨🔧 @itsyoboieltr (2 files, +0 -116)
|
…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
Builds ready [baf2508]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9e62ec0]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [1bd6495]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [4929c28]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [45ecbb1]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…state keys - Remove platform-specific `resolver-binding-darwin-arm64` from LavaMoat build-system policy (CI runs on linux-x64) - Add `lastCompletedWithdrawalTimestamp` and `lastCompletedWithdrawalTxHashes` to state-logs.json (new fields in perps-controller v3.0.0)
Builds ready [0195659]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
aganglada
left a comment
There was a problem hiding this comment.
LGTM, have we set the new env variables
The builder override wiring now only includes clientConfig.providerCredentials.hyperliquid when at least one MM_PERPS_HL_BUILDER_ADDRESS_* env var is configured. This keeps the extension-side contract tighter and avoids passing an explicit undefined override into the perps-controller initialization path when package defaults should be used. Constraint: Keep the PR scoped to builder-address override wiring Rejected: Leave an explicit hyperliquid: undefined override in place | unnecessary config noise at the controller boundary Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep extension-side builder overrides absent when unset so package defaults remain the only source of truth Tested: yarn lint:changed:fix; clean-worktree yarn lint after lint:images:fix; yarn verify-locales --quiet; yarn circular-deps:check; jest app/scripts/messenger-client-init/perps-controller-init.test.ts; jest ui/selectors/perps-controller.test.ts Not-tested: Current checkout-wide yarn lint without a clean worktree because unrelated local .omc/.omx formatting files interfere
Builds ready [4b3a126]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Lock the already-landed review fixes with regression coverage for builder override normalization and provider-default cached selector lookups. Constraint: Full yarn lint currently fails on unrelated repo-wide exhaustive-deps warnings outside this PR Rejected: Expanding this pass into unrelated production code cleanup | would broaden the PR beyond the review scope Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep builder override handling undefined when env vars are absent or whitespace-only so package defaults continue to apply Tested: yarn lint:changed:fix; yarn verify-locales --quiet; yarn circular-deps:check; yarn jest app/scripts/messenger-client-init/perps-controller-init.test.ts --no-coverage; yarn jest ui/selectors/perps-controller.test.ts --no-coverage Not-tested: yarn lint (blocked by pre-existing repo-wide exhaustive-deps warnings in unrelated files)
Builds ready [b0b9249]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Public on-chain address, not a secret — no CI secrets/vars needed.
|
Builds ready [f951f20]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
mcmire
left a comment
There was a problem hiding this comment.
Looks good from a privacy reviewers perspective.
| "fetch": true, | ||
| "performance.now": true, | ||
| "process": true, | ||
| "process.env.NODE_ENV": true, |
There was a problem hiding this comment.
This is probably fine for now, but in controllers we generally try not to rely on environment variables. We should consider passing in the name of the environment to wherever it is needed.
At the very least the scope of the new version seems to be smaller, so that's good.



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 stable v3.0.0, which properly excludes MYX SDK from the package (no preview build or webpack workarounds needed).Mirrors the mobile implementation from PR #27899.
Why the extra changes (v3.0.0 upgrade consequences)
The v3.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:yarn lavamoat:auto. v3.0.0 cleanly excludes MYX SDK from the dependency graph, keeping the policy diff minimal. The browserify policy churn (~500 lines per file) is from merges with main (trezor adapter, tempo transactions, etc.), not from perps-controller changes.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) — state snapshot tests compare actual controller state against JSON fixtures, so they had to be updated to the v2+ shape. New v3.0.0 fields:lastCompletedWithdrawalTimestamp,lastCompletedWithdrawalTxHashes.perps-controller-init.test.ts) —getDefaultPerpsControllerStatemock updated to match v2+ shape for consistency with the rest of the migration.@metamask/perps-controller@3.0.0is now a stable release on npm. The previous@metamask-previewsresolution and webpackIgnorePluginworkaround for MYX are no longer needed.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
Upgrades
@metamask/perps-controllerto v3 and adjusts state/selectors/tests accordingly, which can subtly affect perps data rendering and caching. Env-driven config changes are straightforward but could alter fee routing if misconfigured.Overview
Adds support for overriding Hyperliquid builder fee wallet addresses via
MM_PERPS_HL_BUILDER_ADDRESS_MAINNET/MM_PERPS_HL_BUILDER_ADDRESS_TESTNET, wiring them intoPerpsControllerInitasclientConfig.providerCredentials.hyperliquid(with trimming and “unset means use package defaults” behavior).Upgrades
@metamask/perps-controllerto^3.0.0and updates extension integration points to match the new state shape, including provider-keyed cache selectors (cachedMarketDataByProvider/cachedUserDataByProvider) and refreshed unit/e2e fixtures (plus new withdrawal tracking fields).Removes the temporary webpack warning suppression and its accompanying test for missing
MYXProvider.mjs, updates LavaMoat policies for the new dependency graph, and hardens a perps transaction transform to tolerate missing fundingratevalues.Reviewed by Cursor Bugbot for commit f951f20. Bugbot is set up for automated code reviews on this repo. Configure here.