contract UnifarmFactory is Ownable {
    /// @notice using safemath for maticmatics operations in soldity.
    using SafeMath for uint256;

    /// @notice Vested Array to store Multiple Vesting Addresses.
    address[] public vested;

    /// @notice vestToken Address basically UNIFARM TOKEN Address.
    address public vestToken;

    /// @notice event Vested emitted on every createVest.
    event Vested(address vestAddress, uint256 time);

    /**
    @notice construct UnifarmFactory Contract.
    @param vestToken_ vestToken Address. 
     */

    constructor(address vestToken_) Ownable(_msgSender()) {
        vestToken = vestToken_;
    }

    /**
     * @notice create and deploy multiple vest contracts.
     * @notice can be called by onlyOwner.
     * @param startTime vesting startTime in EPOCH.
     * @param endTime vesting endTime in EPOCH.
     * @param cliff duration when claim starts.
     * @param unlockDuration every liner unlocking schedule in seconds.
     * @param allowReleaseAll allow release All once.
     * @return vestAddress A vesting address.
     */

    function createVest(
        uint256 startTime,
        uint256 endTime,
        uint256 cliff,
        uint256 unlockDuration,
        bool allowReleaseAll
    ) external onlyOwner returns (address vestAddress) {
        vestAddress = address(
            new UnifarmVesting(
                _msgSender(),
                startTime.add(cliff),
                startTime,
                startTime.add(endTime),
                unlockDuration,
                allowReleaseAll,
                address(this)
            )
        );

        vested.push(vestAddress);
        emit Vested(vestAddress, block.timestamp);
    }

    /**
    @notice get the vest child contracts length.
    @return length of vested array. 
     */

    function getVestLength() public view returns (uint256) {
        return vested.length;
    }

    /**
    @notice update the vest Token Address.
    @return bool true.
     */

    function updateVestToken(address _newVestToken) external onlyOwner returns (bool) {
        require(_newVestToken != address(0), "new vest token is zero address");
        vestToken = _newVestToken;
        return true;
    }
}
/**
 * @title Unifarm Factory
 * @dev Unifarm factory for deploying different investor vesting contracts with multiple beneficiary functionality.
 * @author Opendefi by Oropocket.
 */
function updateVestToken(address _newVestToken) external onlyOwner returns (bool) {
    require(_newVestToken != address(0), "new vest token is zero address");
    vestToken = _newVestToken;
    return true;
}

/**
 @notice update the vest Token Address.
 @return bool true.
 */