Skip to content

Conversation

@gambinish
Copy link
Contributor

@gambinish gambinish commented Oct 31, 2025

Description

Fixes incorrect search behavior from PerpsHomeView. We were handling two different search behaviors in PerpsHomeScree and PerpsMarketListView. Correct behavior is:

  1. When search icon is pressed on the PerpsHomeView, it need to navigate to the PerpsMarketListView with search enabled.

  2. On cancel, it should go back to the PerpsMarketListView

  3. When search icon is pressed from PerpsMarketListView, we enable search as is currently does

  4. When cancel is pressed it goes back to PerpsMarketListView

This PR removes the multi-dimensional search from the PerpsHomeScreen view and instead navigates to the MarketListView as per the latest designs.

Changelog

CHANGELOG entry: Fixes search behavior in PerpsHomeScreen

Related issues

Fixes:

Manual testing steps

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

Screen.Recording.2025-10-31.at.10.08.42.AM.mov

Pre-merge author checklist

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.

Note

PerpsHomeView now navigates to PerpsMarketListView with search pre-opened on search tap, with minor header padding tweak, a new navigation param, and updated tests.

  • Perps Home → Market List navigation
    • Replace in-place search in PerpsHomeView with navigation to PerpsMarketListView via usePerpsNavigation.navigateToMarketList({ defaultSearchVisible: true, source: 'homescreen_tab', fromHome: true }).
    • Remove local search state and filtering from PerpsHomeView; call usePerpsHomeData({}).
    • Header in PerpsHomeHeader is always rendered with isSearchVisible: false on Home.
  • Market List search handling
    • Refactor handleSearchToggle in PerpsMarketListView to useCallback; clears query on close and tracks event on open.
  • Header UI tweak
    • PerpsMarketListHeader: add Platform-specific padding for the search bar (py-3 iOS, py-1 Android); import Platform. Mark onSearchClear as unused.
  • Navigation types
    • Add fromHome?: boolean to PerpsNavigationParamList['PerpsMarketListView'].
  • Tests
    • PerpsHomeView.test.tsx: mock navigateToMarketList and assert navigation with { defaultSearchVisible: true, source: 'homescreen_tab', fromHome: true }; remove assertions about HomeView search bar visibility; minor setup/mocks cleanup.

Written by Cursor Bugbot for commit 8218306. This will update automatically on new commits. Configure here.

abretonc7s and others added 7 commits October 31, 2025 16:44
## **Description**

This PR fixes an issue where HIP-3 markets (stocks and commodities) with
$0.00 volume were incorrectly displayed in the Market List View and Home
View.

**What was the problem?**
- Markets with zero or invalid volume data were showing up in the Stocks
and Commodities tabs
- This was inconsistent with how crypto perps markets behave (they
correctly hide zero-volume markets)

**What is the solution?**
- Zero-volume markets are now filtered out consistently across all
market types
- Filtering logic moved to the data layer for consistency
- Both Market List View and Home View now hide markets with $0.00 volume
by default

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1957

## **Manual testing steps**

```gherkin
Feature: Hide zero-volume HIP-3 markets

  Scenario: user views Market List View stocks tab
    Given app is running and Perps feature is enabled

    When user navigates to Market List View
    And user selects the "Stocks" tab
    Then user should only see stocks with valid volume data
    And user should NOT see any markets displaying "$0.00" volume

  Scenario: user views Market List View commodities tab
    Given app is running and Perps feature is enabled

    When user navigates to Market List View
    And user selects the "Commodities" tab
    Then user should only see commodities with valid volume data
    And user should NOT see any markets displaying "$0.00" volume

  Scenario: user views Perps Home View
    Given app is running and Perps feature is enabled

    When user navigates to Perps Home View
    Then user should only see markets with valid volume data in all carousels
    And user should NOT see any markets displaying "$0.00" volume
```

## **Screenshots/Recordings**

### **Before**

Markets with $0.00 volume were visible in the Stocks tab and other HIP-3
market tabs.

### **After**

Only markets with valid volume data are displayed. Zero-volume markets
are filtered out consistently.

## **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]
> Overhauls Perps Markets and Home with searchable/sortable tabs,
consistent zero‑volume filtering, bulk Close/Cancel All flows, market
hours banner/tooltip, refined leverage priority, and extensive hook/test
updates.
> 
> - **UI/Navigation**:
> - **Home**: New `PerpsHomeView` with positions/orders sections,
watchlist, market type sections, navigation card, and bottom sheets for
Close All/Cancel All.
> - **Market List**: Reworked `PerpsMarketListView` with tabs
(All/Crypto/Stocks & Commodities), search header, sorting/filters, and
reusable `PerpsMarketList`/row components.
> - **Bulk Actions**: Added
`PerpsCloseAllPositionsView`/`PerpsCancelAllOrdersView` and modal
variants; shared `PerpsCloseSummary`.
> - **Market Hours**: Added `PerpsMarketHoursBanner` and bottom-sheet
tooltip content.
> - **Hooks/Logic**:
> - **Data**: New `usePerpsHomeData`, `usePerpsMarketListView`,
`usePerpsSearch`, `usePerpsSorting`; consistent zero‑volume filtering
moved to `usePerpsMarkets` (opt‑in via `showZeroVolume`).
> - **Bulk Ops**: `usePerpsCloseAllCalculations`,
`usePerpsCloseAllPositions`, `usePerpsCancelAllOrders` for fees/points
and execution.
> - **Streams**: `usePerpsLiveFills` now returns `{ fills,
isInitialLoading }`.
> - **Orders**: Leverage priority: nav param > existing position > saved
config > default; validation accepts `existingPositionLeverage`.
> - **Routing/Styles/Locale**:
> - Wired Home and modal routes; various style tweaks; added i18n for
market hours.
> - **Tests**: Extensive new unit tests across views, hooks, components,
and styles.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c712e48. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
## **Description**

Implement 2x fee multiplier for HIP-3 (HyperLiquid Improvement Proposal
3) assets as per HyperLiquid protocol specification.

**What changed:**
- HIP-3 assets (identified by `dex:SYMBOL` format like `xyz:TSLA`) now
have 2x base exchange fees
- Regular assets (e.g., `BTC`, `ETH`) are unaffected

**Why:**
HyperLiquid protocol charges double base fees for builder-deployed
perpetuals (HIP-3 assets):
- Regular taker: 0.045% -> HIP-3 taker: 0.090%
- Regular maker: 0.015% -> HIP-3 maker: 0.030%

**How:**
Applied 2x multiplier to all three fee rate sources:
1. Base rates (when no user-specific rates available)
2. Cached user rates (from fee cache)
3. API-fetched user rates (from HyperLiquid API)

## **Changelog**

CHANGELOG entry: Fixed HIP-3 perpetuals to display correct 2x exchange
fees

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1950

## **Manual testing steps**

```gherkin
Feature: HIP-3 Fee Display

  Scenario: user views fees for HIP-3 asset
    Given user is on Perps trading screen

    When user selects a HIP-3 asset (e.g., "xyz:XYZ100")
    And user enters a trade amount
    Then fee modal should show provider fee ~0.086% (2x base rate)
    And total fee should be ~0.186% (provider + 0.1% MetaMask)

  Scenario: user views fees for regular asset
    Given user is on Perps trading screen

    When user selects a regular asset (e.g., "BTC")
    And user enters a trade amount
    Then fee modal should show provider fee ~0.043% (base rate)
    And total fee should be ~0.143% (provider + 0.1% MetaMask)
```

## **Screenshots/Recordings**

### **Before**
HIP-3 assets showed incorrect 0.043% provider fee (missing 2x
multiplier)
<img width="549" height="1061" alt="image"
src="https://github.com/user-attachments/assets/1394476a-e622-4e99-8889-a607cc93a609"
/>

### **After**
HIP-3 assets correctly show 0.086% provider fee (2x multiplier applied)
<img width="554" height="1151" alt="image"
src="https://github.com/user-attachments/assets/132e3609-ebd1-4a94-8778-a69783a445c8"
/>

## **Pre-merge author checklist**

- [x] I've followed MetaMask Contributor Docs and MetaMask Mobile Coding
Standards
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable (225 tests passing, added HIP-3
validation test)
- [x] I've documented my code using JSDoc format if applicable
- [x] I've applied the right labels on the PR

## **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

---

## **Technical Details**

**Files Modified:**
- `app/components/UI/Perps/controllers/types/index.ts` - Added `coin`
parameter to `FeeCalculationParams`
- `app/components/UI/Perps/controllers/providers/HyperLiquidProvider.ts`
- Applied HIP-3 2x multiplier to all rate sources
- `app/components/UI/Perps/controllers/PerpsController.ts` - Updated
method signature
- `app/components/UI/Perps/hooks/usePerpsOrderFees.ts` - Pass `coin`
parameter
- `app/components/UI/Perps/hooks/usePerpsCloseAllCalculations.ts` - Pass
`coin` parameter
- Test files - Updated all tests to pass `coin` parameter

**Test Coverage:**
- All existing tests passing (225/225)
- Added `hip3-fee-validation.test.ts` with 8 validation tests
- Verified HIP-3 detection logic
- Verified 2x multiplier application

**Key Implementation:**
```typescript
// Detect HIP-3 assets by colon separator
const { dex } = parseAssetName(coin); // "xyz:TSLA" -> dex="xyz"
const isHip3Asset = dex !== null;

// Apply 2x multiplier to all rate sources
if (isHip3Asset) {
  feeRate *= 2;
}
```

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Implements a 2× fee multiplier for HIP-3 (`dex:SYMBOL`) assets and
updates fee calculation to require `coin`, applying the multiplier
across base, cached, and API-fetched rates with comprehensive test
updates.
> 
> - **Fees/HIP-3**:
> - Add `HIP3_FEE_CONFIG` with `FEE_MULTIPLIER: 2` in
`constants/hyperLiquidConfig.ts`.
> - Apply 2× multiplier for HIP-3 assets (detected via
`parseAssetName(coin)`) in `HyperLiquidProvider.calculateFees()` for:
>     - Base rates
>     - Cached user rates
>     - API-fetched user rates
> - **API/Types**:
> - Make `coin` required in `FeeCalculationParams`
(`controllers/types`).
> - Update `PerpsController.calculateFees` signature to accept
`FeeCalculationParams` and forward to provider.
> - **Hooks/Usage**:
> - Pass `coin` to fee calc in `usePerpsOrderFees` and
`usePerpsCloseAllCalculations`.
> - **Tests**:
>   - Update all fee tests to include `coin`.
> - Add tests verifying 2× HIP-3 fees for taker/maker in
`HyperLiquidProvider.test.ts`.
> - Minor test cleanups (remove unused placeholders, add
`isFeeCacheValid` edge case).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d096fa9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@github-actions
Copy link
Contributor

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.

@gambinish gambinish changed the title Perps/home screen search nav fix: Navigation behavior from PerpsHomeScreenSearch Oct 31, 2025
@gambinish gambinish marked this pull request as ready for review October 31, 2025 17:23
@gambinish gambinish requested a review from a team as a code owner October 31, 2025 17:23
@gambinish gambinish added the team-perps Perps team label Oct 31, 2025
@nickewansmith nickewansmith self-requested a review October 31, 2025 19:39
@nickewansmith
Copy link
Contributor

Screenshot 2025-10-31 at 2 41 53 PM

There is a very small search input on ios

@nickewansmith
Copy link
Contributor

I am not sure if this would be fixed in this branch or not, but I am still seeing the intermittent switching of the filter tabs

https://www.loom.com/share/9de890196ccf4845bf3733bed1f7a401

@gambinish
Copy link
Contributor Author

gambinish commented Oct 31, 2025

I am not sure if this would be fixed in this branch or not, but I am still seeing the intermittent switching of the filter tabs

https://www.loom.com/share/9de890196ccf4845bf3733bed1f7a401

Hmm, this won't be fixed on this branch but ty for flagging. Likely a bugfix to track. Might be worth it to fit in if it's a scoped change

@gambinish
Copy link
Contributor Author

Thanks for catching this. Fixed in: 920460c

Screenshot 2025-10-31 at 1 55 15 PM Screenshot 2025-10-31 at 1 57 01 PM

@sonarqubecloud
Copy link

@nickewansmith nickewansmith added this pull request to the merge queue Oct 31, 2025
Merged via the queue into main with commit a975b43 Oct 31, 2025
87 checks passed
@nickewansmith nickewansmith deleted the perps/home-screen-search-nav branch October 31, 2025 22:44
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2025
@metamaskbot metamaskbot added the release-7.59.0 Issue or pull request that will be included in release 7.59.0 label Oct 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.59.0 Issue or pull request that will be included in release 7.59.0 size-S team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants