Open code423n4 opened 3 years ago
hickuphh3
In getUserTokenAmount(), TickMath.getSqrtRatioAtTick(_tick) is called twice when the position is active (tickLower ≤_tick < tickUpper).
getUserTokenAmount()
TickMath.getSqrtRatioAtTick(_tick)
Its value should be saved to avoid a repeat calculation.
_uint160 oracleTickPrice = TickMath.getSqrtRatioAtTick(_tick); amount0 = uint(SqrtPriceMath.getAmount0Delta( oracleTickPrice, TickMath.getSqrtRatioAtTick(tickUpper), (int128)(liquidity) )); amount1 = uint(SqrtPriceMath.getAmount1Delta( TickMath.getSqrtRatioAtTick(tickLower), oracleTickPrice, (int128)(liquidity) ));
Handle
hickuphh3
Vulnerability details
Impact
In
getUserTokenAmount()
,TickMath.getSqrtRatioAtTick(_tick)
is called twice when the position is active (tickLower ≤_tick < tickUpper).Its value should be saved to avoid a repeat calculation.
Recommended Mitigation Steps