Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/EulerSwapFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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)))
)
)
Expand Down
12 changes: 12 additions & 0 deletions test/FactoryTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 1 addition & 9 deletions test/utils/HookMiner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
);
}
}