MCPcopy Index your code
hub / github.com/enviodev/polymarket-v2-indexer

github.com/enviodev/polymarket-v2-indexer @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
6 symbols 22 edges 8 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Polymarket V2 Indexer

Indexes the new Polymarket V2 exchange stack on Polygon, built with Envio HyperIndex.

Contracts Indexed

Contract Address What it tracks
CTFExchange V2 (x3) 0xe11118..., 0xe2222d...0f59, 0xe2222d...0036 OrderFilled (with builder codes + metadata), OrdersMatched, FeeCharged, pause events
PolyUSD 0xc011a7e1...82dfb Transfers, balances, Wrapped/Unwrapped (USDC/USDC.e to pUSD)
Rewards 0xdd8db7...e8b Market sponsorship, reward distribution

What's new in V2

  • Builder codes on every order fill for on-chain attribution
  • PolyUSD (pUSD) replaces USDC.e as collateral, backed 1:1 by USDC
  • EIP-1271 smart contract wallet signatures
  • Per-user pause capability
  • Market sponsorship rewards system

Schema

  • OrderFill: every V2 trade with maker, taker, side, tokenId, fee, builder code
  • OrderMatch: matched order pairs
  • FeeEvent: fee collection
  • PolyUSDTransfer / PolyUSDWrap / PolyUSDAccount: pUSD flow and balances
  • PolyUSDStats: total supply, wrapped/unwrapped volumes
  • ExchangeStats: per-exchange aggregates (volume, fills, fees, builder fills)
  • SponsoredMarket / Sponsorship / RewardDistribution: rewards system

Run locally

A HyperSync API token is required. Create one at https://envio.dev/app/api-tokens, then:

cp .env.example .env
# edit .env and set ENVIO_API_TOKEN to your token

Then:

pnpm install
pnpm codegen
pnpm dev

Visit http://localhost:8080 for the GraphQL playground (password: testing).

Test

pnpm test

12 tests covering all handlers with real on-chain data (via HyperSync) and simulated events.

Pre-requisites

Core symbols most depended-on inside this repo

eventId
called by 3
src/handlers/PolyUSD.ts
getOrInitStats
called by 3
src/handlers/PolyUSD.ts
eventId
called by 3
src/handlers/CTFExchangeV2.ts
getOrInitStats
called by 2
src/handlers/CTFExchangeV2.ts
ensureMarket
called by 2
src/handlers/CTFExchangeV2.ts
eventId
called by 2
src/handlers/Rewards.ts

Shape

Function 6

Languages

TypeScript100%

Modules by API surface

src/handlers/CTFExchangeV2.ts3 symbols
src/handlers/PolyUSD.ts2 symbols
src/handlers/Rewards.ts1 symbols

For agents

$ claude mcp add polymarket-v2-indexer \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page