# Get Bonding Curve Details by Pool Address

Each Launchpad pool uses a <mark style="color:yellow;">bonding curve</mark> to manage price and token distribution. By querying the pool using its address, we can fetch detailed curve parameters like virtual reserves, tokens sold, and total funds raised. Shyft's GraphQL API enables us to query and filter pool data based on any available field. Here, we filter by the `pubkey` field to fetch the bonding curve details for the corresponding pool.

You can directly copy paste this code on <mark style="color:yellow;">replit</mark> and see it in action.

#### Fetch parsed Bonding curve pool info

{% tabs %}
{% tab title="Code Snippet" %}
{% code overflow="wrap" %}

```javascript
async function getBondingCurveByPoolAddress(address) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  //query to get Bonding Curve details on Launchpad by pool address
  const operationsDoc = `
        query MyQuery {
            raydium_launchpad_PoolState(
                where: {pubkey: {_eq: ${JSON.stringify(address)}}}
            ) {
                supply
                total_base_sell
                total_quote_fund_raising
                virtual_base
                virtual_quote
                real_base
                real_quote
                pubkey
            }
        }`; //you can cherrypick the fields as per your requirement

  const result = await fetch(
    `https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
    {
      method: "POST",
      body: JSON.stringify({
        query: operationsDoc,
        variables: {},
        operationName: "MyQuery",
      }),
    }
  );

  const { errors, data } = await result.json();

  if (errors) {
    console.error(errors);
    console.log(
      "Failed to fetch data, please provide correct API key or pool address."
    );
    return;
  }

  console.dir(data, { depth: null });
}

getBondingCurveByPoolAddress("4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU");
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "raydium_launchpad_PoolState": [
    {
      "supply": 100000000000000,
      "total_base_sell": 80000000000000,
      "total_quote_fund_raising": 85000000000,
      "virtual_base": 106666666666666,
      "virtual_quote": 28333333333,
      "real_base": 408443396730,
      "real_quote": 108909810,
      "pubkey": "4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

The response contains the following fields which involves the fields of the bonding curve

* `supply`: Total base token supply in the bonding curve.
* `total_base_sell`: Total base tokens sold so far via the curve.
* `total_quote_fund_raising`: Total SOL (quote tokens) raised from buyers.
* `virtual_base` & `virtual_quote`: Curve parameters that define price behavior depending on the curve type (e.g., for Constant Product or Fixed Price).
* `real_base` & `real_quote`: Actual on-chain token balances in the pool vaults (useful for pricing and tracking liquidity backing).
* `curveType` (Available on Global Config): A curvetype `0` indicates a constant curve, `1` means constant price, and `2` means linear. This data is essential for token price calculation.

However, these are not the only fields available in the <mark style="color:yellow;">PoolState</mark> account, other fields such as `quote_mint`, `base_mint` can also be cherrypicked, or omitted as per your requirement.&#x20;

In the next example we will explore how we can fetch more Pool details on Raydium Launchpad, which is as simple as adding more fields on the request query.

#### Fetch parsed Bonding curve pool info

{% tabs %}
{% tab title="Code Snippet" %}
{% code overflow="wrap" %}

```javascript
async function getDetailsByPoolAddress(address) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  //query to get Pool details on Launchpad by pool address
  const operationsDoc = `
        query MyQuery {
            raydium_launchpad_PoolState(
                where: {pubkey: {_eq: ${JSON.stringify(address)}}}
            ) {
                supply
                total_base_sell
                total_quote_fund_raising
                virtual_base
                virtual_quote
                real_base
                real_quote
                pubkey
                migrate_type
                migrate_fee
                base_mint
                base_vault
                base_decimals
                quote_vault
                quote_mint
                quote_decimals
            }
        }`; //more fields are selected here

  const result = await fetch(
    `https://programs.shyft.to/v0/graphql/accounts?api_key=${SHYFT_API_KEY}&network=mainnet-beta`, //SHYFT's GQL endpoint
    {
      method: "POST",
      body: JSON.stringify({
        query: operationsDoc,
        variables: {},
        operationName: "MyQuery",
      }),
    }
  );

  const { errors, data } = await result.json();

  if (errors) {
    console.error(errors);
    console.log(
      "Failed to fetch data, please provide correct API key or pool address."
    );
    return;
  }

  console.dir(data, { depth: null });
}

getDetailsByPoolAddress("4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU");
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
    "raydium_launchpad_PoolState": [
    {
        "supply": 100000000000000,
        "total_base_sell": 80000000000000,
        "total_quote_fund_raising": 85000000000,
        "virtual_base": 106666666666666,
        "virtual_quote": 28333333333,
        "real_base": 408443396730,
        "real_quote": 108909810,
        "pubkey": "4yhL99wpeeM2ptRT6U81hG8P3bCaCNabuw28gSBTCemU",
        "migrate_type": 0,
        "migrate_fee": 0,
        "base_mint": "9uteNEMLWir4UvgoNBpRByRhzE2htUkuAp3i5gRatray",
        "base_vault": "2bESZid9MH3W7r9MdgA7wKsp5QdQuzQXYaboTP9SDHsH",
        "base_decimals": 6,
        "quote_vault": "3cHwS7rbS4pkGF3wkw79heEdXc1CU2aAfzprJ83gv9LF",
        "quote_mint": "So11111111111111111111111111111111111111112",
        "quote_decimals": 9
    }
  ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shyft.to/solana-indexers/case-studies/raydium-launchpad/get-bonding-curve-details-by-pool-address.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
