Skip to content

feat(perps): add MYX provider Stage 1 implementation#25773

Merged
abretonc7s merged 29 commits into
mainfrom
feat/perps/myx-poc1
Feb 10, 2026
Merged

feat(perps): add MYX provider Stage 1 implementation#25773
abretonc7s merged 29 commits into
mainfrom
feat/perps/myx-poc1

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Description

Add MYX protocol as a second perpetuals trading provider (Stage 1 - read-only). MYX is a decentralized perpetuals exchange on BNB Chain that complements the existing HyperLiquid integration, giving users access to MYX-exclusive markets.

Why?

  • Expand perps trading options beyond HyperLiquid
  • Access MYX-exclusive markets (tokens not available on HyperLiquid)
  • Build multi-provider infrastructure for perps trading

What's included (Stage 1 - Read-Only):

  • MYXProvider implementing the PerpsProvider interface (market data only)
  • MYXClientService wrapping @myx-trade/sdk (v0.1.265)
  • Type adapters (myxAdapter.ts) for MYX ↔ MetaMask data transformation
  • Provider selector UI (badge + bottom sheet) to switch between HyperLiquid and MYX
  • Feature flag perpsMYXProviderEnabled with graceful fallback
  • Refactored controllers to use object parameters for consistency

Stage 1 Limitations (by design):

  • Read-only: markets and prices only, no trading
  • REST polling for prices (WebSocket deferred to Stage 3)
  • Positions/orders return empty state (auth not implemented)

Changelog

CHANGELOG entry: null

Related issues

Part of MYX integration epic - Stage 1 implementation

Manual testing steps

Feature: MYX Provider Stage 1

  Scenario: User views MYX markets
    Given user has perps feature enabled
    And perpsMYXProviderEnabled feature flag is true

    When user navigates to Perps home screen
    Then user sees provider selector badge in header
    And user can tap badge to open provider selection sheet

  Scenario: User switches to MYX provider
    Given user is on Perps home screen with HyperLiquid selected

    When user taps provider badge
    And user selects "MYX" from the provider list
    Then provider switches to MYX
    And MYX markets are displayed
    And prices update via REST polling
    And positions/orders sections show empty state

  Scenario: MYX feature flag disabled
    Given perpsMYXProviderEnabled is false

    When user navigates to Perps home screen
    Then provider selector is not shown
    And HyperLiquid remains the only provider

Screenshots/Recordings

Before

N/A - New feature

After

Simulator.Screen.Recording.-.iPhone16Pro-Alpha.-.2026-02-06.at.21.46.47.mp4

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
Introduces a new perps provider and provider-switch reinitialization flow, which can impact initialization, caching, and navigation behavior even though MYX is read-only in this stage.

Overview
Adds Stage 1 read-only support for the MYX perps provider (markets + price polling) alongside HyperLiquid, including new MYXProvider, MYXClientService (wrapping @myx-trade/sdk), MYX config/constants, and MYX↔Perps adapters.

Introduces provider enablement and switching: a new hybrid feature flag (perpsMyxProviderEnabled with MM_PERPS_MYX_PROVIDER_ENABLED fallback) controls MYX registration; PerpsController.switchProvider now performs a guarded full re-init with rollback on failure, and init falls back to HyperLiquid if MYX is selected but disabled.

Updates the Perps UI/navigation to show a provider badge in the home header (flagged) that opens a new modal bottom sheet for provider selection, and hardens stream/caching behavior by invalidating/discarding market data when the active provider changes mid-fetch. Tests and mocks are added/updated (including a Jest mock for @myx-trade/sdk), and ledger update types are generalized to RawLedgerUpdate for provider-agnostic returns.

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

Add MYX as a perpetuals trading provider with the following:
- MYX SDK integration and provider implementation
- Provider selector modal for switching between perps providers
- Feature flag support for MYX provider
- Controller refactoring for object parameter consistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abretonc7s abretonc7s requested review from a team as code owners February 6, 2026 13:41
@github-actions

github-actions Bot commented Feb 6, 2026

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.

@metamaskbot metamaskbot added the team-perps Perps team label Feb 6, 2026
@socket-security

socket-security Bot commented Feb 6, 2026

Copy link
Copy Markdown

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​myx-trade/​sdk@​0.1.265801007698100
Addednpm/​@​ethersproject/​providers@​5.8.0981009581100
Updatednpm/​rxjs@​7.8.1 ⏵ 7.8.29910010084100

View full report

@socket-security

socket-security Bot commented Feb 6, 2026

Copy link
Copy Markdown

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 Medium
System shell access: npm @inquirer/external-editor in module child_process

Module: child_process

Location: Package overview

From: ?npm/@myx-trade/sdk@0.1.265npm/@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 wretch in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: ?npm/@myx-trade/sdk@0.1.265npm/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.

Ignoring alerts on:

  • npm/@myx-trade/sdk@0.1.265

View full report

@abretonc7s abretonc7s removed request for a team February 6, 2026 13:42
@abretonc7s abretonc7s added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Feb 6, 2026
Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
Comment thread app/components/UI/Perps/services/MYXClientService.ts
- Fix ping() timeout timer leak by clearing setTimeout in finally block
- Remove duplicate caching layer in MYXProvider (delegate to MYXClientService)
- Deduplicate MYX feature flag logic into resolvePerpsMyxProviderEnabled()
- Move PROVIDER_DISPLAY_INFO from types to constants file
- Remove unnecessary `as never` type assertions in navigation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread app/components/UI/Perps/utils/myxAdapter.ts Outdated
Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
Comment thread app/components/UI/Perps/providers/PerpsStreamManager.tsx Outdated
Comment thread app/components/UI/Perps/services/MYXClientService.ts Outdated
@abretonc7s

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/@myx-trade/sdk@0.1.265

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Comment thread app/components/UI/Perps/utils/myxAdapter.ts
Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
@abretonc7s abretonc7s enabled auto-merge February 9, 2026 13:50

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread app/components/UI/Perps/controllers/PerpsController.test.ts

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread app/components/UI/Perps/providers/PerpsStreamManager.tsx Outdated

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Comment thread app/components/UI/Perps/providers/PerpsStreamManager.tsx Outdated
Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
@sonarqubecloud

sonarqubecloud Bot commented Feb 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
76.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Comment thread app/components/UI/Perps/providers/PerpsStreamManager.tsx Outdated
Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread app/components/UI/Perps/providers/PerpsStreamManager.tsx Outdated

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Comment thread app/components/UI/Perps/controllers/providers/MYXProvider.ts
Comment thread app/components/UI/Perps/controllers/types/index.ts
Comment thread app/components/UI/Perps/controllers/PerpsController.ts
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: high
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR introduces significant changes to the Perps feature by adding MYX as a new perpetuals trading provider alongside HyperLiquid. The changes include:

  1. PerpsController (CRITICAL): Major modifications to the controller including:

    • New MYX provider registration with feature flag checks
    • Enhanced switchProvider() method with full reinit approach (disconnect → update state → init)
    • Rollback logic on provider switch failure
    • New isMYXProviderEnabled() method using RemoteFeatureFlagController
  2. New Provider Implementation: Complete MYXProvider class implementing the PerpsProvider interface with:

    • Market data fetching via @myx-trade/sdk
    • REST polling for price updates
    • Stubbed trading operations (Stage 1 read-only)
  3. New UI Components:

    • PerpsProviderSelectorBadge - Shows current provider in header
    • PerpsProviderSelectorSheet - Bottom sheet for provider selection
    • PerpsSelectProviderView - Navigation wrapper
    • Updated PerpsHomeHeader with provider badge integration
  4. New Services:

    • MYXClientService for SDK interactions
    • Updated PerpsStreamManager with provider-aware caching
    • Updated PerpsConnectionManager with additional cache clearing
  5. New Dependencies: Added @myx-trade/sdk and viem packages

  6. Navigation Changes: Added SELECT_PROVIDER route

Per the tag descriptions:

  • SmokePerps: Required because this PR directly modifies Perps views (PerpsHomeView, PerpsHomeHeader), the PerpsController, and adds new provider selection functionality. The tag description explicitly mentions "changes to Perps views (headers, lists, full views, e.g. PerpsHomeView, PerpsMarketListView, PerpsWithdrawView) affect Trending."
  • SmokeWalletPlatform: Required because Perps is a section inside the Trending tab, and the tag description states "changes to Perps, Predictions, or Tokens views (headers, lists, full views) that are embedded in Trending affect this tag."
  • SmokeConfirmations: Required per SmokePerps description: "When selecting SmokePerps, also select SmokeWalletPlatform (Trending section) and SmokeConfirmations (Add Funds deposits are on-chain transactions)."

Risk is HIGH because:

  • PerpsController is a critical controller with complex state management
  • Provider switching involves full reinitialization with rollback logic
  • New external SDK dependency (@myx-trade/sdk)
  • Changes affect multiple UI components and navigation
  • Feature flag integration with RemoteFeatureFlagController

Performance Test Selection:
This PR introduces significant changes to the Perps feature including a new MYX provider, provider switching with full reinitialization, and provider-aware caching in PerpsStreamManager. The provider switch involves disconnect → state update → init cycles which could impact performance. The MarketDataChannel now tracks provider IDs and invalidates cache on provider changes. These changes could affect Perps market loading, position management, and add funds flow performance. The @PerformancePreps tag should be run to validate that the multi-provider architecture doesn't degrade perps performance.

View GitHub Actions results

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread app/components/UI/Perps/controllers/PerpsController.ts
@sonarqubecloud

Copy link
Copy Markdown

@abretonc7s abretonc7s added this pull request to the merge queue Feb 10, 2026
Merged via the queue into main with commit 748a489 Feb 10, 2026
94 of 96 checks passed
@abretonc7s abretonc7s deleted the feat/perps/myx-poc1 branch February 10, 2026 09:37
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 10, 2026
@metamaskbot metamaskbot added the release-7.66.0 Issue or pull request that will be included in release 7.66.0 label Feb 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.66.0 Issue or pull request that will be included in release 7.66.0 size-XL skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants