> For the complete documentation index, see [llms.txt](https://docs.shyft.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shyft.to/solana-indexers/case-studies/orca-whirlpool/get-positions-for-a-wallet.md).

# Get Positions for a Wallet

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,&#x20;

* 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 <mark style="color:yellow;">position accounts</mark> using GraphQL.&#x20;

The steps are illustrated below.

{% tabs %}
{% tab title="Code Snippet" %}
{% code overflow="wrap" %}

```typescript

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 getFeesOwedbyWallet(walletAddr) {
    const token = await getWhirlpoolPositionToken(walletAddr);

    const query = gql`
    query MyQuery {
        ORCA_WHIRLPOOLS_position(
          where: {positionMint: {_eq: ${JSON.stringify(token.address)}}}
        ) {
          feeOwedB
          feeOwedA
          liquidity
          positionMint
          pubkey
          whirlpool
        }
      }
    `;

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

```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
  "data": {
    "ORCA_WHIRLPOOLS_position": [
      {
        "feeOwedB": 188,
        "feeOwedA": 2216,
        "liquidity": 54882,
        "positionMint": "E27sJ6dYK4nkWdZPaPYDdmSeYgbJSTaPDfTUMKXqst64",
        "pubkey": "6qQRFMwX6LFeYbXYpobRF28gqg7ZPtGKwj7zQGRWn3Gq",
        "whirlpool": "67S6KLCtgFZmRYzy6dCDc1v754mmcpK33pZd7Hg2yeVj"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

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

{% code overflow="wrap" %}

```typescript
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" && token.name.includes("Orca Whirlpool Position")){
            return {
                success: true,
                address: token.mint
            }
        }
    }
    return {
        success: false,
        address: ""
    }
}
```

{% endcode %}

All whirlpool position tokens have the <mark style="color:yellow;">update\_authority</mark> as <mark style="color:yellow;">`3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr`</mark> 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.\
&#x20;
