code-423n4 / 2021-12-defiprotocol-findings

0 stars 0 forks source link

Use negate(!) rather than `== false` #138

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

0x0x0x

Vulnerability details

Concept

Negation(!) is a better optimized implementation of applying == false. It requires less gas and also the recommended approach to compute the negation.

In other words: x == false and !x compute the same result, but !x costs less gas.

Scope

./Auction.sol:37:        require(auctionOngoing == false, 'ongoing auction');
./Basket.sol:92:        require(auction.auctionOngoing() == false);
./Basket.sol:109:        require(auction.auctionOngoing() == false);
./Basket.sol:221:            if (auction.auctionOngoing() == false) {
./Basket.sol:259:        require(auction.auctionOngoing() == false);