Envio HyperIndex for Polymarket's "BTC Up or Down 5m" markets on Polygon.
- OrderFilled events — indexes
OrderFilledfrom the three CTFExchangeV2 contracts on Polygon. Derives a price frommakerAmountFilled/takerAmountFilled(orientation depends onside). - Market filter — only fills whose
tokenIdcorresponds to an active Polymarket BTC 5-min market are persisted. Other tokens are dropped at the handler. - Market sync (block handler) — every ~150 blocks (~5 min on Polygon),
sweeps the past 24h of 5-min slots, calls
https://gamma-api.polymarket.com/events/slug/btc-updown-5m-{slot}via the Effect API (cached, rate-limited), and upserts aMarketentity perclobTokenId(Up + Down). Markets whoseendDateis older than 24h + 5min are deleted. - Window —
start_blockis set ~48h before the head; the Market table tracks the past 24h. So roughly the first day of fills is filtered out (no matching markets), and the second day is indexed against live markets.
Market— keyed bytokenId(clobTokenId). Holdsslug,conditionId,outcome("Up"or"Down"),slotTimestamp,endDate.OrderFill— keyed by${chainId}_${blockNumber}_${logIndex}, referencesMarket.
pnpm install
pnpm codegen # after any schema.graphql / config.yaml change
TUI_OFF=true pnpm dev # run indexer with AI-friendly logsGraphQL: https://envio.dev/console
Other useful commands:
pnpm tsc --noEmit # type-check
pnpm test # vitestENVIO_API_TOKEN— required for HyperSync data source.