Skip to content

Data Sources

This section describes the source-specific ingestion plan for the SQLite market backend.

The shared rule is:

text
external source
  -> source-specific ingestor
  -> normalized SQLite rows
  -> deterministic context resolver
  -> trading prompt

Market data is global. Clones do not fetch source data independently; they select assets and data streams from the shared SQLite market memory.

Data source ingestion overview

Source Roles

SourcePrimary roleTrading prompt use
HyperliquidTrade universe and asset-level market statePrice, OHLC, liquidity, funding, volatility, positioning
PolymarketEvent and prediction-market contextImmediate, later, and recently closed market signals linked to assets
DefiLlamaMacro and DeFi regime contextCapital base, flows, fees, revenue, volume, open interest

DefiLlama context is macro-first. The resolver links global DeFi rows to every enabled asset and only adds chain/stablecoin rows when the subject can be matched to that asset symbol.

Runtime Shape

Run the backend API and ingestion worker as separate Node processes against the same SQLite database.

bash
cd services/market-backend

# Terminal 1
npm run api

# Terminal 2
npm run ingest

For capped local testing:

bash
npm run ingest:local

Source Summary

SourceChannelsMain cadence
HyperliquidMid prices, OHLC candles, liquidity profile, funding pressure, volatility profile, positioning pressure5s, 1m, and 5m depending on channel
PolymarketMarket discovery, immediate market, later market, recently closed markets5m to 1h depending on channel
DefiLlamaCapital base, capital flows, economic throughput1h

External API Summary

SourceTransportDefault endpoint configMain requests
HyperliquidWebSocket + HTTP POSTHYPERLIQUID_WS_URL=wss://api.hyperliquid.xyz/ws, HYPERLIQUID_INFO_URL=https://api.hyperliquid.xyz/infoallMids, candle, meta, spotMeta, metaAndAssetCtxs, predictedFundings, l2Book
PolymarketHTTP GETPOLYMARKET_GAMMA_URL=https://gamma-api.polymarket.com/events, /public-search
DefiLlamaHTTP GETDEFILLAMA_API_URL=https://api.llama.fi, DEFILLAMA_STABLECOINS_URL=https://stablecoins.llama.fi/v2/chains, /protocols, /stablecoins, /overview/*