All packages

polymarket-collateral

colindickson
v0.12.0/2 downloads/Repository

Package ref

polymarket-collateral@v0.12.0

Run package

CLI

Run map_pusd_events from the command line.

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

README

Polymarket Collateral Substreams Package

Substreams package for extracting pUSD collateral-token and CTF collateral-adapter events from Polymarket on Polygon.

Contract Information

  • Network: Polygon
  • Initial Block: 84902320
ContractAddress
pUSD0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB
CtfCollateralAdapter0xAdA100Db00Ca00073811820692005400218FcE1f
NegRiskCtfCollateralAdapter0xadA2005600Dec949baf300f4C6120000bDB6eAab

Available Modules

ModuleDescriptionOutput Type
map_pusd_eventsExtracts pUSD collateral-token eventsproto:polymarket.collateral.v1.PusdEvents
map_ctf_adapter_eventsExtracts CtfCollateralAdapter eventsproto:polymarket.collateral.v1.CtfAdapterEvents
map_neg_risk_ctf_adapter_eventsExtracts NegRiskCtfCollateralAdapter eventsproto:polymarket.collateral.v1.NegRiskCtfAdapterEvents
map_all_eventsExtracts all collateral eventsproto:polymarket.collateral.v1.AllEvents

Quick Start

Build the WASM binary:

make build-collateral
# or
cd polymarket-collateral && substreams build

Create the Substreams package:

cd polymarket-collateral && substreams pack

Run the Substreams:

substreams run substreams.yaml map_all_events \
  --network polygon \
  --start-block 84902320 \
  --stop-block +1000

Event Types

The package extracts the following event categories:

pUSD Events

  • Transfer - pUSD token transfer
  • Wrapped - Collateral wrapped into pUSD
  • Unwrapped - pUSD unwrapped back to collateral

CTF Collateral Adapter Events

  • PositionSplit - Collateral split into conditional positions
  • PositionsMerged - Conditional positions merged back to collateral
  • PositionsRedeemed - Winning positions redeemed for collateral

NegRisk CTF Collateral Adapter Events

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

Dependencies

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

Binary Output

Build artifacts: target/wasm32-unknown-unknown/release/polymarket_collateral.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