Added functionality to re-use Aave/Lending Rate Oracles

This commit is contained in:
Zer0dot 2021-02-12 11:08:36 -05:00
parent 283cf2ce97
commit 313e3146f4
2 changed files with 31 additions and 18 deletions

View File

@ -177,9 +177,9 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
[eEthereumNetwork.kovan]: '', //'0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a', // Need to re-deploy because of onlyOwner
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
[eEthereumNetwork.main]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', // Need to re-deploy because of onlyOwner
[eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
},
LendingPoolCollateralManager: {
@ -206,7 +206,7 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '',
[EthereumNetwork.kovan]: '',//'0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1', // Need to re-deploy because of onlyOwner
[EthereumNetwork.ropsten]: ZERO_ADDRESS,
[EthereumNetwork.main]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
[EthereumNetwork.main]: '',//'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', // Need to re-deploy because of onlyOwner
[EthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
},
FallbackOracle: {

View File

@ -1,7 +1,7 @@
import { task } from 'hardhat/config';
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { deployAaveOracle, deployLendingRateOracle } from '../../helpers/contracts-deployments';
import { setInitialMarketRatesInRatesOracleByHelper } from '../../helpers/oracles-helpers';
import { setInitialAssetPricesInOracle, setInitialMarketRatesInRatesOracleByHelper } from '../../helpers/oracles-helpers';
import { ICommonConfiguration, eEthereumNetwork, SymbolMap } from '../../helpers/types';
import { waitForTx, notFalsyOrZeroAddress } from '../../helpers/misc-utils';
import {
@ -17,6 +17,7 @@ import {
getLendingRateOracle,
getPairsTokenAggregator,
} from '../../helpers/contracts-getters';
import { AaveOracle } from '../../types';
task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
.addFlag('verify', 'Verify contracts at Etherscan')
@ -47,25 +48,37 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
};
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
const aaveOracle = notFalsyOrZeroAddress(aaveOracleAddress)
? await getAaveOracle(aaveOracleAddress)
: await deployAaveOracle(
[tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)],
verify
);
// const aaveOracle = notFalsyOrZeroAddress(aaveOracleAddress)
// ? await getAaveOracle(aaveOracleAddress)
// : await deployAaveOracle(
// [tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)],
// verify
// );
let aaveOracle: AaveOracle;
if (notFalsyOrZeroAddress(aaveOracleAddress)) {
aaveOracle = await getAaveOracle(aaveOracleAddress);
await aaveOracle.setAssetSources(tokens, aggregators);
} else {
aaveOracle = await deployAaveOracle(
[tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)],
verify
);
}
const lendingRateOracle = notFalsyOrZeroAddress(lendingRateOracleAddress)
? await getLendingRateOracle(lendingRateOracleAddress)
: await deployLendingRateOracle(verify);
const { USD, ...tokensAddressesWithoutUsd } = tokensToWatch;
if (!lendingRateOracleAddress) {
await setInitialMarketRatesInRatesOracleByHelper(
lendingRateOracles,
tokensAddressesWithoutUsd,
lendingRateOracle,
admin
);
}
// This must be done any time a new market is created I believe
//if (!lendingRateOracleAddress) {
await setInitialMarketRatesInRatesOracleByHelper(
lendingRateOracles,
tokensAddressesWithoutUsd,
lendingRateOracle,
admin
);
//}
console.log("ORACLES: %s and %s", aaveOracle.address, lendingRateOracle.address);
// Register the proxy price provider on the addressesProvider
await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address));