Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mintTo has not an extra require statement #142

Open
code423n4 opened this issue Dec 10, 2021 · 1 comment
Open

mintTo has not an extra require statement #142

code423n4 opened this issue Dec 10, 2021 · 1 comment
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Handle

0x0x0x

Vulnerability details

basket.sol#mintTo is as follows:


function mintTo(uint256 amount, address to) public nonReentrant override {

require(auction.auctionOngoing() == false);

require(amount > 0);

uint256 startSupply = totalSupply();

require(startSupply + amount <= maxSupply);

handleFees(startSupply);

pullUnderlying(amount, msg.sender);

_mint(to, amount);

require(totalSupply() <= maxSupply);

emit Minted(to, amount);

}

To check, whether maxSupply is exceeded first the following statement is used:

require(startSupply + amount <= maxSupply);

At the end of the function once again, it is checked:

require(totalSupply() <= maxSupply);

Since second requirement already check whether maximum supply is exceeded, the first on is not required and consumes extra gas.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 10, 2021
code423n4 added a commit that referenced this issue Dec 10, 2021
@0xleastwood
Copy link
Collaborator

I agree, the first require statement is redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants