chore(runway): cherry-pick fix(predict): improve crypto up/down#30703
Merged
Conversation
<!--
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 -->
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. |
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - PR targets a release or stable branch (release/* or stable) All E2E tests pre-selected. |
joaoloureirop
approved these changes
May 27, 2026
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
|
ghgoodreau
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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:
prices while live CLOB price subscriptions remount or warm back up.
bestAsk→ RESTentry.buy→ static market token price.selecting a future time slot does not interrupt the BTC price stream.
target price/actions can follow the selected slot while the chart
remains continuous.
rows and chart sizing do not jump during time-slot changes.
enough renderable points, avoiding a spinner → blank → chart transition.
priceToBeatmetadata as the target-linefallback for hourly/daily crypto up/down markets whose target price API
can be unavailable.
up/down markets that do not provide event
priceToBeatmetadata.padding across larger chart heights/font scales.
crypto up/down markets.
flag.
Changelog
CHANGELOG entry: null
Related issues
Fixes: N/A
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Performance checks (if applicable)
SRPs
to import wallets with many accounts and tokens
performance metrics
trace()for usage andaddTokenfor an example
For performance guidelines and tooling, see the Performance
Guide.
Pre-merge reviewer checklist
app, test code being changed).
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(livebestAsk→ RESTentry.buy→ token price).useLiveMarketPricescaches 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
resolveCryptoTargetPricewith skeletons when appropriate; chart bottompadding scales with height and font scale.
Target price & Polymarket: Event
priceToBeatis parsed ontomarkets;
PredictControllerand UI fall back through fetched price →event metadata →
groupItemThreshold. Hourly recurrence is supported induration helpers.
UX polish: Longer countdowns use
H:MM:SSwhen ≥1 hour; resetcopy uses readable hour/day/week strings. Up/down feed cards require
selectPredictUpDownEnabledFlagin addition toisCryptoUpDown.Reviewed by Cursor Bugbot for commit
31cc179. Bugbot is set up for automated
code reviews on this repo. Configure
here.