Get Pool by Address
Fetch an Orca pool by pubkey.
Fetch parsed pool info
import { Connection, PublicKey } from "@solana/web3.js";
import { gql, GraphQLClient } from "graphql-request";
const SHYFT_API_KEY = 'YOUR-KEY';
const graphQLEndpoint = `https://programs.shyft.to/v0/graphql/?api_key=${SHYFT_API_KEY}`;
const graphQLClient = new GraphQLClient(graphQLEndpoint, {
method: `POST`,
jsonSerializer: {
parse: JSON.parse,
stringify: JSON.stringify,
},
});
async function queryOrcaPool(address:string) {
// We only fetch fields necessary for us
const query = gql`
query MyQuery {
ORCA_WHIRLPOOLS_whirlpool(
where: {pubkey: {_eq: ${JSON.stringify(address)}}}
) {
feeGrowthGlobalA
feeGrowthGlobalB
feeRate
liquidity
protocolFeeOwedA
protocolFeeOwedB
protocolFeeRate
rewardLastUpdatedTimestamp
sqrtPrice
tickCurrentIndex
tickSpacing
tokenMintA
tokenMintB
tokenVaultA
tokenVaultB
whirlpoolsConfig
rewardInfos
tickSpacingSeed
whirlpoolBump
pubkey
}
}`;
return await graphQLClient.request(query);
}
//This is WEN-USDC pool addres
const poolInfo = await queryOrcaPool('5y2jFFA3A8GNjRnVMg8LfTHbBg7y2vivopiK8LmGRP2B');
console.log(poolInfo)Last updated