feat(perps): sync controller from mobile#8460
Merged
abretonc7s merged 1 commit intomainfrom Apr 15, 2026
Merged
Conversation
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit c33111b658fb9f5689ee75317c5c1a19a9141dce. Configure here.
de01135 to
5941237
Compare
Syncs app/controllers/perps/ from mobile commit 87ad5e48. Changes: - Disk-backed cold-start cache for instant data display on launch (perpsDiskPersistence.ts) - Export perps decimal formatters to controller (perpsFormatters.ts) - Fix TP/SL orders disappearing after creating a market order (isPositionTpsl filter) - Avoid full WS reconnection on foreground return when socket still alive - Enforce geo-block and compliance gate on Market Insights actions - Fix missing latest funding payments via paginated fetch with auto-split - Add funding rate display config constants - Extract buildProviderCacheKey/getProviderNetworkKey helpers - Add skipTTL option to cache read methods for disk-hydrated data - Add diskCache mock to test fixtures - Update CHANGELOG.md
5941237 to
b36f510
Compare
michalconsensys
approved these changes
Apr 15, 2026
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
Author
|
@metamaskbot publish-previews |
This was referenced Apr 15, 2026
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 15, 2026
## Explanation This restores the `myxModulePath` workaround for the `MYXProvider` dynamic import in `@metamask/perps-controller` so the built package preserves `webpackIgnore` and consumers do not statically resolve the intentionally-unpublished MYX provider files. This is the narrow publish fix that matches mobile source-of-truth follow-up `MetaMask/metamask-mobile#28871` and unblocks a corrected controller publication for the extension decimal-format adoption in `MetaMask/metamask-extension#41558`. ## References - Related to #8424 - Related to #8460 - Related to MetaMask/metamask-mobile#28871 - Related to MetaMask/metamask-extension#41558 ## 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 - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches HyperLiquid market discovery caching and WebSocket subscription teardown logic, which can affect market availability and live data stability. Also adjusts the MYX dynamic import path handling to influence bundling behavior in downstream consumers. > > **Overview** > Restores the MYX provider dynamic import workaround by moving the module path into a variable so built dist output preserves the `/* webpackIgnore: true */` comment and extension consumers don’t statically resolve the unpublished MYX module. > > Refactors HyperLiquid DEX discovery into a new unified `DexDiscoveryCacheManager` (with a `DexDiscoveryState` type) and updates call sites to use the shared state for raw/validated DEX lists and TTL behavior, reducing cache desync and avoiding rapid market-switching 429s. > > Switches HyperLiquid candle snapshots to use an HTTP `InfoClient` transport, and updates subscription teardown to explicitly `unsubscribe()` all active subscriptions during `clearAll` to prevent orphaned-unsubscribe `SOCKET_NOT_CONNECTED` errors during disconnect. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3430560. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
github-merge-queue Bot
pushed a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Apr 16, 2026
## **Description** This restores the `myxModulePath` workaround in mobile `PerpsController` so the mobile source of truth matches the safe Core pattern from `core#8424`, and it hardens `scripts/perps/validate-core-sync.sh` plus the `perps-core-sync` skill so future syncs fail if the built Core publish artifact loses the `webpackIgnore` safeguard again. This branch has been refreshed onto a `main` that already includes #28865, so no separate follow-up is still pending for the historical candle transport fix. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: - Related to MetaMask/core#8424 - Related to MetaMask/core#8460 - Related to MetaMask/core#8473 - Related to MetaMask/metamask-extension#41558 - Refreshed onto `main` after #28865 merged ## **Manual testing steps** ```gherkin Feature: preserve MYX publish safety during mobile-to-core sync Scenario: validate the sync guard on a clean Core checkout Given mobile is on this branch and Core is checked out locally When I run `bash scripts/perps/validate-core-sync.sh --core-path <core-path> --skip-test` Then the copied-source validation reaches the publish-artifact gate And the run fails if the built Core artifact does not preserve the MYX webpackIgnore safeguard Scenario: validate the perps historical candle transport coverage that is already present on main When I run `yarn jest app/controllers/perps/services/HyperLiquidClientService.test.ts --no-coverage` Then the TAT-2954 historical candle HTTP transport coverage passes ``` ## **Screenshots/Recordings** ### **Before** N/A - controller/source-sync change only. ### **After** N/A - controller/source-sync change only. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [ ] I've tested on Android - [ ] I've tested with a power user scenario - [ ] I've instrumented key operations with Sentry traces for production performance metrics ## **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.
vinnyhoward
pushed a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Apr 17, 2026
## **Description** This restores the `myxModulePath` workaround in mobile `PerpsController` so the mobile source of truth matches the safe Core pattern from `core#8424`, and it hardens `scripts/perps/validate-core-sync.sh` plus the `perps-core-sync` skill so future syncs fail if the built Core publish artifact loses the `webpackIgnore` safeguard again. This branch has been refreshed onto a `main` that already includes #28865, so no separate follow-up is still pending for the historical candle transport fix. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: - Related to MetaMask/core#8424 - Related to MetaMask/core#8460 - Related to MetaMask/core#8473 - Related to MetaMask/metamask-extension#41558 - Refreshed onto `main` after #28865 merged ## **Manual testing steps** ```gherkin Feature: preserve MYX publish safety during mobile-to-core sync Scenario: validate the sync guard on a clean Core checkout Given mobile is on this branch and Core is checked out locally When I run `bash scripts/perps/validate-core-sync.sh --core-path <core-path> --skip-test` Then the copied-source validation reaches the publish-artifact gate And the run fails if the built Core artifact does not preserve the MYX webpackIgnore safeguard Scenario: validate the perps historical candle transport coverage that is already present on main When I run `yarn jest app/controllers/perps/services/HyperLiquidClientService.test.ts --no-coverage` Then the TAT-2954 historical candle HTTP transport coverage passes ``` ## **Screenshots/Recordings** ### **Before** N/A - controller/source-sync change only. ### **After** N/A - controller/source-sync change only. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [ ] I've tested on Android - [ ] I've tested with a power user scenario - [ ] I've instrumented key operations with Sentry traces for production performance metrics ## **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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
Syncs
app/controllers/perps/from MetaMask Mobile (commit87ad5e48) topackages/perps-controller/src/using the automatedvalidate-core-sync.shpipeline. All 9 sync steps passed with 0 suppressions.Key changes:
perpsDiskPersistence.tsenables instant data display on launch by hydrating in-memory caches from MMKV synchronously at construction time. AddsskipTTLoption togetCachedMarketDataForActiveProviderandgetCachedUserDataForActiveProviderso disk-hydrated data is returned regardless of age on first render.perpsFormatters.tsexports shared formatting utilities (price, size, leverage, PnL, funding rate) from the controller for use by extension consumers.isPositionTpslto prevent position-bound orders from disappearing after creating a market order. Distinguishes position TP/SL from normalTpsl children on pending limit orders.ForegroundPingRetryDelayMsconstant.fetchWindowWithAutoSplitthat recursively splits windows hitting the API cap, ensuring complete results. Deduplicates at chunk boundaries.FUNDING_RATE_CONFIGconstants for display formatting.buildProviderCacheKeyandgetProviderNetworkKeyhelpers. Replaces private#marketCacheKey/#providerIsTestnetwith shared utilities. Adds#getAggregatedCacheProviderIdsto recover disk-hydrated provider snapshots beforeinit()finishes.ts-bridgecompatibility.New files:
packages/perps-controller/src/utils/perpsDiskPersistence.ts(360 lines)packages/perps-controller/src/utils/perpsFormatters.ts(624 lines)References
Checklist
Note
Medium Risk
Touches core
PerpsControllercaching/preload behavior (including new disk persistence and cache-key refactors) plus funding history fetching logic; regressions could impact cold-start UI correctness or data freshness across networks/accounts.Overview
Adds a disk-backed cold-start cache for perps market/user data.
PerpsControllernow hydrates in-memory caches synchronously at construction, persists preload snapshots back to disk, and clears disk user data on account changes; cache reads gain an optionalskipTTLto allow first-render usage of disk-hydrated data.Refactors cache keying and aggregated cache reads. Introduces
buildProviderCacheKey/getProviderNetworkKeyhelpers and updates aggregated reads to include provider ids inferred from disk-hydrated keys beforeinit()completes.Fixes and shared utilities. TP/SL lookup now filters by
isPositionTpslto avoid hiding position-bound TP/SL orders, funding history fetching switches to paginated windowed requests with recursive auto-splitting/deduping to avoid API caps, and newperpsFormatters/FUNDING_RATE_CONFIGare exported for consistent formatting.Reviewed by Cursor Bugbot for commit b36f510. Bugbot is set up for automated code reviews on this repo. Configure here.