Get Positions for a Wallet
Fetch a wallet's open positions in Orca pools.
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')
Last updated