The Polymarket Orderbook Substreams contains a comprehensive set of modules that allow you to easily retrieve real-time orderbook analytics from Polymarket prediction markets on Polygon, including order fills, market statistics, trader analytics, and advanced market microstructure data.

The substreams.yaml file defines all the different modules available, and also provides you with documentation about the usage of every module.
In your substreams.yaml:
Import this .spkg:
imports:
polymarket: https://spkg.io/PaulieB14/polymarket-orderbook-substreams-v0.1.0.spkg
Replace any source: sf.ethereum.type.v2.Block input with map: polymarket:map_orderbook_analytics (you will be getting comprehensive orderbook analytics with market data, trader statistics, and real-time insights)
Add block filtering to your "entry modules" (any module reading blocks or transactions before emitting your custom types):
If you want to track specific markets by asset ID, use the market filtering like this:
blockFilter:
module: polymarket:store_markets
query:
string: "market:12345 || market:67890"
If you need to track specific traders, use the trader filtering like this:
blockFilter:
module: polymarket:store_traders
query:
string: "trader:0x1234... || trader:0x5678..."
In your substreams.yaml:
Import this .spkg:
imports:
polymarket: https://spkg.io/PaulieB14/polymarket-orderbook-substreams-v0.1.0.spkg
Set one of the analytics modules (along with source: sf.substreams.v1.Clock if you need block number/timestamp) as your module input:
- name: my_polymarket_module
kind: map
inputs:
- source: sf.substreams.v1.Clock
- map: polymarket:map_orderbook_analytics
Set parameters to filter the data that you want to be fed to your module:
params:
polymarket:store_markets: "asset_id:12345"
polymarket:store_traders: "min_volume:10000"
Run substreams protogen against your substreams.yaml to create the rust bindings of the protobuf definitions inside the substreams.
map_orderbook_analytics (map)This module provides comprehensive orderbook analytics combining market data, trader statistics, global metrics, market alerts, and arbitrage opportunities. It's the main output module that aggregates all orderbook intelligence.
store_markets (store)This foundational store efficiently tracks market-level orderbook data including:
Example keys: market:12345, market:67890
Use it to only get blocks that contain trades for specific markets:
- name: my_module
...
blockFilter:
module: store_markets
query:
string: "market:12345 || market:67890"
store_traders (store)This foundational store tracks comprehensive trader analytics including:
Example keys: trader:0x1234..., trader:0x5678...
Use it to track specific high-value traders:
- name: my_module
...
blockFilter:
module: store_traders
query:
string: "trader:0x1234567890abcdef || min_volume:100000"
map_ctf_exchange_order_filled (map)This module extracts and processes OrderFilled events from the CTF Exchange contract (0x4bfb41d5b3570defd03c39a9a4d8de6bd8b8982e), providing detailed trade execution data with price calculations and trade side determination.
map_neg_risk_exchange_order_filled (map)This module extracts and processes OrderFilled events from the Neg Risk CTF Exchange contract (0xC5d563A36AE78145C45a50134d48A1215220f80a), handling negative risk markets with specialized processing.
map_market_orderbooks (map)This module uses the store_markets foundational store to provide real-time market orderbook snapshots with:
map_trader_accounts (map)This module uses the store_traders foundational store to provide comprehensive trader analytics with:
map_global_orderbook_stats (map)This module aggregates platform-wide statistics including:
0x4bfb41d5b3570defd03c39a9a4d8de6bd8b8982e0xC5d563A36AE78145C45a50134d48A1215220f80a0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174# Install Substreams CLI
curl -sSf https://substreams.streamingfast.io/install | bash
# Clone and build
git clone https://github.com/PaulieB14/polymarket-orderbook-substreams
cd polymarket-orderbook-substreams
substreams build
substreams run substreams.yaml map_orderbook_analytics \
-e polygon.streamingfast.io:443 \
-s 66000000 -t +100
substreams run substreams.yaml map_market_orderbooks \
-e polygon.streamingfast.io:443 \
-s 66000000 -t +50
substreams run substreams.yaml map_trader_accounts \
-e polygon.streamingfast.io:443 \
-s 66000000 -t +25
substreams run substreams.yaml map_global_orderbook_stats \
-e polygon.streamingfast.io:443 \
-s 66000000 -t +10
map_orderbook_analytics - Comprehensive orderbook analyticsmap_market_orderbooks - Market-level orderbook datamap_trader_accounts - Trader analytics and performancemap_global_orderbook_stats - Platform-wide statisticsmap_ctf_exchange_order_filled - CTF exchange order fillsmap_neg_risk_exchange_order_filled - Neg risk exchange order fillsstore_markets - Foundational market state managementstore_traders - Foundational trader analyticsstore_global_stats - Platform-wide metrics storeBuilt on Substreams architecture with:
MIT License
Built with ❤️ for the Polymarket community using advanced Substreams technology
Powered by StreamingFast infrastructure for maximum performance and reliability
substreams gui polymarket-orderbook-substreams@v0.1.0 map_ctf_exchange_order_filledsubstreams gui polymarket-orderbook-substreams@v0.1.0 map_neg_risk_exchange_order_filledsubstreams gui polymarket-orderbook-substreams@v0.1.0 map_ctf_exchange_orders_matchedsubstreams gui polymarket-orderbook-substreams@v0.1.0 map_neg_risk_exchange_orders_matched