kiki_dev
medium
Getting the price in getOwnValuation is likely to lead to an overflow and cause the transaction to revert.
Inside of getOwnValuation()
there is an attempt to get the price from uinpool
.
(uint160 sqrtPriceX96,,,,,,) = uniPool.slot0();
If the token in unipool
is not ussd
then it will enter the else block.
else { price = uint(sqrtPriceX96)*(uint(sqrtPriceX96))*(1e18 /* 1e12 + 1e6 decimal representation */) >> (96 * 2);
When price is calculated here there is good chance it will overflow. This is because sqrtPriceX96
has 96 bits for decimals. 1e18 will take up another 60 bits. Which sums to ((256 - (2*96 ) )-60) = 4
. Meaning there are only 4 bits for non-decimal part of sqrtPriceX96
.
A similar finding was discovered by trust in their security audit. Page 9. M -1 https://www.trust-security.xyz/rysk-audit
getOwnValuation()
will revert which will prevent rebalance()
from executing.
Manual Review
Consider making sure the calculations are performed safely. Potentially converting the sqrtPrice to a 60x18 format and performing arithmetic operations using a library.