Cyfrin / 2023-07-foundry-defi-stablecoin

37 stars 32 forks source link

Use assembly to check for `address(0)` #1133

Open codehawks-bot opened 1 year ago

codehawks-bot commented 1 year ago

Use assembly to check for address(0)

Severity

Gas Optimization / Informational

Relevant GitHub Links

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

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

Summary

Use assembly to check for address(0)

Vulnerability Details

Saves 6 gas per instance

Instances (2):

File: src/DSCEngine.sol

103:         if (s_priceFeeds[token] == address(0)) {

Link to code - https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/tree/main/src/DSCEngine.sol

File: src/DecentralizedStableCoin.sol

59:         if (_to == address(0)) {

Link to code - https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/tree/main/src/DecentralizedStableCoin.sol

Tools Used

Code Review using VSCode

Recommendations

Use assembly to check for address(0)