Skip to content

feat(perps): sync mobile perps code to core#8291

Merged
abretonc7s merged 3 commits intomainfrom
feat/perps/sync-controller
Mar 25, 2026
Merged

feat(perps): sync mobile perps code to core#8291
abretonc7s merged 3 commits intomainfrom
feat/perps/sync-controller

Conversation

@abretonc7s
Copy link
Contributor

@abretonc7s abretonc7s commented Mar 25, 2026

Explanation

Mobile (feat/perps/core-resolver, PR MetaMask/metamask-mobile#27899) is the source of truth for perps code. The last sync to core was Feb 26 — 27 days stale. Since then, 4 commits went directly to core (#7941, #8197, #8214, #8234), all of which have been backported into the mobile branch.

This PR syncs the latest mobile perps code to core using validate-core-sync.sh. Key changes:

  • Geolocation dependency: Added @metamask/geolocation-controller as a devDependency + tsconfig reference — messenger.ts now imports GeolocationControllerGetGeolocationAction for eligibility geolocation checks.
  • New files: MYXWalletService.ts (MYX wallet integration) and PerpsController-method-action-types.ts (typed action map).
  • Package exclusion: Added !dist/services/MYXWalletService* to files in package.json to keep MYX code out of published package.
  • MYX provider: Enhanced error handling (tightened to error.code check), wallet service integration, expanded config constants.
  • HyperLiquid provider: Subscription reliability improvements, order book processing, expanded event names.
  • Eligibility service: Refactored for geolocation-based region blocking via GeolocationController messenger action.
  • ESLint: 3 suppressions (1 no-restricted-globals for require() in MYX dynamic load, 2 @typescript-eslint/no-base-to-string in myxAdapter).

Supersedes stale PR #8207 (feat/perps/newsync, 139 commits behind main).

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Touches core Perps controller/provider logic (provider init, caching, eligibility geo-checks) and adds MYX wallet/authenticated reads, which could affect data freshness and provider availability across networks.

Overview
Syncs Perps code from mobile into core, including new MYX wallet/auth plumbing and broader provider/config updates.

PerpsController now (a) defers messenger handler registration until init(), (b) resolves MYX enablement via credentials/flags and dynamically imports/registers MYX with explicit auth config resolution, and (c) replaces single cached preload fields with per-provider/per-network market+user caches (with reinit guards and preload retriggering).

Adds geolocation-based eligibility checking via GeolocationController:getGeolocation, expands analytics/event constants, and refactors exports to explicit named exports. HyperLiquid reliability is improved with better multi-DEX failure handling, asset-id repair/backfill, stale market-data fallback, configurable builder addresses, and a new fetchHistoricalCandles; MYX config/endpoints are updated and MYXProvider gains authenticated read support (positions/orders/fills/funding/history) plus candle subscription (REST + WS updates).

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

Syncs perps-controller from mobile branch feat/perps/core-resolver
(68a90b5) to core. Key changes:

- Add geolocation-controller dependency for eligibility checks
- Add MYXWalletService and PerpsController-method-action-types
- Exclude MYXWalletService from published package files
- MYX provider: enhanced error handling, wallet service integration
- HyperLiquid provider: subscription reliability, order book processing
- Eligibility service: geolocation-based region blocking

30 files changed, 3 ESLint suppressions.
Synced from mobile eea8376b35. require() defeats webpack code splitting;
import() enables true tree-shaking so MYX is excluded from the extension
bundle when not enabled. Removes stale no-restricted-globals suppression.
@abretonc7s abretonc7s force-pushed the feat/perps/sync-controller branch from 41060c4 to 269b88d Compare March 25, 2026 08:14
Copy link

@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.

- Add missing trailing newline to eslint-suppressions.json (Prettier)
- Add PR #8291 links to all changelog entries (changelog validator)
@abretonc7s abretonc7s enabled auto-merge March 25, 2026 10:30
@abretonc7s abretonc7s added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit a588ad2 Mar 25, 2026
326 checks passed
@abretonc7s abretonc7s deleted the feat/perps/sync-controller branch March 25, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants