The OKTC Swap subgraph provides valuable insights into swap activities, pairs, tokens, transactions, and user interactions. This guide offers practical examples for common queries you can run to extract meaningful data.
👉 Explore live queries on our GraphQL interface
Understanding Block Data
Block Status Overview
Retrieve the latest synchronization status of blocks with this sample query:
query {
blocks(first: 1, orderBy: number, orderDirection: desc) {
id
number
timestamp
}
}Historical Block Queries
For past state snapshots, use The Graph's time-travel feature by specifying a previous block number:
query {
blocks(first: 1, orderBy: number, orderDirection: desc, block: { number: 12345678 }) {
id
number
timestamp
}
}Analyzing Pair Information
Pair Snapshot
Get current pair statistics with this USDT/WOKT example:
query {
pair(id: "0x...") {
id
token0 {
id
symbol
}
token1 {
id
symbol
}
reserve0
reserve1
reserveUSD
volumeUSD
}
}Complete Pair List
Retrieve all pairs in OKTC Swap (note the 1000-entity limit):
query {
pairs(first: 1000, skip: $skip) {
id
token0 {
symbol
}
token1 {
symbol
}
}
}Top Liquidity Pairs
Identify the most liquid pairs:
query {
pairs(first: 10, orderBy: reserveUSD, orderDirection: desc) {
id
token0 {
symbol
}
token1 {
symbol
}
reserveUSD
}
}Recent Pair Activity
View the last 100 swaps in a specific pair:
query {
swaps(first: 100, orderBy: timestamp, orderDirection: desc, where: { pair: "0x..." }) {
id
amount0In
amount1Out
timestamp
transaction {
id
}
}
}Examining Token Metrics
Token Performance Overview
Get WOKT token statistics:
query {
token(id: "0x...") {
id
name
symbol
totalLiquidity
tradeVolume
derivedETH
}
}Token Transactions
Track recent activity for a token:
query {
mints(first: 10, orderBy: timestamp, orderDirection: desc, where: { token: "0x..." }) {
id
amount
timestamp
}
burns(first: 10, orderBy: timestamp, orderDirection: desc, where: { token: "0x..." }) {
id
amount
timestamp
}
swaps(first: 10, orderBy: timestamp, orderDirection: desc, where: { token: "0x..." }) {
id
amountIn
amountOut
timestamp
}
}👉 Access advanced token analytics
FAQ Section
How often is the subgraph updated?
The subgraph updates in near real-time, typically within seconds of new blocks being confirmed.
What's the maximum number of entities I can query?
The Graph currently limits returns to 1000 entities per query. Use pagination with skip/limit parameters for larger datasets.
Can I query historical data?
Yes, you can query historical states by specifying block numbers in your GraphQL queries.
How do I find token/pair addresses?
Token and pair addresses can be found through the OKTC Swap interface or by querying the relevant subgraph entities.
What's the difference between reserveUSD and volumeUSD?
ReserveUSD shows the current liquidity pool value, while volumeUSD represents cumulative trading volume.
Key Takeaways
- The OKTC Swap subgraph provides comprehensive on-chain data through GraphQL queries
- Essential data points include block information, pair statistics, and token metrics
- Query efficiently by using proper sorting, filtering, and pagination
- Historical data access enables powerful time-series analysis
For developers building on OKTC Swap, mastering these queries unlocks valuable insights for analytics dashboards, trading tools, and protocol monitoring solutions.