0

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.

1 Answer 1

1

Not possible.

  1. There is a maximum transaction complexity, the block "gasLimit", so nothing can run forever. There is also per-operation pricing, so you can't have thousands of nodes replicating your operation, for free, nor should you want to because the surveillance aspect of your app doesn't require that kind of confidence.

  2. The EVM is single-threaded which means that transactions are completed, entirely, before the next transaction begins. There is no possibility of something running while other things are going on.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.