From 67d96aeecd9312fe6266fdbe3895acfb8ebcfa77 Mon Sep 17 00:00:00 2001 From: Arthur Breton Date: Tue, 30 Jun 2026 19:48:19 +0200 Subject: [PATCH 1/2] feat(perps-controller): add TP/SL RoE sign analytics constants Expose roe_sign and tpsl_roe_sign_toggled in the shared perps analytics contract so clients can drop interim local mirrors after release. Co-authored-by: Cursor --- packages/perps-controller/CHANGELOG.md | 3 +++ packages/perps-controller/src/constants/eventNames.ts | 4 ++++ .../tests/src/constants/eventNames.test.ts | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/packages/perps-controller/CHANGELOG.md b/packages/perps-controller/CHANGELOG.md index 1ddf1186cb0..964cc7c78ea 100644 --- a/packages/perps-controller/CHANGELOG.md +++ b/packages/perps-controller/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add Auto Close TP/SL RoE sign toggle analytics constants to `PERPS_EVENT_PROPERTY` and `PERPS_EVENT_VALUE` so mobile and extension can import them from `@metamask/perps-controller` instead of local mirrors ([TAT-3429](https://consensyssoftware.atlassian.net/browse/TAT-3429), [#9322](https://github.com/MetaMask/core/pull/9322)) + - New `PERPS_EVENT_PROPERTY` key: `ROE_SIGN` (`roe_sign`) + - New `PERPS_EVENT_VALUE.INTERACTION_TYPE` entry: `TPSL_ROE_SIGN_TOGGLED` (`tpsl_roe_sign_toggled`) - Add `listedAt` (epoch ms) to `PerpsMarketData` and `TerminalAssetMetadata`, sourced from the Terminal API and normalized from either a numeric epoch value or an ISO 8601 string. Clients can use this field to surface recently added markets (e.g. markets listed within the last 30 days). ([#9308](https://github.com/MetaMask/core/pull/9308)) - Add recently viewed markets tracking to `PerpsController`: ([#9308](https://github.com/MetaMask/core/pull/9308)) - New `recentlyViewedMarkets` persisted state (per-network: `testnet`/`mainnet`), containing `{ symbol, viewedAt }` entries ordered newest-first and capped at 10. diff --git a/packages/perps-controller/src/constants/eventNames.ts b/packages/perps-controller/src/constants/eventNames.ts index b5a0eb497d1..5744a851b08 100644 --- a/packages/perps-controller/src/constants/eventNames.ts +++ b/packages/perps-controller/src/constants/eventNames.ts @@ -140,6 +140,8 @@ export const PERPS_EVENT_PROPERTY = { HAS_STOP_LOSS: 'has_stop_loss', TAKE_PROFIT_PERCENTAGE: 'take_profit_percentage', STOP_LOSS_PERCENTAGE: 'stop_loss_percentage', + // Auto Close TP/SL RoE sign toggle (`'+'` | `'-'`) + ROE_SIGN: 'roe_sign', // Watchlist/Favorites properties FAVORITES_COUNT: 'favorites_count', @@ -454,6 +456,8 @@ export const PERPS_EVENT_VALUE = { SLIPPAGE_CONFIG_OPENED: 'slippage_config_opened', SLIPPAGE_CONFIG_CHANGED: 'slippage_config_changed', SLIPPAGE_LIMIT_BLOCKED_ORDER: 'slippage_limit_blocked_order', + // Auto Close TP/SL RoE sign toggle + TPSL_ROE_SIGN_TOGGLED: 'tpsl_roe_sign_toggled', // Discovery analytics MARKET_LIST_FILTER: 'market_list_filter', // Sort / filter interactions (TAT-3142) diff --git a/packages/perps-controller/tests/src/constants/eventNames.test.ts b/packages/perps-controller/tests/src/constants/eventNames.test.ts index 46c72fc023e..dde1c1a9986 100644 --- a/packages/perps-controller/tests/src/constants/eventNames.test.ts +++ b/packages/perps-controller/tests/src/constants/eventNames.test.ts @@ -15,6 +15,12 @@ describe('PERPS_EVENT_PROPERTY', () => { }); }); + describe('Auto Close TP/SL RoE sign analytics keys', () => { + it('exports ROE_SIGN property key', () => { + expect(PERPS_EVENT_PROPERTY.ROE_SIGN).toBe('roe_sign'); + }); + }); + describe('consolidated analytics contract property keys (TAT-3463)', () => { it('exports entry point / discovery attribution keys (TAT-3080)', () => { expect(PERPS_EVENT_PROPERTY.ENTRY_POINT).toBe('entry_point'); @@ -348,6 +354,9 @@ describe('PERPS_EVENT_VALUE consolidated contract entries (TAT-3463)', () => { expect( PERPS_EVENT_VALUE.INTERACTION_TYPE.PAYMENT_TOKEN_SELECTOR_DISMISSED, ).toBe('payment_token_selector_dismissed'); + expect(PERPS_EVENT_VALUE.INTERACTION_TYPE.TPSL_ROE_SIGN_TOGGLED).toBe( + 'tpsl_roe_sign_toggled', + ); }); it('exports ACTION.ABANDON_ORDER (TAT-3136)', () => { From f933d8821646ab3814497a4073ad6aad12778e3a Mon Sep 17 00:00:00 2001 From: Arthur Breton Date: Tue, 30 Jun 2026 20:54:13 +0200 Subject: [PATCH 2/2] chore(perps-controller): drop Jira link from changelog entry Keep ticket reference in the PR description only. Co-authored-by: Cursor --- packages/perps-controller/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/perps-controller/CHANGELOG.md b/packages/perps-controller/CHANGELOG.md index 964cc7c78ea..142dd81917d 100644 --- a/packages/perps-controller/CHANGELOG.md +++ b/packages/perps-controller/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add Auto Close TP/SL RoE sign toggle analytics constants to `PERPS_EVENT_PROPERTY` and `PERPS_EVENT_VALUE` so mobile and extension can import them from `@metamask/perps-controller` instead of local mirrors ([TAT-3429](https://consensyssoftware.atlassian.net/browse/TAT-3429), [#9322](https://github.com/MetaMask/core/pull/9322)) +- Add Auto Close TP/SL RoE sign toggle analytics constants to `PERPS_EVENT_PROPERTY` and `PERPS_EVENT_VALUE` so mobile and extension can import them from `@metamask/perps-controller` instead of local mirrors ([#9322](https://github.com/MetaMask/core/pull/9322)) - New `PERPS_EVENT_PROPERTY` key: `ROE_SIGN` (`roe_sign`) - New `PERPS_EVENT_VALUE.INTERACTION_TYPE` entry: `TPSL_ROE_SIGN_TOGGLED` (`tpsl_roe_sign_toggled`) - Add `listedAt` (epoch ms) to `PerpsMarketData` and `TerminalAssetMetadata`, sourced from the Terminal API and normalized from either a numeric epoch value or an ISO 8601 string. Clients can use this field to surface recently added markets (e.g. markets listed within the last 30 days). ([#9308](https://github.com/MetaMask/core/pull/9308))