code-423n4 / 2022-01-elasticswap-findings

1 stars 0 forks source link

Custom Errors #159

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

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.

GalloDaSballo commented 2 years ago

Finding is valid, customErrors cost less and reduce revert case gas cost as well, also using below 32 char strings helps as well