Registry: Address Provider

AddressProvider is an address provider for registry contracts.

Source code for this contract is available on Github.

How it Works

The address provider is deployed to the Ethereum mainnet at:

This contract is immutable. The address will never change.

The address provider is the point-of-entry for on-chain integrators. All other contracts within the registry are assigned an ID within the address provider. IDs start from zero and increment as new components are added. The address associated with an ID may change, but the API of the associated contract will not.

Integrators requiring an aspect of the registry should always start by querying the address provider for the current address of the desired component. An up-to-date list of registered IDs is available here.

To interact with the address provider using the Brownie console:

$ brownie console --network mainnet
Brownie v1.11.10 - Python development framework for Ethereum

Brownie environment is ready.
>>> provider = Contract.from_explorer('0x0000000022D53366457F9d5E68Ec105046FC4383')
Fetching source of 0x0000000022D53366457F9d5E68Ec105046FC4383 from api.etherscan.io...

>>> provider
<AddressProvider Contract '0x0000000022D53366457F9d5E68Ec105046FC4383'>

View Functions

AddressProvider.get_registry() → address: view

Get the address of the main registry contract.

This is a more gas-efficient equivalent to calling get_address(0).

>>> provider.get_registry()
'0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5'
AddressProvider.get_address(id: uint256) → address: view

Fetch the address associated with id.

>>> provider.get_address(1)
'0xe64608E223433E8a03a1DaaeFD8Cb638C14B552C'
AddressProvider.get_id_info(id: uint256) → address, bool, uint256, uint256, string: view

Fetch information about the given id.

Returns a tuple of the following:

  • address: Address associated to the ID.

  • bool: Is the address at this ID currently set?

  • uint256: Version of the current ID. Each time the address is modified, this number increments.

  • uint256: Epoch timestamp this ID was last modified.

  • string: Human-readable description of the ID.

>>> provider.get_id_info(1).dict()
{
    'addr': "0xe64608E223433E8a03a1DaaeFD8Cb638C14B552C",
    'description': "PoolInfo Getters",
    'is_active': True,
    'last_modified': 1604019085,
    'version': 1
}
AddressProvider.max_id() → uint256: view

Get the highest ID set within the address provider.

>>> provider.max_id()
1

Address IDs

  • 0: The main registry contract. Used to locate pools and query information about them.

  • 1: Aggregate getter methods for querying large data sets about a single pool. Designed for off-chain use.

  • 2: Generalized swap contract. Used for finding rates and performing exchanges.

  • 3: The metapool factory.

  • 4: The fee distributor. Used to distribute collected fees to veCRV holders.