Open codehawks-bot opened 1 year ago
Gas Optimization / Informational
In DSCEngine.sol, the _burnDsc() uses addition assignment which costs more gas
The following code is used in _burnDsc()
function _burnDsc(uint256 amountDscToBurn, address onBehalfOf, address dscFrom) private { s_DSCMinted[onBehalfOf] -= amountDscToBurn; bool success = i_dsc.transferFrom(dscFrom, address(this), amountDscToBurn); // This conditional is hypothtically unreachable if (!success) { revert DSCEngine__TransferFailed(); } i_dsc.burn(amountDscToBurn); }
Extra runtime gas is used.
Manual review
Consider using the following:
s_DSCMinted[onBehalfOf] = s_DSCMinted[onBehalfOf] - amountDscToBurn;
x - y is more efficient than using -=
Severity
Gas Optimization / Informational
Summary
In DSCEngine.sol, the _burnDsc() uses addition assignment which costs more gas
Vulnerability Details
The following code is used in _burnDsc()
Impact
Extra runtime gas is used.
Tools Used
Manual review
Recommendations
Consider using the following: