// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.20; 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 {TestingMetaMorpho} from "./TestingMetaMorpho.sol"; /// @title TestingMetaMorphoFactory /// @author Morpho Labs /// @custom:contact security@morpho.org /// @notice TESTING VERSION: Factory for creating TestingMetaMorpho vaults (no timelock bounds, testnet-only). /// @dev Only deployable on chain ID 31337 (Hardhat) or 31611 (Arbitrum Sepolia). contract TestingMetaMorphoFactory 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) { // TESTING VERSION: Only allow deployment on test networks uint256 chainId = block.chainid; require( chainId == 31337 || chainId == 31611, "Only testnet" ); if (morpho == address(0)) revert ErrorsLib.ZeroAddress(); MORPHO = morpho; } /* EXTERNAL */ /// @inheritdoc IMetaMorphoFactory /// @dev Creates a TestingMetaMorpho vault (no timelock bounds). function createMetaMorpho( address initialOwner, uint256 initialTimelock, address asset, string memory name, string memory symbol, bytes32 salt ) external returns (IMetaMorpho metaMorpho) { metaMorpho = IMetaMorpho( address(new TestingMetaMorpho{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 ); } }