Support Buidler to run solidity-coverage until is ported.

This commit is contained in:
David Racero 2020-11-05 13:44:20 +01:00
parent 21e57a1a37
commit 729b642ea5
35 changed files with 138 additions and 128 deletions

View File

@ -1,10 +1,11 @@
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import {usePlugin} from '@nomiclabs/buidler/config'; import {usePlugin, task} from '@nomiclabs/buidler/config';
// @ts-ignore // @ts-ignore
import {accounts} from './test-wallets.js'; import {accounts} from './test-wallets.js';
import {eEthereumNetwork} from './helpers/types'; import {eEthereumNetwork} from './helpers/types';
import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants'; import {BUIDLEREVM_CHAINID, COVERAGE_CHAINID} from './helpers/buidler-constants';
import {setDRE} from './helpers/misc-utils';
usePlugin('@nomiclabs/buidler-ethers'); usePlugin('@nomiclabs/buidler-ethers');
usePlugin('buidler-typechain'); usePlugin('buidler-typechain');
@ -22,15 +23,12 @@ const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0"; const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || ''; const MNEMONIC = process.env.MNEMONIC || '';
// Prevent to load scripts before compilation and typechain task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
if (!SKIP_LOAD) { async (_, _DRE) => {
['misc', 'migrations', 'dev', 'full'].forEach((folder) => { setDRE(_DRE);
const tasksPath = path.join(__dirname, 'tasks', folder); return _DRE;
fs.readdirSync(tasksPath) }
.filter((pth) => pth.includes('.ts')) );
.forEach((task) => require(`${tasksPath}/${task}`));
});
}
const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => { const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => {
return { return {

View File

@ -23,6 +23,7 @@ const MNEMONIC = process.env.MNEMONIC || '';
// Prevent to load scripts before compilation and typechain // Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) { if (!SKIP_LOAD) {
console.log('NOT SKPP');
['misc', 'migrations', 'dev', 'full'].forEach((folder) => { ['misc', 'migrations', 'dev', 'full'].forEach((folder) => {
const tasksPath = path.join(__dirname, 'tasks', folder); const tasksPath = path.join(__dirname, 'tasks', folder);
fs.readdirSync(tasksPath) 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) => { const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => {
return { return {
url: `https://${networkName}.infura.io/v3/${INFURA_KEY}`, url: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,

View File

@ -13,7 +13,7 @@ import {AaveConfig} from '../config/aave';
import {UniswapConfig} from '../config/uniswap'; import {UniswapConfig} from '../config/uniswap';
import {CommonsConfig} from '../config/commons'; import {CommonsConfig} from '../config/commons';
import {ZERO_ADDRESS} from './constants'; import {ZERO_ADDRESS} from './constants';
import {BRE} from './misc-utils'; import {DRE} from './misc-utils';
import {tEthereumAddress} from './types'; import {tEthereumAddress} from './types';
import {getParamPerNetwork} from './contracts-helpers'; import {getParamPerNetwork} from './contracts-helpers';
import {deployWETHMocked} from './contracts-deployments'; import {deployWETHMocked} from './contracts-deployments';
@ -66,13 +66,13 @@ export const getFeeDistributionParamsCommon = (
}; };
export const getGenesisAaveAdmin = async (config: ICommonConfiguration) => { export const getGenesisAaveAdmin = async (config: ICommonConfiguration) => {
const currentNetwork = BRE.network.name; const currentNetwork = DRE.network.name;
const targetAddress = getParamPerNetwork(config.AaveAdmin, <eEthereumNetwork>currentNetwork); const targetAddress = getParamPerNetwork(config.AaveAdmin, <eEthereumNetwork>currentNetwork);
if (targetAddress) { if (targetAddress) {
return targetAddress; return targetAddress;
} }
const addressList = await Promise.all( 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; const addressIndex = config.AaveAdminIndex;
return addressList[addressIndex]; return addressList[addressIndex];
@ -84,7 +84,7 @@ export const getATokenDomainSeparatorPerNetwork = (
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network); ): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
export const getWethAddress = async (config: ICommonConfiguration) => { export const getWethAddress = async (config: ICommonConfiguration) => {
const currentNetwork = BRE.network.name; const currentNetwork = DRE.network.name;
const wethAddress = getParamPerNetwork(config.WETH, <eEthereumNetwork>currentNetwork); const wethAddress = getParamPerNetwork(config.WETH, <eEthereumNetwork>currentNetwork);
if (wethAddress) { if (wethAddress) {
return wethAddress; return wethAddress;

View File

@ -1,5 +1,5 @@
import {Contract} from 'ethers'; import {Contract} from 'ethers';
import {BRE} from './misc-utils'; import {DRE} from './misc-utils';
import { import {
tEthereumAddress, tEthereumAddress,
eContractid, eContractid,
@ -9,6 +9,7 @@ import {
iMultiPoolsAssets, iMultiPoolsAssets,
IReserveParams, IReserveParams,
PoolConfiguration, PoolConfiguration,
eEthereumNetwork,
} from './types'; } from './types';
import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
@ -50,7 +51,14 @@ import {
import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers'; import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers';
import {StableAndVariableTokensHelperFactory} from '../types/StableAndVariableTokensHelperFactory'; import {StableAndVariableTokensHelperFactory} from '../types/StableAndVariableTokensHelperFactory';
import {MintableDelegationErc20} from '../types/MintableDelegationErc20'; 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) => export const deployLendingPoolAddressesProvider = async (verify?: boolean) =>
withSaveAndVerify( withSaveAndVerify(
await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(), await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(),
@ -84,13 +92,13 @@ export const deployReserveLogicLibrary = async (verify?: boolean) =>
); );
export const deployGenericLogic = async (reserveLogic: Contract, 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, { const linkedGenericLogicByteCode = linkBytecode(genericLogicArtifact, {
[eContractid.ReserveLogic]: reserveLogic.address, [eContractid.ReserveLogic]: reserveLogic.address,
}); });
const genericLogicFactory = await BRE.ethers.getContractFactory( const genericLogicFactory = await DRE.ethers.getContractFactory(
genericLogicArtifact.abi, genericLogicArtifact.abi,
linkedGenericLogicByteCode linkedGenericLogicByteCode
); );
@ -104,14 +112,14 @@ export const deployValidationLogic = async (
genericLogic: Contract, genericLogic: Contract,
verify?: boolean verify?: boolean
) => { ) => {
const validationLogicArtifact = await BRE.artifacts.readArtifact(eContractid.ValidationLogic); const validationLogicArtifact = await readArtifact(eContractid.ValidationLogic);
const linkedValidationLogicByteCode = linkBytecode(validationLogicArtifact, { const linkedValidationLogicByteCode = linkBytecode(validationLogicArtifact, {
[eContractid.ReserveLogic]: reserveLogic.address, [eContractid.ReserveLogic]: reserveLogic.address,
[eContractid.GenericLogic]: genericLogic.address, [eContractid.GenericLogic]: genericLogic.address,
}); });
const validationLogicFactory = await BRE.ethers.getContractFactory( const validationLogicFactory = await DRE.ethers.getContractFactory(
validationLogicArtifact.abi, validationLogicArtifact.abi,
linkedValidationLogicByteCode linkedValidationLogicByteCode
); );

View File

@ -26,15 +26,15 @@ import {
} from '../types'; } from '../types';
import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory'; import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory';
import {MockTokenMap} from './contracts-helpers'; import {MockTokenMap} from './contracts-helpers';
import {BRE, getDb} from './misc-utils'; import {DRE, getDb} from './misc-utils';
import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types'; 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) => export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) =>
await LendingPoolAddressesProviderFactory.connect( await LendingPoolAddressesProviderFactory.connect(
address || address ||
(await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );
@ -42,7 +42,7 @@ export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress
export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => { export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => {
return await LendingPoolConfiguratorFactory.connect( return await LendingPoolConfiguratorFactory.connect(
address || address ||
(await getDb().get(`${eContractid.LendingPoolConfigurator}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.LendingPoolConfigurator}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );
@ -51,55 +51,55 @@ export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress
export const getLendingPool = async (address?: tEthereumAddress) => export const getLendingPool = async (address?: tEthereumAddress) =>
await LendingPoolFactory.connect( await LendingPoolFactory.connect(
address || address ||
(await getDb().get(`${eContractid.LendingPool}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.LendingPool}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getPriceOracle = async (address?: tEthereumAddress) => export const getPriceOracle = async (address?: tEthereumAddress) =>
await PriceOracleFactory.connect( await PriceOracleFactory.connect(
address || address ||
(await getDb().get(`${eContractid.PriceOracle}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.PriceOracle}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getAToken = async (address?: tEthereumAddress) => export const getAToken = async (address?: tEthereumAddress) =>
await ATokenFactory.connect( 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() await getFirstSigner()
); );
export const getStableDebtToken = async (address?: tEthereumAddress) => export const getStableDebtToken = async (address?: tEthereumAddress) =>
await StableDebtTokenFactory.connect( await StableDebtTokenFactory.connect(
address || address ||
(await getDb().get(`${eContractid.StableDebtToken}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.StableDebtToken}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getVariableDebtToken = async (address?: tEthereumAddress) => export const getVariableDebtToken = async (address?: tEthereumAddress) =>
await VariableDebtTokenFactory.connect( await VariableDebtTokenFactory.connect(
address || address ||
(await getDb().get(`${eContractid.VariableDebtToken}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.VariableDebtToken}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getMintableErc20 = async (address: tEthereumAddress) => export const getMintableErc20 = async (address: tEthereumAddress) =>
await MintableErc20Factory.connect( await MintableErc20Factory.connect(
address || address ||
(await getDb().get(`${eContractid.MintableERC20}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getIErc20Detailed = async (address: tEthereumAddress) => export const getIErc20Detailed = async (address: tEthereumAddress) =>
await Ierc20DetailedFactory.connect( await Ierc20DetailedFactory.connect(
address || address ||
(await getDb().get(`${eContractid.IERC20Detailed}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getAaveProtocolTestHelpers = async (address?: tEthereumAddress) => export const getAaveProtocolTestHelpers = async (address?: tEthereumAddress) =>
await AaveProtocolTestHelpersFactory.connect( await AaveProtocolTestHelpersFactory.connect(
address || address ||
(await getDb().get(`${eContractid.AaveProtocolTestHelpers}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.AaveProtocolTestHelpers}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );
@ -109,7 +109,7 @@ export const getInterestRateStrategy = async (address?: tEthereumAddress) =>
address || address ||
( (
await getDb() await getDb()
.get(`${eContractid.DefaultReserveInterestRateStrategy}.${BRE.network.name}`) .get(`${eContractid.DefaultReserveInterestRateStrategy}.${DRE.network.name}`)
.value() .value()
).address, ).address,
await getFirstSigner() await getFirstSigner()
@ -118,7 +118,7 @@ export const getInterestRateStrategy = async (address?: tEthereumAddress) =>
export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) => export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) =>
await MockFlashLoanReceiverFactory.connect( await MockFlashLoanReceiverFactory.connect(
address || address ||
(await getDb().get(`${eContractid.MockFlashLoanReceiver}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.MockFlashLoanReceiver}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );
@ -126,7 +126,7 @@ export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) =>
export const getLendingRateOracle = async (address?: tEthereumAddress) => export const getLendingRateOracle = async (address?: tEthereumAddress) =>
await LendingRateOracleFactory.connect( await LendingRateOracleFactory.connect(
address || address ||
(await getDb().get(`${eContractid.LendingRateOracle}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.LendingRateOracle}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
@ -136,7 +136,7 @@ export const getMockedTokens = async (config: PoolConfiguration) => {
const tokens: MockTokenMap = await tokenSymbols.reduce<Promise<MockTokenMap>>( const tokens: MockTokenMap = await tokenSymbols.reduce<Promise<MockTokenMap>>(
async (acc, tokenSymbol) => { async (acc, tokenSymbol) => {
const accumulator = await acc; 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); accumulator[tokenSymbol] = await getMintableErc20(address);
return Promise.resolve(acc); return Promise.resolve(acc);
}, },
@ -150,7 +150,7 @@ export const getAllMockedTokens = async () => {
const tokens: MockTokenMap = await Object.keys(TokenContractId).reduce<Promise<MockTokenMap>>( const tokens: MockTokenMap = await Object.keys(TokenContractId).reduce<Promise<MockTokenMap>>(
async (acc, tokenSymbol) => { async (acc, tokenSymbol) => {
const accumulator = await acc; 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); accumulator[tokenSymbol] = await getMintableErc20(address);
return Promise.resolve(acc); return Promise.resolve(acc);
}, },
@ -191,7 +191,7 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu
address || address ||
( (
await getDb() await getDb()
.get(`${eContractid.LendingPoolAddressesProviderRegistry}.${BRE.network.name}`) .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${DRE.network.name}`)
.value() .value()
).address, ).address,
await getFirstSigner() await getFirstSigner()
@ -200,14 +200,14 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu
export const getReserveLogic = async (address?: tEthereumAddress) => export const getReserveLogic = async (address?: tEthereumAddress) =>
await ReserveLogicFactory.connect( await ReserveLogicFactory.connect(
address || address ||
(await getDb().get(`${eContractid.ReserveLogic}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.ReserveLogic}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getGenericLogic = async (address?: tEthereumAddress) => export const getGenericLogic = async (address?: tEthereumAddress) =>
await GenericLogicFactory.connect( await GenericLogicFactory.connect(
address || address ||
(await getDb().get(`${eContractid.GenericLogic}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.GenericLogic}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
@ -216,7 +216,7 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres
address || address ||
( (
await getDb() await getDb()
.get(`${eContractid.StableAndVariableTokensHelper}.${BRE.network.name}`) .get(`${eContractid.StableAndVariableTokensHelper}.${DRE.network.name}`)
.value() .value()
).address, ).address,
await getFirstSigner() await getFirstSigner()
@ -225,7 +225,7 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres
export const getATokensAndRatesHelper = async (address?: tEthereumAddress) => export const getATokensAndRatesHelper = async (address?: tEthereumAddress) =>
await ATokensAndRatesHelperFactory.connect( await ATokensAndRatesHelperFactory.connect(
address || address ||
(await getDb().get(`${eContractid.ATokensAndRatesHelper}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.ATokensAndRatesHelper}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );
@ -233,26 +233,26 @@ export const getATokensAndRatesHelper = async (address?: tEthereumAddress) =>
export const getWETHGateway = async (address?: tEthereumAddress) => export const getWETHGateway = async (address?: tEthereumAddress) =>
await WethGatewayFactory.connect( await WethGatewayFactory.connect(
address || address ||
(await getDb().get(`${eContractid.WETHGateway}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getWETHMocked = async (address?: tEthereumAddress) => export const getWETHMocked = async (address?: tEthereumAddress) =>
await Weth9MockedFactory.connect( 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() await getFirstSigner()
); );
export const getMockAToken = async (address?: tEthereumAddress) => export const getMockAToken = async (address?: tEthereumAddress) =>
await MockATokenFactory.connect( 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() await getFirstSigner()
); );
export const getMockVariableDebtToken = async (address?: tEthereumAddress) => export const getMockVariableDebtToken = async (address?: tEthereumAddress) =>
await MockVariableDebtTokenFactory.connect( await MockVariableDebtTokenFactory.connect(
address || address ||
(await getDb().get(`${eContractid.MockVariableDebtToken}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.MockVariableDebtToken}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );
@ -260,14 +260,14 @@ export const getMockVariableDebtToken = async (address?: tEthereumAddress) =>
export const getMockStableDebtToken = async (address?: tEthereumAddress) => export const getMockStableDebtToken = async (address?: tEthereumAddress) =>
await MockStableDebtTokenFactory.connect( await MockStableDebtTokenFactory.connect(
address || address ||
(await getDb().get(`${eContractid.MockStableDebtToken}.${BRE.network.name}`).value()).address, (await getDb().get(`${eContractid.MockStableDebtToken}.${DRE.network.name}`).value()).address,
await getFirstSigner() await getFirstSigner()
); );
export const getSelfdestructTransferMock = async (address?: tEthereumAddress) => export const getSelfdestructTransferMock = async (address?: tEthereumAddress) =>
await SelfdestructTransferFactory.connect( await SelfdestructTransferFactory.connect(
address || address ||
(await getDb().get(`${eContractid.SelfdestructTransferMock}.${BRE.network.name}`).value()) (await getDb().get(`${eContractid.SelfdestructTransferMock}.${DRE.network.name}`).value())
.address, .address,
await getFirstSigner() await getFirstSigner()
); );

View File

@ -2,7 +2,7 @@ import {Contract, Signer, utils, ethers} from 'ethers';
import {signTypedData_v4} from 'eth-sig-util'; import {signTypedData_v4} from 'eth-sig-util';
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util'; import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import {getDb, BRE, waitForTx} from './misc-utils'; import {getDb, DRE, waitForTx} from './misc-utils';
import { import {
tEthereumAddress, tEthereumAddress,
eContractid, eContractid,
@ -14,13 +14,14 @@ import {
} from './types'; } from './types';
import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
import {Artifact} from 'hardhat/types'; import {Artifact} from 'hardhat/types';
import {Artifact as BuidlerArtifact} from '@nomiclabs/buidler/types';
import {verifyContract} from './etherscan-verification'; import {verifyContract} from './etherscan-verification';
import {getIErc20Detailed} from './contracts-getters'; import {getIErc20Detailed} from './contracts-getters';
export type MockTokenMap = {[symbol: string]: MintableERC20}; export type MockTokenMap = {[symbol: string]: MintableERC20};
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => { export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
const currentNetwork = BRE.network.name; const currentNetwork = DRE.network.name;
if (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage')) { if (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage')) {
console.log(`*** ${contractId} ***\n`); console.log(`*** ${contractId} ***\n`);
console.log(`Network: ${currentNetwork}`); console.log(`Network: ${currentNetwork}`);
@ -43,19 +44,19 @@ export const registerContractInJsonDb = async (contractId: string, contractInsta
export const insertContractAddressInDb = async (id: eContractid, address: tEthereumAddress) => export const insertContractAddressInDb = async (id: eContractid, address: tEthereumAddress) =>
await getDb() await getDb()
.set(`${id}.${BRE.network.name}`, { .set(`${id}.${DRE.network.name}`, {
address, address,
}) })
.write(); .write();
export const getEthersSigners = async (): Promise<Signer[]> => export const getEthersSigners = async (): Promise<Signer[]> =>
await Promise.all(await BRE.ethers.getSigners()); await Promise.all(await DRE.ethers.getSigners());
export const getEthersSignersAddresses = async (): Promise<tEthereumAddress[]> => export const getEthersSignersAddresses = async (): Promise<tEthereumAddress[]> =>
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 () => { export const getCurrentBlock = async () => {
return BRE.ethers.provider.getBlockNumber(); return DRE.ethers.provider.getBlockNumber();
}; };
export const decodeAbiNumber = (data: string): number => export const decodeAbiNumber = (data: string): number =>
@ -65,7 +66,7 @@ export const deployContract = async <ContractType extends Contract>(
contractName: string, contractName: string,
args: any[] args: any[]
): Promise<ContractType> => { ): Promise<ContractType> => {
const contract = (await (await BRE.ethers.getContractFactory(contractName)).deploy( const contract = (await (await DRE.ethers.getContractFactory(contractName)).deploy(
...args ...args
)) as ContractType; )) as ContractType;
await waitForTx(contract.deployTransaction); await waitForTx(contract.deployTransaction);
@ -90,9 +91,9 @@ export const withSaveAndVerify = async <ContractType extends Contract>(
export const getContract = async <ContractType extends Contract>( export const getContract = async <ContractType extends Contract>(
contractName: string, contractName: string,
address: string address: string
): Promise<ContractType> => (await BRE.ethers.getContractAt(contractName, address)) as ContractType; ): Promise<ContractType> => (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; let bytecode = artifact.bytecode;
for (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) { for (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) {

View File

@ -2,7 +2,7 @@ import {exit} from 'process';
import fs from 'fs'; import fs from 'fs';
import globby from 'globby'; import globby from 'globby';
import {file} from 'tmp-promise'; import {file} from 'tmp-promise';
import {BRE} from './misc-utils'; import {DRE} from './misc-utils';
const listSolidityFiles = (dir: string) => globby(`${dir}/**/*.sol`); const listSolidityFiles = (dir: string) => globby(`${dir}/**/*.sol`);
@ -14,7 +14,7 @@ const fatalErrors = [
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan']; export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan'];
export const getEtherscanPath = async (contractName: string) => { 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)); const path = paths.find((p) => p.includes(contractName));
if (!path) { if (!path) {
throw new Error( throw new Error(
@ -35,7 +35,7 @@ export const verifyContract = async (
constructorArguments: (string | string[])[], constructorArguments: (string | string[])[],
libraries?: string libraries?: string
) => { ) => {
const currentNetwork = BRE.network.name; const currentNetwork = DRE.network.name;
if (!process.env.ETHERSCAN_KEY) { if (!process.env.ETHERSCAN_KEY) {
throw Error('Missing process.env.ETHERSCAN_KEY.'); throw Error('Missing process.env.ETHERSCAN_KEY.');
@ -82,7 +82,7 @@ export const runTaskWithRetry = async (
try { try {
if (times) { if (times) {
await BRE.run(task, params); await DRE.run(task, params);
cleanup(); cleanup();
} else { } else {
cleanup(); cleanup();
@ -107,7 +107,7 @@ export const runTaskWithRetry = async (
}; };
export const checkVerification = () => { export const checkVerification = () => {
const currentNetwork = BRE.network.name; const currentNetwork = DRE.network.name;
if (!process.env.ETHERSCAN_KEY) { if (!process.env.ETHERSCAN_KEY) {
console.error('Missing process.env.ETHERSCAN_KEY.'); console.error('Missing process.env.ETHERSCAN_KEY.');
exit(3); exit(3);

View File

@ -5,6 +5,7 @@ import FileSync from 'lowdb/adapters/FileSync';
import {WAD} from './constants'; import {WAD} from './constants';
import {Wallet, ContractTransaction} from 'ethers'; import {Wallet, ContractTransaction} from 'ethers';
import {HardhatRuntimeEnvironment} from 'hardhat/types'; import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {BuidlerRuntimeEnvironment} from '@nomiclabs/buidler/types';
export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed(); 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 const getDb = () => low(new FileSync('./deployed-contracts.json'));
export let BRE: HardhatRuntimeEnvironment = {} as HardhatRuntimeEnvironment; export let DRE:
export const setBRE = (_BRE: HardhatRuntimeEnvironment) => { | HardhatRuntimeEnvironment
BRE = _BRE; | BuidlerRuntimeEnvironment = {} as HardhatRuntimeEnvironment;
export const setDRE = (_DRE: HardhatRuntimeEnvironment | BuidlerRuntimeEnvironment) => {
DRE = _DRE;
}; };
export const sleep = (milliseconds: number) => { export const sleep = (milliseconds: number) => {
@ -24,21 +27,21 @@ export const sleep = (milliseconds: number) => {
export const createRandomAddress = () => Wallet.createRandom().address; 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 () => { 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); return new BigNumber(block.timestamp);
}; };
export const advanceBlock = async (timestamp: number) => 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) => { export const increaseTime = async (secondsToIncrease: number) => {
await BRE.ethers.provider.send('evm_increaseTime', [secondsToIncrease]); await DRE.ethers.provider.send('evm_increaseTime', [secondsToIncrease]);
await BRE.ethers.provider.send('evm_mine', []); await DRE.ethers.provider.send('evm_mine', []);
}; };
export const waitForTx = async (tx: ContractTransaction) => await tx.wait(1); export const waitForTx = async (tx: ContractTransaction) => await tx.wait(1);
@ -69,7 +72,7 @@ interface DbEntry {
} }
export const printContracts = () => { export const printContracts = () => {
const network = BRE.network.name; const network = DRE.network.name;
const db = getDb(); const db = getDb();
console.log('Contracts deployed at', network); console.log('Contracts deployed at', network);
console.log('---------------------------------'); console.log('---------------------------------');

View File

@ -10,7 +10,7 @@
"hardhat:main": "hardhat --network main", "hardhat:main": "hardhat --network main",
"hardhat:docker": "hardhat --network hardhatevm_docker", "hardhat:docker": "hardhat --network hardhatevm_docker",
"compile": "SKIP_LOAD=true hardhat compile", "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", "test-scenarios": "npm run test -- test/__setup.spec.ts test/scenario.spec.ts",
"aave:evm:dev:migration": "hardhat aave:dev", "aave:evm:dev:migration": "hardhat aave:dev",
"aave:evm:full:migration": "hardhat aave:full", "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-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-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", "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:deployment": "hardhat dev-deployment",
"dev:deployExample": "hardhat deploy-Example", "dev:deployExample": "hardhat deploy-Example",
"dev:prettier": "prettier --write .", "dev:prettier": "prettier --write .",

View File

@ -4,6 +4,6 @@ import {deployAllMockTokens} from '../../helpers/contracts-deployments';
task('dev:deploy-mock-tokens', 'Deploy mock tokens for dev enviroment') task('dev:deploy-mock-tokens', 'Deploy mock tokens for dev enviroment')
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
await deployAllMockTokens(verify); await deployAllMockTokens(verify);
}); });

View File

@ -11,7 +11,7 @@ task(
) )
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const admin = await (await localBRE.ethers.getSigners())[0].getAddress(); const admin = await (await localBRE.ethers.getSigners())[0].getAddress();

View File

@ -17,7 +17,7 @@ import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment') task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();

View File

@ -24,7 +24,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
.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) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { const {
Mocks: {ChainlinkAggregatorPrices, AllAssetsInitialPrices}, Mocks: {ChainlinkAggregatorPrices, AllAssetsInitialPrices},

View File

@ -29,7 +29,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
.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) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const mockTokens = await getAllMockedTokens(); const mockTokens = await getAllMockedTokens();

View File

@ -6,7 +6,7 @@ import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters';
task('dev:wallet-balance-provider', 'Initialize lending pool configuration.') task('dev:wallet-balance-provider', 'Initialize lending pool configuration.')
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();
await deployWalletBalancerProvider(addressesProvider.address, verify); await deployWalletBalancerProvider(addressesProvider.address, verify);

View File

@ -16,7 +16,7 @@ task(
.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) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const network = <eEthereumNetwork>localBRE.network.name; const network = <eEthereumNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const {ProviderId} = poolConfig; const {ProviderId} = poolConfig;

View File

@ -17,7 +17,7 @@ import {
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment') task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();

View File

@ -19,7 +19,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
.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) => {
try { try {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const network = <eEthereumNetwork>localBRE.network.name; const network = <eEthereumNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const { const {

View File

@ -23,7 +23,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
.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) => {
try { try {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
const network = <eEthereumNetwork>localBRE.network.name; const network = <eEthereumNetwork>localBRE.network.name;
const poolConfig = loadPoolConfig(pool); const poolConfig = loadPoolConfig(pool);
const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration; const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;

View File

@ -1,17 +1,14 @@
import {task} from 'hardhat/config'; import {task} from 'hardhat/config';
import {checkVerification} from '../../helpers/etherscan-verification'; import {checkVerification} from '../../helpers/etherscan-verification';
console.log('ji');
import {ConfigNames} from '../../helpers/configuration'; import {ConfigNames} from '../../helpers/configuration';
console.log('pi');
import {printContracts} from '../../helpers/misc-utils'; import {printContracts} from '../../helpers/misc-utils';
console.log('i');
task('aave:dev', 'Deploy development enviroment') task('aave:dev', 'Deploy development enviroment')
.addOptionalParam('verify', 'Verify contracts at Etherscan') .addOptionalParam('verify', 'Verify contracts at Etherscan')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
const POOL_NAME = ConfigNames.Aave; 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 // Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) { if (verify) {

View File

@ -10,7 +10,7 @@ task('aave:full', 'Deploy development enviroment')
const POOL_NAME = ConfigNames.Aave; const POOL_NAME = ConfigNames.Aave;
const network = <EthereumNetworkNames>localBRE.network.name; const network = <EthereumNetworkNames>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 // Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) { if (verify) {

View File

@ -7,7 +7,7 @@ task('uniswap:dev', 'Deploy development enviroment')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
const POOL_NAME = ConfigNames.Uniswap; 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 // Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) { if (verify) {

View File

@ -7,7 +7,7 @@ task('uniswap:full', 'Deploy development enviroment')
.setAction(async ({verify}, localBRE) => { .setAction(async ({verify}, localBRE) => {
const POOL_NAME = ConfigNames.Uniswap; 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 // Prevent loss of gas verifying all the needed ENVs for Etherscan verification
if (verify) { if (verify) {

View File

@ -1,9 +1,9 @@
import {task} from 'hardhat/config'; import {task} from 'hardhat/config';
import {printContracts} from '../../helpers/misc-utils'; 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) => { async ({}, localBRE) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
printContracts(); printContracts();
} }
); );

View File

@ -1,9 +1,9 @@
import {task} from 'hardhat/config'; 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( task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
async (_, _BRE) => { async (_, _DRE) => {
setBRE(_BRE); setDRE(_DRE);
return _BRE; return _DRE;
} }
); );

View File

@ -8,7 +8,7 @@ interface VerifyParams {
libraries: string; 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('contractName', 'Name of the Solidity smart contract')
.addParam('address', 'Ethereum address of the smart contract') .addParam('address', 'Ethereum address of the smart contract')
.addOptionalParam( .addOptionalParam(
@ -25,7 +25,7 @@ task('verify-sc', 'Inits the BRE, to have access to all the plugins')
{contractName, address, constructorArguments = [], libraries}: VerifyParams, {contractName, address, constructorArguments = [], libraries}: VerifyParams,
localBRE localBRE
) => { ) => {
await localBRE.run('set-bre'); await localBRE.run('set-DRE');
checkVerification(); checkVerification();

View File

@ -263,7 +263,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
}; };
before(async () => { before(async () => {
await rawBRE.run('set-bre'); await rawBRE.run('set-DRE');
const [deployer, secondaryWallet] = await getEthersSigners(); const [deployer, secondaryWallet] = await getEthersSigners();
console.log('-> Deploying test environment...'); console.log('-> Deploying test environment...');
await buildTestEnv(deployer, secondaryWallet); await buildTestEnv(deployer, secondaryWallet);

View File

@ -5,7 +5,7 @@ import {expect} from 'chai';
import {ethers} from 'ethers'; import {ethers} from 'ethers';
import {eEthereumNetwork} from '../helpers/types'; import {eEthereumNetwork} from '../helpers/types';
import {makeSuite, TestEnv} from './helpers/make-suite'; import {makeSuite, TestEnv} from './helpers/make-suite';
import {BRE} from '../helpers/misc-utils'; import {DRE} from '../helpers/misc-utils';
import { import {
ConfigNames, ConfigNames,
getATokenDomainSeparatorPerNetwork, getATokenDomainSeparatorPerNetwork,
@ -47,7 +47,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const tokenName = await aDai.name(); 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 expiration = 0;
const nonce = (await aDai._nonces(owner.address)).toNumber(); const nonce = (await aDai._nonces(owner.address)).toNumber();
const permitAmount = ethers.utils.parseEther('2').toString(); const permitAmount = ethers.utils.parseEther('2').toString();
@ -92,7 +92,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const owner = deployer; const owner = deployer;
const spender = users[1]; 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 deadline = MAX_UINT_AMOUNT;
const nonce = (await aDai._nonces(owner.address)).toNumber(); const nonce = (await aDai._nonces(owner.address)).toNumber();
const permitAmount = parseEther('2').toString(); const permitAmount = parseEther('2').toString();
@ -134,7 +134,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const owner = deployer; const owner = deployer;
const spender = users[1]; 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 deadline = MAX_UINT_AMOUNT;
const nonce = (await aDai._nonces(owner.address)).toNumber(); const nonce = (await aDai._nonces(owner.address)).toNumber();
const permitAmount = '0'; const permitAmount = '0';
@ -180,7 +180,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const owner = deployer; const owner = deployer;
const spender = users[1]; 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 deadline = MAX_UINT_AMOUNT;
const nonce = 1000; const nonce = 1000;
const permitAmount = '0'; const permitAmount = '0';
@ -215,7 +215,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const owner = deployer; const owner = deployer;
const spender = users[1]; const spender = users[1];
const chainId = BRE.network.config.chainId || BUIDLEREVM_CHAINID; const chainId = DRE.network.config.chainId || BUIDLEREVM_CHAINID;
const expiration = '1'; const expiration = '1';
const nonce = (await aDai._nonces(owner.address)).toNumber(); const nonce = (await aDai._nonces(owner.address)).toNumber();
const permitAmount = '0'; const permitAmount = '0';
@ -250,7 +250,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const owner = deployer; const owner = deployer;
const spender = users[1]; 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 deadline = MAX_UINT_AMOUNT;
const nonce = (await aDai._nonces(owner.address)).toNumber(); const nonce = (await aDai._nonces(owner.address)).toNumber();
const permitAmount = '0'; const permitAmount = '0';
@ -285,7 +285,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => {
const owner = deployer; const owner = deployer;
const spender = users[1]; 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 expiration = MAX_UINT_AMOUNT;
const nonce = (await aDai._nonces(owner.address)).toNumber(); const nonce = (await aDai._nonces(owner.address)).toNumber();
const permitAmount = '0'; const permitAmount = '0';

View File

@ -5,7 +5,7 @@ import {expect} from 'chai';
import {ethers} from 'ethers'; import {ethers} from 'ethers';
import {eEthereumNetwork, ProtocolErrors} from '../helpers/types'; import {eEthereumNetwork, ProtocolErrors} from '../helpers/types';
import {makeSuite, TestEnv} from './helpers/make-suite'; import {makeSuite, TestEnv} from './helpers/make-suite';
import {BRE} from '../helpers/misc-utils'; import {DRE} from '../helpers/misc-utils';
import { import {
ConfigNames, ConfigNames,
getATokenDomainSeparatorPerNetwork, getATokenDomainSeparatorPerNetwork,

View File

@ -21,7 +21,7 @@ import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers';
import {getAToken, getMintableErc20} from '../../helpers/contracts-getters'; import {getAToken, getMintableErc20} from '../../helpers/contracts-getters';
import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants'; import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants';
import {SignerWithAddress, TestEnv} from './make-suite'; 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 chai from 'chai';
import {ReserveData, UserReserveData} from './utils/interfaces'; import {ReserveData, UserReserveData} from './utils/interfaces';
@ -729,9 +729,9 @@ export const getTxCostAndTimestamp = async (tx: ContractReceipt) => {
if (!tx.blockNumber || !tx.transactionHash || !tx.cumulativeGasUsed) { if (!tx.blockNumber || !tx.transactionHash || !tx.cumulativeGasUsed) {
throw new Error('No tx blocknumber'); 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( const txCost = new BigNumber(tx.cumulativeGasUsed.toString()).multipliedBy(
txInfo.gasPrice.toString() txInfo.gasPrice.toString()
); );

View File

@ -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 {Signer} from 'ethers';
import { import {
getLendingPool, getLendingPool,
@ -59,7 +59,7 @@ export interface TestEnv {
let buidlerevmSnapshotId: string = '0x1'; let buidlerevmSnapshotId: string = '0x1';
const setBuidlerevmSnapshotId = (id: string) => { const setBuidlerevmSnapshotId = (id: string) => {
if (BRE.network.name === 'hardhat') { if (DRE.network.name === 'hardhat') {
buidlerevmSnapshotId = id; buidlerevmSnapshotId = id;
} }
}; };

View File

@ -10,7 +10,7 @@ import {
} from '../../../helpers/contracts-getters'; } from '../../../helpers/contracts-getters';
import {tEthereumAddress} from '../../../helpers/types'; import {tEthereumAddress} from '../../../helpers/types';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import {getDb, BRE} from '../../../helpers/misc-utils'; import {getDb, DRE} from '../../../helpers/misc-utils';
import {AaveProtocolTestHelpers} from '../../../types/AaveProtocolTestHelpers'; import {AaveProtocolTestHelpers} from '../../../types/AaveProtocolTestHelpers';
export const getReserveData = async ( export const getReserveData = async (
@ -104,7 +104,7 @@ export const getUserData = async (
export const getReserveAddressFromSymbol = async (symbol: string) => { export const getReserveAddressFromSymbol = async (symbol: string) => {
const token = await getMintableErc20( const token = await getMintableErc20(
(await getDb().get(`${symbol}.${BRE.network.name}`).value()).address (await getDb().get(`${symbol}.${DRE.network.name}`).value()).address
); );
if (!token) { if (!token) {

View File

@ -1,6 +1,6 @@
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import {BRE} from '../helpers/misc-utils'; import {DRE} from '../helpers/misc-utils';
import {oneEther} from '../helpers/constants'; import {oneEther} from '../helpers/constants';
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
import {makeSuite} from './helpers/make-suite'; import {makeSuite} from './helpers/make-suite';
@ -185,7 +185,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
} }
const txTimestamp = new BigNumber( const txTimestamp = new BigNumber(
(await BRE.ethers.provider.getBlock(tx.blockNumber)).timestamp (await DRE.ethers.provider.getBlock(tx.blockNumber)).timestamp
); );
const variableDebtBeforeTx = calcExpectedVariableDebtTokenBalance( const variableDebtBeforeTx = calcExpectedVariableDebtTokenBalance(

View File

@ -1,6 +1,6 @@
import BigNumber from 'bignumber.js'; 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 {oneEther} from '../helpers/constants';
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
import {makeSuite} from './helpers/make-suite'; import {makeSuite} from './helpers/make-suite';
@ -185,7 +185,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
return; return;
} }
const txTimestamp = new BigNumber( const txTimestamp = new BigNumber(
(await BRE.ethers.provider.getBlock(tx.blockNumber)).timestamp (await DRE.ethers.provider.getBlock(tx.blockNumber)).timestamp
); );
const stableDebtBeforeTx = calcExpectedStableDebtTokenBalance( const stableDebtBeforeTx = calcExpectedStableDebtTokenBalance(
@ -302,7 +302,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
const usdcReserveDataBefore = await helpersContract.getReserveData(usdc.address); const usdcReserveDataBefore = await helpersContract.getReserveData(usdc.address);
const ethReserveDataBefore = await helpersContract.getReserveData(weth.address); const ethReserveDataBefore = await helpersContract.getReserveData(weth.address);
const amountToLiquidate = BRE.ethers.BigNumber.from( const amountToLiquidate = DRE.ethers.BigNumber.from(
userReserveDataBefore.currentStableDebt.toString() userReserveDataBefore.currentStableDebt.toString()
) )
.div(2) .div(2)

View File

@ -2,7 +2,7 @@ import {MAX_UINT_AMOUNT} from '../helpers/constants';
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers'; import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
import {makeSuite, TestEnv} from './helpers/make-suite'; import {makeSuite, TestEnv} from './helpers/make-suite';
import {formatEther, parseEther, parseUnits} from 'ethers/lib/utils'; 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 {BigNumber} from 'ethers';
import {getStableDebtToken, getVariableDebtToken} from '../helpers/contracts-getters'; import {getStableDebtToken, getVariableDebtToken} from '../helpers/contracts-getters';
import {WethGateway} from '../types/WethGateway'; import {WethGateway} from '../types/WethGateway';
@ -195,7 +195,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
user.signer.sendTransaction({ user.signer.sendTransaction({
to: wethGateway.address, to: wethGateway.address,
value: amount, value: amount,
gasLimit: BRE.network.config.gas, gasLimit: DRE.network.config.gas,
}) })
).to.be.revertedWith('Receive not allowed'); ).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 user = users[0];
const amount = parseEther('1'); const amount = parseEther('1');
const fakeABI = ['function wantToCallFallback()']; 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', []); const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []);
// Call fallback function with value // Call fallback function with value
@ -214,7 +214,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
to: wethGateway.address, to: wethGateway.address,
data: fakeMethodEncoded, data: fakeMethodEncoded,
value: amount, value: amount,
gasLimit: BRE.network.config.gas, gasLimit: DRE.network.config.gas,
}) })
).to.be.revertedWith('Fallback not allowed'); ).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 user = users[0];
const fakeABI = ['function wantToCallFallback()']; 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', []); const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []);
// Call fallback function without value // Call fallback function without value
@ -232,7 +232,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
user.signer.sendTransaction({ user.signer.sendTransaction({
to: wethGateway.address, to: wethGateway.address,
data: fakeMethodEncoded, data: fakeMethodEncoded,
gasLimit: BRE.network.config.gas, gasLimit: DRE.network.config.gas,
}) })
).to.be.revertedWith('Fallback not allowed'); ).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); await wethGateway.connect(deployer.signer).emergencyEtherTransfer(user.address, amount);
const userBalanceAfterRecovery = await user.signer.getBalance(); 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( expect(userBalanceAfterRecovery).to.be.eq(
userBalancePriorCall.sub(gasFees), userBalancePriorCall.sub(gasFees),