Skip to content

Commit d6a30a6

Browse files
authored
Merge pull request #71 from euler-xyz/simplify-salt
Simplify salt
2 parents cd1d8b1 + 1e0402d commit d6a30a6

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/EulerSwapFactory.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil, ProtocolFee {
6060

6161
uninstall(params.eulerAccount);
6262

63-
EulerSwap pool = EulerSwap(
64-
MetaProxyDeployer.deployMetaProxy(
65-
eulerSwapImpl, abi.encode(params), keccak256(abi.encode(params.eulerAccount, salt))
66-
)
67-
);
63+
EulerSwap pool = EulerSwap(MetaProxyDeployer.deployMetaProxy(eulerSwapImpl, abi.encode(params), salt));
6864

6965
updateEulerAccountState(params.eulerAccount, address(pool));
7066

@@ -91,7 +87,7 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil, ProtocolFee {
9187
abi.encodePacked(
9288
bytes1(0xff),
9389
address(this),
94-
keccak256(abi.encode(poolParams.eulerAccount, salt)),
90+
salt,
9591
keccak256(MetaProxyDeployer.creationCodeMetaProxy(eulerSwapImpl, abi.encode(poolParams)))
9692
)
9793
)

test/FactoryTest.t.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ contract FactoryTest is EulerSwapTestBase {
5353
(hookAddress, salt) = HookMiner.find(address(eulerSwapFactory), holder, flags, creationCode);
5454
}
5555

56+
function testDifferingAddressesSameSalt() public view {
57+
(IEulerSwap.Params memory poolParams,) = getBasicParams();
58+
59+
address a1 = eulerSwapFactory.computePoolAddress(poolParams, bytes32(0));
60+
61+
poolParams.eulerAccount = address(123);
62+
63+
address a2 = eulerSwapFactory.computePoolAddress(poolParams, bytes32(0));
64+
65+
assert(a1 != a2);
66+
}
67+
5668
function testDeployPool() public {
5769
uint256 allPoolsLengthBefore = eulerSwapFactory.poolsLength();
5870

test/utils/HookMiner.sol

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,7 @@ library HookMiner {
4949
returns (address hookAddress)
5050
{
5151
return address(
52-
uint160(
53-
uint256(
54-
keccak256(
55-
abi.encodePacked(
56-
bytes1(0xFF), deployer, keccak256(abi.encode(account, salt)), keccak256(creationCode)
57-
)
58-
)
59-
)
60-
)
52+
uint160(uint256(keccak256(abi.encodePacked(bytes1(0xFF), deployer, salt, keccak256(creationCode)))))
6153
);
6254
}
6355
}

0 commit comments

Comments
 (0)