Omniscia Kyo Finance Audit

UniswapV2Gauge Code Style Findings

UniswapV2Gauge Code Style Findings

UVG-01C: Ineffectual Usage of Safe Arithmetics

Description:

The linked mathematical operation is guaranteed to be performed safely by logical inference, such as surrounding conditionals evaluated in require checks or if-else constructs.

Example:

contracts/voting/uniswap-v2/UniswapV2Gauge.sol
52if (balance > owed) return uint128(Math.min(type(uint128).max, balance - owed));

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statement to be wrapped in an unchecked code block thereby optimizing its execution cost.

Alleviation (17c8d4e59f398021156f6f9657ff278aae0462ae):

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

UVG-02C: Inexistent Revert Statement

Description:

Although the UniswapV2Gauge::isInsideV2PairLock function is expected to revert in all cases, it is still considered best practice to either document or always revert if it is ever used in a try-catch clause as is the case within the UniswapV2Gauge::_checkReadOnlyReentrancy function.

Example:

contracts/voting/uniswap-v2/UniswapV2Gauge.sol
79function isInsideV2PairLock() external returns (bool) {
80 try pair.sync() {
81 revert NotReentered();
82 } catch {
83 revert Reentered();
84 }
85}
86
87function _checkReadOnlyReentrancy() internal {
88 try this.isInsideV2PairLock() {}
89 catch (bytes memory err) {
90 if (bytes4(err) == NotReentered.selector) return;
91 else revert Reentered();
92 }
93}

Recommendation:

We advise either a documentation line or a revert statement to be introduced in the try clause's brackets, optimizing the code's legibility.

Alleviation (17c8d4e59f398021156f6f9657ff278aae0462ae):

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