// SPDX-License-Identifier: UNLICENSED pragma solidity =0.8.18; import "../SomaAccessControl/utils/Accessible.sol"; import "../TemplateFactory/TemplateDeployer.sol"; import "./ISomaEarn.sol"; import "./ISomaEarnFactory.sol"; /** * @notice Implementation of the {ISomaEarnFactory} interface. */ contract SomaEarnFactory is ISomaEarnFactory, Accessible, TemplateDeployer { /** * @inheritdoc ISomaEarnFactory */ bytes32 public constant override CREATE_ROLE = keccak256("SomaEarn.CREATE_ROLE"); constructor(uint256 templateVersion) TemplateDeployer(bytes32("SomaEarn"), templateVersion) {} /** * @inheritdoc ISomaEarnFactory */ function create(address asset, address withdrawTo, uint48 startDate, uint48 endDate) external override onlyRole(CREATE_ROLE) { uint256 index = totalDeployments(); address instance = _deploy(bytes32(index)); ISomaEarn(instance).initialize(index, asset, withdrawTo, startDate, endDate); emit SomaEarnCreated(index, asset, instance); } }