Get Pool by Token Addresses

Fetch all liquidity pools involving specific tokens for Meteora DLMM

Liquidity Pools are smart contract based vaults that are associated with specific liquidity token pairs. With SHYFT's GraphQL APIs, we can query Liquidity Pools based on the tokens associated with them for Meteora DLMM. The liquidity pairs are denoted by the following fields: tokenXMint and tokenYMint.

You can directly copy paste the following on replit and see it in action.

Fetch Pool for a Liquidity Pair (SOL-USDC)

async function getLBPairByTokenPair(tokenAddressX, tokenAddressY) {
  const SHYFT_API_KEY = "YOUR_SHYFT_API_KEY";
  //get Pools involving a specific liquidity pair
  const operationsDoc = `
	query MyQuery {
		meteora_dlmm_LbPair(
		where: {tokenXMint: {_in: ${JSON.stringify([tokenAddressX, tokenAddressY])}}, tokenYMint: {_in: ${JSON.stringify([tokenAddressX, tokenAddressY])}}}
		) {
			activationPoint
                        activationType
                        activeId
                        baseKey
                        binStep
                        creator
                        creatorPoolOnOffControl
                        lastUpdatedAt
                        oracle
                        padding4
                        pairType
                        parameters
                        preActivationDuration
                        preActivationSwapAddress
                        protocolFee
                        requireBaseFactorSeed
                        reserveX
                        reserveY
                        status
                        tokenMintXProgramFlag
                        tokenMintYProgramFlag
                        tokenXMint
                        tokenYMint
		}
	}
`; //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();

  console.dir(data, { depth: null });
}
getLBPairByTokenPair("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "So11111111111111111111111111111111111111112");
//fetching Pools for SOL-USDC pair

Fetch Pool for a particular Token (USDC)

Please note that the above query fetches all pools involving USDC as tokenXMint as well as tokenYMint in a single GraphQL request.

Last updated

Was this helpful?