Open code423n4 opened 2 years ago
sorrynotsorry
Gas cost will be higher due to long string inside require statements
require(this.totalSupply() > 0, "Exchange: INSUFFICIENT_LIQUIDITY"); require(_baseTokenQtyMin > 0 && _quoteTokenQtyMin > 0, "Exchange: MINS_MUST_BE_GREATER_THAN_ZERO"
Manual review
Usage of Custom Errors will reduce the gas cost where the require statements may refactored as condition checks.
Finding is valid, customErrors cost less and reduce revert case gas cost as well, also using below 32 char strings helps as well
Handle
sorrynotsorry
Vulnerability details
Impact
Gas cost will be higher due to long string inside require statements
Proof of Concept
require(this.totalSupply() > 0, "Exchange: INSUFFICIENT_LIQUIDITY"); require(_baseTokenQtyMin > 0 && _quoteTokenQtyMin > 0, "Exchange: MINS_MUST_BE_GREATER_THAN_ZERO"
Tools Used
Manual review
Recommended Mitigation Steps
Usage of Custom Errors will reduce the gas cost where the require statements may refactored as condition checks.