A TypeScript-based tool for discovering arbitrage opportunities across various Solana decentralized exchanges (DEXs).
This tool monitors and compares token prices across multiple Solana AMMs (Automated Market Makers) in real-time to identify potential arbitrage opportunities. It currently supports the following DEXs:
- PumpSwap - Decentralized exchange built on Solana
- Raydium - Leading AMM and liquidity provider on Solana
- Orca Whirlpools - Concentrated liquidity pools
- Meteora DMM - Dynamic market maker protocol
- Real-time Price Monitoring: Continuously fetches and compares token prices across multiple DEXs
- Arbitrage Detection: Automatically identifies profitable arbitrage opportunities with customizable profit thresholds
- Live Console Dashboard: Real-time display of prices, spreads, and opportunities
- Direct Trading Links: Provides direct URLs to execute trades on respective platforms
- Error Handling: Robust error handling for failed API calls or network issues
- Configurable Refresh Rate: Adjustable monitoring intervals (default: 1 second)
# Clone the repository
git clone https://github.com/yourusername/solana-arbitrage-scanner.git
cd solana-arbitrage-scanner
# Install dependencies
npm install
# Build the TypeScript project
npm run build- Node.js (v14 or higher)
- npm (v6 or higher)
- TypeScript (installed as dev dependency)
- Stable internet connection for DEX API calls
The application is configured to monitor SOL/USDC pairs by default. You can modify the token pairs in src/index.ts:
const QUOTE_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
const BASE_MINT = "So11111111111111111111111111111111111111112"; // SOL
const FETCH_INTERVAL = 1000; // 1 second refresh rate
const MIN_PROFIT_THRESHOLD = 0.1; // Minimum 0.1% profit threshold# Run the arbitrage scanner
npm start
# Or run in development mode (builds and runs)
npm run devnpm run build # Compile TypeScript to JavaScript
npm run start # Run the compiled application
npm run dev # Build and run in one command
npm run clean # Remove compiled files- Data Fetching: Simultaneously fetches pool data from all supported DEXs using their respective APIs
- Price Normalization: Extracts and normalizes price data for accurate comparison
- Arbitrage Calculation: Compares prices across platforms and calculates profit percentages
- Opportunity Ranking: Sorts opportunities by profit potential
- Real-time Display: Shows live prices, spreads, and profitable opportunities in the console
DEX ARBITRAGE MONITOR - SOL/USDT
Iteration: 1 | Refresh Rate: 1000ms
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
LIVE PRICES - 2:45:30 PM
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PumpSwap 1 SOL = 103.1234 USDT
Pool: 8zx...abc
Trade β https://swap.pump.fun/?input=So111...&output=EPj...
Raydium 1 SOL = 102.9876 USDT
Pool: 7yz...def
Trade β https://raydium.io/swap/?inputMint=sol&outputMint=EPj...
Whirlpool 1 SOL = 103.4567 USDT
Pool: 9ab...ghi
Trade β https://www.orca.so/pools/9ab...ghi
Meteora DMM 1 SOL = 103.2345 USDT
Pool: 5cd...jkl
Trade β https://www.meteora.ag/pools/5cd...jkl
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Highest: Whirlpool (103.4567 USDT)
Lowest: Raydium (102.9876 USDT)
Spread: 0.455%
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ARBITRAGE OPPORTUNITIES
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Opportunity #1
Buy from: Raydium @ 102.9876 USDT
Sell to: Whirlpool @ 103.4567 USDT
Profit: 0.4691 USDT per SOL (0.455%)
Buy: https://raydium.io/swap/?inputMint=sol&outputMint=EPj...
Sell: https://www.orca.so/pools/9ab...ghi
solana-arbitrage-scanner/
βββ src/
β βββ config/ # Configuration files
β β βββ constant.ts # Constants and configuration values
β β βββ index.ts # Solana connection setup
β βββ services/ # DEX integration services
β β βββ ammSimpleCalculation.ts # AMM price calculations
β β βββ dexlabPoolsData.ts # DexLab API integration
β β βββ meteoraDmmPoolData.ts # Meteora DMM pool fetching
β β βββ pumfunBondingCurveData.ts # Pump.fun bonding curve data
β β βββ pumpSwapPoolData.ts # PumpSwap pool fetching
β β βββ raydiumPoolData.ts # Raydium pool fetching
β β βββ whirlPoolData.ts # Orca Whirlpool fetching
β β βββ index.ts # Service exports
β βββ types/ # TypeScript type definitions
β β βββ index.ts # Common types and exports
β β βββ meteora.ts # Meteora-specific types
β β βββ pumpfun.ts # Pump.fun types
β β βββ pumpswap.ts # PumpSwap types
β β βββ raydium.ts # Raydium types
β β βββ whirlpool.ts # Whirlpool types
β βββ index.ts # Main application entry point
βββ IDLs/ # Anchor IDL files
β βββ pumpswap/ # PumpSwap IDL definitions
β βββ pumpswap.json # PumpSwap program IDL
β βββ pumpswapTypes.ts # Generated TypeScript types
βββ dist/ # Compiled JavaScript output (generated)
βββ node_modules/ # Dependencies (generated)
βββ package.json # Project metadata and dependencies
βββ package-lock.json # Dependency lock file
βββ tsconfig.json # TypeScript configuration
βββ .gitignore # Git ignore rules
βββ README.md # This file
- @coral-xyz/anchor (^0.31.1) - Solana Anchor framework for program interaction
- @pump-fun/pump-swap-sdk (^1.7.9) - Official PumpSwap SDK
- @solana/kit (^2.3.0) - Solana development toolkit
- @solana/spl-token (^0.4.14) - Solana Program Library token utilities
- @solana/web3.js (^1.98.4) - Official Solana web3 library
- axios (^1.12.2) - HTTP client for API requests
- bn.js (^5.2.2) - BigNumber library for precise calculations
- @types/bn.js (^5.2.0) - TypeScript types for bn.js
- typescript (^5.0.0) - TypeScript compiler
- Create a new service file in
src/services/:
// src/services/newDexPoolData.ts
export async function fetch_newdex_pools(baseMint: string, quoteMint: string) {
// Implementation for fetching pool data
}- Add corresponding types in
src/types/:
// src/types/newdex.ts
export interface NewDexPoolData {
// Define the pool data structure
}- Update the main monitoring logic in
src/index.ts:
// Add to fetchAllPrices() function
try {
const newdex_res = await fetch_newdex_pools(BASE_MINT, QUOTE_MINT);
// Process and add to prices array
} catch (err) {
console.error("NewDex fetch failed:", err);
}Modify the mint addresses in src/index.ts:
// Example: Monitor BONK/USDC instead of SOL/USDC
const QUOTE_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
const BASE_MINT = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"; // BONK- Network Dependency: This tool requires stable internet connectivity for API calls
- Rate Limits: Be aware of potential rate limiting by DEX APIs
- Gas Fees: Consider transaction costs when evaluating arbitrage opportunities
- Slippage: Large trades may experience slippage that reduces profitability
- Speed: Arbitrage opportunities may disappear quickly due to market efficiency
MIT License - see LICENSE file for details
Contributions, issues, and feature requests are welcome! Please feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This tool is provided for educational and informational purposes only. Cryptocurrency trading carries significant financial risk, and automated arbitrage trading can result in substantial losses. The developers are not responsible for any financial losses incurred through the use of this software. Always perform your own due diligence and consider consulting with a financial advisor before engaging in cryptocurrency trading.
Key Risks:
- Market volatility can eliminate arbitrage opportunities instantly
- Network congestion may delay transactions
- Smart contract risks and potential bugs
- Regulatory changes affecting DEX operations
- Impermanent loss and slippage considerations
Use this software at your own risk and never invest more than you can afford to lose.