feat: added chainlink aggregators

This commit is contained in:
sendra 2021-10-15 13:58:20 +02:00
parent 602cb3d7fd
commit 9204dfa528
6 changed files with 60 additions and 32 deletions

View File

@ -24,14 +24,17 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
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;
IChainlinkAggregator public networkBaseTokenPriceInUsdProxyAggregator;
IChainlinkAggregator public marketReferenceCurrencyPriceInUsdProxyAggregator;
uint256 public constant ETH_CURRENCY_UNIT = 1 ether;
constructor(IChainlinkAggregator networkBaseTokenPriceInUsdProxyAggregator) public {
_networkBaseTokenPriceInUsdProxyAggregator = networkBaseTokenPriceInUsdProxyAggregator;
constructor(
IChainlinkAggregator _networkBaseTokenPriceInUsdProxyAggregator,
IChainlinkAggregator _marketReferenceCurrencyPriceInUsdProxyAggregator
) public {
networkBaseTokenPriceInUsdProxyAggregator = _networkBaseTokenPriceInUsdProxyAggregator;
marketReferenceCurrencyPriceInUsdProxyAggregator = _marketReferenceCurrencyPriceInUsdProxyAggregator;
}
function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy)
@ -136,19 +139,15 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
}
BaseCurrencyInfo memory baseCurrencyInfo;
baseCurrencyInfo.networkBaseTokenPriceInUsd = _networkBaseTokenPriceInUsdProxyAggregator.latestAnswer();
baseCurrencyInfo.networkBaseTokenDecimals = _networkBaseTokenPriceInUsdProxyAggregator.decimals();
baseCurrencyInfo.networkBaseTokenPriceInUsd = networkBaseTokenPriceInUsdProxyAggregator.latestAnswer();
baseCurrencyInfo.networkBaseTokenPriceDecimals = networkBaseTokenPriceInUsdProxyAggregator.decimals();
try oracle.BASE_CURRENCY_UNIT() returns (uint256 baseCurrencyUnit) {
baseCurrencyInfo.baseCurrencyDecimals = baseCurrencyUnit;
if (address(0) == oracle.BASE_CURRENCY()) {
baseCurrencyInfo.baseCurrencyPriceInUsd = USD_PRICE;
} else {
baseCurrencyInfo.baseCurrencyPriceInUsd = oracle.getAssetPrice(MOCK_USD_ADDRESS);
}
baseCurrencyInfo.marketReferenceCurrencyUnit = baseCurrencyUnit;
baseCurrencyInfo.marketReferenceCurrencyPriceInUsd = int256(baseCurrencyUnit);
} catch (bytes memory /*lowLevelData*/) {
baseCurrencyInfo.baseCurrencyDecimals = ETH_CURRENCY_DECIMALS;
baseCurrencyInfo.baseCurrencyPriceInUsd = oracle.getAssetPrice(MOCK_USD_ADDRESS);
baseCurrencyInfo.marketReferenceCurrencyUnit = ETH_CURRENCY_UNIT;
baseCurrencyInfo.marketReferenceCurrencyPriceInUsd = marketReferenceCurrencyPriceInUsdProxyAggregator.latestAnswer();
}
return (reservesData, baseCurrencyInfo);

View File

@ -54,10 +54,10 @@ interface IUiPoolDataProvider {
}
struct BaseCurrencyInfo {
uint256 baseCurrencyDecimals;
uint256 baseCurrencyPriceInUsd;
uint256 marketReferenceCurrencyUnit;
int256 marketReferenceCurrencyPriceInUsd;
int256 networkBaseTokenPriceInUsd;
uint8 networkBaseTokenDecimals;
uint8 networkBaseTokenPriceDecimals;
}
function getReservesList(ILendingPoolAddressesProvider provider)

View File

@ -75,3 +75,21 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
WAVAX: oneEther.multipliedBy('0.006051936629').toFixed(),
USD: '5848466240000000',
};
export const chainlinkAggregatorProxy = {
mainnet: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
kovan: '0x9326BFA02ADD2366b30bacB125260Af641031331',
matic: '0xAB594600376Ec9fD91F8e885dADF0CE036862dE0',
mumbai: '0xd0D5e3DB44DE05E9F294BB0a3bEEaF030DE24Ada',
avalanche: '0x0A77230d17318075983913bC2145DB16C7366156',
fuji: '0x5498BB86BC934c8D34FDA08E81D444153d0D06aD',
};
export const chainlinkEthUsdAggregatorProxy = {
mainnet: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
kovan: '0x9326BFA02ADD2366b30bacB125260Af641031331',
matic: '0xF9680D99D6C9589e2a93a78A04A279e509205945',
mumbai: '0x0715A7794a1dc8e42615F059dD6e406A6594651A',
avalanche: '0x976B3D034E162d8bD72D6b9C989d545b839003b0',
fuji: '0x86d67c3D38D2bCeE722E601025C25a575021c6EA',
};

View File

@ -81,12 +81,16 @@ export const deployUiIncentiveDataProvider = async (verify?: boolean) =>
export const deployUiPoolDataProvider = async (
chainlinkAggregatorProxy: string,
chainlinkEthUsdAggregatorProxy: string,
verify?: boolean
) =>
withSaveAndVerify(
await new UiPoolDataProviderFactory(await getFirstSigner()).deploy(chainlinkAggregatorProxy),
await new UiPoolDataProviderFactory(await getFirstSigner()).deploy(
chainlinkAggregatorProxy,
chainlinkEthUsdAggregatorProxy
),
eContractid.UiPoolDataProvider,
[chainlinkAggregatorProxy],
[chainlinkAggregatorProxy, chainlinkEthUsdAggregatorProxy],
verify
);

View File

@ -1,6 +1,7 @@
import { task } from 'hardhat/config';
import { eContractid } from '../../helpers/types';
import { deployUiPoolDataProvider } from '../../helpers/contracts-deployments';
import { chainlinkAggregatorProxy, chainlinkEthUsdAggregatorProxy } from '../../helpers/constants';
task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider contract`)
.addFlag('verify', 'Verify UiPoolDataProvider contract via Etherscan API.')
@ -10,21 +11,19 @@ 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 eth/usd price aggregator: ${
chainlinkAggregatorProxy[localBRE.network.name]
}`
);
console.log(`\n- UiPoolDataProvider deployment`);
const uiPoolDataProvider = await deployUiPoolDataProvider(
chainlinkAggregatorProxy[localBRE.network.name],
chainlinkEthUsdAggregatorProxy[localBRE.network.name],
verify
);

View File

@ -16,7 +16,11 @@ import {
getAaveProtocolDataProvider,
getLendingPoolAddressesProvider,
} from '../../helpers/contracts-getters';
import { ZERO_ADDRESS } from '../../helpers/constants';
import {
chainlinkAggregatorProxy,
chainlinkEthUsdAggregatorProxy,
ZERO_ADDRESS,
} from '../../helpers/constants';
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
.addFlag('verify', 'Verify contracts at Etherscan')
@ -100,7 +104,11 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
await deployWalletBalancerProvider(verify);
const uiPoolDataProvider = await deployUiPoolDataProvider(verify);
const uiPoolDataProvider = await deployUiPoolDataProvider(
chainlinkAggregatorProxy[localBRE.network.name],
chainlinkEthUsdAggregatorProxy[localBRE.network.name],
verify
);
console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address);
const lendingPoolAddress = await addressesProvider.getLendingPool();