Get Pools by Token Addresses

Fetch Launchpad Pools based on a single Token Address or a Liquidity Pair

Raydium Launchpad uses bonding curve pools to launch tokens, with each pool defined by a token pair (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 baseMintand quoteMintfields using the _in filter.

You can directly copy paste this code on replit and see it in action.

Fetch Pool by Liquidity Pair (CHUCK-SOL)

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");

We can also query liquidity pool involving a particular token address, for that we would have to filter the baseMint or quoteMint field using the _in filter.

Fetch Pools involving a Token

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");

Last updated

Was this helpful?