Commit f43f2a1
chore(runway): cherry-pick fix(predict): improve crypto up/down (#30703)
- fix(predict): improve crypto up/down cp-7.79.0 (#30662)
<!--
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.
-->
## **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**
<!--
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
## **Related issues**
Fixes: N/A
## **Manual testing steps**
```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
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
<!--
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.
#### 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](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).
## **Pre-merge reviewer checklist**
<!--
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 -->
[f24ef18](f24ef18)
Co-authored-by: hunty <hunter.goodreau@consensys.net>1 parent 090f7f5 commit f43f2a1
30 files changed
Lines changed: 1178 additions & 155 deletions
File tree
- app/components/UI/Predict
- components
- PredictCryptoUpDownChart
- PredictCryptoUpDownDetails
- PredictCryptoUpDownMarketCard
- PredictMarket
- TimeSlotPicker
- controllers
- hooks
- providers/polymarket
- types
- utils
- views/PredictMarketDetails/hooks
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
110 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| |||
274 | 280 | | |
275 | 281 | | |
276 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
277 | 305 | | |
278 | 306 | | |
279 | 307 | | |
| |||
367 | 395 | | |
368 | 396 | | |
369 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
370 | 416 | | |
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
7 | 24 | | |
8 | 25 | | |
9 | 26 | | |
| |||
47 | 64 | | |
48 | 65 | | |
49 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
50 | 71 | | |
51 | 72 | | |
52 | | - | |
| 73 | + | |
53 | 74 | | |
54 | 75 | | |
55 | | - | |
| 76 | + | |
56 | 77 | | |
57 | 78 | | |
58 | 79 | | |
| |||
77 | 98 | | |
78 | 99 | | |
79 | 100 | | |
80 | | - | |
| 101 | + | |
81 | 102 | | |
82 | 103 | | |
83 | 104 | | |
| |||
Lines changed: 130 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
162 | 170 | | |
163 | 171 | | |
164 | 172 | | |
| |||
278 | 286 | | |
279 | 287 | | |
280 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
281 | 301 | | |
282 | 302 | | |
283 | 303 | | |
| |||
534 | 554 | | |
535 | 555 | | |
536 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
537 | 587 | | |
538 | 588 | | |
539 | 589 | | |
| |||
795 | 845 | | |
796 | 846 | | |
797 | 847 | | |
798 | | - | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
799 | 893 | | |
800 | 894 | | |
801 | 895 | | |
802 | 896 | | |
803 | 897 | | |
804 | 898 | | |
805 | | - | |
806 | | - | |
| 899 | + | |
807 | 900 | | |
808 | 901 | | |
809 | 902 | | |
| |||
980 | 1073 | | |
981 | 1074 | | |
982 | 1075 | | |
983 | | - | |
| 1076 | + | |
984 | 1077 | | |
985 | 1078 | | |
986 | 1079 | | |
| |||
1083 | 1176 | | |
1084 | 1177 | | |
1085 | 1178 | | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
1086 | 1210 | | |
1087 | 1211 | | |
0 commit comments