refactor(perps): address core PR #7941 review and cleanup#27035
Conversation
…c number constants
…e, remove type cast
|
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. |
- Restore EstimatedGasLimit to 100000 (was incorrectly set to 150000 during constant extraction in prior refactor) - Move Date.now() back into createSelector result function body to restore memoization; default param in input selector fired on every call, defeating the cache - Add fetchHistoricalCandles tests for HyperLiquidProvider (95% new code coverage)
Perps deposits use ERC-20 USDC so totalFiat is always populated; the 0x fallback path was unreachable and broken (ethPriceUSD was never passed by the caller, making it always return $0). Remove the BN import and ethPriceUSD parameter; update tests to expect '$0' for any hex wei input.
|
@metamaskbot update-mobile-fixture |
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.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag Selection Rationale:
The changes are isolated to the perps domain (Phase 6 controller) with no direct impact on core Engine initialization or other controllers. The risk is medium due to the controller initialization refactoring and gas limit changes. Performance Test Selection: |
The committed fixture schema is out of date. To update, comment: |
|



Description
Addresses all actionable review comments from the Core perps-controller PR (MetaMask/core#7941).
Bug fixes:
'User 'prefix to match the pattern used elsewheretimestampas selector input so re-renders fire correctlyperps-types.tsRefactors (per core review feedback):
export *wildcards with explicit named exports inindex.tsPerpsController-method-action-types.ts#createProviders()factoryregisterMethodActionHandlersfrom constructor toinitialize()with an idempotency guardDEPOSIT_GAS_LIMIT,SPOT_ASSET_ID_OFFSET,MYX_TRADING_DEFAULTS,MYX_FEE_CONFIG)fetchHistoricalCandlestoPerpsProviderinterface (removes a type cast inPerpsController)Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches Perps controller initialization/messenger wiring and public exports, which could cause runtime or build-time breakages if any consumers rely on previous timing or wildcard exports. Behavior changes are mostly bounded (constants, cancellation detection, candle fetching interface), but span multiple core perps modules.
Overview
Perps controller refactor and API cleanup. Extracts
PerpsControllermethod action type definitions intoPerpsController-method-action-types.ts, movesregisterMethodActionHandlersfrom the constructor intoinit()with an idempotency guard, and factors provider instantiation/active-provider selection into a private#createProviders().Provider/API surface updates. Replaces
export *barrels incontrollers/perps/index.tswith explicit named exports, adds optionalfetchHistoricalCandlesto thePerpsProviderinterface and implements/tests it inHyperLiquidProvider, and removes a circular dependency by relocatingOrderTypeintotypes/perps-types.ts.Bug fixes and config/constants. Updates deposit cancellation detection strings to match
User cancelled/canceled, fixes a selector memoization ordering regression aroundtimestamp, drops unsupported hex-wei handling inconvertPerpsAmountToUSD(now returns'$0'), and centralizes fee/gas/ID constants (e.g.,DEPOSIT_CONFIG.EstimatedGasLimit,WITHDRAWAL_CONSTANTS.DefaultFeeAmount,ESTIMATED_FEE_RATE,SPOT_ASSET_ID_OFFSET).Written by Cursor Bugbot for commit 29b3e69. This will update automatically on new commits. Configure here.