Skip to content

tentou-tech/polymarket-envio-indexer

 
 

Repository files navigation

Polymarket Indexer

Please check the documentation website for a complete guide on all Envio indexer features.

This indexer is still a work in progress. Do not use it in production. It is meant only as a reference.

This indexer is built to index events emitted from contracts related to Polymarket. It is created by taking reference from the Polymarket Subgraph repo.

Run

pnpm dev

Open http://localhost:8080 to access the GraphQL Playground. The local password is testing.

Generate files from config.yaml or schema.graphql

pnpm codegen

Pre-requisites

Subgraphs Migration Status

  • Wallet Subgraph
  • Sports Oracle Subgraph
  • Order Book Subgraph
  • OI Subgraph
  • FPMM Subgraph
  • Activity Subgraph
  • Fee Module Subgraph
  • PNL Subgraph

Tasks

  • Migrate all subgraphs
  • Validate data against the Polymarket indexer (work in progress)

Smaller Tasks

  • Effects for fetching details about Collateral Token
  • Remove hardcoded return value from getCollateralScale in FPMM handler
  • Debug TradeType import in updatedFields.ts
  • getPositionId implementation (file: ConditionalTokens.ts)
  • understand the use of GlobalUSDCBalance entity used in polymarket subgraph (USDC.ts)
  • Write tests for utility functions like getPositionId or computeProxyWalletAddress
  • Make sure all error message are descriptive
  • In PNL subgraph, ConditionalTokens.ConditionPreparation handler look if you can make a relation between Condition & Position entity. Note: this might be tricky because Condition.positionIds is bigint[] & ids in Position entity is in string.

Notes

This indexer is a work in progress, and some parts of the logic are still being migrated. Data validation has been done for a few subgraphs so far, and we’ll be expanding correctness checks after the main migration is finished.

  • The polymarket-subgraph repo tracks ConditionalTokens event multiple times which different event handlers but in our case we have merged all those event handlers into one.

  • activity-subgraph/src/FixedProductMarketMakerFactoryMapping.ts file is not necessary it is copy that is used in the actiivty subgraph so other event handlers can access the FPMM addresses. We are combining all into a single indexer, we already have that handler.

Feature Requests

Not all are required but just a list that we can talk about:

  • having bytes32 values as 0x{string} instead of just string

About

Index Polymarket events with HyperIndex

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 85.8%
  • Dockerfile 14.2%