Tron DEX API: SunSwap and SunPump Trades, Prices and OHLC with GraphQL
Query and stream every DEX trade on Tron across SunSwap v1, v2 and v3, SunPump and StableSwap: live swaps with USD prices, a token's trades and OHLC, its top traders, new launches and per-wallet history, with queries run on the current Bitquery API.

Tron's DEX activity runs through a small set of venues: SunSwap, whose v1 pools are the former JustSwap and whose v2 and v3 pools follow the Uniswap v2 and v3 designs, SunPump, the bonding-curve launchpad whose graduates move to SunSwap, and a StableSwap pool set for stablecoins. Bitquery indexes all of them, and this post shows the queries for trades, prices, candles, traders, new launches and wallet history on the Tron blockchain. The 2021 version of this post announced the first Tron DEX support on the V1 API; every query below runs on the current API and was run against it before publishing.
The chain's native asset appears in two forms in the data: TRX itself, and WTRX, the wrapped token at TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR that most SunSwap pools quote against. USDT on Tron is TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t and is the example token throughout. Generate a token in the Bitquery IDE to run the queries.
Which DEXs trade on Tron
The chain-level DEXTradeByTokens cube groups trades by protocol, so one query lists every venue with its recent trade count, distinct buyers and distinct tokens. This is the modern form of the 2021 post's "top DEXs" table.
query TronDexes {
Tron {
DEXTradeByTokens(orderBy: { descendingByField: "trades" }, limit: { count: 10 }) {
Trade {
Dex {
ProtocolFamily
ProtocolName
}
}
trades: count
buyers: uniq(of: Trade_Buyer)
tokens: uniq(of: Trade_Currency_SmartContract)
}
}
}
| Protocol name | What it is |
|---|---|
sun_swap_v1 | JustSwap-era constant-product pools |
sun_swap_v2 | Uniswap v2-style pools, where most new tokens list |
sun_swap_v3 | Concentrated-liquidity pools, where most volume sits |
sun_pump_v1 | SunPump bonding curves before graduation |
stable_swap_v1 | Stablecoin pools |
Ranking venues by USD volume works too, with one caution: long-tail launchpad tokens occasionally carry a wildly wrong USD print, so put a per-trade cap on AmountsInUsd.Quote or rank by trade count and traders, as above, when the list mixes launchpad tokens with majors.
Live Tron trades with USD prices
For real time and the last month, the Crypto Trades API streams every Tron swap with the trader, both legs, a USD price and the token's market cap, MEV-filtered. Change subscription to query and add limit and orderBy for a snapshot; add Protocol under Market to follow one venue. On Tron the transaction header carries the hash but not fee or fee-payer fields, which is why the selection below leaves them out.
subscription {
Trading {
Trades(where: { Pair: { Market: { NetworkBid: { is: "bid:tron" } } } }) {
Block {
Time
}
Side
Trader {
Address
}
TransactionHeader {
Hash
}
Pair {
Token {
Symbol
Address
}
QuoteToken {
Symbol
}
Market {
Protocol
ProtocolFamily
}
Pool {
Address
}
}
Amounts {
Base
Quote
}
AmountsInUsd {
Quote
}
PriceInUsd
Supply {
MarketCap
}
}
}
}
Side is the trader's side, and for USD volume sum the quote leg. The Tron DEX trades docs keep the maintained versions of this and the queries that follow.
Latest trades of a token
The chain-level cube returns each swap from the token's point of view with the counter-token on Side. This lists the latest USDT trades against WTRX across every Tron DEX, newest first. Dex.SmartContract is the pool.
query LatestTokenTrades {
Tron {
DEXTradeByTokens(
orderBy: { descending: Block_Time }
limit: { count: 50 }
where: {
Trade: {
Currency: { SmartContract: { is: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" } }
Side: {
Amount: { gt: "0" }
Currency: { SmartContract: { is: "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR" } }
}
Price: { gt: 0 }
}
Transaction: { Result: { Success: true } }
}
) {
Block {
Time
}
Transaction {
Hash
}
Trade {
Dex {
ProtocolFamily
ProtocolName
SmartContract
}
Currency {
Symbol
}
Price
PriceInUSD
Amount
AmountInUSD
Side {
Type
Currency {
Symbol
}
Amount
AmountInUSD
}
}
}
}
}
Drop the Side currency filter to see the token against every counter-token. Side.Type is the trader's action on the counter-leg, so a sell of WTRX on the side means the trader bought USDT, and a buy means they sold it.
The price of a token
For one number per token, the Pairs cube filtered to ranking position one returns the price from the token's top market, in USD even when the pool quotes in TRX. The DEX price index post explains how that price is computed.
query TokenPriceFromTopMarket {
Trading {
Pairs(
where: {
Token: {
Address: { is: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" }
Network: { is: "Tron" }
}
Ranking: { Position: { eq: 1 } }
Interval: { Time: { Duration: { eq: 60 } } }
}
limit: { count: 1 }
orderBy: { descending: Block_Time }
) {
Block {
Time
}
Token {
Symbol
}
QuoteToken {
Symbol
}
Market {
Protocol
}
Pool {
Address
}
Price {
IsQuotedInUsd
Ohlc {
Close
}
}
}
}
}
OHLC candles for a token
Candles built in-query from raw trades, here five-minute bars for USDT priced in USD over the last day, newest first. The PriceAsymmetry filter drops trades whose two legs disagree on price. For pre-aggregated candles from one second up, with moving averages, use the Pairs or Tokens cube instead; the OHLC guide compares the two.
query TokenCandles {
Tron {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_bucket" }
limit: { count: 100 }
where: {
Trade: {
Currency: { SmartContract: { is: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" } }
Side: {
Amount: { gt: "0" }
Currency: { SmartContract: { is: "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR" } }
}
PriceAsymmetry: { lt: 0.1 }
}
Block: { Time: { since_relative: { hours_ago: 24 } } }
}
) {
Block {
bucket: Time(interval: { count: 5, in: minutes })
}
Trade {
open: PriceInUSD(minimum: Block_Number)
close: PriceInUSD(maximum: Block_Number)
max: PriceInUSD(maximum: Trade_PriceInUSD)
min: PriceInUSD(minimum: Trade_PriceInUSD)
}
volume: sum(of: Trade_Side_Amount)
count
}
}
}
Charting front ends can consume either source through the TradingView integration.
Top traders of a token
The largest USDT traders on Tron over the last week, with what each bought and sold and their USD volume. This one runs on the Trading cube, where Trader.Address is the signing wallet and Side is the trader's own side, so the aliases read naturally; on the chain-level cube the token-leg Buyer is the pool whenever the trader sells, which makes it the wrong field to group traders by.
query TopTraders {
Trading {
Trades(
where: {
Pair: {
Token: { Id: { is: "bid:tron:TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" } }
Market: { NetworkBid: { is: "bid:tron" } }
}
Block: { Time: { since_relative: { days_ago: 7 } } }
}
orderBy: { descendingByField: "usd" }
limit: { count: 100 }
) {
Trader {
Address
}
bought: sum(of: Amounts_Base, if: { Side: { is: "Buy" } })
sold: sum(of: Amounts_Base, if: { Side: { is: "Sell" } })
usd: sum(of: AmountsInUsd_Quote)
trades: count
}
}
}
New tokens on SunPump and SunSwap
Tron's launch activity runs through SunPump and lists on SunSwap v2. This returns, for the last day, one row per token quoted in WTRX with the time and price of its first trade in the window, newest first. A token that simply went a day without trading also qualifies, so treat it as a launch radar and confirm a candidate with a second query that checks for trades before the window.
query NewTokensOnTron {
Tron {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_first_trade" }
limitBy: { by: Trade_Currency_SmartContract, count: 1 }
limit: { count: 50 }
where: {
Trade: {
Side: { Currency: { SmartContract: { is: "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR" } } }
}
Block: { Time: { since_relative: { hours_ago: 24 } } }
TransactionStatus: { Success: true }
}
) {
Block {
first_trade: Time(minimum: Block_Time)
}
Trade {
Currency {
Name
Symbol
SmartContract
}
Dex {
ProtocolName
ProtocolFamily
}
first_price: PriceInUSD(minimum: Block_Time)
}
trades: count
buyers: uniq(of: Trade_Buyer)
}
}
}
Trades of a wallet
Two ways to answer "what did this address trade". On the chain-level cube, the wallet can sit on either leg, so the any filter covers both. On the Trading cube, Trader.Address is a first-class filter and every row carries USD.
query WalletTrades {
Tron {
DEXTrades(
limit: { count: 20 }
orderBy: { descending: Block_Time }
where: {
any: [
{ Trade: { Buy: { Buyer: { is: "TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj" } } } }
{ Trade: { Sell: { Buyer: { is: "TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj" } } } }
]
}
) {
Block {
Time
}
Transaction {
Hash
}
Trade {
Dex {
ProtocolName
}
Buy {
Amount
Buyer
Currency {
Symbol
}
}
Sell {
Amount
Buyer
Currency {
Symbol
}
}
}
}
}
}
query WalletTradesWithUsd {
Trading {
Trades(
where: {
Pair: { Market: { NetworkBid: { is: "bid:tron" } } }
Trader: { Address: { is: "TCFNp179Lg46D16zKoumd4Poa2WFFdtqYj" } }
}
orderBy: { descending: Block_Time }
limit: { count: 20 }
) {
Block {
Time
}
Side
Pair {
Token {
Symbol
}
QuoteToken {
Symbol
}
Market {
Protocol
}
}
Amounts {
Base
Quote
}
AmountsInUsd {
Quote
}
PriceInUsd
}
}
}
The Traders API extends the second form to leaderboards, multi-wallet monitoring and PnL-style aggregates.
Streams, Kafka and history
Every chain-level query above streams by changing query to subscription, and the Trading cube queries do the same once limit and orderBy are dropped. Tron trades are also published as Kafka topics for consumers that need replay and lower latency; the streaming overview compares the options and Kafka access comes through sales. The Trading cube holds roughly the last month; the chain-level Tron cubes reach the archive with dataset: combined, which is where multi-year Tron DEX history lives.
FAQ
Which DEXs on Tron does the API cover?
SunSwap v1, v2 and v3, SunPump and StableSwap, listed by protocol name in the first query. JustSwap is SunSwap v1. New venues are added as they gain volume.
How do I get SunSwap trades only?
Filter Trade.Dex.ProtocolFamily to SunSwap on the chain-level cube, or Pair.Market.ProtocolFamily on the Trading cube; use ProtocolName for one version.
Why is USDT quoted against WTRX rather than TRX?
SunSwap pools hold the wrapped token, so the counter-leg is WTRX at the contract address above. The Trading cube shows the quote as TRX and prices in USD regardless, and the Price Index handles the conversion.
How far back does the data go?
The Trading cube holds about a month. The chain-level Tron cubes hold the full archive of DEX trades with dataset: combined.
Related reading
Subscribe to our newsletter
Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.