Get all Pools by Owner
Getting all pools created by one particular wallet on Tensor
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 getAllPoolsByUser(walletAddr) {
//you can select particular fields as per your requirement
const query = gql`
query MyQuery {
Tensor_Pool(
where: {owner: {_eq: ${JSON.stringify(walletAddr)}}}
) {
frozen
createdUnixSeconds
Margin {
owner
poolsAttached
lamports
}
nftAuthority
nftsHeld
orderType
owner
}
}
`;
const response = await graphQLClient.request(query);
console.dir(response,{depth: null});
}
getAllPoolsByUser('9XNuYM6ktSL4KcATv3seDBVhWAmVHEU42foY4t7skygg')
//replace this address to get all Pools of one particular ownerLast updated