PoolAddressesProvider
Overview
The PoolAddressesProvider is a central registry contract that serves as the single source of truth for all protocol contract addresses and configurations. It plays several critical roles in the SparkLend Protocol:
-
Address Registry
- Maintains a mapping of all protocol contract addresses
- Stores addresses for core components like Pool, PoolConfigurator, Price Oracle, and ACL Manager
- Provides a standardized way to fetch contract addresses across the protocol
-
Proxy Factory & Admin
- Acts as a factory for creating proxy contracts
- Manages proxy implementations for upgradeable contracts
- Handles proxy upgrades through implementation updates
- Initializes new proxy contracts with their implementations
-
Market Configuration
- Stores the market identifier for the protocol
- Manages market-specific configurations
- Allows for market parameter updates through governance
-
Access Control
- Owned by Aave Governance on Ethereum mainnet
- On other networks, owned by either Crosschain Governance Bridges or Community Multisigs
- Controls who can update protocol addresses and configurations
The contract is designed to be immutable (except for the owner) and serves as the foundation for the protocol's upgradeability and configuration management. It's the recommended way to fetch any protocol contract address, ensuring that integrations always use the latest deployed versions.
This contract inherits from OpenZeppelin's Ownable
and implements IPoolAddressesProvider
. It acts as a factory of proxies and admin of those, with the right to change their implementations.
Constructor
constructor(string memory marketId, address owner)
Initializes the PoolAddressesProvider with:
marketId
: The identifier of the marketowner
: The address that will own the contract
Contract Identifiers
The contract uses the following constant identifiers to store addresses:
POOL
: The main Pool contractPOOL_CONFIGURATOR
: The PoolConfigurator contractPRICE_ORACLE
: The Price Oracle contractACL_MANAGER
: The ACL Manager contractACL_ADMIN
: The ACL Admin addressPRICE_ORACLE_SENTINEL
: The Price Oracle Sentinel contractDATA_PROVIDER
: The Pool Data Provider contract
Events
The contract emits the following events:
AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress)
: Emitted when an address is setAddressSetAsProxy(bytes32 indexed id, address indexed proxyAddress, address indexed oldImplementationAddress, address newImplementationAddress)
: Emitted when a proxy implementation is updatedPoolUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the Pool implementation is updatedPoolConfiguratorUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the PoolConfigurator implementation is updatedPriceOracleUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the Price Oracle is updatedACLManagerUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the ACL Manager is updatedACLAdminUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the ACL Admin is updatedPriceOracleSentinelUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the Price Oracle Sentinel is updatedPoolDataProviderUpdated(address indexed oldAddress, address indexed newAddress)
: Emitted when the Pool Data Provider is updatedMarketIdSet(string indexed oldMarketId, string indexed newMarketId)
: Emitted when the market ID is updatedProxyCreated(bytes32 indexed id, address indexed proxyAddress, address indexed implementationAddress)
: Emitted when a new proxy is created
View Methods
getMarketId
function getMarketId() external view override returns (string memory)
Fetch the market id of the associated Spark market.
Return Values
Type | Description |
---|---|
string | A string representation of the market |
getAddress
function getAddress(bytes32 id) public view override returns (address)
Fetch the address of protocol contract stored at given id.
Call Params
Name | Type | Description |
---|---|---|
id | bytes32 | id. Example, the Protocol Data Provider uses id 0x1 |
Return Values
Type | Description |
---|---|
address | The address associated with the bytes32 id passed |
// Get address of incentive controller
import { utils } from '@ethers/lib/utils';
const id = utils.keccak256(utils.toUtf8Bytes("INCENTIVES_CONTROLLER"));
const address = poolAddressProvider.getAddress(id);
getPool
function getPool() external view override returns (address)
Fetch the contract of latest pool
Return Values
Type | Description |
---|---|
address | The address of the associated Pool |
getPoolConfigurator
function getPoolConfigurator() external view override returns (address)
Fetch the PoolConfigurator
is used for configuration methods, like init reserves or update token implementation etc, of the market.
Return Value
Type | Description |
---|---|
address | The address of associated market's PoolConfigurator |
getPriceOracle
function getPriceOracle() external view override returns (address)
Fetch Price Oracle used by the market.
Return Value
Type | Description |
---|---|
address | The address of the price oracle used by associated market. |
getACLManager
function getACLManager() external view override returns (address)
Fetch ACLManger that manages the system role of the market
Return Value
Type | Description |
---|---|
address | The address of the ACLManger contract managing the system role of the associated market. |
getACLAdmin
function getACLAdmin() external view override returns (address)
Fetch ACLAdmin of the market which holds the DEFAULT_ADMIN_ROLE
in ACLManager.
Return Value
Type | Description |
---|---|
address | The address of the access control list admin of the associated market. |
getPriceOracleSentinel
function getPriceOracleSentinel() external view override returns (address)
Return Value
Type | Description |
---|---|
address | The address of the Price oracle sentinel of the associated market. |
getPoolDataProvider
function getPoolDataProvider() external view override returns (address)
Fetch address of latest pool data provider.
Return Value
Type | Description |
---|---|
address | The address of the pool data provider of the associated market. |
Write Methods
setMarketId
function setMarketId(string memory newMarketId) external override onlyOwner
Updates the identifier of the Spark market
Call Params
Name | Type | Description |
---|---|---|
newMarketId | string | The new id of the market |
setAddress
function setAddress(bytes32 id, address newAddress) external override onlyOwner
Sets the address of protocol contract stored at given id.
Eg. utils.keccak256(utils.toUtf8Bytes("INCENTIVES_CONTROLLER"))
is set to address of INCENTIVES_CONTROLLER
Call Params
Name | Type | Description |
---|---|---|
id | bytes32 | keccak256 hash of UTF8Bytes string representing Contract |
newAddress | address | The new address to be set corresponding to the id |
setAddressAsProxy
function setAddressAsProxy(bytes32 id, address newImplementationAddress) external override onlyOwner
Sets/updates the implementation address of a specific proxied protocol contract. If there is no proxy registered with the given identifier, it creates a new proxy with newImplementationAddress
as implementation and calls its initialize()
function. If a proxy already exists, it updates the implementation and calls initialize()
via upgradeToAndCall()
.
Call Params
Name | Type | Description |
---|---|---|
id | bytes32 | id of Proxy contract |
newImplementationAddress | address | The address of new implementation contract corresponding to the proxy |
setPoolImpl
function setPoolImpl(address newPoolImpl) external override onlyOwner
Sets/update the implementation of the POOL proxy contract.
Call Params
Name | Type | Description |
---|---|---|
newPoolImpl | address | The address of new Pool implementation contract |
setPoolConfiguratorImp
function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external override onlyOwner
Sets/updates the implementation of the POOL_CONFIGURATOR proxy contract.
Call Params
Name | Type | Description |
---|---|---|
newPoolConfiguratorImpl | address | The address of new PoolConfigurator implementation contract |
setPriceOracle
function setPriceOracle(address newPriceOracle) external override onlyOwner
Sets/updates address of the PriceOracle contract.
Call Params
Name | Type | Description |
---|---|---|
newPriceOracle | address | The address of new PriceOracle contract |
setACLAdmin
function setACLAdmin(address newAclAdmin) external override onlyOwner
Sets/updates address of the AclAdmin.
Call Params
Name | Type | Description |
---|---|---|
newAclAdmin | address | The address of new AclAdming |
setPriceOracleSentinel
function setPriceOracleSentinel(address newPriceOracleSentinel) external override onlyOwner
Sets/updates address of the Price oracle sentinel.
Call Params
Name | Type | Description |
---|---|---|
newPriceOracleSentinel | address | The address of new PriceOracleSentinel |
setPoolDataProvider
function setPoolDataProvider(address newDataProvider) external override onlyOwner
Sets/updates address of PoolDataProvider.
Call Params
Name | Type | Description |
---|---|---|
newDataProvider | address | The address of new PoolDataProvider |