Pool Factory
The SyncSwap Classic Pool Factory contract is responsible for creating and managing Classic Pools within the SyncSwap ecosystem. It interacts with the Pool Master to ensure that newly created pools are properly registered and conform to the expected standards.
Methods
constructor
constructorconstructor(address _master) BasePoolFactory(_master) {
}Initializes the Classic Pool Factory with the address of the Pool Master contract.
_createPool
_createPoolfunction _createPool(address token0, address token1) internal override returns (address pool) {
// Perform sanity checks.
IERC20(token0).balanceOf(address(this));
IERC20(token1).balanceOf(address(this));
bytes memory deployData = abi.encode(token0, token1);
cachedDeployData = deployData;
// The salt is same with deployment data.
bytes32 salt = keccak256(deployData);
pool = address(new SyncSwapClassicPool{salt: salt}()); // this will prevent duplicated pools.
// Register the pool. The config is same with deployment data.
IPoolMaster(master).registerPool(pool, 1, deployData, token0, token1);
}Internal function that creates a new Classic Pool with the given token pair. It performs necessary sanity checks and ensures that the pool is registered with the Pool Master.
getDeployData
getDeployDataReturns the deployment data for the pool being created.
getSwapFee
getSwapFeeReturns the swap fee for a given pool and token pair.
createPool
createPoolCreates a new pool with the provided data and registers it with the Pool Master.
Events
PoolCreated
PoolCreatedEmitted when a new pool is created.
SetFactoryWhitelisted
SetFactoryWhitelistedEmitted when a factory's whitelist status is updated.
RegisterPool
RegisterPoolEmitted when a new pool is registered.
UpdateForwarderRegistry
UpdateForwarderRegistryEmitted when the forwarder registry is updated.
UpdateFeeManager
UpdateFeeManagerEmitted when the fee manager is updated.
Example Usage
Creating a New Classic Pool
To create a new Classic Pool, the following steps are typically followed:
Initialize the factory with the Pool Master address.
Call the
createPoolfunction with the desired token pair.The factory will handle the rest, ensuring the new pool is registered and compliant with the Pool Master.
Example:
Last updated