Skip to main content

User Positions

Query all positions held by a specific account.

Query Structure​

query GetUserPositions($accountId: String!, $limit: Int!) {
positions(
where: { account_id: { _eq: $accountId } }
order_by: { shares: desc }
limit: $limit
) {
id
shares
vault {
term_id
current_share_price
term {
atom { label image }
triple {
subject { label }
predicate { label }
object { label }
}
}
}
}
}

Interactive Example​

Query

query GetUserPositions($accountId: String!, $limit: Int!) {
  positions(
    where: { account_id: { _eq: $accountId } }
    order_by: { shares: desc }
    limit: $limit
  ) {
    id
    shares
    vault {
      term_id
      current_share_price
      market_cap
    }
  }
}

Variables

Click "Run Query" to execute the GraphQL query and see results

Best Practices​

  1. Order by shares to show largest positions first
  2. Include vault data for context
  3. Use aggregates for totals
  4. Filter by shares > 0 for active positions