Adding an if check to avoid unnecessary call #38
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
0xngndev
Vulnerability details
Impact
In the contract
NestedBuybacker
, the internal functiontrigger
calculates how much NST to send to the reserve by doing:uint256 toSendToReserve = balance - toBurn;
and then makes a safeTransfer for that amount to the nstReserve contract:
NST.safeTransfer(nstReserve, toSendToReserve);
Because there's a possibility of the burn rate set to 100%, there can exist situations where the contract ends up transferring 0 NST to the reserve. This would incur in unnecessary gas costs that can be avoided with a simple if check.
The if check increases the contract size from 6189 to 6195 bytes, and adds a small amount of gas cost. However, if the possibility of having the burn rate set to 100% is something feasible, avoiding that call should
end up being cheaper than adding an if check.
Mitigation steps
Simply add an if check to the NST.safeTransfer line that checks that toSendToReserve is not 0
The text was updated successfully, but these errors were encountered: