Get Pool by Token Addresses
Fetch all liquidity pools involving specific tokens for Meteora DLMM
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 pairFetch Pool for a particular Token (USDC)
Last updated