code-423n4 / 2022-01-xdefi-findings

0 stars 0 forks source link

Redundant type casting #150

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L253-L255

require(amount_ != uint256(0) && amount_ <= MAX_TOTAL_XDEFI_SUPPLY, "INVALID_AMOUNT");

https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L289-L289

assert(x_ >= int256(0));

https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L304-L304

require(expiry != uint32(0), "NO_LOCKED_POSITION");

https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L322-L322

require(count > uint256(1), "USE_UNLOCK");

https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L207-L207

require(count > uint256(1), "MIN_2_TO_MERGE");

Redundant type casting increases contract size and gas usage at deployment.

deluca-mike commented 2 years ago

These are declarations, not casting, and thus there is no gas savings or waste either way. This it is done so that types of literals are explicit.

Ivshti commented 2 years ago

agreed with this