I am trying to create an arbitrage bot which swaps between 2 decentralised exchanges. Lots of tutorials say that I need a Javascript or Python program that continuously runs and fetches prices from different DEXes and if it finds an arbitrage opportunity it calls a smart contract which does the actual swap.
But I wondered if it's possible to deploy a smart contract which runs an infinity loop like a while(true)
which fetches prices from different DEXes and when it finds an opportunity it can instantly swap the tokens on the 2 exchanges.
I thought of this because the arbitrage opportunities only last for a few moments and while I am calling my smart contract the opportunity could be gone already.