It doesn't make much sense: the profit is greater than the amount traded by the victim!
The reason is that the open/close wrapped multiple user trades on that token. So the total profit of 3.5ETH is spread across multiple swaps.
We can address this in two steps in order of increasing work:
Step 1: add a heuristic that just drops sandwiches where the computed profit is greater than the traded amount times some constant (1? 0.5?)
Step 2: for each sandwich, go and look at all trades between open/close, and see if multiple swaps are sandwiched. If that's the case, then approximate each user's share of the loss and use that. This step could be done in the current approach, but it would be preferable to wait till we do a full chain scan.
Consider this sandwich:
It doesn't make much sense: the profit is greater than the amount traded by the victim!
The reason is that the open/close wrapped multiple user trades on that token. So the total profit of 3.5ETH is spread across multiple swaps.
We can address this in two steps in order of increasing work: