Get Positions for a Pool

Get all positions for a liquidity pool on Orca Whirlpool.

Whenever users interact with liquidity pools, or trade financial assets, they get a position with respect to that particular pool. Once we have the pool address we can query all the positions respect to that particular pool, by filtering the position accounts data using GraphQl.

You can directly copy paste this code on replit and see it in action.

import { gql, GraphQLClient } from "graphql-request";

const endpoint = ``;

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 {
        where: {liquidity: {_gt: "0"}, whirlpool: {_eq: ${JSON.stringify(poolAddress)}}}
      ) {

  const response = await graphQLClient.request(query);
  console.dir(response,{depth: null});
//you can enter pool address as per your requirement

Last updated