diff --git a/contracts/interfaces/IChainlinkAggregator.sol b/contracts/interfaces/IChainlinkAggregator.sol index 4b75788d..d26a6550 100644 --- a/contracts/interfaces/IChainlinkAggregator.sol +++ b/contracts/interfaces/IChainlinkAggregator.sol @@ -2,6 +2,8 @@ pragma solidity 0.6.12; interface IChainlinkAggregator { + function decimals() external view returns (uint8); + function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); diff --git a/contracts/misc/UiPoolDataProvider.sol b/contracts/misc/UiPoolDataProvider.sol index d40f98a5..f6e266e5 100644 --- a/contracts/misc/UiPoolDataProvider.sol +++ b/contracts/misc/UiPoolDataProvider.sol @@ -14,6 +14,7 @@ import {WadRayMath} from '../protocol/libraries/math/WadRayMath.sol'; import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveConfiguration.sol'; import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; +import {IChainlinkAggregator} from '../interfaces/IChainlinkAggregator.sol'; import { DefaultReserveInterestRateStrategy } from '../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol'; @@ -24,10 +25,13 @@ contract UiPoolDataProvider is IUiPoolDataProvider { using UserConfiguration for DataTypes.UserConfigurationMap; address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96; + IChainlinkAggregator public _networkBaseTokenPriceInUsdProxyAggregator; uint256 public constant USD_PRICE = 100000000; uint256 public constant ETH_CURRENCY_DECIMALS = 18; - constructor() public { + + constructor(IChainlinkAggregator networkBaseTokenPriceInUsdProxyAggregator) public { + _networkBaseTokenPriceInUsdProxyAggregator = networkBaseTokenPriceInUsdProxyAggregator; } function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy) @@ -132,6 +136,9 @@ contract UiPoolDataProvider is IUiPoolDataProvider { } BaseCurrencyInfo memory baseCurrencyInfo; + baseCurrencyInfo.networkBaseTokenPriceInUsd = _networkBaseTokenPriceInUsdProxyAggregator.latestAnswer(); + baseCurrencyInfo.networkBaseTokenDecimals = _networkBaseTokenPriceInUsdProxyAggregator.decimals(); + try oracle.BASE_CURRENCY_UNIT() returns (uint256 baseCurrencyUnit) { baseCurrencyInfo.baseCurrencyDecimals = baseCurrencyUnit; if (address(0) == oracle.BASE_CURRENCY()) { diff --git a/contracts/misc/interfaces/IUiPoolDataProvider.sol b/contracts/misc/interfaces/IUiPoolDataProvider.sol index 4ede9940..84661992 100644 --- a/contracts/misc/interfaces/IUiPoolDataProvider.sol +++ b/contracts/misc/interfaces/IUiPoolDataProvider.sol @@ -56,6 +56,8 @@ interface IUiPoolDataProvider { struct BaseCurrencyInfo { uint256 baseCurrencyDecimals; uint256 baseCurrencyPriceInUsd; + int256 networkBaseTokenPriceInUsd; + uint8 networkBaseTokenDecimals; } function getReservesList(ILendingPoolAddressesProvider provider) diff --git a/helpers/contracts-deployments.ts b/helpers/contracts-deployments.ts index bc03dafc..32d2fc92 100644 --- a/helpers/contracts-deployments.ts +++ b/helpers/contracts-deployments.ts @@ -79,11 +79,14 @@ export const deployUiIncentiveDataProvider = async (verify?: boolean) => verify ); -export const deployUiPoolDataProvider = async (verify?: boolean) => +export const deployUiPoolDataProvider = async ( + chainlinkAggregatorProxy: string, + verify?: boolean +) => withSaveAndVerify( - await new UiPoolDataProviderFactory(await getFirstSigner()).deploy(), + await new UiPoolDataProviderFactory(await getFirstSigner()).deploy(chainlinkAggregatorProxy), eContractid.UiPoolDataProvider, - [], + [chainlinkAggregatorProxy], verify ); diff --git a/tasks/deployments/deploy-UiPoolDataProvider.ts b/tasks/deployments/deploy-UiPoolDataProvider.ts index 464d6b92..94a15717 100644 --- a/tasks/deployments/deploy-UiPoolDataProvider.ts +++ b/tasks/deployments/deploy-UiPoolDataProvider.ts @@ -10,9 +10,23 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider throw new Error('INVALID_CHAIN_ID'); } + const chainlinkAggregatorProxy = { + mainnet: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', + kovan: '0x9326BFA02ADD2366b30bacB125260Af641031331', + matic: '0xAB594600376Ec9fD91F8e885dADF0CE036862dE0', + mumbai: '0xd0D5e3DB44DE05E9F294BB0a3bEEaF030DE24Ada', + avalanche: '0x0A77230d17318075983913bC2145DB16C7366156', + fuji: '0x5498BB86BC934c8D34FDA08E81D444153d0D06aD', + }; + console.log( + `\n- UiPoolDataProvider price aggregator: ${chainlinkAggregatorProxy[localBRE.network.name]}` + ); console.log(`\n- UiPoolDataProvider deployment`); - const uiPoolDataProvider = await deployUiPoolDataProvider(verify); + const uiPoolDataProvider = await deployUiPoolDataProvider( + chainlinkAggregatorProxy[localBRE.network.name], + verify + ); console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address); console.log(`\tFinished UiPoolDataProvider deployment`);