Skip to content

Commit 742a826

Browse files
committed
feat: improve deploy scripts
1 parent 61c2273 commit 742a826

20 files changed

+26086
-101
lines changed

hardhat.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const buidlerConfig: HardhatUserConfig = {
108108
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
109109
avalanche: getCommonNetworkConfig(eAvalancheNetwork.avalanche, 43114),
110110
fuji: getCommonNetworkConfig(eAvalancheNetwork.fuji, 43113),
111+
goerli: getCommonNetworkConfig(eEthereumNetwork.goerli, 5),
111112
hardhat: {
112113
hardfork: 'berlin',
113114
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,

helper-hardhat-config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
5555
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
5656
[eAvalancheNetwork.avalanche]: 'https://api.avax.network/ext/bc/C/rpc',
5757
[eAvalancheNetwork.fuji]: 'https://api.avax-test.network/ext/bc/C/rpc',
58+
[eEthereumNetwork.goerli]: `https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}`,
5859
};
5960

6061
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
@@ -70,6 +71,7 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
7071
[eXDaiNetwork.xdai]: 1 * GWEI,
7172
[eAvalancheNetwork.avalanche]: 225 * GWEI,
7273
[eAvalancheNetwork.fuji]: 85 * GWEI,
74+
[eEthereumNetwork.goerli]: 2 * GWEI,
7375
};
7476

7577
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
@@ -85,4 +87,5 @@ export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
8587
[eXDaiNetwork.xdai]: undefined,
8688
[eAvalancheNetwork.avalanche]: undefined,
8789
[eAvalancheNetwork.fuji]: undefined,
90+
[eEthereumNetwork.goerli]: undefined,
8891
};

helpers/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import BigNumber from 'bignumber.js';
2-
import { eEthereumNetwork } from './types';
32

43
// ----------------
54
// MATH

helpers/contracts-getters.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,21 @@ export const getPairsTokenAggregator = (
210210
getQuoteCurrencies(oracleQuoteCurrency)
211211
);
212212

213-
const pairs = Object.entries(assetsWithoutQuoteCurrency).map(([tokenSymbol, tokenAddress]) => {
214-
//if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) {
215-
const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
216-
(value) => value === tokenSymbol
217-
);
218-
const [, aggregatorAddress] = (
219-
Object.entries(aggregatorsAddresses) as [string, tEthereumAddress][]
220-
)[aggregatorAddressIndex];
221-
return [tokenAddress, aggregatorAddress];
222-
//}
223-
}) as [string, string][];
213+
const pairs = Object.entries(assetsWithoutQuoteCurrency).reduce<[string, string][]>(
214+
(acc, [tokenSymbol, tokenAddress]) => {
215+
const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
216+
(value) => value === tokenSymbol
217+
);
218+
if (aggregatorAddressIndex >= 0) {
219+
const [, aggregatorAddress] = (
220+
Object.entries(aggregatorsAddresses) as [string, tEthereumAddress][]
221+
)[aggregatorAddressIndex];
222+
return [...acc, [tokenAddress, aggregatorAddress]];
223+
}
224+
return acc;
225+
},
226+
[]
227+
);
224228

225229
const mappedPairs = pairs.map(([asset]) => asset);
226230
const mappedAggregators = pairs.map(([, source]) => source);
@@ -424,23 +428,26 @@ export const getFlashLiquidationAdapter = async (address?: tEthereumAddress) =>
424428
export const getMockParaSwapAugustus = async (address?: tEthereumAddress) =>
425429
await MockParaSwapAugustusFactory.connect(
426430
address ||
427-
(await getDb().get(`${eContractid.MockParaSwapAugustus}.${DRE.network.name}`).value())
428-
.address,
431+
(
432+
await getDb().get(`${eContractid.MockParaSwapAugustus}.${DRE.network.name}`).value()
433+
).address,
429434
await getFirstSigner()
430435
);
431436

432437
export const getMockParaSwapAugustusRegistry = async (address?: tEthereumAddress) =>
433438
await MockParaSwapAugustusRegistryFactory.connect(
434439
address ||
435-
(await getDb().get(`${eContractid.MockParaSwapAugustusRegistry}.${DRE.network.name}`).value())
436-
.address,
440+
(
441+
await getDb().get(`${eContractid.MockParaSwapAugustusRegistry}.${DRE.network.name}`).value()
442+
).address,
437443
await getFirstSigner()
438444
);
439445

440446
export const getParaSwapLiquiditySwapAdapter = async (address?: tEthereumAddress) =>
441447
await ParaSwapLiquiditySwapAdapterFactory.connect(
442448
address ||
443-
(await getDb().get(`${eContractid.ParaSwapLiquiditySwapAdapter}.${DRE.network.name}`).value())
444-
.address,
449+
(
450+
await getDb().get(`${eContractid.ParaSwapLiquiditySwapAdapter}.${DRE.network.name}`).value()
451+
).address,
445452
await getFirstSigner()
446453
);

helpers/contracts-helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
145145
};
146146

147147
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
148-
const { main, ropsten, kovan, coverage, buidlerevm, tenderly } =
148+
const { main, ropsten, kovan, coverage, buidlerevm, tenderly, goerli } =
149149
param as iEthereumParamsPerNetwork<T>;
150150
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
151151
const { xdai } = param as iXDaiParamsPerNetwork<T>;
@@ -179,6 +179,8 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
179179
return avalanche;
180180
case eAvalancheNetwork.fuji:
181181
return fuji;
182+
case eEthereumNetwork.goerli:
183+
return goerli;
182184
}
183185
};
184186

helpers/etherscan-verification.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@ const fatalErrors = [
1010
`The constructor for`,
1111
];
1212

13-
const okErrors = [`Contract source code already verified`];
13+
const okErrors = [`Contract source code already verified`, 'Already Verified'];
1414

1515
const unableVerifyError = 'Fail - Unable to verify';
1616

17-
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan', 'matic', 'mumbai'];
17+
export const SUPPORTED_ETHERSCAN_NETWORKS = [
18+
'main',
19+
'ropsten',
20+
'kovan',
21+
'matic',
22+
'mumbai',
23+
'goerli',
24+
'avalanche',
25+
'fuji',
26+
];
1827

1928
function delay(ms: number) {
2029
return new Promise((resolve) => setTimeout(resolve, ms));

helpers/init-helpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { chunk, getDb, waitForTx } from './misc-utils';
1010
import {
1111
getAToken,
1212
getATokensAndRatesHelper,
13+
getLendingPool,
1314
getLendingPoolAddressesProvider,
1415
getLendingPoolConfiguratorProxy,
1516
} from './contracts-getters';
@@ -20,6 +21,7 @@ import {
2021
import { BigNumberish } from 'ethers';
2122
import { ConfigNames } from './configuration';
2223
import { deployRateStrategy } from './contracts-deployments';
24+
import { ZERO_ADDRESS } from './constants';
2325

2426
export const getATokenExtraParams = async (aTokenName: string, tokenAddress: tEthereumAddress) => {
2527
console.log(aTokenName);
@@ -88,6 +90,12 @@ export const initReservesByHelper = async (
8890
console.log(`- Skipping init of ${symbol} due token address is not set at markets config`);
8991
continue;
9092
}
93+
const pool = await getLendingPool(await addressProvider.getLendingPool());
94+
const poolReserve = await pool.getReserveData(tokenAddresses[symbol]);
95+
if (poolReserve.aTokenAddress !== ZERO_ADDRESS) {
96+
console.log(`- Skipping init of ${symbol} due is already initialized`);
97+
continue;
98+
}
9199
const { strategy, aTokenImpl, reserveDecimals } = params;
92100
const {
93101
optimalUtilizationRate,

helpers/oracles-helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const setInitialMarketRatesInRatesOracleByHelper = async (
6767
};
6868

6969
export const setInitialAssetPricesInOracle = async (
70-
prices: iAssetBase<tEthereumAddress>,
70+
prices: { [key: string]: string },
7171
assetsAddresses: iAssetBase<tEthereumAddress>,
7272
priceOracleInstance: PriceOracle
7373
) => {
@@ -113,17 +113,17 @@ export const deployMockAggregators = async (initialPrices: SymbolMap<string>, ve
113113
};
114114

115115
export const deployAllMockAggregators = async (
116-
initialPrices: iAssetAggregatorBase<string>,
116+
initialPrices: SymbolMap<string>,
117117
verify?: boolean
118118
) => {
119-
const aggregators: { [tokenSymbol: string]: MockAggregator } = {};
119+
const aggregators: { [tokenSymbol: string]: tEthereumAddress } = {};
120120
for (const tokenContractName of Object.keys(initialPrices)) {
121121
if (tokenContractName !== 'ETH') {
122122
const priceIndex = Object.keys(initialPrices).findIndex(
123123
(value) => value === tokenContractName
124124
);
125125
const [, price] = (Object.entries(initialPrices) as [string, string][])[priceIndex];
126-
aggregators[tokenContractName] = await deployMockAggregator(price, verify);
126+
aggregators[tokenContractName] = (await deployMockAggregator(price, verify)).address;
127127
}
128128
}
129129
return aggregators;

helpers/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export enum eEthereumNetwork {
1313
main = 'main',
1414
coverage = 'coverage',
1515
hardhat = 'hardhat',
16+
1617
tenderly = 'tenderly',
18+
goerli = 'goerli',
1719
}
1820

1921
export enum ePolygonNetwork {
@@ -432,6 +434,7 @@ export interface iEthereumParamsPerNetwork<T> {
432434
[eEthereumNetwork.main]: T;
433435
[eEthereumNetwork.hardhat]: T;
434436
[eEthereumNetwork.tenderly]: T;
437+
[eEthereumNetwork.goerli]: T;
435438
}
436439

437440
export interface iPolygonParamsPerNetwork<T> {
@@ -480,7 +483,7 @@ export interface IProtocolGlobalConfig {
480483
}
481484

482485
export interface IMocksConfig {
483-
AllAssetsInitialPrices: iAssetBase<string>;
486+
AllAssetsInitialPrices: { [key: string]: string };
484487
}
485488

486489
export interface ILendingRateOracleRatesCommon {

markets/aave/commons.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export const CommonsConfig: ICommonConfiguration = {
114114
[eEthereumNetwork.ropsten]: undefined,
115115
[eEthereumNetwork.main]: undefined,
116116
[eEthereumNetwork.tenderly]: undefined,
117+
[eEthereumNetwork.goerli]: undefined,
117118
},
118119
PoolAdminIndex: 0,
119120
EmergencyAdmin: {
@@ -124,6 +125,7 @@ export const CommonsConfig: ICommonConfiguration = {
124125
[eEthereumNetwork.ropsten]: undefined,
125126
[eEthereumNetwork.main]: undefined,
126127
[eEthereumNetwork.tenderly]: undefined,
128+
[eEthereumNetwork.goerli]: undefined,
127129
},
128130
EmergencyAdminIndex: 1,
129131
ProviderRegistry: {
@@ -134,6 +136,7 @@ export const CommonsConfig: ICommonConfiguration = {
134136
[eEthereumNetwork.hardhat]: '',
135137
[eEthereumNetwork.buidlerevm]: '',
136138
[eEthereumNetwork.tenderly]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
139+
[eEthereumNetwork.goerli]: '',
137140
},
138141
ProviderRegistryOwner: {
139142
[eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
@@ -143,6 +146,7 @@ export const CommonsConfig: ICommonConfiguration = {
143146
[eEthereumNetwork.hardhat]: '',
144147
[eEthereumNetwork.buidlerevm]: '',
145148
[eEthereumNetwork.tenderly]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
149+
[eEthereumNetwork.goerli]: '',
146150
},
147151
LendingRateOracle: {
148152
[eEthereumNetwork.coverage]: '',
@@ -152,6 +156,7 @@ export const CommonsConfig: ICommonConfiguration = {
152156
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
153157
[eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
154158
[eEthereumNetwork.tenderly]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
159+
[eEthereumNetwork.goerli]: '',
155160
},
156161
LendingPoolCollateralManager: {
157162
[eEthereumNetwork.coverage]: '',
@@ -161,6 +166,7 @@ export const CommonsConfig: ICommonConfiguration = {
161166
[eEthereumNetwork.ropsten]: '',
162167
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
163168
[eEthereumNetwork.tenderly]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
169+
[eEthereumNetwork.goerli]: '',
164170
},
165171
LendingPoolConfigurator: {
166172
[eEthereumNetwork.coverage]: '',
@@ -170,6 +176,7 @@ export const CommonsConfig: ICommonConfiguration = {
170176
[eEthereumNetwork.ropsten]: '',
171177
[eEthereumNetwork.main]: '',
172178
[eEthereumNetwork.tenderly]: '',
179+
[eEthereumNetwork.goerli]: '',
173180
},
174181
LendingPool: {
175182
[eEthereumNetwork.coverage]: '',
@@ -179,6 +186,7 @@ export const CommonsConfig: ICommonConfiguration = {
179186
[eEthereumNetwork.ropsten]: '',
180187
[eEthereumNetwork.main]: '',
181188
[eEthereumNetwork.tenderly]: '',
189+
[eEthereumNetwork.goerli]: '',
182190
},
183191
WethGateway: {
184192
[eEthereumNetwork.coverage]: '',
@@ -188,6 +196,7 @@ export const CommonsConfig: ICommonConfiguration = {
188196
[eEthereumNetwork.ropsten]: '',
189197
[eEthereumNetwork.main]: '',
190198
[eEthereumNetwork.tenderly]: '',
199+
[eEthereumNetwork.goerli]: '',
191200
},
192201
TokenDistributor: {
193202
[eEthereumNetwork.coverage]: '',
@@ -197,6 +206,7 @@ export const CommonsConfig: ICommonConfiguration = {
197206
[eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c',
198207
[eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
199208
[eEthereumNetwork.tenderly]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae',
209+
[eEthereumNetwork.goerli]: '',
200210
},
201211
AaveOracle: {
202212
[eEthereumNetwork.coverage]: '',
@@ -206,6 +216,7 @@ export const CommonsConfig: ICommonConfiguration = {
206216
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
207217
[eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
208218
[eEthereumNetwork.tenderly]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
219+
[eEthereumNetwork.goerli]: '',
209220
},
210221
FallbackOracle: {
211222
[eEthereumNetwork.coverage]: '',
@@ -215,6 +226,7 @@ export const CommonsConfig: ICommonConfiguration = {
215226
[eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d',
216227
[eEthereumNetwork.main]: ZERO_ADDRESS,
217228
[eEthereumNetwork.tenderly]: ZERO_ADDRESS,
229+
[eEthereumNetwork.goerli]: '',
218230
},
219231
ChainlinkAggregator: {
220232
[eEthereumNetwork.coverage]: {},
@@ -310,6 +322,7 @@ export const CommonsConfig: ICommonConfiguration = {
310322
USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
311323
xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
312324
},
325+
[eEthereumNetwork.goerli]: {},
313326
},
314327
ReserveAssets: {
315328
[eEthereumNetwork.coverage]: {},
@@ -319,6 +332,7 @@ export const CommonsConfig: ICommonConfiguration = {
319332
[eEthereumNetwork.kovan]: {},
320333
[eEthereumNetwork.ropsten]: {},
321334
[eEthereumNetwork.tenderly]: {},
335+
[eEthereumNetwork.goerli]: {},
322336
},
323337
ReservesConfig: {},
324338
ATokenDomainSeparator: {
@@ -332,6 +346,7 @@ export const CommonsConfig: ICommonConfiguration = {
332346
[eEthereumNetwork.ropsten]: '',
333347
[eEthereumNetwork.main]: '',
334348
[eEthereumNetwork.tenderly]: '',
349+
[eEthereumNetwork.goerli]: '',
335350
},
336351
WETH: {
337352
[eEthereumNetwork.coverage]: '', // deployed in local evm
@@ -341,6 +356,7 @@ export const CommonsConfig: ICommonConfiguration = {
341356
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
342357
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
343358
[eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
359+
[eEthereumNetwork.goerli]: '',
344360
},
345361
WrappedNativeToken: {
346362
[eEthereumNetwork.coverage]: '', // deployed in local evm
@@ -350,6 +366,7 @@ export const CommonsConfig: ICommonConfiguration = {
350366
[eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
351367
[eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
352368
[eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
369+
[eEthereumNetwork.goerli]: '',
353370
},
354371
ReserveFactorTreasuryAddress: {
355372
[eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
@@ -359,6 +376,7 @@ export const CommonsConfig: ICommonConfiguration = {
359376
[eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
360377
[eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
361378
[eEthereumNetwork.tenderly]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
379+
[eEthereumNetwork.goerli]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
362380
},
363381
IncentivesController: {
364382
[eEthereumNetwork.coverage]: ZERO_ADDRESS,
@@ -368,5 +386,6 @@ export const CommonsConfig: ICommonConfiguration = {
368386
[eEthereumNetwork.ropsten]: ZERO_ADDRESS,
369387
[eEthereumNetwork.main]: ZERO_ADDRESS,
370388
[eEthereumNetwork.tenderly]: ZERO_ADDRESS,
389+
[eEthereumNetwork.goerli]: ZERO_ADDRESS,
371390
},
372391
};

0 commit comments

Comments
 (0)