Closed sherlock-admin3 closed 2 months ago
The protocol team fixed this issue in the following PRs/commits: https://github.com/beefyfinance/cowcentrated-contracts/pull/21/files
Fixed. _checkAmounts
now takes the already calculated values and only checks if both of them are non-zero.
The Lead Senior Watson signed off on the fix.
Gas_Optimization
Low/Info issue submitted by petarP1998
Summary
The
StrategyPassiveManagerVelodrome::_checkAmounts
function contains redundant code that calculatesamount0
andamount1
usingLiquidityAmounts.getAmountsForLiquidity
. This calculation is already performed in_addLiquidity
. Therefore, it can be removed from_checkAmounts
and instead, the values can be passed as parameters.Vulnerability Detail
The code snippet below from the
_checkAmounts
function redundantly calculatesamount0
andamount1
:This block is unnecessary since the amounts are already computed in the
_addLiquidity
function.https://github.com/sherlock-audit/2024-05-beefy-cowcentrated-liquidity-manager/blob/main/cowcentrated-contracts/contracts/strategies/velodrome/StrategyPassiveManagerVelodrome.sol#L243
Impact
Removing the redundant code improves the efficiency of the smart contract by eliminating unnecessary calculations, thus reducing gas costs. It also simplifies the code, making it easier to read and maintain.
Code Snippet
Tool used
Manual Review
Recommendation
Refactor the
_checkAmounts
function to remove the redundant code block. Instead, pass the already computedamount0
andamount1
as parameters from_addLiquidity
to_checkAmounts
. This will enhance the contract's efficiency and readability.This will look like this: