Open code423n4 opened 2 years ago
WatchPug
https://github.com/code-423n4/2021-12-amun/blob/cf890dedf2e43ec787e8e5df65726316fda134a1/contracts/basket/contracts/facets/Basket/BasketFacet.sol#L148-L148
require(!this.getLock(), "POOL_LOCKED");
https://github.com/code-423n4/2021-12-amun/blob/cf890dedf2e43ec787e8e5df65726316fda134a1/contracts/basket/contracts/facets/Basket/BasketFacet.sol#L282-L286
function getLock() external view override returns (bool) { LibBasketStorage.BasketStorage storage bs = LibBasketStorage.basketStorage(); return bs.lockBlock == 0 || bs.lockBlock >= block.number; }
getLock() is being defined and used as an external function (this.getLock()), which costs more gas than using it as an internal function.
getLock()
this.getLock()
We suggest change it to require(!getLock(), "POOL_LOCKED"); for gas saving.
require(!getLock(), "POOL_LOCKED");
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-amun/blob/cf890dedf2e43ec787e8e5df65726316fda134a1/contracts/basket/contracts/facets/Basket/BasketFacet.sol#L148-L148
https://github.com/code-423n4/2021-12-amun/blob/cf890dedf2e43ec787e8e5df65726316fda134a1/contracts/basket/contracts/facets/Basket/BasketFacet.sol#L282-L286
getLock()
is being defined and used as an external function (this.getLock()
), which costs more gas than using it as an internal function.We suggest change it to
require(!getLock(), "POOL_LOCKED");
for gas saving.