Closed code423n4 closed 2 years ago
This change would only results in gas saving for sad-path (which most wallets would already prevent the transaction from being broadcasted anyway), and increases gas costs for happy-path. In any case, the check for the amount is being removed in place for a check of units
lower down.
Handle
WatchPug
Vulnerability details
In
lock()
, checks ofamount_
is done in_unlock()
, aftersafeTransferFrom()
.https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L255
Check if
amount_ > 0
earlier can avoid unnecessary code execution when this check failed.https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L92-L97
The same issue also exists in
XDEFIDistribution#lockWithPermit()
.Recommendation
Change to: