mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Merge branch 'feat/66' into 67-use-factory-functions
This commit is contained in:
		
						commit
						628f0de639
					
				| 
						 | 
				
			
			@ -97,7 +97,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "PriceOracle": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x1750499D05Ed1674d822430FB960d5F6731fDf64",
 | 
			
		||||
      "address": "0x0C6c3C47A1f650809B0D1048FDf9603e09473D7E",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +111,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MockAggregator": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
 | 
			
		||||
      "address": "0xc11f8E173ee67ffA7BBdD185D2399994AAd23Ec6",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +125,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "ChainlinkProxyPriceProvider": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x7B6C3e5486D9e6959441ab554A889099eed76290",
 | 
			
		||||
      "address": "0xD662fb7FDC7526C79AA4417d2A4415416e057ec4",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "LendingRateOracle": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E",
 | 
			
		||||
      "address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +161,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "DefaultReserveInterestRateStrategy": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xB660Fdd109a95718cB9d20E3A89EE6cE342aDcB6",
 | 
			
		||||
      "address": "0x7d40dD74d3aE1a7e4A7dd08eaE899e85940563cd",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +220,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MockFlashLoanReceiver": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2"
 | 
			
		||||
      "address": "0x63387deC8C4a0F17Cf0C27Ea3476F03F6a45d3AE"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x2B681757d757fbB80cc51c6094cEF5eE75bF55aA"
 | 
			
		||||
| 
						 | 
				
			
			@ -231,7 +231,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "WalletBalanceProvider": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4",
 | 
			
		||||
      "address": "0x2B681757d757fbB80cc51c6094cEF5eE75bF55aA",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -567,7 +567,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "AaveProtocolTestHelpers": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xe7536f450378748E1BD4645D3c77ec38e0F3ba28"
 | 
			
		||||
      "address": "0x93472C0e03215F9c33DA240Eb16703C8244eAa8c"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4"
 | 
			
		||||
| 
						 | 
				
			
			@ -578,7 +578,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "StableDebtToken": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x830bceA96E56DBC1F8578f75fBaC0AF16B32A07d",
 | 
			
		||||
      "address": "0x5f687ea375c359E0CF6aa8A1004BE0c3BaBee7Fd",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -592,7 +592,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "VariableDebtToken": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E",
 | 
			
		||||
      "address": "0x626FdE749F9d499d3777320CAf29484B624ab84a",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -610,7 +610,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x5f7134cd38C826a7649f9Cc47dda24d834DD2967",
 | 
			
		||||
      "address": "0xB660Fdd109a95718cB9d20E3A89EE6cE342aDcB6",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "coverage": {
 | 
			
		||||
| 
						 | 
				
			
			@ -620,7 +620,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MockAToken": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x392E5355a0e88Bd394F717227c752670fb3a8020",
 | 
			
		||||
      "address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -648,7 +648,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MockStableDebtToken": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x3b050AFb4ac4ACE646b31fF3639C1CD43aC31460",
 | 
			
		||||
      "address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -662,7 +662,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MockVariableDebtToken": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xEBAB67ee3ef604D5c250A53b4b8fcbBC6ec3007C",
 | 
			
		||||
      "address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
| 
						 | 
				
			
			@ -676,7 +676,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MockSwapAdapter": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10"
 | 
			
		||||
      "address": "0x8280D40C9E9F04229D2435EAad6e0011309ce81B"
 | 
			
		||||
    },
 | 
			
		||||
    "coverage": {
 | 
			
		||||
      "address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										353
									
								
								helpers/contracts-deployments.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										353
									
								
								helpers/contracts-deployments.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,353 @@
 | 
			
		|||
import {Contract} from 'ethers';
 | 
			
		||||
import {BRE} from './misc-utils';
 | 
			
		||||
import {
 | 
			
		||||
  tEthereumAddress,
 | 
			
		||||
  eContractid,
 | 
			
		||||
  tStringTokenSmallUnits,
 | 
			
		||||
  AavePools,
 | 
			
		||||
  TokenContractId,
 | 
			
		||||
  iMultiPoolsAssets,
 | 
			
		||||
  IReserveParams,
 | 
			
		||||
  PoolConfiguration,
 | 
			
		||||
} from './types';
 | 
			
		||||
 | 
			
		||||
import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
 | 
			
		||||
import {readArtifact} from '@nomiclabs/buidler/plugins';
 | 
			
		||||
import {MockContract} from 'ethereum-waffle';
 | 
			
		||||
import {getReservesConfigByPool} from './configuration';
 | 
			
		||||
import {getFirstSigner, getReserveLogic} from './contracts-getters';
 | 
			
		||||
import {ZERO_ADDRESS} from './constants';
 | 
			
		||||
import {
 | 
			
		||||
  AaveProtocolTestHelpersFactory,
 | 
			
		||||
  ATokenFactory,
 | 
			
		||||
  ChainlinkProxyPriceProviderFactory,
 | 
			
		||||
  DefaultReserveInterestRateStrategyFactory,
 | 
			
		||||
  GenericLogicFactory,
 | 
			
		||||
  InitializableAdminUpgradeabilityProxyFactory,
 | 
			
		||||
  LendingPoolAddressesProviderFactory,
 | 
			
		||||
  LendingPoolAddressesProviderRegistryFactory,
 | 
			
		||||
  LendingPoolCollateralManagerFactory,
 | 
			
		||||
  LendingPoolConfiguratorFactory,
 | 
			
		||||
  LendingPoolFactory,
 | 
			
		||||
  LendingPoolLibraryAddresses,
 | 
			
		||||
  LendingRateOracleFactory,
 | 
			
		||||
  MintableErc20Factory,
 | 
			
		||||
  MockAggregatorFactory,
 | 
			
		||||
  MockFlashLoanReceiverFactory,
 | 
			
		||||
  MockSwapAdapterFactory,
 | 
			
		||||
  PriceOracleFactory,
 | 
			
		||||
  ReserveLogicFactory,
 | 
			
		||||
  StableDebtTokenFactory,
 | 
			
		||||
  VariableDebtTokenFactory,
 | 
			
		||||
  WalletBalanceProviderFactory,
 | 
			
		||||
} from '../types';
 | 
			
		||||
import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers';
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolAddressesProvider = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new LendingPoolAddressesProviderFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.LendingPoolAddressesProvider,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolAddressesProviderRegistry = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new LendingPoolAddressesProviderRegistryFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.LendingPoolAddressesProviderRegistry,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolConfigurator = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new LendingPoolConfiguratorFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.LendingPoolConfigurator,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployReserveLogicLibrary = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new ReserveLogicFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.ReserveLogic,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployGenericLogic = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new GenericLogicFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.GenericLogic,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployValidationLogic = async (
 | 
			
		||||
  reserveLogic: Contract,
 | 
			
		||||
  genericLogic: Contract,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const validationLogicArtifact = await readArtifact(
 | 
			
		||||
    BRE.config.paths.artifacts,
 | 
			
		||||
    eContractid.ValidationLogic
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const linkedValidationLogicByteCode = linkBytecode(validationLogicArtifact, {
 | 
			
		||||
    [eContractid.ReserveLogic]: reserveLogic.address,
 | 
			
		||||
    [eContractid.GenericLogic]: genericLogic.address,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const validationLogicFactory = await BRE.ethers.getContractFactory(
 | 
			
		||||
    validationLogicArtifact.abi,
 | 
			
		||||
    linkedValidationLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const validationLogic = await (await validationLogicFactory.deploy()).deployed();
 | 
			
		||||
 | 
			
		||||
  return withSaveAndVerify(validationLogic, eContractid.ValidationLogic, [], verify);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployAaveLibraries = async (
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
): Promise<LendingPoolLibraryAddresses> => {
 | 
			
		||||
  const reserveLogic = await deployReserveLogicLibrary(verify);
 | 
			
		||||
  const genericLogic = await deployGenericLogic(verify);
 | 
			
		||||
  const validationLogic = await deployValidationLogic(reserveLogic, genericLogic, verify);
 | 
			
		||||
 | 
			
		||||
  console.log('generic logic address LEND POOL', genericLogic.address);
 | 
			
		||||
  // Hardcoded solidity placeholders, if any library changes path this will fail.
 | 
			
		||||
  // The '__$PLACEHOLDER$__ can be calculated via solidity keccak, but the LendingPoolLibraryAddresses Type seems to
 | 
			
		||||
  // require a hardcoded string.
 | 
			
		||||
  //
 | 
			
		||||
  //  how-to:
 | 
			
		||||
  //  1. PLACEHOLDER = solidityKeccak256(['string'], `${libPath}:${libName}`).slice(2, 36)
 | 
			
		||||
  //  2. LIB_PLACEHOLDER = `__$${PLACEHOLDER}$__`
 | 
			
		||||
  // or grab placeholdes from LendingPoolLibraryAddresses at Typechain generation.
 | 
			
		||||
  //
 | 
			
		||||
  // libPath example: contracts/libraries/logic/GenericLogic.sol
 | 
			
		||||
  // libName example: GenericLogic
 | 
			
		||||
  return {
 | 
			
		||||
    ['__$5201a97c05ba6aa659e2f36a933dd51801$__']: validationLogic.address,
 | 
			
		||||
    ['__$d3b4366daeb9cadc7528af6145b50b2183$__']: reserveLogic.address,
 | 
			
		||||
    ['__$4c26be947d349222af871a3168b3fe584b$__']: genericLogic.address,
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployLendingPool = async (verify?: boolean) => {
 | 
			
		||||
  const libraries = await deployAaveLibraries(verify);
 | 
			
		||||
  return withSaveAndVerify(
 | 
			
		||||
    await new LendingPoolFactory(libraries, await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.LendingPool,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployPriceOracle = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new PriceOracleFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.PriceOracle,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployLendingRateOracle = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new LendingRateOracleFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.LendingRateOracle,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new MockAggregatorFactory(await getFirstSigner()).deploy(price),
 | 
			
		||||
    eContractid.MockAggregator,
 | 
			
		||||
    [price],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployChainlinkProxyPriceProvider = async (
 | 
			
		||||
  args: [tEthereumAddress[], tEthereumAddress[], tEthereumAddress],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new ChainlinkProxyPriceProviderFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.ChainlinkProxyPriceProvider,
 | 
			
		||||
    args,
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolCollateralManager = async (verify?: boolean) => {
 | 
			
		||||
  const reservesLogic = await getReserveLogic();
 | 
			
		||||
  const libraries = {
 | 
			
		||||
    // See deployAaveLibraries() function
 | 
			
		||||
    ['__$d3b4366daeb9cadc7528af6145b50b2183$__']: reservesLogic.address,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  return withSaveAndVerify(
 | 
			
		||||
    await new LendingPoolCollateralManagerFactory(libraries, await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.LendingPoolCollateralManager,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployInitializableAdminUpgradeabilityProxy = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new InitializableAdminUpgradeabilityProxyFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployMockFlashLoanReceiver = async (
 | 
			
		||||
  addressesProvider: tEthereumAddress,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new MockFlashLoanReceiverFactory(await getFirstSigner()).deploy(addressesProvider),
 | 
			
		||||
    eContractid.MockFlashLoanReceiver,
 | 
			
		||||
    [addressesProvider],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployWalletBalancerProvider = async (
 | 
			
		||||
  addressesProvider: tEthereumAddress,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new WalletBalanceProviderFactory(await getFirstSigner()).deploy(addressesProvider),
 | 
			
		||||
    eContractid.WalletBalanceProvider,
 | 
			
		||||
    [addressesProvider],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployMockSwapAdapter = async (addressesProvider: tEthereumAddress) =>
 | 
			
		||||
  await new MockSwapAdapterFactory(await getFirstSigner()).deploy(addressesProvider);
 | 
			
		||||
 | 
			
		||||
export const deployAaveProtocolTestHelpers = async (
 | 
			
		||||
  addressesProvider: tEthereumAddress,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new AaveProtocolTestHelpersFactory(await getFirstSigner()).deploy(addressesProvider),
 | 
			
		||||
    eContractid.AaveProtocolTestHelpers,
 | 
			
		||||
    [addressesProvider],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployMintableERC20 = async (
 | 
			
		||||
  args: [string, string, string],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
): Promise<MintableERC20> =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new MintableErc20Factory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.MintableERC20,
 | 
			
		||||
    args,
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployDefaultReserveInterestRateStrategy = async (
 | 
			
		||||
  args: [tEthereumAddress, string, string, string, string, string],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new DefaultReserveInterestRateStrategyFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.DefaultReserveInterestRateStrategy,
 | 
			
		||||
    args,
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployStableDebtToken = async (
 | 
			
		||||
  args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new StableDebtTokenFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.StableDebtToken,
 | 
			
		||||
    args,
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployVariableDebtToken = async (
 | 
			
		||||
  args: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new VariableDebtTokenFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.VariableDebtToken,
 | 
			
		||||
    args,
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployGenericAToken = async (
 | 
			
		||||
  [poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const args: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ] = [poolAddress, underlyingAssetAddress, ZERO_ADDRESS, name, symbol, incentivesController];
 | 
			
		||||
  return withSaveAndVerify(
 | 
			
		||||
    await new ATokenFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.VariableDebtToken,
 | 
			
		||||
    args,
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployAllMockTokens = async (verify?: boolean) => {
 | 
			
		||||
  const tokens: {[symbol: string]: MockContract | MintableERC20} = {};
 | 
			
		||||
 | 
			
		||||
  const protoConfigData = getReservesConfigByPool(AavePools.proto);
 | 
			
		||||
  const secondaryConfigData = getReservesConfigByPool(AavePools.secondary);
 | 
			
		||||
 | 
			
		||||
  for (const tokenSymbol of Object.keys(TokenContractId)) {
 | 
			
		||||
    let decimals = '18';
 | 
			
		||||
 | 
			
		||||
    let configData = (<any>protoConfigData)[tokenSymbol];
 | 
			
		||||
 | 
			
		||||
    if (!configData) {
 | 
			
		||||
      configData = (<any>secondaryConfigData)[tokenSymbol];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tokens[tokenSymbol] = await deployMintableERC20(
 | 
			
		||||
      [tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals],
 | 
			
		||||
      verify
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployMockTokens = async (config: PoolConfiguration, verify?: boolean) => {
 | 
			
		||||
  const tokens: {[symbol: string]: MockContract | MintableERC20} = {};
 | 
			
		||||
  const defaultDecimals = 18;
 | 
			
		||||
 | 
			
		||||
  const configData = config.ReservesConfig;
 | 
			
		||||
 | 
			
		||||
  for (const tokenSymbol of Object.keys(config.ReserveSymbols)) {
 | 
			
		||||
    tokens[tokenSymbol] = await deployMintableERC20(
 | 
			
		||||
      [
 | 
			
		||||
        tokenSymbol,
 | 
			
		||||
        tokenSymbol,
 | 
			
		||||
        configData[tokenSymbol as keyof iMultiPoolsAssets<IReserveParams>].reserveDecimals ||
 | 
			
		||||
          defaultDecimals.toString(),
 | 
			
		||||
      ],
 | 
			
		||||
      verify
 | 
			
		||||
    );
 | 
			
		||||
    await registerContractInJsonDb(tokenSymbol.toUpperCase(), tokens[tokenSymbol]);
 | 
			
		||||
  }
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,211 @@
 | 
			
		|||
import {
 | 
			
		||||
  AaveProtocolTestHelpersFactory,
 | 
			
		||||
  ATokenFactory,
 | 
			
		||||
  DefaultReserveInterestRateStrategyFactory,
 | 
			
		||||
  GenericLogicFactory,
 | 
			
		||||
  LendingPoolAddressesProviderFactory,
 | 
			
		||||
  LendingPoolAddressesProviderRegistryFactory,
 | 
			
		||||
  LendingPoolConfiguratorFactory,
 | 
			
		||||
  LendingPoolFactory,
 | 
			
		||||
  LendingRateOracleFactory,
 | 
			
		||||
  MintableErc20Factory,
 | 
			
		||||
  MockFlashLoanReceiverFactory,
 | 
			
		||||
  MockSwapAdapterFactory,
 | 
			
		||||
  PriceOracleFactory,
 | 
			
		||||
  ReserveLogicFactory,
 | 
			
		||||
  StableDebtTokenFactory,
 | 
			
		||||
  VariableDebtTokenFactory,
 | 
			
		||||
} from '../types';
 | 
			
		||||
import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory';
 | 
			
		||||
import {getContract, MockTokenMap} from './contracts-helpers';
 | 
			
		||||
import {BRE, getDb} from './misc-utils';
 | 
			
		||||
import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types';
 | 
			
		||||
 | 
			
		||||
export const getFirstSigner = async () => (await BRE.ethers.getSigners())[0];
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await LendingPoolAddressesProviderFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${BRE.network.name}`).value())
 | 
			
		||||
        .address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await LendingPoolConfiguratorFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingPoolConfigurator}.${BRE.network.name}`).value())
 | 
			
		||||
        .address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingPool = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await LendingPoolFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingPool}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getPriceOracle = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await PriceOracleFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.PriceOracle}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getAToken = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await ATokenFactory.connect(
 | 
			
		||||
    address || (await getDb().get(`${eContractid.AToken}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getStableDebtToken = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await StableDebtTokenFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.StableDebtToken}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getVariableDebtToken = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await VariableDebtTokenFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.VariableDebtToken}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getMintableErc20 = async (address: tEthereumAddress) =>
 | 
			
		||||
  await MintableErc20Factory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.MintableERC20}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getIErc20Detailed = async (address: tEthereumAddress) =>
 | 
			
		||||
  await Ierc20DetailedFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.IERC20Detailed}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getAaveProtocolTestHelpers = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await AaveProtocolTestHelpersFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.AaveProtocolTestHelpers}.${BRE.network.name}`).value())
 | 
			
		||||
        .address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getInterestRateStrategy = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await DefaultReserveInterestRateStrategyFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (
 | 
			
		||||
        await getDb()
 | 
			
		||||
          .get(`${eContractid.DefaultReserveInterestRateStrategy}.${BRE.network.name}`)
 | 
			
		||||
          .value()
 | 
			
		||||
      ).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await MockFlashLoanReceiverFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.MockFlashLoanReceiver}.${BRE.network.name}`).value())
 | 
			
		||||
        .address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getMockSwapAdapter = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await MockSwapAdapterFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.MockSwapAdapter}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getLendingRateOracle = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await LendingRateOracleFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingRateOracle}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getMockedTokens = async (config: PoolConfiguration) => {
 | 
			
		||||
  const tokenSymbols = config.ReserveSymbols;
 | 
			
		||||
  const db = getDb();
 | 
			
		||||
  const tokens: MockTokenMap = await tokenSymbols.reduce<Promise<MockTokenMap>>(
 | 
			
		||||
    async (acc, tokenSymbol) => {
 | 
			
		||||
      const accumulator = await acc;
 | 
			
		||||
      const address = db.get(`${tokenSymbol.toUpperCase()}.${BRE.network.name}`).value().address;
 | 
			
		||||
      accumulator[tokenSymbol] = await getMintableErc20(address);
 | 
			
		||||
      return Promise.resolve(acc);
 | 
			
		||||
    },
 | 
			
		||||
    Promise.resolve({})
 | 
			
		||||
  );
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getAllMockedTokens = async () => {
 | 
			
		||||
  const db = getDb();
 | 
			
		||||
  const tokens: MockTokenMap = await Object.keys(TokenContractId).reduce<Promise<MockTokenMap>>(
 | 
			
		||||
    async (acc, tokenSymbol) => {
 | 
			
		||||
      const accumulator = await acc;
 | 
			
		||||
      const address = db.get(`${tokenSymbol.toUpperCase()}.${BRE.network.name}`).value().address;
 | 
			
		||||
      accumulator[tokenSymbol] = await getMintableErc20(address);
 | 
			
		||||
      return Promise.resolve(acc);
 | 
			
		||||
    },
 | 
			
		||||
    Promise.resolve({})
 | 
			
		||||
  );
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getPairsTokenAggregator = (
 | 
			
		||||
  allAssetsAddresses: {
 | 
			
		||||
    [tokenSymbol: string]: tEthereumAddress;
 | 
			
		||||
  },
 | 
			
		||||
  aggregatorsAddresses: {[tokenSymbol: string]: tEthereumAddress}
 | 
			
		||||
): [string[], string[]] => {
 | 
			
		||||
  const {ETH, USD, WETH, ...assetsAddressesWithoutEth} = allAssetsAddresses;
 | 
			
		||||
 | 
			
		||||
  const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => {
 | 
			
		||||
    if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') {
 | 
			
		||||
      const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
 | 
			
		||||
        (value) => value === tokenSymbol
 | 
			
		||||
      );
 | 
			
		||||
      const [, aggregatorAddress] = (Object.entries(aggregatorsAddresses) as [
 | 
			
		||||
        string,
 | 
			
		||||
        tEthereumAddress
 | 
			
		||||
      ][])[aggregatorAddressIndex];
 | 
			
		||||
      return [tokenAddress, aggregatorAddress];
 | 
			
		||||
    }
 | 
			
		||||
  }) as [string, string][];
 | 
			
		||||
 | 
			
		||||
  const mappedPairs = pairs.map(([asset]) => asset);
 | 
			
		||||
  const mappedAggregators = pairs.map(([, source]) => source);
 | 
			
		||||
 | 
			
		||||
  return [mappedPairs, mappedAggregators];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await LendingPoolAddressesProviderRegistryFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (
 | 
			
		||||
        await getDb()
 | 
			
		||||
          .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${BRE.network.name}`)
 | 
			
		||||
          .value()
 | 
			
		||||
      ).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getReserveLogic = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await ReserveLogicFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.ReserveLogic}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getGenericLogic = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await GenericLogicFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.GenericLogic}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
import {Contract, Signer, utils, ethers} from 'ethers';
 | 
			
		||||
import {CommonsConfig} from '../config/commons';
 | 
			
		||||
import {signTypedData_v4} from 'eth-sig-util';
 | 
			
		||||
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import {getDb, BRE} from './misc-utils';
 | 
			
		||||
import {
 | 
			
		||||
  tEthereumAddress,
 | 
			
		||||
| 
						 | 
				
			
			@ -9,48 +11,13 @@ import {
 | 
			
		|||
  AavePools,
 | 
			
		||||
  iParamsPerNetwork,
 | 
			
		||||
  iParamsPerPool,
 | 
			
		||||
  TokenContractId,
 | 
			
		||||
  iMultiPoolsAssets,
 | 
			
		||||
  IReserveParams,
 | 
			
		||||
  ICommonConfiguration,
 | 
			
		||||
  PoolConfiguration,
 | 
			
		||||
} from './types';
 | 
			
		||||
 | 
			
		||||
import {LendingPoolAddressesProvider} from '../types/LendingPoolAddressesProvider';
 | 
			
		||||
import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
 | 
			
		||||
import {LendingPoolAddressesProviderRegistry} from '../types/LendingPoolAddressesProviderRegistry';
 | 
			
		||||
import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator';
 | 
			
		||||
import {readArtifact} from '@nomiclabs/buidler/plugins';
 | 
			
		||||
import {Artifact} from '@nomiclabs/buidler/types';
 | 
			
		||||
import {LendingPool} from '../types/LendingPool';
 | 
			
		||||
import {PriceOracle} from '../types/PriceOracle';
 | 
			
		||||
import {MockAggregator} from '../types/MockAggregator';
 | 
			
		||||
import {LendingRateOracle} from '../types/LendingRateOracle';
 | 
			
		||||
import {DefaultReserveInterestRateStrategy} from '../types/DefaultReserveInterestRateStrategy';
 | 
			
		||||
import {LendingPoolCollateralManager} from '../types/LendingPoolCollateralManager';
 | 
			
		||||
import {InitializableAdminUpgradeabilityProxy} from '../types/InitializableAdminUpgradeabilityProxy';
 | 
			
		||||
import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver';
 | 
			
		||||
import {WalletBalanceProvider} from '../types/WalletBalanceProvider';
 | 
			
		||||
import {AToken} from '../types/AToken';
 | 
			
		||||
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import {Ierc20Detailed} from '../types/Ierc20Detailed';
 | 
			
		||||
import {StableDebtToken} from '../types/StableDebtToken';
 | 
			
		||||
import {VariableDebtToken} from '../types/VariableDebtToken';
 | 
			
		||||
import {MockContract} from 'ethereum-waffle';
 | 
			
		||||
import {getReservesConfigByPool} from './configuration';
 | 
			
		||||
import {verifyContract} from './etherscan-verification';
 | 
			
		||||
 | 
			
		||||
const {
 | 
			
		||||
  ProtocolGlobalParams: {UsdAddress},
 | 
			
		||||
} = CommonsConfig;
 | 
			
		||||
import {getIErc20Detailed} from './contracts-getters';
 | 
			
		||||
 | 
			
		||||
export type MockTokenMap = {[symbol: string]: MintableERC20};
 | 
			
		||||
import {ZERO_ADDRESS} from './constants';
 | 
			
		||||
import {MockSwapAdapter} from '../types/MockSwapAdapter';
 | 
			
		||||
import {signTypedData_v4, TypedData} from 'eth-sig-util';
 | 
			
		||||
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
 | 
			
		||||
import {SignerWithAddress} from '../test/helpers/make-suite';
 | 
			
		||||
 | 
			
		||||
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
 | 
			
		||||
  const currentNetwork = BRE.network.name;
 | 
			
		||||
| 
						 | 
				
			
			@ -106,465 +73,25 @@ export const deployContract = async <ContractType extends Contract>(
 | 
			
		|||
  return contract;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const withSaveAndVerify = async <ContractType extends Contract>(
 | 
			
		||||
  instance: ContractType,
 | 
			
		||||
  id: string,
 | 
			
		||||
  args: (string | string[])[],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
): Promise<ContractType> => {
 | 
			
		||||
  await registerContractInJsonDb(id, instance);
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(id, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getContract = async <ContractType extends Contract>(
 | 
			
		||||
  contractName: string,
 | 
			
		||||
  address: string
 | 
			
		||||
): Promise<ContractType> => (await BRE.ethers.getContractAt(contractName, address)) as ContractType;
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolAddressesProvider = async (verify?: boolean) => {
 | 
			
		||||
  const instance = await deployContract<LendingPoolAddressesProvider>(
 | 
			
		||||
    eContractid.LendingPoolAddressesProvider,
 | 
			
		||||
    []
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.LendingPoolAddressesProvider, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolAddressesProviderRegistry = async (verify?: boolean) => {
 | 
			
		||||
  const instance = await deployContract<LendingPoolAddressesProviderRegistry>(
 | 
			
		||||
    eContractid.LendingPoolAddressesProviderRegistry,
 | 
			
		||||
    []
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.LendingPoolAddressesProviderRegistry, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolConfigurator = async (verify?: boolean) => {
 | 
			
		||||
  const instance = await deployContract<LendingPoolConfigurator>(
 | 
			
		||||
    eContractid.LendingPoolConfigurator,
 | 
			
		||||
    []
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.LendingPoolConfigurator, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const deployLibrary = async (libraryId: eContractid) => {
 | 
			
		||||
  const factory = await BRE.ethers.getContractFactory(libraryId);
 | 
			
		||||
  const library = await factory.deploy();
 | 
			
		||||
  await library.deployed();
 | 
			
		||||
 | 
			
		||||
  return library;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const linkLibrariesToArtifact = async (artifact: Artifact) => {
 | 
			
		||||
  const reserveLogic = await deployLibrary(eContractid.ReserveLogic);
 | 
			
		||||
 | 
			
		||||
  const genericLogicArtifact = await readArtifact(
 | 
			
		||||
    BRE.config.paths.artifacts,
 | 
			
		||||
    eContractid.GenericLogic
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const linkedGenericLogicByteCode = linkBytecode(genericLogicArtifact, {
 | 
			
		||||
    [eContractid.ReserveLogic]: reserveLogic.address,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const genericLogicFactory = await BRE.ethers.getContractFactory(
 | 
			
		||||
    genericLogicArtifact.abi,
 | 
			
		||||
    linkedGenericLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const genericLogic = await (await genericLogicFactory.deploy()).deployed();
 | 
			
		||||
 | 
			
		||||
  const validationLogicArtifact = await readArtifact(
 | 
			
		||||
    BRE.config.paths.artifacts,
 | 
			
		||||
    eContractid.ValidationLogic
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const linkedValidationLogicByteCode = linkBytecode(validationLogicArtifact, {
 | 
			
		||||
    [eContractid.ReserveLogic]: reserveLogic.address,
 | 
			
		||||
    [eContractid.GenericLogic]: genericLogic.address,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const validationLogicFactory = await BRE.ethers.getContractFactory(
 | 
			
		||||
    validationLogicArtifact.abi,
 | 
			
		||||
    linkedValidationLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const validationLogic = await (await validationLogicFactory.deploy()).deployed();
 | 
			
		||||
 | 
			
		||||
  const linkedBytecode = linkBytecode(artifact, {
 | 
			
		||||
    [eContractid.ReserveLogic]: reserveLogic.address,
 | 
			
		||||
    [eContractid.GenericLogic]: genericLogic.address,
 | 
			
		||||
    [eContractid.ValidationLogic]: validationLogic.address,
 | 
			
		||||
  });
 | 
			
		||||
  const factory = await BRE.ethers.getContractFactory(artifact.abi, linkedBytecode);
 | 
			
		||||
 | 
			
		||||
  return factory;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployLendingPool = async (verify?: boolean) => {
 | 
			
		||||
  const lendingPoolArtifact = await readArtifact(
 | 
			
		||||
    BRE.config.paths.artifacts,
 | 
			
		||||
    eContractid.LendingPool
 | 
			
		||||
  );
 | 
			
		||||
  const factory = await linkLibrariesToArtifact(lendingPoolArtifact);
 | 
			
		||||
  const lendingPool = await factory.deploy();
 | 
			
		||||
  const instance = (await lendingPool.deployed()) as LendingPool;
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.LendingPool, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployPriceOracle = async (verify?: boolean) => {
 | 
			
		||||
  const instance = await deployContract<PriceOracle>(eContractid.PriceOracle, []);
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.PriceOracle, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployLendingRateOracle = async (verify?: boolean) => {
 | 
			
		||||
  const instance = await deployContract<LendingRateOracle>(eContractid.LendingRateOracle, []);
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.LendingRateOracle, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify?: boolean) => {
 | 
			
		||||
  const args = [price];
 | 
			
		||||
  const instance = await deployContract<MockAggregator>(eContractid.MockAggregator, args);
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.MockAggregator, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployChainlinkProxyPriceProvider = async (
 | 
			
		||||
  [assetsAddresses, sourcesAddresses, fallbackOracleAddress]: [
 | 
			
		||||
    tEthereumAddress[],
 | 
			
		||||
    tEthereumAddress[],
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const args = [assetsAddresses, sourcesAddresses, fallbackOracleAddress];
 | 
			
		||||
  const instance = await deployContract<MockAggregator>(
 | 
			
		||||
    eContractid.ChainlinkProxyPriceProvider,
 | 
			
		||||
    args
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.MockAggregator, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getChainlingProxyPriceProvider = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await getContract<MockAggregator>(
 | 
			
		||||
    eContractid.ChainlinkProxyPriceProvider,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.ChainlinkProxyPriceProvider}.${BRE.network.name}`).value())
 | 
			
		||||
        .address
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployLendingPoolCollateralManager = async (verify?: boolean) => {
 | 
			
		||||
  const collateralManagerArtifact = await readArtifact(
 | 
			
		||||
    BRE.config.paths.artifacts,
 | 
			
		||||
    eContractid.LendingPoolCollateralManager
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const factory = await linkLibrariesToArtifact(collateralManagerArtifact);
 | 
			
		||||
  const args: string[] = [];
 | 
			
		||||
  const collateralManager = await factory.deploy(args);
 | 
			
		||||
  const instance = (await collateralManager.deployed()) as LendingPoolCollateralManager;
 | 
			
		||||
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.LendingPoolCollateralManager, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployInitializableAdminUpgradeabilityProxy = async (verify?: boolean) => {
 | 
			
		||||
  const instance = await deployContract<InitializableAdminUpgradeabilityProxy>(
 | 
			
		||||
    eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
    []
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.InitializableAdminUpgradeabilityProxy, instance.address, []);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployMockFlashLoanReceiver = async (
 | 
			
		||||
  addressesProvider: tEthereumAddress,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const args = [addressesProvider];
 | 
			
		||||
  const instance = await deployContract<MockFlashLoanReceiver>(
 | 
			
		||||
    eContractid.MockFlashLoanReceiver,
 | 
			
		||||
    args
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.MockFlashLoanReceiver, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployWalletBalancerProvider = async (
 | 
			
		||||
  addressesProvider: tEthereumAddress,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const args = [addressesProvider];
 | 
			
		||||
  const instance = await deployContract<WalletBalanceProvider>(
 | 
			
		||||
    eContractid.WalletBalanceProvider,
 | 
			
		||||
    args
 | 
			
		||||
  );
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.WalletBalanceProvider, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
export const deployMockSwapAdapter = async (addressesProvider: tEthereumAddress) =>
 | 
			
		||||
  await deployContract<MockSwapAdapter>(eContractid.MockSwapAdapter, [addressesProvider]);
 | 
			
		||||
 | 
			
		||||
export const deployAaveProtocolTestHelpers = async (
 | 
			
		||||
  addressesProvider: tEthereumAddress,
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const args = [addressesProvider];
 | 
			
		||||
  const instance = await deployContract<AaveProtocolTestHelpers>(
 | 
			
		||||
    eContractid.AaveProtocolTestHelpers,
 | 
			
		||||
    args
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(eContractid.AaveProtocolTestHelpers, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployMintableERC20 = async ([name, symbol, decimals]: [string, string, number]) =>
 | 
			
		||||
  await deployContract<MintableERC20>(eContractid.MintableERC20, [name, symbol, decimals]);
 | 
			
		||||
 | 
			
		||||
export const deployDefaultReserveInterestRateStrategy = async (
 | 
			
		||||
  [
 | 
			
		||||
    addressesProvider,
 | 
			
		||||
    baseVariableBorrowRate,
 | 
			
		||||
    variableSlope1,
 | 
			
		||||
    variableSlope2,
 | 
			
		||||
    stableSlope1,
 | 
			
		||||
    stableSlope2,
 | 
			
		||||
  ]: [tEthereumAddress, string, string, string, string, string],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const id = eContractid.DefaultReserveInterestRateStrategy;
 | 
			
		||||
  const args = [
 | 
			
		||||
    addressesProvider,
 | 
			
		||||
    baseVariableBorrowRate,
 | 
			
		||||
    variableSlope1,
 | 
			
		||||
    variableSlope2,
 | 
			
		||||
    stableSlope1,
 | 
			
		||||
    stableSlope2,
 | 
			
		||||
  ];
 | 
			
		||||
  const instance = await deployContract<DefaultReserveInterestRateStrategy>(id, args);
 | 
			
		||||
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(id, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployStableDebtToken = async (
 | 
			
		||||
  [name, symbol, underlyingAsset, poolAddress, incentivesController]: [
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const id = eContractid.StableDebtToken;
 | 
			
		||||
  const args = [poolAddress, underlyingAsset, name, symbol, incentivesController];
 | 
			
		||||
  const instance = await deployContract<StableDebtToken>(id, args);
 | 
			
		||||
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(id, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployVariableDebtToken = async (
 | 
			
		||||
  [name, symbol, underlyingAsset, poolAddress, incentivesController]: [
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const id = eContractid.VariableDebtToken;
 | 
			
		||||
  const args = [poolAddress, underlyingAsset, name, symbol, incentivesController];
 | 
			
		||||
  const instance = await deployContract<VariableDebtToken>(id, args);
 | 
			
		||||
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(id, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployGenericAToken = async (
 | 
			
		||||
  [poolAddress, underlyingAssetAddress, name, symbol, incentivesController]: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    tEthereumAddress
 | 
			
		||||
  ],
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const id = eContractid.AToken;
 | 
			
		||||
  const args = [
 | 
			
		||||
    poolAddress,
 | 
			
		||||
    underlyingAssetAddress,
 | 
			
		||||
    ZERO_ADDRESS,
 | 
			
		||||
    name,
 | 
			
		||||
    symbol,
 | 
			
		||||
    incentivesController,
 | 
			
		||||
  ];
 | 
			
		||||
  const instance = await deployContract<AToken>(id, args);
 | 
			
		||||
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(id, instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<LendingPoolAddressesProvider>(
 | 
			
		||||
    eContractid.LendingPoolAddressesProvider,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${BRE.network.name}`).value())
 | 
			
		||||
        .address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<LendingPoolConfigurator>(
 | 
			
		||||
    eContractid.LendingPoolConfigurator,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingPoolConfigurator}.${BRE.network.name}`).value())
 | 
			
		||||
        .address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingPool = async (address?: tEthereumAddress) => {
 | 
			
		||||
  const lendingPoolArtifact = await readArtifact(
 | 
			
		||||
    BRE.config.paths.artifacts,
 | 
			
		||||
    eContractid.LendingPool
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const factory = await linkLibrariesToArtifact(lendingPoolArtifact);
 | 
			
		||||
 | 
			
		||||
  return <LendingPool>(
 | 
			
		||||
    await factory.attach(
 | 
			
		||||
      address ||
 | 
			
		||||
        (await getDb().get(`${eContractid.LendingPool}.${BRE.network.name}`).value()).address
 | 
			
		||||
    )
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getPriceOracle = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<PriceOracle>(
 | 
			
		||||
    eContractid.PriceOracle,
 | 
			
		||||
    address || (await getDb().get(`${eContractid.PriceOracle}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getAToken = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<AToken>(
 | 
			
		||||
    eContractid.AToken,
 | 
			
		||||
    address || (await getDb().get(`${eContractid.AToken}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getStableDebtToken = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<AToken>(
 | 
			
		||||
    eContractid.StableDebtToken,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.StableDebtToken}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getVariableDebtToken = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<AToken>(
 | 
			
		||||
    eContractid.VariableDebtToken,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.VariableDebtToken}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getMintableErc20 = async (address: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<MintableERC20>(
 | 
			
		||||
    eContractid.MintableERC20,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.MintableERC20}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getIErc20Detailed = async (address: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<Ierc20Detailed>(
 | 
			
		||||
    eContractid.IERC20Detailed,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.IERC20Detailed}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getAaveProtocolTestHelpers = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<AaveProtocolTestHelpers>(
 | 
			
		||||
    eContractid.AaveProtocolTestHelpers,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.AaveProtocolTestHelpers}.${BRE.network.name}`).value())
 | 
			
		||||
        .address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getInterestRateStrategy = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<DefaultReserveInterestRateStrategy>(
 | 
			
		||||
    eContractid.DefaultReserveInterestRateStrategy,
 | 
			
		||||
    address ||
 | 
			
		||||
      (
 | 
			
		||||
        await getDb()
 | 
			
		||||
          .get(`${eContractid.DefaultReserveInterestRateStrategy}.${BRE.network.name}`)
 | 
			
		||||
          .value()
 | 
			
		||||
      ).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<MockFlashLoanReceiver>(
 | 
			
		||||
    eContractid.MockFlashLoanReceiver,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.MockFlashLoanReceiver}.${BRE.network.name}`).value())
 | 
			
		||||
        .address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getMockSwapAdapter = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<MockSwapAdapter>(
 | 
			
		||||
    eContractid.MockSwapAdapter,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.MockSwapAdapter}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingRateOracle = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<LendingRateOracle>(
 | 
			
		||||
    eContractid.LendingRateOracle,
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingRateOracle}.${BRE.network.name}`).value()).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const linkBytecode = (artifact: Artifact, libraries: any) => {
 | 
			
		||||
export const linkBytecode = (artifact: Artifact, libraries: any) => {
 | 
			
		||||
  let bytecode = artifact.bytecode;
 | 
			
		||||
 | 
			
		||||
  for (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -633,255 +160,6 @@ export const convertToCurrencyUnits = async (tokenAddress: string, amount: strin
 | 
			
		|||
  return amountInCurrencyUnits.toFixed();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployAllMockTokens = async (verify?: boolean) => {
 | 
			
		||||
  const tokens: {[symbol: string]: MockContract | MintableERC20} = {};
 | 
			
		||||
 | 
			
		||||
  const protoConfigData = getReservesConfigByPool(AavePools.proto);
 | 
			
		||||
  const secondaryConfigData = getReservesConfigByPool(AavePools.secondary);
 | 
			
		||||
 | 
			
		||||
  for (const tokenSymbol of Object.keys(TokenContractId)) {
 | 
			
		||||
    let decimals = 18;
 | 
			
		||||
 | 
			
		||||
    let configData = (<any>protoConfigData)[tokenSymbol];
 | 
			
		||||
 | 
			
		||||
    if (!configData) {
 | 
			
		||||
      configData = (<any>secondaryConfigData)[tokenSymbol];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!configData) {
 | 
			
		||||
      decimals = 18;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tokens[tokenSymbol] = await deployMintableERC20([
 | 
			
		||||
      tokenSymbol,
 | 
			
		||||
      tokenSymbol,
 | 
			
		||||
      configData ? configData.reserveDecimals : 18,
 | 
			
		||||
    ]);
 | 
			
		||||
    await registerContractInJsonDb(tokenSymbol.toUpperCase(), tokens[tokenSymbol]);
 | 
			
		||||
 | 
			
		||||
    if (verify) {
 | 
			
		||||
      await verifyContract(eContractid.MintableERC20, tokens[tokenSymbol].address, []);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const deployMockTokens = async (config: PoolConfiguration, verify?: boolean) => {
 | 
			
		||||
  const tokens: {[symbol: string]: MockContract | MintableERC20} = {};
 | 
			
		||||
  const defaultDecimals = 18;
 | 
			
		||||
 | 
			
		||||
  const configData = config.ReservesConfig;
 | 
			
		||||
 | 
			
		||||
  for (const tokenSymbol of Object.keys(config.ReserveSymbols)) {
 | 
			
		||||
    tokens[tokenSymbol] = await deployMintableERC20([
 | 
			
		||||
      tokenSymbol,
 | 
			
		||||
      tokenSymbol,
 | 
			
		||||
      Number(configData[tokenSymbol as keyof iMultiPoolsAssets<IReserveParams>].reserveDecimals) ||
 | 
			
		||||
        defaultDecimals,
 | 
			
		||||
    ]);
 | 
			
		||||
    await registerContractInJsonDb(tokenSymbol.toUpperCase(), tokens[tokenSymbol]);
 | 
			
		||||
 | 
			
		||||
    if (verify) {
 | 
			
		||||
      await verifyContract(eContractid.MintableERC20, tokens[tokenSymbol].address, []);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getMockedTokens = async (config: PoolConfiguration) => {
 | 
			
		||||
  const tokenSymbols = config.ReserveSymbols;
 | 
			
		||||
  const db = getDb();
 | 
			
		||||
  const tokens: MockTokenMap = await tokenSymbols.reduce<Promise<MockTokenMap>>(
 | 
			
		||||
    async (acc, tokenSymbol) => {
 | 
			
		||||
      const accumulator = await acc;
 | 
			
		||||
      const address = db.get(`${tokenSymbol.toUpperCase()}.${BRE.network.name}`).value().address;
 | 
			
		||||
      accumulator[tokenSymbol] = await getContract<MintableERC20>(
 | 
			
		||||
        eContractid.MintableERC20,
 | 
			
		||||
        address
 | 
			
		||||
      );
 | 
			
		||||
      return Promise.resolve(acc);
 | 
			
		||||
    },
 | 
			
		||||
    Promise.resolve({})
 | 
			
		||||
  );
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getAllMockedTokens = async () => {
 | 
			
		||||
  const db = getDb();
 | 
			
		||||
  const tokens: MockTokenMap = await Object.keys(TokenContractId).reduce<Promise<MockTokenMap>>(
 | 
			
		||||
    async (acc, tokenSymbol) => {
 | 
			
		||||
      const accumulator = await acc;
 | 
			
		||||
      const address = db.get(`${tokenSymbol.toUpperCase()}.${BRE.network.name}`).value().address;
 | 
			
		||||
      accumulator[tokenSymbol] = await getContract<MintableERC20>(
 | 
			
		||||
        eContractid.MintableERC20,
 | 
			
		||||
        address
 | 
			
		||||
      );
 | 
			
		||||
      return Promise.resolve(acc);
 | 
			
		||||
    },
 | 
			
		||||
    Promise.resolve({})
 | 
			
		||||
  );
 | 
			
		||||
  return tokens;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getPairsTokenAggregator = (
 | 
			
		||||
  allAssetsAddresses: {
 | 
			
		||||
    [tokenSymbol: string]: tEthereumAddress;
 | 
			
		||||
  },
 | 
			
		||||
  aggregatorsAddresses: {[tokenSymbol: string]: tEthereumAddress}
 | 
			
		||||
): [string[], string[]] => {
 | 
			
		||||
  const {ETH, USD, WETH, ...assetsAddressesWithoutEth} = allAssetsAddresses;
 | 
			
		||||
 | 
			
		||||
  const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => {
 | 
			
		||||
    if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') {
 | 
			
		||||
      const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex(
 | 
			
		||||
        (value) => value === tokenSymbol
 | 
			
		||||
      );
 | 
			
		||||
      const [, aggregatorAddress] = (Object.entries(aggregatorsAddresses) as [
 | 
			
		||||
        string,
 | 
			
		||||
        tEthereumAddress
 | 
			
		||||
      ][])[aggregatorAddressIndex];
 | 
			
		||||
      return [tokenAddress, aggregatorAddress];
 | 
			
		||||
    }
 | 
			
		||||
  }) as [string, string][];
 | 
			
		||||
 | 
			
		||||
  const mappedPairs = pairs.map(([asset]) => asset);
 | 
			
		||||
  const mappedAggregators = pairs.map(([, source]) => source);
 | 
			
		||||
 | 
			
		||||
  return [mappedPairs, mappedAggregators];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const initReserves = async (
 | 
			
		||||
  reservesParams: iMultiPoolsAssets<IReserveParams>,
 | 
			
		||||
  tokenAddresses: {[symbol: string]: tEthereumAddress},
 | 
			
		||||
  lendingPoolAddressesProvider: LendingPoolAddressesProvider,
 | 
			
		||||
  lendingPool: LendingPool,
 | 
			
		||||
  helpers: AaveProtocolTestHelpers,
 | 
			
		||||
  lendingPoolConfigurator: LendingPoolConfigurator,
 | 
			
		||||
  aavePool: AavePools,
 | 
			
		||||
  incentivesController: tEthereumAddress,
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
 | 
			
		||||
    console.log(`Invalid Aave pool ${aavePool}`);
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  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
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    const {isActive: reserveInitialized} = await helpers.getReserveConfigurationData(tokenAddress);
 | 
			
		||||
 | 
			
		||||
    if (reserveInitialized) {
 | 
			
		||||
      console.log(`Reserve ${assetSymbol} is already active, skipping configuration`);
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      const reserveParamIndex = Object.keys(reservesParams).findIndex(
 | 
			
		||||
        (value) => value === assetSymbol
 | 
			
		||||
      );
 | 
			
		||||
      const [
 | 
			
		||||
        ,
 | 
			
		||||
        {
 | 
			
		||||
          baseVariableBorrowRate,
 | 
			
		||||
          variableRateSlope1,
 | 
			
		||||
          variableRateSlope2,
 | 
			
		||||
          stableRateSlope1,
 | 
			
		||||
          stableRateSlope2,
 | 
			
		||||
        },
 | 
			
		||||
      ] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
 | 
			
		||||
      console.log('deploy def reserve');
 | 
			
		||||
      const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
 | 
			
		||||
        [
 | 
			
		||||
          lendingPoolAddressesProvider.address,
 | 
			
		||||
          baseVariableBorrowRate,
 | 
			
		||||
          variableRateSlope1,
 | 
			
		||||
          variableRateSlope2,
 | 
			
		||||
          stableRateSlope1,
 | 
			
		||||
          stableRateSlope2,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log('deploy stable deb totken ', assetSymbol);
 | 
			
		||||
      const stableDebtToken = await deployStableDebtToken(
 | 
			
		||||
        [
 | 
			
		||||
          `Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          `stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          lendingPool.address,
 | 
			
		||||
          incentivesController,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log('deploy var deb totken ', assetSymbol);
 | 
			
		||||
      const variableDebtToken = await deployVariableDebtToken(
 | 
			
		||||
        [
 | 
			
		||||
          `Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          `variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          lendingPool.address,
 | 
			
		||||
          incentivesController,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log('deploy a token ', assetSymbol);
 | 
			
		||||
      const aToken = await deployGenericAToken(
 | 
			
		||||
        [
 | 
			
		||||
          lendingPool.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          `Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          `a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          incentivesController,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      if (process.env.POOL === AavePools.secondary) {
 | 
			
		||||
        if (assetSymbol.search('UNI') === -1) {
 | 
			
		||||
          assetSymbol = `Uni${assetSymbol}`;
 | 
			
		||||
        } else {
 | 
			
		||||
          assetSymbol = assetSymbol.replace(/_/g, '').replace('UNI', 'Uni');
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      console.log('init reserve currency ', assetSymbol);
 | 
			
		||||
      await lendingPoolConfigurator.initReserve(
 | 
			
		||||
        tokenAddress,
 | 
			
		||||
        aToken.address,
 | 
			
		||||
        stableDebtToken.address,
 | 
			
		||||
        variableDebtToken.address,
 | 
			
		||||
        reserveDecimals,
 | 
			
		||||
        rateStrategyContract.address
 | 
			
		||||
      );
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      console.log(`Reserve initialization for ${assetSymbol} failed with error ${e}. Skipped.`);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await getContract<LendingPoolAddressesProviderRegistry>(
 | 
			
		||||
    eContractid.LendingPoolAddressesProviderRegistry,
 | 
			
		||||
    address ||
 | 
			
		||||
      (
 | 
			
		||||
        await getDb()
 | 
			
		||||
          .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${BRE.network.name}`)
 | 
			
		||||
          .value()
 | 
			
		||||
      ).address
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const buildPermitParams = (
 | 
			
		||||
  chainId: number,
 | 
			
		||||
  token: tEthereumAddress,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,15 @@
 | 
			
		|||
import {iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types';
 | 
			
		||||
import {AavePools, iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types';
 | 
			
		||||
import {LendingPool} from '../types/LendingPool';
 | 
			
		||||
import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator';
 | 
			
		||||
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
 | 
			
		||||
import {LendingPoolAddressesProvider} from '../types/LendingPoolAddressesProvider';
 | 
			
		||||
import {
 | 
			
		||||
  deployDefaultReserveInterestRateStrategy,
 | 
			
		||||
  deployStableDebtToken,
 | 
			
		||||
  deployVariableDebtToken,
 | 
			
		||||
  deployGenericAToken,
 | 
			
		||||
} from './contracts-deployments';
 | 
			
		||||
import {getEthersSigners} from './contracts-helpers';
 | 
			
		||||
 | 
			
		||||
export const enableReservesToBorrow = async (
 | 
			
		||||
  reservesParams: iMultiPoolsAssets<IReserveParams>,
 | 
			
		||||
| 
						 | 
				
			
			@ -79,3 +87,123 @@ export const enableReservesAsCollateral = async (
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const initReserves = async (
 | 
			
		||||
  reservesParams: iMultiPoolsAssets<IReserveParams>,
 | 
			
		||||
  tokenAddresses: {[symbol: string]: tEthereumAddress},
 | 
			
		||||
  lendingPoolAddressesProvider: LendingPoolAddressesProvider,
 | 
			
		||||
  lendingPool: LendingPool,
 | 
			
		||||
  helpers: AaveProtocolTestHelpers,
 | 
			
		||||
  lendingPoolConfigurator: LendingPoolConfigurator,
 | 
			
		||||
  aavePool: AavePools,
 | 
			
		||||
  incentivesController: tEthereumAddress,
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
 | 
			
		||||
    console.log(`Invalid Aave pool ${aavePool}`);
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  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
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    const {isActive: reserveInitialized} = await helpers.getReserveConfigurationData(tokenAddress);
 | 
			
		||||
 | 
			
		||||
    if (reserveInitialized) {
 | 
			
		||||
      console.log(`Reserve ${assetSymbol} is already active, skipping configuration`);
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      const reserveParamIndex = Object.keys(reservesParams).findIndex(
 | 
			
		||||
        (value) => value === assetSymbol
 | 
			
		||||
      );
 | 
			
		||||
      const [
 | 
			
		||||
        ,
 | 
			
		||||
        {
 | 
			
		||||
          baseVariableBorrowRate,
 | 
			
		||||
          variableRateSlope1,
 | 
			
		||||
          variableRateSlope2,
 | 
			
		||||
          stableRateSlope1,
 | 
			
		||||
          stableRateSlope2,
 | 
			
		||||
        },
 | 
			
		||||
      ] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
 | 
			
		||||
      console.log('- Deploy def reserve');
 | 
			
		||||
      const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
 | 
			
		||||
        [
 | 
			
		||||
          lendingPoolAddressesProvider.address,
 | 
			
		||||
          baseVariableBorrowRate,
 | 
			
		||||
          variableRateSlope1,
 | 
			
		||||
          variableRateSlope2,
 | 
			
		||||
          stableRateSlope1,
 | 
			
		||||
          stableRateSlope2,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log('- Deploy stable deb totken ', assetSymbol);
 | 
			
		||||
      const stableDebtToken = await deployStableDebtToken(
 | 
			
		||||
        [
 | 
			
		||||
          lendingPool.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          `Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          `stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          incentivesController,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log('- Deploy var deb totken ', assetSymbol);
 | 
			
		||||
      const variableDebtToken = await deployVariableDebtToken(
 | 
			
		||||
        [
 | 
			
		||||
          lendingPool.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          `Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          `variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          incentivesController,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log('- Deploy a token ', assetSymbol);
 | 
			
		||||
      const aToken = await deployGenericAToken(
 | 
			
		||||
        [
 | 
			
		||||
          lendingPool.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          `Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          `a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
 | 
			
		||||
          incentivesController,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      if (process.env.POOL === AavePools.secondary) {
 | 
			
		||||
        if (assetSymbol.search('UNI') === -1) {
 | 
			
		||||
          assetSymbol = `Uni${assetSymbol}`;
 | 
			
		||||
        } else {
 | 
			
		||||
          assetSymbol = assetSymbol.replace(/_/g, '').replace('UNI', 'Uni');
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      console.log('- init reserve currency ', assetSymbol);
 | 
			
		||||
      await lendingPoolConfigurator.initReserve(
 | 
			
		||||
        tokenAddress,
 | 
			
		||||
        aToken.address,
 | 
			
		||||
        stableDebtToken.address,
 | 
			
		||||
        variableDebtToken.address,
 | 
			
		||||
        reserveDecimals,
 | 
			
		||||
        rateStrategyContract.address
 | 
			
		||||
      );
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      console.log(`Reserve initialization for ${assetSymbol} failed with error ${e}. Skipped.`);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,8 @@ import FileSync from 'lowdb/adapters/FileSync';
 | 
			
		|||
import {WAD} from './constants';
 | 
			
		||||
import {Wallet, ContractTransaction} from 'ethers';
 | 
			
		||||
import {BuidlerRuntimeEnvironment} from '@nomiclabs/buidler/types';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
import fs from 'fs';
 | 
			
		||||
 | 
			
		||||
export const toWad = (value: string | number) => new BigNumber(value).times(WAD).toFixed();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ import {
 | 
			
		|||
import {LendingRateOracle} from '../types/LendingRateOracle';
 | 
			
		||||
import {PriceOracle} from '../types/PriceOracle';
 | 
			
		||||
import {MockAggregator} from '../types/MockAggregator';
 | 
			
		||||
import {deployMockAggregator, getContract, MockTokenMap} from './contracts-helpers';
 | 
			
		||||
import {deployMockAggregator} from './contracts-deployments';
 | 
			
		||||
import {waitForTx} from './misc-utils';
 | 
			
		||||
import {verifyContract} from './etherscan-verification';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {deployAllMockTokens} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {deployAllMockTokens} from '../../helpers/contracts-deployments';
 | 
			
		||||
task('dev:deploy-mock-tokens', 'Deploy mock tokens for dev enviroment')
 | 
			
		||||
  .addOptionalParam('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .setAction(async ({verify}, localBRE) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ import {task} from '@nomiclabs/buidler/config';
 | 
			
		|||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
  deployLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
 | 
			
		||||
task(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,16 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPool,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  deployLendingPoolConfigurator,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {eContractid} from '../../helpers/types';
 | 
			
		||||
import {waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
 | 
			
		||||
 | 
			
		||||
task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
 | 
			
		||||
  .addOptionalParam('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,9 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  deployPriceOracle,
 | 
			
		||||
  getMockedTokens,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
  deployChainlinkProxyPriceProvider,
 | 
			
		||||
  deployLendingRateOracle,
 | 
			
		||||
  getAllMockedTokens,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  setInitialAssetPricesInOracle,
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +14,11 @@ import {ICommonConfiguration, iAssetBase, TokenContractId} from '../../helpers/t
 | 
			
		|||
import {waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
import {getAllAggregatorsAddresses, getAllTokenAddresses} from '../../helpers/mock-helpers';
 | 
			
		||||
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
 | 
			
		||||
import {
 | 
			
		||||
  getAllMockedTokens,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
 | 
			
		||||
  .addOptionalParam('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,23 +1,28 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  initReserves,
 | 
			
		||||
  deployLendingPoolCollateralManager,
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  deployMockFlashLoanReceiver,
 | 
			
		||||
  deployWalletBalancerProvider,
 | 
			
		||||
  deployAaveProtocolTestHelpers,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getAllMockedTokens,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {getReservesConfigByPool} from '../../helpers/configuration';
 | 
			
		||||
 | 
			
		||||
import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
 | 
			
		||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
 | 
			
		||||
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  enableReservesToBorrow,
 | 
			
		||||
  enableReservesAsCollateral,
 | 
			
		||||
  initReserves,
 | 
			
		||||
} from '../../helpers/init-helpers';
 | 
			
		||||
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
 | 
			
		||||
import {ZERO_ADDRESS} from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  getAllMockedTokens,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
 | 
			
		||||
 | 
			
		||||
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		||||
  .addOptionalParam('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,13 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
  deployLendingPoolAddressesProviderRegistry,
 | 
			
		||||
  getParamPerNetwork,
 | 
			
		||||
  getLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
import {ConfigNames, loadPoolConfig, getGenesisAaveAdmin} from '../../helpers/configuration';
 | 
			
		||||
import {eEthereumNetwork} from '../../helpers/types';
 | 
			
		||||
import {getLendingPoolAddressesProviderRegistry} from '../../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
task(
 | 
			
		||||
  'full:deploy-address-provider',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,16 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPool,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  deployLendingPoolConfigurator,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {eContractid} from '../../helpers/types';
 | 
			
		||||
import {waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,17 +1,18 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
  deployChainlinkProxyPriceProvider,
 | 
			
		||||
  deployLendingRateOracle,
 | 
			
		||||
  getParamPerNetwork,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {setInitialMarketRatesInRatesOracle} from '../../helpers/oracles-helpers';
 | 
			
		||||
import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types';
 | 
			
		||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
 | 
			
		||||
import {ConfigNames, loadPoolConfig} from '../../helpers/configuration';
 | 
			
		||||
import {exit} from 'process';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,22 +1,25 @@
 | 
			
		|||
import {task} from '@nomiclabs/buidler/config';
 | 
			
		||||
import {getParamPerNetwork} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  initReserves,
 | 
			
		||||
  deployLendingPoolCollateralManager,
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  deployWalletBalancerProvider,
 | 
			
		||||
  deployAaveProtocolTestHelpers,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getParamPerNetwork,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
 | 
			
		||||
 | 
			
		||||
import {AavePools, eContractid, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
 | 
			
		||||
import {AavePools, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
 | 
			
		||||
import {waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  enableReservesToBorrow,
 | 
			
		||||
  enableReservesAsCollateral,
 | 
			
		||||
  initReserves,
 | 
			
		||||
} from '../../helpers/init-helpers';
 | 
			
		||||
import {ZERO_ADDRESS} from '../../helpers/constants';
 | 
			
		||||
import {exit} from 'process';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,10 @@
 | 
			
		|||
import rawBRE from '@nomiclabs/buidler';
 | 
			
		||||
import {MockContract} from 'ethereum-waffle';
 | 
			
		||||
import {
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  registerContractInJsonDb,
 | 
			
		||||
} from '../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
  deployMintableERC20,
 | 
			
		||||
| 
						 | 
				
			
			@ -7,27 +12,19 @@ import {
 | 
			
		|||
  deployLendingPoolConfigurator,
 | 
			
		||||
  deployLendingPool,
 | 
			
		||||
  deployPriceOracle,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  deployChainlinkProxyPriceProvider,
 | 
			
		||||
  deployLendingPoolCollateralManager,
 | 
			
		||||
  deployMockFlashLoanReceiver,
 | 
			
		||||
  deployWalletBalancerProvider,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  deployAaveProtocolTestHelpers,
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  registerContractInJsonDb,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
  initReserves,
 | 
			
		||||
  deployMockSwapAdapter,
 | 
			
		||||
  deployLendingRateOracle,
 | 
			
		||||
} from '../helpers/contracts-helpers';
 | 
			
		||||
} from '../helpers/contracts-deployments';
 | 
			
		||||
import {Signer} from 'ethers';
 | 
			
		||||
import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types';
 | 
			
		||||
import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
 | 
			
		||||
import {getReservesConfigByPool} from '../helpers/configuration';
 | 
			
		||||
import {initializeMakeSuite} from './helpers/make-suite';
 | 
			
		||||
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  setInitialAssetPricesInOracle,
 | 
			
		||||
| 
						 | 
				
			
			@ -35,9 +32,18 @@ import {
 | 
			
		|||
  deployAllMockAggregators,
 | 
			
		||||
} from '../helpers/oracles-helpers';
 | 
			
		||||
import {waitForTx} from '../helpers/misc-utils';
 | 
			
		||||
import {enableReservesToBorrow, enableReservesAsCollateral} from '../helpers/init-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  enableReservesToBorrow,
 | 
			
		||||
  enableReservesAsCollateral,
 | 
			
		||||
  initReserves,
 | 
			
		||||
} from '../helpers/init-helpers';
 | 
			
		||||
import {AaveConfig} from '../config/aave';
 | 
			
		||||
import {ZERO_ADDRESS} from '../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
} from '../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
 | 
			
		||||
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
 | 
			
		||||
| 
						 | 
				
			
			@ -91,17 +97,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
 | 
			
		||||
  const lendingPoolImpl = await deployLendingPool();
 | 
			
		||||
 | 
			
		||||
  console.log('Deployed lending pool, address:', lendingPoolImpl.address);
 | 
			
		||||
  await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address));
 | 
			
		||||
 | 
			
		||||
  console.log('Added pool to addresses provider');
 | 
			
		||||
 | 
			
		||||
  const address = await addressesProvider.getLendingPool();
 | 
			
		||||
  console.log('Address is ', address);
 | 
			
		||||
  const lendingPoolProxy = await getLendingPool(address);
 | 
			
		||||
 | 
			
		||||
  console.log('implementation set, address:', lendingPoolProxy.address);
 | 
			
		||||
 | 
			
		||||
  await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
 | 
			
		||||
 | 
			
		||||
  const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator();
 | 
			
		||||
| 
						 | 
				
			
			@ -111,6 +111,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
 | 
			
		||||
    await addressesProvider.getLendingPoolConfigurator()
 | 
			
		||||
  );
 | 
			
		||||
  console.log('proxy address', lendingPoolConfiguratorProxy.address);
 | 
			
		||||
  await insertContractAddressInDb(
 | 
			
		||||
    eContractid.LendingPoolConfigurator,
 | 
			
		||||
    lendingPoolConfiguratorProxy.address
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
import {TestEnv, makeSuite} from './helpers/make-suite';
 | 
			
		||||
import {RAY, APPROVAL_AMOUNT_LENDING_POOL, ZERO_ADDRESS} from '../helpers/constants';
 | 
			
		||||
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
 | 
			
		||||
import {ZERO_ADDRESS} from '../helpers/constants';
 | 
			
		||||
import {ProtocolErrors} from '../helpers/types';
 | 
			
		||||
 | 
			
		||||
const {expect} = require('chai');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import {makeSuite, TestEnv} from './helpers/make-suite';
 | 
			
		||||
import {MockSwapAdapter} from '../types/MockSwapAdapter';
 | 
			
		||||
import {getMockSwapAdapter} from '../helpers/contracts-helpers';
 | 
			
		||||
import {getMockSwapAdapter} from '../helpers/contracts-getters';
 | 
			
		||||
import {ProtocolErrors} from '../helpers/types';
 | 
			
		||||
import {ethers} from 'ethers';
 | 
			
		||||
import {APPROVAL_AMOUNT_LENDING_POOL} from '../helpers/constants';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,16 +2,13 @@ import BigNumber from 'bignumber.js';
 | 
			
		|||
 | 
			
		||||
import {TestEnv, makeSuite} from './helpers/make-suite';
 | 
			
		||||
import {APPROVAL_AMOUNT_LENDING_POOL, oneRay} from '../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  convertToCurrencyDecimals,
 | 
			
		||||
  getMockFlashLoanReceiver,
 | 
			
		||||
  getContract,
 | 
			
		||||
} from '../helpers/contracts-helpers';
 | 
			
		||||
import {convertToCurrencyDecimals, getContract} from '../helpers/contracts-helpers';
 | 
			
		||||
import {ethers} from 'ethers';
 | 
			
		||||
import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver';
 | 
			
		||||
import {ProtocolErrors, eContractid} from '../helpers/types';
 | 
			
		||||
import {VariableDebtToken} from '../types/VariableDebtToken';
 | 
			
		||||
import {StableDebtToken} from '../types/StableDebtToken';
 | 
			
		||||
import {getMockFlashLoanReceiver} from '../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
const {expect} = require('chai');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,11 +17,8 @@ import {
 | 
			
		|||
} from './utils/calculations';
 | 
			
		||||
import {getReserveAddressFromSymbol, getReserveData, getUserData} from './utils/helpers';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  convertToCurrencyDecimals,
 | 
			
		||||
  getAToken,
 | 
			
		||||
  getMintableErc20,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {getAToken, getMintableErc20} from '../../helpers/contracts-getters';
 | 
			
		||||
import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants';
 | 
			
		||||
import {SignerWithAddress, TestEnv} from './make-suite';
 | 
			
		||||
import {BRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +28,6 @@ import {ReserveData, UserReserveData} from './utils/interfaces';
 | 
			
		|||
import {ContractReceipt} from 'ethers';
 | 
			
		||||
import {AToken} from '../../types/AToken';
 | 
			
		||||
import {RateMode, tEthereumAddress} from '../../helpers/types';
 | 
			
		||||
import {time} from 'console';
 | 
			
		||||
 | 
			
		||||
const {expect} = chai;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
import {evmRevert, evmSnapshot, BRE} from '../../helpers/misc-utils';
 | 
			
		||||
import {Signer} from 'ethers';
 | 
			
		||||
import {
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getAaveProtocolTestHelpers,
 | 
			
		||||
| 
						 | 
				
			
			@ -11,7 +10,7 @@ import {
 | 
			
		|||
  getPriceOracle,
 | 
			
		||||
  getMockSwapAdapter,
 | 
			
		||||
  getLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import {tEthereumAddress} from '../../helpers/types';
 | 
			
		||||
import {LendingPool} from '../../types/LendingPool';
 | 
			
		||||
import {AaveProtocolTestHelpers} from '../../types/AaveProtocolTestHelpers';
 | 
			
		||||
| 
						 | 
				
			
			@ -27,6 +26,7 @@ import {PriceOracle} from '../../types/PriceOracle';
 | 
			
		|||
import {LendingPoolAddressesProvider} from '../../types/LendingPoolAddressesProvider';
 | 
			
		||||
import {MockSwapAdapter} from '../../types/MockSwapAdapter';
 | 
			
		||||
import {LendingPoolAddressesProviderRegistry} from '../../types/LendingPoolAddressesProviderRegistry';
 | 
			
		||||
import {getEthersSigners} from '../../helpers/contracts-helpers';
 | 
			
		||||
chai.use(bignumberChai());
 | 
			
		||||
chai.use(almostEqual());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ import {
 | 
			
		|||
  MAX_UINT_AMOUNT,
 | 
			
		||||
  OPTIMAL_UTILIZATION_RATE,
 | 
			
		||||
  EXCESS_UTILIZATION_RATE,
 | 
			
		||||
  ZERO_ADDRESS,
 | 
			
		||||
} from '../../../helpers/constants';
 | 
			
		||||
import {IReserveParams, iAavePoolAssets, RateMode, tEthereumAddress} from '../../../helpers/types';
 | 
			
		||||
import './math';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ import {
 | 
			
		|||
  getAToken,
 | 
			
		||||
  getStableDebtToken,
 | 
			
		||||
  getVariableDebtToken,
 | 
			
		||||
} from '../../../helpers/contracts-helpers';
 | 
			
		||||
} from '../../../helpers/contracts-getters';
 | 
			
		||||
import {tEthereumAddress} from '../../../helpers/types';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import {getDb, BRE} from '../../../helpers/misc-utils';
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ export const getReserveData = async (
 | 
			
		|||
  const stableDebtToken = await getStableDebtToken(tokenAddresses.stableDebtTokenAddress);
 | 
			
		||||
  const variableDebtToken = await getVariableDebtToken(tokenAddresses.variableDebtTokenAddress);
 | 
			
		||||
 | 
			
		||||
  const [principalStableDebt] = await stableDebtToken.getSupplyData();
 | 
			
		||||
  const {0: principalStableDebt} = await stableDebtToken.getSupplyData();
 | 
			
		||||
  const totalStableDebtLastUpdated = await stableDebtToken.getTotalSupplyLastUpdated();
 | 
			
		||||
 | 
			
		||||
  const scaledVariableDebt = await variableDebtToken.scaledTotalSupply();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ import {ProtocolErrors} from '../helpers/types';
 | 
			
		|||
import {ethers} from 'ethers';
 | 
			
		||||
import {ZERO_ADDRESS} from '../helpers/constants';
 | 
			
		||||
import {waitForTx} from '../helpers/misc-utils';
 | 
			
		||||
import {deployLendingPool} from '../helpers/contracts-helpers';
 | 
			
		||||
import {deployLendingPool} from '../helpers/contracts-deployments';
 | 
			
		||||
 | 
			
		||||
const {utils} = ethers;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,11 @@
 | 
			
		|||
import {makeSuite, TestEnv} from './helpers/make-suite';
 | 
			
		||||
import {ProtocolErrors, RateMode} from '../helpers/types';
 | 
			
		||||
import {APPROVAL_AMOUNT_LENDING_POOL, oneEther} from '../helpers/constants';
 | 
			
		||||
import {convertToCurrencyDecimals, getMockFlashLoanReceiver} from '../helpers/contracts-helpers';
 | 
			
		||||
import {convertToCurrencyDecimals} from '../helpers/contracts-helpers';
 | 
			
		||||
import {parseEther, parseUnits} from 'ethers/lib/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver';
 | 
			
		||||
import {getMockFlashLoanReceiver} from '../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
const {expect} = require('chai');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,16 +1,12 @@
 | 
			
		|||
import {expect} from 'chai';
 | 
			
		||||
import {makeSuite, TestEnv} from './helpers/make-suite';
 | 
			
		||||
import {ProtocolErrors, eContractid} from '../helpers/types';
 | 
			
		||||
import {
 | 
			
		||||
  deployGenericAToken,
 | 
			
		||||
  getAToken,
 | 
			
		||||
  deployContract,
 | 
			
		||||
  getContract,
 | 
			
		||||
} from '../helpers/contracts-helpers';
 | 
			
		||||
import {deployContract, getContract} from '../helpers/contracts-helpers';
 | 
			
		||||
import {MockAToken} from '../types/MockAToken';
 | 
			
		||||
import {MockStableDebtToken} from '../types/MockStableDebtToken';
 | 
			
		||||
import {MockVariableDebtToken} from '../types/MockVariableDebtToken';
 | 
			
		||||
import {ZERO_ADDRESS} from '../helpers/constants';
 | 
			
		||||
import {getAToken} from '../helpers/contracts-getters';
 | 
			
		||||
 | 
			
		||||
makeSuite('Upgradeability', (testEnv: TestEnv) => {
 | 
			
		||||
  const {CALLER_NOT_AAVE_ADMIN} = ProtocolErrors;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user