-
Notifications
You must be signed in to change notification settings - Fork 26
/
MetaMorphoFactory.sol
57 lines (43 loc) · 1.67 KB
/
MetaMorphoFactory.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;
import {IMetaMorpho} from "./interfaces/IMetaMorpho.sol";
import {IMetaMorphoFactory} from "./interfaces/IMetaMorphoFactory.sol";
import {EventsLib} from "./libraries/EventsLib.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {MetaMorpho} from "./MetaMorpho.sol";
/// @title MetaMorphoFactory
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice This contract allows to create MetaMorpho vaults, and to index them easily.
contract MetaMorphoFactory is IMetaMorphoFactory {
/* IMMUTABLES */
/// @inheritdoc IMetaMorphoFactory
address public immutable MORPHO;
/* STORAGE */
/// @inheritdoc IMetaMorphoFactory
mapping(address => bool) public isMetaMorpho;
/* CONSTRUCTOR */
/// @dev Initializes the contract.
/// @param morpho The address of the Morpho contract.
constructor(address morpho) {
if (morpho == address(0)) revert ErrorsLib.ZeroAddress();
MORPHO = morpho;
}
/* EXTERNAL */
/// @inheritdoc IMetaMorphoFactory
function createMetaMorpho(
address initialOwner,
uint256 initialTimelock,
address asset,
string memory name,
string memory symbol,
bytes32 salt
) external returns (IMetaMorpho metaMorpho) {
metaMorpho =
IMetaMorpho(address(new MetaMorpho{salt: salt}(initialOwner, MORPHO, initialTimelock, asset, name, symbol)));
isMetaMorpho[address(metaMorpho)] = true;
emit EventsLib.CreateMetaMorpho(
address(metaMorpho), msg.sender, initialOwner, initialTimelock, asset, name, symbol, salt
);
}
}