Skip to content

fix: align perps advanced chart price precision#32913

Open
geositta wants to merge 6 commits into
mainfrom
perps/fix-adv-charts-y-axis
Open

fix: align perps advanced chart price precision#32913
geositta wants to merge 6 commits into
mainfrom
perps/fix-adv-charts-y-axis

Conversation

@geositta

@geositta geositta commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

This PR aligns Perps Advanced Charts price precision with the existing Lightweight Charts behavior, especially for markets with very small prices like PEPE and market specific price precision like LIT. Advanced Charts now receives Perps market precision from Hyperliquid szDecimals, uses that precision for price scale labels and price pills, and resolves Perps symbols with enough internal price scale precision for tiny-price assets. Auto-close TP/SL labels also use market-aware Perps price formatting so values like SL $2.1946 are preserved instead of being rounded to two decimals.

Changelog

CHANGELOG entry: Fixed Y-axis labels and price pill parity on perps Advanced Charts

Related issues

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

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

Before

After

Simulator Screenshot - iPhone 17 Pro - 2026-07-07 at 14 29 49 Simulator Screenshot - iPhone 17 Pro - 2026-07-07 at 14 30 04

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.

Note

Medium Risk
Touches shared Advanced Chart WebView logic and Perps market-details display; behavior is opt-in via priceDecimals/szDecimals with broad test coverage and no auth or payment paths.

Overview
Perps Advanced Charts now match Lightweight Charts and Hyperliquid price rules by threading market szDecimals into priceDecimals (6 - szDecimals) on AdvancedChart, including Y-axis labels, last-price pills, and symbol pricescale / variable_tick_size when precision is configured.

AdvancedChart gains an optional priceDecimals prop baked into WebView CONFIG; the WebView applies custom price formatters (alongside existing subscript notation) and a perps-oriented tick ladder for tiny and large prices.

Perps UI forwards szDecimals from market details to PerpsAdvancedChart and PerpsPositionCard. Auto-close TP/SL copy switches from generic fiat rounding to formatPerpsPrice so values like $2.1946 are not collapsed to two decimals.

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

@github-actions

github-actions Bot commented Jul 7, 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.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-perps Perps team label Jul 7, 2026
@mm-token-exchange-service

mm-token-exchange-service Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Manual testing steps still contain template content (the Gherkin example title or a [...] placeholder). Replace with real steps, or write N/A — <reason>.
  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions github-actions Bot added the size-M label Jul 7, 2026
@geositta geositta force-pushed the perps/fix-adv-charts-y-axis branch from 7067a9d to 1f2dee3 Compare July 7, 2026 19:57
@geositta geositta marked this pull request as ready for review July 7, 2026 21:02
@geositta geositta requested a review from a team as a code owner July 7, 2026 21:02
@geositta geositta force-pushed the perps/fix-adv-charts-y-axis branch from 2b9d13b to 8367052 Compare July 7, 2026 21:02
Comment thread app/components/UI/Charts/AdvancedChart/__tests__/AdvancedChart.test.tsx Outdated
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jul 7, 2026
@geositta geositta force-pushed the perps/fix-adv-charts-y-axis branch from dd66bd7 to 53845f9 Compare July 8, 2026 00:01
@geositta geositta force-pushed the perps/fix-adv-charts-y-axis branch from 53845f9 to eabc62a Compare July 8, 2026 01:09
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 15 changed files are within the Perps feature area and the shared AdvancedChart component:

  1. Perps price precision feature: The PR adds szDecimals (Hyperliquid size decimals) propagation from PerpsMarketDetailsViewPerpsAdvancedChart and PerpsPositionCard. This drives a new priceDecimals prop in the chart and a new formatPerpsPrice() utility for TP/SL display.

  2. AdvancedChart changes: New priceDecimals prop added to AdvancedChartProps, AdvancedChartTemplate, and the WebView chart logic (chartLogic.js/chartLogicString.ts). New functions getConfiguredPriceDecimals(), formatPriceWithConfiguredDecimals(), PERPS_VARIABLE_TICK_SIZE, getPriceScale(), getVariableTickSize() affect chart price scale and tick size when priceDecimals is configured. The priceDecimals prop is optional and defaults to null, so non-Perps chart usage (Predictions, Tokens) is unaffected.

  3. formatUtils.ts: New formatPerpsPrice() function using formatHyperLiquidPrice from @metamask/perps-controller for accurate Hyperliquid price precision.

Tag selection rationale:

  • SmokePerps: Directly tests Perps functionality including market details view, position cards, and chart display — all directly modified.
  • SmokeWalletPlatform: Per tag description, Perps is a section inside the Trending tab; changes to Perps views (PerpsMarketDetailsView, PerpsPositionCard) affect Trending.
  • SmokeConfirmations: Per SmokePerps tag description, "Add Funds deposits are on-chain transactions — when selecting SmokePerps, also select SmokeConfirmations."

No changes to core Engine, controllers, navigation, browser, accounts, swaps, staking, or other unrelated areas.

Performance Test Selection:
The PerpsMarketDetailsView and PerpsAdvancedChart are directly modified with new price formatting logic and chart configuration changes (new tick size arrays, price scale computation). The @PerformancePreps tag covers perps market loading and position management, which includes the market details view. While the changes are primarily display/formatting improvements, the chart WebView logic changes (new PERPS_VARIABLE_TICK_SIZE, getPriceScale, getVariableTickSize) could affect chart rendering performance in the perps market details view. Conservatively selecting this tag to validate no performance regression.

View GitHub Actions results

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 eabc62a. Configure here.

}
let configuredPriceDecimals = getConfiguredPriceDecimals();
if (configuredPriceDecimals !== null) {
return formatPriceWithConfiguredDecimals(p, configuredPriceDecimals);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chart subscript diverges TP labels

Medium Severity

With perps priceDecimals enabled, the Advanced Chart custom formatter still prefers subscript notation for very small prices before market-aware decimals run. Auto-close TP/SL now uses formatPerpsPrice / Hyperliquid formatting without subscript. Y-axis and price pills can disagree with TP/SL text on tiny-price markets like PEPE.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit eabc62a. Configure here.

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
64.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

All tests passed · 2 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

✅ Passed Tests (2)
Test Platform Device Duration Team Recording
Perps add funds Android Google Pixel 8 Pro (v14.0) 9.11s @mm-perps-engineering-team 📹 Watch
Perps open position and close it Android Google Pixel 8 Pro (v14.0) 16.76s @mm-perps-engineering-team 📹 Watch

Branch: perps/fix-adv-charts-y-axis · Build: Normal · Commit: 2d2f214 · View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:medium AI analysis: medium risk size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants