Revert "feat: Remove WETH mention from AaveOracle. Add QUOTE_CURRENCY and QUOTE_CURRENCY_UNIT to determine the quote currency of the price sources"

This reverts commit b54c6f8a24.
This commit is contained in:
David Racero 2021-05-27 11:40:28 +02:00
parent 50f60a3666
commit 0b109da9c6

View File

@ -18,14 +18,13 @@ import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol';
contract AaveOracle is IPriceOracleGetter, Ownable { contract AaveOracle is IPriceOracleGetter, Ownable {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
event QuoteCurrencySet(address indexed quoteCurrency, uint256 quoteUnit); event WethSet(address indexed weth);
event AssetSourceUpdated(address indexed asset, address indexed source); event AssetSourceUpdated(address indexed asset, address indexed source);
event FallbackOracleUpdated(address indexed fallbackOracle); event FallbackOracleUpdated(address indexed fallbackOracle);
mapping(address => IChainlinkAggregator) private assetsSources; mapping(address => IChainlinkAggregator) private assetsSources;
IPriceOracleGetter private _fallbackOracle; IPriceOracleGetter private _fallbackOracle;
address public immutable QUOTE_CURRENCY; address public immutable WETH;
uint256 public immutable QUOTE_CURRENCY_UNIT;
/// @notice Constructor /// @notice Constructor
/// @param assets The addresses of the assets /// @param assets The addresses of the assets
@ -36,14 +35,12 @@ contract AaveOracle is IPriceOracleGetter, Ownable {
address[] memory assets, address[] memory assets,
address[] memory sources, address[] memory sources,
address fallbackOracle, address fallbackOracle,
address quoteCurrency, address weth
uint256 quoteCurrencyUnits
) public { ) public {
_setFallbackOracle(fallbackOracle); _setFallbackOracle(fallbackOracle);
_setAssetsSources(assets, sources); _setAssetsSources(assets, sources);
QUOTE_CURRENCY = quoteCurrency; WETH = weth;
QUOTE_CURRENCY_UNIT = quoteCurrencyUnits; emit WethSet(weth);
emit QuoteCurrencySet(quoteCurrency, quoteCurrencyUnits);
} }
/// @notice External function called by the Aave governance to set or replace sources of assets /// @notice External function called by the Aave governance to set or replace sources of assets
@ -86,8 +83,8 @@ contract AaveOracle is IPriceOracleGetter, Ownable {
function getAssetPrice(address asset) public view override returns (uint256) { function getAssetPrice(address asset) public view override returns (uint256) {
IChainlinkAggregator source = assetsSources[asset]; IChainlinkAggregator source = assetsSources[asset];
if (asset == QUOTE_CURRENCY) { if (asset == WETH) {
return QUOTE_CURRENCY_UNIT; return 1 ether;
} else if (address(source) == address(0)) { } else if (address(source) == address(0)) {
return _fallbackOracle.getAssetPrice(asset); return _fallbackOracle.getAssetPrice(asset);
} else { } else {