This is part 1 of a demo for arbitrage trading. This part is to implement a custom smart contract to perform 2 trades using smart router, to form an arbitrage attack.
- [Solidity] FlashLoadSmartRouter.sol: The custom contract with function trade, that handle 2 swaps between 2 ERC20 tokens.
- [Hardhat] ArbitrageFlashLoan.test.js: The test script to test with the contract function.
ArbitrageFlashLoan (FlashLoadSmartRouter) 2025/06/18 11:57 0xca0cc700F5DbFF1662d03a64361600Caa3DA8fd7
- Before calling any contract function, better deploy the contract to be tested first, or it may raise error about failing to get historical block
The contract function work as expected. For next part, protential trade routes would be searched. https://github.com/wwboy6/arbitrage-trading
This approach is then replaced by Universal Router (Part 3). https://github.com/wwboy6/arbitrage-trading2
A script is added to study part 3 attack failure (study-block.test.js)