Get all Pools of a Margin Account
Get all pools attached to a particular margin account 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 getAllPoolsperMargin(marginAddr) {
//fields can be selected as per requirement
const query = gql`
query MyQuery {
Tensor_Pool(where: {margin: {_eq: ${JSON.stringify(marginAddr)}}}) {
createdUnixSeconds
Margin {
poolsAttached
lamports
}
nftAuthority
nftsHeld
orderType
owner
margin
}
}
`;
const response = await graphQLClient.request(query);
console.dir(response,{depth: null});
}
getAllPoolsperMargin('11HQ8NxwY3A6D4WUoYcUM4KRUUVSVRRJXpCMe4oTp4H')
//replace with margin account addressLast updated