IPoolManagerFactory

Git Source

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

NameTypeDescription
_uniswapV3FactoryIUniswapV3FactoryThe UniswapV3 factory contract

POOL_BYTECODE_HASH

Returns the UniswapV3 pool bytecode hash

function POOL_BYTECODE_HASH() external view returns (bytes32 _poolBytecodeHash);

Returns

NameTypeDescription
_poolBytecodeHashbytes32The 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

NameTypeDescription
_wethIERC20The WETH token contract

strategy

Returns the strategy registry

function strategy() external view returns (IStrategy _strategy);

Returns

NameTypeDescription
_strategyIStrategyThe strategy registry

feeManager

Returns the fee manager

function feeManager() external view returns (IFeeManager _feeManager);

Returns

NameTypeDescription
_feeManagerIFeeManagerThe fee manager

childrenCount

Returns the total number of pool managers that this factory has deployed

function childrenCount() external view returns (uint256 _childrenCount);

Returns

NameTypeDescription
_childrenCountuint256The total amount of pool managers created by this factory

feeCollectorJob

Returns the fee collector job

function feeCollectorJob() external view returns (IFeeCollectorJob _feeCollectorJob);

Returns

NameTypeDescription
_feeCollectorJobIFeeCollectorJobThe fee collector job

lockManagerFactory

Returns the lock manager factory

function lockManagerFactory() external view returns (ILockManagerFactory _lockManagerFactory);

Returns

NameTypeDescription
_lockManagerFactoryILockManagerFactoryThe lock manager factory

POOL_MANAGER_DEPLOYER

Returns the pool manager deployer

function POOL_MANAGER_DEPLOYER() external view returns (IPoolManagerDeployer _poolManagerDeployer);

Returns

NameTypeDescription
_poolManagerDeployerIPoolManagerDeployerThe pool manager deployer

poolManagerMigrator

Returns the pool manager migrator contract

function poolManagerMigrator() external view returns (address _poolManagerMigrator);

Returns

NameTypeDescription
_poolManagerMigratoraddressThe pool manager migrator contract

priceOracle

Returns the price oracle

function priceOracle() external view returns (IPriceOracle _priceOracle);

Returns

NameTypeDescription
_priceOracleIPriceOracleThe price oracle

minEthAmount

Returns the minimum amount of ETH to create a PoolManager

function minEthAmount() external view returns (uint256 _minEthAmount);

Returns

NameTypeDescription
_minEthAmountuint256The 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

NameTypeDescription
uniswapV3FactoryIUniswapV3FactoryAddress of the UniswapV3 factory
poolBytecodeHashbytes32Bytecode hash of the UniswapV3 pool
wethIERC20The WETH token
otherTokenIERC20The non-WETH token in the UniswapV3 pool address
feeManagerIFeeManagerThe fee manager contract
priceOracleIPriceOracleThe price oracle contract
owneraddressThe contracts owner
feeuint24The UniswapV3 fee tier, as a 10000th of %
sqrtPriceX96uint160A 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

NameTypeDescription
_poolManagerIPoolManagerThe pool manager to be checked

Returns

NameTypeDescription
_isChildboolWhether 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

NameTypeDescription
_poolIUniswapV3PoolThe address of the Uniswap V3 pool

Returns

NameTypeDescription
_poolManagerIPoolManagerThe 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

NameTypeDescription
_indexuint256The index of the pool manager

Returns

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

isSupportedPool

Returns true if the pool has a valid pool manager

function isSupportedPool(IUniswapV3Pool _pool) external view returns (bool _isSupportedPool);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe address of the Uniswap V3 pool

Returns

NameTypeDescription
_isSupportedPoolboolTrue 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

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH

Returns

NameTypeDescription
_isValidboolTrue 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

NameTypeDescription
_tokenAIERC20The tokenA to check paired with tokenB
_tokenBIERC20The tokenB to check paired with tokenA

Returns

NameTypeDescription
_isSupportedboolTrue 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

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH

Returns

NameTypeDescription
_feeuint24The 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

NameTypeDescription
_tokenIERC20The token paired with WETH

Returns

NameTypeDescription
_feesuint24[]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

NameTypeDescription
_owneraddressThe owner of the contract

pendingOwner

Returns the pending owner

function pendingOwner() external view returns (address _pendingOwner);

Returns

NameTypeDescription
_pendingOwneraddressThe 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

NameTypeDescription
_poolManagerBytecodeHashbytes32The 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

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the given pool
_feeuint24The UniswapV3 pool fee tier, as a 10000th of %
_liquidityuint128The liquidity to create the pool manager
_sqrtPriceX96uint160The sqrt price in base 96

Returns

NameTypeDescription
_poolManagerIPoolManagerThe 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

NameTypeDescription
_startFromuint256Index from where to start the pagination
_amountuint256Maximum amount of pool managers to retrieve

Returns

NameTypeDescription
_listIPoolManager[]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

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the pool
_feeuint24The UniswapV3 fee tier

Returns

NameTypeDescription
_theoreticalPoolManagerAddressIPoolManagerThe 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

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the pool
_feeuint24The UniswapV3 fee tier

Returns

NameTypeDescription
_theoreticalAddressIUniswapV3PoolAddress of the theoretical address of the UniswapV3 pool
_isWethToken0boolDefines 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

NameTypeDescription
_tokenIERC20The address of the token
_feeTiersuint24[]The fee tiers to check

Returns

NameTypeDescription
_poolManagerAddressesaddress[]The available pool managers

setDefaultTokenFee

Sets the default fee for the pool of non-WETH/WETH

function setDefaultTokenFee(IERC20 _token, uint24 _fee) external;

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the pool
_feeuint24The UniswapV3 fee tier to use

setStrategy

Sets the new strategy address

function setStrategy(IStrategy _strategy) external;

Parameters

NameTypeDescription
_strategyIStrategyThe new strategy address

setLockManagerFactory

Sets the new lock manager factory address

function setLockManagerFactory(ILockManagerFactory _lockManagerFactory) external;

Parameters

NameTypeDescription
_lockManagerFactoryILockManagerFactoryThe new lock manager factory address

nominateOwner

Nominates the new owner of the contract

function nominateOwner(address _newOwner) external;

Parameters

NameTypeDescription
_newOwneraddressThe 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

NameTypeDescription
_poolManagerMigratoraddressThe new pool manager migrator

setPriceOracle

Sets price oracle contract

function setPriceOracle(IPriceOracle _priceOracle) external;

Parameters

NameTypeDescription
_priceOracleIPriceOracleThe new price oracle

setFeeManager

Sets the fee manager contract

function setFeeManager(IFeeManager _feeManager) external;

Parameters

NameTypeDescription
_feeManagerIFeeManagerThe new fee manager

setFeeCollectorJob

Sets the fee collector job

function setFeeCollectorJob(IFeeCollectorJob _feeCollectorJob) external;

Parameters

NameTypeDescription
_feeCollectorJobIFeeCollectorJobThe new fee collector job

setMinEthAmount

Sets the minimum ETH amount

function setMinEthAmount(uint256 _minEthAmount) external;

Parameters

NameTypeDescription
_minEthAmountuint256The 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;
}