// SPDX-License-Identifier: MIT pragma solidity =0.8.18; /** * @title SOMA Swap Factory Contract. * @author SOMA.finance * @notice Interface for the {SomaSwapFactory} contract. */ interface ISomaSwapFactory { /** * @notice Emitted when a pair is created via `createPair()`. * @param token0 The address of token0. * @param token1 The address of token1. * @param pair The address of the created pair. */ event PairCreated(address indexed token0, address indexed token1, address pair, uint256); /** * @notice Emitted when the `feeTo` address is updated from `prevFeeTo` to `newFeeTo` by `sender`. * @param prevFeeTo The address of the previous fee to. * @param prevFeeTo The address of the new fee to. * @param sender The address of the message sender. */ event FeeToUpdated(address indexed prevFeeTo, address indexed newFeeTo, address indexed sender); /** * @notice Emitted when a router is added by `sender`. * @param router The address of the router added. * @param sender The address of the message sender. */ event RouterAdded(address indexed router, address indexed sender); /** * @notice Emitted when a router is removed by `sender`. * @param router The address of the router removed. * @param sender The address of the message sender. */ event RouterRemoved(address indexed router, address indexed sender); /** * @notice Returns SOMA Swap Factory Create Pair Role. * @dev Returns `keccak256('SomaSwapFactory.CREATE_PAIR_ROLE')`. */ function CREATE_PAIR_ROLE() external pure returns (bytes32); /** * @notice Returns SOMA Swap Factory Fee Setter Role. * @dev Returns `keccak256('SomaSwapFactory.FEE_SETTER_ROLE')`. */ function FEE_SETTER_ROLE() external pure returns (bytes32); /** * @notice Returns SOMA Swap Factory Manage Router Role. * @dev Returns `keccak256('SomaSwapFactory.MANAGE_ROUTER_ROLE')`. */ function MANAGE_ROUTER_ROLE() external pure returns (bytes32); /** * @notice Returns the address where fees from the exchange get transferred to. */ function feeTo() external view returns (address); /** * @notice Returns the address of the pair contract for tokenA and tokenB if it exists, else returns address(0). * @dev Returns the address of the pair for `tokenA` and `tokenB` if it exists, else returns `address(0)`. * @param tokenA The token0 of the pair. * @param tokenB The token1 of the pair. * @return pair The address of the pair. */ function getPair(address tokenA, address tokenB) external view returns (address pair); /** * @notice Returns the nth pair created through the factory, or address(0). * @dev Returns the `n-th` pair (0 indexed) created through the factory, or `address(0)`. * @return pair The address of the pair. */ function allPairs(uint256) external view returns (address pair); /** * @notice Returns the total number of pairs created through the factory so far. */ function allPairsLength() external view returns (uint256); /** * @notice Returns True if an address is an existing router, else returns False. * @param target The address to return true if it an existing router, or false if it is not. * @return Boolean value indicating if the address is an existing router. */ function isRouter(address target) external view returns (bool); /** * @notice Adds an address as a new router. A router is able to tell a pair who is swapping. * @param router The address to add as a new router. * @custom:emits RouterAdded * @custom:requirement The function caller must have the MANAGE_ROUTER_ROLE. */ function addRouter(address router) external; /** * @notice Removes an address from the list of routers. A router is able to tell a pair who is swapping. * @param router The address to remove from the list of routers. * @custom:emits RouterRemoved * @custom:requirement The function caller must have the MANAGE_ROUTER_ROLE. */ function removeRouter(address router) external; /** * @notice Creates a new pair. * @dev Creates a pair for `tokenA` and `tokenB` if one does not exist already. * @param tokenA The address of token0 of the pair. * @param tokenB The address of token1 of the pair. * @custom:emits PairCreated * @custom:requirement The function caller must have the CREATE_PAIR_ROLE. * @custom:requirement `tokenA` must not be equal to `tokenB`. * @custom:requirement `tokenA` must not be equal to `address(0)`. * @custom:requirement `tokenA` and `tokenB` must not be an existing pair. * @custom:requirement The system must not be paused. * @return pair The address of the pair created. */ function createPair(address tokenA, address tokenB) external returns (address pair); /** * @notice Sets a new `feeTo` address. * @param _feeTo The new address to receive the protocol fees. * @custom:emits FeeToUpdated * @custom:requirement The function caller must have the FEE_SETTER_ROLE. * @custom:requirement The system must not be paused. */ function setFeeTo(address _feeTo) external; }