There will be one Pool Factory for each type of pool, and the factory will be used to create pools for the pool type. The factory implementations will then register the newly created pool to the Pool Master.
Interface
// The standard interface.
interface IPoolFactory {
function master() external view returns (address);
function getDeployData() external view returns (bytes memory);
// Call the function with data to create a pool.
// For base pool factories, the data is as follows.
// `(address tokenA, address tokenB) = abi.decode(data, (address, address));`
function createPool(bytes calldata data) external returns (address pool);
}
// The interface for base pools has two tokens.
interface IBasePoolFactory is IPoolFactory {
event PoolCreated(
address indexed token0,
address indexed token1,
address pool
);
function getPool(address tokenA, address tokenB) external view returns (address pool);
// [Deprecated] This is the interface before the dynamic fees update.
// This function will forward calls to the pool master.
//function getSwapFee(address pool) external view returns (uint24 swapFee);
// [Recommended] This is the latest interface.
// This function will forward calls to the pool master.
function getSwapFee(
address pool,
address sender,
address tokenIn,
address tokenOut,
bytes calldata data
) external view override returns (uint24 swapFee) {
swapFee = IPoolMaster(master).getSwapFee(pool, sender, tokenIn, tokenOut, data);
}
}