Skip to content

Latest commit

 

History

History
415 lines (304 loc) · 31 KB

File metadata and controls

415 lines (304 loc) · 31 KB

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Added

  • Add Perps Discovery analytics constants to PERPS_EVENT_PROPERTY and PERPS_EVENT_VALUE so mobile can import them from @metamask/perps-controller instead of maintaining a local mirror (#9178)
    • New PERPS_EVENT_PROPERTY keys: SOURCE_SECTION, RESULT_COUNT, SECTION_NAME, SECTION_INDEX, SECTIONS_DISPLAYED, WATCHLIST_COUNT, WATCHLIST_MARKETS
    • New PERPS_EVENT_VALUE.SOURCE_SECTION group: values for home sections (positions, orders, watchlist, whats_happening, products, top_gainers, top_losers, crypto, commodity, stock, forex), explore sections (perps_movers, perps_crypto, perps_stocks_commodities, perps_markets), and market-list sections (all_markets, new, active_search)
    • New PERPS_EVENT_VALUE.SECTION_NAME group: balance, positions, orders, watchlist, whats_happening, products, top_movers, explore_crypto, explore_commodities, explore_stocks, explore_forex, recent_activity
    • Extended PERPS_EVENT_VALUE.INTERACTION_TYPE with MARKET_LIST_FILTER
    • Extended PERPS_EVENT_VALUE.BUTTON_CLICKED with WATCHLIST, TOP_MOVERS, WHATS_HAPPENING
    • Extended PERPS_EVENT_VALUE.BUTTON_LOCATION with ASSET_DETAILS

Changed

  • Bump @metamask/utils from ^11.9.0 to ^11.11.0 (#9074)

Added

  • Add observational hard timeout for order submission: tag the Perps Order Submission trace and emit a breadcrumb when a provider round-trip exceeds PlaceOrderTimeoutMs (60s), without cancelling the in-flight order (#8994)
  • Add HYPERLIQUID_ASSET_NAMES (a curated symbol → human-readable name map, e.g. BTC → 'Bitcoin', xyz:AAPL → 'Apple', xyz:GOLD → 'Gold') and the getHyperLiquidAssetName(symbol, names?) helper, both exported from @metamask/perps-controller/constants, so clients can match and display markets by full name (#9082)
    • HyperLiquid does not expose a per-asset human-readable name; this map is maintained client-side and keyed like HIP3_ASSET_MARKET_TYPES (bare SYMBOL for crypto, dex:SYMBOL for HIP-3). Unmapped assets fall back to their ticker.
  • Add rankMarketsByQuery(markets, query) and getMarketMatchRank(market, query) helpers (and the MarketMatchRank enum) for relevance-ranked market search by ticker symbol or human-readable name (exact > prefix > substring, stable within a rank) (#9082)
    • Complements the existing unranked filterMarketsByQuery; same match semantics (case-insensitive substring on symbol and name), but ordered by relevance. No fuzzy/phonetic matching.

Changed

  • Deliver HyperLiquid positions, orders, and account/spot balance via per-DEX clearinghouseState and openOrders subscriptions on all paths, removing the dependency on the deprecated webData2 snapshot channel (#9081)
    • The non-HIP-3 (main-DEX-only) user data path previously used webData2, which HyperLiquid is throttling to a 15s push interval and deprecating. It now uses the same sub-second per-DEX subscriptions as the HIP-3 path, with webData3 retained only for open-interest caps (not latency-sensitive).
  • Surface late order completions via trace reason: 'late_success' | 'late_error' (#8994)
  • PerpsMarketData.name returned by getMarketDataWithPrices() is now the human-readable market name (resolved via HYPERLIQUID_ASSET_NAMES) instead of a copy of the ticker symbol; unmapped assets are unchanged (still equal the symbol) (#9082)
    • transformMarketData gains an optional assetNames parameter (defaults to the bundled map) to override the name source.
  • Bump @metamask/controller-utils from ^12.1.0 to ^12.2.0 (#9058, #9083)

Removed

  • Remove unused Perps Order Submission Toast trace name from the PerpsTraceName union (#8994)

Fixed

  • Fix late_error never being emitted in the placeOrder catch path when a provider call succeeded past PlaceOrderTimeoutMs but a subsequent step threw; the trace reason now correctly reflects 'late_error' whenever the submission threshold was exceeded, regardless of where the exception originated (#8994)

Added

  • Centralise market category classification so consumers share one model instead of re-deriving it per client (#9009)
    • Export getMarketTypeFilter (resolves a market to its UI category filter with singular values aligned to MarketCategory) and isHip3Market. getMarketTypeFilter and matchesCategory treat a marketSource DEX id as a HIP-3 signal consistently, so partial (route-param) markets classify the same way in both.
    • Export the pure matchesCategory and applyMarketFilters helpers (moved from MarketDataService).

Changed

  • BREAKING: Align MarketTypeFilter and MARKET_CATEGORIES values with MarketCategory singular values (#9009)
    • Replace stocks with stock, indices with index, etfs with etf, and commodities with commodity.
  • Reclassify xyz:CBRS (Cerebras) from stock to pre-ipo and add xyz:IPOP (Quantinuum) as pre-ipo in HIP3_ASSET_MARKET_TYPES, so all three Pre-IPO Perpetual markets on trade.xyz (CBRS, SPCX, IPOP) display under the Pre-IPO category (#9038)

Added

  • Add MarketCategory enum, MARKET_CATEGORIES ordered array (7 data-model category pills), and getMarketCategories messenger action (#8892)
  • Expand HIP3_ASSET_MARKET_TYPES with new stock, ETF, pre-IPO, forex, and commodity markets (#8892)
  • Add categories, sortBy, direction, limit, and excludeSymbols optional params to GetMarketDataWithPricesParams and getMarketDataWithPrices() for post-processing filtering, sorting, and pagination of market data (#8892)
  • Export SortField, SortDirection, and GetMarketDataWithPricesParams types from the package root (#8892)

Changed

  • BREAKING: Replace 'equity' with granular MarketType values: 'stock', 'pre-ipo', 'index', and 'etf' (#8892)
    • Update any code matching marketType === 'equity' to use the specific sub-type.

Added

  • Add slippage controls so users can configure per-order slippage tolerance for market trades (#8871)
  • Track vip_tier and vip_discount properties on perps trading events for fee analytics (#8871)
  • Surface an in-app banner during an ongoing HyperLiquid outage so users see degraded trading status (#8871)
  • Expose subpath exports for ./constants, ./constants/*, ./types, and ./utils/* so consumers using legacy node module resolution can deep-import compiled entry points without losing tree-shaking (#8883)

Fixed

  • Prefer the currently selected EVM account when resolving the trading account so account switching is honored across providers (#8871)
  • Suppress User or API Wallet does not exist Sentry noise from unfunded wallets that have not interacted with HyperLiquid (#8871)
  • Approve the HyperLiquid builder fee when missing so order submission succeeds after fresh wallet setup (#8871)

Changed

  • Pass isInternal: true to all internal addTransaction calls to adopt the explicit isInternal flag introduced in @metamask/transaction-controller (#8633)
  • Bump @metamask/transaction-controller from ^65.4.0 to ^66.0.0 (#8848)

Changed

  • Pass the perps builder base fee into rewards discount resolution and treat unhydrated rewards subscription state as retryable instead of a definitive no-discount result (#8803)
  • Bump @metamask/controller-utils from ^12.0.0 to ^12.1.0 (#8774)
  • Bump @metamask/transaction-controller from ^65.3.0 to ^65.4.0 (#8796)

Fixed

  • Defer signing-backed HyperLiquid unified-account setup for hardware wallets across migratable abstraction modes, including Ledger, Trezor, OneKey, Lattice, and QR keyrings, to avoid repeated signing prompts while browsing (#8803)
  • Improve logging and retry classification for failed cancel/close/TP-SL operations and SDK-wrapped keyring-locked errors (#8803)

Changed

  • Bump @metamask/controller-utils from ^11.20.0 to ^12.0.0 (#8755)

Changed

  • BREAKING: Rename AccountState.availableBalance to spendableBalance and AccountState.availableToTradeBalance to withdrawableBalance for clearer semantics across abstraction modes (#8678)
  • Mode-aware spot fold: addSpotBalanceToAccountState now folds free spot USDC into both spendableBalance and withdrawableBalance for Unified/Portfolio modes, while Standard/DEX-abstraction modes keep spot separate (#8678)
  • Add throttled WS-driven userAbstraction refresh so HL-web mode flips propagate back without requiring a restart or account switch (#8678)
  • Fix position direction display for flipped positions (#8707)

Added

  • BREAKING: HyperLiquidClientService now forces the dexAbstraction → unifiedAccount migration via a new internal flow, deferred until first withdraw, placeOrder, or other action entry point so users see unified collateral on their first trade/withdrawal (#8658)
  • BREAKING: addSpotBalanceToAccountState and HyperLiquidSubscriptionService are now mode-aware: spot USDC is only folded into tradeable collateral for unifiedAccount / portfolioMargin modes, and userAbstraction is propagated through subscriptions (#8658)

Changed

  • Bump @nktkas/hyperliquid from ^0.30.2 to ^0.32.2 for userAbstraction / userSetAbstraction / agentSetAbstraction API surface (#8658)
  • Replace agentSetAbstraction wire-code magic string with a typed constant (#8658)
  • Bump @metamask/keyring-controller from ^25.3.0 to ^25.4.0 (#8665)
  • Bump @metamask/account-tree-controller from ^7.1.0 to ^7.2.0 (#8665)
  • Bump @metamask/transaction-controller from ^64.4.0 to ^65.0.0 (#8613)
  • Bump @metamask/messenger from ^1.1.1 to ^1.2.0 (#8632)

Fixed

  • Keep users on portfolioMargin mode and recover the resolved abstraction mode after migration instead of evicting it (#8658)
  • Retry abstraction mode after transient userAbstraction failures and reset the memoized readiness promise after silent migration failures (#8658)
  • Close WebSocket-vs-REST race that could fold spot for Standard users and preserve abstraction REST results across active subscribers (#8658)
  • Drop the pre-fetch generation guard so userAbstraction always resolves; treat cached balances as an unambiguous spot owner (#8658)
  • Restore HyperLiquid withdrawal for Unified Account Mode users and support arb USDC withdraw balance in unified mode (#8658)
  • Harden unified-account migration handling and close MM Pay $0 + analytics gaps (#8658)

Added

  • Add coalescePerpsRestRequest utility for deduplicating concurrent REST requests with account-scoped cache keys (#8560)
  • Add accountUtils helpers for resolving the active perps account id and pinning it to forwarded provider params (#8560)

Changed

  • Account-scope the REST cache and guard cache writes so mount load stays cacheable without cross-account bleed (#8560)
  • Make forceRefresh provider-agnostic and align rate-limit handling with the extension (#8560)
  • Regenerate PerpsController method action types; shrink rate-limit diff and drop verbose history logs (#8560)

Removed

  • BREAKING: Drop the dead spotState parameter from adaptAccountStateFromSDK. Spot balances are layered on by addSpotBalanceToAccountState, which enforces the USDC-only policy via SPOT_COLLATERAL_COINS; removing the dormant branch keeps one source of truth and prevents a future caller from silently getting ALL-coins behavior (#8560)

Fixed

  • HyperLiquid Unified-mode live balance: subscribe to spotState WS and compute tradeable/total balance from on-chain math (#8560)
  • Complete spot-balance parity with the extension consumer (#8560)
  • Preserve integer trailing zeros when szDecimals=0 in perpsFormatters (#8560)
  • Preserve candle pagination cancellation and skip coalesce for explicit-endTime candle paging to avoid stale pages (#8560)
  • Defer account resolution on the non-paginated cache path to prevent race conditions (#8560)
  • Force-refresh on activity mount and evict expired coalesce entries so stale promises cannot resolve to cache (#8560)
  • Normalize event.user to lowercase when caching the spot-state WS address so #ensureSpotState hits the cache instead of triggering a redundant REST spotClearinghouseState refetch when HyperLiquid returns a checksummed address (#8560)

Added

  • Add isAbortError utility export from utils for distinguishing expected cancellation errors from real failures (#8515)

Changed

  • TradingService.flipPosition() no longer passes stale position entryPrice as currentPrice on reverse-position orders; providers now validate and price flips against live market data (#8515)

Removed

  • Remove unused ESTIMATED_FEE_RATE export from constants/hyperLiquidConfig (dead code after reverse-position fee precheck was removed) (#8515)

Fixed

  • Suppress noisy Sentry reports from expected historical-candle fetch cancellations (AbortError) during navigation, while preserving real error reporting in HyperLiquidClientService and MarketDataService (#8515)

Fixed

  • Preserve the webpackIgnore safeguard on the MYXProvider dynamic import in built dist files so extension consumers do not statically resolve the intentionally-unpublished MYX provider module (#8473)
  • Use HTTP transport for HyperLiquid candle snapshots and refresh DEX discovery cache handling to avoid rapid market-switching 429s after syncing the latest mobile perps controller state (#8473)

Added

  • Add disk-backed cold-start cache for instant data display on launch (#8460)
  • Add skipTTL option to getCachedMarketDataForActiveProvider and getCachedUserDataForActiveProvider (#8460)
  • Add perps decimal formatters (perpsFormatters) for shared formatting utilities (#8460)
  • Add FUNDING_RATE_CONFIG constants for funding rate display formatting (#8460)
  • Add buildProviderCacheKey and getProviderNetworkKey helper exports (#8460)

Changed

  • Bump @metamask/transaction-controller from ^64.0.0 to ^64.1.0 (#8432)
  • Bump @metamask/base-controller from ^9.0.1 to ^9.1.0 (#8457)

Fixed

  • Fix TP/SL orders disappearing after creating a market order by filtering on isPositionTpsl (#8460)
  • Fix missing latest funding payments by using paginated fetch with auto-split (#8460)
  • Fix WebSocket reconnection on foreground return when socket is still alive (#8460)

Added

  • Export PerpsControllerGetStateAction type (#8352)
  • Expose missing public PerpsController methods through its messenger (#8352)
    • The following actions are now available:
      • PerpsController:calculateLiquidationPrice
      • PerpsController:calculateMaintenanceMargin
      • PerpsController:clearDepositResult
      • PerpsController:clearWithdrawResult
      • PerpsController:completeWithdrawalFromHistory
      • PerpsController:depositWithConfirmation
      • PerpsController:depositWithOrder
      • PerpsController:fetchHistoricalCandles
      • PerpsController:flipPosition
      • PerpsController:getActiveProvider
      • PerpsController:getActiveProviderOrNull
      • PerpsController:getAvailableDexs
      • PerpsController:getBlockExplorerUrl
      • PerpsController:getCachedMarketDataForActiveProvider
      • PerpsController:getCachedUserDataForActiveProvider
      • PerpsController:getCurrentNetwork
      • PerpsController:getMarketDataWithPrices
      • PerpsController:getMaxLeverage
      • PerpsController:getWatchlistMarkets
      • PerpsController:getWebSocketConnectionState
      • PerpsController:getWithdrawalProgress
      • PerpsController:getWithdrawalRoutes
      • PerpsController:init
      • PerpsController:isCurrentlyReinitializing
      • PerpsController:isFirstTimeUserOnCurrentNetwork
      • PerpsController:isWatchlistMarket
      • PerpsController:reconnect
      • PerpsController:setLiveDataConfig
      • PerpsController:startMarketDataPreload
      • PerpsController:stopMarketDataPreload
      • PerpsController:subscribeToAccount
      • PerpsController:subscribeToCandles
      • PerpsController:subscribeToConnectionState
      • PerpsController:subscribeToOICaps
      • PerpsController:subscribeToOrderBook
      • PerpsController:subscribeToOrderFills
      • PerpsController:subscribeToOrders
      • PerpsController:subscribeToPositions
      • PerpsController:subscribeToPrices
      • PerpsController:switchProvider
      • PerpsController:toggleWatchlistMarket
      • PerpsController:updateMargin
      • PerpsController:updatePositionTPSL
      • PerpsController:updateWithdrawalProgress
      • PerpsController:updateWithdrawalStatus
      • PerpsController:validateClosePosition
      • PerpsController:validateOrder
      • PerpsController:validateWithdrawal
    • Corresponding action types are available as well.
  • Add completeWithdrawalFromHistory method for FIFO-based withdrawal completion matching (#8333)
  • Add lastCompletedWithdrawalTimestamp and lastCompletedWithdrawalTxHashes state fields (#8333)

Changed

  • Refactor pending withdraw/deposit tracking to FIFO queue design (#8333)
  • Centralize Arbitrum network check in deposit hooks to prevent missing network errors (#8333)
  • Provider credentials, builder fee injection, and env var centralization (#8333)
  • Reduce max order amount by 0.5% buffer to avoid insufficient margin rejections (#8333)
  • Bump @metamask/account-tree-controller from ^6.0.0 to ^7.0.0 (#8325)
  • Bump @metamask/profile-sync-controller from ^28.0.1 to ^28.0.2 (#8325)
  • Bump @metamask/controller-utils from ^11.19.0 to ^11.20.0 (#8344)
  • Bump @metamask/messenger from ^1.0.0 to ^1.1.1 (#8364, #8373)
  • Move @myx-trade/sdk from dependencies to optionalDependencies so consumers (extension, mobile) do not install it automatically (#8398)
    • Combined with the MYX adapter export removal below, this prevents @myx-trade/sdk from entering the consumer's static webpack/metro import graph
    • MYXProvider continues to load @myx-trade/sdk via dynamic import() when MM_PERPS_MYX_PROVIDER_ENABLED=true
  • Add /* webpackIgnore: true */ magic comment to the MYXProvider dynamic import so webpack (extension) skips static resolution of the intentionally-unshipped module (#8398)

Removed

  • BREAKING: Remove adaptMarketFromMYX, adaptPriceFromMYX, adaptMarketDataFromMYX, filterMYXExclusiveMarkets, isOverlappingMarket, buildPoolSymbolMap, buildSymbolPoolsMap, and extractSymbolFromPoolId from the public package exports to prevent @myx-trade/sdk from being included in the static webpack bundle (#8398)
    • These functions are still used internally by MYXProvider, which is loaded via dynamic import
    • Consumers that imported these utilities directly should instead import from @metamask/perps-controller/src/utils/myxAdapter or duplicate the logic locally

Fixed

  • Preserve /* webpackIgnore: true */ magic comment in built dist files by using a variable for the MYXProvider dynamic import path, preventing ts-bridge from rewriting the AST node and stripping the comment (#8424)
  • Fix incorrect fee estimate when flipping a position (#8333)
  • Fix incorrect PnL and order size displayed after SL execution (#8333)
  • Fix stop loss not showing up in recent activity (#8333)
  • Fix incorrect market categories (#8333)
  • Fix TP/SL decimal precision for PUMP (#8333)
  • Fix missing decimal on price input when using preset on limit price (#8333)

Changed

  • Sync mobile perps code to core (mobile branch feat/perps/core-resolver) (#8291)
  • Add @metamask/geolocation-controller dependency for eligibility geolocation checks (#8291)
  • Exclude MYXWalletService from published package files (#8291)
  • MYX provider improvements: enhanced error handling, wallet service integration (#8291)
  • HyperLiquid provider improvements: subscription reliability, order book processing (#8291)
  • Eligibility service refactored for geolocation-based region blocking (#8291)
  • Bump @metamask/base-controller from ^9.0.0 to ^9.0.1 (#8317)
  • Bump @metamask/messenger from ^0.3.0 to ^1.0.0 (#8317)

Changed

  • Exclude @myx-trade/sdk from build output by default, reducing bundled size by ~57% (#8234)
  • MYX provider files are excluded from the package when publishing
  • Static import of MYXProvider replaced with dynamic import() that depends upon MM_PERPS_MYX_PROVIDER_ENABLED=true to break the eager dependency chain

Added

  • Add stopEligibilityMonitoring() method to pause geo-blocking eligibility checks when basic functionality is disabled (#8214)

Added

  • feat: defer eligibility to allow for onboarding to proceed without le… (#8197)

Changed

  • Bump @metamask/profile-sync-controller from ^27.1.0 to ^28.0.0 (#8162)
  • Bump @metamask/account-tree-controller from ^5.0.0 to ^5.0.1 (#8162)

Added

  • Initial release (#7654, #7941)
    • Add full PerpsController with multi-provider architecture, state management, and messenger integration
    • Add HyperLiquidProvider with complete DEX integration: trading, market data, order book, WebSocket subscriptions, wallet operations, and HIP-3 builder-deployed perpetuals support
    • Add MYXProvider with DEX integration: trading, market data, and account management
    • Add AggregatedPerpsProvider for multi-provider aggregation and unified market/position views
    • Add ProviderRouter for routing operations to the appropriate provider based on market configuration
    • Add SubscriptionMultiplexer for real-time WebSocket data aggregation across providers
    • Add TradingService for order placement, modification, cancellation, and position management
    • Add MarketDataService for market listing, pricing, funding rates, and order book data
    • Add AccountService for account state, balances, positions, and open orders
    • Add DepositService for deposit flow handling
    • Add EligibilityService for user eligibility verification
    • Add FeatureFlagConfigurationService for runtime feature flag management
    • Add HyperLiquidClientService, HyperLiquidSubscriptionService, and HyperLiquidWalletService for HyperLiquid-specific operations
    • Add MYXClientService for MYX-specific API operations
    • Add DataLakeService for data lake integration
    • Add RewardsIntegrationService for rewards system integration
    • Add TradingReadinessCache for caching trading readiness state
    • Add ServiceContext for service dependency injection
    • Add comprehensive type definitions for perps, HyperLiquid, MYX, configuration, tokens, and transactions
    • Add utility functions for market data transformation, order calculations, account operations, validation, and adapters
    • Add state selectors for accessing controller state
    • Add error code definitions for structured error handling
    • Add configuration constants for HyperLiquid, MYX, charts, order types, and performance metrics
    • Add platform-agnostic design via PerpsPlatformDependencies injection interface
    • Add generated method action types for messenger-exposed methods

Changed

  • Bump @metamask/controller-utils from ^11.18.0 to ^11.19.0 (#7995)