File tree Expand file tree Collapse file tree 1 file changed +25
-23
lines changed Expand file tree Collapse file tree 1 file changed +25
-23
lines changed Original file line number Diff line number Diff line change @@ -420,7 +420,7 @@ contract UniswapV3Pool is IUniswapV3Pool {
420
420
421
421
step.sqrtPriceStartX96 = state.sqrtPriceX96;
422
422
423
- (step.nextTick, ) = tickBitmap.nextInitializedTickWithinOneWord (
423
+ (step.nextTick, step.initialized ) = tickBitmap.nextInitializedTickWithinOneWord (
424
424
state.tick,
425
425
int24 (tickSpacing),
426
426
zeroForOne
@@ -459,28 +459,30 @@ contract UniswapV3Pool is IUniswapV3Pool {
459
459
}
460
460
461
461
if (state.sqrtPriceX96 == step.sqrtPriceNextX96) {
462
- int128 liquidityDelta = ticks.cross (
463
- step.nextTick,
464
- (
465
- zeroForOne
466
- ? state.feeGrowthGlobalX128
467
- : feeGrowthGlobal0X128
468
- ),
469
- (
470
- zeroForOne
471
- ? feeGrowthGlobal1X128
472
- : state.feeGrowthGlobalX128
473
- )
474
- );
475
-
476
- if (zeroForOne) liquidityDelta = - liquidityDelta;
477
-
478
- state.liquidity = LiquidityMath.addLiquidity (
479
- state.liquidity,
480
- liquidityDelta
481
- );
482
-
483
- if (state.liquidity == 0 ) revert NotEnoughLiquidity ();
462
+ if (step.initialized) {
463
+ int128 liquidityDelta = ticks.cross (
464
+ step.nextTick,
465
+ (
466
+ zeroForOne
467
+ ? state.feeGrowthGlobalX128
468
+ : feeGrowthGlobal0X128
469
+ ),
470
+ (
471
+ zeroForOne
472
+ ? feeGrowthGlobal1X128
473
+ : state.feeGrowthGlobalX128
474
+ )
475
+ );
476
+
477
+ if (zeroForOne) liquidityDelta = - liquidityDelta;
478
+
479
+ state.liquidity = LiquidityMath.addLiquidity (
480
+ state.liquidity,
481
+ liquidityDelta
482
+ );
483
+
484
+ if (state.liquidity == 0 ) revert NotEnoughLiquidity ();
485
+ }
484
486
485
487
state.tick = zeroForOne ? step.nextTick - 1 : step.nextTick;
486
488
} else if (state.sqrtPriceX96 != step.sqrtPriceStartX96) {
You can’t perform that action at this time.
0 commit comments