-
Notifications
You must be signed in to change notification settings - Fork 0
/
helptest.txt
22 lines (22 loc) · 923 Bytes
/
helptest.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Function which allows to convert any address to the signer which can sign transactions in a test
const impersonateAddress = async (address) => {
const hre = require('hardhat');
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [address],
});
const signer = await ethers.provider.getSigner(address);
signer.address = signer._address;
return signer;
};
// Function to increase time in mainnet fork
async function increaseTime(value) {
if (!ethers.BigNumber.isBigNumber(value)) {
value = ethers.BigNumber.from(value);
}
await ethers.provider.send('evm_increaseTime', [value.toNumber()]);
await ethers.provider.send('evm_mine');
}
// Construction to get any contract as an object by its interface and address in blockchain
// It is necessary to note that you must add an interface to your project
const WETH = await ethers.getContractAt('IWETH', wethAddress);