From d61d6a2ba0e0aeb3538ea1c8bae06b4af2ba679b Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:26:44 +0800 Subject: [PATCH 01/10] feat: updated pancake-v4-periphery --- lib/pancake-v4-periphery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pancake-v4-periphery b/lib/pancake-v4-periphery index 5a904ec..e0f3aa7 160000 --- a/lib/pancake-v4-periphery +++ b/lib/pancake-v4-periphery @@ -1 +1 @@ -Subproject commit 5a904ecdd6b445fc88d600bcf659209f534ad589 +Subproject commit e0f3aa779f2d414d8d7b9bbf853889cdb82d0573 From 576a077e2a88c5569278afbc862395e621c8daf5 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:58:23 +0800 Subject: [PATCH 02/10] feat: update test cases based on latest v4-periphery --- ...SwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap | 2 +- ...4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap | 2 +- ...inPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap | 2 +- ...ancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap | 2 +- ...ncakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap | 2 +- ...ncakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap | 2 +- ...cakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap | 2 +- ...inPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...eSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap | 2 +- ...SwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap | 2 +- ...PancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap | 2 +- ...ancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap | 2 +- ...CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...ancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap | 2 +- ...ncakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap | 2 +- .forge-snapshots/UniversalRouterBytecodeSize.snap | 2 +- ...nNativeTest#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...onTest#test_v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...test_v4BinPositionmanager_BinAddLiquidity_Native.snap | 2 +- ...3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap | 2 +- test/V3ToV4Migration.t.sol | 9 ++++----- test/V3ToV4MigrationNative.t.sol | 8 +++----- test/v4/BinNativePancakeSwapV4.t.sol | 2 +- test/v4/BinPancakeSwapV4.t.sol | 2 +- test/v4/CLNativePancakeSwapV4.t.sol | 8 +++----- test/v4/CLPancakeSwapV4.t.sol | 8 +++----- 27 files changed, 36 insertions(+), 43 deletions(-) diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap index e241edf..9b0db55 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -145982 \ No newline at end of file +145965 \ No newline at end of file diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap index 7a5cf79..2f37e1a 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap @@ -1 +1 @@ -122905 \ No newline at end of file +122888 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap index 028a4ef..540f2cc 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap @@ -1 +1 @@ -146944 \ No newline at end of file +146927 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap index 06443ee..f1ec03a 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -178353 \ No newline at end of file +178336 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap index 87c0046..5cdbace 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -148738 \ No newline at end of file +148721 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap index e61095b..8d1563a 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -182159 \ No newline at end of file +182177 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap index cb48d03..94eec8a 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -153076 \ No newline at end of file +153094 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index 04b5f6d..716e770 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -151291 \ No newline at end of file +151306 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap index afb341f..04fa8f6 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -172582 \ No newline at end of file +171967 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap index 581658f..0acd0df 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap @@ -1 +1 @@ -174586 \ No newline at end of file +174217 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap index ef5e57a..fe812b4 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap @@ -1 +1 @@ -181948 \ No newline at end of file +181316 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap index d49e626..0580928 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -247830 \ No newline at end of file +246631 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap index cb2505b..3f4c0c6 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -183465 \ No newline at end of file +182857 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index 8df078e..6d5a537 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -185764 \ No newline at end of file +185655 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap index 8446f8f..3009198 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -250612 \ No newline at end of file +250390 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap index ebbb9d7..3b7a5b6 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -187291 \ No newline at end of file +187189 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index 218c26b..5e90e8a 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -23464 \ No newline at end of file +23825 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index 87b8a5a..da17240 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -606007 \ No newline at end of file +558567 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index 2ef41c2..e656853 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -593395 \ No newline at end of file +593340 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 0570d7a..789110b 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -569221 \ No newline at end of file +569182 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index df4f50e..6616267 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -630193 \ No newline at end of file +582733 \ No newline at end of file diff --git a/test/V3ToV4Migration.t.sol b/test/V3ToV4Migration.t.sol index 19e5048..d18b740 100644 --- a/test/V3ToV4Migration.t.sol +++ b/test/V3ToV4Migration.t.sol @@ -24,7 +24,6 @@ import {Plan, Planner} from "pancake-v4-periphery/src/libraries/Planner.sol"; import {CLPositionManager} from "pancake-v4-periphery/src/pool-cl/CLPositionManager.sol"; import {BinPositionManager} from "pancake-v4-periphery/src/pool-bin/BinPositionManager.sol"; import {Actions} from "pancake-v4-periphery/src/libraries/Actions.sol"; -import {PositionConfig} from "pancake-v4-periphery/src/pool-cl/libraries/PositionConfig.sol"; import {IV3NonfungiblePositionManager} from "pancake-v4-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; import {IERC721Permit} from "pancake-v4-periphery/src/pool-cl/interfaces/IERC721Permit.sol"; @@ -114,8 +113,8 @@ contract V3ToV4MigrationTest is BasePancakeSwapV4, OldVersionHelper, BinLiquidit //////////// v4 setup ///////////// /////////////////////////////////// vault = IVault(new Vault()); - binPoolManager = new BinPoolManager(vault, 500000); - clPoolManager = new CLPoolManager(vault, 3000); + binPoolManager = new BinPoolManager(vault); + clPoolManager = new CLPoolManager(vault); vault.registerApp(address(binPoolManager)); vault.registerApp(address(clPoolManager)); @@ -289,9 +288,9 @@ contract V3ToV4MigrationTest is BasePancakeSwapV4, OldVersionHelper, BinLiquidit token1.mint(address(router), 10 ether); // prep position manager action: mint/ settle/ settle - PositionConfig memory positionConfig = PositionConfig({poolKey: clPoolKey, tickLower: -120, tickUpper: 120}); + // PositionConfig memory positionConfig = PositionConfig({poolKey: clPoolKey, tickLower: -120, tickUpper: 120}); Plan memory planner = Planner.init(); - planner.add(Actions.CL_MINT_POSITION, abi.encode(positionConfig, 1 ether, 10 ether, 10 ether, alice, "")); + planner.add(Actions.CL_MINT_POSITION, abi.encode(clPoolKey, -120, 120, 1 ether, 10 ether, 10 ether, alice, "")); planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router planner.add(Actions.SWEEP, abi.encode(clPoolKey.currency0, alice)); diff --git a/test/V3ToV4MigrationNative.t.sol b/test/V3ToV4MigrationNative.t.sol index b0c5a4e..f4c1c44 100644 --- a/test/V3ToV4MigrationNative.t.sol +++ b/test/V3ToV4MigrationNative.t.sol @@ -24,7 +24,6 @@ import {Plan, Planner} from "pancake-v4-periphery/src/libraries/Planner.sol"; import {CLPositionManager} from "pancake-v4-periphery/src/pool-cl/CLPositionManager.sol"; import {BinPositionManager} from "pancake-v4-periphery/src/pool-bin/BinPositionManager.sol"; import {Actions} from "pancake-v4-periphery/src/libraries/Actions.sol"; -import {PositionConfig} from "pancake-v4-periphery/src/pool-cl/libraries/PositionConfig.sol"; import {IV3NonfungiblePositionManager} from "pancake-v4-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; import {IERC721Permit} from "pancake-v4-periphery/src/pool-cl/interfaces/IERC721Permit.sol"; @@ -84,8 +83,8 @@ contract V3ToV4MigrationNativeTest is BasePancakeSwapV4, OldVersionHelper, BinLi //////////// v4 setup ///////////// /////////////////////////////////// vault = IVault(new Vault()); - binPoolManager = new BinPoolManager(vault, 500000); - clPoolManager = new CLPoolManager(vault, 3000); + binPoolManager = new BinPoolManager(vault); + clPoolManager = new CLPoolManager(vault); vault.registerApp(address(binPoolManager)); vault.registerApp(address(clPoolManager)); @@ -149,9 +148,8 @@ contract V3ToV4MigrationNativeTest is BasePancakeSwapV4, OldVersionHelper, BinLi token1.mint(address(router), 10 ether); // prep position manager action: mint/ settle/ settle - PositionConfig memory positionConfig = PositionConfig({poolKey: clPoolKey, tickLower: -120, tickUpper: 120}); Plan memory planner = Planner.init(); - planner.add(Actions.CL_MINT_POSITION, abi.encode(positionConfig, 1 ether, 10 ether, 10 ether, alice, "")); + planner.add(Actions.CL_MINT_POSITION, abi.encode(clPoolKey, -120, 120, 1 ether, 10 ether, 10 ether, alice, "")); planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router planner.add(Actions.SWEEP, abi.encode(clPoolKey.currency0, alice)); diff --git a/test/v4/BinNativePancakeSwapV4.t.sol b/test/v4/BinNativePancakeSwapV4.t.sol index 8c0fcb9..5764737 100644 --- a/test/v4/BinNativePancakeSwapV4.t.sol +++ b/test/v4/BinNativePancakeSwapV4.t.sol @@ -52,7 +52,7 @@ contract BinNativePancakeSwapV4Test is BasePancakeSwapV4, BinLiquidityHelper { function setUp() public { vault = IVault(new Vault()); - poolManager = new BinPoolManager(vault, 500000); + poolManager = new BinPoolManager(vault); vault.registerApp(address(poolManager)); permit2 = IAllowanceTransfer(deployPermit2()); diff --git a/test/v4/BinPancakeSwapV4.t.sol b/test/v4/BinPancakeSwapV4.t.sol index 7014612..1111c5b 100644 --- a/test/v4/BinPancakeSwapV4.t.sol +++ b/test/v4/BinPancakeSwapV4.t.sol @@ -54,7 +54,7 @@ contract BinPancakeSwapV4Test is BasePancakeSwapV4, BinLiquidityHelper { function setUp() public { vault = IVault(new Vault()); - poolManager = new BinPoolManager(vault, 500000); + poolManager = new BinPoolManager(vault); vault.registerApp(address(poolManager)); permit2 = IAllowanceTransfer(deployPermit2()); diff --git a/test/v4/CLNativePancakeSwapV4.t.sol b/test/v4/CLNativePancakeSwapV4.t.sol index c2a8047..152aaaf 100644 --- a/test/v4/CLNativePancakeSwapV4.t.sol +++ b/test/v4/CLNativePancakeSwapV4.t.sol @@ -22,7 +22,6 @@ import {ActionConstants} from "pancake-v4-periphery/src/libraries/ActionConstant import {Plan, Planner} from "pancake-v4-periphery/src/libraries/Planner.sol"; import {CLPositionManager} from "pancake-v4-periphery/src/pool-cl/CLPositionManager.sol"; import {Actions} from "pancake-v4-periphery/src/libraries/Actions.sol"; -import {PositionConfig} from "pancake-v4-periphery/src/pool-cl/libraries/PositionConfig.sol"; import {ICLRouterBase} from "pancake-v4-periphery/src/pool-cl/interfaces/ICLRouterBase.sol"; import {LiquidityAmounts} from "pancake-v4-periphery/src/pool-cl/libraries/LiquidityAmounts.sol"; import {PathKey} from "pancake-v4-periphery/src/libraries/PathKey.sol"; @@ -55,7 +54,7 @@ contract CLNativePancakeSwapV4Test is BasePancakeSwapV4 { function setUp() public { vault = IVault(new Vault()); - poolManager = new CLPoolManager(vault, 3000); + poolManager = new CLPoolManager(vault); vault.registerApp(address(poolManager)); permit2 = IAllowanceTransfer(deployPermit2()); @@ -185,14 +184,13 @@ contract CLNativePancakeSwapV4Test is BasePancakeSwapV4 { uint256 liquidity = LiquidityAmounts.getLiquidityForAmounts(SQRT_PRICE_1_1, sqrtRatioAX96, sqrtRatioBX96, 10 ether, 10 ether); // around 1671 e18 liquidity - PositionConfig memory config = PositionConfig({poolKey: key, tickLower: tickLower, tickUpper: tickUpper}); Plan memory mintPlan = Planner.init(); mintPlan.add( Actions.CL_MINT_POSITION, - abi.encode(config, liquidity, type(uint128).max, type(uint128).max, address(this), "") + abi.encode(key, tickLower, tickUpper, liquidity, type(uint128).max, type(uint128).max, address(this), "") ); - bytes memory calls = mintPlan.finalizeModifyLiquidityWithClose(config.poolKey); + bytes memory calls = mintPlan.finalizeModifyLiquidityWithClose(key); positionManager.modifyLiquidities{value: 10 ether}(calls, block.timestamp + 1); } } diff --git a/test/v4/CLPancakeSwapV4.t.sol b/test/v4/CLPancakeSwapV4.t.sol index d84e195..35a2062 100644 --- a/test/v4/CLPancakeSwapV4.t.sol +++ b/test/v4/CLPancakeSwapV4.t.sol @@ -22,7 +22,6 @@ import {ActionConstants} from "pancake-v4-periphery/src/libraries/ActionConstant import {Plan, Planner} from "pancake-v4-periphery/src/libraries/Planner.sol"; import {CLPositionManager} from "pancake-v4-periphery/src/pool-cl/CLPositionManager.sol"; import {Actions} from "pancake-v4-periphery/src/libraries/Actions.sol"; -import {PositionConfig} from "pancake-v4-periphery/src/pool-cl/libraries/PositionConfig.sol"; import {ICLRouterBase} from "pancake-v4-periphery/src/pool-cl/interfaces/ICLRouterBase.sol"; import {LiquidityAmounts} from "pancake-v4-periphery/src/pool-cl/libraries/LiquidityAmounts.sol"; import {PathKey} from "pancake-v4-periphery/src/libraries/PathKey.sol"; @@ -57,7 +56,7 @@ contract CLPancakeSwapV4Test is BasePancakeSwapV4 { function setUp() public { vault = IVault(new Vault()); - poolManager = new CLPoolManager(vault, 3000); + poolManager = new CLPoolManager(vault); vault.registerApp(address(poolManager)); permit2 = IAllowanceTransfer(deployPermit2()); @@ -338,14 +337,13 @@ contract CLPancakeSwapV4Test is BasePancakeSwapV4 { uint256 liquidity = LiquidityAmounts.getLiquidityForAmounts(SQRT_PRICE_1_1, sqrtRatioAX96, sqrtRatioBX96, 10 ether, 10 ether); // around 1671 e18 liquidity - PositionConfig memory config = PositionConfig({poolKey: key, tickLower: tickLower, tickUpper: tickUpper}); Plan memory mintPlan = Planner.init(); mintPlan.add( Actions.CL_MINT_POSITION, - abi.encode(config, liquidity, type(uint128).max, type(uint128).max, address(this), "") + abi.encode(key, tickLower, tickUpper, liquidity, type(uint128).max, type(uint128).max, address(this), "") ); - bytes memory calls = mintPlan.finalizeModifyLiquidityWithClose(config.poolKey); + bytes memory calls = mintPlan.finalizeModifyLiquidityWithClose(key); positionManager.modifyLiquidities(calls, block.timestamp + 1); } } From 6154fa7460ad8b3abe385af1d002bd1fa3d3e72a Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:58:54 +0800 Subject: [PATCH 03/10] feat: updated v4-periphery --- lib/pancake-v4-periphery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pancake-v4-periphery b/lib/pancake-v4-periphery index e0f3aa7..37c16f2 160000 --- a/lib/pancake-v4-periphery +++ b/lib/pancake-v4-periphery @@ -1 +1 @@ -Subproject commit e0f3aa779f2d414d8d7b9bbf853889cdb82d0573 +Subproject commit 37c16f29a4fdf3ef7a5ecd493cc1ff29a2e2f940 From 13efe2467b45eedb0da916a1f959a24dd570e6c9 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:09:10 +0800 Subject: [PATCH 04/10] feat: update code based on latest commit --- ...test_v4BinSwap_ExactInSingle_NativeIn.snap | 2 +- ...actInSingle_NativeOut_RouterRecipient.snap | 2 +- ...apV4Test#test_v4BinSwap_ExactInSingle.snap | 2 +- ...4Test#test_v4BinSwap_ExactIn_MultiHop.snap | 2 +- ...Test#test_v4BinSwap_ExactIn_SingleHop.snap | 2 +- ...Test#test_v4BinSwap_ExactOut_MultiHop.snap | 2 +- ...est#test_v4BinSwap_ExactOut_SingleHop.snap | 2 +- ...apV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...#test_v4ClSwap_ExactInSingle_NativeIn.snap | 2 +- ...test_v4ClSwap_ExactInSingle_NativeOut.snap | 2 +- ...wapV4Test#test_v4ClSwap_ExactInSingle.snap | 2 +- ...V4Test#test_v4ClSwap_ExactIn_MultiHop.snap | 2 +- ...4Test#test_v4ClSwap_ExactIn_SingleHop.snap | 2 +- ...apV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...4Test#test_v4ClSwap_ExactOut_MultiHop.snap | 2 +- ...Test#test_v4ClSwap_ExactOut_SingleHop.snap | 2 +- ...wapV3Test#test_v3Swap_ExactInput0For1.snap | 2 +- ...apV3Test#test_v3Swap_exactOutput0For1.snap | 2 +- .../UniversalRouterBytecodeSize.snap | 2 +- ...#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ..._v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...ositionmanager_BinAddLiquidity_Native.snap | 2 +- ...ionTest#test_v4CLPositionmanager_Mint.snap | 2 +- src/libraries/BytesLib.sol | 28 +++++++++++++++++-- 24 files changed, 49 insertions(+), 25 deletions(-) diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap index 9b0db55..45d3689 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -145965 \ No newline at end of file +146358 \ No newline at end of file diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap index 2f37e1a..8979a84 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap @@ -1 +1 @@ -122888 \ No newline at end of file +123415 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap index 540f2cc..c293da0 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap @@ -1 +1 @@ -146927 \ No newline at end of file +147320 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap index f1ec03a..d0845ab 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -178336 \ No newline at end of file +178729 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap index 5cdbace..1762821 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -148721 \ No newline at end of file +149114 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap index 8d1563a..fa6f8f5 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -182177 \ No newline at end of file +182570 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap index 94eec8a..22cacea 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -153094 \ No newline at end of file +153487 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index 716e770..f6fccfa 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -151306 \ No newline at end of file +151699 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap index 04fa8f6..68bd635 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -171967 \ No newline at end of file +172360 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap index 0acd0df..ce5c174 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap @@ -1 +1 @@ -174217 \ No newline at end of file +174610 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap index fe812b4..f1a6d10 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap @@ -1 +1 @@ -181316 \ No newline at end of file +181709 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap index 0580928..24abf7c 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -246631 \ No newline at end of file +247024 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap index 3f4c0c6..e43e64d 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -182857 \ No newline at end of file +183250 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index 6d5a537..c73c044 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -185655 \ No newline at end of file +186048 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap index 3009198..55d6385 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -250390 \ No newline at end of file +250783 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap index 3b7a5b6..4077297 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -187189 \ No newline at end of file +187582 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap index 7d0a76b..78f1ad0 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap @@ -1 +1 @@ -151906 \ No newline at end of file +151799 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap index 141cf29..fd87bb3 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap @@ -1 +1 @@ -152784 \ No newline at end of file +152677 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index 5e90e8a..c522624 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -23825 \ No newline at end of file +24025 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index da17240..c6eae9f 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -558567 \ No newline at end of file +559387 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index e656853..e1d204b 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -593340 \ No newline at end of file +594200 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 789110b..fea99dc 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -569182 \ No newline at end of file +570042 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index 6616267..8a2650e 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -582733 \ No newline at end of file +583553 \ No newline at end of file diff --git a/src/libraries/BytesLib.sol b/src/libraries/BytesLib.sol index 0b51305..5ea34eb 100755 --- a/src/libraries/BytesLib.sol +++ b/src/libraries/BytesLib.sol @@ -22,6 +22,30 @@ library BytesLib { } } + /// @notice Decode the `_arg`-th element in `_bytes` as a dynamic array + /// @dev The decoding of `length` and `offset` is universal, + /// whereas the type declaration of `res` instructs the compiler how to read it. + /// @param _bytes The input bytes string to slice + /// @param _arg The index of the argument to extract + /// @return length Length of the array + /// @return offset Pointer to the data part of the array + function toLengthOffset(bytes calldata _bytes, uint256 _arg) + internal + pure + returns (uint256 length, uint256 offset) + { + uint256 relativeOffset; + assembly { + // The offset of the `_arg`-th element is `32 * arg`, which stores the offset of the length pointer. + // shl(5, x) is equivalent to mul(32, x) + let lengthPtr := add(_bytes.offset, calldataload(add(_bytes.offset, shl(5, _arg)))) + length := calldataload(lengthPtr) + offset := add(lengthPtr, 0x20) + relativeOffset := sub(offset, _bytes.offset) + } + if (_bytes.length < length + relativeOffset) revert SliceOutOfBounds(); + } + /// @notice Returns the pool details starting at byte 0 /// @dev length and overflow checks must be carried out before calling /// @param _bytes The input bytes string to slice @@ -42,7 +66,7 @@ library BytesLib { /// @param _bytes The input bytes string to extract an address array from /// @param _arg The index of the argument to extract function toAddressArray(bytes calldata _bytes, uint256 _arg) internal pure returns (address[] calldata res) { - (uint256 length, uint256 offset) = _bytes.toLengthOffset(_arg); + (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg); assembly { res.length := length res.offset := offset @@ -53,7 +77,7 @@ library BytesLib { /// @param _bytes The input bytes string to extract an uint array from /// @param _arg The index of the argument to extract function toUintArray(bytes calldata _bytes, uint256 _arg) internal pure returns (uint256[] calldata res) { - (uint256 length, uint256 offset) = _bytes.toLengthOffset(_arg); + (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg); assembly { res.length := length res.offset := offset From 2b1f44cb89d996571962a80e2841de13f9c295ad Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:11:15 +0800 Subject: [PATCH 05/10] chore: clean up commented code --- test/V3ToV4Migration.t.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/test/V3ToV4Migration.t.sol b/test/V3ToV4Migration.t.sol index d18b740..283cf76 100644 --- a/test/V3ToV4Migration.t.sol +++ b/test/V3ToV4Migration.t.sol @@ -288,7 +288,6 @@ contract V3ToV4MigrationTest is BasePancakeSwapV4, OldVersionHelper, BinLiquidit token1.mint(address(router), 10 ether); // prep position manager action: mint/ settle/ settle - // PositionConfig memory positionConfig = PositionConfig({poolKey: clPoolKey, tickLower: -120, tickUpper: 120}); Plan memory planner = Planner.init(); planner.add(Actions.CL_MINT_POSITION, abi.encode(clPoolKey, -120, 120, 1 ether, 10 ether, 10 ether, alice, "")); planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router From dfa33a6dc90ae79a13293f2b0a97bf6d8d4ff3e3 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:57:03 +0800 Subject: [PATCH 06/10] feat: #8 return early --- ...test_v4BinSwap_ExactInSingle_NativeIn.snap | 2 +- ...actInSingle_NativeOut_RouterRecipient.snap | 2 +- ...apV4Test#test_v4BinSwap_ExactInSingle.snap | 2 +- ...4Test#test_v4BinSwap_ExactIn_MultiHop.snap | 2 +- ...Test#test_v4BinSwap_ExactIn_SingleHop.snap | 2 +- ...Test#test_v4BinSwap_ExactOut_MultiHop.snap | 2 +- ...est#test_v4BinSwap_ExactOut_SingleHop.snap | 2 +- ...apV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...#test_v4ClSwap_ExactInSingle_NativeIn.snap | 2 +- ...test_v4ClSwap_ExactInSingle_NativeOut.snap | 2 +- ...wapV4Test#test_v4ClSwap_ExactInSingle.snap | 2 +- ...V4Test#test_v4ClSwap_ExactIn_MultiHop.snap | 2 +- ...4Test#test_v4ClSwap_ExactIn_SingleHop.snap | 2 +- ...apV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...4Test#test_v4ClSwap_ExactOut_MultiHop.snap | 2 +- ...Test#test_v4ClSwap_ExactOut_SingleHop.snap | 2 +- ...wapV2Test#test_v2Swap_exactInput0For1.snap | 2 +- ...apV2Test#test_v2Swap_exactOutput0For1.snap | 2 +- ...wapV3Test#test_v3Swap_ExactInput0For1.snap | 2 +- ...apV3Test#test_v3Swap_exactOutput0For1.snap | 2 +- ...pTest#test_stableSwap_ExactInput0For1.snap | 2 +- ...pTest#test_stableSwap_ExactInput1For0.snap | 2 +- .../UniversalRouterBytecodeSize.snap | 2 +- .../UniversalRouterTest#test_sweep_token.snap | 2 +- ...#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...ationTest#test_v3PositionManager_burn.snap | 2 +- ..._v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...ositionmanager_BinAddLiquidity_Native.snap | 2 +- ...ionTest#test_v4CLPositionmanager_Mint.snap | 2 +- src/base/Dispatcher.sol | 21 +++++++++++++++++++ 30 files changed, 50 insertions(+), 29 deletions(-) diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap index 45d3689..1844a0a 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -146358 \ No newline at end of file +146304 \ No newline at end of file diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap index 8979a84..1b3cf48 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap @@ -1 +1 @@ -123415 \ No newline at end of file +123362 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap index c293da0..fc5260b 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap @@ -1 +1 @@ -147320 \ No newline at end of file +147266 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap index d0845ab..66daf69 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -178729 \ No newline at end of file +178676 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap index 1762821..413bc40 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -149114 \ No newline at end of file +149062 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap index fa6f8f5..f91f4ae 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -182570 \ No newline at end of file +182517 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap index 22cacea..333e317 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -153487 \ No newline at end of file +153435 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index f6fccfa..39744d8 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -151699 \ No newline at end of file +151645 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap index 68bd635..94dde0f 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -172360 \ No newline at end of file +172308 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap index ce5c174..9b1ca5e 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap @@ -1 +1 @@ -174610 \ No newline at end of file +174558 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap index f1a6d10..9640776 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap @@ -1 +1 @@ -181709 \ No newline at end of file +181657 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap index 24abf7c..a797307 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -247024 \ No newline at end of file +246971 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap index e43e64d..3495a44 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -183250 \ No newline at end of file +183197 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index c73c044..385c3b7 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -186048 \ No newline at end of file +185996 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap index 55d6385..dd5fdb0 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -250783 \ No newline at end of file +250730 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap index 4077297..d710aea 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -187582 \ No newline at end of file +187529 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactInput0For1.snap b/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactInput0For1.snap index 90b45b4..dfed1e4 100644 --- a/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactInput0For1.snap +++ b/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactInput0For1.snap @@ -1 +1 @@ -100147 \ No newline at end of file +100125 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactOutput0For1.snap b/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactOutput0For1.snap index b0ac48d..5f918e2 100644 --- a/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactOutput0For1.snap +++ b/.forge-snapshots/PancakeSwapV2Test#test_v2Swap_exactOutput0For1.snap @@ -1 +1 @@ -117028 \ No newline at end of file +100754 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap index 78f1ad0..3d7ea4e 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap @@ -1 +1 @@ -151799 \ No newline at end of file +151862 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap index fd87bb3..56302cc 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap @@ -1 +1 @@ -152677 \ No newline at end of file +152658 \ No newline at end of file diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap index cf74b44..0386c0a 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap @@ -1 +1 @@ -193217 \ No newline at end of file +193198 \ No newline at end of file diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap index 0055f2d..c823d60 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap @@ -1 +1 @@ -192673 \ No newline at end of file +192654 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index c522624..5c5821e 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -24025 \ No newline at end of file +24137 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap b/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap index 492b3fb..fbc1fd2 100644 --- a/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap +++ b/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap @@ -1 +1 @@ -55442 \ No newline at end of file +55452 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index c6eae9f..336a9d4 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -559387 \ No newline at end of file +559360 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v3PositionManager_burn.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v3PositionManager_burn.snap index 7dce0ea..0b72187 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v3PositionManager_burn.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v3PositionManager_burn.snap @@ -1 +1 @@ -291669 \ No newline at end of file +291590 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index e1d204b..d33e05d 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -594200 \ No newline at end of file +594213 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index fea99dc..4e92467 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -570042 \ No newline at end of file +570015 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index 8a2650e..12c0dea 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -583553 \ No newline at end of file +583566 \ No newline at end of file diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index 9fbfb6f..fbc279e 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -81,6 +81,7 @@ abstract contract Dispatcher is bytes calldata path = inputs.toBytes(3); address payer = payerIsUser ? msgSender() : address(this); v3SwapExactInput(map(recipient), amountIn, amountOutMin, path, payer); + return (success, output); } else if (command == Commands.V3_SWAP_EXACT_OUT) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool)) address recipient; @@ -97,6 +98,7 @@ abstract contract Dispatcher is bytes calldata path = inputs.toBytes(3); address payer = payerIsUser ? msgSender() : address(this); v3SwapExactOutput(map(recipient), amountOut, amountInMax, path, payer); + return (success, output); } else if (command == Commands.PERMIT2_TRANSFER_FROM) { // equivalent: abi.decode(inputs, (address, address, uint160)) address token; @@ -108,6 +110,7 @@ abstract contract Dispatcher is amount := calldataload(add(inputs.offset, 0x40)) } permit2TransferFrom(token, msgSender(), map(recipient), amount); + return (success, output); } else if (command == Commands.PERMIT2_PERMIT_BATCH) { IAllowanceTransfer.PermitBatch calldata permitBatch; assembly { @@ -128,6 +131,7 @@ abstract contract Dispatcher is amountMin := calldataload(add(inputs.offset, 0x40)) } Payments.sweep(token, map(recipient), amountMin); + return (success, output); } else if (command == Commands.TRANSFER) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; @@ -139,6 +143,7 @@ abstract contract Dispatcher is value := calldataload(add(inputs.offset, 0x40)) } Payments.pay(token, map(recipient), value); + return (success, output); } else if (command == Commands.PAY_PORTION) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; @@ -150,6 +155,7 @@ abstract contract Dispatcher is bips := calldataload(add(inputs.offset, 0x40)) } Payments.payPortion(token, map(recipient), bips); + return (success, output); } else { // placeholder area for command 0x07 revert InvalidCommandType(command); @@ -172,6 +178,7 @@ abstract contract Dispatcher is address[] calldata path = inputs.toAddressArray(3); address payer = payerIsUser ? msgSender() : address(this); v2SwapExactInput(map(recipient), amountIn, amountOutMin, path, payer); + return (success, output); } else if (command == Commands.V2_SWAP_EXACT_OUT) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool)) address recipient; @@ -188,6 +195,7 @@ abstract contract Dispatcher is address[] calldata path = inputs.toAddressArray(3); address payer = payerIsUser ? msgSender() : address(this); v2SwapExactOutput(map(recipient), amountOut, amountInMax, path, payer); + return (success, output); } else if (command == Commands.PERMIT2_PERMIT) { // equivalent: abi.decode(inputs, (IAllowanceTransfer.PermitSingle, bytes)) IAllowanceTransfer.PermitSingle calldata permitSingle; @@ -196,6 +204,7 @@ abstract contract Dispatcher is } bytes calldata data = inputs.toBytes(6); // PermitSingle takes first 6 slots (0..5) PERMIT2.permit(msgSender(), permitSingle, data); + return (success, output); } else if (command == Commands.WRAP_ETH) { // equivalent: abi.decode(inputs, (address, uint256)) address recipient; @@ -205,6 +214,7 @@ abstract contract Dispatcher is amount := calldataload(add(inputs.offset, 0x20)) } Payments.wrapETH(map(recipient), amount); + return (success, output); } else if (command == Commands.UNWRAP_WETH) { // equivalent: abi.decode(inputs, (address, uint256)) address recipient; @@ -214,6 +224,7 @@ abstract contract Dispatcher is amountMin := calldataload(add(inputs.offset, 0x20)) } Payments.unwrapWETH9(map(recipient), amountMin); + return (success, output); } else if (command == Commands.PERMIT2_TRANSFER_FROM_BATCH) { IAllowanceTransfer.AllowanceTransferDetails[] calldata batchDetails; (uint256 length, uint256 offset) = inputs.toLengthOffset(0); @@ -222,6 +233,7 @@ abstract contract Dispatcher is batchDetails.offset := offset } permit2TransferFrom(batchDetails, msgSender()); + return (success, output); } else if (command == Commands.BALANCE_CHECK_ERC20) { // equivalent: abi.decode(inputs, (address, address, uint256)) address owner; @@ -234,6 +246,7 @@ abstract contract Dispatcher is } success = (ERC20(token).balanceOf(owner) >= minBalance); if (!success) output = abi.encodePacked(BalanceTooLow.selector); + return (success, output); } else { // placeholder area for command 0x0f revert InvalidCommandType(command); @@ -244,6 +257,7 @@ abstract contract Dispatcher is if (command == Commands.V4_SWAP) { // pass the calldata provided to V4SwapRouter._executeActions (defined in BaseActionsRouter) _executeActions(inputs); + return (success, output); // This contract MUST be approved to spend the token since its going to be doing the call on the position manager } else if (command == Commands.V3_POSITION_MANAGER_PERMIT) { bytes4 selector; @@ -255,6 +269,7 @@ abstract contract Dispatcher is } (success, output) = address(V3_POSITION_MANAGER).call(inputs); + return (success, output); } else if (command == Commands.V3_POSITION_MANAGER_CALL) { bytes4 selector; assembly { @@ -279,14 +294,17 @@ abstract contract Dispatcher is } (success, output) = address(V3_POSITION_MANAGER).call(inputs); + return (success, output); } else if (command == Commands.V4_CL_POSITION_CALL) { // should only call modifyLiquidities() with Actions.CL_MINT_POSITION // do not permit or approve this contract over a v4 position or someone could use this command to decrease, burn, or transfer your position (success, output) = address(V4_CL_POSITION_MANAGER).call{value: address(this).balance}(inputs); + return (success, output); } else if (command == Commands.V4_BIN_POSITION_CALL) { // should only call modifyLiquidities() with Actions.BIN_ADD_LIQUIDITY // do not permit or approve this contract over a v4 position or someone could use this command to decrease, burn, or transfer your position (success, output) = address(V4_BIN_POSITION_MANAGER).call{value: address(this).balance}(inputs); + return (success, output); } else { // placeholder area for commands 0x15-0x20 revert InvalidCommandType(command); @@ -297,6 +315,7 @@ abstract contract Dispatcher is if (command == Commands.EXECUTE_SUB_PLAN) { (bytes calldata _commands, bytes[] calldata _inputs) = inputs.decodeCommandsAndInputs(); (success, output) = (address(this)).call(abi.encodeCall(Dispatcher.execute, (_commands, _inputs))); + return (success, output); } else if (command == Commands.STABLE_SWAP_EXACT_IN) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bytes, bool)) address recipient; @@ -314,6 +333,7 @@ abstract contract Dispatcher is uint256[] calldata flag = inputs.toUintArray(4); address payer = payerIsUser ? msgSender() : address(this); stableSwapExactInput(map(recipient), amountIn, amountOutMin, path, flag, payer); + return (success, output); } else if (command == Commands.STABLE_SWAP_EXACT_OUT) { // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bytes, bool)) address recipient; @@ -334,6 +354,7 @@ abstract contract Dispatcher is /// @dev structured this way as stack too deep by Yul uint256 amountIn = stableSwapExactOutputAmountIn(amountOut, amountInMax, path, flag); stableSwapExactOutput(map(recipient), amountIn, amountOut, path, flag, payer); + return (success, output); } else { // placeholder area for commands 0x24-0x3f revert InvalidCommandType(command); From a0dbda77628620e21b7ee05e9f7149b4490ce56d Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:13:04 +0800 Subject: [PATCH 07/10] feat: add missing early return for 1 command --- .forge-snapshots/UniversalRouterBytecodeSize.snap | 2 +- .forge-snapshots/UniversalRouterTest#test_sweep_token.snap | 2 +- ...igrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...onTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap | 2 +- .../V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap | 2 +- src/base/Dispatcher.sol | 1 + 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index 5c5821e..4cdd517 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -24137 \ No newline at end of file +24108 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap b/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap index fbc1fd2..0efb7fb 100644 --- a/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap +++ b/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap @@ -1 +1 @@ -55452 \ No newline at end of file +55428 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index 336a9d4..43f8a2a 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -559360 \ No newline at end of file +559336 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index d33e05d..1c644c8 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -594213 \ No newline at end of file +594165 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 4e92467..6c91c9a 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -570015 \ No newline at end of file +569991 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index 12c0dea..fff8307 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -583566 \ No newline at end of file +583518 \ No newline at end of file diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index fbc279e..58e98b6 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -120,6 +120,7 @@ abstract contract Dispatcher is } bytes calldata data = inputs.toBytes(1); PERMIT2.permit(msgSender(), permitBatch, data); + return (success, output); } else if (command == Commands.SWEEP) { // equivalent: abi.decode(inputs, (address, address, uint256)) address token; From cc2d2e23eb04cb67054702a5db8609e6df0f5f2c Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:02:53 +0800 Subject: [PATCH 08/10] chore: forge-test after merge --- ...PancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap | 2 +- ...#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap | 2 +- .../BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap | 2 +- .../BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap | 2 +- .../BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap | 2 +- .../BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap | 2 +- .../BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap | 2 +- .../BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- ...ePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap | 2 +- ...PancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap | 2 +- .../CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap | 2 +- .../PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap | 2 +- .../PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap | 2 +- .forge-snapshots/UniversalRouterBytecodeSize.snap | 2 +- ...igrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...onTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap | 2 +- .../V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap index b1b80c7..1844a0a 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -146304 +146304 \ No newline at end of file diff --git a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap index 424cad8..1b3cf48 100644 --- a/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap +++ b/.forge-snapshots/BinNativePancakeSwapV4Test#test_v4BinSwap_ExactInSingle_NativeOut_RouterRecipient.snap @@ -1 +1 @@ -123362 +123362 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap index 8406451..fc5260b 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactInSingle.snap @@ -1 +1 @@ -147266 +147266 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap index decfaa0..66daf69 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -178676 +178676 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap index 9f1cc74..413bc40 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -149062 +149062 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap index b641fb5..f91f4ae 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -182517 +182517 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap index ea13f03..333e317 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4BinSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -153435 +153435 \ No newline at end of file diff --git a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index 28106b5..39744d8 100644 --- a/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/BinPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -151645 +151645 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap index 3fc77ff..94dde0f 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeIn.snap @@ -1 +1 @@ -172308 +172308 \ No newline at end of file diff --git a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap index a22e607..9b1ca5e 100644 --- a/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap +++ b/.forge-snapshots/CLNativePancakeSwapV4Test#test_v4ClSwap_ExactInSingle_NativeOut.snap @@ -1 +1 @@ -174558 +174558 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap index 2ce21b7..9640776 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactInSingle.snap @@ -1 +1 @@ -181657 +181657 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap index 3dc38b2..a797307 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_MultiHop.snap @@ -1 +1 @@ -246971 +246971 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap index ff34e20..3495a44 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactIn_SingleHop.snap @@ -1 +1 @@ -183197 +183197 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap index 4d2c32f..385c3b7 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOutSingle.snap @@ -1 +1 @@ -185996 +185996 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap index ba56247..dd5fdb0 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_MultiHop.snap @@ -1 +1 @@ -250730 +250730 \ No newline at end of file diff --git a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap index c908e95..d710aea 100644 --- a/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap +++ b/.forge-snapshots/CLPancakeSwapV4Test#test_v4ClSwap_ExactOut_SingleHop.snap @@ -1 +1 @@ -187529 +187529 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap index 2527dcf..3d7ea4e 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_ExactInput0For1.snap @@ -1 +1 @@ -151862 +151862 \ No newline at end of file diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap index c210874..56302cc 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap @@ -1 +1 @@ -152658 +152658 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index ec1c14f..4cdd517 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -24108 +24108 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index 1fa96da..43f8a2a 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -559336 +559336 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index 6dd4c9c..1c644c8 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -594165 +594165 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 3cf5a6f..6c91c9a 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -569991 +569991 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index 93d597f..fff8307 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -583518 +583518 \ No newline at end of file From 51be189f3df31108ee40a5fb8b1257a0afdc3d80 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:07:48 +0800 Subject: [PATCH 09/10] feat: move invalidCommandType revert out of if-else --- ...wapTest#test_stableSwap_ExactInput0For1.snap | 2 +- ...wapTest#test_stableSwap_ExactInput1For0.snap | 2 +- .../UniversalRouterBytecodeSize.snap | 2 +- ...st#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...st_v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...nPositionmanager_BinAddLiquidity_Native.snap | 2 +- ...ationTest#test_v4CLPositionmanager_Mint.snap | 2 +- src/base/Dispatcher.sol | 17 +++++------------ 8 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap index 0386c0a..612ad57 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap @@ -1 +1 @@ -193198 \ No newline at end of file +193207 \ No newline at end of file diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap index c823d60..eae79b6 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap @@ -1 +1 @@ -192654 \ No newline at end of file +192663 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index 4cdd517..3657f89 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -24108 \ No newline at end of file +24168 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index 43f8a2a..e39cb60 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -559336 \ No newline at end of file +559351 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index 1c644c8..25ae5d9 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -594165 \ No newline at end of file +594181 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 6c91c9a..496ea9a 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -569991 \ No newline at end of file +570007 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index fff8307..23dd0ab 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -583518 \ No newline at end of file +583533 \ No newline at end of file diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index 58e98b6..029e8b9 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -157,10 +157,8 @@ abstract contract Dispatcher is } Payments.payPortion(token, map(recipient), bips); return (success, output); - } else { - // placeholder area for command 0x07 - revert InvalidCommandType(command); } + // placeholder area for command 0x07 } else { // 0x08 <= command < 0x10 if (command == Commands.V2_SWAP_EXACT_IN) { @@ -248,10 +246,8 @@ abstract contract Dispatcher is success = (ERC20(token).balanceOf(owner) >= minBalance); if (!success) output = abi.encodePacked(BalanceTooLow.selector); return (success, output); - } else { - // placeholder area for command 0x0f - revert InvalidCommandType(command); } + // placeholder area for command 0x0f } } else { // 0x10 <= command < 0x21 @@ -306,10 +302,8 @@ abstract contract Dispatcher is // do not permit or approve this contract over a v4 position or someone could use this command to decrease, burn, or transfer your position (success, output) = address(V4_BIN_POSITION_MANAGER).call{value: address(this).balance}(inputs); return (success, output); - } else { - // placeholder area for commands 0x15-0x20 - revert InvalidCommandType(command); } + // placeholder area for commands 0x15-0x20 } } else { // 0x21 <= command @@ -356,11 +350,10 @@ abstract contract Dispatcher is uint256 amountIn = stableSwapExactOutputAmountIn(amountOut, amountInMax, path, flag); stableSwapExactOutput(map(recipient), amountIn, amountOut, path, flag, payer); return (success, output); - } else { - // placeholder area for commands 0x24-0x3f - revert InvalidCommandType(command); } + // placeholder area for commands 0x24-0x3f } + revert InvalidCommandType(command); } /// @notice Calculates the recipient address for a command From 41c82abc556152aead373b03e6cba7186da840f9 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:54:58 +0800 Subject: [PATCH 10/10] test: updated snapshot --- .../PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap | 2 +- .../StableSwapTest#test_stableSwap_ExactInput0For1.snap | 2 +- .../StableSwapTest#test_stableSwap_ExactInput1For0.snap | 2 +- .forge-snapshots/UniversalRouterBytecodeSize.snap | 2 +- .forge-snapshots/UniversalRouterTest#test_sweep_token.snap | 2 +- ...igrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap | 2 +- ...MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap | 2 +- ...onTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap | 2 +- .../V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap index c210874..73d7c6c 100644 --- a/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap +++ b/.forge-snapshots/PancakeSwapV3Test#test_v3Swap_exactOutput0For1.snap @@ -1 +1 @@ -152658 +152659 \ No newline at end of file diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap index 9fa3daa..612ad57 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput0For1.snap @@ -1 +1 @@ -193207 +193207 \ No newline at end of file diff --git a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap index 71f1e6e..eae79b6 100644 --- a/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap +++ b/.forge-snapshots/StableSwapTest#test_stableSwap_ExactInput1For0.snap @@ -1 +1 @@ -192663 +192663 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterBytecodeSize.snap b/.forge-snapshots/UniversalRouterBytecodeSize.snap index 71128ee..452efc2 100644 --- a/.forge-snapshots/UniversalRouterBytecodeSize.snap +++ b/.forge-snapshots/UniversalRouterBytecodeSize.snap @@ -1 +1 @@ -24168 +24220 \ No newline at end of file diff --git a/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap b/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap index 89b3d19..63f357d 100644 --- a/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap +++ b/.forge-snapshots/UniversalRouterTest#test_sweep_token.snap @@ -1 +1 @@ -55428 +55441 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap index 6fd4f6f..4ec305b 100644 --- a/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationNativeTest#test_v4CLPositionmanager_Mint_Native.snap @@ -1 +1 @@ -559351 +559388 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap index e9f9c53..00914cc 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity.snap @@ -1 +1 @@ -594181 +594207 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap index 8af97cb..70693ec 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4BinPositionmanager_BinAddLiquidity_Native.snap @@ -1 +1 @@ -570007 +570044 \ No newline at end of file diff --git a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap index 0dd7107..9fceaba 100644 --- a/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap +++ b/.forge-snapshots/V3ToV4MigrationTest#test_v4CLPositionmanager_Mint.snap @@ -1 +1 @@ -583533 +583559 \ No newline at end of file