Skip to content

Polymarket Data Source

Polymarket adds event and prediction-market context around the assets a clone is allowed to trade.

It is not the trade universe. Hyperliquid remains the trade universe; Polymarket is a related-market signal layer.

Polymarket ingestion flow

What We Store

ChannelTableCadencePurpose
Market discoverypolymarket_events, polymarket_markets, polymarket_market_asset_links1hDiscover and link relevant markets to Hyperliquid assets
Immediate marketpolymarket_immediate_markets5m health cadenceNear-term active prediction-market context
Later marketpolymarket_later_markets30m health cadenceLonger-dated context
Recently closed marketspolymarket_recently_closed_markets15m health cadenceSettled outcomes and recent resolution context

The current implementation performs discovery as one hourly job, then writes the immediate, later, and recently closed feature rows from that discovered registry.

Discovery Model

Discovery is registry-first:

text
Hyperliquid asset registry
  -> asset display names and search terms
  -> Gamma crypto tag crawl
  -> Gamma public search by asset term
  -> local event/market/link registry
  -> derived feature rows

The asset search terms come from hyperliquid_assets, including curated aliases where available. This is important because prediction markets often use names like Bitcoin instead of ticker-only strings like BTC.

How We Fetch Data

Configured endpoint:

ConfigDefault
POLYMARKET_GAMMA_URLhttps://gamma-api.polymarket.com
POLYMARKET_CRYPTO_TAG_ID21

The ingestor uses Polymarket Gamma HTTP GET requests.

Crypto tag crawl:

http
GET /events?active=true&closed=false&tag_id=21&order=volume_24hr&ascending=false&limit=100&offset=0

This pulls high-volume active Crypto-tagged events. Pagination continues until the configured page cap or until a short page is returned.

Asset search:

http
GET /public-search?q=Bitcoin&limit=5

Search terms come from the Hyperliquid asset registry. The ingestor runs throttled searches using POLYMARKET_SEARCH_DELAY_MS and can cap total searched terms with POLYMARKET_MAX_SEARCH_TERMS for local testing.

Fetched events and markets are parsed, matched to assets, and written into:

  • polymarket_events
  • polymarket_markets
  • polymarket_market_asset_links
  • polymarket_immediate_markets
  • polymarket_later_markets
  • polymarket_recently_closed_markets

Matching Policy

Polymarket rows should be linked to assets cautiously:

  • Prefer explicit asset-name and alias matches.
  • Keep match source and score metadata.
  • Store the durable event/market registry separately from derived summaries.
  • Avoid querying every CLOB orderbook by default.

CLOB enrichment can be added later for selected high-signal markets, but v1 should keep Polymarket as compact context rather than a heavy market-data stream.

Trading Context

Trading prompts can use Polymarket context to answer:

  • Is there a near-term event changing sentiment for this asset?
  • Are longer-dated markets implying a macro/narrative shift?
  • Did a recently closed market resolve in a way that affects the asset or sector?

Local Commands

bash
cd services/market-backend
npm run polymarket:discover
npm run polymarket:discover -- --dry-run --max-search-terms=5