Skip to main content

Solana DEX Trades gRPC Stream (Bitquery CoreCast)

The dex_trades stream of Bitquery CoreCast sends each Solana DEX trade as it lands, already decoded, across supported protocols (Pump.fun, Raydium, Orca, Jupiter, and more). A trading bot reads both sides of the trade, the amounts, the pool and the trader without decoding each DEX program's instructions, which a raw Yellowstone gRPC stream would require.


Overview​

Subscribe to live DEX swaps with context-aware filtering. Each event includes transaction details, token context, trade amounts, and market address. Data is in protobuf format; use bitquery-corecast-proto to parse it.

Filters required

At least one filter per subscription. See Filtering Options.

Configuration​

To subscribe to DEX trades, configure your stream as follows:

server:
address: "corecast.bitquery.io"
authorization: "<your_api_token>"
insecure: false

stream:
type: "dex_trades"

filters:
programs:
- "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" # Pump.fun example

Available Data​

The DEX trades stream provides comprehensive trade information including:

  • Transaction details: Slot, signature, status, fees (in native and USD)
  • Account information: Signers, token accounts, program IDs
  • Token context: Mint addresses, decimals, owners
  • Trade specifics: Amounts, protocols, pools
  • Balance updates: Pre/post balances for accounts and token accounts, showing pool liquidity changes

Sample Data Structure​

Here's an example of the data structure you'll receive:

{
"Block": {
"Slot": 370028492
},
"Transaction": {
"Index": 779,
"Signature": "2eoFGRLxJFXhLGBXS4dPgSGYfjF9yGx3Tfc4EgJqrndiMqTX22SZwaH1E8E8p7333z2CWqofY8YvJgB7DN6hJv1L",
"Status": {
"Success": true,
"ErrorMessage": ""
},
"Header": {
...
"Accounts": [...]
}
},
"Trade": {
"InstructionIndex": 9,
"Dex": {
"ProgramAddress": "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
"ProtocolName": "pump_amm",
"ProtocolFamily": "Pumpswap"
},
"Market": {
"MarketAddress": "6pSvYm5Yff625pUPAWNDmhccHMqw1itAyjoV2DGpDTDJ",
"BaseCurrency": {
...
},
"QuoteCurrency": {
...
}
},
"Buy": {
"Amount": 2797967683010,
"Currency": {
...
},
"Account": {
...
}
},
"Sell": {
"Amount": 6645427517,
"Currency": {
...
},
"Account": {
...
}
}
}
}

Key Points​

  • No price data: Prices are not included as they're not on-chain information. Calculate prices from token amounts and decimals.
  • Token context: Each token account includes mint address, owner, decimals, and program ID.
  • Multiple protocols: Supports various DEX protocols on Solana.

Filtering Options​

The filter options are defined in the request.proto file. You can filter DEX trades using the following filters:

message SubscribeTradesRequest {
AddressFilter program;
AddressFilter pool;
AddressFilter token;
AddressFilter trader;
}

Available filters:

  • program: Filter by DEX program address
  • pool: Filter by specific pool/market address
  • token: Filter by token mint address (e.g., WSOL, USDC)
  • trader: Filter by trader's wallet address

Keep a trading bot's stream current​

When a busy stream falls behind, check the client first. Node's @grpc/grpc-js opens each connection with a 64 KB HTTP/2 flow-control window. In a Bitquery test on 4 November 2026, a client about 175 ms from the server read a CoreCast stream filtered to the Pump.fun program at about 0.2 MB per second with that window, and fell 108 seconds behind within 2 minutes. With a 16 MB window, the same stream kept pace at about 290 messages per second: 1.2 seconds behind at the start and 0.2 seconds behind after a full minute.

Set the window when you create the client:

const client = new solanaCorecast.CoreCast(
"corecast.bitquery.io",
grpc.credentials.createSsl(),
{ "grpc-node.flow_control_window": 16 * 1024 * 1024 } // 16 MB; the default is 64 KB
);

Two more habits keep the lag low:

  • Filter as narrowly as the bot allows. A pool or token filter sends far fewer messages than a whole DEX program.
  • Measure the lag. Compare each message's Block.Slot with the latest slot from a Solana RPC node, and alert when the gap grows.

Schema Reference​

Python Installation​

For Python development, install the protobuf package:

pip install bitquery-corecast-proto

NPM Package​

npm install bitquery-corecast-proto

This package includes all necessary protobuf definitions without requiring manual downloads.


Build with Bitquery

Ready to run this in production?

Get an API key and run these queries in minutes, or talk to us about plans and enterprise delivery.