Skip to content

feat: AUS Perps Watchlist#9010

Merged
gambinish merged 23 commits into
mainfrom
perps/tat-2663-migrate-perps-watchlist-to-aus
Jun 23, 2026
Merged

feat: AUS Perps Watchlist#9010
gambinish merged 23 commits into
mainfrom
perps/tat-2663-migrate-perps-watchlist-to-aus

Conversation

@gambinish

@gambinish gambinish commented Jun 4, 2026

Copy link
Copy Markdown
Member

Explanation

Persists state.watchlistMarkets to AUS so the watchlist follows the user across devices and clients, rather than being device-local only.

What changed

  • toggleWatchlistMarket now performs an optimistic local update first (UI is instant), then syncs to AUS. If the remote write fails, local state is reverted.
  • On init(), the controller hydrates state.watchlistMarkets from AUS. AUS is the source of truth; local state acts as an offline cache (persist: true unchanged).
  • One-time migration: if a user already has local markets saved but no AUS record yet, those are pushed up automatically on first init.
  • Falls back to local-only silently when unauthenticated or when the active provider has no AUS mapping (e.g. aggregated).
  • Adds resolveWatchlistExchangeKey() — the single extension point for adding future DEX providers to AUS sync.
    Integration (client PRs)

Each client needs to grant the PerpsController messenger two new allowed actions:

  • AuthenticatedUserStorageService:getNotificationPreferences
  • AuthenticatedUserStorageService:putNotificationPreferences

No other wiring needed — AuthenticatedUserStorageService is already running wherever NotificationServicesController is wired, and AuthenticationController:getBearerToken was already allowed.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Cross-device user preference writes and a breaking toggleWatchlistMarket API change require correct messenger wiring; merge logic and queue ordering reduce race risk but remote/local divergence on auth failures is possible by design.

Overview
Perps watchlist favorites are now synced to Authenticated UserStorage (perps.watchlistMarkets inside notification preferences) so they follow the signed-in user across devices, while local persisted state remains the offline cache.

toggleWatchlistMarket is now async (Promise<void>) and does an optimistic local update, then a serialized AUS read-merge-write via #ausQueue; failed remote writes revert local state. Init kicks off non-blocking #syncWatchlistFromRemote on the same queue so hydration finishes before toggles race it. Remote is source of truth when an exchange key exists (including empty lists); missing exchange keys trigger a one-time migration from local favorites. resolveWatchlistExchangeKey maps hyperliquid/myx; aggregated and missing blobs skip AUS without throwing. Favorite-toggle analytics are emitted on toggle.

Clients must allow messenger actions AuthenticatedUserStorageService:getNotificationPreferences and putNotificationPreferences (README dependency graph updated). Package adds @metamask/authenticated-user-storage as a dev dependency and extensive AUS sync tests.

Reviewed by Cursor Bugbot for commit f1d5db8. Bugbot is set up for automated code reviews on this repo. Configure here.

@gambinish gambinish changed the title feat: aus watchlist init feat: AUS Perps Watchlist Jun 4, 2026
Comment thread packages/perps-controller/src/PerpsController.ts
@gambinish

Copy link
Copy Markdown
Member Author

@metamaskbot publish-previews

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.2-preview-7bc7196a6
@metamask-previews/accounts-controller@39.0.1-preview-7bc7196a6
@metamask-previews/address-book-controller@7.1.2-preview-7bc7196a6
@metamask-previews/ai-controllers@0.7.0-preview-7bc7196a6
@metamask-previews/analytics-controller@1.1.1-preview-7bc7196a6
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-7bc7196a6
@metamask-previews/announcement-controller@8.1.0-preview-7bc7196a6
@metamask-previews/app-metadata-controller@2.0.1-preview-7bc7196a6
@metamask-previews/approval-controller@9.0.2-preview-7bc7196a6
@metamask-previews/assets-controller@8.3.3-preview-7bc7196a6
@metamask-previews/assets-controllers@108.6.0-preview-7bc7196a6
@metamask-previews/authenticated-user-storage@2.0.0-preview-7bc7196a6
@metamask-previews/base-controller@9.1.0-preview-7bc7196a6
@metamask-previews/base-data-service@0.1.3-preview-7bc7196a6
@metamask-previews/bridge-controller@75.0.0-preview-7bc7196a6
@metamask-previews/bridge-status-controller@72.1.0-preview-7bc7196a6
@metamask-previews/build-utils@3.0.4-preview-7bc7196a6
@metamask-previews/chain-agnostic-permission@1.6.1-preview-7bc7196a6
@metamask-previews/chomp-api-service@3.1.0-preview-7bc7196a6
@metamask-previews/claims-controller@0.5.3-preview-7bc7196a6
@metamask-previews/client-controller@1.0.1-preview-7bc7196a6
@metamask-previews/compliance-controller@2.1.0-preview-7bc7196a6
@metamask-previews/composable-controller@12.0.1-preview-7bc7196a6
@metamask-previews/config-registry-controller@0.4.1-preview-7bc7196a6
@metamask-previews/connectivity-controller@0.2.0-preview-7bc7196a6
@metamask-previews/controller-utils@12.1.1-preview-7bc7196a6
@metamask-previews/core-backend@6.3.3-preview-7bc7196a6
@metamask-previews/delegation-controller@3.0.2-preview-7bc7196a6
@metamask-previews/earn-controller@12.2.0-preview-7bc7196a6
@metamask-previews/eip-5792-middleware@3.0.4-preview-7bc7196a6
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-7bc7196a6
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-7bc7196a6
@metamask-previews/ens-controller@19.1.3-preview-7bc7196a6
@metamask-previews/eth-block-tracker@15.0.1-preview-7bc7196a6
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-7bc7196a6
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-7bc7196a6
@metamask-previews/foundryup@1.0.1-preview-7bc7196a6
@metamask-previews/gas-fee-controller@26.2.2-preview-7bc7196a6
@metamask-previews/gator-permissions-controller@4.2.0-preview-7bc7196a6
@metamask-previews/geolocation-controller@0.1.3-preview-7bc7196a6
@metamask-previews/json-rpc-engine@10.5.0-preview-7bc7196a6
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-7bc7196a6
@metamask-previews/keyring-controller@27.0.0-preview-7bc7196a6
@metamask-previews/logging-controller@8.0.2-preview-7bc7196a6
@metamask-previews/message-manager@14.1.2-preview-7bc7196a6
@metamask-previews/messenger@1.2.0-preview-7bc7196a6
@metamask-previews/messenger-cli@0.2.0-preview-7bc7196a6
@metamask-previews/money-account-balance-service@1.0.2-preview-7bc7196a6
@metamask-previews/money-account-controller@0.3.3-preview-7bc7196a6
@metamask-previews/money-account-upgrade-controller@2.0.4-preview-7bc7196a6
@metamask-previews/multichain-account-service@10.0.3-preview-7bc7196a6
@metamask-previews/multichain-api-middleware@3.1.3-preview-7bc7196a6
@metamask-previews/multichain-network-controller@3.1.3-preview-7bc7196a6
@metamask-previews/multichain-transactions-controller@7.1.1-preview-7bc7196a6
@metamask-previews/name-controller@9.1.2-preview-7bc7196a6
@metamask-previews/network-controller@32.0.0-preview-7bc7196a6
@metamask-previews/network-enablement-controller@5.3.0-preview-7bc7196a6
@metamask-previews/notification-services-controller@24.1.3-preview-7bc7196a6
@metamask-previews/passkey-controller@2.0.1-preview-7bc7196a6
@metamask-previews/permission-controller@13.1.1-preview-7bc7196a6
@metamask-previews/permission-log-controller@5.1.0-preview-7bc7196a6
@metamask-previews/perps-controller@8.0.0-preview-7bc7196a6
@metamask-previews/phishing-controller@17.2.0-preview-7bc7196a6
@metamask-previews/polling-controller@16.0.6-preview-7bc7196a6
@metamask-previews/preferences-controller@23.1.0-preview-7bc7196a6
@metamask-previews/profile-metrics-controller@3.2.0-preview-7bc7196a6
@metamask-previews/profile-sync-controller@28.1.1-preview-7bc7196a6
@metamask-previews/ramps-controller@14.1.1-preview-7bc7196a6
@metamask-previews/rate-limit-controller@7.0.1-preview-7bc7196a6
@metamask-previews/react-data-query@0.2.1-preview-7bc7196a6
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-7bc7196a6
@metamask-previews/sample-controllers@5.0.1-preview-7bc7196a6
@metamask-previews/seedless-onboarding-controller@10.0.2-preview-7bc7196a6
@metamask-previews/selected-network-controller@26.1.3-preview-7bc7196a6
@metamask-previews/shield-controller@5.1.2-preview-7bc7196a6
@metamask-previews/signature-controller@39.2.5-preview-7bc7196a6
@metamask-previews/snap-account-service@0.3.1-preview-7bc7196a6
@metamask-previews/social-controllers@2.2.1-preview-7bc7196a6
@metamask-previews/storage-service@1.0.2-preview-7bc7196a6
@metamask-previews/subscription-controller@6.1.3-preview-7bc7196a6
@metamask-previews/transaction-controller@67.1.0-preview-7bc7196a6
@metamask-previews/transaction-pay-controller@23.4.0-preview-7bc7196a6
@metamask-previews/user-operation-controller@41.2.4-preview-7bc7196a6
@metamask-previews/wallet@3.0.0-preview-7bc7196a6

@gambinish gambinish marked this pull request as ready for review June 15, 2026 19:51
@gambinish gambinish requested review from a team as code owners June 15, 2026 19:51
* main: (497 commits)
  Release/1053.0.0 (#9195)
  Revert @metamask/transaction-pay-controller changes not required (#9194)
  chore: add discovery event names (#9178)
  chore: deprecate CurrencyRateController (#9182)
  Release/1052.0.0 (#9188)
  fix: getQuoteUser function is broken if request is not postQuote (#9187)
  fix(network-controller): Remove deprecated NetworkControllerGetNetworkConfigurationByNetworkClientId type (#9185)
  fix(network-controller): Remove MegaETH v1 default configuration (#9183)
  Release/1051.0.0 (#9181)
  fix: MM Pay transaction with isQuoteRequired that have same source and destination chain and token (#9150)
  Release/1050.0.0 (#9180)
  fix(network-controller): Only consider failover endpoints when using Infura (#9125)
  feat(assets-controllers): add isDeprecated to multichain controllers (#9044)
  refactor(smart-transactions-controller): import AuthenticationController namespace (#9167)
  Release 1049.0.0 (#9177)
  fix(transaction-pay-controller): vault musd via sentinel (#9161)
  Release 1048.0.0 (#9174)
  chore: remove orphaned semver.sh helper (#9172)
  fix(rpc-service): Consider all Infura HTTP errors as service failures except 400 and 429 (#9123)
  chore: remove outdated migrate-tags guide (#9171)
  ...
Comment thread packages/perps-controller/src/PerpsController.ts
Comment thread packages/perps-controller/src/PerpsController.ts Outdated
Comment thread packages/perps-controller/src/PerpsController.ts
Comment thread packages/perps-controller/src/PerpsController.ts
@socket-security

socket-security Bot commented Jun 22, 2026

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@geositta geositta 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.

Requesting changes. The AUS integration follows the expected messenger and read merge write pattern, and the queue addresses concurrent toggle ordering. I found one source of truth issue where an intentionally cleared remote watchlist can be overwritten by stale local cache during init. Changing the init check to use exchange key presence instead of symbol count should preserve remote clears and keep migration limited to users who have not been migrated yet.

Comment thread packages/perps-controller/src/PerpsController.ts Outdated
@gambinish gambinish requested a review from geositta June 23, 2026 21:22

@geositta geositta 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.

Approve. Thanks, the AUS watchlist sync now preserves remote source of truth, including empty remote watchlists.

@gambinish gambinish added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 8560978 Jun 23, 2026
396 checks passed
@gambinish gambinish deleted the perps/tat-2663-migrate-perps-watchlist-to-aus branch June 23, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants