Omniscia Steer Protocol Audit
GaussianPosition Code Style Findings
GaussianPosition Code Style Findings
GPN-01C: Generic Typographic Mistake
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | GaussianPosition.sol:L42 |
Description:
The referenced line contains a typographical mistake (i.e. private variable without an underscore prefix, a non-snake_case module) or generic documentational error (i.e. copy-paste) that should be corrected.
Example:
42uint256 invertwedExpValue = 1e36 / expValue;Recommendation:
We advise this to be done so to enhance the legibility of the codebase.
Alleviation:
The referenced typographic mistake has been corrected.
GPN-02C: Inefficient Recalculations of Square Root Ratios
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | GaussianPosition.sol:L138, L139, L162, L163 |
Description:
The referenced square root ratios will be re-calculated twice redundantly.
Example:
131// Step 2: Calculate liquidity and normalize weights132for (uint256 i = 0; i < uint24(_numPositions); i++) {133 // Normalize the weight by dividing by totalWeight134 uint256 normalizedWeight = weights[i] * 1e4 / totalWeight;135
136 (uint256 amount0Wanted, uint256 amount1Wanted) = LiquidityAmounts.getAmountsForLiquidity(137 sqrtPriceX96,138 TickMath.getSqrtRatioAtTick(positions[i].lowerTick),139 TickMath.getSqrtRatioAtTick(positions[i].upperTick),140 uint128(PRECISION * normalizedWeight)141 );142 // No safecast here--an overflow will lead to an incorrect number,143 // which will either (usually) revert, or cause a harmless liquidity miscalculation.144 // Record amt0Delta and amt1Delta for this position145 positionT0Requested[i] = amount0Wanted;146 positionT1Requested[i] = amount1Wanted;147
148 // Add amt0Delta and amt1Delta to totalT0Requested and totalT1Requested149 totalT0Requested += amount0Wanted;150 totalT1Requested += amount1Wanted;151}152for (uint256 i; i != _numPositions; ++i) {153 // Liquidity to deposit for this position is calculated using _liquidityForAmounts154 // and the calculated tokens to deposit for the position.155 // Set token amounts for this position156 uint256 positionT0Amount =157 totalT0Requested > 0 ? FullMath.mulDiv(positionT0Requested[i], token0Desired, totalT0Requested) : 0;158 uint256 positionT1Amount =159 totalT1Requested > 0 ? FullMath.mulDiv(positionT1Requested[i], token1Desired, totalT1Requested) : 0;160 liquidity[i] = LiquidityAmounts.getLiquidityForAmounts(161 sqrtPriceX96,162 TickMath.getSqrtRatioAtTick(positions[i].lowerTick),163 TickMath.getSqrtRatioAtTick(positions[i].upperTick),164 positionT0Amount,165 positionT1Amount166 );167 total0 += positionT0Amount;168 total1 += positionT1Amount;169}Recommendation:
We advise them to be calculated once, potentially by attaching them to the position data entries.
Alleviation:
The Steer Protocol team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase.
GPN-03C: Redundant Parenthesis Statements
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | GaussianPosition.sol: • I-1: L46 • I-2: L86 • I-3: L87 • I-4: L88 |
Description:
The referenced statements are redundantly wrapped in parenthesis' (()).
Example:
46return (invertwedExpValue) / denominator;Recommendation:
We advise them to be safely omitted, increasing the legibility of the codebase.
Alleviation:
The redundant parenthesis in the referenced statements have been safely omitted.
GPN-04C: Redundant Type Casting
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | GaussianPosition.sol:L132 |
Description:
The referenced type casting to uint24 is unnecessary as the variable is already of the desired type.
Example:
132for (uint256 i = 0; i < uint24(_numPositions); i++) {Recommendation:
We advise the variable to be utilized directly, optimizing the code's syntax.
Alleviation:
The referenced redundant type casting has been omitted, optimizing the code's syntax.
GPN-05C: Unutilized Constant
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | GaussianPosition.sol:L20 |
Description:
The referenced constant remains unused within the codebase.
Example:
20uint256 constant E = 271828182845904523536028747135266249776; // e * 1e20Recommendation:
We advise it to be omitted, optimizing the code's syntax.
Alleviation:
The unutilized constant declaration has been omitted as advised.
GPN-06C: Variable Mutability Specifiers (Immutable)
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | GaussianPosition.sol: • I-1: L23 • I-2: L24 |
Description:
The linked variables are assigned to only once during the contract's constructor.
Example:
23uint24 public numPositions;24uint256 public sigma;25
26constructor(uint24 _numPositions, uint256 _sigma) {27 require(_numPositions > 0, "POS");28 require(_sigma > 0, "SIG");29 numPositions = _numPositions;30 sigma = _sigma;31}Recommendation:
We advise them to be set as immutable greatly optimizing their read-access gas cost.
Alleviation:
The Steer Protocol team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase.
