From 729b642ea547dfbd39352750abb0b07770944211 Mon Sep 17 00:00:00 2001 From: David Racero Date: Thu, 5 Nov 2020 13:44:20 +0100 Subject: [PATCH] Support Buidler to run solidity-coverage until is ported. --- buidler.config.ts | 18 ++++---- hardhat.config.ts | 3 ++ helpers/configuration.ts | 8 ++-- helpers/contracts-deployments.ts | 18 ++++++-- helpers/contracts-getters.ts | 56 +++++++++++------------ helpers/contracts-helpers.ts | 19 ++++---- helpers/etherscan-verification.ts | 10 ++-- helpers/misc-utils.ts | 23 ++++++---- package.json | 4 +- tasks/dev/1_mock_tokens.ts | 2 +- tasks/dev/2_address_provider_registry.ts | 2 +- tasks/dev/3_lending_pool.ts | 2 +- tasks/dev/4_oracles.ts | 2 +- tasks/dev/5_initialize.ts | 2 +- tasks/dev/6_wallet_balance_provider.ts | 2 +- tasks/full/1_address_provider_registry.ts | 2 +- tasks/full/2_lending_pool.ts | 2 +- tasks/full/3_oracles.ts | 2 +- tasks/full/5_initialize.ts | 2 +- tasks/migrations/aave.dev.ts | 5 +- tasks/migrations/aave.full.ts | 2 +- tasks/migrations/uniswap.dev.ts | 2 +- tasks/migrations/uniswap.full.ts | 2 +- tasks/misc/print-contracts.ts | 4 +- tasks/misc/set-bre.ts | 10 ++-- tasks/misc/verify-sc.ts | 4 +- test/__setup.spec.ts | 2 +- test/atoken-permit.spec.ts | 16 +++---- test/delegation-aware-atoken.spec.ts | 2 +- test/helpers/actions.ts | 6 +-- test/helpers/make-suite.ts | 4 +- test/helpers/utils/helpers.ts | 4 +- test/liquidation-atoken.spec.ts | 4 +- test/liquidation-underlying.spec.ts | 6 +-- test/weth-gateway.spec.ts | 14 +++--- 35 files changed, 138 insertions(+), 128 deletions(-) diff --git a/buidler.config.ts b/buidler.config.ts index deaa7bcd..aa91a3a7 100644 --- a/buidler.config.ts +++ b/buidler.config.ts @@ -1,10 +1,11 @@ import path from 'path'; import fs from 'fs'; -import {usePlugin} from '@nomiclabs/buidler/config'; +import {usePlugin, task} from '@nomiclabs/buidler/config'; // @ts-ignore import {accounts} from './test-wallets.js'; import {eEthereumNetwork} from './helpers/types'; import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants'; +import {setDRE} from './helpers/misc-utils'; usePlugin('@nomiclabs/buidler-ethers'); usePlugin('buidler-typechain'); @@ -22,15 +23,12 @@ const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || ''; const MNEMONIC_PATH = "m/44'/60'/0'/0"; const MNEMONIC = process.env.MNEMONIC || ''; -// Prevent to load scripts before compilation and typechain -if (!SKIP_LOAD) { - ['misc', 'migrations', 'dev', 'full'].forEach((folder) => { - const tasksPath = path.join(__dirname, 'tasks', folder); - fs.readdirSync(tasksPath) - .filter((pth) => pth.includes('.ts')) - .forEach((task) => require(`${tasksPath}/${task}`)); - }); -} +task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction( + async (_, _DRE) => { + setDRE(_DRE); + return _DRE; + } +); const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => { return { diff --git a/hardhat.config.ts b/hardhat.config.ts index 8723050e..7398222d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -23,6 +23,7 @@ const MNEMONIC = process.env.MNEMONIC || ''; // Prevent to load scripts before compilation and typechain if (!SKIP_LOAD) { + console.log('NOT SKPP'); ['misc', 'migrations', 'dev', 'full'].forEach((folder) => { const tasksPath = path.join(__dirname, 'tasks', folder); fs.readdirSync(tasksPath) @@ -33,6 +34,8 @@ if (!SKIP_LOAD) { }); } +require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`); + const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => { return { url: `https://${networkName}.infura.io/v3/${INFURA_KEY}`, diff --git a/helpers/configuration.ts b/helpers/configuration.ts index b5b9f804..8faea63f 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -13,7 +13,7 @@ import {AaveConfig} from '../config/aave'; import {UniswapConfig} from '../config/uniswap'; import {CommonsConfig} from '../config/commons'; import {ZERO_ADDRESS} from './constants'; -import {BRE} from './misc-utils'; +import {DRE} from './misc-utils'; import {tEthereumAddress} from './types'; import {getParamPerNetwork} from './contracts-helpers'; import {deployWETHMocked} from './contracts-deployments'; @@ -66,13 +66,13 @@ export const getFeeDistributionParamsCommon = ( }; export const getGenesisAaveAdmin = async (config: ICommonConfiguration) => { - const currentNetwork = BRE.network.name; + const currentNetwork = DRE.network.name; const targetAddress = getParamPerNetwork(config.AaveAdmin, currentNetwork); if (targetAddress) { return targetAddress; } const addressList = await Promise.all( - (await BRE.ethers.getSigners()).map((signer) => signer.getAddress()) + (await DRE.ethers.getSigners()).map((signer) => signer.getAddress()) ); const addressIndex = config.AaveAdminIndex; return addressList[addressIndex]; @@ -84,7 +84,7 @@ export const getATokenDomainSeparatorPerNetwork = ( ): tEthereumAddress => getParamPerNetwork(config.ATokenDomainSeparator, network); export const getWethAddress = async (config: ICommonConfiguration) => { - const currentNetwork = BRE.network.name; + const currentNetwork = DRE.network.name; const wethAddress = getParamPerNetwork(config.WETH, currentNetwork); if (wethAddress) { return wethAddress; diff --git a/helpers/contracts-deployments.ts b/helpers/contracts-deployments.ts index 291c069b..a8185ff3 100644 --- a/helpers/contracts-deployments.ts +++ b/helpers/contracts-deployments.ts @@ -1,5 +1,5 @@ import {Contract} from 'ethers'; -import {BRE} from './misc-utils'; +import {DRE} from './misc-utils'; import { tEthereumAddress, eContractid, @@ -9,6 +9,7 @@ import { iMultiPoolsAssets, IReserveParams, PoolConfiguration, + eEthereumNetwork, } from './types'; import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; @@ -50,7 +51,14 @@ import { import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers'; import {StableAndVariableTokensHelperFactory} from '../types/StableAndVariableTokensHelperFactory'; import {MintableDelegationErc20} from '../types/MintableDelegationErc20'; +import {readArtifact as buidlerReadArtifact} from '@nomiclabs/buidler/plugins'; +const readArtifact = async (id: string) => { + if (DRE.network.name === eEthereumNetwork.buidlerevm) { + return buidlerReadArtifact(DRE.config.paths.artifacts, id); + } + return DRE.artifacts.readArtifact(id); +}; export const deployLendingPoolAddressesProvider = async (verify?: boolean) => withSaveAndVerify( await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(), @@ -84,13 +92,13 @@ export const deployReserveLogicLibrary = async (verify?: boolean) => ); export const deployGenericLogic = async (reserveLogic: Contract, verify?: boolean) => { - const genericLogicArtifact = await BRE.artifacts.readArtifact(eContractid.GenericLogic); + const genericLogicArtifact = await readArtifact(eContractid.GenericLogic); const linkedGenericLogicByteCode = linkBytecode(genericLogicArtifact, { [eContractid.ReserveLogic]: reserveLogic.address, }); - const genericLogicFactory = await BRE.ethers.getContractFactory( + const genericLogicFactory = await DRE.ethers.getContractFactory( genericLogicArtifact.abi, linkedGenericLogicByteCode ); @@ -104,14 +112,14 @@ export const deployValidationLogic = async ( genericLogic: Contract, verify?: boolean ) => { - const validationLogicArtifact = await BRE.artifacts.readArtifact(eContractid.ValidationLogic); + const validationLogicArtifact = await readArtifact(eContractid.ValidationLogic); const linkedValidationLogicByteCode = linkBytecode(validationLogicArtifact, { [eContractid.ReserveLogic]: reserveLogic.address, [eContractid.GenericLogic]: genericLogic.address, }); - const validationLogicFactory = await BRE.ethers.getContractFactory( + const validationLogicFactory = await DRE.ethers.getContractFactory( validationLogicArtifact.abi, linkedValidationLogicByteCode ); diff --git a/helpers/contracts-getters.ts b/helpers/contracts-getters.ts index 713fb5cc..74b8564b 100644 --- a/helpers/contracts-getters.ts +++ b/helpers/contracts-getters.ts @@ -26,15 +26,15 @@ import { } from '../types'; import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory'; import {MockTokenMap} from './contracts-helpers'; -import {BRE, getDb} from './misc-utils'; +import {DRE, getDb} from './misc-utils'; import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types'; -export const getFirstSigner = async () => (await BRE.ethers.getSigners())[0]; +export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0]; export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => await LendingPoolAddressesProviderFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); @@ -42,7 +42,7 @@ export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => { return await LendingPoolConfiguratorFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolConfigurator}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.LendingPoolConfigurator}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); @@ -51,55 +51,55 @@ export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress export const getLendingPool = async (address?: tEthereumAddress) => await LendingPoolFactory.connect( address || - (await getDb().get(`${eContractid.LendingPool}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.LendingPool}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getPriceOracle = async (address?: tEthereumAddress) => await PriceOracleFactory.connect( address || - (await getDb().get(`${eContractid.PriceOracle}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.PriceOracle}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getAToken = async (address?: tEthereumAddress) => await ATokenFactory.connect( - address || (await getDb().get(`${eContractid.AToken}.${BRE.network.name}`).value()).address, + address || (await getDb().get(`${eContractid.AToken}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getStableDebtToken = async (address?: tEthereumAddress) => await StableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.StableDebtToken}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.StableDebtToken}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getVariableDebtToken = async (address?: tEthereumAddress) => await VariableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.VariableDebtToken}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.VariableDebtToken}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getMintableErc20 = async (address: tEthereumAddress) => await MintableErc20Factory.connect( address || - (await getDb().get(`${eContractid.MintableERC20}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getIErc20Detailed = async (address: tEthereumAddress) => await Ierc20DetailedFactory.connect( address || - (await getDb().get(`${eContractid.IERC20Detailed}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getAaveProtocolTestHelpers = async (address?: tEthereumAddress) => await AaveProtocolTestHelpersFactory.connect( address || - (await getDb().get(`${eContractid.AaveProtocolTestHelpers}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.AaveProtocolTestHelpers}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); @@ -109,7 +109,7 @@ export const getInterestRateStrategy = async (address?: tEthereumAddress) => address || ( await getDb() - .get(`${eContractid.DefaultReserveInterestRateStrategy}.${BRE.network.name}`) + .get(`${eContractid.DefaultReserveInterestRateStrategy}.${DRE.network.name}`) .value() ).address, await getFirstSigner() @@ -118,7 +118,7 @@ export const getInterestRateStrategy = async (address?: tEthereumAddress) => export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) => await MockFlashLoanReceiverFactory.connect( address || - (await getDb().get(`${eContractid.MockFlashLoanReceiver}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.MockFlashLoanReceiver}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); @@ -126,7 +126,7 @@ export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) => export const getLendingRateOracle = async (address?: tEthereumAddress) => await LendingRateOracleFactory.connect( address || - (await getDb().get(`${eContractid.LendingRateOracle}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.LendingRateOracle}.${DRE.network.name}`).value()).address, await getFirstSigner() ); @@ -136,7 +136,7 @@ export const getMockedTokens = async (config: PoolConfiguration) => { const tokens: MockTokenMap = await tokenSymbols.reduce>( async (acc, tokenSymbol) => { const accumulator = await acc; - const address = db.get(`${tokenSymbol.toUpperCase()}.${BRE.network.name}`).value().address; + const address = db.get(`${tokenSymbol.toUpperCase()}.${DRE.network.name}`).value().address; accumulator[tokenSymbol] = await getMintableErc20(address); return Promise.resolve(acc); }, @@ -150,7 +150,7 @@ export const getAllMockedTokens = async () => { const tokens: MockTokenMap = await Object.keys(TokenContractId).reduce>( async (acc, tokenSymbol) => { const accumulator = await acc; - const address = db.get(`${tokenSymbol.toUpperCase()}.${BRE.network.name}`).value().address; + const address = db.get(`${tokenSymbol.toUpperCase()}.${DRE.network.name}`).value().address; accumulator[tokenSymbol] = await getMintableErc20(address); return Promise.resolve(acc); }, @@ -191,7 +191,7 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu address || ( await getDb() - .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${BRE.network.name}`) + .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${DRE.network.name}`) .value() ).address, await getFirstSigner() @@ -200,14 +200,14 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu export const getReserveLogic = async (address?: tEthereumAddress) => await ReserveLogicFactory.connect( address || - (await getDb().get(`${eContractid.ReserveLogic}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.ReserveLogic}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getGenericLogic = async (address?: tEthereumAddress) => await GenericLogicFactory.connect( address || - (await getDb().get(`${eContractid.GenericLogic}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.GenericLogic}.${DRE.network.name}`).value()).address, await getFirstSigner() ); @@ -216,7 +216,7 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres address || ( await getDb() - .get(`${eContractid.StableAndVariableTokensHelper}.${BRE.network.name}`) + .get(`${eContractid.StableAndVariableTokensHelper}.${DRE.network.name}`) .value() ).address, await getFirstSigner() @@ -225,7 +225,7 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres export const getATokensAndRatesHelper = async (address?: tEthereumAddress) => await ATokensAndRatesHelperFactory.connect( address || - (await getDb().get(`${eContractid.ATokensAndRatesHelper}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.ATokensAndRatesHelper}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); @@ -233,26 +233,26 @@ export const getATokensAndRatesHelper = async (address?: tEthereumAddress) => export const getWETHGateway = async (address?: tEthereumAddress) => await WethGatewayFactory.connect( address || - (await getDb().get(`${eContractid.WETHGateway}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getWETHMocked = async (address?: tEthereumAddress) => await Weth9MockedFactory.connect( - address || (await getDb().get(`${eContractid.WETHMocked}.${BRE.network.name}`).value()).address, + address || (await getDb().get(`${eContractid.WETHMocked}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getMockAToken = async (address?: tEthereumAddress) => await MockATokenFactory.connect( - address || (await getDb().get(`${eContractid.MockAToken}.${BRE.network.name}`).value()).address, + address || (await getDb().get(`${eContractid.MockAToken}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getMockVariableDebtToken = async (address?: tEthereumAddress) => await MockVariableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.MockVariableDebtToken}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.MockVariableDebtToken}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); @@ -260,14 +260,14 @@ export const getMockVariableDebtToken = async (address?: tEthereumAddress) => export const getMockStableDebtToken = async (address?: tEthereumAddress) => await MockStableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.MockStableDebtToken}.${BRE.network.name}`).value()).address, + (await getDb().get(`${eContractid.MockStableDebtToken}.${DRE.network.name}`).value()).address, await getFirstSigner() ); export const getSelfdestructTransferMock = async (address?: tEthereumAddress) => await SelfdestructTransferFactory.connect( address || - (await getDb().get(`${eContractid.SelfdestructTransferMock}.${BRE.network.name}`).value()) + (await getDb().get(`${eContractid.SelfdestructTransferMock}.${DRE.network.name}`).value()) .address, await getFirstSigner() ); diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index 663df086..d651080e 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -2,7 +2,7 @@ import {Contract, Signer, utils, ethers} from 'ethers'; import {signTypedData_v4} from 'eth-sig-util'; import {fromRpcSig, ECDSASignature} from 'ethereumjs-util'; import BigNumber from 'bignumber.js'; -import {getDb, BRE, waitForTx} from './misc-utils'; +import {getDb, DRE, waitForTx} from './misc-utils'; import { tEthereumAddress, eContractid, @@ -14,13 +14,14 @@ import { } from './types'; import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; import {Artifact} from 'hardhat/types'; +import {Artifact as BuidlerArtifact} from '@nomiclabs/buidler/types'; import {verifyContract} from './etherscan-verification'; import {getIErc20Detailed} from './contracts-getters'; export type MockTokenMap = {[symbol: string]: MintableERC20}; export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => { - const currentNetwork = BRE.network.name; + const currentNetwork = DRE.network.name; if (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage')) { console.log(`*** ${contractId} ***\n`); console.log(`Network: ${currentNetwork}`); @@ -43,19 +44,19 @@ export const registerContractInJsonDb = async (contractId: string, contractInsta export const insertContractAddressInDb = async (id: eContractid, address: tEthereumAddress) => await getDb() - .set(`${id}.${BRE.network.name}`, { + .set(`${id}.${DRE.network.name}`, { address, }) .write(); export const getEthersSigners = async (): Promise => - await Promise.all(await BRE.ethers.getSigners()); + await Promise.all(await DRE.ethers.getSigners()); export const getEthersSignersAddresses = async (): Promise => - await Promise.all((await BRE.ethers.getSigners()).map((signer) => signer.getAddress())); + await Promise.all((await DRE.ethers.getSigners()).map((signer) => signer.getAddress())); export const getCurrentBlock = async () => { - return BRE.ethers.provider.getBlockNumber(); + return DRE.ethers.provider.getBlockNumber(); }; export const decodeAbiNumber = (data: string): number => @@ -65,7 +66,7 @@ export const deployContract = async ( contractName: string, args: any[] ): Promise => { - const contract = (await (await BRE.ethers.getContractFactory(contractName)).deploy( + const contract = (await (await DRE.ethers.getContractFactory(contractName)).deploy( ...args )) as ContractType; await waitForTx(contract.deployTransaction); @@ -90,9 +91,9 @@ export const withSaveAndVerify = async ( export const getContract = async ( contractName: string, address: string -): Promise => (await BRE.ethers.getContractAt(contractName, address)) as ContractType; +): Promise => (await DRE.ethers.getContractAt(contractName, address)) as ContractType; -export const linkBytecode = (artifact: Artifact, libraries: any) => { +export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: any) => { let bytecode = artifact.bytecode; for (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) { diff --git a/helpers/etherscan-verification.ts b/helpers/etherscan-verification.ts index f02b00ec..02fe6c52 100644 --- a/helpers/etherscan-verification.ts +++ b/helpers/etherscan-verification.ts @@ -2,7 +2,7 @@ import {exit} from 'process'; import fs from 'fs'; import globby from 'globby'; import {file} from 'tmp-promise'; -import {BRE} from './misc-utils'; +import {DRE} from './misc-utils'; const listSolidityFiles = (dir: string) => globby(`${dir}/**/*.sol`); @@ -14,7 +14,7 @@ const fatalErrors = [ export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan']; export const getEtherscanPath = async (contractName: string) => { - const paths = await listSolidityFiles(BRE.config.paths.sources); + const paths = await listSolidityFiles(DRE.config.paths.sources); const path = paths.find((p) => p.includes(contractName)); if (!path) { throw new Error( @@ -35,7 +35,7 @@ export const verifyContract = async ( constructorArguments: (string | string[])[], libraries?: string ) => { - const currentNetwork = BRE.network.name; + const currentNetwork = DRE.network.name; if (!process.env.ETHERSCAN_KEY) { throw Error('Missing process.env.ETHERSCAN_KEY.'); @@ -82,7 +82,7 @@ export const runTaskWithRetry = async ( try { if (times) { - await BRE.run(task, params); + await DRE.run(task, params); cleanup(); } else { cleanup(); @@ -107,7 +107,7 @@ export const runTaskWithRetry = async ( }; export const checkVerification = () => { - const currentNetwork = BRE.network.name; + const currentNetwork = DRE.network.name; if (!process.env.ETHERSCAN_KEY) { console.error('Missing process.env.ETHERSCAN_KEY.'); exit(3); diff --git a/helpers/misc-utils.ts b/helpers/misc-utils.ts index 91965035..0356fef4 100644 --- a/helpers/misc-utils.ts +++ b/helpers/misc-utils.ts @@ -5,6 +5,7 @@ import FileSync from 'lowdb/adapters/FileSync'; import {WAD} from './constants'; import {Wallet, ContractTransaction} from 'ethers'; import {HardhatRuntimeEnvironment} from 'hardhat/types'; +import {BuidlerRuntimeEnvironment} from '@nomiclabs/buidler/types'; export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed(); @@ -13,9 +14,11 @@ export const stringToBigNumber = (amount: string): BigNumber => new BigNumber(am export const getDb = () => low(new FileSync('./deployed-contracts.json')); -export let BRE: HardhatRuntimeEnvironment = {} as HardhatRuntimeEnvironment; -export const setBRE = (_BRE: HardhatRuntimeEnvironment) => { - BRE = _BRE; +export let DRE: + | HardhatRuntimeEnvironment + | BuidlerRuntimeEnvironment = {} as HardhatRuntimeEnvironment; +export const setDRE = (_DRE: HardhatRuntimeEnvironment | BuidlerRuntimeEnvironment) => { + DRE = _DRE; }; export const sleep = (milliseconds: number) => { @@ -24,21 +27,21 @@ export const sleep = (milliseconds: number) => { export const createRandomAddress = () => Wallet.createRandom().address; -export const evmSnapshot = async () => await BRE.ethers.provider.send('evm_snapshot', []); +export const evmSnapshot = async () => await DRE.ethers.provider.send('evm_snapshot', []); -export const evmRevert = async (id: string) => BRE.ethers.provider.send('evm_revert', [id]); +export const evmRevert = async (id: string) => DRE.ethers.provider.send('evm_revert', [id]); export const timeLatest = async () => { - const block = await BRE.ethers.provider.getBlock('latest'); + const block = await DRE.ethers.provider.getBlock('latest'); return new BigNumber(block.timestamp); }; export const advanceBlock = async (timestamp: number) => - await BRE.ethers.provider.send('evm_mine', [timestamp]); + await DRE.ethers.provider.send('evm_mine', [timestamp]); export const increaseTime = async (secondsToIncrease: number) => { - await BRE.ethers.provider.send('evm_increaseTime', [secondsToIncrease]); - await BRE.ethers.provider.send('evm_mine', []); + await DRE.ethers.provider.send('evm_increaseTime', [secondsToIncrease]); + await DRE.ethers.provider.send('evm_mine', []); }; export const waitForTx = async (tx: ContractTransaction) => await tx.wait(1); @@ -69,7 +72,7 @@ interface DbEntry { } export const printContracts = () => { - const network = BRE.network.name; + const network = DRE.network.name; const db = getDb(); console.log('Contracts deployed at', network); console.log('---------------------------------'); diff --git a/package.json b/package.json index 7b3db65a..fe1490b4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "hardhat:main": "hardhat --network main", "hardhat:docker": "hardhat --network hardhatevm_docker", "compile": "SKIP_LOAD=true hardhat compile", - "test": "TS_NODE_TRANSPILE_ONLY=1 hardhat test", + "test": "SKIP_LOAD=true TS_NODE_TRANSPILE_ONLY=1 hardhat test", "test-scenarios": "npm run test -- test/__setup.spec.ts test/scenario.spec.ts", "aave:evm:dev:migration": "hardhat aave:dev", "aave:evm:full:migration": "hardhat aave:full", @@ -44,7 +44,7 @@ "test-stable-and-atokens": "hardhat test test/__setup.spec.ts test/atoken-transfer.spec.ts test/stable-token.spec.ts", "test-subgraph:scenarios": "hardhat --network hardhatevm_docker test test/__setup.spec.ts test/subgraph-scenarios.spec.ts", "test-weth": "hardhat test test/__setup.spec.ts test/weth-gateway.spec.ts", - "dev:coverage": "buidler coverage --network coverage", + "dev:coverage": "buidler compile --force && buidler coverage --network coverage", "dev:deployment": "hardhat dev-deployment", "dev:deployExample": "hardhat deploy-Example", "dev:prettier": "prettier --write .", diff --git a/tasks/dev/1_mock_tokens.ts b/tasks/dev/1_mock_tokens.ts index 221ccd6b..550135f5 100644 --- a/tasks/dev/1_mock_tokens.ts +++ b/tasks/dev/1_mock_tokens.ts @@ -4,6 +4,6 @@ import {deployAllMockTokens} from '../../helpers/contracts-deployments'; task('dev:deploy-mock-tokens', 'Deploy mock tokens for dev enviroment') .addFlag('verify', 'Verify contracts at Etherscan') .setAction(async ({verify}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); await deployAllMockTokens(verify); }); diff --git a/tasks/dev/2_address_provider_registry.ts b/tasks/dev/2_address_provider_registry.ts index 5d709cad..cdb29e88 100644 --- a/tasks/dev/2_address_provider_registry.ts +++ b/tasks/dev/2_address_provider_registry.ts @@ -11,7 +11,7 @@ task( ) .addFlag('verify', 'Verify contracts at Etherscan') .setAction(async ({verify}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const admin = await (await localBRE.ethers.getSigners())[0].getAddress(); diff --git a/tasks/dev/3_lending_pool.ts b/tasks/dev/3_lending_pool.ts index 819aa0cc..b1aeb58c 100644 --- a/tasks/dev/3_lending_pool.ts +++ b/tasks/dev/3_lending_pool.ts @@ -17,7 +17,7 @@ import {insertContractAddressInDb} from '../../helpers/contracts-helpers'; task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment') .addFlag('verify', 'Verify contracts at Etherscan') .setAction(async ({verify}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const addressesProvider = await getLendingPoolAddressesProvider(); diff --git a/tasks/dev/4_oracles.ts b/tasks/dev/4_oracles.ts index 9814fdf2..a3ce7203 100644 --- a/tasks/dev/4_oracles.ts +++ b/tasks/dev/4_oracles.ts @@ -24,7 +24,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment') .addFlag('verify', 'Verify contracts at Etherscan') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .setAction(async ({verify, pool}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const poolConfig = loadPoolConfig(pool); const { Mocks: {ChainlinkAggregatorPrices, AllAssetsInitialPrices}, diff --git a/tasks/dev/5_initialize.ts b/tasks/dev/5_initialize.ts index 8061588e..aadc6a52 100644 --- a/tasks/dev/5_initialize.ts +++ b/tasks/dev/5_initialize.ts @@ -29,7 +29,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') .addFlag('verify', 'Verify contracts at Etherscan') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .setAction(async ({verify, pool}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const poolConfig = loadPoolConfig(pool); const mockTokens = await getAllMockedTokens(); diff --git a/tasks/dev/6_wallet_balance_provider.ts b/tasks/dev/6_wallet_balance_provider.ts index c84395a4..be7f6419 100644 --- a/tasks/dev/6_wallet_balance_provider.ts +++ b/tasks/dev/6_wallet_balance_provider.ts @@ -6,7 +6,7 @@ import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters'; task('dev:wallet-balance-provider', 'Initialize lending pool configuration.') .addFlag('verify', 'Verify contracts at Etherscan') .setAction(async ({verify}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const addressesProvider = await getLendingPoolAddressesProvider(); await deployWalletBalancerProvider(addressesProvider.address, verify); diff --git a/tasks/full/1_address_provider_registry.ts b/tasks/full/1_address_provider_registry.ts index 00e3fdca..bfe062a8 100644 --- a/tasks/full/1_address_provider_registry.ts +++ b/tasks/full/1_address_provider_registry.ts @@ -16,7 +16,7 @@ task( .addFlag('verify', 'Verify contracts at Etherscan') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .setAction(async ({verify, pool}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const network = localBRE.network.name; const poolConfig = loadPoolConfig(pool); const {ProviderId} = poolConfig; diff --git a/tasks/full/2_lending_pool.ts b/tasks/full/2_lending_pool.ts index b9103a6f..b8b57344 100644 --- a/tasks/full/2_lending_pool.ts +++ b/tasks/full/2_lending_pool.ts @@ -17,7 +17,7 @@ import { task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment') .addFlag('verify', 'Verify contracts at Etherscan') .setAction(async ({verify}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const addressesProvider = await getLendingPoolAddressesProvider(); diff --git a/tasks/full/3_oracles.ts b/tasks/full/3_oracles.ts index 178862d6..dbc255fa 100644 --- a/tasks/full/3_oracles.ts +++ b/tasks/full/3_oracles.ts @@ -19,7 +19,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .setAction(async ({verify, pool}, localBRE) => { try { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const network = localBRE.network.name; const poolConfig = loadPoolConfig(pool); const { diff --git a/tasks/full/5_initialize.ts b/tasks/full/5_initialize.ts index 1ac99fad..6b168dc6 100644 --- a/tasks/full/5_initialize.ts +++ b/tasks/full/5_initialize.ts @@ -23,7 +23,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) .setAction(async ({verify, pool}, localBRE) => { try { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); const network = localBRE.network.name; const poolConfig = loadPoolConfig(pool); const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration; diff --git a/tasks/migrations/aave.dev.ts b/tasks/migrations/aave.dev.ts index 29412f74..1892cb53 100644 --- a/tasks/migrations/aave.dev.ts +++ b/tasks/migrations/aave.dev.ts @@ -1,17 +1,14 @@ import {task} from 'hardhat/config'; import {checkVerification} from '../../helpers/etherscan-verification'; -console.log('ji'); import {ConfigNames} from '../../helpers/configuration'; -console.log('pi'); import {printContracts} from '../../helpers/misc-utils'; -console.log('i'); task('aave:dev', 'Deploy development enviroment') .addOptionalParam('verify', 'Verify contracts at Etherscan') .setAction(async ({verify}, localBRE) => { const POOL_NAME = ConfigNames.Aave; - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); // Prevent loss of gas verifying all the needed ENVs for Etherscan verification if (verify) { diff --git a/tasks/migrations/aave.full.ts b/tasks/migrations/aave.full.ts index 7d9963c8..502a77ae 100644 --- a/tasks/migrations/aave.full.ts +++ b/tasks/migrations/aave.full.ts @@ -10,7 +10,7 @@ task('aave:full', 'Deploy development enviroment') const POOL_NAME = ConfigNames.Aave; const network = localBRE.network.name; - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); // Prevent loss of gas verifying all the needed ENVs for Etherscan verification if (verify) { diff --git a/tasks/migrations/uniswap.dev.ts b/tasks/migrations/uniswap.dev.ts index d2c56acf..70a31f49 100644 --- a/tasks/migrations/uniswap.dev.ts +++ b/tasks/migrations/uniswap.dev.ts @@ -7,7 +7,7 @@ task('uniswap:dev', 'Deploy development enviroment') .setAction(async ({verify}, localBRE) => { const POOL_NAME = ConfigNames.Uniswap; - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); // Prevent loss of gas verifying all the needed ENVs for Etherscan verification if (verify) { diff --git a/tasks/migrations/uniswap.full.ts b/tasks/migrations/uniswap.full.ts index 0dbc4204..bca82466 100644 --- a/tasks/migrations/uniswap.full.ts +++ b/tasks/migrations/uniswap.full.ts @@ -7,7 +7,7 @@ task('uniswap:full', 'Deploy development enviroment') .setAction(async ({verify}, localBRE) => { const POOL_NAME = ConfigNames.Uniswap; - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); // Prevent loss of gas verifying all the needed ENVs for Etherscan verification if (verify) { diff --git a/tasks/misc/print-contracts.ts b/tasks/misc/print-contracts.ts index 51e08ec7..d3caf0cc 100644 --- a/tasks/misc/print-contracts.ts +++ b/tasks/misc/print-contracts.ts @@ -1,9 +1,9 @@ import {task} from 'hardhat/config'; import {printContracts} from '../../helpers/misc-utils'; -task('print-contracts', 'Inits the BRE, to have access to all the plugins').setAction( +task('print-contracts', 'Inits the DRE, to have access to all the plugins').setAction( async ({}, localBRE) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); printContracts(); } ); diff --git a/tasks/misc/set-bre.ts b/tasks/misc/set-bre.ts index 8156aadb..a1cb29c5 100644 --- a/tasks/misc/set-bre.ts +++ b/tasks/misc/set-bre.ts @@ -1,9 +1,9 @@ import {task} from 'hardhat/config'; -import {setBRE} from '../../helpers/misc-utils'; +import {setDRE} from '../../helpers/misc-utils'; -task(`set-bre`, `Inits the BRE, to have access to all the plugins' objects`).setAction( - async (_, _BRE) => { - setBRE(_BRE); - return _BRE; +task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction( + async (_, _DRE) => { + setDRE(_DRE); + return _DRE; } ); diff --git a/tasks/misc/verify-sc.ts b/tasks/misc/verify-sc.ts index b5fbf650..854aa36c 100644 --- a/tasks/misc/verify-sc.ts +++ b/tasks/misc/verify-sc.ts @@ -8,7 +8,7 @@ interface VerifyParams { libraries: string; } -task('verify-sc', 'Inits the BRE, to have access to all the plugins') +task('verify-sc', 'Inits the DRE, to have access to all the plugins') .addParam('contractName', 'Name of the Solidity smart contract') .addParam('address', 'Ethereum address of the smart contract') .addOptionalParam( @@ -25,7 +25,7 @@ task('verify-sc', 'Inits the BRE, to have access to all the plugins') {contractName, address, constructorArguments = [], libraries}: VerifyParams, localBRE ) => { - await localBRE.run('set-bre'); + await localBRE.run('set-DRE'); checkVerification(); diff --git a/test/__setup.spec.ts b/test/__setup.spec.ts index 09079f47..b5c7f1dc 100644 --- a/test/__setup.spec.ts +++ b/test/__setup.spec.ts @@ -263,7 +263,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { }; before(async () => { - await rawBRE.run('set-bre'); + await rawBRE.run('set-DRE'); const [deployer, secondaryWallet] = await getEthersSigners(); console.log('-> Deploying test environment...'); await buildTestEnv(deployer, secondaryWallet); diff --git a/test/atoken-permit.spec.ts b/test/atoken-permit.spec.ts index 44c90008..aa680ee3 100644 --- a/test/atoken-permit.spec.ts +++ b/test/atoken-permit.spec.ts @@ -5,7 +5,7 @@ import {expect} from 'chai'; import {ethers} from 'ethers'; import {eEthereumNetwork} from '../helpers/types'; import {makeSuite, TestEnv} from './helpers/make-suite'; -import {BRE} from '../helpers/misc-utils'; +import {DRE} from '../helpers/misc-utils'; import { ConfigNames, getATokenDomainSeparatorPerNetwork, @@ -47,7 +47,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const tokenName = await aDai.name(); - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const expiration = 0; const nonce = (await aDai._nonces(owner.address)).toNumber(); const permitAmount = ethers.utils.parseEther('2').toString(); @@ -92,7 +92,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const owner = deployer; const spender = users[1]; - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const deadline = MAX_UINT_AMOUNT; const nonce = (await aDai._nonces(owner.address)).toNumber(); const permitAmount = parseEther('2').toString(); @@ -134,7 +134,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const owner = deployer; const spender = users[1]; - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const deadline = MAX_UINT_AMOUNT; const nonce = (await aDai._nonces(owner.address)).toNumber(); const permitAmount = '0'; @@ -180,7 +180,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const owner = deployer; const spender = users[1]; - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const deadline = MAX_UINT_AMOUNT; const nonce = 1000; const permitAmount = '0'; @@ -215,7 +215,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const owner = deployer; const spender = users[1]; - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const expiration = '1'; const nonce = (await aDai._nonces(owner.address)).toNumber(); const permitAmount = '0'; @@ -250,7 +250,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const owner = deployer; const spender = users[1]; - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const deadline = MAX_UINT_AMOUNT; const nonce = (await aDai._nonces(owner.address)).toNumber(); const permitAmount = '0'; @@ -285,7 +285,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { const owner = deployer; const spender = users[1]; - const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; + const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID; const expiration = MAX_UINT_AMOUNT; const nonce = (await aDai._nonces(owner.address)).toNumber(); const permitAmount = '0'; diff --git a/test/delegation-aware-atoken.spec.ts b/test/delegation-aware-atoken.spec.ts index 7170cc22..cc055c0d 100644 --- a/test/delegation-aware-atoken.spec.ts +++ b/test/delegation-aware-atoken.spec.ts @@ -5,7 +5,7 @@ import {expect} from 'chai'; import {ethers} from 'ethers'; import {eEthereumNetwork, ProtocolErrors} from '../helpers/types'; import {makeSuite, TestEnv} from './helpers/make-suite'; -import {BRE} from '../helpers/misc-utils'; +import {DRE} from '../helpers/misc-utils'; import { ConfigNames, getATokenDomainSeparatorPerNetwork, diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index d998962b..c6feab6b 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -21,7 +21,7 @@ import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers'; import {getAToken, getMintableErc20} from '../../helpers/contracts-getters'; import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants'; import {SignerWithAddress, TestEnv} from './make-suite'; -import {BRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils'; +import {DRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils'; import chai from 'chai'; import {ReserveData, UserReserveData} from './utils/interfaces'; @@ -729,9 +729,9 @@ export const getTxCostAndTimestamp = async (tx: ContractReceipt) => { if (!tx.blockNumber || !tx.transactionHash || !tx.cumulativeGasUsed) { throw new Error('No tx blocknumber'); } - const txTimestamp = new BigNumber((await BRE.ethers.provider.getBlock(tx.blockNumber)).timestamp); + const txTimestamp = new BigNumber((await DRE.ethers.provider.getBlock(tx.blockNumber)).timestamp); - const txInfo = await BRE.ethers.provider.getTransaction(tx.transactionHash); + const txInfo = await DRE.ethers.provider.getTransaction(tx.transactionHash); const txCost = new BigNumber(tx.cumulativeGasUsed.toString()).multipliedBy( txInfo.gasPrice.toString() ); diff --git a/test/helpers/make-suite.ts b/test/helpers/make-suite.ts index b875193d..1099b7b2 100644 --- a/test/helpers/make-suite.ts +++ b/test/helpers/make-suite.ts @@ -1,4 +1,4 @@ -import {evmRevert, evmSnapshot, BRE} from '../../helpers/misc-utils'; +import {evmRevert, evmSnapshot, DRE} from '../../helpers/misc-utils'; import {Signer} from 'ethers'; import { getLendingPool, @@ -59,7 +59,7 @@ export interface TestEnv { let buidlerevmSnapshotId: string = '0x1'; const setBuidlerevmSnapshotId = (id: string) => { - if (BRE.network.name === 'hardhat') { + if (DRE.network.name === 'hardhat') { buidlerevmSnapshotId = id; } }; diff --git a/test/helpers/utils/helpers.ts b/test/helpers/utils/helpers.ts index 7a909c20..c51a8960 100644 --- a/test/helpers/utils/helpers.ts +++ b/test/helpers/utils/helpers.ts @@ -10,7 +10,7 @@ import { } from '../../../helpers/contracts-getters'; import {tEthereumAddress} from '../../../helpers/types'; import BigNumber from 'bignumber.js'; -import {getDb, BRE} from '../../../helpers/misc-utils'; +import {getDb, DRE} from '../../../helpers/misc-utils'; import {AaveProtocolTestHelpers} from '../../../types/AaveProtocolTestHelpers'; export const getReserveData = async ( @@ -104,7 +104,7 @@ export const getUserData = async ( export const getReserveAddressFromSymbol = async (symbol: string) => { const token = await getMintableErc20( - (await getDb().get(`${symbol}.${BRE.network.name}`).value()).address + (await getDb().get(`${symbol}.${DRE.network.name}`).value()).address ); if (!token) { diff --git a/test/liquidation-atoken.spec.ts b/test/liquidation-atoken.spec.ts index 78b97842..b0f65336 100644 --- a/test/liquidation-atoken.spec.ts +++ b/test/liquidation-atoken.spec.ts @@ -1,6 +1,6 @@ import BigNumber from 'bignumber.js'; -import {BRE} from '../helpers/misc-utils'; +import {DRE} from '../helpers/misc-utils'; import {oneEther} from '../helpers/constants'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {makeSuite} from './helpers/make-suite'; @@ -185,7 +185,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => } const txTimestamp = new BigNumber( - (await BRE.ethers.provider.getBlock(tx.blockNumber)).timestamp + (await DRE.ethers.provider.getBlock(tx.blockNumber)).timestamp ); const variableDebtBeforeTx = calcExpectedVariableDebtTokenBalance( diff --git a/test/liquidation-underlying.spec.ts b/test/liquidation-underlying.spec.ts index 3a735e79..cccd46e8 100644 --- a/test/liquidation-underlying.spec.ts +++ b/test/liquidation-underlying.spec.ts @@ -1,6 +1,6 @@ import BigNumber from 'bignumber.js'; -import {BRE, increaseTime} from '../helpers/misc-utils'; +import {DRE, increaseTime} from '../helpers/misc-utils'; import {oneEther} from '../helpers/constants'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {makeSuite} from './helpers/make-suite'; @@ -185,7 +185,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', return; } const txTimestamp = new BigNumber( - (await BRE.ethers.provider.getBlock(tx.blockNumber)).timestamp + (await DRE.ethers.provider.getBlock(tx.blockNumber)).timestamp ); const stableDebtBeforeTx = calcExpectedStableDebtTokenBalance( @@ -302,7 +302,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', const usdcReserveDataBefore = await helpersContract.getReserveData(usdc.address); const ethReserveDataBefore = await helpersContract.getReserveData(weth.address); - const amountToLiquidate = BRE.ethers.BigNumber.from( + const amountToLiquidate = DRE.ethers.BigNumber.from( userReserveDataBefore.currentStableDebt.toString() ) .div(2) diff --git a/test/weth-gateway.spec.ts b/test/weth-gateway.spec.ts index f201a218..402ddabb 100644 --- a/test/weth-gateway.spec.ts +++ b/test/weth-gateway.spec.ts @@ -2,7 +2,7 @@ import {MAX_UINT_AMOUNT} from '../helpers/constants'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {makeSuite, TestEnv} from './helpers/make-suite'; import {formatEther, parseEther, parseUnits} from 'ethers/lib/utils'; -import {BRE, waitForTx} from '../helpers/misc-utils'; +import {DRE, waitForTx} from '../helpers/misc-utils'; import {BigNumber} from 'ethers'; import {getStableDebtToken, getVariableDebtToken} from '../helpers/contracts-getters'; import {WethGateway} from '../types/WethGateway'; @@ -195,7 +195,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => user.signer.sendTransaction({ to: wethGateway.address, value: amount, - gasLimit: BRE.network.config.gas, + gasLimit: DRE.network.config.gas, }) ).to.be.revertedWith('Receive not allowed'); }); @@ -205,7 +205,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => const user = users[0]; const amount = parseEther('1'); const fakeABI = ['function wantToCallFallback()']; - const abiCoder = new BRE.ethers.utils.Interface(fakeABI); + const abiCoder = new DRE.ethers.utils.Interface(fakeABI); const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []); // Call fallback function with value @@ -214,7 +214,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => to: wethGateway.address, data: fakeMethodEncoded, value: amount, - gasLimit: BRE.network.config.gas, + gasLimit: DRE.network.config.gas, }) ).to.be.revertedWith('Fallback not allowed'); }); @@ -224,7 +224,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => const user = users[0]; const fakeABI = ['function wantToCallFallback()']; - const abiCoder = new BRE.ethers.utils.Interface(fakeABI); + const abiCoder = new DRE.ethers.utils.Interface(fakeABI); const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []); // Call fallback function without value @@ -232,7 +232,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => user.signer.sendTransaction({ to: wethGateway.address, data: fakeMethodEncoded, - gasLimit: BRE.network.config.gas, + gasLimit: DRE.network.config.gas, }) ).to.be.revertedWith('Fallback not allowed'); }); @@ -299,7 +299,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => await wethGateway.connect(deployer.signer).emergencyEtherTransfer(user.address, amount); const userBalanceAfterRecovery = await user.signer.getBalance(); - const wethGatewayAfterRecovery = await BRE.ethers.provider.getBalance(wethGateway.address); + const wethGatewayAfterRecovery = await DRE.ethers.provider.getBalance(wethGateway.address); expect(userBalanceAfterRecovery).to.be.eq( userBalancePriorCall.sub(gasFees),