Atomic cross-DEX arbitrage on Arbitrum
Off-chain services watch prices; a Solidity executor borrows through a flash loan, swaps across two DEXs and repays in one transaction, or reverts.
The problem
Price differences between DEXs close within seconds, and holding capital to trade them ties up money and adds risk.
The system
- Off-chain Node.js and Python services watch pool prices and pending transactions, and estimate profit after gas.
- When an opportunity clears the threshold, they call a Solidity executor contract with the route and a minimum profit.
- The contract takes a Balancer flash loan, swaps across two DEXs and repays the loan inside the same transaction.
- If the trade would not clear the minimum at execution time, the whole transaction reverts and no position is left open.
Key decisions
Flash loans instead of held capital
WhyWorking capital is borrowed and returned within one transaction.
Trade-offOnly opportunities larger than gas costs are worth taking.
Enforce the profit check on-chain
WhyPrices move between simulation and inclusion; the contract enforces the minimum itself.
Trade-offMore gas on every attempt.
Arbitrum instead of Ethereum mainnet
WhyLower gas makes smaller spreads viable.
Trade-offFewer venues and thinner liquidity.
Results
- Runs on Arbitrum mainnet
- Contract and code walkthrough available on request
What I’d do next
Private order flow to cut failed attempts, and a public write-up of the risk controls.