Fix README.md steps for mainnet fork. Added console fork mode. Fix infura subdomain in mainnet fork mode.

This commit is contained in:
David Racero 2021-01-07 13:45:18 +01:00
parent eea6d38f24
commit 43df62a9c9
4 changed files with 1596 additions and 3268 deletions

View File

@ -106,28 +106,34 @@ npm run aave:kovan:full:migration
### Mainnet fork deployment
You can deploy Aave Protocol v2 in a forked Mainnet chain using Hardhat built-in feature:
You can deploy Aave Protocol v2 in a forked Mainnet chain using Hardhat built-in fork feature:
```
# In one terminal, run a hardhat note with mainnet fork enabled
MAINNET_FORK=true npx hardhat node
docker-compose run contracts-env npm run aave:fork:main
```
# In another terminal, run docker-compose
docker-compose up
### Mainnet fork - Interact with Aave via Hardhat console
# Open another tab or terminal
docker-compose exec contracts-env bash
You can also deploy Aave into the Hardhat console in fork mode, to interact with the protocol inside the fork or for testing purposes.
# A new Bash terminal is prompted, connected to the container
npm run aave:fork:main
```
# Run the console in fork mode
docker-compose run contracts-env npm run console:fork
# Contracts are now deployed at Hardhat node with Mainnet fork.
# Deploy the Aave protocol in fork mode
await run('aave:mainnet')
# You can interact with them via Hardhat console
MAINNET_FORK=true npx hardhat console
# Or your custom Hardhat task
MAINNET_FORK=true npx hardhat your-custom-task
await run('your-custom-task');
# After you initialize the Signers via 'set-DRE' task, you can import any TS/JS file
await run('set-DRE'); // Initialize signers
# Import contract getters to retrieve an Ethers.js Contract instance
const contractGetters = require('./helpers/contracts-getters'); // Import a TS/JS file
# Lending pool instance
const lendingPool = await contractGetters.getLendingPool("LendingPool address from 'aave:mainnet' task");
```
### Mainnet fork - Run the check list

View File

@ -40,12 +40,11 @@ if (!SKIP_LOAD) {
require(`${path.join(__dirname, 'tasks/misc')}/set-bre.ts`);
const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number) => {
const net = networkName === 'main' ? 'mainnet' : networkName;
return {
url: ALCHEMY_KEY
? `https://eth-${
networkName === 'main' ? 'mainnet' : networkName
}.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,
? `https://eth-${net}.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://${net}.infura.io/v3/${INFURA_KEY}`,
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
@ -65,7 +64,7 @@ const mainnetFork = MAINNET_FORK
blockNumber: 11366117,
url: ALCHEMY_KEY
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://main.infura.io/v3/${INFURA_KEY}`,
: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
}
: undefined;

4750
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
"hardhat:main": "hardhat --network main",
"hardhat:docker": "hardhat --network hardhatevm_docker",
"compile": "SKIP_LOAD=true hardhat compile",
"console:fork": "MAINNET_FORK=true hardhat console",
"test": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test/*.spec.ts",
"test-scenarios": "npm run test -- test/__setup.spec.ts test/scenario.spec.ts",
"test-repay-with-collateral": "hardhat test test/__setup.spec.ts test/repay-with-collateral.spec.ts",