LogoLogo
TwitterTelegramDiscordMedium
  • 👋Welcome to DFX Finance
  • Protocol
    • 🏭DFX AMM
    • 🏛️Protocol Governance
      • 🗳️Proposal Process
        • Proposal Forum
        • Proposal Template
        • Vote on Proposals
      • 🪙DFX Token
      • 🪙veDFX
        • 🔐Lock Details
          • 🔒How to Lock?
        • 🎛️Gauges
        • 🚀Boost
      • 📸Snapshot
    • ⛏️Liquidity Mining
      • 🤔What is Liquidity Mining?
      • ➕How to Supply Liquidity
      • 💱Swaps & Liquidity Pools
      • 📊Current Yield Rates
    • 🧠Education Zone
      • ❔What is DFX?
        • 🇨🇳什么是 DFX Finance
        • 🇳🇱Wat is DFX Finance?
        • 🇫🇷Le protocole DFX Finance?
        • 🇩🇪Was ist DFX Finance?
        • 🇮🇱מהו DFX פיננסים?
        • 🇮🇳DFX फाइनेंस क्या है?
        • 🇵🇹O que é DFX Finance?
        • 🇪🇸Que es DFX?
        • 🇮🇳DFX పరిచయం
        • 🇹🇷DFX Finans Nedir ?
      • ➕How to Supply Liquidity
      • 💱Swaps & Liquidity Pools
      • 🔒How to Lock?
      • 🔗Migrate from V1 to V2
    • 🏆DFX Grants Program
      • 🐲Ambassador Program
  • Dev Zone
    • 🕸️Subgraphs
      • Entities
      • Queries
      • 📖Read Me
    • 📃Smart Contracts
      • 3️⃣𝓥3
      • 2️⃣V2
    • 📃Deprecated Smart Contracts
  • Stablecoins
    • 🇺🇸USDC
    • 🇨🇦CADC
    • 🇪🇺EURC
    • 🇬🇧GBPT
    • 🇯🇵GYEN
    • 🇳🇬NGNC
    • 🇹🇷TRYB
    • 🇸🇬XSGD
    • 🇮🇩XIDR
  • Communities
    • X (Formally Twitter)
    • Medium
    • Discord
    • Telegram
    • LinkedIn
  • FAQs
    • ❔General Questions
    • 🏭Create Pools
    • 🪙DFX Migration / Bridge
    • 📊Analytics
    • 💸 KPI Options
    • 🌌Reimbursement Plan
    • 📰DFX Media Kit
    • ✅Protocol Audits
Powered by GitBook
On this page
  • DFX Factory
  • Total liquidity, volume, and pools
  • DFX Day Data
  • Daily snapshots of all total liquidity and volume
  • Trade
  • Pairs
  • Pair by ID
  • Pairs ordered by liquidity
  • Pairs ordered by volume
  • Pair Day Data
  • Tokens
  • Token by ID
  • Token Day Data
  • Pool Participants
  • Volume

Was this helpful?

  1. Dev Zone
  2. Subgraphs

Queries

Query examples provided for the DFX subgraphs

PreviousEntitiesNextRead Me

Last updated 1 year ago

Was this helpful?

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

{
  dfxfactories {
    id
    pairCount
    totalVolumeUSD
    totalLiquidityUSD
  }
}

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

{
  dfxdayDatas (
    orderBy: date
    orderDirection: asc
  ){
    totalVolumeUSD
    totalLiquidityUSD
  }
}

Trade

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
  }
}

Pairs

This query lists the all pairs offered by DFX

{
  pairs {
    id
    token0{
      name
    }
    token1 {
      name
    }
    swapRateUSD
  }
}

Pair by ID

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
  }
}

Pairs ordered by liquidity

This query lists the all pairs offered by DFX ordered by liquidity in descending direction

{
  pairs(
    orderBy: reserveUSD
    orderDirection: desc
  ){
    id
    reserveUSD
  }
}

Pairs ordered by volume

This query lists the all pairs offered by DFX ordered by volume in descending direction

{
  pairs(
    orderBy: volumeUSD
    orderDirection: desc
  ){
    id
    volumeUSD
  }
}

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

{
  pairDayDatas(
    orderBy: date
    orderDirection: asc
    where: {
      pair: "0xa6c0cbcaebd93ad3c6c94412ec06aaa37870216d"
    }
  ){
    date
    swapRateUSD
    reserveUSD
    volumeUSD
    participantCount
  }
}

Tokens

This query lists the all tokens offered on DFX

{
  tokens {
    id
    name
    symbol
    decimals
    priceUSD
  }
}

Token by ID

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
  }
}

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

{
  tokenDayDatas (
    orderBy: date
    orderDirection: asc
    where: {
      token:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
    }
  ){
    id
    dailyVolumeUSD
    priceUSD
  }
}

Pool Participants

Volume

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
  }
}
🕸️
Mainnet Subgraph
Polygon Subgraph