All packages

polymarket-neg-risk-adapter

colindickson
v0.12.0/2 downloads/Repository

Package ref

polymarket-neg-risk-adapter@v0.12.0

Run package

CLI

Run map_market_events from the command line.

substreams run polymarket-neg-risk-adapter@v0.12.0 map_market_events -e polygon --start-block -1
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

Polymarket Neg Risk Adapter Substreams Package

Substreams package for extracting events from the Polymarket NegRiskAdapter contract on Polygon.

Contract Information

  • Address: 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296
  • Network: Polygon
  • Initial Block: 50505403
  • Explorer: View on Polygonscan

Available Modules

ModuleDescriptionOutput Type
map_market_eventsExtracts market/question lifecycle eventsproto:polymarket.neg_risk_adapter.v1.MarketEvents
map_trading_eventsExtracts position and redemption eventsproto:polymarket.neg_risk_adapter.v1.TradingEvents
map_admin_eventsExtracts admin role eventsproto:polymarket.neg_risk_adapter.v1.AdminEvents
map_all_eventsExtracts all NegRiskAdapter eventsproto:polymarket.neg_risk_adapter.v1.AllEvents

Quick Start

Build the WASM binary:

make build-neg-risk-adapter
# or
cd polymarket-neg-risk-adapter && substreams build

Create the Substreams package:

cd polymarket-neg-risk-adapter && substreams pack

Run the Substreams:

substreams run substreams.yaml map_all_events \
  --network polygon \
  --start-block 50505403 \
  --stop-block +10000

Event Types

The package extracts the following event categories:

Market Events

  • MarketPrepared - New neg-risk market prepared
  • QuestionPrepared - Question added to a market
  • OutcomeReported - Outcome reported for a question

Trading Events

  • PositionSplit - Collateral split into conditional positions
  • PositionsMerge - Conditional positions merged back to collateral
  • PositionsConverted - Neg-risk positions converted across outcomes
  • PayoutRedemption - Winning positions redeemed for collateral

Admin Events

  • NewAdmin - New admin added
  • RemovedAdmin - Admin removed

Dependencies

  • substreams: ^0.7
  • substreams-ethereum: ^0.11
  • ethabi: ^18

Binary Output

Build artifacts: target/wasm32-unknown-unknown/release/polymarket_neg_risk_adapter.wasm

Modules

Execution graph

6 modules
Show 2 dependencies
map

eth_common:all_events

`all_events` gives you all the events in a block (from successful transactions), with basic block hash/number/timestamp and transaction hash

Output

sf.substreams.ethereum.v1.Events

blockIndex

eth_common:index_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