20,000 USDC
View results
Submission Details
Severity: gas
Valid

Constants or literal values in comparisons

Summary

Constants or literal values in comparisons should appear on the left side of the comparison operator in order to prevent typo bugs.

Vulnerability Details

There are 7 instances of this issue.

View 7 Instances
File: src/Lender.sol
134: p.minLoanSize == 0 ||
135: p.maxLoanRatio == 0 ||
136: p.auctionLength == 0 ||
184: if (amount == 0) revert PoolConfig();
200: if (amount == 0) revert PoolConfig();
212: if (maxLoanRatio == 0) revert PoolConfig();
244: if (collateral == 0) revert ZeroCollateral();
File Link Instance Count Instance Links
Lender.sol 7 134,135,136,184,200,212,244

Impact

If an operator character is missing, an unintentional variable assignment can occur. For example:

// Intent - compare value to ten
if (voteCount == 10) {
// do something
}
// Typo - forgot one equal sign causing variable assignment
if (voteCount = 10) {
// now voteCount equals ten
}
// Preventative style - a missing equal sign will not compile
if (10 == voteCount) {
// do something
}

Tools Used

baudit: a custom static code analysis tool; manual review

Recommendations

Place constants and literal values on the left side of the comparison operator.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.