From b54c6f8a2459f0a16b0c5844fe0c58d7eb347f88 Mon Sep 17 00:00:00 2001 From: David Racero Date: Thu, 27 May 2021 09:17:36 +0200 Subject: [PATCH] feat: Remove WETH mention from AaveOracle. Add QUOTE_CURRENCY and QUOTE_CURRENCY_UNIT to determine the quote currency of the price sources --- contracts/misc/AaveOracle.sol | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/contracts/misc/AaveOracle.sol b/contracts/misc/AaveOracle.sol index 0cb8e180..11a2e332 100644 --- a/contracts/misc/AaveOracle.sol +++ b/contracts/misc/AaveOracle.sol @@ -18,13 +18,14 @@ import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol'; contract AaveOracle is IPriceOracleGetter, Ownable { using SafeERC20 for IERC20; - event WethSet(address indexed weth); + event QuoteCurrencySet(address indexed quoteCurrency, uint256 quoteUnit); 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; + address public immutable QUOTE_CURRENCY; + uint256 public immutable QUOTE_CURRENCY_UNIT; /// @notice Constructor /// @param assets The addresses of the assets @@ -35,12 +36,14 @@ contract AaveOracle is IPriceOracleGetter, Ownable { address[] memory assets, address[] memory sources, address fallbackOracle, - address weth + address quoteCurrency, + uint256 quoteCurrencyUnits ) public { _setFallbackOracle(fallbackOracle); _setAssetsSources(assets, sources); - WETH = weth; - emit WethSet(weth); + QUOTE_CURRENCY = quoteCurrency; + QUOTE_CURRENCY_UNIT = quoteCurrencyUnits; + emit QuoteCurrencySet(quoteCurrency, quoteCurrencyUnits); } /// @notice External function called by the Aave governance to set or replace sources of assets @@ -83,8 +86,8 @@ contract AaveOracle is IPriceOracleGetter, Ownable { function getAssetPrice(address asset) public view override returns (uint256) { IChainlinkAggregator source = assetsSources[asset]; - if (asset == WETH) { - return 1 ether; + if (asset == QUOTE_CURRENCY) { + return QUOTE_CURRENCY_UNIT; } else if (address(source) == address(0)) { return _fallbackOracle.getAssetPrice(asset); } else {