Gas: XDEFIDistribution.sol
's withdrawAmount
substraction can be unchecked
#49
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
Dravee
Vulnerability details
Impact
Waste of gas due to unnecessary underflow checks
Proof of Concept
On
XDEFIDistribution.sol:120
andXDEFIDistribution.sol:175
, you can find the following substraction:uint256 withdrawAmount = amountUnlocked_ - lockAmount_;
However, as the Solidity version is 0.8.10, default overflow and underflow checks are made, which cost some gas.
You can save this gas with the
unchecked
keyword to bypass these checks as 5 lines above (L115 and L170), arequire
statement already checks thatlockAmount_ <= amountUnlocked_
.Therefore, no underflow is possible.
Tools Used
VS Code
Recommended Mitigation Steps
Use the "unchecked" keyword
The text was updated successfully, but these errors were encountered: