# Pricing with Subgraph

{% hint style="danger" %}
For current prices, subgraph pricing is deprecated. Please use [api pricing](https://documentation.kodiak.finance/developers/backend-api)
{% endhint %}

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**:

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

  ```bash
  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\
   [The Graph Doucmentation](https://thegraph.com/docs/en/querying/querying-the-graph/)
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<br>

   ```graphql
   {
     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:&#x20;
     * `Token Price (USD) = derivedETH * ethPrice`
2. Listing All Tokens with Derived Prices

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

   \
   **Example response:**

   ```graphql
   {
     "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"
       }
     }
   }
   ```

\ <br>
