feat(perps): sync perps controller with mobile#8207
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| errorMessage.includes('cancelled') || | ||
| errorMessage.includes('canceled'); | ||
| errorMessage.includes('User cancelled') || | ||
| errorMessage.includes('User canceled'); |
There was a problem hiding this comment.
Cancellation detection narrowed may miss non-prefixed messages
Medium Severity
The depositWithOrder error-handling path changed from includes('cancelled') / includes('canceled') to includes('User cancelled') / includes('User canceled'). This narrows the set of error messages that are recognized as user cancellations. If any wallet, signing library, or internal component produces a cancellation message that contains "cancelled"/"canceled" but not the "User " prefix (e.g., "Transaction was cancelled", "Request cancelled due to timeout"), those will now be misclassified as failures instead of cancellations, causing the deposit request status to be set to 'failed' instead of 'cancelled' and potentially triggering incorrect failure toasts to the user.
| */ | ||
| #marketCacheKey(providerId: string, isTestnet: boolean): string { | ||
| return `${providerId}:${isTestnet ? 'testnet' : 'mainnet'}`; | ||
| } |
There was a problem hiding this comment.
Method #marketCacheKey misleadingly used for user data
Low Severity
#marketCacheKey is documented as building "a cache key for per-provider market data" but is also used to generate keys for cachedUserDataByProvider throughout the user data preload and retrieval paths (#performUserDataPreload, getCachedUserDataForActiveProvider). The method name and JSDoc are misleading, increasing the risk that a future maintainer modifies the key format for market data without realizing it also affects user data caching, breaking cache lookups silently.


Explanation
Updates the perps controller with the latest sync from mobile. This PR replaces #8197.
Changes should always flow from mobile first (source of truth), then be synced to core using
scripts/perps/validate-core-sync.shin the mobile repo. This ensures consistency between mobile and core implementations.Key changes
PerpsControllerwith latest sync state from mobileHyperLiquidProviderandMYXProviderwith expanded functionalityMYXWalletServiceand expandedMYXClientServiceHyperLiquidSubscriptionServicewith latest changesEligibilityServicePerpsController-method-action-typesand event name constantsindex.tsmyxAdapterutilitiesReferences
Checklist
Note
Medium Risk
Medium risk because it changes eligibility/geolocation flow and rewires preload caching and provider initialization across networks/providers, which can affect trading readiness and displayed balances/markets. It also expands MYX integration (auth reads, endpoints, chains), increasing surface area for runtime misconfiguration or data mismatches.
Overview
Adds a deferred eligibility flow to
PerpsController(deferEligibilityCheck,startEligibilityMonitoring) so geolocation checks can be postponed until after onboarding, and switches eligibility to consume geolocation fromGeolocationController(removing internal geo-fetch/caching).Refactors background preloading caches to be per provider + network (
cachedMarketDataByProvider,cachedUserDataByProvider) with helpers to read assembled cache in aggregated mode, plus guards to avoid writing stale preload data during reinitialization and to re-trigger preloads aftertoggleTestnet/provider switches.Expands MYX support by enabling mainnet (no longer forced testnet-only), wiring credential-based enablement and auth config into provider creation, updating MYX chain/endpoints/price parsing, and implementing authenticated read paths in
MYXProvider(positions/orders/fills/funding/history) plus candle fetching/WS kline updates; also hardensHyperLiquidProviderwith asset-id repair, partial multi-DEX failure handling, and stale market-data fallback.Additionally restructures package exports in
index.tsto explicit named exports, introducesPerpsControllermethod-action types, tweaks deposit/withdrawal constants, and adds new analytics event name values.Written by Cursor Bugbot for commit bdef687. This will update automatically on new commits. Configure here.