In times of high market turbulence where price impact needs to be set above 50% in order to swap, the position would not be able to properly rebalance.
Proof of Concept
When rebalancing in TALOS, the protocol will eventually call UniswapV3Pool.swap.
Focusing on the exactSqrtPriceImpact calculation, we see that the _strategy.priceImpactPercentage is divided by 2. Price impact percentage is set by the owner in TalosOptimizer.sol
The price impact percentage cannot be set above 1e6 (which is 100%) and 0. Back to the exactSqrtPriceImpact calculation, because price impact percentage is divided by 2, price impact cannot be set above 50% when the original range is from 0-100%. This division effective restricts the range that the price impact percentage can go, which restricts the flexibility of sqrtPriceLimitX96 when swapping.
Tools Used
VSCode
Recommended Mitigation Steps
Recommend removing the division by 2 beside the priceImpactPercentage variable.
Lines of code
https://github.com/code-423n4/2023-05-maia/blob/main/src/talos/libraries/PoolVariables.sol#L250-L253
Vulnerability details
Impact
In times of high market turbulence where price impact needs to be set above 50% in order to swap, the position would not be able to properly rebalance.
Proof of Concept
When rebalancing in TALOS, the protocol will eventually call UniswapV3Pool.swap.
Before calling swap, TALOS Poolvariables.sol will calculate the appropriate sqrtPriceLimitX96.
Focusing on the
exactSqrtPriceImpact
calculation, we see that the_strategy.priceImpactPercentage
is divided by 2. Price impact percentage is set by the owner in TalosOptimizer.solThe price impact percentage cannot be set above 1e6 (which is 100%) and 0. Back to the
exactSqrtPriceImpact
calculation, because price impact percentage is divided by 2, price impact cannot be set above 50% when the original range is from 0-100%. This division effective restricts the range that the price impact percentage can go, which restricts the flexibility ofsqrtPriceLimitX96
when swapping.Tools Used
VSCode
Recommended Mitigation Steps
Recommend removing the division by 2 beside the
priceImpactPercentage
variable.Assessed type
Context