Open code423n4 opened 3 years ago
This feels correct, though the additional verification of the pair (token swap + token amount > minimum, ETH swap + ETH amount > minimum) feels like a good way to avoid having to reason about potentially complex interactions between ETH and token amounts in edge cases. We may leave this as-is.
Handle
csanuragjain
Vulnerability details
Impact
Gas wastage, can be optimized with changing condition
Proof of Concept
Navigate to https://github.com/code-423n4/2021-10-tally/blob/main/contracts/swap/Swap.sol
Let us see the swapByQuote function which has below condition
Now there are only 2 types of token which are ETH and non ETH token.
But the condition in 2 is splitting the checks based on type of token which can be optimized. Since we already know that tokens can be ETH or non ETH so simply we can change the condition to
Tools Used
Recommended Mitigation Steps
Change the condition to below: