A malicious user can use this. An example of this kind of manipulation would be using flash swaps to borrow assets from the pool, manipulate the square root price through a series of trades, and then return the borrowed assets.
Impact
sqrtPriceX96() can be manipulated to cause a loss of funds for the protocol and users.
tsvetanovv
high
_getCurrentSqrtPriceX96()
is easy to manipulationSummary
Usage of
slot0
in_getCurrentSqrtPriceX96()
is easy to manipulation.Vulnerability Detail
In
LiquidityManager.sol
we have_getCurrentSqrtPriceX96()
function:This function retrieves the current square root price from a Uniswap V3 pool.
_getCurrentSqrtPriceX96()
usingslot0
to retrieve data from Uniswap V3 pool. Theslot0
function returns various parameters of the pool, including thesqrtPriceX96
value.slot0
is the most recent data point and is therefore extremely easy to manipulate. https://docs.uniswap.org/contracts/v3/reference/core/interfaces/pool/IUniswapV3PoolState#slot0A malicious user can use this. An example of this kind of manipulation would be using flash swaps to borrow assets from the pool, manipulate the square root price through a series of trades, and then return the borrowed assets.
Impact
sqrtPriceX96()
can be manipulated to cause a loss of funds for the protocol and users.Code Snippet
https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/LiquidityManager.sol#L341
Tool used
Manual Review
Recommendation
Don't use
slot0
. Is better to use TWAP Oracle instead.Duplicate of #109