diff --git a/src/EulerSwapFactory.sol b/src/EulerSwapFactory.sol index 0cec8fb..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), keccak256(abi.encode(params.eulerAccount, salt)) - ) - ); + EulerSwap pool = EulerSwap(MetaProxyDeployer.deployMetaProxy(eulerSwapImpl, abi.encode(params), salt)); updateEulerAccountState(params.eulerAccount, address(pool)); @@ -91,7 +87,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..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, keccak256(abi.encode(account, salt)), keccak256(creationCode) - ) - ) - ) - ) + uint160(uint256(keccak256(abi.encodePacked(bytes1(0xFF), deployer, salt, keccak256(creationCode))))) ); } }