Factory
Inherits: IFactory
Author: typicalHuman.
Factory should be single instance for UX (finding pools for different tokens and for possible routing).
State Variables
s_owner
address immutable s_owner;
s_pools
mapping(address => mapping(address => address)) s_pools;
Functions
constructor
constructor();
createPool
Create new pool with 2 assets.
Pool should be unique (pool with these assets shouldn't be used on this factory yet).
function createPool(address token0, address token1) external returns (address poolAddress);
Parameters
| Name | Type | Description |
|---|---|---|
token0 | address | First asset of the pool. |
token1 | address | Second asset of the pool. |
Returns
| Name | Type | Description |
|---|---|---|
poolAddress | address | Address of newly created pool. |
getPool
Get pool address based on assets.
The order matters.
function getPool(address token0, address token1) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
token0 | address | First asset of the pool. |
token1 | address | Second asset of the pool. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the pool, if not found - returns zero address. |
getProtocolBeneficiary
Get address which will receive protocol fees.
function getProtocolBeneficiary() external view returns (address);
Events
PoolCreated
event PoolCreated(address pool, address token0, address token1);
Errors
TOKENS_NOT_SORTED
error TOKENS_NOT_SORTED();
POOL_ALREADY_EXISTS
error POOL_ALREADY_EXISTS();