gas

Amounts should be checked for `0` before calling a `transfer`

Reward

Total

24.49 USDC

Selected
24.49 USDC
Selected Submission

Amounts should be checked for 0 before calling a transfer

Severity

Gas Optimization / Informational

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/tree/main/src/DSCEngine.sol#L157

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/tree/main/src/DSCEngine.sol#L287

Summary

Vulnerability Details

According to the fact that EIP-20 states that zero-valued transfers must be accepted.

Checking non-zero transfer values can avoid an expensive external call and save gas. While this is done at some places, it’s not consistently done in the solution.

There are 2 instances of this issue:

Impact

Tools Used

Recommendations

Consider adding a non-zero-value check at the beginning of function.