Skip to main content

Arbitrum DEX Trades API

In this section we will see how to get Arbitrum DEX trades information using our API.

This query returns the top trending pairs traded on Arbitrum Chain based on the trade volume for the last 24 hours, and returns info such as latest price, number of buyers and sellers, number of trades in a day and much more.

query pairs(
$min_count: String
$network: evm_network
$time_ago: DateTime
$time_10min_ago: DateTime
$time_1h_ago: DateTime
$time_3h_ago: DateTime
$weth: String!
$usdc: String!
$usdt: String!
$usdc2: String!
) {
EVM(network: $network) {
DEXTradeByTokens(
where: {
Block: { Time: { since: $time_ago } }
any: [
{ Trade: { Side: { Currency: { SmartContract: { is: $usdt } } } } }
{
Trade: {
Side: { Currency: { SmartContract: { is: $usdc } } }
Currency: { SmartContract: { notIn: [$usdt] } }
}
}
{
Trade: {
Side: { Currency: { SmartContract: { is: $usdc2 } } }
Currency: { SmartContract: { notIn: [$usdt, $usdc] } }
}
}
{
Trade: {
Side: { Currency: { SmartContract: { is: $weth } } }
Currency: { SmartContract: { notIn: [$usdc, $usdt, $usdc2] } }
}
}
{
Trade: {
Side: {
Currency: { SmartContract: { notIn: [$usdc, $usdt, $weth] } }
}
Currency: {
SmartContract: { notIn: [$usdc, $usdc2, $usdt, $weth] }
}
}
}
]
}
orderBy: { descendingByField: "usd" }
limit: { count: 100 }
) {
Trade {
Currency {
Symbol
Name
SmartContract
ProtocolName
}
Side {
Currency {
Symbol
Name
SmartContract
ProtocolName
}
}
price_last: PriceInUSD(maximum: Block_Number)
price_10min_ago: PriceInUSD(
maximum: Block_Number
if: { Block: { Time: { before: $time_10min_ago } } }
)
price_1h_ago: PriceInUSD(
maximum: Block_Number
if: { Block: { Time: { before: $time_1h_ago } } }
)
price_3h_ago: PriceInUSD(
maximum: Block_Number
if: { Block: { Time: { before: $time_3h_ago } } }
)
}
dexes: uniq(of: Trade_Dex_OwnerAddress)
amount: sum(of: Trade_Side_Amount)
usd: sum(of: Trade_Side_AmountInUSD)
sellers: uniq(of: Trade_Seller)
buyers: uniq(of: Trade_Buyer)
count(selectWhere: { ge: $min_count })
}
}
}

Implementation of this data in a full scale project could be seen on DEXRabbit.

Trending Pairs on Arbitrum

Latest Trades for a Token Pair on Arbitrum​

This query retrieves all DEX trades on the arbitrum where the Arbitrum currency is ArbitrumCurrency and the quote currency is quoteCurrency that occurred between the specified dates. You can find the query here

query ($network: evm_network!, $ArbitrumCurrency: String!, $limit: Int, $quoteCurrency: String!, $from: String, $till: String) {
EVM(network: $network, dataset: archive) {
sell: DEXTrades(
where: {Trade: {Sell: {Currency: {SmartContract: {is: $ArbitrumCurrency}}}, Buy: {Currency: {SmartContract: {is: $quoteCurrency}}}}, Block: {Date: {since: $from, till: $till}}}
orderBy: {descending: Block_Date}
limit: {count: $limit}
) {
ChainId
Block {
Time
Number
}
Trade {
Sell {
Buyer
Amount
Currency {
Symbol
Name
SmartContract
}
}
Buy {
Price
Amount
Currency {
Symbol
SmartContract
Name
}
}
Dex {
ProtocolName
SmartContract
ProtocolFamily
ProtocolVersion
}
}
}
}
}
{
"network": "arbitrum",
"limit": 15,
"from": "2023-09-07",
"till": "2023-09-07",
"ArbitrumCurrency": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
"quoteCurrency": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1"
}

OHLC for a Token Pair​

This query returns the OHLC/K Line Data for a specified token pair. For this example we are considering the ARB 0x912ce59144191c1204e64559fe8253a0e49e6548 and USDC 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 pair.

query tradingViewPairs(
$network: evm_network
$dataset: dataset_arg_enum
$interval: Int
$token: String
$base: String
$time_ago: DateTime
) {
EVM(network: $network, dataset: $dataset) {
DEXTradeByTokens(
orderBy: { ascendingByField: "Block_Time" }
where: {
Trade: {
Side: {
Amount: { gt: "0" }
Currency: { SmartContract: { is: $token } }
}
Currency: { SmartContract: { is: $base } }
PriceAsymmetry: { le: 0.1 }
}
Block: { Time: { since: $time_ago } }
}
) {
Block {
Time(interval: { count: $interval, in: minutes })
}
Trade {
open: PriceInUSD(minimum: Block_Time)
close: PriceInUSD(maximum: Block_Time)
max: PriceInUSD(maximum: Trade_PriceInUSD)
min: PriceInUSD(minimum: Trade_PriceInUSD)
}
volume: sum(of: Trade_AmountInUSD)
}
}
}

An example for the data visualisation of the data obtained could be seen on the DEXRabbit.

OHLC/ K Line for a Pair on Arbitrum

Latest Trades in Realtime with Subscription​

This subscription query will return the latest DEX trades on the Arbitrum network in real time. You can find the query here

subscription {
EVM(network: arbitrum) {
DEXTrades {
Trade {
Dex {
ProtocolFamily
ProtocolName
}
Sender
Buy {
Amount
Buyer
Currency {
Name
SmartContract
Symbol
}
Price
Seller
}
Sell {
Amount
Buyer
Currency {
Name
Symbol
SmartContract
}
Price
Seller
}
}
}
}
}

Top Bought Tokens on Arbitrum network​

This query will give you top bought tokens on Arbitrum network in last 1 hour. Change the timestamp in {Block: {Time: {since: "2024-12-24T08:20:00Z"}}} accordingly. You can find the query here

query MyQuery {
EVM(network: arbitrum) {
DEXTradeByTokens(
where: {Block: {Time: {since: "2024-12-24T08:20:00Z"}}}
limit: {count: 100}
orderBy: {descendingByField: "total_bought"}
) {
Trade {
Currency {
Name
Symbol
SmartContract
}
}
total_bought: sum(of:Trade_Side_AmountInUSD if:{Trade:{Side:{Type:{is:buy}}}})
total_sold: sum(of:Trade_Side_AmountInUSD if:{Trade:{Side:{Type:{is:sell}}}})

}
}
}

Get Price Change 5min, 1h, 6h and 24h of a specific token​

Use below query to get price change 5min, 1h, 6h and 24h of a specific token. Change the Currency{SmartContract} and Dex{SmartContract} according to your needs. Test the query [here] (https://ide.bitquery.io/Price-change-5min-1hr-6hr-24hr-precentage-of-a-specific-token_1).

query MyQuery {
EVM(dataset: combined network:arbitrum) {
DEXTradeByTokens(
where: {Trade: {Currency: {SmartContract: {is: "0x30a538eFFD91ACeFb1b12CE9Bc0074eD18c9dFc9"}}, Dex: {SmartContract: {is: "0xdaAe914e4Bae2AAe4f536006C353117B90Fb37e3"}}}, TransactionStatus: {Success: true}, Block: {Time: {since_relative: {hours_ago: 24}}}}
){
Trade {
Price_5min_ago: PriceInUSD(minimum:Block_Number if:{Block:{Time:{since_relative:{minutes_ago:5}}}})
Price_1h_ago: PriceInUSD(minimum:Block_Number if:{Block:{Time:{since_relative:{hours_ago:1}}}})
Price_6h_ago: PriceInUSD(minimum: Block_Number if:{Block:{Time:{since_relative:{hours_ago:6}}}})
Price_24h_ago: PriceInUSD(minimum: Block_Number)
CurrentPrice: PriceInUSD(maximum: Block_Number)
}
volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {since_relative: {minutes_ago: 5}}}}
)
volume_1h: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {since_relative: {hours_ago: 1}}}}
)
volume_6h: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {since_relative: {hours_ago: 6}}}}
)
volume_24h: sum(
of: Trade_Side_AmountInUSD
)
Price_Change_5min: calculate(expression: "(($Trade_CurrentPrice - $Trade_Price_5min_ago) / $Trade_Price_5min_ago) * 100")
Price_Change_1h: calculate(expression: "(($Trade_CurrentPrice - $Trade_Price_1h_ago) / $Trade_Price_1h_ago) * 100")
Price_Change_6h: calculate(expression: "(($Trade_CurrentPrice - $Trade_Price_6h_ago) / $Trade_Price_6h_ago) * 100")
Price_Change_24h: calculate(expression: "(($Trade_CurrentPrice - $Trade_Price_24h_ago) / $Trade_Price_24h_ago) * 100")
}
}
}

Top 10 Arbitrum Tokens by Price Change in last 1h​

Use below query to get top 10 Arbitrum Tokens by Price Change in last 1h. Test the query [here] (https://ide.bitquery.io/Top-10-arb-tokens-by-price-change-in-last-1-hr).

query MyQuery {
EVM(dataset: combined network:arbitrum) {
DEXTradeByTokens(
limit:{count:10}
orderBy:{descendingByField:"Price_Change_1h"}
where: {TransactionStatus: {Success: true}, Block: {Time: {since_relative: {hours_ago: 24}}}}
) {
Trade {
Currency {
Name
Symbol
SmartContract
}
Price_5min_ago: PriceInUSD(
minimum: Block_Number
if: {Block: {Time: {since_relative: {minutes_ago: 5}}}}
)
Price_1h_ago: PriceInUSD(
minimum: Block_Number
if: {Block: {Time: {since_relative: {hours_ago: 1}}}}
)
Price_6h_ago: PriceInUSD(
minimum: Block_Number
if: {Block: {Time: {since_relative: {hours_ago: 6}}}}
)
Price_24h_ago: PriceInUSD(minimum: Block_Number)
CurrentPrice: PriceInUSD(maximum: Block_Number)
Side {
Currency {
Name
Symbol
SmartContract
}
}
Dex{
SmartContract
}
}

volume_5min: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {since_relative: {minutes_ago: 5}}}}
)
volume_1h: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {since_relative: {hours_ago: 1}}}}
)
volume_6h: sum(
of: Trade_Side_AmountInUSD
if: {Block: {Time: {since_relative: {hours_ago: 6}}}}
)
volume_24h: sum(of: Trade_Side_AmountInUSD)
Price_Change_5min: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_5min_ago) / $Trade_Price_5min_ago) * 100"
)
Price_Change_1h: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_1h_ago) / $Trade_Price_1h_ago) * 100"
)
Price_Change_6h: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_6h_ago) / $Trade_Price_6h_ago) * 100"
)
Price_Change_24h: calculate(
expression: "(($Trade_CurrentPrice - $Trade_Price_24h_ago) / $Trade_Price_24h_ago) * 100"
)
}
}
}

Top Sold Tokens on Arbitrum network​

This query will give you top sold tokens on Arbitrum network in last 1 hour. Change the timestamp in {Block: {Time: {since: "2024-12-24T08:20:00Z"}}} accordingly. You can find the query here

query MyQuery {
EVM(network: arbitrum) {
DEXTradeByTokens(
where: {Block: {Time: {since: "2024-12-24T08:20:00Z"}}}
limit: {count: 100}
orderBy: {descendingByField: "total_sold"}
) {
Trade {
Currency {
Name
Symbol
SmartContract
}
}
total_bought: sum(of:Trade_Side_AmountInUSD if:{Trade:{Side:{Type:{is:buy}}}})
total_sold: sum(of:Trade_Side_AmountInUSD if:{Trade:{Side:{Type:{is:sell}}}})

}
}
}

Top Traders of a Token on Arbitrum​

This query returns the top traders of a token on arbitrum based on the volume of trades involving the particular token. This query returns info such as buyers, sellers, DEX Protocol used, amount bought and sold.

query topTraders($network: evm_network, $time_ago: DateTime, $token: String) {
EVM(network: $network) {
DEXTradeByTokens(
orderBy: {descendingByField: "volumeUsd"}
limit: {count: 100}
where: {Trade: {Currency: {SmartContract: {is: $token}}}, Block: {Time: {since: $time_ago}}}
) {
Trade {
Buyer
Dex {
ProtocolFamily
}
}
bought: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: sell}}}})
sold: sum(of: Trade_Amount, if: {Trade: {Side: {Type: {is: buy}}}})
volume: sum(of: Trade_Amount)
volumeUsd: sum(of: Trade_Side_AmountInUSD)
}
}
}
{
"network": "arbitrum",
"token": "0x912ce59144191c1204e64559fe8253a0e49e6548",
"time_ago": "2024-11-17T08:11:44Z"
}

The implementation of this data could also be seen on the DEXRabbit.

Top Traders for a token on Arbitrum

The DEXTrades API contains the following information about each trade:

  • Dex: The details of the decentralized exchange where the trade was executed, including the protocol family and the protocol name.
  • Sender: The address of the sender of the trade.
  • Buy: The details of the buy order, including the amount of token bought, the buyer's address, the token's symbol, and the price of the trade.
  • Sell: The details of the sell order, including the amount of token sold, the seller's address, the token's symbol, and the price of the trade.

Video Tutorial | How to get Top Traders of a Token on Arbitrum​

Video Tutorial | How to track Realtime DEXTrades of a Token on Arbitrum​

Video Tutorial | How to get OHLC Data of a Token Pair on Arbitrum​

Video Tutorial | How to get Top Bought & Top Sold Tokens on Arbitrum network​