diff --git a/hardhat.config.ts b/hardhat.config.ts index 10b4402b..3e2c945e 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -62,8 +62,6 @@ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({ }, }); -let forkMode; - const buidlerConfig: HardhatUserConfig = { solidity: { version: '0.6.12', @@ -113,16 +111,6 @@ const buidlerConfig: HardhatUserConfig = { })), forking: buildForkConfig(), }, - buidlerevm_docker: { - hardfork: 'berlin', - blockGasLimit: 9500000, - gas: 9500000, - gasPrice: 8000000000, - chainId: BUIDLEREVM_CHAINID, - throwOnTransactionFailures: true, - throwOnCallFailures: true, - url: 'http://localhost:8545', - }, ganache: { url: 'http://ganache:8545', accounts: { diff --git a/helpers/configuration.ts b/helpers/configuration.ts index 9b21d08d..0bad185b 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -5,11 +5,15 @@ import { PoolConfiguration, ICommonConfiguration, eNetwork, + IUsdAmmConfiguration, + IBaseConfiguration, } from './types'; import { getParamPerPool } from './contracts-helpers'; import AaveConfig from '../markets/aave'; import MaticConfig from '../markets/matic'; import AmmConfig from '../markets/amm'; +import UsdConfig from '../markets/usd-amm'; + import { CommonsConfig } from '../markets/aave/commons'; import { DRE, filterMapBy } from './misc-utils'; import { tEthereumAddress } from './types'; @@ -21,6 +25,7 @@ export enum ConfigNames { Aave = 'Aave', Matic = 'Matic', Amm = 'Amm', + Usd = 'Usd', } export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { @@ -31,6 +36,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { return MaticConfig; case ConfigNames.Amm: return AmmConfig; + case ConfigNames.Usd: + return UsdConfig; case ConfigNames.Commons: return CommonsConfig; default: @@ -54,12 +61,15 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets => { const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const targetAddress = getParamPerNetwork(config.PoolAdmin, currentNetwork); @@ -73,9 +83,7 @@ export const getGenesisPoolAdmin = async ( return addressList[addressIndex]; }; -export const getEmergencyAdmin = async ( - config: ICommonConfiguration -): Promise => { +export const getEmergencyAdmin = async (config: IBaseConfiguration): Promise => { const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const targetAddress = getParamPerNetwork(config.EmergencyAdmin, currentNetwork); if (targetAddress) { @@ -88,19 +96,17 @@ export const getEmergencyAdmin = async ( return addressList[addressIndex]; }; -export const getTreasuryAddress = async ( - config: ICommonConfiguration -): Promise => { +export const getTreasuryAddress = async (config: IBaseConfiguration): Promise => { const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; return getParamPerNetwork(config.ReserveFactorTreasuryAddress, currentNetwork); }; export const getATokenDomainSeparatorPerNetwork = ( network: eNetwork, - config: ICommonConfiguration + config: IBaseConfiguration ): tEthereumAddress => getParamPerNetwork(config.ATokenDomainSeparator, network); -export const getWethAddress = async (config: ICommonConfiguration) => { +export const getWethAddress = async (config: IBaseConfiguration) => { const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; const wethAddress = getParamPerNetwork(config.WETH, currentNetwork); if (wethAddress) { @@ -113,7 +119,7 @@ export const getWethAddress = async (config: ICommonConfiguration) => { return weth.address; }; -export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration) => { +export const getWrappedNativeTokenAddress = async (config: IBaseConfiguration) => { const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const wethAddress = getParamPerNetwork(config.WrappedNativeToken, currentNetwork); if (wethAddress) { @@ -126,7 +132,7 @@ export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration) return weth.address; }; -export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { +export const getLendingRateOracles = (poolConfig: IBaseConfiguration) => { const { ProtocolGlobalParams: { UsdAddress }, LendingRateOracleRatesCommon, diff --git a/helpers/constants.ts b/helpers/constants.ts index d0de9aa4..9fa3e822 100644 --- a/helpers/constants.ts +++ b/helpers/constants.ts @@ -73,10 +73,8 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = { xSUSHI: oneEther.multipliedBy('0.00913428586').toFixed(), USD: '5848466240000000', REW: oneEther.multipliedBy('0.00137893825230').toFixed(), - '3Crv': '0', - 'cDAI+cUSDC': '0', - a3CRV: '0', - saCRV: '0', + 'a3CRV-gauge': '0', + 'saCRV-gauge': '0', }; export const MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES = { @@ -89,12 +87,11 @@ export const MOCK_CHAINLINK_AGGREGATORS_USD_CURVE_AMM_PRICES = { USDC: oneUsd.toFixed(), USDT: oneUsd.toFixed(), USD: oneUsd.toFixed(), - '3Crv': oneUsd.multipliedBy('1.0168').toFixed(), - 'cDAI+cUSDC': oneUsd.multipliedBy('1.0758').toFixed(), - a3CRV: oneUsd.multipliedBy('1.0536').toFixed(), - saCRV: oneUsd.multipliedBy('1.0318').toFixed(), + 'a3CRV-gauge': oneUsd.multipliedBy('1.0536').toFixed(), + 'saCRV-gauge': oneUsd.multipliedBy('1.0318').toFixed(), }; export const CRV_TOKEN = { [eEthereumNetwork.main]: '0xD533a949740bb3306d119CC777fa900bA034cd52', + [eEthereumNetwork.tenderlyMain]: '0xD533a949740bb3306d119CC777fa900bA034cd52', }; diff --git a/helpers/contracts-getters.ts b/helpers/contracts-getters.ts index 2ddbefbc..22c00c02 100644 --- a/helpers/contracts-getters.ts +++ b/helpers/contracts-getters.ts @@ -35,7 +35,7 @@ import { } from '../types'; import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory'; import { MockTokenMap } from './contracts-helpers'; -import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils'; +import { DRE, getDb, notFalsyOrZeroAddress, omit } from './misc-utils'; import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types'; export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0]; @@ -168,15 +168,30 @@ export const getAllMockedTokens = async () => { return tokens; }; +export const getQuoteCurrencies = (oracleQuoteCurrency: string): string[] => { + switch (oracleQuoteCurrency) { + case 'USD': + return ['USD']; + case 'ETH': + case 'WETH': + default: + return ['ETH', 'WETH']; + } +}; + export const getPairsTokenAggregator = ( allAssetsAddresses: { [tokenSymbol: string]: tEthereumAddress; }, - aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress } + aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress }, + oracleQuoteCurrency: string ): [string[], string[]] => { - const { ETH, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses; + const assetsWithoutQuoteCurrency = omit( + allAssetsAddresses, + getQuoteCurrencies(oracleQuoteCurrency) + ); - const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { + const pairs = Object.entries(assetsWithoutQuoteCurrency).map(([tokenSymbol, tokenAddress]) => { //if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) { const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex( (value) => value === tokenSymbol diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index d9f73638..e376e3b4 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -27,7 +27,7 @@ import { getFirstSigner, getIErc20Detailed } from './contracts-getters'; import { usingTenderly, verifyAtTenderly } from './tenderly-utils'; import { usingPolygon, verifyAtPolygon } from './polygon-utils'; import { ConfigNames, loadPoolConfig } from './configuration'; -import { ZERO_ADDRESS } from './constants'; +import { USD_ADDRESS, ZERO_ADDRESS } from './constants'; import { RewardsTokenFactory, RewardsATokenMockFactory } from '../types'; export type MockTokenMap = { [symbol: string]: MintableERC20 }; @@ -185,7 +185,10 @@ export const getOptionalParamAddressPerNetwork = ( return getParamPerNetwork(param, network); }; -export const getParamPerPool = ({ proto, amm, matic }: iParamsPerPool, pool: AavePools) => { +export const getParamPerPool = ( + { proto, amm, matic, usd }: iParamsPerPool, + pool: AavePools +) => { switch (pool) { case AavePools.proto: return proto; @@ -193,6 +196,8 @@ export const getParamPerPool = ({ proto, amm, matic }: iParamsPerPool, poo return amm; case AavePools.matic: return matic; + case AavePools.usd: + return usd; default: return proto; } diff --git a/helpers/init-helpers.ts b/helpers/init-helpers.ts index 4dee6fa0..0d006beb 100644 --- a/helpers/init-helpers.ts +++ b/helpers/init-helpers.ts @@ -143,6 +143,7 @@ export const initReservesByHelper = async ( console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`); for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) { + console.log(chunkedInitInputParams[chunkIndex]); const tx3 = await waitForTx( await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex]) ); diff --git a/helpers/misc-utils.ts b/helpers/misc-utils.ts index 55cde7f2..387d4399 100644 --- a/helpers/misc-utils.ts +++ b/helpers/misc-utils.ts @@ -129,3 +129,9 @@ export const impersonateAddress = async (address: tEthereumAddress): Promise(obj: T, keys: U[]): Omit => + (Object.keys(obj) as U[]).reduce( + (acc, curr) => (keys.includes(curr) ? acc : { ...acc, [curr]: obj[curr] }), + {} as Omit + ); diff --git a/helpers/types.ts b/helpers/types.ts index 2693cf9f..e57f23c1 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -38,6 +38,7 @@ export enum AavePools { proto = 'proto', matic = 'matic', amm = 'amm', + usd = 'usd', } export enum eContractid { @@ -243,10 +244,8 @@ export interface iAssetBase { xSUSHI: T; STAKE: T; REW: T; - '3Crv': T; - 'cDAI+cUSDC': T; - a3CRV: T; - saCRV: T; + 'a3CRV-gauge': T; + 'saCRV-gauge': T; } export type iAssetsWithoutETH = Omit, 'ETH'>; @@ -305,7 +304,7 @@ export type iLpPoolAssets = Pick< export type iUsdLpPoolAssets = Pick< iAssetsWithoutUSD, - 'WETH' | 'WBTC' | 'DAI' | 'SUSD' | 'USDC' | 'USDT' | '3Crv' | 'cDAI+cUSDC' | 'a3CRV' | 'saCRV' + 'WETH' | 'WBTC' | 'DAI' | 'SUSD' | 'USDC' | 'USDT' | 'a3CRV-gauge' | 'saCRV-gauge' >; export type iMaticPoolAssets = Pick< @@ -438,6 +437,7 @@ export interface iParamsPerPool { [AavePools.proto]: T; [AavePools.matic]: T; [AavePools.amm]: T; + [AavePools.usd]: T; } export interface iBasicDistributionParams { @@ -508,6 +508,7 @@ export interface IBaseConfiguration { StableDebtTokenImplementation?: iParamsPerNetwork; VariableDebtTokenImplementation?: iParamsPerNetwork; ReserveAssets: iParamsPerNetwork>; + OracleQuoteCurrency: string; } export interface ICommonConfiguration extends IBaseConfiguration { @@ -544,4 +545,4 @@ export interface ITokenAddress { [token: string]: tEthereumAddress; } -export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration; +export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration | IUsdAmmConfiguration; diff --git a/markets/aave/commons.ts b/markets/aave/commons.ts index f9dbd31d..1475edac 100644 --- a/markets/aave/commons.ts +++ b/markets/aave/commons.ts @@ -12,6 +12,7 @@ export const CommonsConfig: ICommonConfiguration = { VariableDebtTokenNamePrefix: 'Aave variable debt bearing', SymbolPrefix: '', ProviderId: 0, // Overriden in index.ts + OracleQuoteCurrency: 'ETH', ProtocolGlobalParams: { TokenDistributorPercentageBase: '10000', MockUsdPriceInWei: '5848466240000000', diff --git a/markets/amm/commons.ts b/markets/amm/commons.ts index 8be1f2c0..ee6f6a59 100644 --- a/markets/amm/commons.ts +++ b/markets/amm/commons.ts @@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = { VariableDebtTokenNamePrefix: 'Aave AMM Market variable debt', SymbolPrefix: 'Amm', ProviderId: 0, // Overriden in index.ts + OracleQuoteCurrency: 'ETH', ProtocolGlobalParams: { TokenDistributorPercentageBase: '10000', MockUsdPriceInWei: '5848466240000000', diff --git a/markets/matic/commons.ts b/markets/matic/commons.ts index 8a0274a0..2832d25a 100644 --- a/markets/matic/commons.ts +++ b/markets/matic/commons.ts @@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = { VariableDebtTokenNamePrefix: 'Aave Matic Market variable debt', SymbolPrefix: 'm', ProviderId: 0, // Overriden in index.ts + OracleQuoteCurrency: 'ETH', ProtocolGlobalParams: { TokenDistributorPercentageBase: '10000', MockUsdPriceInWei: '5848466240000000', diff --git a/markets/usd-amm/index.ts b/markets/usd-amm/index.ts index 3b10d61d..a6c06873 100644 --- a/markets/usd-amm/index.ts +++ b/markets/usd-amm/index.ts @@ -20,11 +20,12 @@ import { export const AmmConfig: IUsdAmmConfiguration = { MarketId: 'Aave AMM market', - ProviderId: 3, + ProviderId: 4, ATokenNamePrefix: 'Aave USD AMM Market', StableDebtTokenNamePrefix: 'Aave USD AMM Market stable debt', VariableDebtTokenNamePrefix: 'Aave USD AMM Market variable debt', SymbolPrefix: 'usdAmm', + OracleQuoteCurrency: 'USD', ProtocolGlobalParams: { TokenDistributorPercentageBase: '10000', MockUsdPriceInWei: '10000000', @@ -173,10 +174,8 @@ export const AmmConfig: IUsdAmmConfiguration = { SUSD: '0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94', USDC: '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6', USDT: '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D', - '3Crv': ZERO_ADDRESS, - 'cDAI+cUSDC': ZERO_ADDRESS, - a3CRV: ZERO_ADDRESS, - saCRV: ZERO_ADDRESS, + 'a3CRV-gauge': ZERO_ADDRESS, + 'saCRV-gauge': ZERO_ADDRESS, }, [eEthereumNetwork.tenderlyMain]: { WETH: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e', @@ -185,10 +184,8 @@ export const AmmConfig: IUsdAmmConfiguration = { SUSD: '0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94', USDC: '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6', USDT: '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D', - '3Crv': ZERO_ADDRESS, - 'cDAI+cUSDC': ZERO_ADDRESS, - a3CRV: ZERO_ADDRESS, - saCRV: ZERO_ADDRESS, + 'a3CRV-gauge': ZERO_ADDRESS, + 'saCRV-gauge': ZERO_ADDRESS, }, }, ATokenDomainSeparator: { @@ -246,10 +243,8 @@ export const AmmConfig: IUsdAmmConfiguration = { SUSD: strategySUSD, USDC: strategyUSDC, USDT: strategyUSDT, - '3Crv': strategyCurveLP, - 'cDAI+cUSDC': strategyCurveLP, - a3CRV: strategyCurveLP, - saCRV: strategyCurveLP, + 'a3CRV-gauge': strategyCurveLP, + 'saCRV-gauge': strategyCurveLP, }, ReserveAssets: { [eEthereumNetwork.buidlerevm]: {}, @@ -264,10 +259,8 @@ export const AmmConfig: IUsdAmmConfiguration = { SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51', USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', - '3Crv': '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', - 'cDAI+cUSDC': '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2', - a3CRV: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900', - saCRV: '0x02d341CcB60fAaf662bC0554d13778015d1b285C', + 'a3CRV-gauge': '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d', + 'saCRV-gauge': '0x462253b8F74B72304c145DB0e4Eebd326B22ca39', }, [eEthereumNetwork.tenderlyMain]: { WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', @@ -276,10 +269,8 @@ export const AmmConfig: IUsdAmmConfiguration = { SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51', USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', - '3Crv': '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', - 'cDAI+cUSDC': '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2', - a3CRV: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900', - saCRV: '0x02d341CcB60fAaf662bC0554d13778015d1b285C', + 'a3CRV-gauge': '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d', + 'saCRV-gauge': '0x462253b8F74B72304c145DB0e4Eebd326B22ca39', }, }, }; diff --git a/markets/xdai/commons.ts b/markets/xdai/commons.ts index ee9f1f9f..856dd50a 100644 --- a/markets/xdai/commons.ts +++ b/markets/xdai/commons.ts @@ -19,6 +19,7 @@ export const CommonsConfig: ICommonConfiguration = { VariableDebtTokenNamePrefix: 'Aave XDAI Market variable debt', SymbolPrefix: 'm', ProviderId: 0, // Overriden in index.ts + OracleQuoteCurrency: 'ETH', ProtocolGlobalParams: { TokenDistributorPercentageBase: '10000', MockUsdPriceInWei: '5848466240000000', diff --git a/package.json b/package.json index ab658bc8..29574252 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,13 @@ "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic --skip-registry", "matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic --skip-registry", "amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --skip-registry", + "usd:main:full:migration": "npm run compile && npm run hardhat:main -- usd:mainnet --skip-registry", "aave:docker:full:migration:add-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet", "aave:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet", "matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic", "matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic", "amm:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet", + "usd:main:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- usd:mainnet", "aave:docker:add-market-to-registry-from-config": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave", "aave:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave", "matic:mumbai:add-market-to-registry-from-config": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic", @@ -51,6 +53,7 @@ "aave:main:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry", "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave", "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify", + "usd:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- usd:mainnet --skip-registry", "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet", "aave:fork:main": "npm run compile && FORK=main hardhat aave:mainnet", "aave:fork:kovan": "npm run compile && FORK=kovan hardhat aave:mainnet", diff --git a/tasks/dev/4_oracles.ts b/tasks/dev/4_oracles.ts index 23c24133..02f951af 100644 --- a/tasks/dev/4_oracles.ts +++ b/tasks/dev/4_oracles.ts @@ -29,6 +29,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment') Mocks: { AllAssetsInitialPrices }, ProtocolGlobalParams: { UsdAddress, MockUsdPriceInWei }, LendingRateOracleRatesCommon, + OracleQuoteCurrency, } = poolConfig as ICommonConfiguration; const defaultTokenList = { @@ -54,7 +55,8 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment') const [tokens, aggregators] = getPairsTokenAggregator( allTokenAddresses, - allAggregatorsAddresses + allAggregatorsAddresses, + OracleQuoteCurrency ); await deployAaveOracle( diff --git a/tasks/full/3_oracles.ts b/tasks/full/3_oracles.ts index 3346ebd4..c056d943 100644 --- a/tasks/full/3_oracles.ts +++ b/tasks/full/3_oracles.ts @@ -46,7 +46,11 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') ...reserveAssets, USD: UsdAddress, }; - const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators); + const [tokens, aggregators] = getPairsTokenAggregator( + tokensToWatch, + chainlinkAggregators, + poolConfig.OracleQuoteCurrency + ); let aaveOracle: AaveOracle; let lendingRateOracle: LendingRateOracle; diff --git a/tasks/migrations/usd.mainnet.ts b/tasks/migrations/usd.mainnet.ts new file mode 100644 index 00000000..f91a9cd0 --- /dev/null +++ b/tasks/migrations/usd.mainnet.ts @@ -0,0 +1,57 @@ +import { task } from 'hardhat/config'; +import { checkVerification } from '../../helpers/etherscan-verification'; +import { ConfigNames } from '../../helpers/configuration'; +import { printContracts } from '../../helpers/misc-utils'; +import { usingTenderly } from '../../helpers/tenderly-utils'; + +task('usd:mainnet', 'Deploy development enviroment') + .addFlag('verify', 'Verify contracts at Etherscan') + .addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry') + .setAction(async ({ verify, skipRegistry }, DRE) => { + const POOL_NAME = ConfigNames.Usd; + await DRE.run('set-DRE'); + + // Prevent loss of gas verifying all the needed ENVs for Etherscan verification + if (verify) { + checkVerification(); + } + + console.log('Migration started\n'); + + console.log('1. Deploy address provider'); + await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry }); + + console.log('2. Deploy lending pool'); + await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME }); + + console.log('3. Deploy oracles'); + await DRE.run('full:deploy-oracles', { pool: POOL_NAME }); + + console.log('4. Deploy Data Provider'); + await DRE.run('full:data-provider', { pool: POOL_NAME }); + + console.log('5. Deploy WETH Gateway'); + await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME }); + + console.log('6. Initialize lending pool'); + await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME }); + + if (verify) { + printContracts(); + console.log('7. Veryfing contracts'); + await DRE.run('verify:general', { all: true, pool: POOL_NAME }); + + console.log('8. Veryfing aTokens and debtTokens'); + await DRE.run('verify:tokens', { pool: POOL_NAME }); + } + + if (usingTenderly()) { + const postDeployHead = DRE.tenderlyRPC.getHead(); + const postDeployFork = DRE.tenderlyRPC.getFork(); + console.log('Tenderly Info'); + console.log('- Head', postDeployHead); + console.log('- Fork', postDeployFork); + } + console.log('\nFinished migrations'); + printContracts(); + }); diff --git a/tasks/misc/add-token-aave-oracle.ts b/tasks/misc/add-token-aave-oracle.ts new file mode 100644 index 00000000..4a3e66ee --- /dev/null +++ b/tasks/misc/add-token-aave-oracle.ts @@ -0,0 +1,30 @@ +import { task } from 'hardhat/config'; +import { getAaveOracle } from '../../helpers/contracts-getters'; +import { waitForTx } from '../../helpers/misc-utils'; +import { usingTenderly } from '../../helpers/tenderly-utils'; + +task('dev:set-price-providers-to-aave-oracle', 'Set price providers ') + .addParam('aaveOracle', 'Aave Oracle where you are the owner') + .addParam('tokens', 'Token addresses separated by comma') + .addParam('priceProviders', 'Token address price providers separated by comma') + .setAction(async ({ aaveOracle, tokens, priceProviders }, localBRE) => { + await localBRE.run('set-DRE'); + const oracle = await getAaveOracle(aaveOracle); + const tokenAddresses = tokens.split(','); + const priceProviderAddresses = priceProviders.split(','); + + await waitForTx(await oracle.setAssetSources(tokenAddresses, priceProviderAddresses)); + console.log('- Set asset sources for AaveOracle:'); + tokenAddresses.forEach((element, i) => { + console.log(' Asset:', element); + console.log(' Source:', priceProviderAddresses[i]); + }); + + if (usingTenderly()) { + const postDeployHead = localBRE.tenderlyRPC.getHead(); + const postDeployFork = localBRE.tenderlyRPC.getFork(); + console.log('Tenderly Info'); + console.log('- Head', postDeployHead); + console.log('- Fork', postDeployFork); + } + }); diff --git a/test-suites/test-aave/__setup.spec.ts b/test-suites/test-aave/__setup.spec.ts index d3abf2c2..f89e93bd 100644 --- a/test-suites/test-aave/__setup.spec.ts +++ b/test-suites/test-aave/__setup.spec.ts @@ -220,7 +220,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { {} ); - const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); + const [tokens, aggregators] = getPairsTokenAggregator( + allTokenAddresses, + allAggregatorsAddresses, + config.OracleQuoteCurrency + ); await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]); await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address)); diff --git a/test-suites/test-amm/__setup.spec.ts b/test-suites/test-amm/__setup.spec.ts index 318d80b5..d7d3cea3 100644 --- a/test-suites/test-amm/__setup.spec.ts +++ b/test-suites/test-amm/__setup.spec.ts @@ -220,7 +220,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { {} ); - const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); + const [tokens, aggregators] = getPairsTokenAggregator( + allTokenAddresses, + allAggregatorsAddresses, + config.OracleQuoteCurrency + ); await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]); await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));