Queries
Query examples provided for the DFX subgraphs
All the query examples can be tested on the playground in the subgraphs provided below
This query gets the all time information about DFX
{
dfxfactories {
id
pairCount
totalVolumeUSD
totalLiquidityUSD
}
}
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
{
dfxdayDatas (
orderBy: date
orderDirection: asc
){
totalVolumeUSD
totalLiquidityUSD
}
}
This query gets the latest 10 trades that were made in a pool. i.e. the EURS/USDC pool
{
trades (
first: 10
orderBy: timestamp
orderDirection:desc
where: {
pair: "0x1a4ffe0dcbdb4d551cfca61a5626afd190731347"
}
){
timestamp
trader
origin
target
originAmount
targetAmount
}
}
This query lists the all pairs offered by DFX
{
pairs {
id
token0{
name
}
token1 {
name
}
swapRateUSD
}
}
This query gets a pair by its id (contract address). For example below is the EURS/USDC pool
{
pairs (
where: {
id: "0x1a4ffe0dcbdb4d551cfca61a5626afd190731347"
}
){
id
token0{
name
}
token1 {
name
}
swapRateUSD
}
}
This query lists the all pairs offered by DFX ordered by liquidity in descending direction
{
pairs(
orderBy: reserveUSD
orderDirection: desc
){
id
reserveUSD
}
}
This query lists the all pairs offered by DFX ordered by volume in descending direction
{
pairs(
orderBy: volumeUSD
orderDirection: desc
){
id
volumeUSD
}
}
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
{
pairDayDatas(
orderBy: date
orderDirection: asc
where: {
pair: "0xa6c0cbcaebd93ad3c6c94412ec06aaa37870216d"
}
){
date
swapRateUSD
reserveUSD
volumeUSD
participantCount
}
}
This query lists the all tokens offered on DFX
{
tokens {
id
name
symbol
decimals
priceUSD
}
}
This query gets a token by its id (contract address) For example below is the USDC token
{
tokens (
where: {
id: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
}
){
id
name
symbol
decimals
priceUSD
}
}
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
{
tokenDayDatas (
orderBy: date
orderDirection: asc
where: {
token:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
}
){
id
dailyVolumeUSD
priceUSD
}
}
This query lists the top 5 addresses by trading volume in a pool. For example below is the CADC/USDC pool
{
poolParticipants (
orderBy: volumeUSD
orderDirection: desc
first: 5
where: {
pair: "0xa6c0cbcaebd93ad3c6c94412ec06aaa37870216d"
}
){
id
volumeUSD
}
}
Last modified 2mo ago