Closed sherlock-admin closed 1 year ago
0xpinky
medium
_getTicksForPosition
tickSpacingOffset > 0
_getTicksForPosition will return the incorrect the lower and upper tick values when calling from _initializeStrategy
_initializeStrategy is called to initialize the strategies by traversing the strategy in a loop.
_initializeStrategy
It would call the _getTicksForPosition to get the lower as well as upper ticks.
when look at the function _getTicksForPosition, below logic is used to decide the lower and upper tick value.
} else if (tickSpacingOffset > 0) { lowerTick = floorTick + tickSpacing * tickSpacingOffset; upperTick = lowerTick + positionRange; } else {
But it is incorrect, upperTick is marked as lowerTick and vise versa.
Valid ticks are marked as invalid and reverted in the Line296
This _initializeStrategy would be calling in deposit(first time), rebalanceAll
So, rebalancing would be reverted due to this.
https://github.com/sherlock-audit/2023-06-real-wagmi/blob/main/concentrator/contracts/Multipool.sol#L272-L297
Manual Review
Update the below portion the codes as shown below
https://github.com/sherlock-audit/2023-06-real-wagmi/blob/main/concentrator/contracts/Multipool.sol#L263-L266
} else if (tickSpacingOffset > 0) { upperTick = floorTick + tickSpacing * tickSpacingOffset; lowerTick = lowerTick + positionRange; } else {
0xpinky
medium
_getTicksForPosition
will not determine the valid lower and upper tick whentickSpacingOffset > 0
Summary
_getTicksForPosition
will return the incorrect the lower and upper tick values when calling from _initializeStrategyVulnerability Detail
_initializeStrategy
is called to initialize the strategies by traversing the strategy in a loop.It would call the
_getTicksForPosition
to get the lower as well as upper ticks.when look at the function _getTicksForPosition, below logic is used to decide the lower and upper tick value.
But it is incorrect, upperTick is marked as lowerTick and vise versa.
Impact
Valid ticks are marked as invalid and reverted in the Line296
This _initializeStrategy would be calling in deposit(first time), rebalanceAll
So, rebalancing would be reverted due to this.
Code Snippet
https://github.com/sherlock-audit/2023-06-real-wagmi/blob/main/concentrator/contracts/Multipool.sol#L272-L297
Tool used
Manual Review
Recommendation
Update the below portion the codes as shown below
https://github.com/sherlock-audit/2023-06-real-wagmi/blob/main/concentrator/contracts/Multipool.sol#L263-L266