Trades metadata along with price

Returns the latest DEX trade by token on Solana, where currency mint address is GbNqCE…B81m, side currency mint address is So1111…1112 and DEX protocol name is raydium_amm: protocol family, protocol name, price in USD, currency name, currency symbol, decimals, fungible and 4 more fields.

By Chrome · saved 30 September 2024 · run 2 times · Bitquery API v2

What it returns

Filters

The query

query ($token: String, $base: String) {
  Solana {
    DEXTradeByTokens(
      orderBy: {descending: Block_Time}
      where: {Trade: {Currency: {MintAddress: {is: $token}}, Side: {Amount: {gt: "0"}, Currency: {MintAddress: {is: $base}}}, Dex: {ProtocolName: {is: "raydium_amm"}}}, Transaction: {Result: {Success: true}}, Block: {Time: {since: "2024-09-30T15:09:03Z"}}}
      limit: {count: 1}
    ) {
      Trade {
        Dex {
          ProtocolFamily
          ProtocolName
        }
        price: PriceInUSD(maximum: Block_Slot)
        price_from_block: PriceInUSD(minimum: Block_Slot)
        Currency {
          Name
          Symbol
          Decimals
          Fungible
          MetadataAddress
        }
      }
      amount: sum(of: Trade_Side_Amount)
      pairs: uniq(of: Trade_Side_Currency_MintAddress)
      trades: count
      buy_trades: count(if: {Trade: {Side: {Type: {is: buy}}}})
      sell_trades: count(if: {Trade: {Side: {Type: {is: sell}}}})
    }
  }
}

Variables

{
  "token": "GbNqCEFMVzc8BvcCKjZdGVYMbc7sSqdu8EHsBpsMB81m",
  "base": "So11111111111111111111111111111111111111112",
  "time_3h_ago": "2024-09-30T15:09:03Z"
}

Similar queries