all files / contracts/products/ ProductFactory.sol

100% Statements 8/8
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                                                                    146× 146×                 110× 110×                                                   27× 26×                 20× 20×    
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;
 
import "./SolaceMarketProduct.sol";
import "../utils//Factory.sol";
import "../interfaces/products/IProductFactory.sol";
 
/**
 * @title ProductFactory
 * @author solace.fi
 * @notice The **ProductFactory** manages the creation of new products.
 */
contract ProductFactory is Factory, IProductFactory {
    /**
     * @notice Creates and initializes a new product.
     * @param base_ The product's source code.
     * @param governance_ The governor.
     * @param registry_ The IRegistry contract.
     * @param minPeriod_ The minimum policy period in blocks to purchase a **policy**.
     * @param maxPeriod_ The maximum policy period in blocks to purchase a **policy**.
     * @param typehash_ The typehash for submitting claims.
     * @param domain_ The user readable name of the EIP712 signing domain.
     * @param version_ The current major version of the signing domain.
     */
    function createProduct(
        address base_,
        address governance_,
        IRegistry registry_,
        uint40 minPeriod_,
        uint40 maxPeriod_,
        bytes32 typehash_,
        string memory domain_,
        string memory version_
    ) external override returns (address product) {
        product = _deployMinimalProxy(base_);
        SolaceMarketProduct(payable(product)).initialize(
            governance_,
            registry_,
            minPeriod_,
            maxPeriod_,
            typehash_,
            domain_,
            version_
        );
        emit ProductCreated(product);
        return product;
    }
 
    /**
     * @notice Creates and initializes a new product.
     * @param base_ The product's source code.
     * @param salt_ The salt for CREATE2.
     * @param governance_ The governor.
     * @param registry_ The IRegistry contract.
     * @param minPeriod_ The minimum policy period in blocks to purchase a **policy**.
     * @param maxPeriod_ The maximum policy period in blocks to purchase a **policy**.
     * @param typehash_ The typehash for submitting claims.
     * @param domain_ The user readable name of the EIP712 signing domain.
     * @param version_ The current major version of the signing domain.
     */
    function create2Product(
        address base_,
        bytes32 salt_,
        address governance_,
        IRegistry registry_,
        uint40 minPeriod_,
        uint40 maxPeriod_,
        bytes32 typehash_,
        string memory domain_,
        string memory version_
    ) external override returns (address product) {
        product = _deployMinimalProxy(base_, salt_);
        SolaceMarketProduct(payable(product)).initialize(
            governance_,
            registry_,
            minPeriod_,
            maxPeriod_,
            typehash_,
            domain_,
            version_
        );
        emit ProductCreated(product);
        return product;
    }
}