The UniswapV3Helper.getUserTokenAmount function uses some low-level Uniswap math libraries to compute the token0 and token1 value for a given amount of liquidity, a given pool price, and the prices at the tick boundaries.
It's always better to use the official libraries instead of re-implementing them using low-level math libraries.
This avoids potential errors in your implementation, reduces code complexity, and makes the code easier to read.
Recommendation
Consider using the mentioned LiquidityAmounts.getAmountsForLiquidity(TickMath.getSqrtRatioAtTick(_tick), TickMath.getSqrtRatioAtTick(tickLower), TickMath.getSqrtRatioAtTick(tickUpper)) function instead.
Handle
cmichel
Vulnerability details
The
UniswapV3Helper.getUserTokenAmount
function uses some low-level Uniswap math libraries to compute thetoken0
andtoken1
value for a given amount of liquidity, a given pool price, and the prices at the tick boundaries.This is exactly what the higher-level function LiquidityAmounts.getAmountsForLiquidity is doing. The code is also the same.
Impact
It's always better to use the official libraries instead of re-implementing them using low-level math libraries. This avoids potential errors in your implementation, reduces code complexity, and makes the code easier to read.
Recommendation
Consider using the mentioned
LiquidityAmounts.getAmountsForLiquidity(TickMath.getSqrtRatioAtTick(_tick), TickMath.getSqrtRatioAtTick(tickLower), TickMath.getSqrtRatioAtTick(tickUpper))
function instead.