If token1=Dai the rebalance mostly wont work with high USSD value
Summary
When token1=daiThe price will be divided by 1e14 /1e12 which for almost any value in dai it will return 0 and cause wrong calculations and wrong rebalancing and possible reverts if dai is more than USSD.
Vulnerability Detail
Mostly like if the price is `9000e18/8000e6` which dai to USSD then we do the sqrt math on it and it becomes
2.
sqrtPriceX96 = sqrt(9000e18/8000e6) * 2**96=8.40341564622e34;
3.
price =(sqrtPriceX96 * sqrtPriceX96) * (1e18) >> (96 *2) // which is / 2**96
price=8.91316828285e58;
4.
(1e24/price)/1e12= which turns price into 0 because 1e24 is smaller then e58 value
Impact
rebalance will revert or cause an undesired state by not getting the real price and instead getting zero
simon135
high
If
token1=Dai
the rebalance mostly wont work with high USSD valueSummary
When
token1=dai
The price will be divided by 1e14 /1e12 which for almost any value in dai it will return 0 and cause wrong calculations and wrong rebalancing and possible reverts if dai is more than USSD.Vulnerability Detail
Impact
rebalance will revert or cause an undesired state by not getting the real price and instead getting zero
Code Snippet
poc
Tool used
Manual Review
Recommendation
if 0 make it revert and change the math to
am/1e24
Duplicate of #222