Repository navigation
fix(polymarket): resolve inactive markets via CLOB slug and stop retrying deleted events - #308
Merged
Conversation
…ying deleted events
Main pass: `/markets/keyset` never returns inactive markets whatever filters
are passed, so on-chain registrations of negRisk placeholder slots failed
with "No market found" every cycle. Fall back to CLOB `/markets/{condition}`
for the `market_slug`, then Gamma `/markets/slug/{slug}` for the full market
(with events). Resolves all 104 condition ids failing in prod right now.
Enrichment: `/events/keyset` returns [] both on errors and for deleted
events. Fall back to `/events/slug/{slug}` and record the event as enriched
on a 404, so deleted events can't pin the head of the queue; other
failures stay retriable.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fallback paths are validated, preserve retry behavior for transient failures, and have focused test coverage.
0 open findings
What changed in this PR
Adds reliable fallbacks for inactive Polymarket markets and deleted events.
Changes:
- Resolves omitted markets through CLOB and Gamma slug endpoints.
- Distinguishes deleted events from transient API failures.
- Adds fallback and enrichment tests.
| File | Description |
|---|---|
services/polymarket/gamma.ts |
Adds market and event fallback lookups. |
services/polymarket/index.ts |
Records deleted events as enriched. |
services/polymarket/index.test.ts |
Tests deleted-event enrichment. |
services/polymarket/fetch-gamma.test.ts |
Tests fallback API behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
YaroShkvorets
merged commit Oct 7, 2026
846f4fb
into
fix/polymarket-enrichment-placeholder-markets
1 check passed
YaroShkvorets
deleted the
fix/polymarket-inactive-markets-and-deleted-events
branch
October 7, 2026 15:24
YaroShkvorets
added a commit
that referenced
this pull request
Oct 7, 2026
…ders don't stall the queue (#307) * fix(polymarket): use event-embedded markets in enrichment so placeholders don't stall the queue The enrichment pass re-fetched missing child markets via `/markets/keyset?condition_ids=`, which never returns placeholder markets (e.g. unnamed negRisk "App D" slots) even though `/events/keyset` lists them. An empty result was treated as a transient failure and the event was left unrecorded, so those slugs stayed at the head of the alphabetical queue and the same 1000 events were retried every cycle without writing anything. - Insert the full market objects already embedded in the event response, linking them back to the parent event; drops one Gamma call per event. - Record every event Gamma returns in polymarket_events_enriched, including ones with no markets; only a failed event fetch stays retriable. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(polymarket): resolve inactive markets via CLOB slug and stop retrying deleted events (#308) Main pass: `/markets/keyset` never returns inactive markets whatever filters are passed, so on-chain registrations of negRisk placeholder slots failed with "No market found" every cycle. Fall back to CLOB `/markets/{condition}` for the `market_slug`, then Gamma `/markets/slug/{slug}` for the full market (with events). Resolves all 104 condition ids failing in prod right now. Enrichment: `/events/keyset` returns [] both on errors and for deleted events. Fall back to `/events/slug/{slug}` and record the event as enriched on a 404, so deleted events can't pin the head of the queue; other failures stay retriable. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #307. Stacked on #307: this PR targets that branch and contains only the follow-up commit. Merge #307 first; GitHub will then retarget this PR to
main.Problem
Gamma's
/markets/keysetnever returns inactive markets, whateveractive/closed/archivedfilters are passed. Polymarket has many of these: unnamed negRisk placeholder slots like "Will candidate O be the next regional board…" or MLB NRFI markets. #307 fixed the enrichment pass. This PR fixes the two remaining problems:No market found for condition_idevery cycle (104 distinct ids in a single prod run on 2026-10-07)./events/keysetreturns[]both on errors and for events that no longer exist, so a deleted event was retried forever and could pin the head of the enrichment queue, the same failure mode as fix(polymarket): use event-embedded markets in enrichment so placeholders don't stall the queue #307.Fix
Main pass (
fetchMarketFromApi): when keyset doesn't return a market, fall back to CLOB/markets/{condition_id}to get itsmarket_slug, then Gamma/markets/slug/{slug}for the full market includingevents. The result is only accepted if itsconditionIdmatches the one requested.Enrichment (
fetchEventFromApi): when keyset is empty, fall back to/events/slug/{slug}. A 404 returns'not_found'andprocessEventEnrichmentrecords the event as enriched (0 markets). Any other failure returnsnulland stays retriable.A new
fetchJsonhelper keeps a 404 distinct from other failures for single-object endpoints.fetchGammaApiis unchanged.Verification
'not_found'.nulland are retried as before.'not_found', 503 →null; deleted event recorded by the enrichment pass.bun test services/polymarket: 35/35 pass. The 9hyperliquidfailures also happen onmainand are unrelated.Note
fetchMarketsFromApi(batch) is now only used by its tests. Gamma's OpenAPI spec capscondition_idsat 100 per request, whileKEYSET_PAGE_LIMITis 1000, so it's worth checking if anything starts using it again.🤖 Generated with Claude Code