mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Aggregated deployments for initialization, atokens and debtTokens
This commit is contained in:
		
							parent
							
								
									cbc188e62a
								
							
						
					
					
						commit
						1c7ce57b2b
					
				|  | @ -14,7 +14,7 @@ usePlugin('@nomiclabs/buidler-etherscan'); | |||
| //usePlugin('buidler-gas-reporter');
 | ||||
| 
 | ||||
| const SKIP_LOAD = process.env.SKIP_LOAD === 'true'; | ||||
| const DEFAULT_BLOCK_GAS_LIMIT = 10000000; | ||||
| const DEFAULT_BLOCK_GAS_LIMIT = 12000000; | ||||
| const DEFAULT_GAS_PRICE = 10; | ||||
| const HARDFORK = 'istanbul'; | ||||
| const INFURA_KEY = process.env.INFURA_KEY || ''; | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ contract DeployATokensAndRates { | |||
|   } | ||||
| 
 | ||||
|   function concat(string memory a, string memory b) internal pure returns (string memory) { | ||||
|     return string(abi.encodePacked(a, ' ', b)); | ||||
|     return string(abi.encodePacked(a, b)); | ||||
|   } | ||||
| 
 | ||||
|   function initDeployment( | ||||
|  |  | |||
|  | @ -1,35 +0,0 @@ | |||
| // SPDX-License-Identifier: agpl-3.0 | ||||
| pragma solidity ^0.6.8; | ||||
| pragma experimental ABIEncoderV2; | ||||
| 
 | ||||
| import {LendingPoolConfigurator} from '../lendingpool/LendingPoolConfigurator.sol'; | ||||
| 
 | ||||
| contract ReserveInitializer { | ||||
|   address private poolConfigurator; | ||||
| 
 | ||||
|   constructor(address _poolConfigurator) public { | ||||
|     poolConfigurator = _poolConfigurator; | ||||
|   } | ||||
| 
 | ||||
|   function initReserve( | ||||
|     address[] calldata tokens, | ||||
|     address[] calldata stables, | ||||
|     address[] calldata variables, | ||||
|     address[] calldata aTokens, | ||||
|     address[] calldata strategies, | ||||
|     uint8[] calldata reserveDecimals | ||||
|   ) external { | ||||
|     // TODO require(check lenghts) | ||||
| 
 | ||||
|     for (uint256 i = 0; i < tokens.length; i++) { | ||||
|       LendingPoolConfigurator(poolConfigurator).initReserve( | ||||
|         tokens[i], | ||||
|         aTokens[i], | ||||
|         stables[i], | ||||
|         variables[i], | ||||
|         reserveDecimals[i], | ||||
|         strategies[i] | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | @ -1,7 +1,7 @@ | |||
| { | ||||
|   "MintableERC20": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xB7d4f04E8dF26d2FEE35D4AeB2A63fEB49451B78", | ||||
|       "address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -15,7 +15,7 @@ | |||
|   }, | ||||
|   "LendingPoolAddressesProvider": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xC5f7aC6895DcB76877E71db756433fB0E0478FEB", | ||||
|       "address": "0xa4bcDF64Cdd5451b6ac3743B414124A6299B65FF", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -33,7 +33,7 @@ | |||
|   }, | ||||
|   "LendingPoolAddressesProviderRegistry": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x4b2c297ba5be42610994974b9543D56B864CA011", | ||||
|       "address": "0x5A0773Ff307Bf7C71a832dBB5312237fD3437f9F", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -70,7 +70,7 @@ | |||
|   }, | ||||
|   "LendingPoolConfigurator": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x891E9f1BbD041265856b486DE4F5A5c5659370b6" | ||||
|       "address": "0x6642B57e4265BAD868C17Fc1d1F4F88DBBA04Aa8" | ||||
|     }, | ||||
|     "localhost": { | ||||
|       "address": "0x9Ec55627757348b322c8dD0865D704649bFa0c7b" | ||||
|  | @ -86,7 +86,7 @@ | |||
|   }, | ||||
|   "LendingPool": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x08ce4E45cD12Ae467fF24A1fd563321De309B613" | ||||
|       "address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e" | ||||
|     }, | ||||
|     "localhost": { | ||||
|       "address": "0x3EE716e38f21e5FC16BFDB773db24D63C637A5d8" | ||||
|  | @ -97,7 +97,7 @@ | |||
|   }, | ||||
|   "PriceOracle": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x951d1CE3CE90D719F5BdeCBbFE6EeA9c7bff948E", | ||||
|       "address": "0x0C6c3C47A1f650809B0D1048FDf9603e09473D7E", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -111,7 +111,7 @@ | |||
|   }, | ||||
|   "MockAggregator": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xff1B1B810F5DCe853a9b1819DE220D532D1CFeF2", | ||||
|       "address": "0xc11f8E173ee67ffA7BBdD185D2399994AAd23Ec6", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -125,7 +125,7 @@ | |||
|   }, | ||||
|   "ChainlinkProxyPriceProvider": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xf55Af78B3f3059fACF166Aa338FFe059A14e75F6", | ||||
|       "address": "0xD662fb7FDC7526C79AA4417d2A4415416e057ec4", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -143,7 +143,7 @@ | |||
|   }, | ||||
|   "LendingRateOracle": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xaD3AdbC18E4AD090034A6C74Eda61f4310dce313", | ||||
|       "address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -224,7 +224,7 @@ | |||
|   }, | ||||
|   "MockFlashLoanReceiver": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x5Ea694f66BD0CBd08FC7967af01b67Dcef68cC5c" | ||||
|       "address": "0xB8054085AF605D93c32E6B829d3d7eA2A8C84F9A" | ||||
|     }, | ||||
|     "localhost": { | ||||
|       "address": "0x9c91aEaD98b1354C7B0EAfb8ff539d0796c79894" | ||||
|  | @ -235,7 +235,7 @@ | |||
|   }, | ||||
|   "WalletBalanceProvider": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x93bB79570dFECC052e36E25cE10793A139e75f1b", | ||||
|       "address": "0xA3Ab089388B0C1BA83B3496696242FcA3F8eb9D5", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -571,7 +571,7 @@ | |||
|   }, | ||||
|   "AaveProtocolTestHelpers": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xa89E20284Bd638F31b0011D0fC754Fc9d2fa73e3" | ||||
|       "address": "0x93472C0e03215F9c33DA240Eb16703C8244eAa8c" | ||||
|     }, | ||||
|     "localhost": { | ||||
|       "address": "0x987223924D2DD6c6efB601756850f3886ECbceF6" | ||||
|  | @ -640,7 +640,7 @@ | |||
|   }, | ||||
|   "MockAToken": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x392E5355a0e88Bd394F717227c752670fb3a8020", | ||||
|       "address": "0x2dC17ABe95C889aA4c9474eD45Dd454Ed1Ec1ec1", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -668,7 +668,7 @@ | |||
|   }, | ||||
|   "MockStableDebtToken": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x3b050AFb4ac4ACE646b31fF3639C1CD43aC31460", | ||||
|       "address": "0x8b949D7E587518A6ad727ef30C5815De4a16A0D7", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -682,7 +682,7 @@ | |||
|   }, | ||||
|   "MockVariableDebtToken": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xEBAB67ee3ef604D5c250A53b4b8fcbBC6ec3007C", | ||||
|       "address": "0xCC5F3Be6e695bD0239dFd0efC8E9FFC6E969D29e", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     }, | ||||
|     "localhost": { | ||||
|  | @ -706,25 +706,25 @@ | |||
|   }, | ||||
|   "ReserveLogic": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x285671fF5C8172dE63cF5eA264B2e827aDBC6740", | ||||
|       "address": "0xFAe0fd738dAbc8a0426F47437322b6d026A9FD95", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     } | ||||
|   }, | ||||
|   "GenericLogic": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xb840b4fe440b5E26e1840cd2D6320FAda1C0ca5d", | ||||
|       "address": "0x6082731fdAba4761277Fb31299ebC782AD3bCf24", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     } | ||||
|   }, | ||||
|   "ValidationLogic": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0x1a432D97211e8b2CD53DF262c8Da0EfeBa6b6b3D", | ||||
|       "address": "0x8456161947DFc1fC159A0B26c025cD2b4bba0c3e", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     } | ||||
|   }, | ||||
|   "LendingPoolCollateralManager": { | ||||
|     "buidlerevm": { | ||||
|       "address": "0xb2B548BE73010C188C083c510d255Aed74843b05", | ||||
|       "address": "0xeB80313502EA077FA9B8E89b45e4a1B236cA17Ea", | ||||
|       "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" | ||||
|     } | ||||
|   } | ||||
|  |  | |||
|  | @ -9,10 +9,10 @@ import { | |||
|   deployVariableDebtToken, | ||||
|   deployGenericAToken, | ||||
| } from './contracts-deployments'; | ||||
| import {waitForTx} from './misc-utils'; | ||||
| import {chunk, waitForTx} from './misc-utils'; | ||||
| import {DeployTokens} from '../types/DeployTokens'; | ||||
| import {ZERO_ADDRESS} from './constants'; | ||||
| import {getFirstSigner} from './contracts-getters'; | ||||
| import {getFirstSigner, getLendingPoolAddressesProvider} from './contracts-getters'; | ||||
| import {DeployATokensAndRatesFactory} from '../types/DeployATokensAndRatesFactory'; | ||||
| import {DeployStableAndVariableTokensFactory} from '../types/DeployStableAndVariableTokensFactory'; | ||||
| import {getDefaultSettings} from 'http2'; | ||||
|  | @ -233,93 +233,138 @@ export const initReservesByHelper = async ( | |||
|   lendingPoolConfigurator: tEthereumAddress, | ||||
|   reservesParams: iMultiPoolsAssets<IReserveParams>, | ||||
|   tokenAddresses: {[symbol: string]: tEthereumAddress}, | ||||
|   helpers: AaveProtocolTestHelpers | ||||
|   helpers: AaveProtocolTestHelpers, | ||||
|   admin: tEthereumAddress, | ||||
|   incentivesController: tEthereumAddress | ||||
| ) => { | ||||
|   const stableAndVariableDeployer = await new DeployStableAndVariableTokensFactory( | ||||
|     await getFirstSigner() | ||||
|   ).deploy(lendingPoolProxy, addressesProvider); | ||||
|   const stableTx = await waitForTx(stableAndVariableDeployer.deployTransaction); | ||||
|   console.log('GAS', stableTx.gasUsed.toString()); | ||||
|   console.log('- Deployed StableAndVariableDeployer'); | ||||
|   await waitForTx(stableAndVariableDeployer.deployTransaction); | ||||
|   const atokenAndRatesDeployer = await new DeployATokensAndRatesFactory( | ||||
|     await getFirstSigner() | ||||
|   ).deploy(lendingPoolProxy, addressesProvider, lendingPoolConfigurator); | ||||
|   const atokenTx = await waitForTx(atokenAndRatesDeployer.deployTransaction); | ||||
|   console.log('GAS', atokenTx.gasUsed.toString()); | ||||
|   console.log('- Deployed ATokenAndRatesDeployer'); | ||||
|   console.log('doing calls'); | ||||
|   for (let [assetSymbol, {reserveDecimals}] of Object.entries(reservesParams) as [ | ||||
|     string, | ||||
|     IReserveParams | ||||
|   ][]) { | ||||
|     const assetAddressIndex = Object.keys(tokenAddresses).findIndex( | ||||
|       (value) => value === assetSymbol | ||||
|     ); | ||||
|     const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[ | ||||
|       assetAddressIndex | ||||
|     ]; | ||||
|   await waitForTx(atokenAndRatesDeployer.deployTransaction); | ||||
|   const addressProvider = await getLendingPoolAddressesProvider(addressesProvider); | ||||
| 
 | ||||
|     const {isActive: reserveInitialized} = await helpers.getReserveConfigurationData(tokenAddress); | ||||
|   // Set aTokenAndRatesDeployer as temporal admin
 | ||||
|   await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address)); | ||||
| 
 | ||||
|     if (reserveInitialized) { | ||||
|       console.log(`Reserve ${assetSymbol} is already active, skipping configuration`); | ||||
|       continue; | ||||
|     } | ||||
|   // CHUNK CONFIGURATION
 | ||||
|   const tokensChunks = 3; | ||||
|   const initChunks = 6; | ||||
| 
 | ||||
|     const reserveParamIndex = Object.keys(reservesParams).findIndex( | ||||
|       (value) => value === assetSymbol | ||||
|     ); | ||||
|     const [ | ||||
|       , | ||||
|       { | ||||
|   // Deploy tokens and rates in chunks
 | ||||
|   const reservesChunks = chunk( | ||||
|     Object.entries(reservesParams) as [string, IReserveParams][], | ||||
|     tokensChunks | ||||
|   ); | ||||
|   // Initialize variables for future reserves initialization
 | ||||
|   let deployedStableTokens: string[] = []; | ||||
|   let deployedVariableTokens: string[] = []; | ||||
|   let deployedATokens: string[] = []; | ||||
|   let deployedRates: string[] = []; | ||||
|   let reserveTokens: string[] = []; | ||||
|   let reserveInitDecimals: string[] = []; | ||||
| 
 | ||||
|   console.log( | ||||
|     `- Token deployments in ${reservesChunks.length * 2} txs instead of ${ | ||||
|       Object.entries(reservesParams).length * 4 | ||||
|     } txs` | ||||
|   ); | ||||
|   for (let reservesChunk of reservesChunks) { | ||||
|     // Prepare data
 | ||||
|     const tokens: string[] = []; | ||||
|     const symbols: string[] = []; | ||||
|     const strategyRates: string[][] = []; | ||||
|     const reservesDecimals: string[] = []; | ||||
| 
 | ||||
|     for (let [assetSymbol, {reserveDecimals}] of reservesChunk) { | ||||
|       const assetAddressIndex = Object.keys(tokenAddresses).findIndex( | ||||
|         (value) => value === assetSymbol | ||||
|       ); | ||||
|       const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[ | ||||
|         assetAddressIndex | ||||
|       ]; | ||||
| 
 | ||||
|       const reserveParamIndex = Object.keys(reservesParams).findIndex( | ||||
|         (value) => value === assetSymbol | ||||
|       ); | ||||
|       const [ | ||||
|         , | ||||
|         { | ||||
|           baseVariableBorrowRate, | ||||
|           variableRateSlope1, | ||||
|           variableRateSlope2, | ||||
|           stableRateSlope1, | ||||
|           stableRateSlope2, | ||||
|         }, | ||||
|       ] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex]; | ||||
|       // Add to lists
 | ||||
|       tokens.push(tokenAddress); | ||||
|       symbols.push(assetSymbol === 'WETH' ? 'ETH' : assetSymbol); | ||||
|       strategyRates.push([ | ||||
|         baseVariableBorrowRate, | ||||
|         variableRateSlope1, | ||||
|         variableRateSlope2, | ||||
|         stableRateSlope1, | ||||
|         stableRateSlope2, | ||||
|       }, | ||||
|     ] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex]; | ||||
|     assetSymbol = assetSymbol === 'WETH' ? 'ETH' : assetSymbol; | ||||
|       ]); | ||||
|       reservesDecimals.push(reserveDecimals); | ||||
|     } | ||||
| 
 | ||||
|     // Deploy stable and variable deployers
 | ||||
|     const tx1 = await waitForTx( | ||||
|       await stableAndVariableDeployer.initDeployment([tokenAddress], [assetSymbol], ZERO_ADDRESS, { | ||||
|         gasLimit: 9000000, | ||||
|       }) | ||||
|       await stableAndVariableDeployer.initDeployment(tokens, symbols, incentivesController) | ||||
|     ); | ||||
|     console.log('call 1', tx1.gasUsed.toString()); | ||||
| 
 | ||||
|     const stableTokens: string[] = tx1.events?.map((e) => e.args?.stableToken) || []; | ||||
|     const variableTokens: string[] = tx1.events?.map((e) => e.args?.variableToken) || []; | ||||
| 
 | ||||
|     // Deploy atokens and rate strategies
 | ||||
|     const tx2 = await waitForTx( | ||||
|       await atokenAndRatesDeployer.initDeployment( | ||||
|         [tokenAddress], | ||||
|         [assetSymbol], | ||||
|         [ | ||||
|           [ | ||||
|             baseVariableBorrowRate, | ||||
|             variableRateSlope1, | ||||
|             variableRateSlope2, | ||||
|             stableRateSlope1, | ||||
|             stableRateSlope2, | ||||
|           ], | ||||
|         ], | ||||
|         ZERO_ADDRESS | ||||
|         tokens, | ||||
|         symbols, | ||||
|         strategyRates, | ||||
|         incentivesController | ||||
|       ) | ||||
|     ); | ||||
|     console.log(`  - Deployed aToken, DebtTokens and Strategy for: ${symbols.join(', ')} `); | ||||
|     const stableTokens: string[] = tx1.events?.map((e) => e.args?.stableToken) || []; | ||||
|     const variableTokens: string[] = tx1.events?.map((e) => e.args?.variableToken) || []; | ||||
|     const aTokens: string[] = tx2.events?.map((e) => e.args?.aToken) || []; | ||||
|     const strategies: string[] = tx2.events?.map((e) => e.args?.strategy) || []; | ||||
|     console.log(aTokens.length, strategies.length, stableTokens.length, variableTokens.length); | ||||
|     console.log('call 2', tx2.gasUsed.toString()); | ||||
| 
 | ||||
|     deployedStableTokens = [...deployedStableTokens, ...stableTokens]; | ||||
|     deployedVariableTokens = [...deployedVariableTokens, ...variableTokens]; | ||||
|     deployedATokens = [...deployedATokens, ...aTokens]; | ||||
|     deployedRates = [...deployedRates, ...strategies]; | ||||
|     reserveInitDecimals = [...reserveInitDecimals, ...reservesDecimals]; | ||||
|     reserveTokens = [...reserveTokens, ...tokens]; | ||||
|   } | ||||
| 
 | ||||
|   // Deploy init reserves per chunks
 | ||||
|   const chunkedTokens = chunk(reserveTokens, initChunks); | ||||
|   const chunkedStableTokens = chunk(deployedStableTokens, initChunks); | ||||
|   const chunkedVariableTokens = chunk(deployedVariableTokens, initChunks); | ||||
|   const chunkedAtokens = chunk(deployedATokens, initChunks); | ||||
|   const chunkedRates = chunk(deployedRates, initChunks); | ||||
|   const chunkedDecimals = chunk(reserveInitDecimals, initChunks); | ||||
|   const chunkedSymbols = chunk(Object.keys(tokenAddresses), initChunks); | ||||
| 
 | ||||
|   console.log(`- Reserves initialization in ${chunkedTokens.length} txs`); | ||||
|   for (let chunkIndex = 0; chunkIndex < chunkedDecimals.length; chunkIndex++) { | ||||
|     const tx3 = await waitForTx( | ||||
|       await atokenAndRatesDeployer.initReserve( | ||||
|         [tokenAddress], | ||||
|         stableTokens, | ||||
|         variableTokens, | ||||
|         aTokens, | ||||
|         strategies, | ||||
|         [reserveDecimals] | ||||
|         chunkedTokens[chunkIndex], | ||||
|         chunkedStableTokens[chunkIndex], | ||||
|         chunkedVariableTokens[chunkIndex], | ||||
|         chunkedAtokens[chunkIndex], | ||||
|         chunkedRates[chunkIndex], | ||||
|         chunkedDecimals[chunkIndex] | ||||
|       ) | ||||
|     ); | ||||
|     console.log('call 3', tx3.gasUsed.toString()); | ||||
|     console.log(`  - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`); | ||||
|   } | ||||
| 
 | ||||
|   // Set deployer back as admin
 | ||||
|   await waitForTx(await addressProvider.setAaveAdmin(admin)); | ||||
| }; | ||||
|  |  | |||
|  | @ -52,3 +52,13 @@ export const filterMapBy = (raw: {[key: string]: any}, fn: (key: string) => bool | |||
|       obj[key] = raw[key]; | ||||
|       return obj; | ||||
|     }, {}); | ||||
| 
 | ||||
| export const chunk = <T>(arr: Array<T>, chunkSize: number): Array<Array<T>> => { | ||||
|   return arr.reduce( | ||||
|     (prevVal: any, currVal: any, currIndx: number, array: Array<T>) => | ||||
|       !(currIndx % chunkSize) | ||||
|         ? prevVal.concat([array.slice(currIndx, currIndx + chunkSize)]) | ||||
|         : prevVal, | ||||
|     [] | ||||
|   ); | ||||
| }; | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ import { | |||
|   enableReservesToBorrow, | ||||
|   enableReservesAsCollateral, | ||||
|   initReserves, | ||||
|   initReservesByHelper, | ||||
| } from '../../helpers/init-helpers'; | ||||
| import {getAllTokenAddresses} from '../../helpers/mock-helpers'; | ||||
| import {ZERO_ADDRESS} from '../../helpers/constants'; | ||||
|  | @ -44,16 +45,17 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') | |||
| 
 | ||||
|     const reservesParams = getReservesConfigByPool(AavePools.proto); | ||||
| 
 | ||||
|     await initReserves( | ||||
|     const admin = await addressesProvider.getAaveAdmin(); | ||||
| 
 | ||||
|     await initReservesByHelper( | ||||
|       lendingPoolProxy.address, | ||||
|       addressesProvider.address, | ||||
|       lendingPoolConfiguratorProxy.address, | ||||
|       reservesParams, | ||||
|       protoPoolReservesAddresses, | ||||
|       addressesProvider, | ||||
|       lendingPoolProxy, | ||||
|       testHelpers, | ||||
|       lendingPoolConfiguratorProxy, | ||||
|       AavePools.proto, | ||||
|       ZERO_ADDRESS, | ||||
|       verify | ||||
|       admin, | ||||
|       ZERO_ADDRESS | ||||
|     ); | ||||
|     await enableReservesToBorrow( | ||||
|       reservesParams, | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ import {waitForTx} from '../../helpers/misc-utils'; | |||
| import { | ||||
|   enableReservesToBorrow, | ||||
|   enableReservesAsCollateral, | ||||
|   initReserves, | ||||
|   initReservesByHelper, | ||||
| } from '../../helpers/init-helpers'; | ||||
| import {ZERO_ADDRESS} from '../../helpers/constants'; | ||||
| import {exit} from 'process'; | ||||
|  | @ -27,7 +27,6 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') | |||
|   .setAction(async ({verify, pool}, localBRE) => { | ||||
|     try { | ||||
|       await localBRE.run('set-bre'); | ||||
|       console.log('init'); | ||||
|       const network = <eEthereumNetwork>localBRE.network.name; | ||||
|       const poolConfig = loadPoolConfig(pool); | ||||
|       const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration; | ||||
|  | @ -40,16 +39,20 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') | |||
| 
 | ||||
|       const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address, verify); | ||||
| 
 | ||||
|       await initReserves( | ||||
|       const admin = await addressesProvider.getAaveAdmin(); | ||||
|       if (!reserveAssets) { | ||||
|         throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory'; | ||||
|       } | ||||
| 
 | ||||
|       await initReservesByHelper( | ||||
|         lendingPoolProxy.address, | ||||
|         addressesProvider.address, | ||||
|         lendingPoolConfiguratorProxy.address, | ||||
|         ReservesConfig, | ||||
|         reserveAssets, | ||||
|         addressesProvider, | ||||
|         lendingPoolProxy, | ||||
|         testHelpers, | ||||
|         lendingPoolConfiguratorProxy, | ||||
|         AavePools.proto, | ||||
|         ZERO_ADDRESS, | ||||
|         verify | ||||
|         admin, | ||||
|         ZERO_ADDRESS | ||||
|       ); | ||||
|       await enableReservesToBorrow( | ||||
|         ReservesConfig, | ||||
|  |  | |||
|  | @ -35,6 +35,7 @@ import { | |||
|   enableReservesToBorrow, | ||||
|   enableReservesAsCollateral, | ||||
|   initReserves, | ||||
|   initReservesByHelper, | ||||
| } from '../helpers/init-helpers'; | ||||
| import {AaveConfig} from '../config/aave'; | ||||
| import {ZERO_ADDRESS} from '../helpers/constants'; | ||||
|  | @ -206,16 +207,15 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | |||
|   await insertContractAddressInDb(eContractid.AaveProtocolTestHelpers, testHelpers.address); | ||||
| 
 | ||||
|   console.log('Initialize configuration'); | ||||
|   await initReserves( | ||||
|   await initReservesByHelper( | ||||
|     lendingPoolProxy.address, | ||||
|     addressesProvider.address, | ||||
|     lendingPoolConfiguratorProxy.address, | ||||
|     reservesParams, | ||||
|     protoPoolReservesAddresses, | ||||
|     addressesProvider, | ||||
|     lendingPoolProxy, | ||||
|     testHelpers, | ||||
|     lendingPoolConfiguratorProxy, | ||||
|     AavePools.proto, | ||||
|     ZERO_ADDRESS, | ||||
|     false | ||||
|     await deployer.getAddress(), | ||||
|     ZERO_ADDRESS | ||||
|   ); | ||||
|   await enableReservesToBorrow( | ||||
|     reservesParams, | ||||
|  |  | |||
|  | @ -97,13 +97,10 @@ export async function initializeMakeSuite() { | |||
| 
 | ||||
|   testEnv.helpersContract = await getAaveProtocolTestHelpers(); | ||||
| 
 | ||||
|   const aDaiAddress = (await testEnv.helpersContract.getAllATokens()).find( | ||||
|     (aToken) => aToken.symbol === 'aDAI' | ||||
|   )?.tokenAddress; | ||||
|   const allTokens = await testEnv.helpersContract.getAllATokens(); | ||||
|   const aDaiAddress = allTokens.find((aToken) => aToken.symbol === 'aDAI')?.tokenAddress; | ||||
| 
 | ||||
|   const aEthAddress = (await testEnv.helpersContract.getAllATokens()).find( | ||||
|     (aToken) => aToken.symbol === 'aETH' | ||||
|   )?.tokenAddress; | ||||
|   const aEthAddress = allTokens.find((aToken) => aToken.symbol === 'aETH')?.tokenAddress; | ||||
| 
 | ||||
|   const reservesTokens = await testEnv.helpersContract.getAllReservesTokens(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -35,6 +35,7 @@ import { | |||
| import AaveConfig from '../config/aave'; | ||||
| import {DeployTokensFactory} from '../types'; | ||||
| import {initReservesByHelper} from '../helpers/init-helpers'; | ||||
| import {ZERO_ADDRESS} from '../helpers/constants'; | ||||
| 
 | ||||
| const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei; | ||||
| const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices; | ||||
|  | @ -181,7 +182,9 @@ makeSuite('Init helper test', (testEnv: TestEnv) => { | |||
|       lendingPoolConfiguratorProxy.address, | ||||
|       reservesParams, | ||||
|       protoPoolReservesAddresses, | ||||
|       testHelpers | ||||
|       testHelpers, | ||||
|       await deployer.getAddress(), | ||||
|       ZERO_ADDRESS | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 David Racero
						David Racero