Merge branch 'master' of gitlab.com:aave-tech/protocol-v2 into 119-add-a-borroweth-function-to-the-weth-gateway

This commit is contained in:
David Racero 2020-11-06 13:22:15 +01:00
commit 7beda9bcc0
6 changed files with 21 additions and 10 deletions

View File

@ -214,8 +214,8 @@ export const CommonsConfig: ICommonConfiguration = {
BUSD: '0x63294A05C9a81b1A40CAD3f2ff30617111630393',
USD: '0xD21912D8762078598283B14cbA40Cb4bFCb87581',
YFI: '0xe45f3ed2218E7e411bf8DFdE66069e57F46b26eF',
REN: ZERO_ADDRESS,
UNI: ZERO_ADDRESS,
REN: '0xF1939BECE7708382b5fb5e559f630CB8B39a10ee',
UNI: '0x17756515f112429471F86f98D5052aCB6C47f6ee',
ENJ: '0xfaDbe2ee798889F02d1d39eDaD98Eff4c7fe95D4',
UNI_DAI_ETH: '0x0338C40020Bf886c11406115fD1ba205Ef1D9Ff9',
UNI_USDC_ETH: '0x7f5E5D34591e9a70D187BBA94260C30B92aC0961',

View File

@ -18,11 +18,13 @@ import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol';
contract ChainlinkProxyPriceProvider is IPriceOracleGetter, Ownable {
using SafeERC20 for IERC20;
event WethSet(address indexed weth);
event AssetSourceUpdated(address indexed asset, address indexed source);
event FallbackOracleUpdated(address indexed fallbackOracle);
mapping(address => IChainlinkAggregator) private assetsSources;
IPriceOracleGetter private _fallbackOracle;
address public immutable WETH;
/// @notice Constructor
/// @param assets The addresses of the assets
@ -32,10 +34,13 @@ contract ChainlinkProxyPriceProvider is IPriceOracleGetter, Ownable {
constructor(
address[] memory assets,
address[] memory sources,
address fallbackOracle
address fallbackOracle,
address weth
) public {
_setFallbackOracle(fallbackOracle);
_setAssetsSources(assets, sources);
WETH = weth;
emit WethSet(weth);
}
/// @notice External function called by the Aave governance to set or replace sources of assets
@ -77,8 +82,10 @@ contract ChainlinkProxyPriceProvider is IPriceOracleGetter, Ownable {
/// @param asset The asset address
function getAssetPrice(address asset) public override view returns (uint256) {
IChainlinkAggregator source = assetsSources[asset];
// If there is no registered source for the asset, call the fallbackOracle
if (address(source) == address(0)) {
if (asset == WETH) {
return 1 ether;
} else if (address(source) == address(0)) {
return _fallbackOracle.getAssetPrice(asset);
} else {
int256 price = IChainlinkAggregator(source).latestAnswer();

View File

@ -189,7 +189,7 @@ export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify
);
export const deployChainlinkProxyPriceProvider = async (
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress],
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress, tEthereumAddress],
verify?: boolean
) =>
withSaveAndVerify(

View File

@ -13,7 +13,7 @@ import {
import {ICommonConfiguration, iAssetBase, TokenContractId} from '../../helpers/types';
import {waitForTx} from '../../helpers/misc-utils';
import {getAllAggregatorsAddresses, getAllTokenAddresses} from '../../helpers/mock-helpers';
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
import {ConfigNames, loadPoolConfig, getWethAddress} from '../../helpers/configuration';
import {
getAllMockedTokens,
getLendingPoolAddressesProvider,
@ -58,7 +58,10 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
allAggregatorsAddresses
);
await deployChainlinkProxyPriceProvider([tokens, aggregators, fallbackOracle.address], verify);
await deployChainlinkProxyPriceProvider(
[tokens, aggregators, fallbackOracle.address, await getWethAddress(poolConfig)],
verify
);
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
const lendingRateOracle = await deployLendingRateOracle(verify);

View File

@ -7,7 +7,7 @@ import {
import {setInitialMarketRatesInRatesOracleByHelper} from '../../helpers/oracles-helpers';
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
import {ConfigNames, loadPoolConfig, getWethAddress} from '../../helpers/configuration';
import {exit} from 'process';
import {
getLendingPoolAddressesProvider,
@ -46,7 +46,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
const chainlinkProviderPriceProvider = await deployChainlinkProxyPriceProvider(
[tokens, aggregators, fallbackOracle],
[tokens, aggregators, fallbackOracle, await getWethAddress(poolConfig)],
verify
);
await waitForTx(

View File

@ -205,6 +205,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
tokens,
aggregators,
fallbackOracle.address,
mockTokens.WETH.address
]);
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));