Kodiak Finance
  • OVERVIEW
    • πŸ»β€β„οΈIntroducing Kodiak
    • 🐻Kodiak x Berachain
    • βœ‰οΈContact Us
    • 🍯Kodiak Contracts
  • πŸ…±οΈKodiak-Boyco
  • PROTOCOL
    • πŸ”ƒDEX
      • Swaps
      • Liquidity Provision
      • Trading Fees
    • 🏝️Islands
      • Island Liquidity Provision
      • Sweetened Islands
      • Island Mechanics
        • Auto-BGT
        • Real-time Security
        • Rebalancing
        • Strategies
    • 🐼Panda Factory
  • πŸͺ™Tokenomics
    • Kodiak Pre-TGE Rewards
  • 🧠User Guide
    • Launch a Token Launch on Panda Factory
    • Trading on Panda Factory
    • Swap
    • Create a V2 Position
    • Create a V3 Position
    • Add/Stake Islands Liquidity
    • Migrating to a Reward Vault
    • Deploying new Permissonless Islands
    • Deploying and Configuring a Kodiak Farm
    • Add your token
  • Add Your Project to the Ecosystem
  • πŸ‘¨β€πŸ’»Developers
    • 🐼Panda
      • Technical Integration Guide
      • Subgraph
        • Entity Reference
        • Query Guide
        • Advanced Usage Guide
      • Smart Contract Reference
        • Panda Factory
        • Panda Pool
        • Panda Token
      • Api
    • Farms
      • Technical Integration Guide
      • Smart Contract Reference
    • 🌴Kodiak Islands
      • Technical Integration Guide
        • Understanding Token Deposit Ratio
      • Subgraph
        • Entity Reference
        • Query Guide
        • Advanced Usage Guide
      • Smart Contract Reference
        • Kodiak Island Factory
        • Kodiak Island
        • Kodiak Island Router
      • Api
    • πŸ’°Pricing with Subgraph
    • πŸ’±Quotes
    • Backend
  • πŸ›‘οΈSECURITY
    • πŸ”Audits
    • Page
  • ℹ️Informational
    • πŸ“œTerms of Use
    • πŸ”Privacy Policy
    • TradingView Advanced License
Powered by GitBook
On this page
  1. Developers

Pricing with Subgraph

PreviousApiNextQuotes

Last updated 3 months ago

Kodiak provides two distinct protocols β€” V2 and V3 β€” each with separate endpoints for their subgraphs. While the structure of the queries remains the same across both protocols, the results may differ due to the underlying differences in how liquidity and pricing are handled.

Endpoints:

  • Kodiak V2 Subgraph Endpoint:

    https://api.goldsky.com/api/public/project_clpx84oel0al201r78jsl0r3i/subgraphs/kodiak-v2-berachain-mainnet/latest/gn
  • Kodiak V3 Subgraph Endpoint:

    https://api.goldsky.com/api/public/project_clpx84oel0al201r78jsl0r3i/subgraphs/kodiak-v3-berachain-mainnet/latest/gn

Steps to Get Started:

  1. Understand the Basics of Subgraphs:

    • Subgraphs index blockchain data and expose it through GraphQL endpoints.

    • Each subgraph has entities (e.g., token, pool, transaction) that define the structure of the data you can query.

  2. Read the Subgraph Documentation: Learn how subgraph works

  3. Set Up a GraphQL Client:

    • Use tools like Postman, Insomnia, or GraphQL playgrounds to send queries.

    • In your application, you can use libraries like graphql-request or Apollo Client.

  4. Know the Key Entities:

    • token: Represents individual tokens, their metadata, and derived pricing.

    • bundle: Contains aggregate data like the current price of ETH in USD.

Query examples

  1. Fetching a Specific Token’s Price in ETH and USD

    {
      token(id: "TOKEN_ADDRESS") {
        id
        symbol
        name
        derivedETH
      }
      bundle(id: "1") {
        ethPrice
      }
    }
    • Replace TOKEN_ADDRESS with the contract address of the token you’re querying.

    • Use thie formula to calculate USD price:

      • Token Price (USD) = derivedETH * ethPrice

  2. Listing All Tokens with Derived Prices

    {
      tokens(first: 10) {
        id
        symbol
        name
        derivedETH
      }
      bundle(id: "1") {
        ethPrice
      }
    }

    Example response:

    {
      "data": {
        "tokens": [
          { "id": "0x...123", "symbol": "USDT", "name": "Tether", "derivedETH": "0.0005" },
          { "id": "0x...456", "symbol": "USDC", "name": "USD Coin", "derivedETH": "0.0005" }
        ],
        "bundle": {
          "ethPrice": "2000"
        }
      }
    }

πŸ‘¨β€πŸ’»
πŸ’°
The Graph Doucmentation