LogoLogo
WebsiteGithubCommunity Docs
  • Developer Docs
  • Smart Contracts
    • Bond System
      • Auctioneer
        • Auctioneer Interfaces
        • Sequential Dutch Auctioneer (SDA)
          • Auction Pricing
          • Fixed-Term SDA
          • Fixed-Expiry SDA
        • Fixed Price Auctioneer (FPA)
          • Fixed-Term FPA
          • Fixed-Expiry FPA
        • Oracle-based Auctioneers
          • Oracle Interface
        • Oracle Fixed Discount Auctioneer (OFDA)
          • Fixed-Term OFDA
          • Fixed-Expiry OFDA
        • Oracle Sequential Dutch Auctioneer (OSDA)
          • Fixed-Term OSDA
          • Fixed-Expiry OSDA
      • Teller
        • Teller Interfaces
        • Base Teller
        • Fixed-Expiry Teller
        • Fixed-Term Teller
      • Callback
        • Callback Interface
        • Base Callback
        • Sample Callback Contract
      • Aggregator
        • Aggregator Interface
        • Aggregator Contract
      • Intended User Actions
      • Limit Orders
    • Option System
      • Fixed Strike oTokens
      • Fixed Strike Option Teller
      • Options Liquidity Mining (OLM)
        • Manual Strike OLM
        • Oracle Strike OLM
      • OLM Factories
  • Developers
    • Subgraph
    • Market Calculations
    • Purchases & Redemptions
    • User Balances
    • Options Library
      • Helper Functions
      • Types
  • References
    • Technical Resources
      • Audits
    • Community Resources
    • Brand Assets
    • Contact Us
Powered by GitBook
On this page
  1. Developers

Subgraph

View data related to markets, tokens and bond purchases

PreviousOLM FactoriesNextMarket Calculations

Last updated 1 year ago

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.

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
      }
    }
  }

https://gateway.thegraph.com/api/{API_KEY}/subgraphs/id/9F8K4UDnrQEzXsVmHoJxs5qBVDJB5jEKtU9EVsXNTzZZ(Mainnet Production - paid, requires API key)

(Mainnet Development - version number at the end of the URL may change)

(Arbitrum Production)

(Mainnet Backup)

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://api.studio.thegraph.com/query/41517/bond-protocol-ethereum-mainnet/v1.0.6
https://api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-arbitrum-mainnet
https://thegraph.com/hosted-service/subgraph/bond-protocol/bond-protocol-mainnet
https://api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-goerli
https://api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-goerli-arbitrum
https://api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-optimism-goerli
https://api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-polygon-mumbai
https://api.thegraph.com/subgraphs/name/bond-protocol/bond-protocol-avalanche-fuji
https://thegraph.com/docs/en/querying/graphql-api/#pagination
Click the Query link in the Document Explorer
Click the link for the entity you are interested in
A description of the entity and each field will be available