In this post, we go over the main concepts behind building a flash loan arbitrage bot: arbitrage, contract-based Ethereum transactions and optimistic transfer.
We then walk through how to structure a program with Infura that can watch for and execute on profitable arbitrage trades!
Let us know your thoughts and what you’d like us to show you next!
Hello, maybe I’m wrong, but I believe the code in part ii is incorrect.
An example where we borrow WETH on Uni to swap for DAI on Sushi.
The path is set so that we go from borrowed => not borrowed (WETH => DAI).
amountRequired calls getAmountsIn which gives us the input amount given an output amount and path passed in params. The code provided gets us the amount of WETH required given the amount of WETH borrowed. It should be getting the amount of DAI required given the amount of WETH borrowed. (DAI => WETH as path).
Also, not sure why amountRequired is passed into the output amount of amountReceived (this would just mean that you never profit).
hey - hope you are doing well, has anything been done with regards to this? also where can I learn more about the Building flash loan arbitrage with Infura, because if your code is for demonstration and is written wrong or has mistakes to stop users from profitting then is there a place to learn more and make sure I can correct the code. Thanks.
We’ve updated the articles to reflect that the immense amount of MEV almost certainly eliminates the possibility of actually running a successful arbitrage. The articles are educational around the concept rather than showing a specific way to code.
Hey there
May anyone can tell me more about const spread = Math.abs((priceSushiswap / priceUniswap - 1) * 100) - 0.6;
i mean, how is it calculated and why “-0.6” operation at the end?
I´m also having a similar issue in that whenever I perform getAmountsIn, the amountRequired ALWAYS supersedes the amountReceived via swapXXX function. Any ideas as to why is this happening?
Thank you