Subgraph Query Examples
This doc will teach you how to query Struct analytics by writing GraphQL queries on the subgraph. You can fetch data points like:
- Total tokens locked in GMX markets
- USDC deposits over 10,000 since June 1st, 2023
- BTC.b senior tranches that are open for deposit
and much more. Below are some example queries. To run a query copy and paste it into the explorer to get fresh data.
Market Data
An example querying all listed GMX markets listed, the token addresses of the market pair, and their respective tokens locked:
{
platforms(where: {id: "0x46f8765781ac36e5e8f9937658fa311af9d735d7"}) {
id
markets {
tokenAddress0
tokenAddress1
totalTokensLocked0
totalTokensLocked1
}
}
}
Transaction Data
An example querying all USDC deposit transactions since June 1st, 2023 where the amount is greater than 10,000*, and returning the user address, tranche type, timestamp, and transaction hash:
{
transactions(
where: {
type: "Deposit",
tokenAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"
amount_gt: "10000000000000000000000",
timestamp_gt: "1685597969"
}) {
amount
userAddress
trancheType
timestamp
transactionHash
}
}
*All token amounts are denominated in 18 decimals, regardless of a particular token's decimals.
Tranche & Product Data
An example querying all BTC.b senior tranches which are still open for deposit, and returning the timestamp when the tranche will be invested:
{
trancheCreateds(
where: {
trancheType: "0",
tokenAddress: "0x152b9d0fdc40c096757f570a51e494bd4b943e50",
product_: {
status: 0
}
}) {
product {
trancheStartTime
}
}
}