Extracts exchange trading events (OrderFilled, OrdersMatched) from the CTF Exchange V2 contract.

polymarket-exchange
Package ref
polymarket-exchange@v1.2.0Run package
CLI
Run map_exchange_events from the command line.
substreams run polymarket-exchange@v1.2.0 map_exchange_events -e polygon --start-block -1substreams auth or directly on thegraph.market (see docs).README
Polymarket Exchange Substreams Package
Substreams package for extracting events from the Polymarket exchange contracts on Polygon: CTF Exchange V2 and the Protocol V2 Exchange ("ExchangeV3").
Contract Information
| Contract | Address | exchange field |
|---|---|---|
| CTF Exchange V2 | 0xE111180000d2663C0091e4f400237545B87B996B | ctf_v2 |
| Protocol V2 Exchange (ExchangeV3, proxy) | 0xe3333700cA9d93003F00f0F71f8515005F6c00Aa | exchange_v3 |
- Network: Polygon
- Initial block: 84902353 (CTF Exchange V2). ExchangeV3 was deployed after it (its address is listed in Polymarket's
polymarket-v2-externalREADME as of 2026-09-24; the exact deployment block isn't pinned here), so the initial block covers both.
Both contracts emit the same event signatures, so every module reads both and every
event carries an exchange field saying which one emitted it. ExchangeV3 token_ids are
Protocol V2 PositionManager position ids, not Conditional Tokens ERC1155 ids.
Available Modules
| Module | Description | Output Type |
|---|---|---|
map_exchange_events | Extracts exchange trading events | proto:polymarket.exchange.v1.ExchangeEvents |
map_fee_events | Extracts fee-related events | proto:polymarket.exchange.v1.FeeEvents |
map_admin_events | Extracts admin role events | proto:polymarket.exchange.v1.AdminEvents |
map_pause_events | Extracts user pause events | proto:polymarket.exchange.v1.PauseEvents |
map_approval_events | Extracts order approval events | proto:polymarket.exchange.v1.OrderApprovalEvents |
map_all_events | Extracts all exchange events | proto:polymarket.exchange.v1.AllEvents |
Quick Start
Build the WASM binary:
make build-exchange
# or
cd polymarket-exchange && substreams build
Create the Substreams package:
cd polymarket-exchange && substreams pack
Run the Substreams:
substreams run substreams.yaml map_all_events \
--network polygon \
--start-block -1000
Event Types
The package extracts the following event categories. ExchangeV3 emits the exchange, fee,
pause and order approval events; the admin events (and FeeReceiverUpdated,
MaxFeeRateUpdated) only come from CTF Exchange V2.
Exchange Events
OrderFilled- Order filled (withsideuint8,token_id,builder,metadata)OrdersMatched- Orders matched (withsideuint8,token_id)
Fee Events
FeeCharged- Trading fee charged (recipient,amount)FeeReceiverUpdated- Fee receiver address changedMaxFeeRateUpdated- Maximum fee rate changed
Admin Events
NewAdmin- New admin addedNewOperator- New operator addedRemovedAdmin- Admin removedRemovedOperator- Operator removed
Pause Events
UserPaused- User paused from tradingUserUnpaused- User unpausedUserPauseBlockIntervalUpdated- Pause interval changed
Order Approval Events
OrderPreapproved- Order preapprovedOrderPreapprovalInvalidated- Order preapproval invalidated
Dependencies
substreams: ^0.8substreams-ethereum: ^0.12buffa: 0.9
Binary Output
Build artifacts: target/wasm32-unknown-unknown/release/polymarket_exchange.wasm
Modules
Execution graph
Extracts admin role events (NewAdmin, NewOperator, RemovedAdmin, RemovedOperator) from the CTF Exchange V2 contract.
Extracts all exchange events (trading, fees, admin, pause, approvals) from a single pass over the CTF Exchange V2 contract.
Extracts order approval events (OrderPreapproved, OrderPreapprovalInvalidated) from the CTF Exchange V2 contract.
Extracts fee-related events (FeeCharged, FeeReceiverUpdated, MaxFeeRateUpdated) from the CTF Exchange V2 contract.
Extracts user pause events (UserPaused, UserUnpaused, UserPauseBlockIntervalUpdated) from the CTF Exchange V2 contract.
Show 2 dependencies
Output
sf.substreams.ethereum.v1.Events
`index_events` sets the following keys on the block: * Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x) * Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x)
Output
sf.substreams.index.v1.Keys
Inputs
