Closed code423n4 closed 2 years ago
TomFrench
Increased gas cost on swaps
The logic in the require statement at this link can be simplified: https://github.com/code-423n4/2021-10-tally/blob/c585c214edb58486e0564cb53d87e4831959c08b/contracts/swap/Swap.sol#L142-L152
(!signifiesETHOrZero(zrxBuyTokenAddress) && boughtERC20Amount >= minimumAmountReceived) ||(signifiesETHOrZero(zrxBuyTokenAddress) && boughtETHAmount >= minimumAmountReceived)
is equivalent to
signifiesETHOrZero(zrxBuyTokenAddress) ? boughtETHAmount >= minimumAmountReceived : boughtERC20Amount >= minimumAmountReceived
Replace logic statement with simplified version.
dupe of #41
Handle
TomFrench
Vulnerability details
Impact
Increased gas cost on swaps
Proof of Concept
The logic in the require statement at this link can be simplified: https://github.com/code-423n4/2021-10-tally/blob/c585c214edb58486e0564cb53d87e4831959c08b/contracts/swap/Swap.sol#L142-L152
(!signifiesETHOrZero(zrxBuyTokenAddress) && boughtERC20Amount >= minimumAmountReceived) ||(signifiesETHOrZero(zrxBuyTokenAddress) && boughtETHAmount >= minimumAmountReceived)
is equivalent to
signifiesETHOrZero(zrxBuyTokenAddress) ? boughtETHAmount >= minimumAmountReceived : boughtERC20Amount >= minimumAmountReceived
Recommended Mitigation Steps
Replace logic statement with simplified version.