mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
7d4dd6d0e0
Added management of WETH to ChainlinkProxyPriceProvider. Closes #117 See merge request aave-tech/protocol-v2!128
81 lines
3.2 KiB
TypeScript
81 lines
3.2 KiB
TypeScript
import {task} from 'hardhat/config';
|
|
import {
|
|
deployPriceOracle,
|
|
deployChainlinkProxyPriceProvider,
|
|
deployLendingRateOracle,
|
|
} from '../../helpers/contracts-deployments';
|
|
|
|
import {
|
|
setInitialAssetPricesInOracle,
|
|
deployAllMockAggregators,
|
|
setInitialMarketRatesInRatesOracleByHelper,
|
|
} from '../../helpers/oracles-helpers';
|
|
import {ICommonConfiguration, iAssetBase, TokenContractId} from '../../helpers/types';
|
|
import {waitForTx} from '../../helpers/misc-utils';
|
|
import {getAllAggregatorsAddresses, getAllTokenAddresses} from '../../helpers/mock-helpers';
|
|
import {ConfigNames, loadPoolConfig, getWethAddress} from '../../helpers/configuration';
|
|
import {
|
|
getAllMockedTokens,
|
|
getLendingPoolAddressesProvider,
|
|
getPairsTokenAggregator,
|
|
} from '../../helpers/contracts-getters';
|
|
|
|
task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
|
.setAction(async ({verify, pool}, localBRE) => {
|
|
await localBRE.run('set-DRE');
|
|
const poolConfig = loadPoolConfig(pool);
|
|
const {
|
|
Mocks: {ChainlinkAggregatorPrices, AllAssetsInitialPrices},
|
|
ProtocolGlobalParams: {UsdAddress, MockUsdPriceInWei},
|
|
LendingRateOracleRatesCommon,
|
|
} = poolConfig as ICommonConfiguration;
|
|
|
|
const defaultTokenList = {
|
|
...Object.fromEntries(Object.keys(TokenContractId).map((symbol) => [symbol, ''])),
|
|
USD: UsdAddress,
|
|
} as iAssetBase<string>;
|
|
const mockTokens = await getAllMockedTokens();
|
|
const mockTokensAddress = Object.keys(mockTokens).reduce<iAssetBase<string>>((prev, curr) => {
|
|
prev[curr as keyof iAssetBase<string>] = mockTokens[curr].address;
|
|
return prev;
|
|
}, defaultTokenList);
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
|
const admin = await addressesProvider.getPoolAdmin();
|
|
|
|
const fallbackOracle = await deployPriceOracle(verify);
|
|
await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei));
|
|
await setInitialAssetPricesInOracle(AllAssetsInitialPrices, mockTokensAddress, fallbackOracle);
|
|
|
|
const mockAggregators = await deployAllMockAggregators(ChainlinkAggregatorPrices, verify);
|
|
|
|
const allTokenAddresses = getAllTokenAddresses(mockTokens);
|
|
const allAggregatorsAddresses = getAllAggregatorsAddresses(mockAggregators);
|
|
|
|
const [tokens, aggregators] = getPairsTokenAggregator(
|
|
allTokenAddresses,
|
|
allAggregatorsAddresses
|
|
);
|
|
|
|
await deployChainlinkProxyPriceProvider(
|
|
[tokens, aggregators, fallbackOracle.address, await getWethAddress(poolConfig)],
|
|
verify
|
|
);
|
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
|
|
|
const lendingRateOracle = await deployLendingRateOracle(verify);
|
|
await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
|
|
|
|
const {USD, ...tokensAddressesWithoutUsd} = allTokenAddresses;
|
|
const allReservesAddresses = {
|
|
...tokensAddressesWithoutUsd,
|
|
};
|
|
await setInitialMarketRatesInRatesOracleByHelper(
|
|
LendingRateOracleRatesCommon,
|
|
allReservesAddresses,
|
|
lendingRateOracle,
|
|
admin
|
|
);
|
|
});
|