mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: Add OracleQuoteUnit to configs and adapt deployment scripts to support the config change.
This commit is contained in:
parent
b54c6f8a24
commit
50f60a3666
|
@ -8,9 +8,9 @@ pragma solidity 0.6.12;
|
||||||
|
|
||||||
interface IPriceOracleGetter {
|
interface IPriceOracleGetter {
|
||||||
/**
|
/**
|
||||||
* @dev returns the asset price in ETH
|
* @dev returns the asset price in Quote currency
|
||||||
* @param asset the address of the asset
|
* @param asset the address of the asset
|
||||||
* @return the ETH price of the asset
|
* @return the price of the asset in Quote currency
|
||||||
**/
|
**/
|
||||||
function getAssetPrice(address asset) external view returns (uint256);
|
function getAssetPrice(address asset) external view returns (uint256);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,3 +144,15 @@ export const getLendingRateOracles = (poolConfig: IBaseConfiguration) => {
|
||||||
Object.keys(ReserveAssets[network]).includes(key)
|
Object.keys(ReserveAssets[network]).includes(key)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getQuoteCurrency = async (config: IBaseConfiguration) => {
|
||||||
|
switch (config.OracleQuoteCurrency) {
|
||||||
|
case 'ETH':
|
||||||
|
case 'WETH':
|
||||||
|
return getWethAddress(config);
|
||||||
|
case 'USD':
|
||||||
|
return config.ProtocolGlobalParams.UsdAddress;
|
||||||
|
default:
|
||||||
|
throw `Quote ${config.OracleQuoteCurrency} currency not set. Add a new case to getQuoteCurrency switch`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -225,7 +225,7 @@ export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployAaveOracle = async (
|
export const deployAaveOracle = async (
|
||||||
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress, tEthereumAddress],
|
args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress, tEthereumAddress, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) =>
|
) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
|
|
|
@ -509,6 +509,7 @@ export interface IBaseConfiguration {
|
||||||
VariableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>;
|
VariableDebtTokenImplementation?: iParamsPerNetwork<tEthereumAddress>;
|
||||||
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
|
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
|
||||||
OracleQuoteCurrency: string;
|
OracleQuoteCurrency: string;
|
||||||
|
OracleQuoteUnit: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICommonConfiguration extends IBaseConfiguration {
|
export interface ICommonConfiguration extends IBaseConfiguration {
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import { oneRay, ZERO_ADDRESS, MOCK_CHAINLINK_AGGREGATORS_PRICES } from '../../helpers/constants';
|
import {
|
||||||
|
oneRay,
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
||||||
|
oneEther,
|
||||||
|
} from '../../helpers/constants';
|
||||||
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
|
@ -13,6 +18,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
SymbolPrefix: '',
|
SymbolPrefix: '',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
OracleQuoteCurrency: 'ETH',
|
OracleQuoteCurrency: 'ETH',
|
||||||
|
OracleQuoteUnit: oneEther.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
RAY,
|
RAY,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
MOCK_CHAINLINK_AGGREGATORS_PRICES,
|
||||||
|
oneUsd,
|
||||||
} from '../../helpers/constants';
|
} from '../../helpers/constants';
|
||||||
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
SymbolPrefix: 'Amm',
|
SymbolPrefix: 'Amm',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
OracleQuoteCurrency: 'ETH',
|
OracleQuoteCurrency: 'ETH',
|
||||||
|
OracleQuoteUnit: oneEther.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
|
@ -20,6 +20,7 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
SymbolPrefix: 'm',
|
SymbolPrefix: 'm',
|
||||||
ProviderId: 0, // Overriden in index.ts
|
ProviderId: 0, // Overriden in index.ts
|
||||||
OracleQuoteCurrency: 'ETH',
|
OracleQuoteCurrency: 'ETH',
|
||||||
|
OracleQuoteUnit: oneEther.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '5848466240000000',
|
MockUsdPriceInWei: '5848466240000000',
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES,
|
MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES,
|
||||||
|
oneUsd,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
} from '../../helpers/constants';
|
} from '../../helpers/constants';
|
||||||
import { eEthereumNetwork, IUsdAmmConfiguration } from '../../helpers/types';
|
import { eEthereumNetwork, IUsdAmmConfiguration } from '../../helpers/types';
|
||||||
|
@ -26,6 +27,7 @@ export const AmmConfig: IUsdAmmConfiguration = {
|
||||||
VariableDebtTokenNamePrefix: 'Aave USD AMM Market variable debt',
|
VariableDebtTokenNamePrefix: 'Aave USD AMM Market variable debt',
|
||||||
SymbolPrefix: 'usdAmm',
|
SymbolPrefix: 'usdAmm',
|
||||||
OracleQuoteCurrency: 'USD',
|
OracleQuoteCurrency: 'USD',
|
||||||
|
OracleQuoteUnit: oneUsd.toString(),
|
||||||
ProtocolGlobalParams: {
|
ProtocolGlobalParams: {
|
||||||
TokenDistributorPercentageBase: '10000',
|
TokenDistributorPercentageBase: '10000',
|
||||||
MockUsdPriceInWei: '10000000',
|
MockUsdPriceInWei: '10000000',
|
||||||
|
|
|
@ -12,14 +12,19 @@ import {
|
||||||
import { ICommonConfiguration, iAssetBase, TokenContractId } from '../../helpers/types';
|
import { ICommonConfiguration, iAssetBase, TokenContractId } from '../../helpers/types';
|
||||||
import { waitForTx } from '../../helpers/misc-utils';
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
import { getAllAggregatorsAddresses, getAllTokenAddresses } from '../../helpers/mock-helpers';
|
import { getAllAggregatorsAddresses, getAllTokenAddresses } from '../../helpers/mock-helpers';
|
||||||
import { ConfigNames, loadPoolConfig, getWethAddress } from '../../helpers/configuration';
|
import {
|
||||||
|
ConfigNames,
|
||||||
|
loadPoolConfig,
|
||||||
|
getWethAddress,
|
||||||
|
getQuoteCurrency,
|
||||||
|
} from '../../helpers/configuration';
|
||||||
import {
|
import {
|
||||||
getAllMockedTokens,
|
getAllMockedTokens,
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
getPairsTokenAggregator,
|
getPairsTokenAggregator,
|
||||||
} from '../../helpers/contracts-getters';
|
} from '../../helpers/contracts-getters';
|
||||||
|
|
||||||
task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
task('dev:deploy-oracles', 'Deploy oracles for dev environment')
|
||||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||||
.setAction(async ({ verify, pool }, localBRE) => {
|
.setAction(async ({ verify, pool }, localBRE) => {
|
||||||
|
@ -60,7 +65,13 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
);
|
);
|
||||||
|
|
||||||
await deployAaveOracle(
|
await deployAaveOracle(
|
||||||
[tokens, aggregators, fallbackOracle.address, await getWethAddress(poolConfig)],
|
[
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracle.address,
|
||||||
|
await getQuoteCurrency(poolConfig),
|
||||||
|
pool.OracleQuoteUnit,
|
||||||
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
getWethAddress,
|
getWethAddress,
|
||||||
getGenesisPoolAdmin,
|
getGenesisPoolAdmin,
|
||||||
getLendingRateOracles,
|
getLendingRateOracles,
|
||||||
|
getQuoteCurrency,
|
||||||
} from '../../helpers/configuration';
|
} from '../../helpers/configuration';
|
||||||
import {
|
import {
|
||||||
getAaveOracle,
|
getAaveOracle,
|
||||||
|
@ -59,7 +60,13 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
aaveOracle = await await getAaveOracle(aaveOracleAddress);
|
aaveOracle = await await getAaveOracle(aaveOracleAddress);
|
||||||
} else {
|
} else {
|
||||||
aaveOracle = await deployAaveOracle(
|
aaveOracle = await deployAaveOracle(
|
||||||
[tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)],
|
[
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracleAddress,
|
||||||
|
await getQuoteCurrency(poolConfig),
|
||||||
|
poolConfig.OracleQuoteUnit,
|
||||||
|
],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
|
await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
|
||||||
|
|
|
@ -49,7 +49,7 @@ import {
|
||||||
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
||||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||||
import AaveConfig from '../../markets/aave';
|
import AaveConfig from '../../markets/aave';
|
||||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
import { oneEther, ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {
|
import {
|
||||||
getLendingPool,
|
getLendingPool,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
|
@ -226,7 +226,13 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
config.OracleQuoteCurrency
|
config.OracleQuoteCurrency
|
||||||
);
|
);
|
||||||
|
|
||||||
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
|
await deployAaveOracle([
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracle.address,
|
||||||
|
mockTokens.WETH.address,
|
||||||
|
oneEther.toString(),
|
||||||
|
]);
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||||
|
|
||||||
const lendingRateOracle = await deployLendingRateOracle();
|
const lendingRateOracle = await deployLendingRateOracle();
|
||||||
|
|
|
@ -48,7 +48,7 @@ import {
|
||||||
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
||||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||||
import AmmConfig from '../../markets/amm';
|
import AmmConfig from '../../markets/amm';
|
||||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
import { oneEther, ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {
|
import {
|
||||||
getLendingPool,
|
getLendingPool,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
|
@ -226,7 +226,13 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
config.OracleQuoteCurrency
|
config.OracleQuoteCurrency
|
||||||
);
|
);
|
||||||
|
|
||||||
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
|
await deployAaveOracle([
|
||||||
|
tokens,
|
||||||
|
aggregators,
|
||||||
|
fallbackOracle.address,
|
||||||
|
mockTokens.WETH.address,
|
||||||
|
oneEther.toString(),
|
||||||
|
]);
|
||||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||||
|
|
||||||
const lendingRateOracle = await deployLendingRateOracle();
|
const lendingRateOracle = await deployLendingRateOracle();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user