Skip to content
Verified contractPartialMIT

FactoryController

Address0xf71173ba73f6fb9464f03c010c44f84da5fcb07b
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 10,000 runs
EVM version
cancun
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,090,960
Creation transaction
0xe6b257aea2…170121c77b

src/FactoryController.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {IFactoryController} from "src/interfaces/IFactoryController.sol";
import {IOwnableFactory} from "src/interfaces/IOwnableFactory.sol";

/// @title FactoryController
/// @author Exodus
/// @notice Governance layer for PaymentFactory and SubscriptionManagerFactory contracts.
/// Implements role-based access control with timelocks for high-risk actions.
///
/// Security model:
/// - Core (via CoreTimelock, 48h): ownership transfers, role changes, factory registration
/// - Ops (via OpsTimelock, 24h): addToken, setCloner, unpause
/// - Guardian (direct, no timelock): pause new deployments only
/// - Live payments remain merchant-controlled — this contract has NO access to capture/refund/rescue
///
/// Pull-based pause model: Factories query `controller.paused()` when deploying payments.
/// The controller does NOT push pause state to factories; this eliminates cascade failures
/// and DoS vectors from malicious factories in the registry. Factories check the controller
/// pause state in addition to their own local pause flag.
///
/// @dev This contract owns per-merchant factories. The factories' Ownable2Step pattern
/// requires a two-step transfer: this contract calls `transferOwnership`, then the new
/// owner calls `acceptOwnership`. For factories remaining under controller governance,
/// use `registerFactory` after the factory's original owner calls `transferOwnership(controller)`.
// aderyn-fp-next-line(centralization-risk): governance contract; owner is CoreTimelock (48h delay), not EOA
contract FactoryController is Ownable2Step, IFactoryController {
  using EnumerableSet for EnumerableSet.AddressSet;

  address public coreTimelock;
  address public pendingCoreTimelock;
  address public opsTimelock;
  address public guardian;
  bool public paused;

  EnumerableSet.AddressSet private _registeredFactories;

  modifier onlyCore() {
    _checkCore();
    _;
  }

  modifier onlyOps() {
    _checkOps();
    _;
  }

  // aderyn-fp-next-line(modifier-used-only-once): intentional; guardian role only pauses (single function)
  modifier onlyGuardian() {
    _checkGuardian();
    _;
  }

  modifier onlyRegistered(
    address factory
  ) {
    _checkRegistered(factory);
    _;
  }

  modifier whenNotPaused() {
    _checkNotPaused();
    _;
  }

  function _checkCore() internal view {
    if (msg.sender != coreTimelock) revert NotCore();
  }

  function _checkOps() internal view {
    if (msg.sender != opsTimelock) revert NotOps();
  }

  function _checkGuardian() internal view {
    if (msg.sender != guardian) revert NotGuardian();
  }

  function _checkRegistered(
    address factory
  ) internal view {
    if (!_registeredFactories.contains(factory)) revert FactoryNotRegistered(factory);
  }

  function _checkNotPaused() internal view {
    if (paused) revert DeploymentsPausedError();
  }

  /// @param coreTimelock_ Address with Core role access (typically OZ TimelockController with 48h delay).
  /// @param opsTimelock_ Address with Ops role access (typically OZ TimelockController with 24h delay).
  /// @param guardian_ Address with Guardian role access (typically 2-of-7 Safe, no timelock).
  /// @dev The controller itself is owned by coreTimelock_ for self-governance actions via Ownable2Step.
  // slither-disable-start missing-zero-check
  constructor(
    address coreTimelock_,
    address opsTimelock_,
    address guardian_
  ) Ownable(_requireNonZero(coreTimelock_)) {
    // slither-disable-end missing-zero-check
    if (opsTimelock_ == address(0)) revert ZeroAddress();
    if (guardian_ == address(0)) revert ZeroAddress();

    // aderyn-fp-next-line(state-no-address-check): checked via _requireNonZero in Ownable() call
    coreTimelock = coreTimelock_;
    opsTimelock = opsTimelock_;
    guardian = guardian_;
  }

  function _requireNonZero(
    address addr
  ) private pure returns (address) {
    if (addr == address(0)) revert ZeroAddress();
    return addr;
  }

  // =========================================================================
  // Guardian functions (no timelock)
  // =========================================================================

  /// @notice Pause new deployments on all registered factories. Emergency response only.
  /// @dev Does NOT affect live payments — capture/refund/rescue remain merchant-controlled.
  /// Pull-based model: sets controller.paused = true; factories query this when deploying.
  /// No cascade loop — factories check controller.paused() in their deploy functions.
  function pauseDeployments() external onlyGuardian {
    // aderyn-fp(centralization-risk): guardian-only pause; does not affect live payments
    if (paused) revert DeploymentsPausedError();
    paused = true;
    emit DeploymentsPaused(msg.sender);
  }

  // =========================================================================
  // Ops functions (via OpsTimelock)
  // =========================================================================

  /// @notice Resume deployments on all registered factories after a pause.
  /// @dev Pull-based model: sets controller.paused = false; factories query this when deploying.
  function unpauseDeployments() external onlyOps {
    // aderyn-fp(centralization-risk): ops-only unpause via timelock
    if (!paused) revert DeploymentsNotPaused();
    paused = false;
    emit DeploymentsUnpaused(msg.sender);
  }

  /// @notice Add a token to a factory's whitelist (uses factory's canonical decimals).
  /// @param factory The PaymentFactory address.
  /// @param token The ERC20 token to whitelist.
  /// @dev Emits decimals=255 as sentinel indicating the factory's default was used.
  /// The factory's own TokenAdded event contains the actual decimals applied.
  // slither-disable-next-line reentrancy-events
  function addTokenToFactory(
    address factory,
    address token
  ) external onlyOps onlyRegistered(factory) whenNotPaused {
    IOwnableFactory(factory).addToken(token);
    emit TokenAddedToFactory(factory, token, type(uint8).max);
  }

  /// @notice Add a token to a factory's whitelist with explicit decimals.
  /// @param factory The PaymentFactory address.
  /// @param token The ERC20 token to whitelist.
  /// @param decimals The token's decimals (must be >= 6).
  // slither-disable-next-line reentrancy-events
  function addTokenToFactory(
    address factory,
    address token,
    uint8 decimals
  ) external onlyOps onlyRegistered(factory) whenNotPaused {
    IOwnableFactory(factory).addToken(token, decimals);
    emit TokenAddedToFactory(factory, token, decimals);
  }

  /// @notice Set the cloner address on a factory (PaymentFactoryFactory or SubscriptionManagerFactory).
  /// @dev Not paused-gated: cloner rotation is the primary remediation for a compromised relayer,
  /// which is the likeliest trigger for a Guardian pause. Blocking rotation during pause would
  /// prevent fixing the very issue the pause was meant to contain.
  /// @param factory The factory address.
  /// @param newCloner The new cloner address (typically the API relayer).
  // slither-disable-next-line reentrancy-events
  function setClonerOnFactory(
    address factory,
    address newCloner
  ) external onlyOps onlyRegistered(factory) {
    IOwnableFactory(factory).setCloner(newCloner);
    emit ClonerUpdatedOnFactory(factory, newCloner);
  }

  // =========================================================================
  // Core functions (via CoreTimelock)
  // =========================================================================

  /// @notice Start ownership transfer of a factory to a new owner and unregister it atomically.
  /// @dev The new owner must call `acceptOwnership()` on the factory to complete the transfer.
  /// This function atomically removes the factory from the registry to prevent orphaned entries
  /// (factories that appear registered but are no longer owned by this controller).
  /// Recovery: Core can re-register via `registerFactory` if the new owner transfers back.
  /// @param factory The factory address.
  /// @param newOwner The new owner address.
  // slither-disable-next-line reentrancy-events,unused-return
  function transferFactoryOwnership(
    address factory,
    address newOwner
  ) external onlyCore onlyRegistered(factory) {
    if (newOwner == address(0)) revert ZeroAddress();
    // aderyn-fp-next-line(unchecked-return): return value irrelevant; factory guaranteed registered by onlyRegistered modifier
    _registeredFactories.remove(factory);
    IOwnableFactory(factory).transferOwnership(newOwner);
    emit FactoryUnregistered(factory);
    emit FactoryOwnershipTransferStarted(factory, newOwner);
  }

  /// @notice Register a factory under controller governance.
  /// @dev If the factory is already owned by this controller, it is simply added to the registry.
  /// Otherwise, the factory must have already called `transferOwnership(address(this))` and
  /// this function will accept the pending ownership.
  /// Note: the factory only queries controller.paused() if it was deployed/initialized with
  /// this controller's address. Legacy factories (controller=address(0)) or factories pointing
  /// to a different controller won't respect this controller's pause state.
  /// @param factory The factory address to register.
  // slither-disable-next-line reentrancy-events,unused-return
  function registerFactory(
    address factory
  ) external onlyCore {
    if (factory == address(0)) revert ZeroAddress();
    if (_registeredFactories.contains(factory)) revert FactoryAlreadyRegistered(factory);

    address currentOwner = IOwnableFactory(factory).owner();
    if (currentOwner != address(this)) {
      IOwnableFactory(factory).acceptOwnership();
      if (IOwnableFactory(factory).owner() != address(this)) {
        revert OwnershipTransferFailed(factory);
      }
    }

    // aderyn-fp-next-line(unchecked-return): return checked by prior contains() call
    _registeredFactories.add(factory);
    emit FactoryRegistered(factory);
  }

  /// @notice Unregister a factory from controller governance.
  /// @dev This only removes the factory from the registry. Use `transferFactoryOwnership`
  /// first if you want to transfer ownership to another address.
  /// @param factory The factory address.
  // slither-disable-next-line unused-return
  function unregisterFactory(
    address factory
  ) external onlyCore onlyRegistered(factory) {
    // aderyn-fp-next-line(unchecked-return): return checked by onlyRegistered modifier
    _registeredFactories.remove(factory);
    emit FactoryUnregistered(factory);
  }

  /// @notice Propose a new Core timelock address. Two-step handover to prevent bricking.
  /// @dev The new Core timelock must call acceptCoreTimelock() to complete the transfer.
  /// @param newCoreTimelock The proposed new Core timelock address.
  // aderyn-fp-next-line(centralization-risk): core-only via 48h timelock; self-governance config
  function proposeCoreTimelock(
    address newCoreTimelock
  ) external onlyCore {
    if (newCoreTimelock == address(0)) revert ZeroAddress();
    pendingCoreTimelock = newCoreTimelock;
    emit CoreTimelockProposed(coreTimelock, newCoreTimelock);
  }

  /// @notice Accept the pending Core timelock role. Called by the proposed new Core.
  /// @dev Completes the two-step Core handover. Also transfers Ownable ownership.
  function acceptCoreTimelock() external {
    if (msg.sender != pendingCoreTimelock) revert NotPendingCore();
    emit CoreTimelockUpdated(coreTimelock, pendingCoreTimelock);
    coreTimelock = pendingCoreTimelock;
    _transferOwnership(pendingCoreTimelock);
    pendingCoreTimelock = address(0);
  }

  /// @notice Update the Ops timelock address.
  /// @param newOpsTimelock The new Ops timelock address.
  // aderyn-fp-next-line(centralization-risk): core-only via 48h timelock; self-governance config
  function setOpsTimelock(
    address newOpsTimelock
  ) external onlyCore {
    if (newOpsTimelock == address(0)) revert ZeroAddress();
    emit OpsTimelockUpdated(opsTimelock, newOpsTimelock);
    opsTimelock = newOpsTimelock;
  }

  /// @notice Update the Guardian address.
  /// @param newGuardian The new Guardian address.
  // aderyn-fp-next-line(centralization-risk): core-only via 48h timelock; self-governance config
  function setGuardian(
    address newGuardian
  ) external onlyCore {
    if (newGuardian == address(0)) revert ZeroAddress();
    emit GuardianUpdated(guardian, newGuardian);
    guardian = newGuardian;
  }

  // =========================================================================
  // Permissionless
  // =========================================================================

  /// @notice Accept pending ownership of a factory (does NOT add to registry).
  /// @dev Anyone can call this to complete a two-step ownership transfer.
  /// Useful after the controller itself calls `transferOwnership` on a factory
  /// with `newOwner = address(this)` (e.g., after a factory version upgrade).
  /// NOTE: This does NOT register the factory. Use `registerFactory` (Core-only)
  /// to add it to the registry. This separation prevents registry poisoning DoS.
  /// @param factory The factory address.
  function acceptFactoryOwnership(
    address factory
  ) external {
    if (factory == address(0)) revert ZeroAddress();
    IOwnableFactory(factory).acceptOwnership();
  }

  // =========================================================================
  // Ownable2Step Overrides
  // =========================================================================

  /// @notice Disabled — use proposeCoreTimelock/acceptCoreTimelock instead.
  /// @dev Reverts to prevent accidental use of the inherited Ownable2Step pattern.
  function transferOwnership(
    address
  ) public pure override {
    revert UseProposeCoreTimelock();
  }

  /// @notice Disabled — ownership renouncement is forbidden.
  /// @dev Reverts to prevent bricking the controller.
  function renounceOwnership() public pure override {
    revert OwnershipRenounceForbidden();
  }

  // =========================================================================
  // Views
  // =========================================================================

  /// @notice Check if a factory is registered under controller governance.
  /// @param factory The factory address.
  /// @return True if registered.
  function isFactoryRegistered(
    address factory
  ) external view returns (bool) {
    return _registeredFactories.contains(factory);
  }

  /// @notice Get all registered factories.
  /// @return Array of factory addresses.
  function getRegisteredFactories() external view returns (address[] memory) {
    return _registeredFactories.values();
  }
}

dependencies/@openzeppelin-contracts-5.2.0/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

dependencies/@openzeppelin-contracts-5.2.0/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

dependencies/@openzeppelin-contracts-5.2.0/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

dependencies/@openzeppelin-contracts-5.2.0/utils/structs/EnumerableSet.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._positions[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We cache the value's position to prevent multiple reads from the same storage slot
        uint256 position = set._positions[value];

        if (position != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 valueIndex = position - 1;
            uint256 lastIndex = set._values.length - 1;

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._positions[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        assembly ("memory-safe") {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly ("memory-safe") {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly ("memory-safe") {
            result := store
        }

        return result;
    }
}

src/interfaces/IFactoryController.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

interface IFactoryController {
  // -- Events --

  event DeploymentsPaused(address indexed guardian);
  event DeploymentsUnpaused(address indexed ops);
  event FactoryRegistered(address indexed factory);
  event FactoryUnregistered(address indexed factory);
  event TokenAddedToFactory(address indexed factory, address indexed token, uint8 decimals);
  event FactoryOwnershipTransferStarted(address indexed factory, address indexed pendingOwner);
  event ClonerUpdatedOnFactory(address indexed factory, address indexed newCloner);
  event CoreTimelockProposed(address indexed currentCore, address indexed proposedCore);
  event CoreTimelockUpdated(address indexed previousCore, address indexed newCore);
  event OpsTimelockUpdated(address indexed previousOps, address indexed newOps);
  event GuardianUpdated(address indexed previousGuardian, address indexed newGuardian);

  // -- Errors --

  error ZeroAddress();
  error NotCore();
  error NotOps();
  error NotGuardian();
  error NotPendingCore();
  error DeploymentsPausedError();
  error DeploymentsNotPaused();
  error FactoryNotRegistered(address factory);
  error FactoryAlreadyRegistered(address factory);
  error OwnershipTransferFailed(address factory);
  error UseProposeCoreTimelock();
  error OwnershipRenounceForbidden();

  // -- Guardian functions (no timelock) --

  function pauseDeployments() external;

  // -- Ops functions (via OpsTimelock) --

  function unpauseDeployments() external;
  function addTokenToFactory(
    address factory,
    address token
  ) external;
  function addTokenToFactory(
    address factory,
    address token,
    uint8 decimals
  ) external;
  function setClonerOnFactory(
    address factory,
    address newCloner
  ) external;

  // -- Core functions (via CoreTimelock) --

  function transferFactoryOwnership(
    address factory,
    address newOwner
  ) external;
  function registerFactory(
    address factory
  ) external;
  function unregisterFactory(
    address factory
  ) external;
  function proposeCoreTimelock(
    address newCoreTimelock
  ) external;
  function acceptCoreTimelock() external;
  function setOpsTimelock(
    address newOpsTimelock
  ) external;
  function setGuardian(
    address newGuardian
  ) external;

  // -- Permissionless --

  function acceptFactoryOwnership(
    address factory
  ) external;

  // -- Views --

  function coreTimelock() external view returns (address);
  function pendingCoreTimelock() external view returns (address);
  function opsTimelock() external view returns (address);
  function guardian() external view returns (address);
  function paused() external view returns (bool);
  function isFactoryRegistered(
    address factory
  ) external view returns (bool);
  function getRegisteredFactories() external view returns (address[] memory);
}

src/interfaces/IOwnableFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

interface IOwnableFactory {
  function owner() external view returns (address);
  function transferOwnership(
    address newOwner
  ) external;
  function acceptOwnership() external;
  function addToken(
    address token
  ) external;
  function addToken(
    address token,
    uint8 decimals
  ) external;
  function setCloner(
    address newCloner
  ) external;
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 10000,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=dependencies/forge-std-1.9.7/src/",
    "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.2.0/",
    "@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
    "@openzeppelin-contracts-5.2.0/=dependencies/@openzeppelin-contracts-5.2.0/",
    "@openzeppelin-contracts-upgradeable-5.2.0/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
    "forge-std-1.9.7/=dependencies/forge-std-1.9.7/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.