Example: User Positions
Fetch user positions with aggregate statistics.
This example uses a live-verified account with populated positions; position counts and values change over time.
Account IDs are stored in EIP-55 checksummed form and _eq comparisons are case-sensitive β pass the address exactly as checksummed (as shown below), or the query silently returns empty results.
Queryβ
Query
query GetUserPositions($accountId: String!, $limit: Int!) {
stats: positions_aggregate(where: { account_id: { _eq: $accountId } }) {
aggregate {
count
sum { shares }
}
}
positions(
where: { account_id: { _eq: $accountId } }
order_by: { shares: desc }
limit: $limit
) {
id
shares
vault {
term_id
current_share_price
market_cap
term {
atom { label image }
}
}
}
}Variables
Click "Run Query" to execute the GraphQL query and see results