Skip to content

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

Closed
abretonc7s wants to merge 6 commits into
mainfrom
fix/tat-3094-fix-open-order-decimals
Closed

fix(perps): Mobile decimals on open orders #29770
abretonc7s wants to merge 6 commits into
mainfrom
fix/tat-3094-fix-open-order-decimals

Conversation

@abretonc7s
Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s commented May 5, 2026

written, 10221 bytes, replacements=1
r and limit prices now use the same market-price precision rules as Perps market prices. This fixes low-priced markets such as CHIP showing rounded two-decimal prices in compact open-order rows and order details, while leaving USD notional values and fees on fiat formatting.

Self-review follow-up added explicit trigger-condition interpolation coverage for the $0.001234 formatting path and clarified the executable recipe scope.

Changelog

CHANGELOG entry: Fixed open order trigger and limit prices to display the correct market decimal precision.

Related issues

Fixes: TAT-3094

Manual testing steps

Feature: Open order price precision

  Scenario: Low-priced market limit order details use market precision
    Given the wallet is unlocked and Perps are available
    When a CHIP limit order with price "0.001234" is opened in order details
    Then the Price row displays "$0.001234"
    And the Order value row may still display fiat notional precision such as "$0.12"

  Scenario: Compact open order rows use market precision
    Given the wallet has an open limit, take-profit, or stop-loss order
    When the order is shown in a compact order row
    Then the trigger or limit price uses the same decimal precision as the market price

Additional automated coverage:

  • PerpsOrderDetailsView.test.tsx asserts the trigger-condition translation receives price: '$0.001234'.
  • PerpsCompactOrderRow.test.tsx asserts compact order rows pass universal price ranges to the formatter.

Screenshots/Recordings

CHIP open order details display the six-decimal trigger/limit price using market precision.

Before · AC1 · CHIP order details
Before — CHIP order details limit price precision
After · AC1 · CHIP order details
After — CHIP order details six-decimal limit price

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": "29770",
  "title": "Mobile decimals on open orders",
  "jira": "TAT-3094",
  "acceptance_criteria": [
    "Open orders (limit, TP, SL) on wallet home, perps home and perp market detail screens display the same number of decimals for trigger/limit price as the displayed market price (examples: 0 for BTC, 2 for CL, 6 for CHIP)."
  ],
  "coverage_notes": {
    "recipe_scope": "Executable recipe proves the low-priced CHIP limit-order details surface only, using the concrete value that failed before the fix.",
    "not_recipe_covered": [
      "Wallet home compact open-order row",
      "Perps home compact open-order row",
      "Market detail compact open-order row",
      "Take-profit trigger condition in order details",
      "Stop-loss trigger condition in order details"
    ],
    "non_recipe_evidence": [
      "PerpsCompactOrderRow.test.tsx asserts compact open-order price formatting passes PRICE_RANGES_UNIVERSAL.",
      "PerpsOrderDetailsView.test.tsx asserts limit, trigger-condition, take-profit, and stop-loss prices use universal-range formatted output."
    ]
  },
  "validate": {
    "workflow": {
      "pre_conditions": ["wallet.unlocked", "perps.feature_enabled"],
      "entry": "ac1-open-chip-order-details",
      "nodes": {
        "ac1-open-chip-order-details": {
          "action": "navigate",
          "target": "PerpsOrderDetailsView",
          "params": {
            "order": {
              "orderId": "recipe-chip-limit",
              "symbol": "CHIP",
              "side": "buy",
              "orderType": "limit",
              "size": "100",
              "originalSize": "100",
              "price": "0.001234",
              "filledSize": "0",
              "remainingSize": "100",
              "status": "open",
              "timestamp": 1777982726658,
              "detailedOrderType": "Limit",
              "isTrigger": false,
              "reduceOnly": false,
              "isPositionTpsl": false,
              "triggerPrice": "0"
            }
          },
          "next": "ac1-wait-order-details"
        },
        "ac1-wait-order-details": {
          "action": "wait_for",
          "route": "PerpsOrderDetailsView",
          "next": "ac1-assert-chip-limit-price"
        },
        "ac1-assert-chip-limit-price": {
          "action": "eval_sync",
          "expression": "(function(){var hook=globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;var out=[];function add(x){if(x===null||x===undefined)return;if(typeof x==='string'||typeof x==='number')out.push(String(x));else if(Array.isArray(x)){for(var i=0;i<x.length;i++)add(x[i]);}}function walk(f){if(!f)return;var p=f.memoizedProps;if(p)add(p.children);walk(f.child);walk(f.sibling);}if(!hook||!hook.getFiberRoots)return JSON.stringify({found:false,text:''});hook.renderers.forEach(function(v,id){var roots=hook.getFiberRoots(id);if(roots)roots.forEach(function(root){walk(root.current);});});var text=out.join('|');return JSON.stringify({found:text.indexOf('$0.001234')>=0,text:text});})()",
          "assert": {
            "operator": "eq",
            "field": "found",
            "value": true
          },
          "next": "ac1-screenshot-chip-order-details"
        },
        "ac1-screenshot-chip-order-details": {
          "action": "screenshot",
          "filename": "evidence-ac1-chip-order-details.png",
          "note": "AC1: CHIP order details renders six-decimal limit price $0.001234",
          "next": "ac1-done"
        },
        "ac1-done": {
          "action": "end",
          "status": "pass"
        }
      }
    }
  }
}

Recipe Workflow

workflow.mmd
flowchart TD
  %% Mobile decimals on open orders
  __entry__(["ENTRY"]) --> node_ac1_open_chip_order_details
  node_ac1_open_chip_order_details["ac1-open-chip-order-details<br/>navigate"]
  node_ac1_wait_order_details["ac1-wait-order-details<br/>wait_for"]
  node_ac1_assert_chip_limit_price["ac1-assert-chip-limit-price<br/>eval_sync"]
  node_ac1_screenshot_chip_order_details["ac1-screenshot-chip-order-details<br/>screenshot"]
  node_ac1_done(["ac1-done<br/>PASS"])
  node_ac1_open_chip_order_details --> node_ac1_wait_order_details
  node_ac1_wait_order_details --> node_ac1_assert_chip_limit_price
  node_ac1_assert_chip_limit_price --> node_ac1_screenshot_chip_order_details
  node_ac1_screenshot_chip_order_details --> node_ac1_done
Loading

Note

Low Risk
Low risk UI-formatting change that only affects how perps open-order prices (limit/trigger/TP/SL) are displayed; no changes to order logic, execution, or fee/notional calculations.

Overview
Updates perps open-order displays to format limit and trigger-derived prices using PRICE_RANGES_UNIVERSAL, matching market price precision for low-priced markets (e.g., CHIP) in both PerpsOrderDetailsView and PerpsCompactOrderRow.

Extends tests to cover the new precision path, including explicit assertions for six-decimal limit prices and correct trigger-condition string interpolation with the universally-formatted price, plus updated expectations for TP/SL rows.

Reviewed by Cursor Bugbot for commit 1802b06. 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 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

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.

@metamaskbotv2 metamaskbotv2 Bot added the team-perps Perps team label May 5, 2026
abretonc7s added 3 commits May 6, 2026 07:51
Open-order trigger and limit prices need to match the decimal precision used for market prices, so compact rows and order details now use the universal Perps price ranges while notional values stay on fiat formatting.

Constraint: Order value and fee rows remain USD fiat values and should not use market-price precision
Rejected: Change formatPerpsFiat defaults globally | broader display risk outside open-order prices
Confidence: high
Scope-risk: narrow
Tested: yarn lint && NODE_OPTIONS='--max-old-space-size=8192' yarn lint:tsc && yarn format:check
Tested: yarn jest app/components/UI/Perps/Views/PerpsOrderDetailsView/PerpsOrderDetailsView.test.tsx app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.test.tsx --no-coverage
Tested: bash scripts/perps/agentic/validate-recipe.sh .task/fix/tat-3094-0506-073600/artifacts/ --skip-manual
Not-tested: Android device run
@github-actions github-actions Bot added the size-S label May 6, 2026
@abretonc7s
Copy link
Copy Markdown
Contributor Author

Run Duration Model Nudges Grade Cost
1344ff21 2m gpt-5.5 0 medium / 5 $unknown
Worker report

TAT-3094 Report

Summary

Open order trigger and limit prices were using compact/default fiat precision, so low-priced markets such as CHIP rounded to two decimals in compact rows and order details. The fix routes open-order price fields through the same universal price ranges used by market prices while leaving notional value and fee formatting unchanged.

Root Cause

Market prices are transformed with PRICE_RANGES_UNIVERSAL in app/controllers/perps/utils/marketDataTransform.ts, but open-order UI used different formatting paths:

  • app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.tsx:51 formatted the order price with compact/minimal ranges.
  • app/components/UI/Perps/Views/PerpsOrderDetailsView/PerpsOrderDetailsView.tsx:135, :141, :183, and :188 formatted limit, trigger, take-profit, and stop-loss prices with universal ranges only after this fix.

Order value continues to use default fiat formatting because it is a USD notional value, not a market trigger/limit price.

Changes

  • PerpsCompactOrderRow.tsx formats compact open-order prices with PRICE_RANGES_UNIVERSAL.
  • PerpsOrderDetailsView.tsx formats limit, trigger, TP, and SL prices with PRICE_RANGES_UNIVERSAL.
  • Added/updated Jest coverage for CHIP six-decimal detail view, compact rows, trigger, TP, and SL expectations.
  • Kept existing typecheck fixes localized in PerpsController.ts and rewards/index.ts.

Test Plan

Automated:

  • yarn lint && NODE_OPTIONS='--max-old-space-size=8192' yarn lint:tsc && yarn format:check — passed; lint emitted existing repository warnings.
  • yarn jest app/components/UI/Perps/Views/PerpsOrderDetailsView/PerpsOrderDetailsView.test.tsx app/components/UI/Perps/components/PerpsCompactOrderRow/PerpsCompactOrderRow.test.tsx --no-coverage — passed, 2 suites / 44 tests.
  • yarn coverage:analyze — passed.
  • bash scripts/perps/agentic/validate-recipe.sh .task/fix/tat-3094-0506-073600/artifacts/ --skip-manual — passed 4/4 recipe nodes.

Evidence

  • .task/fix/tat-3094-0506-073600/artifacts/before.mp4
  • .task/fix/tat-3094-0506-073600/artifacts/after.mp4
  • .task/fix/tat-3094-0506-073600/artifacts/after-ac1-chip-order-details.png
  • .task/fix/tat-3094-0506-073600/artifacts/recipe.json
  • .task/fix/tat-3094-0506-073600/artifacts/summary.json
  • .task/fix/tat-3094-0506-073600/artifacts/trace.json

Ticket

TAT-3094: https://consensyssoftware.atlassian.net/browse/TAT-3094

Recipe workflow diagram
flowchart TD
  %% Mobile decimals on open orders
  __entry__(["ENTRY"]) --> node_ac1_open_chip_order_details
  node_ac1_open_chip_order_details["ac1-open-chip-order-details<br/>navigate"]
  node_ac1_wait_order_details["ac1-wait-order-details<br/>wait_for"]
  node_ac1_assert_chip_limit_price["ac1-assert-chip-limit-price<br/>eval_sync"]
  node_ac1_screenshot_chip_order_details["ac1-screenshot-chip-order-details<br/>screenshot"]
  node_ac1_done(["ac1-done<br/>PASS"])
  node_ac1_open_chip_order_details --> node_ac1_wait_order_details
  node_ac1_wait_order_details --> node_ac1_assert_chip_limit_price
  node_ac1_assert_chip_limit_price --> node_ac1_screenshot_chip_order_details
  node_ac1_screenshot_chip_order_details --> node_ac1_done
Loading

@abretonc7s abretonc7s marked this pull request as ready for review May 6, 2026 00:56
@abretonc7s abretonc7s requested review from a team as code owners May 6, 2026 00:56
The prior branch included unrelated typecheck workarounds in controller and rewards files. Typecheck passes without them, so this removes those changes from the PR and leaves only the open-order decimal fix plus targeted tests.

Constraint: PR should address TAT-3094 without unrelated controller or rewards churn
Rejected: Keep ambient typecheck cleanups in this PR | they are not required for the decimal bug and make review harder
Confidence: high
Scope-risk: narrow
Directive: Keep future TAT-3094 edits limited to Perps open-order price formatting unless validation proves broader changes are necessary
Tested: NODE_OPTIONS='--max-old-space-size=8192' npx tsc --noEmit --incremental false --project ./tsconfig.json
Not-tested: Full unit test suite after scope-only cleanup
@metamaskbotv2 metamaskbotv2 Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are focused on Perps UI price formatting:

  1. PerpsCompactOrderRow.tsx: Switches from PRICE_RANGES_MINIMAL_VIEW to PRICE_RANGES_UNIVERSAL for price display in compact order rows. This ensures low-value token prices (e.g., $0.001234) are displayed with appropriate precision instead of being truncated.

  2. PerpsOrderDetailsView.tsx: Adds PRICE_RANGES_UNIVERSAL formatting to order price, trigger price, take profit price, and stop loss price fields. Previously these used default formatting or no ranges option.

  3. Test files: Updated unit tests to reflect the new PRICE_RANGES_UNIVERSAL formatting behavior.

These are purely UI formatting changes within the Perps feature area - no controller changes, no navigation changes, no shared component changes. The risk is low.

Tag selection rationale:

  • SmokePerps: Directly affected - PerpsCompactOrderRow and PerpsOrderDetailsView are core Perps UI components that display order information. The formatting change affects how prices appear in the order list and order details screens.
  • SmokeWalletPlatform: Per tag description, Perps is a section inside the Trending tab; changes to Perps views (headers, lists, full views) affect Trending. PerpsCompactOrderRow is used in order lists which are part of the Perps section embedded in Trending.

Tags NOT selected:

  • SmokeConfirmations: Not needed - these are order display components, not transaction confirmation flows
  • Other tags: No impact on other feature areas

Performance Test Selection:
The changes are purely UI price formatting changes within Perps order display components. Switching between price range constants (PRICE_RANGES_MINIMAL_VIEW to PRICE_RANGES_UNIVERSAL) is a trivial formatting operation with no meaningful performance impact. No performance tests are warranted.

View GitHub Actions results

@abretonc7s abretonc7s changed the title fix(perps): Mobile decimals on open orders [NOT-READY] fix(perps): Mobile decimals on open orders May 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@abretonc7s abretonc7s closed this May 6, 2026
@abretonc7s abretonc7s deleted the fix/tat-3094-fix-open-order-decimals branch May 6, 2026 14:38
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

agentic DO-NOT-MERGE Pull requests that should not be merged INVALID-PR-TEMPLATE PR's body doesn't match template size-S team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant