Skip to content

chore(runway): cherry-pick fix(predict): improve crypto up/down#30703

Merged
joaoloureirop merged 1 commit into
release/7.79.0from
cherry-pick-7-79-0-f24ef18
May 27, 2026
Merged

chore(runway): cherry-pick fix(predict): improve crypto up/down#30703
joaoloureirop merged 1 commit into
release/7.79.0from
cherry-pick-7-79-0-f24ef18

Conversation

@runway-github

@runway-github runway-github Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Description

Improves the crypto up/down market experience on the feed series card
and market details screen.

These changes are scoped to the existing crypto up/down work behind the
Predict up/down feature flag. They improve release quality for the
upcoming crypto up/down experience, where the current UX is unstable for
users, with minimal regression risk outside the gated feature.

This PR fixes several visible stability issues:

  • Prevents Up/Down CTA prices from briefly flickering to stale fallback
    prices while live CLOB price subscriptions remount or warm back up.
  • Uses a shared buy-price precedence for CTA labels: live WebSocket
    bestAsk → REST entry.buy → static market token price.
  • Keeps the details chart anchored to the currently live market so
    selecting a future time slot does not interrupt the BTC price stream.
  • Keeps the selected time slot independent from the chart market, so
    target price/actions can follow the selected slot while the chart
    remains continuous.
  • Preserves series data during transient series refetches so position
    rows and chart sizing do not jump during time-slot changes.
  • Keeps crypto up/down chart loading visible until the live chart has
    enough renderable points, avoiding a spinner → blank → chart transition.
  • Uses Polymarket event priceToBeat metadata as the target-line
    fallback for hourly/daily crypto up/down markets whose target price API
    can be unavailable.
  • Preserves the existing group item threshold fallback for crypto
    up/down markets that do not provide event priceToBeat metadata.
  • Improves crypto up/down chart rendering/loading behavior and bottom
    padding across larger chart heights/font scales.
  • Improves longer-duration countdown/reset copy for hourly/daily/weekly
    crypto up/down markets.
  • Keeps crypto up/down card routing behind the Predict up/down feature
    flag.

Changelog

CHANGELOG entry: null

Related issues

Fixes: N/A

Manual testing steps

Feature: Crypto up/down market experience

  Scenario: user views the crypto up/down series card while prices update
    Given the Predict up/down feature flag is enabled
    And a live crypto up/down market is visible in the Predict feed

    When live CLOB price updates are received for the Up and Down tokens
    Then the Up and Down CTA prices update from the live buy prices
    And the CTA prices do not briefly flicker to stale REST or static market prices

  Scenario: user opens crypto up/down market details and changes time slots
    Given the user is on a live crypto up/down market details screen
    And the market series includes a future time slot

    When user selects the future time slot
    Then the selected time slot updates
    And the chart remains anchored to the live market price stream
    And the Up and Down actions use the selected time slot market
    And the current price display remains stable while the target price loads

  Scenario: user waits for the crypto up/down chart to load
    Given the user is on a crypto up/down market details screen
    And live chart data has not produced at least two renderable points

    When the initial chart request finishes
    Then the chart loading state remains visible
    And the screen does not briefly show an empty chart area before the live line renders

  Scenario: user views hourly or daily crypto up/down target lines
    Given an hourly or daily crypto up/down market has Polymarket event price to beat metadata
    And the crypto target price API is unavailable

    When the market card or market details screen is rendered
    Then the target line uses the event price to beat metadata
    And the existing group item threshold fallback is still available if event metadata is missing

  Scenario: user views longer-duration crypto up/down markets
    Given a crypto up/down market has an hourly, daily, or weekly recurrence

    When the market card or time slot picker is rendered
    Then the countdown and reset copy use readable longer-duration formatting

Screenshots/Recordings

Before

N/A

After

N/A

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
  • See trace() for usage and
    addToken
    for an example

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 live pricing, chart anchoring, and controller fallbacks across
Predict crypto up/down flows, but scope is largely behind the up/down
feature flag with broad test coverage.

Overview
This PR tightens the gated crypto up/down Predict experience (feed
card, details, and routing) so prices, charts, and target lines stay
stable during live updates and time-slot changes.

Pricing & live data: Buy CTAs now share getPredictBuyPrice (live
bestAsk → REST entry.buy → token price). useLiveMarketPrices
caches recent updates so remounts do not flash stale REST/static prices.
Chart loading stays active until at least two renderable points exist;
current price can still propagate while loading.

Details screen: The chart stays on the live series market
while the picker only changes the selected slot (target line, Up/Down
actions, share). Series markets are held in a ref during refetch so
positions/chart height do not jump. Target/current summaries use
resolveCryptoTargetPrice with skeletons when appropriate; chart bottom
padding scales with height and font scale.

Target price & Polymarket: Event priceToBeat is parsed onto
markets; PredictController and UI fall back through fetched price →
event metadata → groupItemThreshold. Hourly recurrence is supported in
duration helpers.

UX polish: Longer countdowns use H:MM:SS when ≥1 hour; reset
copy uses readable hour/day/week strings. Up/down feed cards require
selectPredictUpDownEnabledFlag in addition to isCryptoUpDown.

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

[f24ef18](https://github.com/MetaMask/metamask-mobile/commit/f24ef18867b8a0e54ad93905b37033606daa6810)

<!--
Please submit this PR as a draft initially.

Do not mark it as "Ready for review" until this PR meets the canonical
Definition of Ready For Review in `docs/readme/ready-for-review.md`.

In short: the template must be materially complete (not just section
titles
present), all status checks must be currently passing, and the only
expected
follow-up commits must be reviewer-driven.
-->

Improves the crypto up/down market experience on the feed series card
and market details screen.

These changes are scoped to the existing crypto up/down work behind the
Predict up/down feature flag. They improve release quality for the
upcoming crypto up/down experience, where the current UX is unstable for
users, with minimal regression risk outside the gated feature.

This PR fixes several visible stability issues:

- Prevents Up/Down CTA prices from briefly flickering to stale fallback
prices while live CLOB price subscriptions remount or warm back up.
- Uses a shared buy-price precedence for CTA labels: live WebSocket
`bestAsk` → REST `entry.buy` → static market token price.
- Keeps the details chart anchored to the currently live market so
selecting a future time slot does not interrupt the BTC price stream.
- Keeps the selected time slot independent from the chart market, so
target price/actions can follow the selected slot while the chart
remains continuous.
- Preserves series data during transient series refetches so position
rows and chart sizing do not jump during time-slot changes.
- Keeps crypto up/down chart loading visible until the live chart has
enough renderable points, avoiding a spinner → blank → chart transition.
- Uses Polymarket event `priceToBeat` metadata as the target-line
fallback for hourly/daily crypto up/down markets whose target price API
can be unavailable.
- Preserves the existing group item threshold fallback for crypto
up/down markets that do not provide event `priceToBeat` metadata.
- Improves crypto up/down chart rendering/loading behavior and bottom
padding across larger chart heights/font scales.
- Improves longer-duration countdown/reset copy for hourly/daily/weekly
crypto up/down markets.
- Keeps crypto up/down card routing behind the Predict up/down feature
flag.

<!--
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

Fixes: N/A

```gherkin
Feature: Crypto up/down market experience

  Scenario: user views the crypto up/down series card while prices update
    Given the Predict up/down feature flag is enabled
    And a live crypto up/down market is visible in the Predict feed

    When live CLOB price updates are received for the Up and Down tokens
    Then the Up and Down CTA prices update from the live buy prices
    And the CTA prices do not briefly flicker to stale REST or static market prices

  Scenario: user opens crypto up/down market details and changes time slots
    Given the user is on a live crypto up/down market details screen
    And the market series includes a future time slot

    When user selects the future time slot
    Then the selected time slot updates
    And the chart remains anchored to the live market price stream
    And the Up and Down actions use the selected time slot market
    And the current price display remains stable while the target price loads

  Scenario: user waits for the crypto up/down chart to load
    Given the user is on a crypto up/down market details screen
    And live chart data has not produced at least two renderable points

    When the initial chart request finishes
    Then the chart loading state remains visible
    And the screen does not briefly show an empty chart area before the live line renders

  Scenario: user views hourly or daily crypto up/down target lines
    Given an hourly or daily crypto up/down market has Polymarket event price to beat metadata
    And the crypto target price API is unavailable

    When the market card or market details screen is rendered
    Then the target line uses the event price to beat metadata
    And the existing group item threshold fallback is still available if event metadata is missing

  Scenario: user views longer-duration crypto up/down markets
    Given a crypto up/down market has an hourly, daily, or weekly recurrence

    When the market card or time slot picker is rendered
    Then the countdown and reset copy use readable longer-duration formatting
```

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

N/A

N/A

<!--
Every checklist item must be consciously assessed before marking this PR
as
"Ready for review". A checked box means you deliberately considered that
responsibility, not that you literally performed every action listed.

Unchecked boxes are ambiguous: they are not an implicit "N/A" and they
are not
a silent "skip". See `docs/readme/ready-for-review.md` for the full
checklist
semantics.
-->

- [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.

- [ ] 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](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example

For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).

<!--
Reviewer checklist items follow the same semantics as the author
checklist: an
unchecked box is ambiguous, a checked box means the reviewer consciously
assessed that responsibility. See `docs/readme/ready-for-review.md`.
-->

- [ ] 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]
> **Medium Risk**
> Touches live pricing, chart anchoring, and controller fallbacks across
Predict crypto up/down flows, but scope is largely behind the up/down
feature flag with broad test coverage.
>
> **Overview**
> This PR tightens the **gated** crypto up/down Predict experience (feed
card, details, and routing) so prices, charts, and target lines stay
stable during live updates and time-slot changes.
>
> **Pricing & live data:** Buy CTAs now share `getPredictBuyPrice` (live
`bestAsk` → REST `entry.buy` → token price). `useLiveMarketPrices`
caches recent updates so remounts do not flash stale REST/static prices.
Chart loading stays active until at least two renderable points exist;
current price can still propagate while loading.
>
> **Details screen:** The chart stays on the **live** series market
while the picker only changes the selected slot (target line, Up/Down
actions, share). Series markets are held in a ref during refetch so
positions/chart height do not jump. Target/current summaries use
`resolveCryptoTargetPrice` with skeletons when appropriate; chart bottom
padding scales with height and font scale.
>
> **Target price & Polymarket:** Event `priceToBeat` is parsed onto
markets; `PredictController` and UI fall back through fetched price →
event metadata → `groupItemThreshold`. Hourly recurrence is supported in
duration helpers.
>
> **UX polish:** Longer countdowns use `H:MM:SS` when ≥1 hour; reset
copy uses readable hour/day/week strings. Up/down feed cards require
`selectPredictUpDownEnabledFlag` in addition to `isCryptoUpDown`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
31cc179. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github Bot requested a review from a team as a code owner May 27, 2026 18:05
@github-actions

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.

@metamaskbotv2 metamaskbotv2 Bot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label May 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - PR targets a release or stable branch (release/* or stable)

All E2E tests pre-selected.

View GitHub Actions results

@joaoloureirop joaoloureirop enabled auto-merge (squash) May 27, 2026 18:07
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 15 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/7.79.0@090f7f5). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...CryptoUpDownDetails/PredictCryptoUpDownDetails.tsx 72.00% 1 Missing and 6 partials ⚠️
...components/UI/Predict/hooks/useLiveMarketPrices.ts 86.95% 4 Missing and 2 partials ⚠️
app/components/UI/Predict/utils/prices.ts 91.66% 0 Missing and 1 partial ⚠️
...iews/PredictMarketDetails/hooks/useOpenOutcomes.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             release/7.79.0   #30703   +/-   ##
=================================================
  Coverage                  ?   82.27%           
=================================================
  Files                     ?     5518           
  Lines                     ?   148732           
  Branches                  ?    34274           
=================================================
  Hits                      ?   122366           
  Misses                    ?    18030           
  Partials                  ?     8336           

☔ 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.

@sonarqubecloud

Copy link
Copy Markdown

@joaoloureirop joaoloureirop merged commit f43f2a1 into release/7.79.0 May 27, 2026
212 of 213 checks passed
@joaoloureirop joaoloureirop deleted the cherry-pick-7-79-0-f24ef18 branch May 27, 2026 19:06
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-XL team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants