feat: remove all MYX protocol from core - #10038
Conversation
MYX was an unused protocol, so its removal is filed as a plain Removed entry rather than a breaking change. Point both changelog links at the real PR (#10038); they were written against a guessed number before the PR existed.
MYX is no longer a supported perps venue. Removing it drops the optional @myx-trade/sdk dependency, the dynamic-import plus webpackIgnore workaround, and the three !dist/*MYX* packaging exclusions that existed only to keep the provider out of published bundles. Deletes MYXProvider, MYXClientService, MYXWalletService, the MYX adapter, and the MYX config and type modules with their test suites, and de-wires the controller: #isMYXProviderEnabled, the dynamic import, registerMYXProvider, handleMYXImportError, resolveMyxAuthConfig, and every 'myx' routing and cache-key branch. PerpsProviderType narrows to 'hyperliquid' | 'lighter'. BREAKING CHANGE: removes the MYXCredentials type, the providerCredentials.myx option, PROVIDER_CONFIG.MYX_TESTNET_ONLY, and all MYX_* constant, endpoint, converter, and asset-config exports. Setting activeProvider: 'myx' or passing providerId: 'myx' now throws Unsupported provider. PerpsWatchlistMarkets.myx in authenticated-user-storage is made optional and deprecated rather than removed: it is a server-persisted schema, and blobs already stored with a myx watchlist must keep validating. Nothing writes it any more. A regression test pins both shapes. Where MYX served only as a second provider in aggregation, routing, and cache tests, those cases were repointed at Lighter so multi-provider coverage is preserved. HyperLiquid and Lighter behavior is unchanged.
`activeProvider` is persisted, and before this fix a value restored from an
older version whose venue has since been removed — notably 'myx' — fell
through to the `Unsupported provider` throw. That throw happens inside
performInitialization, so it was caught by the retry loop, burned every
attempt with backoff, and ended at InitializationState.Failed without ever
rewriting the persisted value. Perps stayed broken on every launch, not just
the first, until the client cleared state.
Make the fallback the default branch instead: any direct provider that is not
registered falls back to hyperliquid and rewrites the persisted value, which
is how 'myx' behaved before it was removed. The compile-time break is
unaffected — PerpsProviderType still does not admit 'myx'.
Also corrects the changelog, which claimed the controller throws for 'myx':
switchProvider returns { success: false, error: 'Provider myx not available' }
and persisted state now self-heals.
Remove the removed venue's name from the two explanatory comments left by the self-heal fix; the fallback is generic, so the comments describe it generically. The one remaining 'myx' literal is the regression test's input — it reproduces the value real users have in persisted state, so replacing it would stop the test proving upgrade behaviour. Condense the changelog entry from implementation narration to migration instructions, and drop the nested BREAKING prefixes now that the parent entry carries one.
MYX was an unused protocol, so its removal is filed as a plain Removed entry rather than a breaking change. Point both changelog links at the real PR (#10038); they were written against a guessed number before the PR existed.
The previous commit kept `myx` on `PerpsWatchlistMarkets` as an optional, `@deprecated` member, on the theory that preference blobs already stored server-side would stop validating if the key were removed outright. That was wrong. `PerpsWatchlistMarketsSchema` is a superstruct `type()`, which ignores unknown keys — only `object()` rejects them. Stored blobs carrying a `myx` watchlist validate exactly the same with the key gone, so the declaration bought nothing and left dead code in a removal. Remove the type member and the schema entry. The compat test stays, no longer referencing the removed type: it pins that pre-removal blobs keep validating, and records that this depends on `type()` over `object()`.
The test asserted that a preference blob carrying a `myx` watchlist still validates after the key was removed from `PerpsWatchlistMarkets`. That is superstruct's own `type()` behaviour — unknown keys pass, `object()` would reject them — not behaviour this package defines, and the suite still reports 100% coverage without it. The reasoning it documented is kept in the changelog entry for the removal, which is where a maintainer tightening the schema would look.
The removal narrows `PerpsProviderType` to `'hyperliquid' | 'lighter'` and drops public exports (`MYXCredentials`, the `MYX_*` constants, the `getMYX*` / `fromMYX*` / `toMYX*` helpers, `PROVIDER_CONFIG.MYX_TESTNET_ONLY`), which is breaking under the repo's changelog rules regardless of how widely the venue was used. Restore the prefix dropped in 84496d2, keeping the corrected PR link.
The Scale price-ladder tests merged from main use 'myx' as the stand-in second provider. That id no longer exists in PerpsProviderType, so point them at 'lighter' instead, which keeps each case's intent (default route, explicit route, not implemented, not registered, misattributed ladder).
4e1d1fd to
56a972d
Compare
|
Rebased onto Two things needed resolving, both from 1. 2. Retargeted those cases at
Validation on the post-rebase tree:
Only the changelog needed a real merge decision; the rest was mechanical. Re-approval needed since the push reset it. |
Explanation
@metamask/perps-controllershipped a full MYX protocol implementation alongside HyperLiquid andLighter. MYX is being dropped as a venue, and keeping it cost real weight: an optional
@myx-trade/sdkdependency, a dynamic-import +webpackIgnoreworkaround plus three!dist/*MYX*filesexclusions so extension bundles could skip the provider, and'myx'branches threaded through the controller, the provider router, and the provider-type unions.
This PR removes MYX from the package. It deletes
MYXProvider,MYXClientService,MYXWalletService, the MYX adapter, and the MYX config and type modules along with their testsuites; drops the
@myx-trade/sdkdependency and the packaging exclusions it required; andde-wires the controller —
#isMYXProviderEnabled, the dynamic-import registration path,registerMYXProvider,handleMYXImportError,resolveMyxAuthConfig, and the'myx'routing andcache-key branches all go. Net: ~8,700 lines removed across 42 files.
Notable API effects, all breaking for consumers that used MYX:
PerpsProviderTypeis now'hyperliquid' | 'lighter'.switchProvider('myx')returns{ success: false, error: 'Provider myx not available' }. A'myx'value restored frompersisted state falls back to
'hyperliquid'and rewrites the persisted value, so existingMYX users self-heal on next launch rather than getting a broken perps tab.
MYXCredentialstype andproviderCredentials.myxoption are gone.MYX_*constants,getMYXChainId/getMYXHttpEndpoint, thefromMYX*/toMYX*converters, and the MYX-only
USDT_BNB_TESTNET/USDT_BNB_MAINNETcollateral addresses are nolonger exported.
PROVIDER_CONFIG.MYX_TESTNET_ONLYis removed;buildProviderCacheKeyno longer special-cases'myx'.perpsMyxProviderEnabledremote flag andMM_PERPS_MYX_PROVIDER_ENABLEDenv override areno longer read, so clients can retire both.
Two changes may not be obvious:
packages/authenticated-user-storageis touched deliberately.PerpsWatchlistMarkets.myxis a server-persisted preference schema, not protocol code, and blobs already stored remotely
contain a
myxkey. Deleting the required field would have failed validation on that existingdata. It is instead made
optional()and@deprecated: nothing writes it any more, storedblobs still validate, and
perps-controlleris left with zero MYX references.filesfield is now plain["dist/"]. With the MYX exclusions gone, everything emittedinto
dist/publishes — so a staledist/from a previous build would ship MYX artifacts. Thevalidation below uses
yarn build:clean(which wipespackages/*/distfirst) and asserts theemitted tree contains no MYX file at all.
HyperLiquid and Lighter behavior is unchanged. Where MYX served only as "a second provider" in
multi-provider aggregation, routing, and cache tests, those cases were repointed at Lighter rather
than deleted, so multi-provider coverage is preserved.
Validation
yarn workspace @metamask/perps-controller run test— 79 suites, 3399 passed, 0 failures,coverage thresholds met (89.4% lines vs 80% required, 81.54% branches vs 69%, 85.58% functions
vs 78%).
yarn workspace @metamask/authenticated-user-storage run jest— 44 passed, 0 failures.yarn build:clean(root ts-bridge) — exit 0, "Project built successfully"; the emittedpackages/perps-controller/distcontains no MYX file, anddist/index.d.cts/dist/index.cjsexport no MYX symbol.
yarn changelog:validate— passes.src//tests/, none in the manifest,none in the built
dist/) and then reads live HyperLiquid testnet positions, orders, andaccount state through the de-wired controller to show the removal caused no regression. The
assertions were confirmed to fail against the pre-change tree, so a revert of this diff breaks
the recipe.
References
Client follow-ups needed before/alongside adoption:
providerCredentials.myx,activeProvider: 'myx', orproviderId: 'myx'usage and remove MYX from provider pickers.perpsMyxProviderEnabledremote feature flag can be retired once clients are updated.myxwatchlist key entirely once nostored blob relies on it.
Checklist
routing, and cache coverage is preserved.
'myx'as a sample provider now use'lighter'; comments in theLighter provider, wallet service, and adapter that referenced MYX as their template were
rewritten to stand alone.
perps-controller(Removed,**BREAKING:**) andauthenticated-user-storage(Changed).clients and consumer packages to resolve them
open. They are listed under References and should land before this is adopted.
Screenshots/Recordings
Note
Medium Risk
Large breaking removal across public types and exports; clients must drop MYX usage, though persisted stale provider state is handled with a HyperLiquid fallback.
Overview
Removes MYX as a perps venue across
@metamask/perps-controllerand aligned user-preference types. The MYX provider stack (MYXProvider, client/wallet services, adapters, config, types), the optional@myx-trade/sdkdependency, and dynamic-import /distpackaging workarounds are deleted (~8k+ lines).Breaking API surface:
PerpsProviderTypeis now'hyperliquid' | 'lighter';MYXCredentials,providerCredentials.myx, allMYX_*exports, and MYX-specific cache/config behavior are gone. The controller no longer registers MYX or readsperpsMyxProviderEnabled/MM_PERPS_MYX_PROVIDER_ENABLED. PersistedactiveProvider: 'myx'self-heals to HyperLiquid instead of failing init. Multi-provider tests and docs examples that used MYX are repointed to Lighter.Authenticated user storage:
PerpsWatchlistMarketsdrops the requiredmyxkey from types and validation; existing remote blobs with amyxfield should still validate because unknown keys are ignored.HyperLiquid and Lighter paths are otherwise unchanged.
Reviewed by Cursor Bugbot for commit 56a972d. Bugbot is set up for automated code reviews on this repo. Configure here.