mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Added management of WETH to ChainlinkProxyPriceProvider.
This commit is contained in:
parent
aa354bad59
commit
3aa5de28b4
|
@ -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();
|
||||
|
|
|
@ -191,7 +191,7 @@ export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify
|
|||
);
|
||||
|
||||
export const deployChainlinkProxyPriceProvider = async (
|
||||
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress],
|
||||
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress, tEthereumAddress],
|
||||
verify?: boolean
|
||||
) =>
|
||||
withSaveAndVerify(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user