Use Case
DEX swap indexing unlocks powerful analytics:- Price Discovery: Extract real-time token prices from swap amounts without relying on third-party APIs
- Volume Analysis: Calculate 24h trading volumes, identify trending pairs, and detect unusual activity
- Liquidity Tracking: Monitor pool depth changes and identify liquidity migration patterns
- MEV Detection: Analyze sandwich attacks, arbitrage opportunities, and front-running patterns by correlating swaps within blocks
Code Example
Try it yourself with the interactive query interface below:
Key Parameters
The Swap event signature varies by DEX. Uniswap V3 uses a different signature than Uniswap V2 or other DEXs.
Expected Output
Track Specific Pool
Monitor swaps for a specific trading pair:Uniswap V2 Swaps
For Uniswap V2, use the V2 Swap event signature:Decode Swap Amounts and Calculate Prices
The real value in DEX data comes from decoding swap amounts to calculate prices. Here’s how to extract and interpret Uniswap V3 swap data:Advanced Analysis: Detecting MEV Sandwich Attacks
Sandwich attacks are a common MEV strategy where an attacker places trades before and after a victim’s transaction to profit from price impact. By analyzing swap sequences within blocks, you can detect these patterns:Advanced Analysis: Multi-Hop Swaps and Arbitrage
Many swaps route through multiple pools via aggregators like 1inch or Uniswap’s Universal Router. By combining swap events with traces, you can reconstruct complete arbitrage paths and calculate profitability:Performance Tips
- Filter by pool address: Query specific high-volume pools (USDC/WETH, WETH/USDT) instead of all swaps
- Use block ranges: Process 10k-50k block batches for optimal throughput
- Batch decode: Decode multiple events in parallel rather than sequentially
- Cache pool metadata: Store token decimals and symbols to avoid repeated lookups
- Combine with traces: Track multi-hop swaps and MEV activity by analyzing call traces alongside events
Related Examples
Query Event Logs
General event log querying
Query Traces
Track multi-hop swaps with traces
Track NFT Transfers
Monitor NFT marketplace activity
API Reference
View complete API docs