Get Pool by Token Address
Get pool details from Orca for a token address.
Fetch pools with Jito token
import { gql, GraphQLClient } from 'graphql-request';
const endpoint = `https://programs.shyft.to/v0/graphql?api_key=YOUR-API-KEY`; //Shyft's gQl endpoint
const graphQLClient = new GraphQLClient(endpoint, {
method: `POST`,
jsonSerializer: {
parse: JSON.parse,
stringify: JSON.stringify,
},
}); //Initialize gQL Client
async function getWhirlpoolsforToken(tokenAddress) {
//you can cherry pick fields as per your requirements
const query = gql`
query MyQuery {
ORCA_WHIRLPOOLS_whirlpool(
where: {liquidity: {_gt: "0"}, tokenMintB: {_eq: ${JSON.stringify(tokenAddress)}}}
) {
tokenMintA
tokenMintB
rewardInfos
tickCurrentIndex
liquidity
whirlpoolsConfig
pubkey
}
}
`;
const response = await graphQLClient.request(query);
console.dir(response,{depth: null});
}
getWhirlpoolsforToken('J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn');
//replace this with token address for which you want to get PoolsFetch Token Pairs SOL-USDC
Last updated