Get Solana Token Price

This supports pump fun and returns the last buy and the last sell price, the application should check which one is newer and use that

By Ramyo Bags · saved 8 December 2024 · run 3 times · Bitquery API v2

What it returns

Filters

The query

{
  Solana {
    lastBuy: DEXTrades(
      limit: {count: 1}
      orderBy: {descending: Block_Date}
      where: {
        Trade: {
          Buy: {
            Currency: {
              MintAddress: {is: "D2ExFFcrETK7PFWNLkzj3D2aubMGZmGHZke9GNdFpump"}
            }
            Price: {gt: 0}
            PriceInUSD: {gt: 0}
          }
        }
        Transaction: {Result: {Success: true}}
      }
    ) {
      Block {
        Time
      }
      Trade {
        Buy {
          Price
          PriceInUSD
          Currency {
            MintAddress
          }
        }
      }
    }
    lastSell: DEXTrades(
      limit: {count: 1}
      orderBy: {descending: Block_Date}
      where: {
        Trade: {
          Sell: {
            Currency: {
              MintAddress: {is: "D2ExFFcrETK7PFWNLkzj3D2aubMGZmGHZke9GNdFpump"}
            }
            Price: {gt: 0}
            PriceInUSD: {gt: 0}
          }
        }
        Transaction: {Result: {Success: true}}
      }
    ) {
      Block {
        Time
      }
      Trade {
        Sell {
          Price
          PriceInUSD
          Currency {
            MintAddress
          }
        }
      }
    }
  }
}

Similar queries