feat(predict): adds crypto target price client for up/down markets#28694
feat(predict): adds crypto target price client for up/down markets#28694ghgoodreau wants to merge 4 commits intomainfrom
Conversation
Fetches target price from undocumented Polymarket crypto-price endpoint. Caches per eventId in a module-level Map (immutable once window opens) alongside React Query staleTime: Infinity. Falls back to groupItemThreshold from event outcomes when primary API fails; logs warning (not error) for monitoring. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Thin wrapper over the query options. Accepts optional pre-loaded outcomes to avoid redundant network calls in the fallback path. Consumed by LiveScrollingChart (PRED-778) to render the horizontal target line. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
The undocumented endpoint returns { openPrice, closePrice, timestamp, ... }
not { price }. The openPrice is the target line — the price to beat.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
|
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #28694 +/- ##
==========================================
+ Coverage 82.14% 82.17% +0.02%
==========================================
Files 4949 4951 +2
Lines 130070 130305 +235
Branches 29004 29041 +37
==========================================
+ Hits 106851 107081 +230
- Misses 15923 15927 +4
- Partials 7296 7297 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Aligns with the Predict module convention — every other log call in Predict uses DevLogger, not Logger. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: SmokePredictions is the primary tag since all changes are within the Predict feature area — the new hook/query will be used in prediction market flows (crypto Up/Down markets). The SmokePredictions tag description explicitly requires also selecting SmokeWalletPlatform (Predictions is a section inside Trending tab) and SmokeConfirmations (opening/closing positions are on-chain transactions). No shared infrastructure (navigation, modals, Engine, controllers) is modified. The changes are purely additive within the Predict module. Risk is medium because new API calls and caching logic are introduced that could affect prediction market display/behavior. Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 1e20a42. Configure here.
| DevLogger.log( | ||
| `[${PREDICT_CONSTANTS.FEATURE_NAME}] Crypto target price API failed for event ${eventId}, falling back to groupItemThreshold`, | ||
| apiError, | ||
| ); |
There was a problem hiding this comment.
DevLogger is a no-op in production, breaking observability
Medium Severity
The code uses DevLogger.log to log the API fallback warning, but DevLogger.log only outputs to console when process.env.SDK_DEV === 'DEV' — it's completely silent in production. The PR description explicitly states the intent is for "API breakage [to be] detectable via Sentry breadcrumbs without triggering alerts," which requires Logger.log from app/util/Logger. Logger.log adds a Sentry breadcrumb in production; DevLogger.log does not. This means crypto-price API failures will go completely undetected in production.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 1e20a42. Configure here.
|
✅ E2E Fixture Validation — Schema is up to date |
|





Description
Adds the
CryptoTargetPriceClient— a query + hook that fetches the "price to beat" for crypto Up/Down market windows from Polymarket's undocumentedcrypto-priceendpoint, returning theopenPriceas the target line value.The target price is immutable once a window opens, so caching is aggressive: a module-level
Map<eventId, number>persists across React Query garbage-collection, andstaleTime: Infinityprevents refetches. Subsequent calls for the same event return instantly from cache with zero network cost.When the primary API fails (geo-blocked, endpoint changed, etc.), the client falls back to parsing
groupItemThresholdfrom event outcomes. If both fail, it returnsnull. Fallback triggers aLogger.logwarning (not error) so API breakage is detectable via Sentry breadcrumbs without triggering alerts.The consumer passes optional pre-loaded
outcomesto avoid a redundantgetMarketcall in the fallback path — the detail screen already has this data.Consumed by
LiveScrollingChart(PRED-778) to render the horizontal target line.Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Introduces new network fetching logic against an undocumented external endpoint plus a module-level cache, which could impact correctness/memory if parameters or event IDs are mishandled. Changes are otherwise additive and covered by unit tests for success, caching, and fallback behavior.
Overview
Adds a new
cryptoTargetPriceReact Query client anduseCryptoTargetPricehook to fetch the immutable “price to beat” for crypto Up/Down markets from Polymarket’scrypto-priceendpoint (returningopenPrice), withstaleTime: Infinity.Implements an event-scoped module cache to persist target prices beyond React Query GC, and adds a fallback path that derives the price from
groupItemThreshold(using providedoutcomeswhen available, otherwise callingPredictController.getMarket), logging a warning breadcrumb on API failure. Includes comprehensive unit tests for API success, caching, parameter encoding, and fallback/null scenarios, and wires the new query intopredictQueriesand hook exports.Reviewed by Cursor Bugbot for commit 1e20a42. Bugbot is set up for automated code reviews on this repo. Configure here.