IPoolManagerFactory
Creates a new pool manager associated with a defined UniswapV3 pool
The UniswapV3 pool needs to be a pool deployed by the current UniswapV3 factory. The pool might or might not already exist (the correct deterministic address is checked but not called).
Functions
UNISWAP_V3_FACTORY
Returns the UniswapV3 factory contract
function UNISWAP_V3_FACTORY() external view returns (IUniswapV3Factory _uniswapV3Factory);
Returns
Name | Type | Description |
---|---|---|
_uniswapV3Factory | IUniswapV3Factory | The UniswapV3 factory contract |
POOL_BYTECODE_HASH
Returns the UniswapV3 pool bytecode hash
function POOL_BYTECODE_HASH() external view returns (bytes32 _poolBytecodeHash);
Returns
Name | Type | Description |
---|---|---|
_poolBytecodeHash | bytes32 | The UniswapV3 pool bytecode hash |
STRATEGY_SETTER_ROLE
The role that allows changing the Strategy
function STRATEGY_SETTER_ROLE() external view returns (bytes32);
FACTORY_SETTER_ROLE
The role that allows changing the lock manager factory
function FACTORY_SETTER_ROLE() external view returns (bytes32);
MIGRATOR_SETTER_ROLE
The role that allows changing the pool manager migrator address
function MIGRATOR_SETTER_ROLE() external view returns (bytes32);
PRICE_ORACLE_SETTER_ROLE
The role that allows changing the price oracle address
function PRICE_ORACLE_SETTER_ROLE() external view returns (bytes32);
FEE_MANAGER_SETTER_ROLE
The role that allows changing the fee manager address
function FEE_MANAGER_SETTER_ROLE() external view returns (bytes32);
FEE_COLLECTOR_SETTER_ROLE
The role that allows changing the fee collector job
function FEE_COLLECTOR_SETTER_ROLE() external view returns (bytes32);
MIN_ETH_AMOUNT_SETTER_ROLE
The role that allows changing the min ETH amount to create a PoolManager
function MIN_ETH_AMOUNT_SETTER_ROLE() external view returns (bytes32);
WETH
Returns the WETH token contract
function WETH() external view returns (IERC20 _weth);
Returns
Name | Type | Description |
---|---|---|
_weth | IERC20 | The WETH token contract |
strategy
Returns the strategy registry
function strategy() external view returns (IStrategy _strategy);
Returns
Name | Type | Description |
---|---|---|
_strategy | IStrategy | The strategy registry |
feeManager
Returns the fee manager
function feeManager() external view returns (IFeeManager _feeManager);
Returns
Name | Type | Description |
---|---|---|
_feeManager | IFeeManager | The fee manager |
childrenCount
Returns the total number of pool managers that this factory has deployed
function childrenCount() external view returns (uint256 _childrenCount);
Returns
Name | Type | Description |
---|---|---|
_childrenCount | uint256 | The total amount of pool managers created by this factory |
feeCollectorJob
Returns the fee collector job
function feeCollectorJob() external view returns (IFeeCollectorJob _feeCollectorJob);
Returns
Name | Type | Description |
---|---|---|
_feeCollectorJob | IFeeCollectorJob | The fee collector job |
lockManagerFactory
Returns the lock manager factory
function lockManagerFactory() external view returns (ILockManagerFactory _lockManagerFactory);
Returns
Name | Type | Description |
---|---|---|
_lockManagerFactory | ILockManagerFactory | The lock manager factory |
POOL_MANAGER_DEPLOYER
Returns the pool manager deployer
function POOL_MANAGER_DEPLOYER() external view returns (IPoolManagerDeployer _poolManagerDeployer);
Returns
Name | Type | Description |
---|---|---|
_poolManagerDeployer | IPoolManagerDeployer | The pool manager deployer |
poolManagerMigrator
Returns the pool manager migrator contract
function poolManagerMigrator() external view returns (address _poolManagerMigrator);
Returns
Name | Type | Description |
---|---|---|
_poolManagerMigrator | address | The pool manager migrator contract |
priceOracle
Returns the price oracle
function priceOracle() external view returns (IPriceOracle _priceOracle);
Returns
Name | Type | Description |
---|---|---|
_priceOracle | IPriceOracle | The price oracle |
minEthAmount
Returns the minimum amount of ETH to create a PoolManager
function minEthAmount() external view returns (uint256 _minEthAmount);
Returns
Name | Type | Description |
---|---|---|
_minEthAmount | uint256 | The minimum amount of ETH |
constructorArguments
Getter for a pool manager params public variable used to initialize a new pool manager factory
This method is called by the pool manager constructor (no parameters are passed not to influence the deterministic address)
function constructorArguments()
external
view
returns (
IUniswapV3Factory uniswapV3Factory,
bytes32 poolBytecodeHash,
IERC20 weth,
IERC20 otherToken,
IFeeManager feeManager,
IPriceOracle priceOracle,
address owner,
uint24 fee,
uint160 sqrtPriceX96
);
Returns
Name | Type | Description |
---|---|---|
uniswapV3Factory | IUniswapV3Factory | Address of the UniswapV3 factory |
poolBytecodeHash | bytes32 | Bytecode hash of the UniswapV3 pool |
weth | IERC20 | The WETH token |
otherToken | IERC20 | The non-WETH token in the UniswapV3 pool address |
feeManager | IFeeManager | The fee manager contract |
priceOracle | IPriceOracle | The price oracle contract |
owner | address | The contracts owner |
fee | uint24 | The UniswapV3 fee tier, as a 10000th of % |
sqrtPriceX96 | uint160 | A sqrt price representing the current pool prices |
isChild
Returns true if this factory deployed the given pool manager
function isChild(IPoolManager _poolManager) external view returns (bool _isChild);
Parameters
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager to be checked |
Returns
Name | Type | Description |
---|---|---|
_isChild | bool | Whether the given pool manager was deployed by this factory |
poolManagers
Returns the address of the pool manager for a given pool, the zero address if there is no pool manager
function poolManagers(IUniswapV3Pool _pool) external view returns (IPoolManager _poolManager);
Parameters
Name | Type | Description |
---|---|---|
_pool | IUniswapV3Pool | The address of the Uniswap V3 pool |
Returns
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The address of the pool manager for a given pool |
children
Returns the list of all the pool managers deployed by this factory
function children(uint256 _index) external view returns (IPoolManager _poolManager);
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | The index of the pool manager |
Returns
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager |
isSupportedPool
Returns true if the pool has a valid pool manager
function isSupportedPool(IUniswapV3Pool _pool) external view returns (bool _isSupportedPool);
Parameters
Name | Type | Description |
---|---|---|
_pool | IUniswapV3Pool | The address of the Uniswap V3 pool |
Returns
Name | Type | Description |
---|---|---|
_isSupportedPool | bool | True if the pool has a pool manager |
isSupportedToken
Returns true if the token has a pool paired with WETH
function isSupportedToken(IERC20 _token) external view returns (bool _isValid);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The non-WETH token paired with WETH |
Returns
Name | Type | Description |
---|---|---|
_isValid | bool | True if the token has a pool paired with WETH |
isSupportedTokenPair
Returns if a specific pair supports routing through WETH
function isSupportedTokenPair(IERC20 _tokenA, IERC20 _tokenB) external view returns (bool _isSupported);
Parameters
Name | Type | Description |
---|---|---|
_tokenA | IERC20 | The tokenA to check paired with tokenB |
_tokenB | IERC20 | The tokenB to check paired with tokenA |
Returns
Name | Type | Description |
---|---|---|
_isSupported | bool | True if the pair is supported |
defaultTokenFee
Returns the default fee to be used for a specific non-WETH token paired with WETH
function defaultTokenFee(IERC20 _token) external view returns (uint24 _fee);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The non-WETH token paired with WETH |
Returns
Name | Type | Description |
---|---|---|
_fee | uint24 | The default fee for the non-WETH token on the WETH/TOKEN pool |
tokenFees
Returns the fee tiers for a specific non-WETH token paired with WETH
function tokenFees(IERC20 _token) external view returns (uint24[] memory _fees);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The token paired with WETH |
Returns
Name | Type | Description |
---|---|---|
_fees | uint24[] | The fee tiers the non-WETH token on the WETH/TOKEN pool |
owner
Returns owner of the contract
function owner() external view returns (address _owner);
Returns
Name | Type | Description |
---|---|---|
_owner | address | The owner of the contract |
pendingOwner
Returns the pending owner
function pendingOwner() external view returns (address _pendingOwner);
Returns
Name | Type | Description |
---|---|---|
_pendingOwner | address | The pending owner of the contract |
POOL_MANAGER_BYTECODE_HASH
Returns the pool manager bytecode hash for deterministic addresses
function POOL_MANAGER_BYTECODE_HASH() external view returns (bytes32 _poolManagerBytecodeHash);
Returns
Name | Type | Description |
---|---|---|
_poolManagerBytecodeHash | bytes32 | The pool manager bytecode hash |
createPoolManager
Deploys a new pool manager for a given UniswapV3 pool if it does not exist yet
function createPoolManager(IERC20 _token, uint24 _fee, uint128 _liquidity, uint160 _sqrtPriceX96)
external
returns (IPoolManager _poolManager);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The non-WETH token paired with WETH in the given pool |
_fee | uint24 | The UniswapV3 pool fee tier, as a 10000th of % |
_liquidity | uint128 | The liquidity to create the pool manager |
_sqrtPriceX96 | uint160 | The sqrt price in base 96 |
Returns
Name | Type | Description |
---|---|---|
_poolManager | IPoolManager | The pool manager newly deployed |
listChildren
Returns pagination of the pool managers deployed by this factory
function listChildren(uint256 _startFrom, uint256 _amount) external view returns (IPoolManager[] memory _list);
Parameters
Name | Type | Description |
---|---|---|
_startFrom | uint256 | Index from where to start the pagination |
_amount | uint256 | Maximum amount of pool managers to retrieve |
Returns
Name | Type | Description |
---|---|---|
_list | IPoolManager[] | Paginated pool managers deployed by this factory |
getPoolManagerAddress
Computes the deterministic address of a given pool manager, a non-WETH token, and the fee
function getPoolManagerAddress(IERC20 _token, uint24 _fee)
external
view
returns (IPoolManager _theoreticalPoolManagerAddress);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The non-WETH token paired with WETH in the pool |
_fee | uint24 | The UniswapV3 fee tier |
Returns
Name | Type | Description |
---|---|---|
_theoreticalPoolManagerAddress | IPoolManager | The theoretical address of the pool manager |
getWethPoolAddress
Computes the deterministic address of a UniswapV3 pool with WETH, given the non-WETH token and its fee tier.
function getWethPoolAddress(IERC20 _token, uint24 _fee)
external
view
returns (IUniswapV3Pool _theoreticalAddress, bool _isWethToken0);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The non-WETH token paired with WETH in the pool |
_fee | uint24 | The UniswapV3 fee tier |
Returns
Name | Type | Description |
---|---|---|
_theoreticalAddress | IUniswapV3Pool | Address of the theoretical address of the UniswapV3 pool |
_isWethToken0 | bool | Defines if WETH is the token0 of the UniswapV3 pool |
getPoolManagers
Lists the existing pool managers for a given token
function getPoolManagers(IERC20 _token, uint24[] memory _feeTiers)
external
view
returns (address[] memory _poolManagerAddresses);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The address of the token |
_feeTiers | uint24[] | The fee tiers to check |
Returns
Name | Type | Description |
---|---|---|
_poolManagerAddresses | address[] | The available pool managers |
setDefaultTokenFee
Sets the default fee for the pool of non-WETH/WETH
function setDefaultTokenFee(IERC20 _token, uint24 _fee) external;
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | The non-WETH token paired with WETH in the pool |
_fee | uint24 | The UniswapV3 fee tier to use |
setStrategy
Sets the new strategy address
function setStrategy(IStrategy _strategy) external;
Parameters
Name | Type | Description |
---|---|---|
_strategy | IStrategy | The new strategy address |
setLockManagerFactory
Sets the new lock manager factory address
function setLockManagerFactory(ILockManagerFactory _lockManagerFactory) external;
Parameters
Name | Type | Description |
---|---|---|
_lockManagerFactory | ILockManagerFactory | The new lock manager factory address |
nominateOwner
Nominates the new owner of the contract
function nominateOwner(address _newOwner) external;
Parameters
Name | Type | Description |
---|---|---|
_newOwner | address | The new owner |
acceptOwnership
Sets a new owner and grants all roles needed to manage the contract
function acceptOwnership() external;
setPoolManagerMigrator
Sets the contract address responsible for migrating
function setPoolManagerMigrator(address _poolManagerMigrator) external;
Parameters
Name | Type | Description |
---|---|---|
_poolManagerMigrator | address | The new pool manager migrator |
setPriceOracle
Sets price oracle contract
function setPriceOracle(IPriceOracle _priceOracle) external;
Parameters
Name | Type | Description |
---|---|---|
_priceOracle | IPriceOracle | The new price oracle |
setFeeManager
Sets the fee manager contract
function setFeeManager(IFeeManager _feeManager) external;
Parameters
Name | Type | Description |
---|---|---|
_feeManager | IFeeManager | The new fee manager |
setFeeCollectorJob
Sets the fee collector job
function setFeeCollectorJob(IFeeCollectorJob _feeCollectorJob) external;
Parameters
Name | Type | Description |
---|---|---|
_feeCollectorJob | IFeeCollectorJob | The new fee collector job |
setMinEthAmount
Sets the minimum ETH amount
function setMinEthAmount(uint256 _minEthAmount) external;
Parameters
Name | Type | Description |
---|---|---|
_minEthAmount | uint256 | The new minimum ETH amount |
Events
LockManagerFactoryChanged
Emitted when the lock manager factory changes
event LockManagerFactoryChanged(ILockManagerFactory _lockManagerFactory);
StrategyChanged
Emitted when the strategy changes
event StrategyChanged(IStrategy _strategy);
OwnerNominated
Emitted when a new owner is nominated
event OwnerNominated(address _owner);
OwnerChanged
Emitted when the owner changes
event OwnerChanged(address _owner);
PoolManagerMigratorChanged
Emitted when the migrator address changes
event PoolManagerMigratorChanged(address _poolManagerMigrator);
FeeManagerChanged
Emitted when the fee manager address changes
event FeeManagerChanged(IFeeManager _feeManager);
PriceOracleChanged
Emitted when the price oracle address changes
event PriceOracleChanged(IPriceOracle _priceOracle);
FeeCollectorJobChanged
Emitted when the fee collector job changes
event FeeCollectorJobChanged(IFeeCollectorJob _feeCollectorJob);
PoolManagerCreated
Emitted when the pool manager is created
event PoolManagerCreated(IPoolManager _poolManager);
MinEthAmountChanged
Emitted when the min ETH amount changes
event MinEthAmountChanged(uint256 _minEthAmount);
Errors
PoolManagerFactory_InvalidPool
Thrown when changing the default fee to a nonexistent pool
error PoolManagerFactory_InvalidPool();
PoolManagerFactory_ExistingPoolManager
Thrown when trying to create a pool manager that was already created
error PoolManagerFactory_ExistingPoolManager();
PoolManagerFactory_ZeroAddress
Thrown when zero address was supplied to a function
error PoolManagerFactory_ZeroAddress();
PoolManagerFactory_InvalidPendingOwner
Thrown when an invalid account tries to accept ownership of the contract
error PoolManagerFactory_InvalidPendingOwner();
PoolManagerFactory_SmallAmount
Thrown when creating a PoolManager with less than the min ETH amount
error PoolManagerFactory_SmallAmount();
PoolManagerFactory_InvalidMinEthAmount
Thrown when trying to set min ETH amount to 0
error PoolManagerFactory_InvalidMinEthAmount();
Structs
PoolManagerParams
Used to pass constructor arguments when deploying new pool (will call msg.sender.constructorArguments()), to avoid having to retrieve them when checking if the sender is a valid pool manager address
struct PoolManagerParams {
IUniswapV3Factory uniswapV3Factory;
bytes32 poolBytecodeHash;
IERC20 weth;
IERC20 otherToken;
IFeeManager feeManager;
IPriceOracle priceOracle;
address owner;
uint24 fee;
uint160 sqrtPriceX96;
}