Omniscia Steer Protocol Audit
BaseLiquidityManager Code Style Findings
BaseLiquidityManager Code Style Findings
BLM-01C: Inexistent Error Messages
Type | Severity | Location |
---|---|---|
Code Style | BaseLiquidityManager.sol:L223, L234, L266-L271, L367, L379 |
Description:
The linked require
checks have no error messages explicitly defined.
Example:
223require(msg.sender == address(pool));
Recommendation:
We advise each to be set so to increase the legibility of the codebase and aid in validating the require
checks' conditions.
Alleviation (0ed41ccc18a72b7e559b8d79ab7ba6172362ee3b):
The Steer Protocol team evaluated this exhibit but opted not to apply it to retain a smaller bytecode size for the contract and avoid surpassing the bytecode deployment limit. As a result, we consider this exhibit acknowledged.
BLM-02C: Non-Standard Gap Declaration
Type | Severity | Location |
---|---|---|
Code Style | BaseLiquidityManager.sol:L160 |
Description:
The gap
variable commonly found in upgradeable contracts of OpenZeppelin are meant to represent the current number of storage slots the contract consumes (we define it as n
) subtracted to the value of 50
(i.e. for 5 storage slots the length
of the gap
should be 50 - 5 = 45
).
Example:
160uint256[100] gap;
Recommendation:
We advise this methodology to be applied in the current contract as otherwise the length
value of the gap
is meaningless.
Alleviation (200f275c40):
The gap
variable was updated to consume 124
slots based on the assumption that a total of 250
slots are claimed by the contract, however, the contract only claims 10
slots. We advise the gap
to be revised to 40
in line with the OpenZeppelin gap standardization style.
Alleviation (0ed41ccc18):
While the gap
size was significantly reduced, it was set to the exemplary value of 45
instead of the actual value of 40
the contract should use.
Alleviation (878a807a67):
The gap
has been set to 40
as originally advised, rendering this exhibit alleviated.
BLM-03C: Relocation of Validation Check
Type | Severity | Location |
---|---|---|
Gas Optimization | BaseLiquidityManager.sol:L467 |
Description:
The linked require
check is executed after multiple expensive operations are performed.
Example:
451require(shares > 0, "shares");452require(amount0Used >= amount0Min, "amt0");453require(amount1Used >= amount1Min, "amt1");454
455// Pull in tokens from sender456if (amount0Used > 0) {457 token0.safeTransferFrom(msg.sender, address(this), amount0Used);458}459if (amount1Used > 0) {460 token1.safeTransferFrom(msg.sender, address(this), amount1Used);461}462
463// Mint shares to recipient464_mint(to, shares);465
466// TotalSupply after deposit must not exceed max total supply467require(totalSupply() <= maxTotalSupply, "TOT");
Recommendation:
We advise it to be relocated after the non-zero check for shares
(whilst also adding shares
to totalSupply
) to ensure that the method halts as soon as it detects an error and minimizing gas wasted in failure cases.
Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):
The check has been properly relocated, optimizing the worst-case gas consumption of the function accordingly.
BLM-04C: Sub-Optimal Data Types
Type | Severity | Location |
---|---|---|
Gas Optimization | BaseLiquidityManager.sol:L63, L65-L67 |
Description:
The linked data types have been defined as uint24
inefficiently.
Example:
59/// @notice Fee info60/// @dev Fee rates, each multiplied by 10,00061/// (a TOTAL_FEE of 100 means a 1% cut of total uniswap fees)62/// @dev Total fraction of fees not going towards LPs, multiplied by 10,00063uint24 public constant TOTAL_FEE = 1500;64/// @dev Total fraction of fees going towards Steer (as opposed to going towards strategist)65uint24 public constant STEER_FRACTION_OF_FEE = 6667;66uint24 internal constant FEE_DIVISOR = 1e4;67uint24 internal constant ONE_MINUS_FEE = FEE_DIVISOR - TOTAL_FEE;
Recommendation:
Given that the EVM is built to operate on 32-byte (256-bit) data types, we advise them to be upcast to uint256
variables which does not affect the operations they are included in whilst rendering them cheaper to execute.
Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):
All referenced data types have been adequately upscaled to uint256
, decreasing the gas cost consumed when utilizing them.