Skip to main content

Example: Atom with Vault

Fetch atom metadata along with vault statistics.

Use Case​

Display atom information with market data on a detail page.

Query​

Query

query GetAtomWithVault($atomId: String!, $curveId: numeric!) {
  atom(term_id: $atomId) {
    term_id
    label
    image
    type
    created_at
    creator {
      id
      label
    }
    term {
      vaults(where: { curve_id: { _eq: $curveId } }) {
        curve_id
        total_shares
        total_assets
        current_share_price
        market_cap
        position_count
      }
    }
  }
}

Variables

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

Implementation​

import { GraphQLClient } from 'graphql-request'
import { API_URL_PROD } from '@0xintuition/graphql'

const client = new GraphQLClient(API_URL_PROD)

const query = `
query GetAtomWithVault($atomId: String!, $curveId: numeric!) {
atom(term_id: $atomId) {
term_id
label
image
term {
vaults(where: { curve_id: { _eq: $curveId } }) {
total_shares
market_cap
position_count
}
}
}
}
`

const data = await client.request(query, {
atomId: '0x...',
curveId: '1'
})