Skip to main content
ChainStream currently supports Solana (sol), Ethereum (eth), and BSC (bsc). Supported DEXes are Jupiter, Raydium, PumpFun, Moonshot, Candy (Solana), and KyberSwap (Ethereum/BSC). Some code examples below reference additional DEXes for conceptual illustration — check Supported Chains for the current coverage.
Coming Soon — This feature is under development and not yet available.
This tutorial will guide you through building a cross-DEX arbitrage scanner that discovers price differences between exchanges in real-time and identifies potential arbitrage opportunities.
Estimated Time: 45 minutes
Difficulty Level: ⭐⭐⭐ Intermediate

Objective

Discover cross-DEX price difference arbitrage opportunities: Feature Checklist:
  • ✅ Get multi-DEX trading pair prices
  • ✅ Calculate spread percentage
  • ✅ Evaluate feasibility (considering Gas, slippage, depth)
  • ✅ Risk alerts (MEV, front-running)

Arbitrage Principles

Cross-DEX Arbitrage

The same token may have price differences across different DEXes:

Profit Formula

Net Profit = Spread Revenue - Gas Fees - Slippage Loss
Practical considerations:
  • Gas fees for two transactions
  • Buy/sell slippage
  • Liquidity depth limits
  • MEV front-running risk

Step 1: Get Trading Pairs

1.1 Install Dependencies

1.2 Configuration File

1.3 Get Price Data


Step 2: Calculate Spread


Step 3: Evaluate Feasibility

Risk Assessment

Risk Warning

Important Risk Warnings:
  1. MEV Front-running: Arbitrage trades are easily front-run by MEV bots
  2. Price Latency: Prices may have changed by execution time
  3. Gas Volatility: Costs can surge significantly during network congestion
  4. Slippage: Actual slippage may be higher than estimated
This tool is only for discovering opportunities and does not constitute investment advice.

Complete Code


Extension Suggestions

Flash Loan Integration

Use flash loans for zero-capital arbitrage

Multi-chain Scanning

Add eth / bsc KyberSwap quotes alongside Solana venues

Auto Execution

Integrate wallet for automatic trading (use caution)

DeFi Monitoring Overview

Learn about DeFi monitoring dimensions

Price Alert Bot

Get started with real-time price monitoring