Platform: Code4rena
Start Date: 23/09/2021
Pot Size: $50,000 USDC
Total HM: 5
Participants: 14
Period: 7 days
Judge: ghoulsol
Total Solo HM: 3
Id: 32
League: ETH
Rank: 10/14
Findings: 2
Award: $348.69
🌟 Selected for report: 3
🚀 Solo Findings: 0
🌟 Selected for report: hickuphh3
116.225 USDC - $116.23
hickuphh3
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.
_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) ));
🌟 Selected for report: hickuphh3
116.225 USDC - $116.23
hickuphh3
The following functions can have their visibilities restricted to pure:
getUserTokenAmount()
getSqrtPriceX96()
positionAmounts()
#0 - talegift
2021-10-01T14:41:18Z
Only getSqrtPriceX96
can be pure. The rest is reading the state.
🌟 Selected for report: hickuphh3
116.225 USDC - $116.23
hickuphh3
In getUserTokenAmount()
, I presume that the pool is initialized for testing / development purposes. However, it was not commented out / removed, and becomes unused in the function.
Redundant
IUniswapV3Pool pool = IUniswapV3Pool( PoolAddress.computeAddress( positionManager.factory(), PoolAddress.PoolKey({ token0: token0, token1: token1, fee: fee }) ) ); // (, int24 currentTick, , , , , ) = pool.slot0();
Remove or uncomment the lines mentioned above.