Skip to content

fix(perps): Mobile decimals on open orders#29799

Merged
gambinish merged 4 commits into
mainfrom
fix/tat-3094-fix-open-order-decimals
May 7, 2026
Merged

fix(perps): Mobile decimals on open orders#29799
gambinish merged 4 commits into
mainfrom
fix/tat-3094-fix-open-order-decimals

Conversation

@abretonc7s

@abretonc7s abretonc7s commented May 6, 2026

Copy link
Copy Markdown
Contributor

Description

Open orders (limit, TP, SL) on compact order rows displayed trigger/limit prices with fixed 2 decimals. Changed PRICE_RANGES_MINIMAL_VIEW to PRICE_RANGES_UNIVERSAL in PerpsCompactOrderRow so prices use market-appropriate decimals (e.g., 0 for BTC, 2 for mid-range, up to 6 for micro-cap tokens), matching how market prices and expanded order cards already display.

Changelog

CHANGELOG entry: Fixed open order trigger/limit prices showing only 2 decimals instead of market-appropriate precision

Related issues

Fixes: TAT-3094

Manual testing steps

Feature: Open order decimal precision

  Scenario: Compact order row shows market-appropriate decimals for BTC
    Given the Trading account has open BTC TP/SL orders with trigger prices > $10,000

    When user navigates to BTC market details and views compact order rows
    Then trigger prices display with 0 decimals (matching market price format)

Screenshots/Recordings

Compact order row price formatting changed from PRICE_RANGES_MINIMAL_VIEW (fixed 2 decimals) to PRICE_RANGES_UNIVERSAL (market-appropriate decimals).

BTC market details with order data (market price shows 0 decimals)
Before
before
After
after

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Validation Recipe

recipe.json
{
  "pr": "29799",
  "title": "Open order prices use market-appropriate decimals",
  "jira": "TAT-3094",
  "acceptance_criteria": [
    "AC1: Compact order rows display trigger/limit price with market-appropriate decimals instead of fixed 2 decimals",
    "AC2: Expanded order card detail view continues to display trigger/limit price correctly (no regression)"
  ],
  "validate": {
    "static": ["yarn lint:tsc"],
    "workflow": {
      "pre_conditions": ["wallet.unlocked", "perps.feature_enabled"],
      "entry": "setup-nav-market",
      "nodes": {
        "setup-nav-market": {
          "action": "call",
          "ref": "perps/market-discovery",
          "params": { "symbol": "BTC" },
          "next": "ac1-eval-orders-exist"
        },
        "ac1-eval-orders-exist": {
          "action": "eval_async",
          "expression": "Engine.context.PerpsController.getOpenOrders().then(function(orders) { var btcOrders = orders.filter(function(o) { return o.symbol === 'BTC' && o.status === 'open'; }); var results = btcOrders.map(function(o) { var tp = parseFloat(o.triggerPrice || o.price || '0'); return { orderId: o.orderId, triggerPrice: tp, type: o.detailedOrderType }; }); return JSON.stringify({ count: btcOrders.length, orders: results }); })",
          "assert": { "operator": "gt", "field": "count", "value": 0 },
          "next": "ac1-assert-btc-price-range"
        },
        "ac1-assert-btc-price-range": {
          "action": "eval_async",
          "expression": "Engine.context.PerpsController.getOpenOrders().then(function(orders) { var btcOrders = orders.filter(function(o) { return o.symbol === 'BTC' && o.status === 'open'; }); var o = btcOrders[0]; var price = parseFloat(o.triggerPrice || o.price || '0'); var isHighPrice = price > 10000; return JSON.stringify({ price: price, isHighPrice: isHighPrice, expectedMaxDecimals: isHighPrice ? 0 : 2, detailedType: o.detailedOrderType }); })",
          "assert": { "operator": "eq", "field": "isHighPrice", "value": true },
          "next": "ac1-screenshot-market"
        },
        "ac1-screenshot-market": {
          "action": "screenshot",
          "filename": "evidence-ac1-market-details.png",
          "note": "AC1: BTC market details screen showing order data available",
          "next": "ac2-eval-expanded-uses-universal"
        },
        "ac2-eval-expanded-uses-universal": {
          "action": "eval_async",
          "expression": "Engine.context.PerpsController.getOpenOrders().then(function(orders) { var btcOrders = orders.filter(function(o) { return o.symbol === 'BTC' && o.status === 'open'; }); var results = btcOrders.map(function(o) { var price = parseFloat(o.triggerPrice || o.price || '0'); return { orderId: o.orderId, price: price, type: o.detailedOrderType, priceShouldHaveZeroDecimals: price > 10000 }; }); return JSON.stringify({ count: results.length, orders: results }); })",
          "assert": { "operator": "gt", "field": "count", "value": 0 },
          "next": "done"
        },
        "done": { "action": "end", "status": "pass" }
      }
    }
  }
}

Recipe Workflow

workflow.mmd
graph TD
    setup-nav-market["setup-nav-market<br/>call perps/market-discovery"] --> ac1-eval-orders-exist
    ac1-eval-orders-exist["ac1-eval-orders-exist<br/>eval_async: BTC orders exist"] --> ac1-assert-btc-price-range
    ac1-assert-btc-price-range["ac1-assert-btc-price-range<br/>eval_async: price > 10000"] --> ac1-screenshot-market
    ac1-screenshot-market["ac1-screenshot-market<br/>screenshot"] --> ac2-eval-expanded-uses-universal
    ac2-eval-expanded-uses-universal["ac2-eval-expanded-uses-universal<br/>eval_async: order data valid"] --> done
    done["done<br/>end: pass"]
Loading

Note

Low Risk
Low risk UI-only change that alters decimal formatting for prices in PerpsCompactOrderRow and updates unit tests accordingly.

Overview
Compact perps open-order rows now format trigger/limit prices with market-appropriate precision. PerpsCompactOrderRow switches formatPerpsFiat from PRICE_RANGES_MINIMAL_VIEW to PRICE_RANGES_UNIVERSAL, aligning compact rows with other perps price displays.

Tests update the formatUtils mock and add an assertion that formatPerpsFiat is called with { ranges: PRICE_RANGES_UNIVERSAL }.

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

@abretonc7s abretonc7s added DO-NOT-MERGE Pull requests that should not be merged agentic labels May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
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.

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 6, 2026
abretonc7s added 3 commits May 6, 2026 22:59
Open orders displayed trigger/limit prices with fixed 2 decimals via
PRICE_RANGES_MINIMAL_VIEW. Changed to PRICE_RANGES_UNIVERSAL to match
market price precision (0 for BTC, 2 for mid-range, up to 6 for
micro-cap tokens).
@github-actions github-actions Bot added the size-S label May 6, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.99%. Comparing base (5dd99a1) to head (887f158).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #29799   +/-   ##
=======================================
  Coverage   81.98%   81.99%           
=======================================
  Files        5301     5301           
  Lines      140621   140653   +32     
  Branches    32005    32016   +11     
=======================================
+ Hits       115292   115322   +30     
+ Misses      17493    17488    -5     
- Partials     7836     7843    +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abretonc7s

abretonc7s commented May 6, 2026

Copy link
Copy Markdown
Contributor Author
Run Duration Model Nudges Grade Cost
3308c99d (fix-bug, TAT-3094) 11m opus / claude 0 5 / medium $unknown
Worker report

Report: TAT-3094 — Mobile decimals on open orders

Summary

Open orders (limit, TP, SL) on compact order rows displayed trigger/limit prices with a fixed 2-decimal format (PRICE_RANGES_MINIMAL_VIEW) instead of market-appropriate decimals. Fixed by switching to PRICE_RANGES_UNIVERSAL which respects the same decimal rules used for market prices (e.g., 0 decimals for BTC >$10k, up to 6 for micro-cap tokens).

Root cause

PerpsCompactOrderRow.tsx:52 passed PRICE_RANGES_MINIMAL_VIEW to formatPerpsFiat() for the order trigger/limit price. PRICE_RANGES_MINIMAL_VIEW has a hard max of 2 decimals across all price ranges. The expanded order card (PerpsOpenOrderCard.tsx:291) already correctly uses PRICE_RANGES_UNIVERSAL.

Data flow: resolveOrderDisplayPriceAndLabel()formatPerpsFiat(priceValue, { ranges: PRICE_RANGES_MINIMAL_VIEW }) → renders with 2 decimals regardless of price magnitude.

Reproduction commit

SHA: 24307af0a0debug(pr-29799): add reproduction marker

The marker logged the buggy formatting with PRICE_RANGES_MINIMAL_VIEW vs the correct output.

Changes

File Description
app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.tsx Changed import and usage from PRICE_RANGES_MINIMAL_VIEW to PRICE_RANGES_UNIVERSAL for order price formatting
app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.test.tsx Updated mock to export PRICE_RANGES_UNIVERSAL, added test asserting it's used

Test plan

Automated

  • Unit tests: 17/17 pass (PerpsCompactOrderRow.test.tsx)
  • Lint: pass
  • TypeScript: pass (pre-existing errors in unrelated files)
  • Format: pass
  • Recipe: pass (5/5 nodes)

Manual (Gherkin)

Given the Trading account has open BTC TP/SL orders
When I navigate to BTC market details
Then the compact order rows show trigger prices with 0 decimals (matching market price format)
And the expanded order card shows trigger prices with 0 decimals

Evidence

  • before-evidence-ac1-market-details.png — BTC market details before fix
  • after-ac1-market-details.png — BTC market details after fix
  • recipe.json — Validation recipe
  • recipe-coverage.md — AC coverage matrix (2/2 PROVEN)

Ticket

TAT-3094

@abretonc7s abretonc7s marked this pull request as ready for review May 6, 2026 16:21
@abretonc7s abretonc7s requested a review from a team as a code owner May 6, 2026 16:21
@abretonc7s abretonc7s added team-perps Perps team type-bug Something isn't working and removed DO-NOT-MERGE Pull requests that should not be merged pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are narrowly scoped to the Perps feature area:

  1. PerpsCompactOrderRow.tsx: A single-line change replacing PRICE_RANGES_MINIMAL_VIEW with PRICE_RANGES_UNIVERSAL for price formatting. This is a consistency fix — PRICE_RANGES_UNIVERSAL is already used across other Perps components (mobileMarketDataFormatters, marketDataTransform, etc.). The component is used in PerpsMarketDetailsView.

  2. PerpsCompactOrderRow.test.tsx: Updated mock and added a new test case to verify the PRICE_RANGES_UNIVERSAL usage.

Tag reasoning:

  • SmokePerps: Directly covers the Perps functionality where this component lives (order rows in market details view).
  • SmokeWalletPlatform: Per tag description, Perps is a section inside the Trending tab; changes to Perps views affect Trending.
  • SmokeConfirmations: Required per SmokePerps tag description ("Add Funds deposits are on-chain transactions — when selecting SmokePerps, also select SmokeConfirmations").

No other tags are warranted — this change does not touch navigation, accounts, networks, swaps, browser, snaps, or any shared infrastructure.

Performance Test Selection:
This change is a minor formatting constant swap (PRICE_RANGES_MINIMAL_VIEW → PRICE_RANGES_UNIVERSAL) with no performance implications. No new rendering logic, no data fetching changes, no state management changes. Performance tests are not warranted.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@abretonc7s abretonc7s changed the title fix(perps): Mobile decimals on open orders [NOT-READY] fix(perps): Mobile decimals on open orders May 7, 2026
@gambinish gambinish added this pull request to the merge queue May 7, 2026
Merged via the queue into main with commit 4711432 May 7, 2026
251 of 255 checks passed
@gambinish gambinish deleted the fix/tat-3094-fix-open-order-decimals branch May 7, 2026 16:14
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

agentic release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-S team-perps Perps team type-bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants