Base Chain DEX Trades API
In this section we will see how to get Base DEX trades information using our API.
This Base API is part of our Early Access Program (EAP), which is intended for evaluation purposes.
This program allows you to test the data and its integration into your applications before full-scale implementation. Read more here
Subscribe to Latest Base Trades
This subscription will return information about the most recent trades executed on Base's DEX platforms. You can find the query here
subscription MyQuery {
EVM(network: base) {
DEXTrades {
Block {
Time
Number
}
Transaction {
Hash
}
Call {
Signature {
Name
Signature
}
}
Log {
Index
SmartContract
Signature {
Signature
Name
}
}
Trade {
Sender
Buy {
Buyer
AmountInUSD
Amount
Seller
PriceInUSD
Price
Currency {
Name
Symbol
SmartContract
}
}
Dex {
SmartContract
ProtocolName
ProtocolVersion
}
Sell {
Buyer
AmountInUSD
Amount
Seller
PriceInUSD
Price
Currency {
Name
Symbol
SmartContract
}
}
}
}
}
}
Subscribe to Latest Price of a Token in Real-time
This query provides real-time updates on price of USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
in terms of DAI 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb
, including details about the DEX, market, and order specifics. Find the query here
subscription {
EVM(network: base) {
DEXTrades(
where: {Trade: {Sell: {Currency: {SmartContract: {is: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}}}, Buy: {Currency: {SmartContract: {is: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"}}}}}
) {
Block {
Time
}
Trade {
Buy {
Amount
Buyer
Seller
Price_in_terms_of_sell_currency: Price
Currency {
Name
Symbol
SmartContract
}
}
Sell {
Amount
Buyer
Seller
Price_in_terms_of_buy_currency: Price
Currency {
Symbol
SmartContract
Name
}
}
}
}
}
}
Latest USD Price of a Token
The below query retrieves the USD price of a token on Base chain by setting SmartContract: {is: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"}
. Check the field PriceInUSD
for the USD value. You can access the query here.
subscription {
EVM(network: base) {
DEXTradeByTokens(
where: {Trade: {Currency: {SmartContract: {is: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"}}}}
) {
Transaction {
Hash
}
Trade {
Buyer
AmountInUSD
Amount
Price
PriceInUSD
Seller
Currency {
Name
Symbol
SmartContract
}
Dex {
ProtocolFamily
SmartContract
ProtocolName
}
Side {
Amount
AmountInUSD
Buyer
Seller
Currency {
Name
SmartContract
Symbol
}
}
}
}
}
}