@@ -138,8 +138,9 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
138138 /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
139139 /// check
140140 function balance0 () private view returns (uint256 ) {
141- (bool success , bytes memory data ) =
142- token0.staticcall (abi.encodeWithSelector (IERC20Minimal .balanceOf.selector , address (this )));
141+ (bool success , bytes memory data ) = token0.staticcall (
142+ abi.encodeWithSelector (IERC20Minimal .balanceOf.selector , address (this ))
143+ );
143144 require (success && data.length >= 32 );
144145 return abi.decode (data, (uint256 ));
145146 }
@@ -148,8 +149,9 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
148149 /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
149150 /// check
150151 function balance1 () private view returns (uint256 ) {
151- (bool success , bytes memory data ) =
152- token1.staticcall (abi.encodeWithSelector (IERC20Minimal .balanceOf.selector , address (this )));
152+ (bool success , bytes memory data ) = token1.staticcall (
153+ abi.encodeWithSelector (IERC20Minimal .balanceOf.selector , address (this ))
154+ );
153155 require (success && data.length >= 32 );
154156 return abi.decode (data, (uint256 ));
155157 }
@@ -207,15 +209,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
207209 );
208210 } else if (_slot0.tick < tickUpper) {
209211 uint32 time = _blockTimestamp ();
210- (int56 tickCumulative , uint160 secondsPerLiquidityCumulativeX128 ) =
211- observations.observeSingle (
212- time,
213- 0 ,
214- _slot0.tick,
215- _slot0.observationIndex,
216- liquidity,
217- _slot0.observationCardinality
218- );
212+ (int56 tickCumulative , uint160 secondsPerLiquidityCumulativeX128 ) = observations.observeSingle (
213+ time,
214+ 0 ,
215+ _slot0.tick,
216+ _slot0.observationIndex,
217+ liquidity,
218+ _slot0.observationCardinality
219+ );
219220 return (
220221 tickCumulative - tickCumulativeLower - tickCumulativeUpper,
221222 secondsPerLiquidityCumulativeX128 -
@@ -259,8 +260,10 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
259260 noDelegateCall
260261 {
261262 uint16 observationCardinalityNextOld = slot0.observationCardinalityNext; // for the event
262- uint16 observationCardinalityNextNew =
263- observations.grow (observationCardinalityNextOld, observationCardinalityNext);
263+ uint16 observationCardinalityNextNew = observations.grow (
264+ observationCardinalityNextOld,
265+ observationCardinalityNext
266+ );
264267 slot0.observationCardinalityNext = observationCardinalityNextNew;
265268 if (observationCardinalityNextOld != observationCardinalityNextNew)
266269 emit IncreaseObservationCardinalityNext (observationCardinalityNextOld, observationCardinalityNextNew);
@@ -393,15 +396,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
393396 bool flippedUpper;
394397 if (liquidityDelta != 0 ) {
395398 uint32 time = _blockTimestamp ();
396- (int56 tickCumulative , uint160 secondsPerLiquidityCumulativeX128 ) =
397- observations.observeSingle (
398- time,
399- 0 ,
400- slot0.tick,
401- slot0.observationIndex,
402- liquidity,
403- slot0.observationCardinality
404- );
399+ (int56 tickCumulative , uint160 secondsPerLiquidityCumulativeX128 ) = observations.observeSingle (
400+ time,
401+ 0 ,
402+ slot0.tick,
403+ slot0.observationIndex,
404+ liquidity,
405+ slot0.observationCardinality
406+ );
405407
406408 flippedLower = ticks.update (
407409 tickLower,
@@ -436,8 +438,13 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
436438 }
437439 }
438440
439- (uint256 feeGrowthInside0X128 , uint256 feeGrowthInside1X128 ) =
440- ticks.getFeeGrowthInside (tickLower, tickUpper, tick, _feeGrowthGlobal0X128, _feeGrowthGlobal1X128);
441+ (uint256 feeGrowthInside0X128 , uint256 feeGrowthInside1X128 ) = ticks.getFeeGrowthInside (
442+ tickLower,
443+ tickUpper,
444+ tick,
445+ _feeGrowthGlobal0X128,
446+ _feeGrowthGlobal1X128
447+ );
441448
442449 position.update (liquidityDelta, feeGrowthInside0X128, feeGrowthInside1X128);
443450
@@ -462,15 +469,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
462469 bytes calldata data
463470 ) external override lock returns (uint256 amount0 , uint256 amount1 ) {
464471 require (amount > 0 );
465- (, int256 amount0Int , int256 amount1Int ) =
466- _modifyPosition (
467- ModifyPositionParams ({
468- owner: recipient,
469- tickLower: tickLower,
470- tickUpper: tickUpper,
471- liquidityDelta: int256 (amount).toInt128 ()
472- })
473- );
472+ (, int256 amount0Int , int256 amount1Int ) = _modifyPosition (
473+ ModifyPositionParams ({
474+ owner: recipient,
475+ tickLower: tickLower,
476+ tickUpper: tickUpper,
477+ liquidityDelta: int256 (amount).toInt128 ()
478+ })
479+ );
474480
475481 amount0 = uint256 (amount0Int);
476482 amount1 = uint256 (amount1Int);
@@ -519,15 +525,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
519525 int24 tickUpper ,
520526 uint128 amount
521527 ) external override lock returns (uint256 amount0 , uint256 amount1 ) {
522- (Position.Info storage position , int256 amount0Int , int256 amount1Int ) =
523- _modifyPosition (
524- ModifyPositionParams ({
525- owner: msg .sender ,
526- tickLower: tickLower,
527- tickUpper: tickUpper,
528- liquidityDelta: - int256 (amount).toInt128 ()
529- })
530- );
528+ (Position.Info storage position , int256 amount0Int , int256 amount1Int ) = _modifyPosition (
529+ ModifyPositionParams ({
530+ owner: msg .sender ,
531+ tickLower: tickLower,
532+ tickUpper: tickUpper,
533+ liquidityDelta: - int256 (amount).toInt128 ()
534+ })
535+ );
531536
532537 amount0 = uint256 (- amount0Int);
533538 amount1 = uint256 (- amount1Int);
@@ -614,28 +619,26 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
614619
615620 slot0.unlocked = false ;
616621
617- SwapCache memory cache =
618- SwapCache ({
619- liquidityStart: liquidity,
620- blockTimestamp: _blockTimestamp (),
621- feeProtocol: zeroForOne ? (slot0Start.feeProtocol % 16 ) : (slot0Start.feeProtocol >> 4 ),
622- secondsPerLiquidityCumulativeX128: 0 ,
623- tickCumulative: 0 ,
624- computedLatestObservation: false
625- });
622+ SwapCache memory cache = SwapCache ({
623+ liquidityStart: liquidity,
624+ blockTimestamp: _blockTimestamp (),
625+ feeProtocol: zeroForOne ? (slot0Start.feeProtocol % 16 ) : (slot0Start.feeProtocol >> 4 ),
626+ secondsPerLiquidityCumulativeX128: 0 ,
627+ tickCumulative: 0 ,
628+ computedLatestObservation: false
629+ });
626630
627631 bool exactInput = amountSpecified > 0 ;
628632
629- SwapState memory state =
630- SwapState ({
631- amountSpecifiedRemaining: amountSpecified,
632- amountCalculated: 0 ,
633- sqrtPriceX96: slot0Start.sqrtPriceX96,
634- tick: slot0Start.tick,
635- feeGrowthGlobalX128: zeroForOne ? feeGrowthGlobal0X128 : feeGrowthGlobal1X128,
636- protocolFee: 0 ,
637- liquidity: cache.liquidityStart
638- });
633+ SwapState memory state = SwapState ({
634+ amountSpecifiedRemaining: amountSpecified,
635+ amountCalculated: 0 ,
636+ sqrtPriceX96: slot0Start.sqrtPriceX96,
637+ tick: slot0Start.tick,
638+ feeGrowthGlobalX128: zeroForOne ? feeGrowthGlobal0X128 : feeGrowthGlobal1X128,
639+ protocolFee: 0 ,
640+ liquidity: cache.liquidityStart
641+ });
639642
640643 // continue swapping as long as we haven't used the entire input/output and haven't reached the price limit
641644 while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) {
@@ -706,15 +709,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
706709 );
707710 cache.computedLatestObservation = true ;
708711 }
709- int128 liquidityNet =
710- ticks.cross (
711- step.tickNext,
712- (zeroForOne ? state.feeGrowthGlobalX128 : feeGrowthGlobal0X128),
713- (zeroForOne ? feeGrowthGlobal1X128 : state.feeGrowthGlobalX128),
714- cache.secondsPerLiquidityCumulativeX128,
715- cache.tickCumulative,
716- cache.blockTimestamp
717- );
712+ int128 liquidityNet = ticks.cross (
713+ step.tickNext,
714+ (zeroForOne ? state.feeGrowthGlobalX128 : feeGrowthGlobal0X128),
715+ (zeroForOne ? feeGrowthGlobal1X128 : state.feeGrowthGlobalX128),
716+ cache.secondsPerLiquidityCumulativeX128,
717+ cache.tickCumulative,
718+ cache.blockTimestamp
719+ );
718720 // if we're moving leftward, we interpret liquidityNet as the opposite sign
719721 // safe because liquidityNet cannot be type(int128).min
720722 if (zeroForOne) liquidityNet = - liquidityNet;
@@ -731,15 +733,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
731733
732734 // update tick and write an oracle entry if the tick change
733735 if (state.tick != slot0Start.tick) {
734- (uint16 observationIndex , uint16 observationCardinality ) =
735- observations.write (
736- slot0Start.observationIndex,
737- cache.blockTimestamp,
738- slot0Start.tick,
739- cache.liquidityStart,
740- slot0Start.observationCardinality,
741- slot0Start.observationCardinalityNext
742- );
736+ (uint16 observationIndex , uint16 observationCardinality ) = observations.write (
737+ slot0Start.observationIndex,
738+ cache.blockTimestamp,
739+ slot0Start.tick,
740+ cache.liquidityStart,
741+ slot0Start.observationCardinality,
742+ slot0Start.observationCardinalityNext
743+ );
743744 (slot0.sqrtPriceX96, slot0.tick, slot0.observationIndex, slot0.observationCardinality) = (
744745 state.sqrtPriceX96,
745746 state.tick,
0 commit comments