Skip to content

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:

  1. 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
  2. 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
  3. Market Configuration
    • Stores the market identifier for the protocol
    • Manages market-specific configurations
    • Allows for market parameter updates through governance
  4. 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 market
  • owner: The address that will own the contract

Contract Identifiers

The contract uses the following constant identifiers to store addresses:

  • POOL: The main Pool contract
  • POOL_CONFIGURATOR: The PoolConfigurator contract
  • PRICE_ORACLE: The Price Oracle contract
  • ACL_MANAGER: The ACL Manager contract
  • ACL_ADMIN: The ACL Admin address
  • PRICE_ORACLE_SENTINEL: The Price Oracle Sentinel contract
  • DATA_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 set
  • AddressSetAsProxy(bytes32 indexed id, address indexed proxyAddress, address indexed oldImplementationAddress, address newImplementationAddress): Emitted when a proxy implementation is updated
  • PoolUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the Pool implementation is updated
  • PoolConfiguratorUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the PoolConfigurator implementation is updated
  • PriceOracleUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the Price Oracle is updated
  • ACLManagerUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the ACL Manager is updated
  • ACLAdminUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the ACL Admin is updated
  • PriceOracleSentinelUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the Price Oracle Sentinel is updated
  • PoolDataProviderUpdated(address indexed oldAddress, address indexed newAddress): Emitted when the Pool Data Provider is updated
  • MarketIdSet(string indexed oldMarketId, string indexed newMarketId): Emitted when the market ID is updated
  • ProxyCreated(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

TypeDescription
stringA 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

NameTypeDescription
idbytes32id. Example, the Protocol Data Provider uses id 0x1

Return Values

TypeDescription
addressThe 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

TypeDescription
addressThe 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

TypeDescription
addressThe address of associated market's PoolConfigurator

getPriceOracle

function getPriceOracle() external view override returns (address)

Fetch Price Oracle used by the market.

Return Value

TypeDescription
addressThe 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

TypeDescription
addressThe 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

TypeDescription
addressThe address of the access control list admin of the associated market.

getPriceOracleSentinel

function getPriceOracleSentinel() external view override returns (address)

Return Value

TypeDescription
addressThe 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

TypeDescription
addressThe 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

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

NameTypeDescription
idbytes32keccak256 hash of UTF8Bytes string representing Contract
newAddressaddressThe 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

NameTypeDescription
idbytes32id of Proxy contract
newImplementationAddressaddressThe 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

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

NameTypeDescription
newPoolConfiguratorImpladdressThe address of new PoolConfigurator implementation contract

setPriceOracle

function setPriceOracle(address newPriceOracle) external override onlyOwner

Sets/updates address of the PriceOracle contract.

Call Params

NameTypeDescription
newPriceOracleaddressThe address of new PriceOracle contract

setACLAdmin

function setACLAdmin(address newAclAdmin) external override onlyOwner

Sets/updates address of the AclAdmin.

Call Params

NameTypeDescription
newAclAdminaddressThe address of new AclAdming

setPriceOracleSentinel

function setPriceOracleSentinel(address newPriceOracleSentinel) external override onlyOwner

Sets/updates address of the Price oracle sentinel.

Call Params

NameTypeDescription
newPriceOracleSentineladdressThe address of new PriceOracleSentinel

setPoolDataProvider

function setPoolDataProvider(address newDataProvider) external override onlyOwner

Sets/updates address of PoolDataProvider.

Call Params

NameTypeDescription
newDataProvideraddressThe address of new PoolDataProvider