Skip to main content

APoolContractsRegistry

Overview​

License: MIT​

abstract contract APoolContractsRegistry is Initializable, ADependant

The PoolContractsRegistry module

This contract can be used as a pool registry that keeps track of deployed pools by the system. One can integrate factories to deploy and register pools or add them manually otherwise.

The registry uses BeaconProxy pattern to provide upgradeability and EIP-6224 pattern to provide dependency injection mechanism into the pools.

The PoolContractsRegistry contract operates by managing ProxyBeacons that point to pools' implementations. The factory contract would deploy BeaconProxies that point to these ProxyBeacons, allowing simple and cheap upgradeability mechanics.

Structs info​

APoolContractsRegistryStorage​

struct APoolContractsRegistryStorage {
address contractsRegistry;
mapping(string => UpgradeableBeacon) beacons;
mapping(string => EnumerableSet.AddressSet) pools;
}

Errors info​

NoMappingExists​

error NoMappingExists(string poolName)

NoPoolsToInject​

error NoPoolsToInject(string poolName)

ProxyDoesNotExist​

error ProxyDoesNotExist(string poolName)

Functions info​

setDependencies (0x69130451)​

function setDependencies(
address contractsRegistry_,
bytes memory
) public virtual override dependant

The function that accepts dependencies from the ContractsRegistry, can be overridden

Parameters:

NameTypeDescription
contractsRegistry_addressthe dependency registry

addProxyPool (0x09ae152b)​

function addProxyPool(string memory name_, address poolAddress_) public virtual

The function to add new pools into the registry. Gets called from APoolFactory

Proper only factory access control must be added in descending contracts + _addProxyPool() should be called inside.

Parameters:

NameTypeDescription
name_stringthe pool's associated name
poolAddress_addressthe proxy address of the pool

getImplementation (0x6b683896)​

function getImplementation(string memory name_) public view returns (address)

The function to get implementation of the specific pools

Parameters:

NameTypeDescription
name_stringthe name of the pools

Return values:

NameTypeDescription
[0]addressaddress_ the implementation these pools point to

getProxyBeacon (0xc21182e7)​

function getProxyBeacon(string memory name_) public view returns (address)

The function to get the BeaconProxy of the specific pools (mostly needed in the factories)

Parameters:

NameTypeDescription
name_stringthe name of the pools

Return values:

NameTypeDescription
[0]addressaddress the BeaconProxy address

isPool (0x8f0f764e)​

function isPool(string memory name_, address pool_) public view returns (bool)

The function to check if the address is a pool

Parameters:

NameTypeDescription
name_stringthe associated pools name
pool_addressthe address to check

Return values:

NameTypeDescription
[0]booltrue if pool_ is whithing the registry

countPools (0x33c21917)​

function countPools(string memory name_) public view returns (uint256)

The function to count pools by specified name

Parameters:

NameTypeDescription
name_stringthe associated pools name

Return values:

NameTypeDescription
[0]uint256the number of pools with this name

getContractsRegistry (0xbcb9491c)​

function getContractsRegistry() public view returns (address)

Returns the address of the contracts registry

listPools (0x71dd21c6)​

function listPools(
string memory name_,
uint256 offset_,
uint256 limit_
) public view returns (address[] memory pools_)

The paginated function to list pools by their name (call countPools() to account for pagination)

Parameters:

NameTypeDescription
name_stringthe associated pools name
offset_uint256the starting index in the pools array
limit_uint256the number of pools

Return values:

NameTypeDescription
pools_address[]the array of pools proxies