The transferFrom
function of the DSC token always returns true, making it unnecessary to create an if statement and compare the result to false.
In the DSCEngine._burnDsc
function calls the DecentralizedStableCoin.transferFrom
function to transfer tokens from msg.sender
to the DSCEngine
contract.
The return value of the transferFrom
function is stored, and we check if it's false to revert the transaction. However, it's important to note that the transferFrom
function in the DecentralizedStableCoin
contract (inherited from OZ ERC20 v4.8.0) always returns true.
As a result, the additiond of an if statement to check for a false return value is redundant and unnecessary. Eliminating this check can help save gas for each burn operation, leading to more efficient contract execution.
Save gas for users anytime DSCEngine burn DSC tokens.
VSCode
Remove the following check to save gas:
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DSCEngine.sol#L276-L278
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.