As of #4, we fetch token/pool info for every swap we retrieve in the initial getSwaps() call. But we do not need this info when searching for sandwiches. We only need it after a sandwich has been identified. Furthermore, the majority of swaps are not sandwiched. This all means that we are doing a lot of contract read requests for nothing, and this noticeably slows down the initial phase, especially for addresses with many swaps (such as 0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf).
We should instead fetch this info only after a sandwich has been detected. We can remove the pool field from the SwapLog, and just look it up locally in findSandwich().
As of #4, we fetch token/pool info for every swap we retrieve in the initial
getSwaps()
call. But we do not need this info when searching for sandwiches. We only need it after a sandwich has been identified. Furthermore, the majority of swaps are not sandwiched. This all means that we are doing a lot of contract read requests for nothing, and this noticeably slows down the initial phase, especially for addresses with many swaps (such as 0x3328f5f2cEcAF00a2443082B657CedEAf70bfAEf).We should instead fetch this info only after a sandwich has been detected. We can remove the
pool
field from theSwapLog
, and just look it up locally in findSandwich().