Get Positions for a Pool
Get all positions for a liquidity pool on Orca Whirlpool.
import { gql, GraphQLClient } from "graphql-request";
const endpoint = `https://programs.shyft.to/v0/graphql/?api_key=YOUR-KEY`;
const graphQLClient = new GraphQLClient(endpoint, {
method: `POST`,
jsonSerializer: {
parse: JSON.parse,
stringify: JSON.stringify,
},
});
async function getAllPositionsforWhirlpool(poolAddress) {
//you can add more fields as per your requirements
const query = gql`
query MyQuery {
ORCA_WHIRLPOOLS_position(
where: {liquidity: {_gt: "0"}, whirlpool: {_eq: ${JSON.stringify(poolAddress)}}}
) {
liquidity
positionMint
pubkey
whirlpool
}
}
`;
const response = await graphQLClient.request(query);
console.dir(response,{depth: null});
}
getAllPositionsforWhirlpool('ASdEzNQWHttmokANHz8DX2UnWsvgcVF2tN7eKe62Aj7o');
//you can enter pool address as per your requirementLast updated