Queries
Query examples provided for the DFX subgraphs
All the query examples can be tested on the playground in the subgraphs provided below

DFX Factory

Total liquidity, volume, and pools

This query gets the all time information about DFX
1
{
2
dfxfactories {
3
id
4
pairCount
5
totalVolumeUSD
6
totalLiquidityUSD
7
}
8
}
Copied!

DFX Day Data

Daily snapshots of all total liquidity and volume

This query gets the daily snapshots on the all time information about DFX such as the US dollar value of the total liquidity and total volume across all DFX pools
1
{
2
dfxdayDatas (
3
orderBy: date
4
orderDirection: asc
5
){
6
totalVolumeUSD
7
totalLiquidityUSD
8
}
9
}
Copied!

Trade

This query gets the latest 10 trades that were made in a pool. i.e. the EURS/USDC pool
1
{
2
trades (
3
first: 10
4
orderBy: timestamp
5
orderDirection:desc
6
where: {
7
pair: "0x1a4ffe0dcbdb4d551cfca61a5626afd190731347"
8
}
9
){
10
timestamp
11
trader
12
origin
13
target
14
originAmount
15
targetAmount
16
}
17
}
Copied!

Pair

Pairs

This query lists the all pairs offered by DFX
1
{
2
pairs {
3
id
4
token0{
5
name
6
}
7
token1 {
8
name
9
}
10
swapRateUSD
11
}
12
}
Copied!

Pair by ID

This query gets a pair by its id (contract address). For example below is the EURS/USDC pool
1
{
2
pairs (
3
where: {
4
id: "0x1a4ffe0dcbdb4d551cfca61a5626afd190731347"
5
}
6
){
7
id
8
token0{
9
name
10
}
11
token1 {
12
name
13
}
14
swapRateUSD
15
}
16
}
Copied!

Pairs ordered by liquidity

This query lists the all pairs offered by DFX ordered by liquidity in descending direction
1
{
2
pairs(
3
orderBy: reserveUSD
4
orderDirection: desc
5
){
6
id
7
reserveUSD
8
}
9
}
Copied!

Pairs ordered by volume

This query lists the all pairs offered by DFX ordered by volume in descending direction
1
{
2
pairs(
3
orderBy: volumeUSD
4
orderDirection: desc
5
){
6
id
7
volumeUSD
8
}
9
}
Copied!

Pair Day Data

This query lists a pair's data for a particular day ordered by date in ascending direction. For example below is the CADC/USDC pool
1
{
2
pairDayDatas(
3
orderBy: date
4
orderDirection: asc
5
where: {
6
pair: "0xa6c0cbcaebd93ad3c6c94412ec06aaa37870216d"
7
}
8
){
9
date
10
swapRateUSD
11
reserveUSD
12
volumeUSD
13
participantCount
14
}
15
}
Copied!

Token

Tokens

This query lists the all tokens offered on DFX
1
{
2
tokens {
3
id
4
name
5
symbol
6
decimals
7
priceUSD
8
}
9
}
Copied!

Token by ID

This query gets a token by its id (contract address) For example below is the USDC token
1
{
2
tokens (
3
where: {
4
id: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
5
}
6
){
7
id
8
name
9
symbol
10
decimals
11
priceUSD
12
}
13
}
Copied!

Token Day Data

This query lists a pair's data for a particular day ordered by date in ascending direction. For example below is the CADC/USDC pool
1
{
2
tokenDayDatas (
3
orderBy: date
4
orderDirection: asc
5
where: {
6
token:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
7
}
8
){
9
id
10
dailyVolumeUSD
11
priceUSD
12
}
13
}
Copied!

Pool Participants

Volume

This query lists the top 5 addresses by trading volume in a pool. For example below is the CADC/USDC pool
1
{
2
poolParticipants (
3
orderBy: volumeUSD
4
orderDirection: desc
5
first: 5
6
where: {
7
pair: "0xa6c0cbcaebd93ad3c6c94412ec06aaa37870216d"
8
}
9
){
10
id
11
volumeUSD
12
}
13
}
Copied!
Last modified 23d ago