Omniscia Mean Finance Audit
UniswapV3Adapter Code Style Findings
UniswapV3Adapter Code Style Findings
UVA-01C: Inexplicable Usage of Lower-Accuracy Types
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | UniswapV3Adapter.sol:L25, L29 |
Description:
The linked variables use a variable type less than 256-bits which is sub-optimal given that the EVM is built to operate on 256-bit types and any type less than that is artificial by the Solidity compiler using padding and unpadding instructions. Additionally, the variables declared in sequence do not occupy a full storage slot (i.e. the bit sum of period, cardinalityPerMinute, and gasPerCardinality does not exceed 256 bits) thus allowing room for expansion of the bit types.
Example:
24/// @inheritdoc IUniswapV3Adapter25uint16 public period;26/// @inheritdoc IUniswapV3Adapter27uint8 public cardinalityPerMinute;28/// @inheritdoc IUniswapV3Adapter29uint32 public gasPerCardinality = 22_250;Recommendation:
We advise the period to be expanded to a uint32 data type (thus rendering the casting operation performed in _addOrModifySupportForPair redundant) and the gasPerCardinality type to be set to a uint216 data type thus making use of the full storage slot the three variables occupy.
Alleviation:
The period, gasPerCardinality as well as the newly declared gasCostToSupportPool variables have all had their bit-sizes adjusted to fit within the 256-bit threshold described in the exhibit thus optimizing the codebase.
