Omniscia Steer Protocol Audit

LiquidityManagerVault Code Style Findings

LiquidityManagerVault Code Style Findings

LMV-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:

src/LiquidityManagerVault.sol
457require(msg.value >= amount0Used, "N0");
458uint256 refund = msg.value - amount0Used;

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 (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The refund calculation has been safely wrapped in an unchecked code block, optimizing its gas cost.

LMV-02C: Inexistent Error Messages

TypeSeverityLocation
Code StyleLiquidityManagerVault.sol:
I-1: L276
I-2: L278
I-3: L301
I-4: L302
I-5: L394
I-6: L395
I-7: L445
I-8: L503
I-9: L597

Description:

The linked require checks have no error messages explicitly defined.

Example:

src/LiquidityManagerVault.sol
276require(to != address(0));

Recommendation:

We advise each to be set so to increase the legibility of the codebase and aid in validating the require checks' conditions.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

All require statements have been updated to if-revert pattern validations that yield proper error declarations, addressing this exhibit in an exemplary manner.

LMV-03C: Misleading Minimum Share Notion

Description:

The MIN_SHARES constant remains unused within the contract and a 1e6 constant is utilized instead as the minimum shares to mint per deposit operation.

Example:

src/LiquidityManagerVault.sol
448(shares, amount0Used, amount1Used) = IHelper(helper).getShares(
449 totalSupply(), total0, total1, amount0Desired, amount1Desired, amount0Min, amount1Min, 1e6
450);

Recommendation:

We advise these values to be streamlined in one way or another, ensuring constant declarations in the contract are properly utilized and magic values are avoided.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The MIN_SHARES constant was updated to reflect 1e6 and is now utilized for the IHelper::getShares call, addressing this exhibit in full.

LMV-04C: Redundant Assignments

Description:

The referenced assignments of 0 will be followed by a return statement of those 0 values which is inefficient.

Example:

src/LiquidityManagerVault.sol
753// For complete burn (shares=1, totalShares=1), return nothing as values are not used in case of complete burn
754if (shares == 1 && totalShares == 1) {
755 vars.total0 = 0; // we can send 0 as the return values are not used in case of complete burn
756 vars.total1 = 0;
757} else {
758 // For partial burn, calculate LP portion of fees
759 vars.lpFees0 = vars.fees0 - vars.cut0;
760 vars.lpFees1 = vars.fees1 - vars.cut1;
761
762 // Calculate amounts to return based on shares
763 vars.total0 = vars.principal0 + FullMath.mulDiv(vars.lpFees0, shares, totalShares);
764 vars.total1 = vars.principal1 + FullMath.mulDiv(vars.lpFees1, shares, totalShares);
765}
766
767return (vars.total0, vars.total1);

Recommendation:

We advise the code to immediately return the values of 0 as literals, optimizing the code's gas cost.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The code was updated per our recommendation, yielding (0,0) immediately and thus optimizing its gas cost.

LMV-05C: Redundant Execution of Full Withdrawal in Initial State

Description:

The LiquidityManagerVault::unlockCallback function will execute several statements unnecessarily with zero values when the initial configuration of the vault's positions is performed.

Example:

src/LiquidityManagerVault.sol
805// 1. First burn all positions
806_executeBurn(1, 1);

Recommendation:

We advise the code to execute a burn solely when the number of positions is non-zero, optimizing the contract's initialization significantly.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The code was updated to perform a position burn solely when non-zero positions exist in the system, optimizing its initialization cost as advised.

LMV-06C: Redundant Parenthesis Statements

TypeSeverityLocation
Code StyleLiquidityManagerVault.sol:
I-1: L298
I-2: L299
I-3: L332
I-4: L345
I-5: L455
I-6: L478
I-7: L491
I-8: L509
I-9: L519
I-10: L904

Description:

The referenced statements are redundantly wrapped in parenthesis' (()).

Example:

src/LiquidityManagerVault.sol
298amount0 = amount0 + (t0FromPool);

Recommendation:

We advise them to be safely omitted, increasing the legibility of the codebase.

Alleviation (121dc0b132):

All instances except for I-6 have been addressed.

Alleviation (2bab393ad0):

The final redundant parenthesis statement has been omitted as advised, fully addressing this exhibit.

LMV-07C: Redundant Repetition of Data Point

Description:

The three referenced data points can all be deduced by a single swapAmount data point.

Example:

src/LiquidityManagerVault.sol
616// Combine all operations (burn, swap, mint) in a single unlock call
617vars.combinedData = abi.encode(
618 Action.CombinedOps,
619 vars.swapAmount, // If non-zero, we'll perform a swap
620 vars.swapAmount > 0, // zeroForOne
621 vars.swapAmount > 0 ? uint256(vars.swapAmount) : uint256(-vars.swapAmount), // absAmount
622 vars.sqrtPriceLimitX96,
623 newPositions, // If lowerTick.length > 0, we'll migrate positions
624 vars.sqrtPriceX96,
625 vars.t0ToDeposit, // t0ToDeposit
626 vars.t1ToDeposit // t1ToDeposit
627);

Recommendation:

We advise this to be done so in the CombinedOps unlock callback, significantly reducing the code's gas cost.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The redundant data points were omitted as advised, extrapolating them in the LiquidityManagerVault::unlockCallback as needed.

LMV-08C: Redundant Usage of Nested Iterator

Description:

The referenced for loop is not nested yet utilizes the j iterator usually reserved for nested loops that have the i iterator already declared.

Example:

src/LiquidityManagerVault.sol
741for (uint256 j; j != vars.fees.length; ++j) {

Recommendation:

We advise the i iterator to be re-used, optimizing the code's style.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The iterator was updated to i as advised.

LMV-09C: Repeated Constant Declarations

Description:

The referenced constant declarations point to the same underlying value.

Example:

src/LiquidityManagerVault.sol
139uint256 internal constant FEE_DIVISOR = 100_00;
140uint256 internal constant ONE_MINUS_FEE = FEE_DIVISOR - TOTAL_FEE;
141uint256 internal constant DIVISOR = 100_00;

Recommendation:

We advise a single constant to be utilized in their place.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The latter of the two constant declarations was omitted per our recommendation.

LMV-10C: Unnecessary TODO Comment

Description:

The referenced TODO comment implies that native fund settlement (erroneously referring to acquiring the output amount of a swap which is not a settlement) must be accounted for via different code.

The existing code already handles native fund swap output extractions and does not need to be updated.

Example:

src/LiquidityManagerVault.sol
839if (outAmount > 0) {
840 poolManager.take( //@todo add native currency settlement
841 zeroForOne ? poolKey.currency1 : poolKey.currency0, address(this), uint256(int256(outAmount)));
842}

Recommendation:

We advise the TODO comment to be omitted.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The referenced TODO comment has been omitted as advised.

LMV-11C: Unresolved TODO Comment

Description:

The referenced helper contract is presently inaccessible due to pointing to an incorrect address.

Example:

src/LiquidityManagerVault.sol
128address internal constant helper = 0x1234567890123456789012345678901234567890; // TODO: Set actual helper address

Recommendation:

We advise the proper address to be utilized here after the conclusion of the audit report to ensure the LiquidityManagerVault contract behaves as expected.

Alleviation (121dc0b1329a48555f90bb92e58a95e8ff8a7c79):

The TODO comment was updated to @notice documentation indicating that the address is expected to change between deployments.