-
Notifications
You must be signed in to change notification settings - Fork 3
Description
In AUniswapDecoder, all actions that require forwarding value are decoded and value is appended.
Arbitrage bots buy and sell the same pairs, with a resulting small value transfer when using a chain's native token.
We could therefore temporary store (memory or transient storage) a int256 value, add and subtract based on whether CurrencyOut is native, then convert to the minimum between 0 and uint256(value) (or int256 casted to uint256). This would allow forwarding only necessary value. Technically, this would not save gas unless the swaps resulted in exact native amount in and out, and diff token amount in and out (which is generally not the case); by contrast, there is a slight increase in gas consumption for extra condition handling. However, this would allow taking advantage of uniswap's v4 flash accounting.