feat(perps): add live order book to pro market view - #33664
Conversation
Wire the Extension-style dual-stream order book (raw mid/spread + AggregatedOrderBookConnection ladder) into PerpsProOrderBookPanel.
Replace the local yalc build with the npm release that ships AggregatedOrderBookConnection for the pro order book.
Keep the live pro order book implementation over main's scaffold placeholders.
|
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. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
🧪 Flaky unit test detectionRun history flaky detectionHistorical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow. Failures / runs sampled per window:
AI-detected flaky patterns
|
Add required mode/proLayoutPreferences defaults and map UNSUPPORTED_COLLATERAL so TypeScript checks pass after the controller bump.
Align Engine and E2E/component-view PerpsController fixtures with perps-controller 10.0.0 default state.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #33664 +/- ##
==========================================
+ Coverage 84.70% 84.73% +0.02%
==========================================
Files 6202 6205 +3
Lines 166489 166697 +208
Branches 40711 40796 +85
==========================================
+ Hits 141022 141246 +224
+ Misses 15845 15801 -44
- Partials 9622 9650 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Keep @metamask/perps-controller at ^10.0.0 and resolve Engine perps-controller test mocks with PerpsMode from constants.
Render the config sheet in a Modal so it is not clipped by the narrow column, and stop the ladder from flex-stretching away from the buy/sell ratio.
Introduce collapse/expand controls for the Perps Pro order book so the order form can expand to full width. Adds testIDs, UI state and handlers in PerpsProMarketView, conditional rendering in PerpsProMarketLayout, and a collapse button in PerpsProOrderBookPanel. Includes unit tests for collapse/expand behavior and new localization strings for accessibility labels. This improves layout flexibility during trading and is covered by updated tests.
Restyle listed-by and group-by options as outlined chips with correct selected/unselected borders, and use Order book settings / Save copy.
Only snapshot currency/metric/grouping into draft state when the sheet opens so live mid/grouping updates do not wipe in-progress selections.
Keep local grouping in sync with the active symbol's saved preference so a prior market selection cannot stick and drive the wrong nSigFigs.
geositta
left a comment
There was a problem hiding this comment.
Thanks for implementing the dedicated aggregated connection alongside the raw controller stream. I verified that this matches the controller’s fast stream and reconnection behavior.
I am requesting changes for three focused issues:
- Add Android system-Back handling to the React Native Modal.
- Expose the active orderbook view mode to assistive technology.
- Remove duplicate mode and proLayoutPreferences fixture keys.
Collapse currently resets the non-persisted orderbook controls when the panel is expanded again. I am treating that as a non-blocking scope decision for this greenfield task, provided the behavior is intentional.
|
|
||
| return ( | ||
| <View> | ||
| <Modal visible transparent animationType="none" statusBarTranslucent> |
There was a problem hiding this comment.
React Native requires onRequestClose for Android Modals. While this Modal is open, BackHandler events are not emitted, so the Android system Back button has no path to close the sheet. Please add onRequestClose={handleClose} and cover that callback in the sheet test.
| <Pressable | ||
| onPress={handleCycleViewMode} | ||
| accessibilityRole="button" | ||
| accessibilityLabel={strings('perps.order_book.view_toggle')} |
There was a problem hiding this comment.
This label describes the action but does not expose whether the current view shows both sides, bids only, or asks only. Please add a localized accessibilityValue={{ text: ... }} derived from viewMode, and verify that its value changes as the control cycles. This lets VoiceOver and TalkBack announce the current state.
| "optionId": "volume", | ||
| "direction": "desc" | ||
| }, | ||
| "mode": "lite", |
There was a problem hiding this comment.
This comment applies to line 491 but since that line is not in the PR diff will include here.
mode and proLayoutPreferences are already defined at lines 532–540. JSON parsing silently keeps these later values, making the earlier definitions ineffective. Please retain one authoritative copy so fixture changes behave as written.
| > | ||
| {orderBook} | ||
| </Box> | ||
| {!isOrderBookCollapsed ? ( |
There was a problem hiding this comment.
Nonblocking followup: Collapsing the column unmounts PerpsProOrderBookPanel. On expansion, currency, metric, and view mode return to their defaults; grouping persists because it is stored separately. If resetting these session only choices is intentional for this task, please document that behavior. Otherwise, preserve them above this conditional boundary in a followup while still allowing the hidden subscriptions to disconnect.
Wire Android Modal back to close settings, announce view-mode state for a11y, drop duplicate PerpsController fixture keys, and document collapse remount behavior for session-only book preferences.
Resolve PerpsProMarketView to keep live order-book collapse wiring and main's Pro order-form order-type sheet.
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.
Reviewed by Cursor Bugbot for commit 2b9f53c. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
⚡ Performance Test Results
❌ 4 tests failed · 20 tests · 1 device 📱 Devices tested (1)Android: Google Pixel 8 Pro (v14.0) ❌ Failed Tests (4)@swap-bridge-dev-team
@mm-perps-engineering-team
@metamask-onboarding-team
✅ Passed Tests (16)
Branch: |




Description
Adds a live order book to the Perps Pro market screen (
PerpsProOrderBookPanel), matching Extension’s dual-stream approach:PerpsController.subscribeToOrderBook(mid price + spread)AggregatedOrderBookConnectionso server-sidenSigFigsgrouping does not clobber the shared socketAlso includes:
Modal(avoids clipping in the narrow order-book column)@metamask/perps-controllerto^10.0.0(npm) forAggregatedOrderBookConnectionmodeandproLayoutPreferencesChangelog
CHANGELOG entry: Added a live order book to the Perps Pro market view
Related issues
Refs: https://consensyssoftware.atlassian.net/browse/TAT-3579
Manual testing steps
Screenshots/Recordings
N/A — UI verified on iOS simulator during development; attach before/after screenshots before ready-for-review if desired.
Before
After
N/A (pending attached device screenshots of live ladder, settings sheet, and collapse)
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
New real-time WebSocket subscriptions and a major perps-controller bump affect trading UI reliability; scope is mostly Pro perps UI with solid test coverage.
Overview
Replaces the Pro market order book placeholder with a live ladder wired like Extension: raw mid/spread on
PerpsController.subscribeToOrderBook, plus a server-aggregated stream on a new mobileAggregatedOrderBookConnectionsingleton so grouping does not affect the shared socket.usePerpsLiveOrderBookgains anorderBookAggregatedchannel withconnectionStatusandreconnect.The panel adds depth bars, spread, buy/sell ratio, view-mode cycling, loading skeleton, reconnect on errors, and a Modal-wrapped settings sheet (currency, metric, grouping with per-market persistence). Collapse/expand hides the right column, unmounts the book (drops live subscriptions), and widens the order form; route price is parsed as a grouping fallback.
Also bumps
@metamask/perps-controllerto ^10.0.0, extendsorderBookGroupinghelpers, new i18n strings, test IDs, and test/fixture updates for Pro layout state.Reviewed by Cursor Bugbot for commit 2b9f53c. Bugbot is set up for automated code reviews on this repo. Configure here.