To make arbitrage between two defis why i need a smart contract? web3py or web3js can interact with defi smart contracts. A script can monitor price difference and if find arbitrage opportunity script can send transaction.

Speed or batch tx in one transaction?


1 Answer 1


I think reasons are multiple:

  • if you sign the transaction to interact with the exchanges contracts directly with an EOA you must know the exact best amounts to optimise your gain since the beginning. If you call a custom contract, instead, you can make the contract compute the optimal amounts or even revert the transaction if the there is no more gain. Remember that your transaction gets executed only when someone mine a new block containing it. Moreover, there is always the risk of being frontrunned.

  • Most used decentralized exchanges (like Uniswap) does not implement the logic you would need to do this kind of complex swaps in a single transaction. You would have to make multiple transactions temporarily collecting the tokens in your wallet and this is risky since prices could change and you could lose your arbitrage chance halfway.

  • About flash loans/flash swaps: a prerogative of these flash operations is to conclude them during a single transaction, so you need to put this logic in a custom contract.

Obviously this contract should be called by service that continuously look for opportunities but the arbitrage logic itself (or better, the checks that everything is going well and the prices are not changed too much when your transaction get actually executed) should be in the contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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