From 59a0f83db7671551b323d7479da8d99bc0f90130 Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Tue, 29 Apr 2025 00:53:42 -0400 Subject: [PATCH 1/2] combining eulerAccount with salt is no longer necessary --- src/EulerSwapFactory.sol | 4 ++-- test/FactoryTest.t.sol | 12 ++++++++++++ test/utils/HookMiner.sol | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/EulerSwapFactory.sol b/src/EulerSwapFactory.sol index 0cec8fb..5a97309 100644 --- a/src/EulerSwapFactory.sol +++ b/src/EulerSwapFactory.sol @@ -62,7 +62,7 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil, ProtocolFee { EulerSwap pool = EulerSwap( MetaProxyDeployer.deployMetaProxy( - eulerSwapImpl, abi.encode(params), keccak256(abi.encode(params.eulerAccount, salt)) + eulerSwapImpl, abi.encode(params), salt ) ); @@ -91,7 +91,7 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil, ProtocolFee { abi.encodePacked( bytes1(0xff), address(this), - keccak256(abi.encode(poolParams.eulerAccount, salt)), + salt, keccak256(MetaProxyDeployer.creationCodeMetaProxy(eulerSwapImpl, abi.encode(poolParams))) ) ) diff --git a/test/FactoryTest.t.sol b/test/FactoryTest.t.sol index 628cd8c..1ef4ee2 100644 --- a/test/FactoryTest.t.sol +++ b/test/FactoryTest.t.sol @@ -53,6 +53,18 @@ contract FactoryTest is EulerSwapTestBase { (hookAddress, salt) = HookMiner.find(address(eulerSwapFactory), holder, flags, creationCode); } + function testDifferingAddressesSameSalt() public view { + (IEulerSwap.Params memory poolParams,) = getBasicParams(); + + address a1 = eulerSwapFactory.computePoolAddress(poolParams, bytes32(0)); + + poolParams.eulerAccount = address(123); + + address a2 = eulerSwapFactory.computePoolAddress(poolParams, bytes32(0)); + + assert(a1 != a2); + } + function testDeployPool() public { uint256 allPoolsLengthBefore = eulerSwapFactory.poolsLength(); diff --git a/test/utils/HookMiner.sol b/test/utils/HookMiner.sol index 0bcdf88..6f44774 100644 --- a/test/utils/HookMiner.sol +++ b/test/utils/HookMiner.sol @@ -53,7 +53,7 @@ library HookMiner { uint256( keccak256( abi.encodePacked( - bytes1(0xFF), deployer, keccak256(abi.encode(account, salt)), keccak256(creationCode) + bytes1(0xFF), deployer, salt, keccak256(creationCode) ) ) ) From 1e0402d2717b68588089014133ac08c78b065cdc Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Tue, 29 Apr 2025 00:55:22 -0400 Subject: [PATCH 2/2] forge fmt --- src/EulerSwapFactory.sol | 6 +----- test/utils/HookMiner.sol | 10 +--------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/EulerSwapFactory.sol b/src/EulerSwapFactory.sol index 5a97309..c427819 100644 --- a/src/EulerSwapFactory.sol +++ b/src/EulerSwapFactory.sol @@ -60,11 +60,7 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil, ProtocolFee { uninstall(params.eulerAccount); - EulerSwap pool = EulerSwap( - MetaProxyDeployer.deployMetaProxy( - eulerSwapImpl, abi.encode(params), salt - ) - ); + EulerSwap pool = EulerSwap(MetaProxyDeployer.deployMetaProxy(eulerSwapImpl, abi.encode(params), salt)); updateEulerAccountState(params.eulerAccount, address(pool)); diff --git a/test/utils/HookMiner.sol b/test/utils/HookMiner.sol index 6f44774..1b28a84 100644 --- a/test/utils/HookMiner.sol +++ b/test/utils/HookMiner.sol @@ -49,15 +49,7 @@ library HookMiner { returns (address hookAddress) { return address( - uint160( - uint256( - keccak256( - abi.encodePacked( - bytes1(0xFF), deployer, salt, keccak256(creationCode) - ) - ) - ) - ) + uint160(uint256(keccak256(abi.encodePacked(bytes1(0xFF), deployer, salt, keccak256(creationCode))))) ); } }