[pull] main from MetaMask:main#371
Merged
Merged
Conversation
## **Description**
Improves the Perps order book view with several UX fixes:
1. **Consistent row count across groupings** - Uses Hyperliquid API's
`nSigFigs` and `mantissa` parameters for server-side price aggregation,
ensuring ~20 rows display regardless of selected price grouping
2. **Persisted price grouping** - Order book price grouping selection is
now persisted per asset in the PerpsController state
3. **Improved header** - Replaced generic "Order Book" title with
`PerpsMarketHeader` component showing asset icon, live price, and
leverage badge (consistent with other perps views)
4. **Spread tooltip** - Added info icon next to spread value with
explanation tooltip
### How nSigFigs + mantissa Works (Hyperliquid API)
The API's `nSigFigs` (2-5) and `mantissa` (2 or 5, when nSigFigs=5)
parameters control price aggregation granularity. For BTC at ~$90k:
| Grouping | API Parameters | Price Increment |
|----------|---------------|-----------------|
| $1-2 | `nSigFigs: 5, mantissa: 2` | ~$1-2 |
| $5 | `nSigFigs: 5, mantissa: 5` | ~$5 |
| $10 | `nSigFigs: 4` | ~$10 |
| $100 | `nSigFigs: 3` | ~$100 |
| $1000 | `nSigFigs: 2` | ~$1000 |
The `mantissa` parameter is only applicable when `nSigFigs` is 5,
enabling finer control at the finest aggregation levels. By dynamically
mapping the user's selected grouping to the appropriate parameters, each
grouping level displays a consistent ~20 rows.
## **Changelog**
CHANGELOG entry: Fixed order book display to show consistent number of
rows across all price groupings
## **Related issues**
Fixes: TAT-2164, TAT-2174, TAT-2175
## **Manual testing steps**
```gherkin
Feature: Order Book Price Grouping
Scenario: User changes price grouping
Given the user is on the order book view for BTC
When user taps the grouping dropdown and selects "$100"
Then the order book displays ~20 rows at $100 increments
And the grouping selection persists when navigating away and back
Scenario: Consistent row count
Given the user is on the order book view for BTC
When user cycles through different grouping options ($1, $10, $100, $1000)
Then each grouping displays approximately 20 rows
Scenario: User taps spread info icon
Given the user is on the order book view
When user taps the info icon next to the spread value
Then a tooltip appears explaining what spread means
```
## **Screenshots/Recordings**
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Switches order book to server-side aggregation (dynamic
nSigFigs/mantissa), persists grouping per asset, adds market
header/controls and spread tooltip, and updates services/types/tests.
>
> - **Order Book Data & Aggregation**:
> - Replace client-side aggregation with server-side via `nSigFigs` +
`mantissa`; request `MAX_ORDER_BOOK_LEVELS` (`20`).
> - Add `calculateAggregationParams` and use dynamic params from market
price/grouping.
> - Update `HyperLiquidSubscriptionService.subscribeToOrderBook` and
types to accept `mantissa` and stricter `nSigFigs`.
> - **State & Persistence**:
> - Persist per-asset grouping in `PerpsController`
(`getOrderBookGrouping`/`saveOrderBookGrouping`) and selectors
(`selectOrderBookGrouping`).
> - New hook `usePerpsOrderBookGrouping` to read/save grouping.
> - **UI/UX**:
> - `PerpsOrderBookView`: add `PerpsMarketHeader`, controls row (unit
toggle + grouping), tooltip modal for spread, and server-side data
wiring.
> - `PerpsBottomSheetTooltip`: add `spread` content key and locale
strings.
> - `PerpsOrderBookDepthChart`: remove mid-price line/label; show only
min/max labels; style cleanup.
> - `PerpsOrderBookTable`: compact large USD totals (`K/M`), smaller
text, padding tweaks.
> - Add E2E selectors for spread info and tooltip.
> - **Tests**:
> - Update/expand tests across view, chart, table, hooks, controller,
selectors, and utils to reflect new aggregation, params, UI, and
persistence.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
43b0cad. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
update hyperliquid sdk 0.27.1
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry:
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Update Hyperliquid SDK to 0.27.1 and refresh lockfile dependencies.
>
> - **Dependencies**:
> - Bump `@nktkas/hyperliquid` to `^0.27.1` in `package.json` and
`yarn.lock`.
> - Lockfile updates:
> - Add `@nktkas/rews`; upgrade `valibot` to `1.2.0`.
> - Remove transitive deps `@msgpack/msgpack` and
`typescript-event-target`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0f4182c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Extend season end date to make e2e pass
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Extends mocked rewards season end dates to 2026-03-31 across e2e
rewards mocks to keep tests valid.
>
> - **e2e rewards mocks**:
> - Update `endDate` to `2026-03-31` in
`SEASON_STATUS_RESPONSE_ONBOARDING`, `SEASON_STATUS_RESPONSE`, and
season metadata mock (`/public/seasons/:id/meta`).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6ef8f31. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
…sing (#23513) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Add automatic polling mechanism to usePredictEligibility hook that refreshes eligibility when no country is returned in the response. Changes: - Add sequential polling pattern (wait for response → wait interval → poll again) - Poll every 2 seconds until country is returned or component unmounts - Continue polling even if individual requests fail - Stop polling automatically when country becomes available - Add comprehensive tests for the new polling behavior This ensures users get their country data even if the initial eligibility check doesn't return it, improving the reliability of the Predict feature's geo-restriction handling. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds sequential auto-refresh polling to `usePredictEligibility` when `country` is missing, reduces debounce to 100ms, and updates tests accordingly. > > - **Predict Eligibility Hook (`usePredictEligibility`)**: > - Adds sequential auto-refresh polling when `eligibility[providerId].country` is missing. > - Polls every `2000ms` up to `3` retries; stops on country availability or unmount; logs failures and retry limits. > - Introduces `useRef` to stabilize `refreshEligibility` in effects. > - Reduces debounce interval to `100ms` for automatic refreshes. > - **Tests (`usePredictEligibility.test.ts`)**: > - Update debounce expectations to `100ms` and related timings. > - Add comprehensive tests for missing-country polling: start/interval, max retries, error handling, cleanup on unmount, and sequential polling behavior. > - Ensure scenarios for app state transitions, race prevention, manual refresh, and error logging reflect new timings and polling logic. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9ad7a9c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )