A Graph Protocol subgraph that indexes Polymarket's orderbook data and trading activity.
This subgraph tracks orderbook events from Polymarket's CTF Exchange contract, providing real-time analytics for trading activity, volume analysis, and market data.
- Orderbook Tracking: Real-time monitoring of trades and market depth
- Account Analytics: Individual trader statistics and activity tracking
- Volume Analysis: Comprehensive volume metrics with scaled calculations
- Price Tracking: Real-time price calculations and trade side identification
- Fee Analytics: Fee collection and distribution tracking
- Orderbook: Market orderbook state and trading statistics
- OrderFilledEvent: Individual trade execution records
- OrdersMatchedEvent: Order matching events
- MarketData: Market metadata and condition information
- Account: Individual trader statistics and activity
- Global: Platform-wide statistics and metrics
- OrdersMatchedGlobal: Global order matching statistics
# Install dependencies
npm install
# Generate types
npm run codegen
# Build subgraph
npm run build
# Deploy to Graph Studio
npm run deploy{
orderbooks(first: 5) {
id
tradesQuantity
buysQuantity
sellsQuantity
collateralVolume
scaledCollateralVolume
averageTradeSize
totalFees
}
}{
orderFilledEvents(first: 10, orderBy: timestamp, orderDirection: desc) {
id
transactionHash
timestamp
maker
taker
makerAssetId
takerAssetId
makerAmountFilled
takerAmountFilled
fee
side
price
}
}{
accounts(first: 10, orderBy: tradesQuantity, orderDirection: desc) {
id
tradesQuantity
totalVolume
totalFees
firstTrade
lastTrade
isActive
}
}{
global(id: "") {
tradesQuantity
collateralVolume
scaledCollateralVolume
collateralFees
scaledCollateralFees
uniqueTraders
activeMarkets
}
}{
marketData(id: "YOUR_TOKEN_ID") {
id
condition
outcomeIndex
}
}{
ordersMatchedEvents(first: 10, orderBy: timestamp, orderDirection: desc) {
id
timestamp
makerAssetID
takerAssetID
makerAmountFilled
takerAmountFilled
blockNumber
}
}The subgraph is deployed on Graph Studio at:
https://api.studio.thegraph.com/query/92142/polymarket-orderbook/0.0.21
- Exchange:
0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E - NegRiskExchange:
0xC5d563A36AE78145C45a50134d48A1215220f80a
MIT License