diff --git a/src/MixedQuoter.sol b/src/MixedQuoter.sol index 98fb971..39b8d63 100644 --- a/src/MixedQuoter.sol +++ b/src/MixedQuoter.sol @@ -65,11 +65,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { */ /// @inheritdoc IPancakeV3SwapCallback - function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes memory data) - external - view - override - { + function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes memory data) external view override { require(amount0Delta > 0 || amount1Delta > 0); // swaps entirely within 0-liquidity regions are not supported (address tokenIn, address tokenOut, uint24 fee) = abi.decode(data, (address, address, uint24)); V3SmartRouterHelper.verifyCallback(factoryV3, tokenIn, tokenOut, fee); @@ -144,7 +140,8 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1) : params.sqrtPriceLimitX96, abi.encode(params.tokenIn, params.tokenOut, params.fee) - ) {} catch (bytes memory reason) { + ) {} + catch (bytes memory reason) { gasEstimate = gasBefore - gasleft(); return handleV3Revert(reason, pool, gasEstimate); } @@ -273,11 +270,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { if (!withContext) { (amountIn,,, gasEstimateForCurAction) = quoteExactInputSingleV3( QuoteExactInputSingleV3Params({ - tokenIn: tokenIn, - tokenOut: tokenOut, - amountIn: amountIn, - fee: fee, - sqrtPriceLimitX96: 0 + tokenIn: tokenIn, tokenOut: tokenOut, amountIn: amountIn, fee: fee, sqrtPriceLimitX96: 0 }) ); } else { @@ -292,11 +285,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { amountIn += accAmountIn; (swapAmountOut,,, gasEstimateForCurAction) = quoteExactInputSingleV3( QuoteExactInputSingleV3Params({ - tokenIn: tokenIn, - tokenOut: tokenOut, - amountIn: amountIn, - fee: fee, - sqrtPriceLimitX96: 0 + tokenIn: tokenIn, tokenOut: tokenOut, amountIn: amountIn, fee: fee, sqrtPriceLimitX96: 0 }) ); MixedQuoterRecorder.setPoolSwapTokenAccumulation(poolHash, amountIn, swapAmountOut, zeroForOne); @@ -383,10 +372,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { if (!withContext) { (amountIn, gasEstimateForCurAction) = quoteExactInputSingleStable( QuoteExactInputSingleStableParams({ - tokenIn: tokenIn, - tokenOut: tokenOut, - amountIn: amountIn, - flag: 2 + tokenIn: tokenIn, tokenOut: tokenOut, amountIn: amountIn, flag: 2 }) ); } else { @@ -400,10 +386,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { amountIn += accAmountIn; (swapAmountOut, gasEstimateForCurAction) = quoteExactInputSingleStable( QuoteExactInputSingleStableParams({ - tokenIn: tokenIn, - tokenOut: tokenOut, - amountIn: amountIn, - flag: 2 + tokenIn: tokenIn, tokenOut: tokenOut, amountIn: amountIn, flag: 2 }) ); MixedQuoterRecorder.setPoolSwapTokenAccumulation(poolHash, amountIn, swapAmountOut, zeroForOne); @@ -415,10 +398,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { // params[actionIndex] is zero bytes (amountIn, gasEstimateForCurAction) = quoteExactInputSingleStable( QuoteExactInputSingleStableParams({ - tokenIn: tokenIn, - tokenOut: tokenOut, - amountIn: amountIn, - flag: 3 + tokenIn: tokenIn, tokenOut: tokenOut, amountIn: amountIn, flag: 3 }) ); } else { diff --git a/src/interfaces/IERC721Permit.sol b/src/interfaces/IERC721Permit.sol index c190b1c..96b65bf 100644 --- a/src/interfaces/IERC721Permit.sol +++ b/src/interfaces/IERC721Permit.sol @@ -21,7 +21,5 @@ interface IERC721Permit is IERC721 { /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` - function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) - external - payable; + function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable; } diff --git a/src/interfaces/ISelfPermit.sol b/src/interfaces/ISelfPermit.sol index 301904a..1681194 100644 --- a/src/interfaces/ISelfPermit.sol +++ b/src/interfaces/ISelfPermit.sol @@ -12,9 +12,7 @@ interface ISelfPermit { /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` - function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) - external - payable; + function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable; /// @notice Permits this contract to spend a given token from `msg.sender` /// @dev The `owner` is always msg.sender and the `spender` is always address(this). diff --git a/src/libraries/CalldataDecoder.sol b/src/libraries/CalldataDecoder.sol index 32f0666..65b749b 100644 --- a/src/libraries/CalldataDecoder.sol +++ b/src/libraries/CalldataDecoder.sol @@ -143,11 +143,7 @@ library CalldataDecoder { } /// @dev equivalent to: abi.decode(params, (Currency, uint256)) in calldata - function decodeCurrencyAndUint256(bytes calldata params) - internal - pure - returns (Currency currency, uint256 amount) - { + function decodeCurrencyAndUint256(bytes calldata params) internal pure returns (Currency currency, uint256 amount) { assembly ("memory-safe") { if lt(params.length, 0x40) { mstore(0, SLICE_ERROR_SELECTOR) diff --git a/src/libraries/external/V3SmartRouterHelper.sol b/src/libraries/external/V3SmartRouterHelper.sol index 484986f..2224025 100644 --- a/src/libraries/external/V3SmartRouterHelper.sol +++ b/src/libraries/external/V3SmartRouterHelper.sol @@ -12,7 +12,6 @@ library V3SmartRouterHelper { /** * Stable ************************************************* */ - // get the pool info in stable swap function getStableInfo(address stableSwapFactory, address input, address output, uint256 flag) internal diff --git a/src/pool-bin/interfaces/IBinQuoter.sol b/src/pool-bin/interfaces/IBinQuoter.sol index 302dcb1..b00456e 100644 --- a/src/pool-bin/interfaces/IBinQuoter.sol +++ b/src/pool-bin/interfaces/IBinQuoter.sol @@ -40,9 +40,7 @@ interface IBinQuoter is IQuoter { /// exactAmount The desired input amount /// @return amountOut The output quote for the exactIn swap /// @return gasEstimate Estimated gas units used for the swap - function quoteExactInput(QuoteExactParams memory params) - external - returns (uint256 amountOut, uint256 gasEstimate); + function quoteExactInput(QuoteExactParams memory params) external returns (uint256 amountOut, uint256 gasEstimate); /// @notice Returns the delta amounts for a given exact output swap of a single pool /// @param params The params for the quote, encoded as `QuoteExactSingleParams` @@ -63,7 +61,5 @@ interface IBinQuoter is IQuoter { /// exactAmount The desired output amount /// @return amountIn The input quote for the exactOut swap /// @return gasEstimate Estimated gas units used for the swap - function quoteExactOutput(QuoteExactParams memory params) - external - returns (uint256 amountIn, uint256 gasEstimate); + function quoteExactOutput(QuoteExactParams memory params) external returns (uint256 amountIn, uint256 gasEstimate); } diff --git a/src/pool-cl/CLPositionManager.sol b/src/pool-cl/CLPositionManager.sol index 843f396..f564032 100644 --- a/src/pool-cl/CLPositionManager.sol +++ b/src/pool-cl/CLPositionManager.sol @@ -452,10 +452,7 @@ contract CLPositionManager is (liquidityDelta, feesAccrued) = clPoolManager.modifyLiquidity( poolKey, ICLPoolManager.ModifyLiquidityParams({ - tickLower: info.tickLower(), - tickUpper: info.tickUpper(), - liquidityDelta: liquidityChange, - salt: salt + tickLower: info.tickLower(), tickUpper: info.tickUpper(), liquidityDelta: liquidityChange, salt: salt }), hookData ); @@ -494,11 +491,7 @@ contract CLPositionManager is } /// @inheritdoc ICLPositionManager - function getPoolAndPositionInfo(uint256 tokenId) - public - view - returns (PoolKey memory poolKey, CLPositionInfo info) - { + function getPoolAndPositionInfo(uint256 tokenId) public view returns (PoolKey memory poolKey, CLPositionInfo info) { info = positionInfo[tokenId]; poolKey = poolKeys[info.poolId()]; } diff --git a/src/pool-cl/CLRouterBase.sol b/src/pool-cl/CLRouterBase.sol index ed51ded..031eec3 100644 --- a/src/pool-cl/CLRouterBase.sol +++ b/src/pool-cl/CLRouterBase.sol @@ -30,8 +30,8 @@ abstract contract CLRouterBase is ICLRouterBase, DeltaResolver { _getFullCredit(params.zeroForOne ? params.poolKey.currency0 : params.poolKey.currency1).toUint128(); } uint128 amountOut = _swapExactPrivate( - params.poolKey, params.zeroForOne, -int256(uint256(amountIn)), params.hookData - ).toUint128(); + params.poolKey, params.zeroForOne, -int256(uint256(amountIn)), params.hookData + ).toUint128(); if (amountOut < params.amountOutMinimum) { revert IInfinityRouter.TooLittleReceived(params.amountOutMinimum, amountOut); } @@ -70,9 +70,10 @@ abstract contract CLRouterBase is ICLRouterBase, DeltaResolver { amountOut = _getFullDebt(params.zeroForOne ? params.poolKey.currency1 : params.poolKey.currency0).toUint128(); } - uint128 amountIn = ( - -_swapExactPrivate(params.poolKey, params.zeroForOne, int256(uint256(amountOut)), params.hookData) - ).toUint128(); + uint128 amountIn = (-_swapExactPrivate( + params.poolKey, params.zeroForOne, int256(uint256(amountOut)), params.hookData + )) + .toUint128(); if (amountIn > params.amountInMaximum) { revert IInfinityRouter.TooMuchRequested(params.amountInMaximum, amountIn); } @@ -95,11 +96,10 @@ abstract contract CLRouterBase is ICLRouterBase, DeltaResolver { pathKey = params.path[i - 1]; (PoolKey memory poolKey, bool oneForZero) = pathKey.getPoolAndSwapDirection(currencyOut); // The output delta will always be negative, except for when interacting with certain hook pools - amountIn = ( - uint256( + amountIn = (uint256( -int256(_swapExactPrivate(poolKey, !oneForZero, int256(uint256(amountOut)), pathKey.hookData)) - ) - ).toUint128(); + )) + .toUint128(); amountOut = amountIn; currencyOut = pathKey.intermediateCurrency; diff --git a/src/pool-cl/base/CLNotifier.sol b/src/pool-cl/base/CLNotifier.sol index 3963f53..2efde7a 100644 --- a/src/pool-cl/base/CLNotifier.sol +++ b/src/pool-cl/base/CLNotifier.sol @@ -95,8 +95,9 @@ abstract contract CLNotifier is ICLNotifier { // remove the subscriber delete subscriber[tokenId]; - bool success = - _call(_subscriber, abi.encodeCall(ICLSubscriber.notifyBurn, (tokenId, owner, info, liquidity, feesAccrued))); + bool success = _call( + _subscriber, abi.encodeCall(ICLSubscriber.notifyBurn, (tokenId, owner, info, liquidity, feesAccrued)) + ); if (!success) { _subscriber.bubbleUpAndRevertWith(ICLSubscriber.notifyBurn.selector, BurnNotificationReverted.selector); diff --git a/src/pool-cl/base/ERC721Permit.sol b/src/pool-cl/base/ERC721Permit.sol index 8ff7194..590f819 100644 --- a/src/pool-cl/base/ERC721Permit.sol +++ b/src/pool-cl/base/ERC721Permit.sol @@ -93,7 +93,8 @@ abstract contract ERC721Permit is ERC721, IERC721Permit, EIP712, UnorderedNonce } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { - return spender == ownerOf(tokenId) || getApproved[tokenId] == spender - || isApprovedForAll[ownerOf(tokenId)][spender]; + return + spender == ownerOf(tokenId) || getApproved[tokenId] == spender + || isApprovedForAll[ownerOf(tokenId)][spender]; } } diff --git a/src/pool-cl/interfaces/ICLQuoter.sol b/src/pool-cl/interfaces/ICLQuoter.sol index 5549627..5044fd0 100644 --- a/src/pool-cl/interfaces/ICLQuoter.sol +++ b/src/pool-cl/interfaces/ICLQuoter.sol @@ -40,9 +40,7 @@ interface ICLQuoter is IQuoter { /// exactAmount The desired input amount /// @return amountOut The output quote for the exactIn swap /// @return gasEstimate Estimated gas units used for the swap - function quoteExactInput(QuoteExactParams memory params) - external - returns (uint256 amountOut, uint256 gasEstimate); + function quoteExactInput(QuoteExactParams memory params) external returns (uint256 amountOut, uint256 gasEstimate); /// @notice Returns the delta amounts for a given exact output swap of a single pool /// @param params The params for the quote, encoded as `QuoteExactSingleParams` @@ -63,7 +61,5 @@ interface ICLQuoter is IQuoter { /// exactAmount The desired output amount /// @return amountIn The input quote for the exactOut swap /// @return gasEstimate Estimated gas units used for the swap - function quoteExactOutput(QuoteExactParams memory params) - external - returns (uint256 amountIn, uint256 gasEstimate); + function quoteExactOutput(QuoteExactParams memory params) external returns (uint256 amountIn, uint256 gasEstimate); } diff --git a/src/pool-cl/lens/CLQuoter.sol b/src/pool-cl/lens/CLQuoter.sol index 35bddb7..769a2f7 100644 --- a/src/pool-cl/lens/CLQuoter.sol +++ b/src/pool-cl/lens/CLQuoter.sol @@ -52,10 +52,7 @@ contract CLQuoter is ICLQuoter, BaseInfinityQuoter { } /// @inheritdoc ICLQuoter - function quoteExactInput(QuoteExactParams memory params) - external - returns (uint256 amountOut, uint256 gasEstimate) - { + function quoteExactInput(QuoteExactParams memory params) external returns (uint256 amountOut, uint256 gasEstimate) { uint256 gasBefore = gasleft(); try vault.lock(abi.encodeCall(this._quoteExactInput, (params))) {} catch (bytes memory reason) { @@ -80,10 +77,7 @@ contract CLQuoter is ICLQuoter, BaseInfinityQuoter { } /// @inheritdoc ICLQuoter - function quoteExactOutput(QuoteExactParams memory params) - external - returns (uint256 amountIn, uint256 gasEstimate) - { + function quoteExactOutput(QuoteExactParams memory params) external returns (uint256 amountIn, uint256 gasEstimate) { uint256 gasBefore = gasleft(); try vault.lock(abi.encodeCall(this._quoteExactOutput, (params))) {} catch (bytes memory reason) { diff --git a/src/pool-cl/lens/TickLens.sol b/src/pool-cl/lens/TickLens.sol index 2ea774a..334a30b 100644 --- a/src/pool-cl/lens/TickLens.sol +++ b/src/pool-cl/lens/TickLens.sol @@ -59,9 +59,7 @@ contract TickLens is ITickLens { int24 populatedTick = ((int24(tickBitmapIndex) << 8) + int24(int256(i))) * tickSpacing; Tick.Info memory tickInfo = poolManager.getPoolTickInfo(id, populatedTick); populatedTicks[--numberOfPopulatedTicks] = PopulatedTick({ - tick: populatedTick, - liquidityNet: tickInfo.liquidityNet, - liquidityGross: tickInfo.liquidityGross + tick: populatedTick, liquidityNet: tickInfo.liquidityNet, liquidityGross: tickInfo.liquidityGross }); } } diff --git a/src/pool-cl/libraries/CLPositionInfoLibrary.sol b/src/pool-cl/libraries/CLPositionInfoLibrary.sol index fe82a8a..4c30272 100644 --- a/src/pool-cl/libraries/CLPositionInfoLibrary.sol +++ b/src/pool-cl/libraries/CLPositionInfoLibrary.sol @@ -96,11 +96,10 @@ library CLPositionInfoLibrary { { bytes25 _poolId = bytes25(PoolId.unwrap(_poolKey.toId())); assembly { - info := - or( - or(and(MASK_UPPER_200_BITS, _poolId), shl(TICK_UPPER_OFFSET, and(MASK_24_BITS, _tickUpper))), - shl(TICK_LOWER_OFFSET, and(MASK_24_BITS, _tickLower)) - ) + info := or( + or(and(MASK_UPPER_200_BITS, _poolId), shl(TICK_UPPER_OFFSET, and(MASK_24_BITS, _tickUpper))), + shl(TICK_LOWER_OFFSET, and(MASK_24_BITS, _tickLower)) + ) } } } diff --git a/src/pool-cl/libraries/LiquidityAmounts.sol b/src/pool-cl/libraries/LiquidityAmounts.sol index 3b561c3..b0bccf6 100644 --- a/src/pool-cl/libraries/LiquidityAmounts.sol +++ b/src/pool-cl/libraries/LiquidityAmounts.sol @@ -56,7 +56,9 @@ library LiquidityAmounts { uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { - if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); + if (sqrtRatioAX96 > sqrtRatioBX96) { + (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); + } if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); @@ -116,7 +118,9 @@ library LiquidityAmounts { uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { - if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); + if (sqrtRatioAX96 > sqrtRatioBX96) { + (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); + } if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); diff --git a/test/MixedQuoter.t.sol b/test/MixedQuoter.t.sol index 371e4ec..9721039 100644 --- a/test/MixedQuoter.t.sol +++ b/test/MixedQuoter.t.sol @@ -846,10 +846,7 @@ contract MixedQuoterTest is (uint256 _amountOut, uint256 _gasEstimate) = clQuoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: poolKey, - zeroForOne: true, - exactAmount: 1 ether, - hookData: ZERO_BYTES + poolKey: poolKey, zeroForOne: true, exactAmount: 1 ether, hookData: ZERO_BYTES }) ); assertEq(_amountOut, amountOut); @@ -1036,10 +1033,7 @@ contract MixedQuoterTest is (uint256 _amountOut, uint256 _gasEstimate) = clQuoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: poolKey, - zeroForOne: false, - exactAmount: 1 ether, - hookData: ZERO_BYTES + poolKey: poolKey, zeroForOne: false, exactAmount: 1 ether, hookData: ZERO_BYTES }) ); assertEq(_amountOut, amountOut); @@ -1072,10 +1066,7 @@ contract MixedQuoterTest is (uint256 _amountOut, uint256 _gasEstimate) = clQuoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: poolKeyWithWETH, - zeroForOne: true, - exactAmount: 1 ether, - hookData: ZERO_BYTES + poolKey: poolKeyWithWETH, zeroForOne: true, exactAmount: 1 ether, hookData: ZERO_BYTES }) ); assertEq(_amountOut, amountOut); @@ -1102,10 +1093,7 @@ contract MixedQuoterTest is (uint256 _amountOut, uint256 _gasEstimate) = binQuoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: binPoolKey, - zeroForOne: true, - exactAmount: 1 ether, - hookData: ZERO_BYTES + poolKey: binPoolKey, zeroForOne: true, exactAmount: 1 ether, hookData: ZERO_BYTES }) ); assertEq(_amountOut, amountOut); @@ -1285,10 +1273,7 @@ contract MixedQuoterTest is (uint256 _amountOut, uint256 _gasEstimate) = binQuoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: binPoolKey, - zeroForOne: false, - exactAmount: 1 ether, - hookData: ZERO_BYTES + poolKey: binPoolKey, zeroForOne: false, exactAmount: 1 ether, hookData: ZERO_BYTES }) ); assertEq(_amountOut, amountOut); diff --git a/test/Multicall.t.sol b/test/Multicall.t.sol index 8591c27..c2b8ae8 100644 --- a/test/Multicall.t.sol +++ b/test/Multicall.t.sol @@ -29,8 +29,9 @@ contract MulticallTest is Test { function test_multicall_firstRevert() public { bytes[] memory calls = new bytes[](2); - calls[0] = - abi.encodeWithSelector(MockMulticall(multicall).functionThatRevertsWithString.selector, "First call failed"); + calls[0] = abi.encodeWithSelector( + MockMulticall(multicall).functionThatRevertsWithString.selector, "First call failed" + ); calls[1] = abi.encodeWithSelector(MockMulticall(multicall).functionThatReturnsTuple.selector, 1, 2); vm.expectRevert("First call failed"); diff --git a/test/helpers/DeployStableSwapHelper.sol b/test/helpers/DeployStableSwapHelper.sol index 84e58dd..7be27bc 100644 --- a/test/helpers/DeployStableSwapHelper.sol +++ b/test/helpers/DeployStableSwapHelper.sol @@ -41,8 +41,12 @@ contract DeployStableSwapHelper is Script { address pancakeStableSwapLPFactory; bytes32 salt = keccak256(abi.encodePacked(msg.sender, block.timestamp)); assembly ("memory-safe") { - pancakeStableSwapLPFactory := - create2(0, add(pancakeStableSwapLPFactoryBytecode, 32), mload(pancakeStableSwapLPFactoryBytecode), salt) + pancakeStableSwapLPFactory := create2( + 0, + add(pancakeStableSwapLPFactoryBytecode, 32), + mload(pancakeStableSwapLPFactoryBytecode), + salt + ) } return pancakeStableSwapLPFactory; @@ -55,13 +59,12 @@ contract DeployStableSwapHelper is Script { address pancakeStableSwapTwoPoolDeployer; bytes32 salt = keccak256(abi.encodePacked(msg.sender, block.timestamp)); assembly ("memory-safe") { - pancakeStableSwapTwoPoolDeployer := - create2( - 0, - add(pancakeStableSwapTwoPoolDeployerBytecode, 32), - mload(pancakeStableSwapTwoPoolDeployerBytecode), - salt - ) + pancakeStableSwapTwoPoolDeployer := create2( + 0, + add(pancakeStableSwapTwoPoolDeployerBytecode, 32), + mload(pancakeStableSwapTwoPoolDeployerBytecode), + salt + ) } return pancakeStableSwapTwoPoolDeployer; @@ -74,13 +77,12 @@ contract DeployStableSwapHelper is Script { address pancakeStableSwapThreePoolDeployer; bytes32 salt = keccak256(abi.encodePacked(msg.sender, block.timestamp)); assembly ("memory-safe") { - pancakeStableSwapThreePoolDeployer := - create2( - 0, - add(pancakeStableSwapThreePoolDeployerBytecode, 32), - mload(pancakeStableSwapThreePoolDeployerBytecode), - salt - ) + pancakeStableSwapThreePoolDeployer := create2( + 0, + add(pancakeStableSwapThreePoolDeployerBytecode, 32), + mload(pancakeStableSwapThreePoolDeployerBytecode), + salt + ) } return pancakeStableSwapThreePoolDeployer; diff --git a/test/helpers/PancakeV3Router.sol b/test/helpers/PancakeV3Router.sol index 411d704..bb1fea6 100644 --- a/test/helpers/PancakeV3Router.sol +++ b/test/helpers/PancakeV3Router.sol @@ -68,15 +68,16 @@ contract PancakeV3Router { bool zeroForOne = tokenIn < tokenOut; - (int256 amount0, int256 amount1) = getPool(tokenIn, tokenOut, fee).swap( - recipient, - zeroForOne, - int256(amountIn), - sqrtPriceLimitX96 == 0 - ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1) - : sqrtPriceLimitX96, - data - ); + (int256 amount0, int256 amount1) = getPool(tokenIn, tokenOut, fee) + .swap( + recipient, + zeroForOne, + int256(amountIn), + sqrtPriceLimitX96 == 0 + ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1) + : sqrtPriceLimitX96, + data + ); return uint256(-(zeroForOne ? amount1 : amount0)); } diff --git a/test/libraries/CalldataDecoder.t.sol b/test/libraries/CalldataDecoder.t.sol index a589bd4..09ad08f 100644 --- a/test/libraries/CalldataDecoder.t.sol +++ b/test/libraries/CalldataDecoder.t.sol @@ -142,10 +142,7 @@ contract CalldataDecoderTest is Test { decoder.decodeCurrencyPairAndAddress(invalidParams); } - function test_fuzz_decodeCurrencyAddressAndUint256(Currency _currency, address _addr, uint256 _amount) - public - view - { + function test_fuzz_decodeCurrencyAddressAndUint256(Currency _currency, address _addr, uint256 _amount) public view { bytes memory params = abi.encode(_currency, _addr, _amount); (Currency currency, address addr, uint256 amount) = decoder.decodeCurrencyAddressAndUint256(params); diff --git a/test/mocks/MockBaseActionsRouter.sol b/test/mocks/MockBaseActionsRouter.sol index 2761c11..fa83baf 100644 --- a/test/mocks/MockBaseActionsRouter.sol +++ b/test/mocks/MockBaseActionsRouter.sol @@ -58,55 +58,107 @@ contract MockBaseActionsRouter is BaseActionsRouter { return address(0xdeadbeef); } - function _clSwap(bytes calldata /* params **/ ) internal { + function _clSwap( + bytes calldata /* params **/ + ) + internal + { clSwapCount++; } - function _binSwap(bytes calldata /* params **/ ) internal { + function _binSwap( + bytes calldata /* params **/ + ) + internal + { binSwapCount++; } - function _clIncreaseLiquidity(bytes calldata /* params **/ ) internal { + function _clIncreaseLiquidity( + bytes calldata /* params **/ + ) + internal + { clIncreaseLiqCount++; } - function _binAddLiquidity(bytes calldata /* params **/ ) internal { + function _binAddLiquidity( + bytes calldata /* params **/ + ) + internal + { binAddLiqCount++; } - function _clDecreaseLiquidity(bytes calldata /* params **/ ) internal { + function _clDecreaseLiquidity( + bytes calldata /* params **/ + ) + internal + { clDecreaseLiqCount++; } - function _binRemoveLiquidity(bytes calldata /* params **/ ) internal { + function _binRemoveLiquidity( + bytes calldata /* params **/ + ) + internal + { binRemoveLiqCount++; } - function _clDonate(bytes calldata /* params **/ ) internal { + function _clDonate( + bytes calldata /* params **/ + ) + internal + { clDonateCount++; } - function _binDonate(bytes calldata /* params **/ ) internal { + function _binDonate( + bytes calldata /* params **/ + ) + internal + { binDonateCount++; } - function _settle(bytes calldata /* params **/ ) internal { + function _settle( + bytes calldata /* params **/ + ) + internal + { settleCount++; } - function _take(bytes calldata /* params **/ ) internal { + function _take( + bytes calldata /* params **/ + ) + internal + { takeCount++; } - function _mint6909(bytes calldata /* params **/ ) internal { + function _mint6909( + bytes calldata /* params **/ + ) + internal + { mintCount++; } - function _burn6909(bytes calldata /* params **/ ) internal { + function _burn6909( + bytes calldata /* params **/ + ) + internal + { burnCount++; } - function _clear(bytes calldata /* params **/ ) internal { + function _clear( + bytes calldata /* params **/ + ) + internal + { clearCount++; } diff --git a/test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol b/test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol index 15181c7..ff51139 100644 --- a/test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol +++ b/test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol @@ -880,9 +880,7 @@ contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, TokenFixt ); } - function _test_transferLiquidityToken_revertIfVaultLocked(uint256[] memory ids, uint256[] memory amounts) - external - { + function _test_transferLiquidityToken_revertIfVaultLocked(uint256[] memory ids, uint256[] memory amounts) external { vm.expectRevert(IPositionManager.VaultMustBeUnlocked.selector); binPm.batchTransferFrom(address(this), makeAddr("someone"), ids, amounts); } @@ -909,19 +907,19 @@ contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, TokenFixt fotKey, binIds, uint128(amountAfterTransfer), uint128(amountAfterTransfer), activeId, address(this) ); - IBinPositionManager.BinAddLiquidityFromDeltasParams memory param = IBinPositionManager - .BinAddLiquidityFromDeltasParams({ - poolKey: _param.poolKey, - amount0Max: _param.amount0Max, - amount1Max: _param.amount1Max, - activeIdDesired: _param.activeIdDesired, - idSlippage: _param.idSlippage, - deltaIds: _param.deltaIds, - distributionX: _param.distributionX, - distributionY: _param.distributionY, - to: _param.to, - hookData: _param.hookData - }); + IBinPositionManager.BinAddLiquidityFromDeltasParams memory param = + IBinPositionManager.BinAddLiquidityFromDeltasParams({ + poolKey: _param.poolKey, + amount0Max: _param.amount0Max, + amount1Max: _param.amount1Max, + activeIdDesired: _param.activeIdDesired, + idSlippage: _param.idSlippage, + deltaIds: _param.deltaIds, + distributionX: _param.distributionX, + distributionY: _param.distributionY, + to: _param.to, + hookData: _param.hookData + }); planner.add(Actions.BIN_ADD_LIQUIDITY_FROM_DELTAS, abi.encode(param)); bytes memory plan = planner.encode(); @@ -958,19 +956,19 @@ contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, TokenFixt IBinPositionManager.BinAddLiquidityParams memory _param = _getAddParams(key1, binIds, uint128(amountToSend), uint128(amountToSend), activeId, address(this)); - IBinPositionManager.BinAddLiquidityFromDeltasParams memory param = IBinPositionManager - .BinAddLiquidityFromDeltasParams({ - poolKey: _param.poolKey, - amount0Max: _param.amount0Max, - amount1Max: _param.amount1Max, - activeIdDesired: _param.activeIdDesired, - idSlippage: _param.idSlippage, - deltaIds: _param.deltaIds, - distributionX: _param.distributionX, - distributionY: _param.distributionY, - to: _param.to, - hookData: _param.hookData - }); + IBinPositionManager.BinAddLiquidityFromDeltasParams memory param = + IBinPositionManager.BinAddLiquidityFromDeltasParams({ + poolKey: _param.poolKey, + amount0Max: _param.amount0Max, + amount1Max: _param.amount1Max, + activeIdDesired: _param.activeIdDesired, + idSlippage: _param.idSlippage, + deltaIds: _param.deltaIds, + distributionX: _param.distributionX, + distributionY: _param.distributionY, + to: _param.to, + hookData: _param.hookData + }); planner.add(Actions.BIN_ADD_LIQUIDITY_FROM_DELTAS, abi.encode(param)); bytes memory plan = planner.encode(); @@ -1025,19 +1023,19 @@ contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, TokenFixt IBinPositionManager.BinAddLiquidityParams memory _param = _getAddParams( fotKey, binIds, uint128(amount0AfterTransfer), uint128(amount1AfterTransfer), activeId, address(this) ); - IBinPositionManager.BinAddLiquidityFromDeltasParams memory param = IBinPositionManager - .BinAddLiquidityFromDeltasParams({ - poolKey: _param.poolKey, - amount0Max: _param.amount0Max, - amount1Max: _param.amount1Max, - activeIdDesired: _param.activeIdDesired, - idSlippage: _param.idSlippage, - deltaIds: _param.deltaIds, - distributionX: _param.distributionX, - distributionY: _param.distributionY, - to: _param.to, - hookData: _param.hookData - }); + IBinPositionManager.BinAddLiquidityFromDeltasParams memory param = + IBinPositionManager.BinAddLiquidityFromDeltasParams({ + poolKey: _param.poolKey, + amount0Max: _param.amount0Max, + amount1Max: _param.amount1Max, + activeIdDesired: _param.activeIdDesired, + idSlippage: _param.idSlippage, + deltaIds: _param.deltaIds, + distributionX: _param.distributionX, + distributionY: _param.distributionY, + to: _param.to, + hookData: _param.hookData + }); planner.add(Actions.BIN_ADD_LIQUIDITY_FROM_DELTAS, abi.encode(param)); bytes memory plan = planner.encode(); diff --git a/test/pool-bin/BinPositionManager_MultiCall.t.sol b/test/pool-bin/BinPositionManager_MultiCall.t.sol index 8b0b9c2..0b845ed 100644 --- a/test/pool-bin/BinPositionManager_MultiCall.t.sol +++ b/test/pool-bin/BinPositionManager_MultiCall.t.sol @@ -32,12 +32,7 @@ import {BaseActionsRouter} from "../../src/base/BaseActionsRouter.sol"; import {Permit2SignatureHelpers} from "../shared/Permit2SignatureHelpers.sol"; import {IWETH9} from "../../src/interfaces/external/IWETH9.sol"; -contract BinPositionManager_MultiCallTest is - Permit2SignatureHelpers, - BinLiquidityHelper, - TokenFixture, - DeployPermit2 -{ +contract BinPositionManager_MultiCallTest is Permit2SignatureHelpers, BinLiquidityHelper, TokenFixture, DeployPermit2 { using BinPoolParametersHelper for bytes32; using SafeCast for uint256; using BinTokenLibrary for PoolId; diff --git a/test/pool-bin/BinQuoter.t.sol b/test/pool-bin/BinQuoter.t.sol index 43c8616..57378f5 100644 --- a/test/pool-bin/BinQuoter.t.sol +++ b/test/pool-bin/BinQuoter.t.sol @@ -166,10 +166,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountOut, uint256 _gasEstimate) = quoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key3, - zeroForOne: true, - exactAmount: 1 ether, - hookData: new bytes(0) + poolKey: key3, zeroForOne: true, exactAmount: 1 ether, hookData: new bytes(0) }) ); @@ -211,10 +208,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountOut, uint256 _gasEstimate) = quoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key3, - zeroForOne: false, - exactAmount: 1 ether, - hookData: new bytes(0) + poolKey: key3, zeroForOne: false, exactAmount: 1 ether, hookData: new bytes(0) }) ); @@ -273,9 +267,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountOut, uint256 _gasEstimate) = quoter.quoteExactInput( IQuoter.QuoteExactParams({ - exactCurrency: Currency.wrap(address(token0)), - path: quoter_path, - exactAmount: 1 ether + exactCurrency: Currency.wrap(address(token0)), path: quoter_path, exactAmount: 1 ether }) ); @@ -349,9 +341,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountOut, uint256 _gasEstimate) = quoter.quoteExactInput( IQuoter.QuoteExactParams({ - exactCurrency: Currency.wrap(address(token0)), - path: quoter_path, - exactAmount: 1 ether + exactCurrency: Currency.wrap(address(token0)), path: quoter_path, exactAmount: 1 ether }) ); @@ -389,10 +379,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountIn, uint256 _gasEstimate) = quoter.quoteExactOutputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key, - zeroForOne: true, - exactAmount: 0.5 ether, - hookData: new bytes(0) + poolKey: key, zeroForOne: true, exactAmount: 0.5 ether, hookData: new bytes(0) }) ); @@ -433,10 +420,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountIn, uint256 _gasEstimate) = quoter.quoteExactOutputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key, - zeroForOne: false, - exactAmount: 0.5 ether, - hookData: new bytes(0) + poolKey: key, zeroForOne: false, exactAmount: 0.5 ether, hookData: new bytes(0) }) ); @@ -502,9 +486,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountIn, uint256 _gasEstimate) = quoter.quoteExactOutput( IQuoter.QuoteExactParams({ - exactCurrency: Currency.wrap(address(token1)), - path: quoter_path, - exactAmount: 0.5 ether + exactCurrency: Currency.wrap(address(token1)), path: quoter_path, exactAmount: 0.5 ether }) ); @@ -583,9 +565,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { (uint256 _amountIn, uint256 _gasEstimate) = quoter.quoteExactOutput( IQuoter.QuoteExactParams({ - exactCurrency: Currency.wrap(address(token2)), - path: quoter_path, - exactAmount: 0.5 ether + exactCurrency: Currency.wrap(address(token2)), path: quoter_path, exactAmount: 0.5 ether }) ); @@ -642,10 +622,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { quoter._quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key3, - zeroForOne: true, - exactAmount: 1 ether, - hookData: new bytes(0) + poolKey: key3, zeroForOne: true, exactAmount: 1 ether, hookData: new bytes(0) }) ); } @@ -661,10 +638,7 @@ contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 { ); quoter.quoteExactOutputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key, - zeroForOne: true, - exactAmount: 20 ether, - hookData: new bytes(0) + poolKey: key, zeroForOne: true, exactAmount: 20 ether, hookData: new bytes(0) }) ); } diff --git a/test/pool-bin/libraries/BinCalldataDecoder.t.sol b/test/pool-bin/libraries/BinCalldataDecoder.t.sol index bef7d97..f3cb450 100644 --- a/test/pool-bin/libraries/BinCalldataDecoder.t.sol +++ b/test/pool-bin/libraries/BinCalldataDecoder.t.sol @@ -89,10 +89,7 @@ contract BinCalldataDecoderTest is Test { function test_decodeBinSwapExactInParams_outOfBounds() public { PathKey[] memory path = new PathKey[](0); IInfinityRouter.BinSwapExactInputParams memory _swapParams = IBinRouterBase.BinSwapExactInputParams({ - currencyIn: Currency.wrap(makeAddr("currencyIn")), - path: path, - amountIn: 1 ether, - amountOutMinimum: 1 ether + currencyIn: Currency.wrap(makeAddr("currencyIn")), path: path, amountIn: 1 ether, amountOutMinimum: 1 ether }); /// @dev params.length is 192 as abi.encode adds 32 bytes for dynamic field. However ether.js doesn't add 32 bytes @@ -123,11 +120,7 @@ contract BinCalldataDecoderTest is Test { function test_fuzz_decodeBinSwapExactInSingleParams_outOfBounds(PoolKey memory key) public { IInfinityRouter.BinSwapExactInputSingleParams memory _swapParams = IBinRouterBase.BinSwapExactInputSingleParams({ - poolKey: key, - swapForY: true, - amountIn: 1 ether, - amountOutMinimum: 1 ether, - hookData: "" + poolKey: key, swapForY: true, amountIn: 1 ether, amountOutMinimum: 1 ether, hookData: "" }); /// @dev params.length is 384 as abi.encode adds 32 bytes for dynamic field. However ether.js doesn't add 32 bytes @@ -191,13 +184,8 @@ contract BinCalldataDecoderTest is Test { } function test_fuzz_decodeBinSwapExactOutSingleParams_outOfBounds(PoolKey memory key) public { - IInfinityRouter.BinSwapExactOutputSingleParams memory _swapParams = IBinRouterBase - .BinSwapExactOutputSingleParams({ - poolKey: key, - swapForY: true, - amountOut: 1 ether, - amountInMaximum: 1 ether, - hookData: "" + IInfinityRouter.BinSwapExactOutputSingleParams memory _swapParams = IBinRouterBase.BinSwapExactOutputSingleParams({ + poolKey: key, swapForY: true, amountOut: 1 ether, amountInMaximum: 1 ether, hookData: "" }); /// @dev params.length is 384 as abi.encode adds 32 bytes for dynamic field. However ether.js doesn't add 32 bytes diff --git a/test/pool-bin/shared/BinHookModifyLiquidities.sol b/test/pool-bin/shared/BinHookModifyLiquidities.sol index 215c411..0be22f8 100644 --- a/test/pool-bin/shared/BinHookModifyLiquidities.sol +++ b/test/pool-bin/shared/BinHookModifyLiquidities.sol @@ -31,7 +31,11 @@ contract BinHookModifyLiquidities is BinHookSavesDelta { bool, /* swapForY **/ int128, /* amountSpecified **/ bytes calldata hookData - ) external override returns (bytes4, BeforeSwapDelta, uint24) { + ) + external + override + returns (bytes4, BeforeSwapDelta, uint24) + { approvePosmCurrency(key.currency0); approvePosmCurrency(key.currency1); @@ -45,7 +49,11 @@ contract BinHookModifyLiquidities is BinHookSavesDelta { PoolKey calldata, /* key **/ IBinPoolManager.MintParams calldata, /* params **/ bytes calldata hookData - ) external override returns (bytes4, uint24) { + ) + external + override + returns (bytes4, uint24) + { if (hookData.length > 0) { (bytes memory actions, bytes[] memory params) = abi.decode(hookData, (bytes, bytes[])); posm.modifyLiquiditiesWithoutLock(actions, params); @@ -58,7 +66,11 @@ contract BinHookModifyLiquidities is BinHookSavesDelta { PoolKey calldata, /* key **/ IBinPoolManager.BurnParams calldata, /* params **/ bytes calldata hookData - ) external override returns (bytes4) { + ) + external + override + returns (bytes4) + { if (hookData.length > 0) { (bytes memory actions, bytes[] memory params) = abi.decode(hookData, (bytes, bytes[])); posm.modifyLiquiditiesWithoutLock(actions, params); diff --git a/test/pool-cl/CLQuoter.t.sol b/test/pool-cl/CLQuoter.t.sol index 95eaf2f..669c424 100644 --- a/test/pool-cl/CLQuoter.t.sol +++ b/test/pool-cl/CLQuoter.t.sol @@ -89,10 +89,7 @@ contract CLQuoterTest is Test, Deployers { (uint256 _amountOut, uint256 _gasEstimate) = quoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key02, - zeroForOne: true, - exactAmount: uint128(amountIn), - hookData: ZERO_BYTES + poolKey: key02, zeroForOne: true, exactAmount: uint128(amountIn), hookData: ZERO_BYTES }) ); @@ -117,10 +114,7 @@ contract CLQuoterTest is Test, Deployers { (uint256 _amountOut, uint256 _gasEstimate) = quoter.quoteExactInputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key02, - zeroForOne: false, - exactAmount: uint128(amountIn), - hookData: ZERO_BYTES + poolKey: key02, zeroForOne: false, exactAmount: uint128(amountIn), hookData: ZERO_BYTES }) ); @@ -290,10 +284,7 @@ contract CLQuoterTest is Test, Deployers { ); quoter.quoteExactOutputSingle( IQuoter.QuoteExactSingleParams({ - poolKey: key01, - zeroForOne: true, - exactAmount: type(uint128).max, - hookData: ZERO_BYTES + poolKey: key01, zeroForOne: true, exactAmount: type(uint128).max, hookData: ZERO_BYTES }) ); } @@ -501,8 +492,8 @@ contract CLQuoterTest is Test, Deployers { ICLPoolManager.ModifyLiquidityParams({ tickLower: MIN_TICK, tickUpper: MAX_TICK, - liquidityDelta: calculateLiquidityFromAmounts(SQRT_RATIO_1_1, MIN_TICK, MAX_TICK, 1000000, 1000000).toInt256( - ), + liquidityDelta: calculateLiquidityFromAmounts(SQRT_RATIO_1_1, MIN_TICK, MAX_TICK, 1000000, 1000000) + .toInt256(), salt: bytes32(0) }), ZERO_BYTES diff --git a/test/pool-cl/CLSwapRouter.t.sol b/test/pool-cl/CLSwapRouter.t.sol index eed6578..7207b32 100644 --- a/test/pool-cl/CLSwapRouter.t.sol +++ b/test/pool-cl/CLSwapRouter.t.sol @@ -74,10 +74,7 @@ contract CLSwapRouterTest is TokenFixture, Test { positionManager.modifyPosition( poolKey0, ICLPoolManager.ModifyLiquidityParams({ - tickLower: 46053, - tickUpper: 46055, - liquidityDelta: 1e4 ether, - salt: bytes32(0) + tickLower: 46053, tickUpper: 46055, liquidityDelta: 1e4 ether, salt: bytes32(0) }), new bytes(0) ); @@ -99,10 +96,7 @@ contract CLSwapRouterTest is TokenFixture, Test { positionManager.modifyPosition( poolKey1, ICLPoolManager.ModifyLiquidityParams({ - tickLower: -5, - tickUpper: 5, - liquidityDelta: 1e5 ether, - salt: bytes32(0) + tickLower: -5, tickUpper: 5, liquidityDelta: 1e5 ether, salt: bytes32(0) }), new bytes(0) ); @@ -126,10 +120,7 @@ contract CLSwapRouterTest is TokenFixture, Test { positionManager.modifyPosition{value: 25 ether}( poolKey2, ICLPoolManager.ModifyLiquidityParams({ - tickLower: -5, - tickUpper: 5, - liquidityDelta: 1e5 ether, - salt: bytes32(0) + tickLower: -5, tickUpper: 5, liquidityDelta: 1e5 ether, salt: bytes32(0) }), new bytes(0) ); diff --git a/test/pool-cl/TickLens.t.sol b/test/pool-cl/TickLens.t.sol index 86be081..80637ca 100644 --- a/test/pool-cl/TickLens.t.sol +++ b/test/pool-cl/TickLens.t.sol @@ -74,10 +74,7 @@ contract TickLensTest is TokenFixture, Test { positionManager.modifyPosition( poolKey0, ICLPoolManager.ModifyLiquidityParams({ - tickLower: -300, - tickUpper: 300, - liquidityDelta: 10 ether, - salt: bytes32(0) + tickLower: -300, tickUpper: 300, liquidityDelta: 10 ether, salt: bytes32(0) }), new bytes(0) ); @@ -124,10 +121,7 @@ contract TickLensTest is TokenFixture, Test { positionManager.modifyPosition( poolKey0, ICLPoolManager.ModifyLiquidityParams({ - tickLower: -260, - tickUpper: 260, - liquidityDelta: 9 ether, - salt: bytes32(0) + tickLower: -260, tickUpper: 260, liquidityDelta: 9 ether, salt: bytes32(0) }), new bytes(0) ); @@ -135,10 +129,7 @@ contract TickLensTest is TokenFixture, Test { positionManager.modifyPosition( poolKey0, ICLPoolManager.ModifyLiquidityParams({ - tickLower: -360, - tickUpper: 360, - liquidityDelta: 11 ether, - salt: bytes32(0) + tickLower: -360, tickUpper: 360, liquidityDelta: 11 ether, salt: bytes32(0) }), new bytes(0) ); @@ -173,10 +164,7 @@ contract TickLensTest is TokenFixture, Test { positionManager.modifyPosition( poolKey2, ICLPoolManager.ModifyLiquidityParams({ - tickLower: tickLower, - tickUpper: tickUpper, - liquidityDelta: 10 ether, - salt: bytes32(0) + tickLower: tickLower, tickUpper: tickUpper, liquidityDelta: 10 ether, salt: bytes32(0) }), new bytes(0) ); @@ -197,10 +185,7 @@ contract TickLensTest is TokenFixture, Test { positionManager.modifyPosition( poolKey1, ICLPoolManager.ModifyLiquidityParams({ - tickLower: tickLower, - tickUpper: tickUpper, - liquidityDelta: 1 ether, - salt: bytes32(0) + tickLower: tickLower, tickUpper: tickUpper, liquidityDelta: 1 ether, salt: bytes32(0) }), new bytes(0) ); @@ -229,10 +214,7 @@ contract TickLensTest is TokenFixture, Test { positionManager.modifyPosition( poolKey1, ICLPoolManager.ModifyLiquidityParams({ - tickLower: tickLower, - tickUpper: tickUpper, - liquidityDelta: 1 ether, - salt: bytes32(0) + tickLower: tickLower, tickUpper: tickUpper, liquidityDelta: 1 ether, salt: bytes32(0) }), new bytes(0) ); diff --git a/test/pool-cl/erc721Permit/ERC721Permit.permitForAll.t.sol b/test/pool-cl/erc721Permit/ERC721Permit.permitForAll.t.sol index c66c6fa..03697fa 100644 --- a/test/pool-cl/erc721Permit/ERC721Permit.permitForAll.t.sol +++ b/test/pool-cl/erc721Permit/ERC721Permit.permitForAll.t.sol @@ -319,9 +319,7 @@ contract ERC721PermitForAllTest is Test { } // Helpers related to permitForAll - function _permitForAll(uint256 privateKey, address owner, address operator, bool approved, uint256 nonce) - internal - { + function _permitForAll(uint256 privateKey, address owner, address operator, bool approved, uint256 nonce) internal { bytes32 digest = _getPermitForAllDigest(operator, approved, nonce, block.timestamp); (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest); diff --git a/test/pool-cl/libraries/CLCalldataDecoder.t.sol b/test/pool-cl/libraries/CLCalldataDecoder.t.sol index 476949e..5bed428 100644 --- a/test/pool-cl/libraries/CLCalldataDecoder.t.sol +++ b/test/pool-cl/libraries/CLCalldataDecoder.t.sol @@ -77,8 +77,9 @@ contract CLCalldataDecoderTest is Test { address _owner, bytes calldata _hookData ) public view { - bytes memory params = - abi.encode(_poolKey, _tickLower, _tickUpper, _liquidity, _amount0Max, _amount1Max, _owner, _hookData); + bytes memory params = abi.encode( + _poolKey, _tickLower, _tickUpper, _liquidity, _amount0Max, _amount1Max, _owner, _hookData + ); ( PoolKey memory poolKey, int24 tickLower, @@ -138,10 +139,7 @@ contract CLCalldataDecoderTest is Test { function test_decodeSwapExactInParams_outOfBounds() public { PathKey[] memory path = new PathKey[](0); IInfinityRouter.CLSwapExactInputParams memory _swapParams = ICLRouterBase.CLSwapExactInputParams({ - currencyIn: Currency.wrap(makeAddr("currencyIn")), - path: path, - amountIn: 1 ether, - amountOutMinimum: 1 ether + currencyIn: Currency.wrap(makeAddr("currencyIn")), path: path, amountIn: 1 ether, amountOutMinimum: 1 ether }); /// @dev params.length is 192 as abi.encode adds 32 bytes for dynamic field. However ether.js doesn't add 32 bytes @@ -172,11 +170,7 @@ contract CLCalldataDecoderTest is Test { function test_fuzz_decodeSwapExactInSingleParams_outOfBounds(PoolKey memory key) public { IInfinityRouter.CLSwapExactInputSingleParams memory _swapParams = ICLRouterBase.CLSwapExactInputSingleParams({ - poolKey: key, - zeroForOne: true, - amountIn: 1 ether, - amountOutMinimum: 1 ether, - hookData: "" + poolKey: key, zeroForOne: true, amountIn: 1 ether, amountOutMinimum: 1 ether, hookData: "" }); /// @dev params.length is 384 as abi.encode adds 32 bytes for dynamic field. However ether.js doesn't add 32 bytes @@ -257,11 +251,7 @@ contract CLCalldataDecoderTest is Test { function test_fuzz_decodeSwapExactOutSingleParams_outOfBounds(PoolKey memory key) public { IInfinityRouter.CLSwapExactOutputSingleParams memory _swapParams = ICLRouterBase.CLSwapExactOutputSingleParams({ - poolKey: key, - zeroForOne: true, - amountOut: 1 ether, - amountInMaximum: 1 ether, - hookData: "" + poolKey: key, zeroForOne: true, amountOut: 1 ether, amountInMaximum: 1 ether, hookData: "" }); /// @dev params.length is 384 as abi.encode adds 32 bytes for dynamic field. However ether.js doesn't add 32 bytes diff --git a/test/pool-cl/mocks/ReentrantToken.sol b/test/pool-cl/mocks/ReentrantToken.sol index b68e4d4..8d11754 100644 --- a/test/pool-cl/mocks/ReentrantToken.sol +++ b/test/pool-cl/mocks/ReentrantToken.sol @@ -11,7 +11,17 @@ contract ReentrantToken is MockERC20 { posm = _posm; } - function transferFrom(address, /*from*/ address, /*to*/ uint256 /*amount*/ ) public override returns (bool) { + function transferFrom( + address, + /*from*/ + address, + /*to*/ + uint256 /*amount*/ + ) + public + override + returns (bool) + { // we dont need data because itll revert before it does anything posm.modifyLiquidities("", type(uint256).max); return true; diff --git a/test/pool-cl/position-managers/CLPositionManager.gas.t.sol b/test/pool-cl/position-managers/CLPositionManager.gas.t.sol index 3f19ff0..fad1bc5 100644 --- a/test/pool-cl/position-managers/CLPositionManager.gas.t.sol +++ b/test/pool-cl/position-managers/CLPositionManager.gas.t.sol @@ -87,31 +87,40 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { } function test_gas_mint_withClose() public { - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - -300, - 300, - 10_000 ether, - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - ActionConstants.MSG_SENDER, - ZERO_BYTES - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + -300, + 300, + 10_000 ether, + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + ActionConstants.MSG_SENDER, + ZERO_BYTES + ) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); vm.snapshotGasLastCall("test_gas_mint_withClose"); } function test_gas_mint_withSettlePair() public { - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, -300, 300, 10_000 ether, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, address(this), ZERO_BYTES - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + -300, + 300, + 10_000 ether, + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + address(this), + ZERO_BYTES + ) + ); bytes memory calls = planner.finalizeModifyLiquidityWithSettlePair(key); lpm.modifyLiquidities(calls, _deadline); vm.snapshotGasLastCall("test_gas_mint_withSettlePair"); @@ -123,19 +132,20 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { mint(key, 0, 60, 10_000 ether, address(bob), ZERO_BYTES); vm.stopPrank(); // Mint to a diff config, diff user. - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - -300, - 300, - 10_000 ether, - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - ActionConstants.MSG_SENDER, - ZERO_BYTES - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + -300, + 300, + 10_000 ether, + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + ActionConstants.MSG_SENDER, + ZERO_BYTES + ) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); vm.prank(alice); lpm.modifyLiquidities(calls, _deadline); @@ -148,19 +158,20 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { mint(key, -300, -60, 10_000 ether, address(bob), ZERO_BYTES); vm.stopPrank(); // Mint to a diff config, diff user. - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - -300, - 300, - 10_000 ether, - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - ActionConstants.MSG_SENDER, - ZERO_BYTES - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + -300, + 300, + 10_000 ether, + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + ActionConstants.MSG_SENDER, + ZERO_BYTES + ) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); vm.prank(alice); lpm.modifyLiquidities(calls, _deadline); @@ -173,19 +184,20 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { mint(key, 60, 300, 10_000 ether, address(bob), ZERO_BYTES); vm.stopPrank(); // Mint to a diff config, diff user. - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - -300, - 300, - 10_000 ether, - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - ActionConstants.MSG_SENDER, - ZERO_BYTES - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + -300, + 300, + 10_000 ether, + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + ActionConstants.MSG_SENDER, + ZERO_BYTES + ) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); vm.prank(alice); lpm.modifyLiquidities(calls, _deadline); @@ -196,10 +208,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_INCREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_INCREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); @@ -210,10 +223,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, address(this), ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_INCREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_INCREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithSettlePair(key); lpm.modifyLiquidities(calls, _deadline); @@ -254,10 +268,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { tokensOwedAlice ); - Plan memory planner = Planner.init().add( - Actions.CL_INCREASE_LIQUIDITY, - abi.encode(tokenIdAlice, liquidityDelta, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_INCREASE_LIQUIDITY, + abi.encode(tokenIdAlice, liquidityDelta, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) + ); // because its a perfect autocompound, the delta is exactly 0 and we dont need to "close" deltas bytes memory calls = planner.encode(); @@ -349,10 +364,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { halfTokensOwedAlice ); - Plan memory planner = Planner.init().add( - Actions.CL_INCREASE_LIQUIDITY, - abi.encode(tokenIdAlice, liquidityDelta, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_INCREASE_LIQUIDITY, + abi.encode(tokenIdAlice, liquidityDelta, MAX_SLIPPAGE_INCREASE, MAX_SLIPPAGE_INCREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); @@ -365,10 +381,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); @@ -379,10 +396,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithTakePair(key, address(this)); lpm.modifyLiquidities(calls, _deadline); @@ -433,10 +451,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { router.donate(key, 0.2e18, 0.2e18, ZERO_BYTES); // Collect by calling decrease with 0. - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 0, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 0, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); @@ -451,10 +470,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { router.donate(key, 0.2e18, 0.2e18, ZERO_BYTES); // Collect by calling decrease with 0. - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 0, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 0, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithTakePair(key, address(this)); lpm.modifyLiquidities(calls, _deadline); @@ -465,19 +485,20 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { function test_gas_sameRange_mint() public { mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - -300, - 300, - 10_001 ether, - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - ActionConstants.MSG_SENDER, - ZERO_BYTES - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + -300, + 300, + 10_001 ether, + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + ActionConstants.MSG_SENDER, + ZERO_BYTES + ) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); vm.prank(alice); lpm.modifyLiquidities(calls, _deadline); @@ -493,10 +514,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); @@ -515,10 +537,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { // donate to create fee revenue router.donate(key, 0.2e18, 0.2e18, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 0, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 0, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); @@ -529,9 +552,10 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); lpm.modifyLiquidities(calls, _deadline); @@ -542,9 +566,10 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithTakePair(key, address(this)); lpm.modifyLiquidities(calls, _deadline); @@ -556,9 +581,10 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); decreaseLiquidity(tokenId, 10_000 ether, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); // There is no need to include CLOSE commands. bytes memory calls = planner.encode(); @@ -572,10 +598,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mint(key, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); planner.add( Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) ); @@ -701,9 +728,10 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mintWithNative(SQRT_RATIO_1_1, nativeKey, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithClose(nativeKey); lpm.modifyLiquidities(calls, _deadline); @@ -714,9 +742,10 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mintWithNative(SQRT_RATIO_1_1, nativeKey, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); bytes memory calls = planner.finalizeModifyLiquidityWithTakePair(nativeKey, address(this)); lpm.modifyLiquidities(calls, _deadline); @@ -728,9 +757,10 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { mintWithNative(SQRT_RATIO_1_1, nativeKey, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); decreaseLiquidity(tokenId, 10_000 ether, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_BURN_POSITION, abi.encode(tokenId, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); // There is no need to include CLOSE commands. bytes memory calls = planner.encode(); @@ -744,10 +774,11 @@ contract CLPositionManagerGasTest is Test, PosmTestSetup { uint256 tokenId = lpm.nextTokenId(); mintWithNative(SQRT_RATIO_1_1, nativeKey, -300, 300, 10_000 ether, ActionConstants.MSG_SENDER, ZERO_BYTES); - Plan memory planner = Planner.init().add( - Actions.CL_DECREASE_LIQUIDITY, - abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_DECREASE_LIQUIDITY, + abi.encode(tokenId, 10_000 ether, MIN_SLIPPAGE_DECREASE, MIN_SLIPPAGE_DECREASE, ZERO_BYTES) + ); planner.add(Actions.CL_BURN_POSITION, abi.encode(tokenId, 0 wei, 0 wei, ZERO_BYTES)); // We must include CLOSE commands. diff --git a/test/pool-cl/position-managers/CLPositionManager.modifyLiquidity.t.sol b/test/pool-cl/position-managers/CLPositionManager.modifyLiquidity.t.sol index 8cc62c5..79ed494 100644 --- a/test/pool-cl/position-managers/CLPositionManager.modifyLiquidity.t.sol +++ b/test/pool-cl/position-managers/CLPositionManager.modifyLiquidity.t.sol @@ -129,9 +129,7 @@ contract CLPositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, Liquidit // seedWeth(address(this)); wethConfig = PositionConfig({ - poolKey: wethKey, - tickLower: TickMath.minUsableTick(60), - tickUpper: TickMath.maxUsableTick(60) + poolKey: wethKey, tickLower: TickMath.minUsableTick(60), tickUpper: TickMath.maxUsableTick(60) }); nativeConfig = PositionConfig({poolKey: nativeKey, tickLower: -120, tickUpper: 120}); fotConfig = PositionConfig({poolKey: fotKey, tickLower: -120, tickUpper: 120}); diff --git a/test/pool-cl/shared/FeeMath.sol b/test/pool-cl/shared/FeeMath.sol index 0e85624..5e4cada 100644 --- a/test/pool-cl/shared/FeeMath.sol +++ b/test/pool-cl/shared/FeeMath.sol @@ -58,8 +58,8 @@ library FeeMath { pure returns (uint128 tokenOwed) { - tokenOwed = - (FullMath.mulDiv(feeGrowthInsideX128 - feeGrowthInsideLastX128, liquidity, FixedPoint128.Q128)).toUint128(); + tokenOwed = (FullMath.mulDiv(feeGrowthInsideX128 - feeGrowthInsideLastX128, liquidity, FixedPoint128.Q128)) + .toUint128(); } // TODO: should we consider migrating this into core repo ? diff --git a/test/pool-cl/shared/HookModifyLiquidities.sol b/test/pool-cl/shared/HookModifyLiquidities.sol index ae2057a..ece102d 100644 --- a/test/pool-cl/shared/HookModifyLiquidities.sol +++ b/test/pool-cl/shared/HookModifyLiquidities.sol @@ -30,7 +30,11 @@ contract HookModifyLiquidities is HookSavesDelta { PoolKey calldata key, /* key **/ ICLPoolManager.SwapParams calldata, /* params **/ bytes calldata hookData - ) external override returns (bytes4, BeforeSwapDelta, uint24) { + ) + external + override + returns (bytes4, BeforeSwapDelta, uint24) + { approvePosmCurrency(key.currency0); approvePosmCurrency(key.currency1); diff --git a/test/pool-cl/shared/fuzz/LiquidityFuzzers.sol b/test/pool-cl/shared/fuzz/LiquidityFuzzers.sol index 8959ca5..2d02975 100644 --- a/test/pool-cl/shared/fuzz/LiquidityFuzzers.sol +++ b/test/pool-cl/shared/fuzz/LiquidityFuzzers.sol @@ -27,19 +27,20 @@ contract LiquidityFuzzers is Fuzzers { params = Fuzzers.createFuzzyLiquidityParams(key, params, sqrtPriceX96); uint128 MAX_SLIPPAGE_INCREASE = type(uint128).max; - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - params.tickLower, - params.tickUpper, - uint256(params.liquidityDelta), - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - recipient, - hookData - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + params.tickLower, + params.tickUpper, + uint256(params.liquidityDelta), + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + recipient, + hookData + ) + ); uint256 tokenId = lpm.nextTokenId(); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); @@ -81,19 +82,20 @@ contract LiquidityFuzzers is Fuzzers { params = createFuzzyTwoSidedLiquidityParams(key, params, sqrtPriceX96); uint128 MAX_SLIPPAGE_INCREASE = type(uint128).max; - Plan memory planner = Planner.init().add( - Actions.CL_MINT_POSITION, - abi.encode( - key, - params.tickLower, - params.tickUpper, - uint256(params.liquidityDelta), - MAX_SLIPPAGE_INCREASE, - MAX_SLIPPAGE_INCREASE, - recipient, - hookData - ) - ); + Plan memory planner = Planner.init() + .add( + Actions.CL_MINT_POSITION, + abi.encode( + key, + params.tickLower, + params.tickUpper, + uint256(params.liquidityDelta), + MAX_SLIPPAGE_INCREASE, + MAX_SLIPPAGE_INCREASE, + recipient, + hookData + ) + ); uint256 tokenId = lpm.nextTokenId(); bytes memory calls = planner.finalizeModifyLiquidityWithClose(key); diff --git a/test/shared/Permit2SignatureHelpers.sol b/test/shared/Permit2SignatureHelpers.sol index 1f5d075..a96bb26 100644 --- a/test/shared/Permit2SignatureHelpers.sol +++ b/test/shared/Permit2SignatureHelpers.sol @@ -105,11 +105,10 @@ contract Permit2SignatureHelpers { { IAllowanceTransfer.PermitDetails memory details = IAllowanceTransfer.PermitDetails({token: token0, amount: amount, expiration: expiration, nonce: nonce}); - return IAllowanceTransfer.PermitSingle({ - details: details, - spender: address(this), - sigDeadline: block.timestamp + 100 - }); + return + IAllowanceTransfer.PermitSingle({ + details: details, spender: address(this), sigDeadline: block.timestamp + 100 + }); } function defaultERC20PermitBatchAllowance(address[] memory tokens, uint160 amount, uint48 expiration, uint48 nonce) @@ -121,17 +120,13 @@ contract Permit2SignatureHelpers { for (uint256 i = 0; i < tokens.length; ++i) { details[i] = IAllowanceTransfer.PermitDetails({ - token: tokens[i], - amount: amount, - expiration: expiration, - nonce: nonce + token: tokens[i], amount: amount, expiration: expiration, nonce: nonce }); } - return IAllowanceTransfer.PermitBatch({ - details: details, - spender: address(this), - sigDeadline: block.timestamp + 100 - }); + return + IAllowanceTransfer.PermitBatch({ + details: details, spender: address(this), sigDeadline: block.timestamp + 100 + }); } }