mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	feat: Added support to fork any chain. Added deployment scripts to Github Actions
This commit is contained in:
		
							parent
							
								
									a89598671f
								
							
						
					
					
						commit
						2cdfbbbc5d
					
				
							
								
								
									
										8
									
								
								.github/workflows/node.js.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/node.js.yml
									
									
									
									
										vendored
									
									
								
							|  | @ -30,6 +30,14 @@ jobs: | |||
|         run: npm ci | ||||
|       - name: Test | ||||
|         run: npm run ci:test | ||||
|       - name: Dev deployment | ||||
|         run: npm run aave:evm:dev:migration | ||||
|       - name: Mainnet deployment at Mainnet fork | ||||
|         run: npm run aave:fork:main | ||||
|       - name: Amm deployment at Mainnet fork | ||||
|         run: npm run amm:fork:main | ||||
|       - name: Aave deployment at Kovan fork | ||||
|         run: npm run aave:fork:kovan | ||||
|       # - name: Coverage | ||||
|       #   run: npm run coverage | ||||
|       # - uses: codecov/codecov-action@v1 | ||||
|  |  | |||
|  | @ -18,6 +18,7 @@ import {IInitializableDebtToken} from '../../interfaces/IInitializableDebtToken. | |||
| import {IInitializableAToken} from '../../interfaces/IInitializableAToken.sol'; | ||||
| import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol'; | ||||
| import {ILendingPoolConfigurator} from '../../interfaces/ILendingPoolConfigurator.sol'; | ||||
| import 'hardhat/console.sol'; | ||||
| 
 | ||||
| /** | ||||
|  * @title LendingPoolConfigurator contract | ||||
|  | @ -61,6 +62,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|    * @dev Initializes reserves in batch | ||||
|    **/ | ||||
|   function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin { | ||||
|     console.log('batch init'); | ||||
|     ILendingPool cachedPool = pool; | ||||
|     for (uint256 i = 0; i < input.length; i++) { | ||||
|       _initReserve(cachedPool, input[i]); | ||||
|  | @ -68,6 +70,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|   } | ||||
| 
 | ||||
|   function _initReserve(ILendingPool pool, InitReserveInput calldata input) internal { | ||||
|     console.log('0'); | ||||
|     address aTokenProxyAddress = | ||||
|       _initTokenWithProxy( | ||||
|         input.aTokenImpl, | ||||
|  | @ -113,7 +116,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|           input.params | ||||
|         ) | ||||
|       ); | ||||
| 
 | ||||
|     console.log('1'); | ||||
|     pool.initReserve( | ||||
|       input.underlyingAsset, | ||||
|       aTokenProxyAddress, | ||||
|  | @ -121,6 +124,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|       variableDebtTokenProxyAddress, | ||||
|       input.interestRateStrategyAddress | ||||
|     ); | ||||
|     console.log('2'); | ||||
| 
 | ||||
|     DataTypes.ReserveConfigurationMap memory currentConfig = | ||||
|       pool.getConfiguration(input.underlyingAsset); | ||||
|  | @ -132,6 +136,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
| 
 | ||||
|     pool.setConfiguration(input.underlyingAsset, currentConfig.data); | ||||
| 
 | ||||
|     console.log('3'); | ||||
|     emit ReserveInitialized( | ||||
|       input.underlyingAsset, | ||||
|       aTokenProxyAddress, | ||||
|  | @ -151,7 +156,8 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
| 
 | ||||
|     (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); | ||||
| 
 | ||||
|     bytes memory encodedCall = abi.encodeWithSelector( | ||||
|     bytes memory encodedCall = | ||||
|       abi.encodeWithSelector( | ||||
|         IInitializableAToken.initialize.selector, | ||||
|         cachedPool, | ||||
|         input.treasury, | ||||
|  | @ -163,11 +169,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|         input.params | ||||
|       ); | ||||
| 
 | ||||
|     _upgradeTokenImplementation( | ||||
|       reserveData.aTokenAddress, | ||||
|       input.implementation, | ||||
|       encodedCall | ||||
|     ); | ||||
|     _upgradeTokenImplementation(reserveData.aTokenAddress, input.implementation, encodedCall); | ||||
| 
 | ||||
|     emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); | ||||
|   } | ||||
|  | @ -179,10 +181,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|     ILendingPool cachedPool = pool; | ||||
| 
 | ||||
|     DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); | ||||
|       | ||||
| 
 | ||||
|     (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); | ||||
| 
 | ||||
|     bytes memory encodedCall = abi.encodeWithSelector( | ||||
|     bytes memory encodedCall = | ||||
|       abi.encodeWithSelector( | ||||
|         IInitializableDebtToken.initialize.selector, | ||||
|         cachedPool, | ||||
|         input.asset, | ||||
|  | @ -209,17 +212,15 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur | |||
|   /** | ||||
|    * @dev Updates the variable debt token implementation for the asset | ||||
|    **/ | ||||
|   function updateVariableDebtToken(UpdateDebtTokenInput calldata input) | ||||
|     external | ||||
|     onlyPoolAdmin | ||||
|   { | ||||
|   function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin { | ||||
|     ILendingPool cachedPool = pool; | ||||
| 
 | ||||
|     DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); | ||||
| 
 | ||||
|     (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); | ||||
| 
 | ||||
|     bytes memory encodedCall = abi.encodeWithSelector( | ||||
|     bytes memory encodedCall = | ||||
|       abi.encodeWithSelector( | ||||
|         IInitializableDebtToken.initialize.selector, | ||||
|         cachedPool, | ||||
|         input.asset, | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { HardhatUserConfig } from 'hardhat/types'; | |||
| import { accounts } from './test-wallets.js'; | ||||
| import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types'; | ||||
| import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants'; | ||||
| import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config'; | ||||
| import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS, BLOCK_TO_FORK } from './helper-hardhat-config'; | ||||
| 
 | ||||
| require('dotenv').config(); | ||||
| 
 | ||||
|  | @ -24,7 +24,7 @@ const HARDFORK = 'istanbul'; | |||
| const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || ''; | ||||
| const MNEMONIC_PATH = "m/44'/60'/0'/0"; | ||||
| const MNEMONIC = process.env.MNEMONIC || ''; | ||||
| const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||
| const FORK = process.env.FORK || ''; | ||||
| 
 | ||||
| // Prevent to load scripts before compilation and typechain
 | ||||
| if (!SKIP_LOAD) { | ||||
|  | @ -57,10 +57,13 @@ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({ | |||
|   }, | ||||
| }); | ||||
| 
 | ||||
| const mainnetFork = MAINNET_FORK | ||||
| const forkMode = FORK | ||||
|   ? { | ||||
|       blockNumber: 12012081, | ||||
|       url: NETWORKS_RPC_URL['main'], | ||||
|       url: NETWORKS_RPC_URL[FORK], | ||||
|       ...(FORK && | ||||
|         BLOCK_TO_FORK[FORK] && { | ||||
|           blockNumber: BLOCK_TO_FORK[FORK], | ||||
|         }), | ||||
|     } | ||||
|   : undefined; | ||||
| 
 | ||||
|  | @ -111,7 +114,7 @@ const buidlerConfig: HardhatUserConfig = { | |||
|         privateKey: secretKey, | ||||
|         balance, | ||||
|       })), | ||||
|       forking: mainnetFork, | ||||
|       forking: forkMode, | ||||
|     }, | ||||
|     buidlerevm_docker: { | ||||
|       hardfork: 'berlin', | ||||
|  |  | |||
|  | @ -45,3 +45,16 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = { | |||
|   [ePolygonNetwork.matic]: 2 * GWEI, | ||||
|   [eXDaiNetwork.xdai]: 1 * GWEI, | ||||
| }; | ||||
| 
 | ||||
| export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = { | ||||
|   [eEthereumNetwork.main]: 12406069, | ||||
|   [eEthereumNetwork.kovan]: undefined, | ||||
|   [eEthereumNetwork.ropsten]: undefined, | ||||
|   [eEthereumNetwork.coverage]: undefined, | ||||
|   [eEthereumNetwork.hardhat]: undefined, | ||||
|   [eEthereumNetwork.buidlerevm]: undefined, | ||||
|   [eEthereumNetwork.tenderlyMain]: 12406069, | ||||
|   [ePolygonNetwork.mumbai]: undefined, | ||||
|   [ePolygonNetwork.matic]: undefined, | ||||
|   [eXDaiNetwork.xdai]: undefined, | ||||
| }; | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { | |||
|     case ConfigNames.Matic: | ||||
|       return MaticConfig; | ||||
|     case ConfigNames.Amm: | ||||
|         return AmmConfig; | ||||
|       return AmmConfig; | ||||
|     case ConfigNames.Commons: | ||||
|       return CommonsConfig; | ||||
|     default: | ||||
|  | @ -61,7 +61,7 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes | |||
| export const getGenesisPoolAdmin = async ( | ||||
|   config: ICommonConfiguration | ||||
| ): Promise<tEthereumAddress> => { | ||||
|   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||
|   const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; | ||||
|   const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork); | ||||
|   if (targetAddress) { | ||||
|     return targetAddress; | ||||
|  | @ -76,7 +76,7 @@ export const getGenesisPoolAdmin = async ( | |||
| export const getEmergencyAdmin = async ( | ||||
|   config: ICommonConfiguration | ||||
| ): Promise<tEthereumAddress> => { | ||||
|   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||
|   const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; | ||||
|   const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork); | ||||
|   if (targetAddress) { | ||||
|     return targetAddress; | ||||
|  | @ -91,7 +91,7 @@ export const getEmergencyAdmin = async ( | |||
| export const getTreasuryAddress = async ( | ||||
|   config: ICommonConfiguration | ||||
| ): Promise<tEthereumAddress> => { | ||||
|   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||
|   const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; | ||||
|   return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork); | ||||
| }; | ||||
| 
 | ||||
|  | @ -101,7 +101,7 @@ export const getATokenDomainSeparatorPerNetwork = ( | |||
| ): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network); | ||||
| 
 | ||||
| export const getWethAddress = async (config: ICommonConfiguration) => { | ||||
|   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||
|   const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name; | ||||
|   const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork); | ||||
|   if (wethAddress) { | ||||
|     return wethAddress; | ||||
|  | @ -120,8 +120,7 @@ export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { | |||
|     ReserveAssets, | ||||
|   } = poolConfig; | ||||
| 
 | ||||
|   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||
|   const network = MAINNET_FORK ? 'main' : DRE.network.name; | ||||
|   const network = process.env.FORK ? process.env.FORK : DRE.network.name; | ||||
|   return filterMapBy(LendingRateOracleRatesCommon, (key) => | ||||
|     Object.keys(ReserveAssets[network]).includes(key) | ||||
|   ); | ||||
|  |  | |||
|  | @ -30,8 +30,8 @@ export type MockTokenMap = { [symbol: string]: MintableERC20 }; | |||
| 
 | ||||
| export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => { | ||||
|   const currentNetwork = DRE.network.name; | ||||
|   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||
|   if (MAINNET_FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) { | ||||
|   const FORK = process.env.FORK; | ||||
|   if (FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) { | ||||
|     console.log(`*** ${contractId} ***\n`); | ||||
|     console.log(`Network: ${currentNetwork}`); | ||||
|     console.log(`tx: ${contractInstance.deployTransaction.hash}`); | ||||
|  | @ -153,9 +153,8 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet | |||
|   } = param as iEthereumParamsPerNetwork<T>; | ||||
|   const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>; | ||||
|   const { xdai } = param as iXDaiParamsPerNetwork<T>; | ||||
|   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||
|   if (MAINNET_FORK) { | ||||
|     return main; | ||||
|   if (process.env.FORK) { | ||||
|     return param[process.env.FORK as eNetwork] as T; | ||||
|   } | ||||
| 
 | ||||
|   switch (network) { | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ import { | |||
|   getAaveProtocolDataProvider, | ||||
|   getAToken, | ||||
|   getATokensAndRatesHelper, | ||||
|   getFirstSigner, | ||||
|   getLendingPoolAddressesProvider, | ||||
|   getLendingPoolConfiguratorProxy, | ||||
|   getStableAndVariableTokensHelper, | ||||
|  | @ -32,6 +33,7 @@ import { | |||
| import { ZERO_ADDRESS } from './constants'; | ||||
| import { isZeroAddress } from 'ethereumjs-util'; | ||||
| import { DefaultReserveInterestRateStrategy, DelegationAwareAToken } from '../types'; | ||||
| import { config } from 'process'; | ||||
| 
 | ||||
| export const chooseATokenDeployment = (id: eContractid) => { | ||||
|   switch (id) { | ||||
|  | @ -226,8 +228,19 @@ export const initReservesByHelper = async ( | |||
| 
 | ||||
|   console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`); | ||||
|   for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) { | ||||
|     console.log('address', await (await getFirstSigner()).getAddress()); | ||||
|     const prov = await getLendingPoolAddressesProvider(); | ||||
|     console.log('admin', await prov.getPoolAdmin()); | ||||
|     console.log('conf add', await prov.getLendingPoolConfigurator()); | ||||
|     console.log( | ||||
|       'prior batch init', | ||||
|       configurator.address, | ||||
|       chunkedInitInputParams[chunkIndex].slice(0, 1) | ||||
|     ); | ||||
|     const tx3 = await waitForTx( | ||||
|       await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex]) | ||||
|       await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex].slice(0, 1), { | ||||
|         gasLimit: '11000000', | ||||
|       }) | ||||
|     ); | ||||
| 
 | ||||
|     console.log(`  - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`); | ||||
|  | @ -431,8 +444,9 @@ export const initTokenReservesByHelper = async ( | |||
|     params: string; | ||||
|   }[] = []; | ||||
| 
 | ||||
|   const network = | ||||
|     process.env.MAINNET_FORK === 'true' ? eEthereumNetwork.main : (DRE.network.name as eNetwork); | ||||
|   const network = process.env.FORK | ||||
|     ? (process.env.FORK as eEthereumNetwork) | ||||
|     : (DRE.network.name as eNetwork); | ||||
|   // Grab config from DB
 | ||||
|   for (const [symbol, address] of Object.entries(tokenAddresses)) { | ||||
|     const { aTokenAddress } = await protocolDataProvider.getReserveTokensAddresses(address); | ||||
|  |  | |||
|  | @ -138,11 +138,11 @@ export const CommonsConfig: ICommonConfiguration = { | |||
|   ProviderRegistryOwner: { | ||||
|     [eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F', | ||||
|     [eEthereumNetwork.ropsten]: '', | ||||
|     [eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f', | ||||
|     [eEthereumNetwork.main]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE', | ||||
|     [eEthereumNetwork.coverage]: '', | ||||
|     [eEthereumNetwork.hardhat]: '', | ||||
|     [eEthereumNetwork.buidlerevm]: '', | ||||
|     [eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f', | ||||
|     [eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE', | ||||
|   }, | ||||
|   LendingRateOracle: { | ||||
|     [eEthereumNetwork.coverage]: '', | ||||
|  | @ -285,6 +285,7 @@ export const CommonsConfig: ICommonConfiguration = { | |||
|       YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4', | ||||
|       ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962', | ||||
|       USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', | ||||
|       xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F', | ||||
|     }, | ||||
|     [eEthereumNetwork.tenderlyMain]: { | ||||
|       AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012', | ||||
|  | @ -307,6 +308,7 @@ export const CommonsConfig: ICommonConfiguration = { | |||
|       YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4', | ||||
|       ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962', | ||||
|       USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', | ||||
|       xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F', | ||||
|     }, | ||||
|   }, | ||||
|   ReserveAssets: { | ||||
|  |  | |||
|  | @ -139,14 +139,13 @@ export const CommonsConfig: ICommonConfiguration = { | |||
|     [eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413', | ||||
|   }, | ||||
|   ProviderRegistryOwner: { | ||||
|     // DEPLOYED WITH CORRECT ADDRESS
 | ||||
|     [eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F', | ||||
|     [eEthereumNetwork.ropsten]: '', | ||||
|     [eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f', | ||||
|     [eEthereumNetwork.main]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE', | ||||
|     [eEthereumNetwork.coverage]: '', | ||||
|     [eEthereumNetwork.hardhat]: '', | ||||
|     [eEthereumNetwork.buidlerevm]: '', | ||||
|     [eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f', | ||||
|     [eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE', | ||||
|   }, | ||||
|   LendingRateOracle: { | ||||
|     [eEthereumNetwork.coverage]: '', | ||||
|  |  | |||
							
								
								
									
										16
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								package.json
									
									
									
									
									
								
							|  | @ -17,7 +17,7 @@ | |||
|     "hardhat:mumbai": "hardhat --network mumbai", | ||||
|     "hardhat:matic": "hardhat --network matic", | ||||
|     "compile": "SKIP_LOAD=true hardhat compile", | ||||
|     "console:fork": "MAINNET_FORK=true hardhat console", | ||||
|     "console:fork": "FORK=main hardhat console", | ||||
|     "test": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-aave/*.spec.ts", | ||||
|     "test-amm": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-amm/*.spec.ts", | ||||
|     "test-amm-scenarios": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-amm/__setup.spec.ts test-suites/test-amm/scenario.spec.ts", | ||||
|  | @ -37,7 +37,7 @@ | |||
|     "test-weth:main": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/weth-gateway.spec.ts", | ||||
|     "test-weth:amm": "hardhat test test-suites/test-amm/__setup.spec.ts test-suites/test-amm/weth-gateway.spec.ts", | ||||
|     "test-uniswap": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/uniswapAdapters*.spec.ts", | ||||
|     "test:main:check-list": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test  test-suites/test-aave/__setup.spec.ts test-suites/test-aave/mainnet/check-list.spec.ts", | ||||
|     "test:main:check-list": "FORK=main TS_NODE_TRANSPILE_ONLY=1 hardhat test  test-suites/test-aave/__setup.spec.ts test-suites/test-aave/mainnet/check-list.spec.ts", | ||||
|     "dev:coverage": "buidler compile --force && buidler coverage --network coverage", | ||||
|     "aave:evm:dev:migration": "npm run compile && hardhat aave:dev", | ||||
|     "aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet --skip-registry", | ||||
|  | @ -65,11 +65,13 @@ | |||
|     "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave", | ||||
|     "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify", | ||||
|     "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet", | ||||
|     "aave:fork:main": "npm run compile && MAINNET_FORK=true hardhat aave:mainnet", | ||||
|     "amm:fork:main": "npm run compile && MAINNET_FORK=true hardhat amm:mainnet", | ||||
|     "aave:fork:main": "npm run compile && FORK=main hardhat aave:mainnet", | ||||
|     "aave:fork:kovan": "npm run compile && FORK=kovan hardhat aave:mainnet", | ||||
|     "amm:fork:main": "npm run compile && FORK=main hardhat amm:mainnet", | ||||
|     "amm:fork:kovan": "npm run compile && FORK=kovan hardhat amm:mainnet", | ||||
|     "amm:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- amm:mainnet", | ||||
|     "aave:main:full:migration": "npm run compile && npm run hardhat:main -- aave:mainnet --verify", | ||||
|     "aave:main:full:initialize": "npm run compile && MAINNET_FORK=true full:initialize-tokens --pool Aave", | ||||
|     "aave:main:full:initialize": "npm run compile && FORK=main full:initialize-tokens --pool Aave", | ||||
|     "amm:main:full:migration": "npm run compile && npm run hardhat:main -- amm:mainnet --verify", | ||||
|     "prettier:check": "npx prettier -c 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts'  'test-suites/test-aave/**/*.ts'", | ||||
|     "prettier:write": "prettier --write 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts'  'test-suites/test-aave/**/*.ts'", | ||||
|  | @ -92,9 +94,9 @@ | |||
|     "kovan:verify:tokens": "npm run hardhat:kovan verify:tokens -- --pool Aave", | ||||
|     "ropsten:verify:tokens": "npm run hardhat:ropsten verify:tokens -- --pool Aave", | ||||
|     "mainnet:verify:tokens": "npm run hardhat:main verify:tokens -- --pool Aave", | ||||
|     "print-config:fork:mainnet": "MAINNET_FORK=true hardhat print-config:fork", | ||||
|     "print-config:fork:mainnet": "FORK=main hardhat print-config:fork", | ||||
|     "print-config:kovan": "hardhat --network kovan print-config --pool Aave --data-provider 0xA1901785c29cBd48bfA74e46b67C736b26054fa4", | ||||
|     "main:fork:initialize-tokens": "npm run compile && MAINNET_FORK=true hardhat full:initialize-tokens --pool Aave", | ||||
|     "main:fork:initialize-tokens": "npm run compile && FORK=main hardhat full:initialize-tokens --pool Aave", | ||||
|     "main:initialize-tokens": "npm run compile && hardhat --network main full:initialize-tokens --pool Aave", | ||||
|     "kovan:initialize-tokens": "npm run compile && hardhat --network kovan full:initialize-tokens --pool Aave", | ||||
|     "external:deploy-assets-kovan": "npm run compile && hardhat --network kovan external:deploy-new-asset --symbol ${SYMBOL} --verify", | ||||
|  |  | |||
|  | @ -56,7 +56,7 @@ task('add-market-to-registry', 'Adds address provider to registry') | |||
|     } | ||||
| 
 | ||||
|     // Checks if deployer address is registry owner
 | ||||
|     if (process.env.MAINNET_FORK === 'true') { | ||||
|     if (process.env.FORK) { | ||||
|       await DRE.network.provider.request({ | ||||
|         method: 'hardhat_impersonateAccount', | ||||
|         params: [providerRegistryOwner], | ||||
|  | @ -64,8 +64,7 @@ task('add-market-to-registry', 'Adds address provider to registry') | |||
|       signer = DRE.ethers.provider.getSigner(providerRegistryOwner); | ||||
|       const firstAccount = await getFirstSigner(); | ||||
|       await firstAccount.sendTransaction({ value: parseEther('10'), to: providerRegistryOwner }); | ||||
|     } | ||||
|     if ( | ||||
|     } else if ( | ||||
|       !deployed && | ||||
|       providerRegistryOwner.toLocaleLowerCase() !== currentSignerAddress.toLocaleLowerCase() | ||||
|     ) { | ||||
|  |  | |||
|  | @ -22,8 +22,9 @@ task('full:initialize-tokens', 'Initialize lending pool configuration.') | |||
|     try { | ||||
|       await DRE.run('set-DRE'); | ||||
|       let signer: Signer; | ||||
|       const network = | ||||
|         process.env.MAINNET_FORK === 'true' ? eEthereumNetwork.main : <eNetwork>DRE.network.name; | ||||
|       const network = process.env.FORK | ||||
|         ? (process.env.FORK as eNetwork) | ||||
|         : <eNetwork>DRE.network.name; | ||||
|       const poolConfig = loadPoolConfig(pool); | ||||
|       const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration; | ||||
| 
 | ||||
|  | @ -46,7 +47,7 @@ task('full:initialize-tokens', 'Initialize lending pool configuration.') | |||
|         throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory'; | ||||
|       } | ||||
| 
 | ||||
|       if (process.env.MAINNET_FORK === 'true') { | ||||
|       if (process.env.FORK) { | ||||
|         await DRE.network.provider.request({ | ||||
|           method: 'hardhat_impersonateAccount', | ||||
|           params: [providerRegistryOwner], | ||||
|  |  | |||
|  | @ -14,10 +14,10 @@ task('print-config', 'Inits the DRE, to have access to all the plugins') | |||
|   .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) | ||||
|   .setAction(async ({ pool, dataProvider }, localBRE) => { | ||||
|     await localBRE.run('set-DRE'); | ||||
|     const network = | ||||
|       process.env.MAINNET_FORK === 'true' | ||||
|         ? eEthereumNetwork.main | ||||
|         : (localBRE.network.name as eNetwork); | ||||
|     const network = process.env.FORK | ||||
|       ? (process.env.FORK as eNetwork) | ||||
|       : (localBRE.network.name as eNetwork); | ||||
|     console.log(network); | ||||
|     const poolConfig = loadPoolConfig(pool); | ||||
| 
 | ||||
|     const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network); | ||||
|  | @ -60,7 +60,7 @@ task('print-config', 'Inits the DRE, to have access to all the plugins') | |||
|     ]; | ||||
|     const tokensFields = ['aToken', 'stableDebtToken', 'variableDebtToken']; | ||||
|     for (const [symbol, address] of Object.entries( | ||||
|       getParamPerNetwork(poolConfig.ReserveAssets, network) | ||||
|       getParamPerNetwork(poolConfig.ReserveAssets, network as eNetwork) | ||||
|     )) { | ||||
|       console.log(`- ${symbol} asset config`); | ||||
|       console.log(`  - reserve address: ${address}`); | ||||
|  |  | |||
|  | @ -5,6 +5,8 @@ import { usingTenderly } from '../../helpers/tenderly-utils'; | |||
| import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||||
| import { getFirstSigner } from '../../helpers/contracts-getters'; | ||||
| import { formatEther } from 'ethers/lib/utils'; | ||||
| import { fork } from 'child_process'; | ||||
| import { env } from 'process'; | ||||
| 
 | ||||
| task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction( | ||||
|   async (_, _DRE) => { | ||||
|  | @ -36,6 +38,18 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set | |||
|       ); | ||||
|     } | ||||
| 
 | ||||
|     console.log('- Enviroment'); | ||||
|     if (process.env.FORK) { | ||||
|       console.log('  - Fork Mode activated at network: ', process.env.FORK); | ||||
|       if (_DRE?.config?.networks?.hardhat?.forking?.url) { | ||||
|         console.log('  - Provider URL:', _DRE.config.networks.hardhat.forking?.url?.split('/')[2]); | ||||
|       } else { | ||||
|         console.error( | ||||
|           `[FORK][Error], missing Provider URL for "${_DRE.network.name}" network. Fill the URL at './helper-hardhat-config.ts' file` | ||||
|         ); | ||||
|       } | ||||
|     } | ||||
|     console.log('  - Network :', _DRE.network.name); | ||||
|     setDRE(_DRE); | ||||
|     return _DRE; | ||||
|   } | ||||
|  |  | |||
|  | @ -191,7 +191,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | |||
|       WMATIC: mockTokens.WMATIC.address, | ||||
|       USD: USD_ADDRESS, | ||||
|       STAKE: mockTokens.STAKE.address, | ||||
|       xSUSHI: mockTokens.xSUSHI.address | ||||
|       xSUSHI: mockTokens.xSUSHI.address, | ||||
|     }, | ||||
|     fallbackOracle | ||||
|   ); | ||||
|  | @ -295,9 +295,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | |||
| before(async () => { | ||||
|   await rawBRE.run('set-DRE'); | ||||
|   const [deployer, secondaryWallet] = await getEthersSigners(); | ||||
|   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||
|   const FORK = process.env.FORK; | ||||
| 
 | ||||
|   if (MAINNET_FORK) { | ||||
|   if (FORK) { | ||||
|     await rawBRE.run('aave:mainnet'); | ||||
|   } else { | ||||
|     console.log('-> Deploying test environment...'); | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ import { | |||
|   getUniswapRepayAdapter, | ||||
|   getFlashLiquidationAdapter, | ||||
| } from '../../../helpers/contracts-getters'; | ||||
| import { eEthereumNetwork, tEthereumAddress } from '../../../helpers/types'; | ||||
| import { eEthereumNetwork, eNetwork, tEthereumAddress } from '../../../helpers/types'; | ||||
| import { LendingPool } from '../../../types/LendingPool'; | ||||
| import { AaveProtocolDataProvider } from '../../../types/AaveProtocolDataProvider'; | ||||
| import { MintableERC20 } from '../../../types/MintableERC20'; | ||||
|  | @ -116,9 +116,9 @@ export async function initializeMakeSuite() { | |||
| 
 | ||||
|   testEnv.addressesProvider = await getLendingPoolAddressesProvider(); | ||||
| 
 | ||||
|   if (process.env.MAINNET_FORK === 'true') { | ||||
|   if (process.env.FORK) { | ||||
|     testEnv.registry = await getLendingPoolAddressesProviderRegistry( | ||||
|       getParamPerNetwork(AaveConfig.ProviderRegistry, eEthereumNetwork.main) | ||||
|       getParamPerNetwork(AaveConfig.ProviderRegistry, process.env.FORK as eNetwork) | ||||
|     ); | ||||
|   } else { | ||||
|     testEnv.registry = await getLendingPoolAddressesProviderRegistry(); | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ import { | |||
|   deployUniswapLiquiditySwapAdapter, | ||||
|   deployUniswapRepayAdapter, | ||||
|   deployFlashLiquidationAdapter, | ||||
|   authorizeWETHGateway | ||||
|   authorizeWETHGateway, | ||||
| } from '../../helpers/contracts-deployments'; | ||||
| import { Signer } from 'ethers'; | ||||
| import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types'; | ||||
|  | @ -240,8 +240,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | |||
|   console.log('Initialize configuration'); | ||||
| 
 | ||||
|   const config = loadPoolConfig(ConfigNames.Amm); | ||||
|    | ||||
|   const {  | ||||
| 
 | ||||
|   const { | ||||
|     ATokenNamePrefix, | ||||
|     StableDebtTokenNamePrefix, | ||||
|     VariableDebtTokenNamePrefix, | ||||
|  | @ -292,9 +292,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | |||
| before(async () => { | ||||
|   await rawBRE.run('set-DRE'); | ||||
|   const [deployer, secondaryWallet] = await getEthersSigners(); | ||||
|   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||
|   const FORK = process.env.FORK; | ||||
| 
 | ||||
|   if (MAINNET_FORK) { | ||||
|   if (FORK) { | ||||
|     await rawBRE.run('amm:mainnet'); | ||||
|   } else { | ||||
|     console.log('-> Deploying test environment...'); | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ import { | |||
|   getUniswapRepayAdapter, | ||||
|   getFlashLiquidationAdapter, | ||||
| } from '../../../helpers/contracts-getters'; | ||||
| import { eEthereumNetwork, tEthereumAddress } from '../../../helpers/types'; | ||||
| import { eEthereumNetwork, eNetwork, tEthereumAddress } from '../../../helpers/types'; | ||||
| import { LendingPool } from '../../../types/LendingPool'; | ||||
| import { AaveProtocolDataProvider } from '../../../types/AaveProtocolDataProvider'; | ||||
| import { MintableERC20 } from '../../../types/MintableERC20'; | ||||
|  | @ -116,9 +116,9 @@ export async function initializeMakeSuite() { | |||
| 
 | ||||
|   testEnv.addressesProvider = await getLendingPoolAddressesProvider(); | ||||
| 
 | ||||
|   if (process.env.MAINNET_FORK === 'true') { | ||||
|   if (process.env.FORK) { | ||||
|     testEnv.registry = await getLendingPoolAddressesProviderRegistry( | ||||
|       getParamPerNetwork(AmmConfig.ProviderRegistry, eEthereumNetwork.main) | ||||
|       getParamPerNetwork(AmmConfig.ProviderRegistry, process.env.FORK as eNetwork) | ||||
|     ); | ||||
|   } else { | ||||
|     testEnv.registry = await getLendingPoolAddressesProviderRegistry(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 David Racero
						David Racero