Omniscia Kyo Finance Audit

SingleStreamConsumer Code Style Findings

SingleStreamConsumer Code Style Findings

SSC-01C: Inexistent Conditional Chaining

TypeSeverityLocation
Gas OptimizationSingleStreamConsumer.sol:
I-1: L23, L24, L25
I-2: L29, L31, L32

Description:

The SingleStreamConsumer will employ several independent if conditionals each evaluating comparisons that influence each other's validity.

Example:

contracts/reward/SingleStreamConsumer.sol
28function _inputTokens() internal view virtual override returns (address[] memory) {
29 if (nToken <= 2) {
30 address[] memory ret = new address[](nToken);
31 if (nToken >= 1) ret[0] = token0;
32 if (nToken >= 2) ret[1] = token1;
33 return ret;
34 }
35 return _tokens;
36}

Recommendation:

We advise the system to combine the conditionals in nested if clauses, optimizing the code's gas cost as well as legibility.

For example, the SingleStreamConsumer::_inputTokens function can nest the nToken >= 2 comparison within the nToken >= 1 comparison and further adjust it to an equality comparison whilst the SingleStreamConsumer::constructor can handle each nToken length case in an if-else-if structure.

Alleviation (17c8d4e59f398021156f6f9657ff278aae0462ae):

The Kyo Finance team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase.