code-423n4 / 2021-09-wildcredit-findings

0 stars 0 forks source link

`UniswapV3Helper.getUserTokenAmount` could be simplified #47

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

cmichel

Vulnerability details

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.

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.

talegift commented 2 years ago

Suggest lowering severity to 0 as it's not a bug.

ghoul-sol commented 2 years ago

improvement proposal, non-critical