Use Case
DEX swap tracking enables you to:- Build DEX trading analytics and volume trackers
- Monitor liquidity pool activity
- Analyze trading patterns and arbitrage
- Create real-time price feeds
Code Example
Try it yourself with the interactive query interface below:
Key Parameters
| Parameter | Description |
|---|---|
programId | DEX program address (e.g., Orca Whirlpool) |
d8 | 8-byte instruction discriminator for swap instruction |
accounts | Instruction account addresses (includes pool, tokens, etc.) |
data | Instruction data payload (contains swap amounts) |
Different DEX protocols use different instruction discriminators. Check the
program IDL to find the correct discriminator for your target DEX.
Expected Output
Track Specific Pool
Monitor swaps for a specific trading pair:Decode Swap Amounts
Swap amounts are encoded in thedata field. Here’s how to decode them for Orca Whirlpool:
Performance Tips
- Filter by pool address: Query specific pools instead of all swaps
- Use slot ranges: Process data in 10k-50k slot batches
- Decode off-chain: Decode swap amounts in your application, not in the query
- Combine with token balances: Use token balances to track actual amounts transferred
Related Examples
Query Instructions
General instruction querying
Token Transfers
Track token movements
Query Transactions
Monitor wallet activity
API Reference
View complete API docs

