Skip to content

wwboy6/hardhatdemo

Repository files navigation

Sample Hardhat Project

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.

Workflow Highlight

  • [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.

Deployed contract

ArbitrageFlashLoan (FlashLoadSmartRouter) 2025/06/18 11:57 0xca0cc700F5DbFF1662d03a64361600Caa3DA8fd7

Pitfall

Anvil

  • Before calling any contract function, better deploy the contract to be tested first, or it may raise error about failing to get historical block

Review

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published