My Arbitrage Journey
说明与用途
作者在Arbitrum上构建了自动化闪电贷套利机器人,但初始测试因状态污染而误导。隔离测试和模拟检查显示所有交易均不盈利,证实市场效率和HFT竞争使套利几乎不可能。
问题
Build a production‑grade flashloan arbitrage bot on Arbitrum and discover why it ultimately fails.
结果
The bot initially appeared profitable due to flawed testing, but realistic isolation and fee analysis showed all trades were unprofitable, confirming that DEX‑to‑DEX arbitrage on Arbitrum is dominated by HFT bots and fee structures.
工作流
- 1. Set up Node.js + Ethers v6 to monitor real‑time prices via WebSockets. 2. Use Balancer V2 for 0% fee flashloans. 3. Write and test Solidity ArbitrageExecutor contract with Foundry. 4. Deploy contract and link to Node.js bot. 5. Run Foundry tests on a forked mainnet; observe initial profit. 6. Identify state contamination by running isolated tests. 7. Build a Node.js scanner to monitor price differences across Uniswap V3, Camelot V3, and PancakeSwap. 8. Add staticCall simulation and minPnl guard to prevent costly failed transactions. 9. Pause bot and analyze lessons learned.
证据
I built a Solidity contract that could hold the logic: request a flashloan, swap on DEX 1, swap back on DEX 2, repay the loan, and sweep the profit.
SUCCESS! pnl (wei): 21742847117914354 (A profit of ~$52)
The $52 profit was actually false.
Once I accepted that my test was flawed, I built a Node.js scanner to check the real‑time price differences across Uniswap V3, Camelot V3, and PancakeSwap for multiple mid‑cap Arbitrum tokens.
If I hadn't added that, every time the bot detected a gap, it would send the transaction to the Arbitrum network, fail on‑chain, and burn gas. At $0.10 per failed transaction, it might look small, but it's still data.
- 记录日期: 2026-10-21T20:26:05.706Z