Subgraph

View data related to markets, tokens and bond purchases

We have subgraphs available for all supported chains, mainnet and testnet. Our Ethereum Mainnet runs on Graph Protocol's decentralized network, all others are on their hosted service.

Documentation is available for all entities and their fields, to access it, follow one of the links at the bottom of this page, then in GraphiQL:

The documentation is usually identical across all subgraphs, so it does not matter which one you use.

However, if changes are being made, the updates may appear on testnet or backup subgraphs before they appear in production.

Mainnet Subgraphs

Testnet Subgraphs

Example Queries

NOTES

  • Each subgraph only returns data for the chain it is indexing. You cannot filter by fields such as "network" or "chainId", they have only been added to allow the dApp to do so, once the results from multiple subgraphs have been merged.

  • String searches are case sensitive, unless you add _nocase for example owner_contains_nocase as seen in the vesting token balance example.

  • The hasClosed field on the Market entity is not fully trustworthy, markets can sometimes close without triggering an event which updates this. We use it to filter out the majority which do trigger an event, then on the dApp, filter the rest manually.

  • By default, a request returns a maximum of 100 results. You can request up to 1000 using first: 1000, for example: ownerTokenTbvs(first: 1000). If more than 1000 results are required, you will have to use pagination (https://thegraph.com/docs/en/querying/graphql-api/#pagination).

List markets, including all data loaded by dApp on initial load:

{
    markets(where: { hasClosed: false }) {
      id
      name
      network
      auctioneer
      teller
      marketId
      owner
      callbackAddress
      capacity
      capacityInQuote
      chainId
      minPrice
      scale
      start
      conclusion
      payoutToken {
        id
        address
        symbol
        decimals
        name
      }
      quoteToken {
        id
        address
        symbol
        decimals
        name
        lpPair {
          token0 {
            id
            address
            symbol
            decimals
            name
            typeName
          }
          token1 {
            id
            address
            symbol
            decimals
            name
            typeName
          }
        }
        balancerWeightedPool {
          id
          vaultAddress
          poolId
          constituentTokens {
            id
            address
            symbol
            decimals
            name
            typeName
          }
        }
      }
      vesting
      vestingType
      isInstantSwap
      hasClosed
      totalBondedAmount
      totalPayoutAmount
      creationBlockTimestamp
    }
  }

List all tokens:

{
    tokens {
      id
      network
      chainId
      address
      decimals
      symbol
      name
      lpPair {
        token0 {
          id
        }
        token1 {
          id
        }
      }
      balancerWeightedPool {
        constituentTokens {
          id
        }
      }
    }
  }

Show vesting token balances for a given user:

{
    ownerBalances(where: { owner_contains_nocase: OWNER_ADDRESS, balance_gt: 0 }) {
      id
      tokenId
      owner
      balance
      network
      chainId
      bondToken {
        id
        symbol
        decimals
        expiry
        network
        chainId
        type
        teller
        underlying {
          id
          symbol
          decimals
        }
      }
    }
  }

TBV per owner/token combination:

{
    ownerTokenTbvs(first: 1000) {
      owner
      token
      tbv
      network
      chainId
    }
  }

Bond purchases per market:

{
    bondPurchases(
      first: 1000
      where: { marketId: MARKET_ID }
      orderBy: timestamp
    ) {
      id
      recipient
      payout
      amount
      timestamp
      purchasePrice
      postPurchasePrice
      quoteToken {
        id
        name
        symbol
        address
      }
      payoutToken {
        id
        name
        symbol
        address
      }
    }
  }

Last updated