Skip to content

Commit 2aeb420

Browse files
authored
Merge pull request #104 from aave/fix/101-support-registry-config
fix: kovan deployment scripts
2 parents b4ed523 + 9b06eb1 commit 2aeb420

26 files changed

+418
-268
lines changed

.github/workflows/node.js.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ jobs:
3030
run: npm ci
3131
- name: Test
3232
run: npm run ci:test
33+
- name: Dev deployment
34+
run: npm run aave:evm:dev:migration
35+
- name: Mainnet deployment at Mainnet fork
36+
run: npm run aave:fork:main
37+
env:
38+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
39+
- name: Amm deployment at Mainnet fork
40+
run: npm run amm:fork:main
41+
env:
42+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
43+
- name: Aave deployment at Kovan fork
44+
run: npm run aave:fork:kovan
45+
env:
46+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
3347
# - name: Coverage
3448
# run: npm run coverage
3549
# - uses: codecov/codecov-action@v1

hardhat.config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { HardhatUserConfig } from 'hardhat/types';
55
import { accounts } from './test-wallets.js';
66
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
77
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
8-
import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config';
8+
import {
9+
NETWORKS_RPC_URL,
10+
NETWORKS_DEFAULT_GAS,
11+
BLOCK_TO_FORK,
12+
buildForkConfig,
13+
} from './helper-hardhat-config';
914

1015
require('dotenv').config();
1116

@@ -16,6 +21,7 @@ import 'hardhat-gas-reporter';
1621
import 'hardhat-typechain';
1722
import '@tenderly/hardhat-tenderly';
1823
import 'solidity-coverage';
24+
import { fork } from 'child_process';
1925

2026
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
2127
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
@@ -24,7 +30,6 @@ const HARDFORK = 'istanbul';
2430
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
2531
const MNEMONIC_PATH = "m/44'/60'/0'/0";
2632
const MNEMONIC = process.env.MNEMONIC || '';
27-
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
2833

2934
// Prevent to load scripts before compilation and typechain
3035
if (!SKIP_LOAD) {
@@ -57,12 +62,7 @@ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
5762
},
5863
});
5964

60-
const mainnetFork = MAINNET_FORK
61-
? {
62-
blockNumber: 12012081,
63-
url: NETWORKS_RPC_URL['main'],
64-
}
65-
: undefined;
65+
let forkMode;
6666

6767
const buidlerConfig: HardhatUserConfig = {
6868
solidity: {
@@ -111,7 +111,7 @@ const buidlerConfig: HardhatUserConfig = {
111111
privateKey: secretKey,
112112
balance,
113113
})),
114-
forking: mainnetFork,
114+
forking: buildForkConfig(),
115115
},
116116
buidlerevm_docker: {
117117
hardfork: 'berlin',

helper-hardhat-config.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @ts-ignore
2+
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
23
import {
34
eEthereumNetwork,
45
ePolygonNetwork,
@@ -11,9 +12,26 @@ require('dotenv').config();
1112
const INFURA_KEY = process.env.INFURA_KEY || '';
1213
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
1314
const TENDERLY_FORK_ID = process.env.TENDERLY_FORK_ID || '';
15+
const FORK = process.env.FORK || '';
16+
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER
17+
? parseInt(process.env.FORK_BLOCK_NUMBER)
18+
: 0;
1419

1520
const GWEI = 1000 * 1000 * 1000;
1621

22+
export const buildForkConfig = (): HardhatNetworkForkingUserConfig | undefined => {
23+
let forkMode;
24+
if (FORK) {
25+
forkMode = {
26+
url: NETWORKS_RPC_URL[FORK],
27+
};
28+
if (FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK]) {
29+
forkMode.blockNumber = FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK];
30+
}
31+
}
32+
return forkMode;
33+
};
34+
1735
export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
1836
[eEthereumNetwork.kovan]: ALCHEMY_KEY
1937
? `https://eth-kovan.alchemyapi.io/v2/${ALCHEMY_KEY}`
@@ -34,7 +52,7 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
3452
};
3553

3654
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
37-
[eEthereumNetwork.kovan]: 65 * GWEI,
55+
[eEthereumNetwork.kovan]: 1 * GWEI,
3856
[eEthereumNetwork.ropsten]: 65 * GWEI,
3957
[eEthereumNetwork.main]: 65 * GWEI,
4058
[eEthereumNetwork.coverage]: 65 * GWEI,
@@ -45,3 +63,16 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
4563
[ePolygonNetwork.matic]: 1 * GWEI,
4664
[eXDaiNetwork.xdai]: 1 * GWEI,
4765
};
66+
67+
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
68+
[eEthereumNetwork.main]: 12406069,
69+
[eEthereumNetwork.kovan]: undefined,
70+
[eEthereumNetwork.ropsten]: undefined,
71+
[eEthereumNetwork.coverage]: undefined,
72+
[eEthereumNetwork.hardhat]: undefined,
73+
[eEthereumNetwork.buidlerevm]: undefined,
74+
[eEthereumNetwork.tenderlyMain]: 12406069,
75+
[ePolygonNetwork.mumbai]: undefined,
76+
[ePolygonNetwork.matic]: undefined,
77+
[eXDaiNetwork.xdai]: undefined,
78+
};

helpers/configuration.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
6161
export const getGenesisPoolAdmin = async (
6262
config: ICommonConfiguration
6363
): Promise<tEthereumAddress> => {
64-
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
64+
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
6565
const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork);
6666
if (targetAddress) {
6767
return targetAddress;
@@ -76,7 +76,7 @@ export const getGenesisPoolAdmin = async (
7676
export const getEmergencyAdmin = async (
7777
config: ICommonConfiguration
7878
): Promise<tEthereumAddress> => {
79-
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
79+
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
8080
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork);
8181
if (targetAddress) {
8282
return targetAddress;
@@ -91,7 +91,7 @@ export const getEmergencyAdmin = async (
9191
export const getTreasuryAddress = async (
9292
config: ICommonConfiguration
9393
): Promise<tEthereumAddress> => {
94-
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
94+
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
9595
return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
9696
};
9797

@@ -101,7 +101,7 @@ export const getATokenDomainSeparatorPerNetwork = (
101101
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
102102

103103
export const getWethAddress = async (config: ICommonConfiguration) => {
104-
const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
104+
const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
105105
const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork);
106106
if (wethAddress) {
107107
return wethAddress;
@@ -133,8 +133,7 @@ export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => {
133133
ReserveAssets,
134134
} = poolConfig;
135135

136-
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
137-
const network = MAINNET_FORK ? 'main' : DRE.network.name;
136+
const network = process.env.FORK ? process.env.FORK : DRE.network.name;
138137
return filterMapBy(LendingRateOracleRatesCommon, (key) =>
139138
Object.keys(ReserveAssets[network]).includes(key)
140139
);

helpers/contracts-helpers.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export type MockTokenMap = { [symbol: string]: MintableERC20 };
3131

3232
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
3333
const currentNetwork = DRE.network.name;
34-
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
35-
if (MAINNET_FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) {
34+
const FORK = process.env.FORK;
35+
if (FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) {
3636
console.log(`*** ${contractId} ***\n`);
3737
console.log(`Network: ${currentNetwork}`);
3838
console.log(`tx: ${contractInstance.deployTransaction.hash}`);
@@ -144,9 +144,8 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
144144
} = param as iEthereumParamsPerNetwork<T>;
145145
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
146146
const { xdai } = param as iXDaiParamsPerNetwork<T>;
147-
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
148-
if (MAINNET_FORK) {
149-
return main;
147+
if (process.env.FORK) {
148+
return param[process.env.FORK as eNetwork] as T;
150149
}
151150

152151
switch (network) {

helpers/init-helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getAaveProtocolDataProvider,
1313
getAToken,
1414
getATokensAndRatesHelper,
15+
getFirstSigner,
1516
getLendingPoolAddressesProvider,
1617
getLendingPoolConfiguratorProxy,
1718
getStableAndVariableTokensHelper,
@@ -32,6 +33,7 @@ import {
3233
import { ZERO_ADDRESS } from './constants';
3334
import { isZeroAddress } from 'ethereumjs-util';
3435
import { DefaultReserveInterestRateStrategy, DelegationAwareAToken } from '../types';
36+
import { config } from 'process';
3537

3638
export const chooseATokenDeployment = (id: eContractid) => {
3739
switch (id) {
@@ -144,6 +146,10 @@ export const initReservesByHelper = async (
144146
) as [string, IReserveParams][];
145147

146148
for (let [symbol, params] of reserves) {
149+
if (!tokenAddresses[symbol]) {
150+
console.log(`- Skipping init of ${symbol} due token address is not set at markets config`);
151+
continue;
152+
}
147153
const { strategy, aTokenImpl, reserveDecimals } = params;
148154
const {
149155
optimalUtilizationRate,
@@ -293,6 +299,12 @@ export const configureReservesByHelper = async (
293299
borrowingEnabled,
294300
},
295301
] of Object.entries(reservesParams) as [string, IReserveParams][]) {
302+
if (!tokenAddresses[assetSymbol]) {
303+
console.log(
304+
`- Skipping init of ${assetSymbol} due token address is not set at markets config`
305+
);
306+
continue;
307+
}
296308
if (baseLTVAsCollateral === '-1') continue;
297309

298310
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(

helpers/oracles-helpers.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ export const setInitialAssetPricesInOracle = async (
7272
priceOracleInstance: PriceOracle
7373
) => {
7474
for (const [assetSymbol, price] of Object.entries(prices) as [string, string][]) {
75-
76-
console.log("Trying for ", assetsAddresses, assetSymbol);
77-
7875
const assetAddressIndex = Object.keys(assetsAddresses).findIndex(
7976
(value) => value === assetSymbol
8077
);

markets/aave/commons.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ export const CommonsConfig: ICommonConfiguration = {
9393
UNI: {
9494
borrowRate: oneRay.multipliedBy(0.03).toFixed(),
9595
},
96+
ENJ: {
97+
borrowRate: oneRay.multipliedBy(0.03).toFixed(),
98+
},
9699
BUSD: {
97100
borrowRate: oneRay.multipliedBy(0.05).toFixed(),
98101
},
@@ -135,11 +138,11 @@ export const CommonsConfig: ICommonConfiguration = {
135138
ProviderRegistryOwner: {
136139
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
137140
[eEthereumNetwork.ropsten]: '',
138-
[eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
141+
[eEthereumNetwork.main]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
139142
[eEthereumNetwork.coverage]: '',
140143
[eEthereumNetwork.hardhat]: '',
141144
[eEthereumNetwork.buidlerevm]: '',
142-
[eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
145+
[eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
143146
},
144147
LendingRateOracle: {
145148
[eEthereumNetwork.coverage]: '',
@@ -181,7 +184,7 @@ export const CommonsConfig: ICommonConfiguration = {
181184
[eEthereumNetwork.coverage]: '',
182185
[eEthereumNetwork.hardhat]: '',
183186
[eEthereumNetwork.buidlerevm]: '',
184-
[eEthereumNetwork.kovan]: '0xf99b8E67a0E044734B01EC4586D1c88C9a869718',
187+
[eEthereumNetwork.kovan]: '',
185188
[eEthereumNetwork.ropsten]: '',
186189
[eEthereumNetwork.main]: '',
187190
[eEthereumNetwork.tenderlyMain]: '',
@@ -282,6 +285,7 @@ export const CommonsConfig: ICommonConfiguration = {
282285
YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4',
283286
ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962',
284287
USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
288+
xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
285289
},
286290
[eEthereumNetwork.tenderlyMain]: {
287291
AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012',
@@ -304,6 +308,7 @@ export const CommonsConfig: ICommonConfiguration = {
304308
YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4',
305309
ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962',
306310
USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
311+
xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
307312
},
308313
},
309314
ReserveAssets: {

markets/aave/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
strategyWETH,
2424
strategyYFI,
2525
strategyXSUSHI,
26+
strategyENJ,
2627
} from './reservesConfigs';
2728

2829
// ----------------
@@ -38,7 +39,7 @@ export const AaveConfig: IAaveConfiguration = {
3839
BAT: strategyBAT,
3940
BUSD: strategyBUSD,
4041
DAI: strategyDAI,
41-
ENJ: strategyREN,
42+
ENJ: strategyENJ,
4243
KNC: strategyKNC,
4344
LINK: strategyLINK,
4445
MANA: strategyMANA,

markets/amm/commons.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,13 @@ export const CommonsConfig: ICommonConfiguration = {
139139
[eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
140140
},
141141
ProviderRegistryOwner: {
142-
// DEPLOYED WITH CORRECT ADDRESS
143142
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
144143
[eEthereumNetwork.ropsten]: '',
145-
[eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
144+
[eEthereumNetwork.main]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
146145
[eEthereumNetwork.coverage]: '',
147146
[eEthereumNetwork.hardhat]: '',
148147
[eEthereumNetwork.buidlerevm]: '',
149-
[eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
148+
[eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
150149
},
151150
LendingRateOracle: {
152151
[eEthereumNetwork.coverage]: '',

0 commit comments

Comments
 (0)