TopTraders

Example of subscription that makes 2 queries in one subscription and filtering of amount from mempool

By Name · saved 18 November 2024 · run 6 times · Bitquery API v2

What it returns

Filters

The query

query TopTraders($token: String, $base: String) {
  Solana {
    DEXTradeByTokens(
      orderBy: {descendingByField: "volume"}
      limit: {count: 100}
      where: {Trade: {Currency: {MintAddress: {is: $token}}, Side: {Amount: {gt: "0"}, Currency: {MintAddress: {is: $base}}, Type: {}}}, Transaction: {Result: {Success: true}}}
    ) {
      Trade {
        Account {
          Owner
        }
        Dex {
          ProgramAddress
          ProtocolFamily
          ProtocolName
        }
      }
      boughtTokens: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: buy}}}})
      boughtTokensInWsol: sum(
        of: Trade_Side_Amount
        if: {Trade: {Side: {Type: {is: buy}}}}
      )
      boughtTimes: count(if: {Trade: {Side: {Type: {is: buy}}}})
      soldTokens: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: sell}}}})
      soldTokensInWsol: sum(
        of: Trade_Side_Amount
        if: {Trade: {Side: {Type: {is: sell}}}}
      )
      soldTimes: count(if: {Trade: {Side: {Type: {is: sell}}}})
      volume: sum(of: Trade_Amount)
    }
    DEXTrades(
      limitBy: {count: 1, by: Trade_Buy_Currency_MintAddress}
      orderBy: {descending: Block_Time}
      where: {Trade: {Buy: {Currency: {MintAddress: {is: $token}}}}, Transaction: {Result: {Success: true}}}
    ) {
      Trade {
        Buy {
          Currency {
            MintAddress
          }
          currentPriceTokenInWsol: Price(selectWhere: {gt: 0})
        }
      }
    }
  }
}

Variables

{
  "token": "8ed1atmV8B2kVeZCr6DzSjBAkMtT95U4qmQ9wQE3pump",
  "base": "So11111111111111111111111111111111111111112"
}

Similar queries