Get Positions for a Wallet

Fetch a wallet's open positions in Orca pools.

When combined with SHYFT APIs/SDK or DAS, we can also query all the position details with respect to a pool using graphQl. This involves two simple steps,

  • We use SHYFT's APIs/SDK to get all the Orca position mints from a users wallet.

  • We use the position mint to query Orca's position accounts using GraphQL.

The steps are illustrated below.

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

const endpoint = ``; //Shyft's gQl endpoint

const graphQLClient = new GraphQLClient(endpoint, {
  method: `POST`,
  jsonSerializer: {
    parse: JSON.parse,
    stringify: JSON.stringify,
}); //Initialize gQL Client

async function getFeesOwedbyWallet(walletAddr) {
    const token = await getWhirlpoolPositionToken(walletAddr);

    const query = gql`
    query MyQuery {
          where: {positionMint: {_eq: ${JSON.stringify(token.address)}}}
        ) {

  const response = await graphQLClient.request(query);
  console.dir(response,{depth: null});

Please note that, the Orca Whirlpool position token can be fetched from a users wallet using multiple ways, one of which is illustrated below

import { Network, ShyftSdk } from '@shyft-to/js';
const shyft = new ShyftSdk({ apiKey: "YOUR-API-KEY", network: Network.Mainnet }); //Initialize Shyft SDK
async function getWhirlpoolPositionToken(walletAddress)
    const getAllTokens = await shyft.nft.getNftByOwner(walletAddress);
    //using SHYFT SDK to get all Tokens
    console.log("Total Tokens: ",getAllTokens.length);

    for(let i = 0; i < getAllTokens.length; i++){
        const token = getAllTokens[i];

        if(token.update_authority === "3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr" &&"Orca Whirlpool Position")){
            return {
                success: true,
    return {
        success: false,
        address: ""

All whirlpool position tokens have the update_authority as 3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr and the name as 'Orca Whirlpool Position'. Also, please note that in this case we have considered the wallet address has only one Position token. A wallet can have multiple position token, and in that case, we would have to query with each position token in the users wallet in order to get the desired Whirlpool position details.

Last updated