generated from transmissions11/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create3Factory.sol
31 lines (24 loc) · 1.13 KB
/
Create3Factory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import "solmate/utils/CREATE3.sol";
import "solmate/auth/Owned.sol";
interface ICreate3Factory {
function deploy(bytes32 salt, bytes memory creationCode) external payable returns (address deployed);
function getAddress(address deployer, bytes32 salt) external view returns (address deployed);
}
interface IClone {
function initialize(address _wethAddress, uint256 _uintOne, uint256 _uintTwo) external returns (address);
}
contract Create3Factory is Owned, ICreate3Factory {
constructor(address owner) Owned(owner) {}
function deploy(bytes32 salt, bytes memory creationCode) external payable override returns (address deployed) {
// salt is combined with the msg sender
salt = keccak256(abi.encodePacked(msg.sender, salt));
return CREATE3.deploy(salt, creationCode, msg.value);
}
function getAddress(address deployer, bytes32 salt) external view override returns (address deployed) {
// salt is combined with the msg sender
salt = keccak256(abi.encodePacked(deployer, salt));
return CREATE3.getDeployed(salt);
}
}