To run the unit tests, run the following command
cargo test
To run an integration test, run the following command
cargo run
Pools are designed as observables and notifies all listeners. This is done to simulate a bot listening for transactions in the Ethereum mempool. Whenever a swap is carried out, the run_arbitrage
function runs and tries to arbitrage the price difference.
To derive the formula, the following constraints were used:
- The change in
DAI
in pool 1 and pool 2 must be the same k
remains the same after a swap in each pool (almost)- The ratio of tokens in each must be the same after the swap. If not, then more arbitrage opportunities can be found after the initial one