Omniscia Sovryn Audit
Utils Code Style Findings
Utils Code Style Findings
UTI-01C: Ill-Advised Error Style
Type | Severity | Location |
---|---|---|
Code Style | Informational | Utils.sol:L95 |
Description:
The require
statement linked will always throw due to boasting a false
literal as the conditional.
Example:
sovryn-token-bridge/bridge/contracts/Utils.sol
75function granularityToDecimals(uint256 granularity) public pure returns (uint8) {76 if(granularity == 1) return 18;77 if(granularity == 10) return 17;78 if(granularity == 100) return 16;79 if(granularity == 1000) return 15;80 if(granularity == 10000) return 14;81 if(granularity == 100000) return 13;82 if(granularity == 1000000) return 12;83 if(granularity == 10000000) return 11;84 if(granularity == 100000000) return 10;85 if(granularity == 1000000000) return 9;86 if(granularity == 10000000000) return 8;87 if(granularity == 100000000000) return 7;88 if(granularity == 1000000000000) return 6;89 if(granularity == 10000000000000) return 5;90 if(granularity == 100000000000000) return 4;91 if(granularity == 1000000000000000) return 3;92 if(granularity == 10000000000000000) return 2;93 if(granularity == 100000000000000000) return 1;94 if(granularity == 1000000000000000000) return 0;95 require(false, "Utils: invalid granularity");96}
Recommendation:
We advise it to either be adjusted to a revert
instruction or to a require
validating the last if
conditional, rendering the conditional redundant.
Alleviation:
The development team has acknowledged this exhibit but decided to not apply its remediation in the current version of the codebase.