1

More specifically, is there any advantages to be had with having the bot trading logic on chain in a smart contract? Versus doing it all off chain, watching for events and submitting the transaction

4
  • This bot project is a scam. Commented Jun 18, 2023 at 23:04
  • That's a perfectly acceptable question , why would you downvote it @MadeInDreams? Commented Jun 19, 2023 at 0:25
  • @MadeInDreams I'm confused why you all think I'm referring to some specific project, I'm not Commented Jun 19, 2023 at 3:30
  • 1
    @hearhar there's a well known scam (the video i linked to in my answer) that consists of having you deploy a smart contract pretending it's a frontrunning bot or whatever, and that actually just steals your funds Commented Jun 19, 2023 at 3:35

2 Answers 2

3

To actually answer the question, you'd need to define what MEV is. If we're talking about frontrunning, sandwich attacks and other 'do-something-related-to-pending-transactions' actions, then these actions CANNOT be executed by a smart contract alone. They aren't aware of the mempool, an external transaction cannot be sandwiched between two actions performed by a contract in a single transaction, and they cannot fire up transactions automatically. If you're referring to something you saw on a youtube video like this one (if it's still available when you read this), then those are trying to scam you.

Now, does that mean that MEV bots never use smart contracts? Not at all. See, smart contracts have that interesting property that they can do things EOAs can't do. Mainly, interacting with multiple smart contracts in a single transaction, or reverting/cancelling multiple already taken actions based on another actions result (you can actually do that, using flashbot bundles, but they're more expensive than standard transactions).

In practice, most MEV bots would run on a combination of off-chain code (that contains the actual business logic, finds the profit opportunities, initiates the transactions, etc.) and a very simple smart contract that would look like something like this :

contract Multicall { function runMulticall( address[] calldata targets, bytes[] calldata datas, uint[] calldata values, bool[] calldata reverts) external payable { for(uint i; i < targets.lenght, ++i) { (bool success,) = targets[i].call(datas[i]){value: values[i]}; if(reverts[i] == true) { require(success, "Key transaction failed"); } } } } 

This contracts purpose is only to forward an arbitrary number of arbitrary calls to arbitrary targets, taking advantage of the fact that doing this through a contract is less expensive than doing it through bundles.

1
  • No this isn't about a video or anything I appreciate it though. Just to clarify, I was curious if there is any advantages to having your transactions executed on-chain versus sending or bundling the transactions off chain. But you've answered that. I didn't realize all the limitations EOAs had. Commented Jun 19, 2023 at 3:45
0

You are referring to a scam project that make you deploy what you think is a trading bot smart contract. It is not. There are no on-chain trading bot.

The blockchain can't run process like bots. Any funds sent to the contract is lost.

1
  • I think I worded my question poorly. Here's an example, you can send transactions using ethers "sendTransaction" method or you can write a smart contract that directly interacts with a contract. I was asking if there is a speed benefit or any other benefit to executing the same type of transaction through a smart contract versus doing it off-chain using a script with ethers.js? Commented Jun 19, 2023 at 3:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.