> For the complete documentation index, see [llms.txt](https://docs.shyft.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shyft.to/solana-indexers/case-studies/raydium-launchpad/get-pools-by-token-addresses.md).

# Get Pools by Token Addresses

Raydium Launchpad uses bonding curve pools to launch tokens, with each pool defined by a <mark style="color:yellow;">token pair</mark> (also known as liquidity pair). This pair is represented by the `baseMint` (the launched token) and `quoteMint` (the token used to buy it). We can apply filters to these fields to retrieve specific pool details involving a particular token pair.\
\
For instance we are trying to get liquidity pools involving CHUCK token and SOL, so we filter `baseMint`and `quoteMint`fields using the *\_in* filter.

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

#### Fetch Pool by Liquidity Pair (CHUCK-SOL)

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

```javascript
async function getPoolDetailsByLiquidtyPair(mintAddressA, mintAddressB) {
    const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
    //query to get pool details on Launchpad by liquidity pair
    const operationsDoc = `
      query MyQuery {
        raydium_launchpad_PoolState(where: {base_mint: {_in: ${JSON.stringify([
        mintAddressA,
        mintAddressB,
      ])}}, quote_mint: {_in: ${JSON.stringify([
        mintAddressA,
        mintAddressB,
      ])}}}) {    
                    total_base_sell
                    total_quote_fund_raising
                    virtual_base
                    virtual_quote
                    real_base
                    real_quote
                    pubkey
                    base_mint
                    base_vault
                    base_decimals
                    quote_vault
                    quote_mint
                    quote_decimals
                    creator
            }
        }
`; //you can cherrypick the fields as per your requirement

  const result = await fetch(
    `https://programs.shyft.to/v0/graphql?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();

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

getPoolDetailsByLiquidtyPair("AzDFgqyGq1drDHyxTpVUf5dXLQd74P3m5sspJXgnbray","So11111111111111111111111111111111111111112");
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "raydium_launchpad_PoolState": [
    {
      "supply": 1000000000000000,
      "total_base_sell": 793100000000000,
      "total_quote_fund_raising": 85000000000,
      "virtual_base": 1073025605596382,
      "virtual_quote": 30000852951,
      "real_base": 3362661090671,
      "real_quote": 94312608,
      "pubkey": "DH9yxXuEVVZDckygk3rjyCuCiCruZh5UjNEqPRpinhvs",
      "migrate_type": 0,
      "migrate_fee": 0,
      "base_mint": "AzDFgqyGq1drDHyxTpVUf5dXLQd74P3m5sspJXgnbray",
      "base_vault": "ACxk6fqKasawUyHfUyEXjco72zDHVbSuXtZNniKo8Bf1",
      "base_decimals": 6,
      "quote_vault": "3Z9991PEpofHaA3SyN7K7cBhU2zrvi6TgdJEhz4fEYsT",
      "quote_mint": "So11111111111111111111111111111111111111112",
      "quote_decimals": 9,
      "creator": "8yxpxgHkuK323jhxQ4qawKsq2SpePaPV5qYZL8sZ3edX"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

We can also query liquidity pool involving a particular <mark style="color:yellow;">token address</mark>, for that we would have to filter the `baseMint` or `quoteMint` field using the *\_in* filter.

#### Fetch Pools involving a Token

{% tabs %}
{% tab title="Code Snippet" %}

```javascript
async function getPoolsForAToken(mintAddress) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  const operationsDoc = `
		query MyQuery {
            raydium_launchpad_PoolState(where: {_or: [{_or: {base_mint: {_eq: ${JSON.stringify(
              mintAddress
            )}}}},{_or: {quote_mint: {_eq: ${JSON.stringify(
    mintAddress
  )}}}}]}) {
              total_base_sell
              total_quote_fund_raising
              virtual_base
              virtual_quote
              real_base
              real_quote
              pubkey
              base_mint
              base_vault
              base_decimals
              quote_vault
              quote_mint
              quote_decimals
              creator
            }
        }
		`; //you can cherrypick the fields as per your requirement

  const result = await fetch(
    `https://programs.shyft.to/v0/graphql?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();

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

getPoolsForAToken("C4cAaJyaeKGpCLRRwuPSh6J76vytgPUzE265PtBrWray");
```

{% endtab %}

{% tab title="Response" %}

```json
{
  "raydium_launchpad_PoolState": [
    {
      "total_base_sell": 793100000000000,
      "total_quote_fund_raising": 85000000000,
      "virtual_base": 1073025605596382,
      "virtual_quote": 30000852951,
      "real_base": 3540872139,
      "real_quote": 99005,
      "pubkey": 'DSUdt9zUrxSe5QXQbjtVvm4qXHboG7jKMp12QoMkuN1e',
      "base_mint": 'C4cAaJyaeKGpCLRRwuPSh6J76vytgPUzE265PtBrWray',
      "base_vault": 'EJgxfswUpZmkfBZCPDyDYPzgMXduCJztRH4pWAHqgkXv',
      "base_decimals": 6,
      "quote_vault": 'T1M3iHY9aZfkGywjqVh9vcgLm1e3cFFypCL4UHtg1ND',
      "quote_mint": 'So11111111111111111111111111111111111111112',
      "quote_decimals": 9,
      "creator": 'HrbmBQdxp5QWTE3wB5eBQ9ZmkawMLWwYv1nVJznTr4h4'
    }
  ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.shyft.to/solana-indexers/case-studies/raydium-launchpad/get-pools-by-token-addresses.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
