mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Merge branch 'master' into feat/uniswap-adapter-flashloan
# Conflicts: # helpers/contracts-helpers.ts # test/helpers/make-suite.ts
This commit is contained in:
		
						commit
						9478381992
					
				|  | @ -179,13 +179,16 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|    * @dev Allows users to borrow a specific amount of the reserve currency, provided that the borrower |    * @dev Allows users to borrow a specific amount of the reserve underlying asset, provided that the borrower | ||||||
|    * already deposited enough collateral. |    * already deposited enough collateral, or he was given enough allowance by a credit delegator on the | ||||||
|  |    * corresponding debt token (StableDebtToken or VariableDebtToken) | ||||||
|    * @param asset the address of the reserve |    * @param asset the address of the reserve | ||||||
|    * @param amount the amount to be borrowed |    * @param amount the amount to be borrowed | ||||||
|    * @param interestRateMode the interest rate mode at which the user wants to borrow. Can be 0 (STABLE) or 1 (VARIABLE) |    * @param interestRateMode the interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable | ||||||
|    * @param referralCode a referral code for integrators |    * @param referralCode a referral code for integrators | ||||||
|    * @param onBehalfOf address of the user who will receive the debt |    * @param onBehalfOf address of the user who will receive the debt. Should be the address of the borrower itself | ||||||
|  |    * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator | ||||||
|  |    * if he has been given credit delegation allowance  | ||||||
|    **/ |    **/ | ||||||
|   function borrow( |   function borrow( | ||||||
|     address asset, |     address asset, | ||||||
|  |  | ||||||
|  | @ -6,13 +6,13 @@ import { | ||||||
|   ICommonConfiguration, |   ICommonConfiguration, | ||||||
|   eEthereumNetwork, |   eEthereumNetwork, | ||||||
| } from './types'; | } from './types'; | ||||||
| import {getParamPerPool} from './contracts-helpers'; | import { getParamPerPool } from './contracts-helpers'; | ||||||
| import AaveConfig from '../markets/aave'; | import AaveConfig from '../markets/aave'; | ||||||
| import {CommonsConfig} from '../markets/aave/commons'; | import { CommonsConfig } from '../markets/aave/commons'; | ||||||
| import {DRE, filterMapBy} from './misc-utils'; | import { DRE, filterMapBy } from './misc-utils'; | ||||||
| import {tEthereumAddress} from './types'; | import { tEthereumAddress } from './types'; | ||||||
| import {getParamPerNetwork} from './contracts-helpers'; | import { getParamPerNetwork } from './contracts-helpers'; | ||||||
| import {deployWETHMocked} from './contracts-deployments'; | import { deployWETHMocked } from './contracts-deployments'; | ||||||
| 
 | 
 | ||||||
| export enum ConfigNames { | export enum ConfigNames { | ||||||
|   Commons = 'Commons', |   Commons = 'Commons', | ||||||
|  | @ -48,7 +48,7 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes | ||||||
| export const getGenesisPoolAdmin = async ( | export const getGenesisPoolAdmin = async ( | ||||||
|   config: ICommonConfiguration |   config: ICommonConfiguration | ||||||
| ): Promise<tEthereumAddress> => { | ): Promise<tEthereumAddress> => { | ||||||
|   const currentNetwork = DRE.network.name; |   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||||
|   const targetAddress = getParamPerNetwork(config.PoolAdmin, <eEthereumNetwork>currentNetwork); |   const targetAddress = getParamPerNetwork(config.PoolAdmin, <eEthereumNetwork>currentNetwork); | ||||||
|   if (targetAddress) { |   if (targetAddress) { | ||||||
|     return targetAddress; |     return targetAddress; | ||||||
|  | @ -63,7 +63,7 @@ export const getGenesisPoolAdmin = async ( | ||||||
| export const getEmergencyAdmin = async ( | export const getEmergencyAdmin = async ( | ||||||
|   config: ICommonConfiguration |   config: ICommonConfiguration | ||||||
| ): Promise<tEthereumAddress> => { | ): Promise<tEthereumAddress> => { | ||||||
|   const currentNetwork = DRE.network.name; |   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||||
|   const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eEthereumNetwork>currentNetwork); |   const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eEthereumNetwork>currentNetwork); | ||||||
|   if (targetAddress) { |   if (targetAddress) { | ||||||
|     return targetAddress; |     return targetAddress; | ||||||
|  | @ -81,7 +81,7 @@ export const getATokenDomainSeparatorPerNetwork = ( | ||||||
| ): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network); | ): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network); | ||||||
| 
 | 
 | ||||||
| export const getWethAddress = async (config: ICommonConfiguration) => { | export const getWethAddress = async (config: ICommonConfiguration) => { | ||||||
|   const currentNetwork = DRE.network.name; |   const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; | ||||||
|   const wethAddress = getParamPerNetwork(config.WETH, <eEthereumNetwork>currentNetwork); |   const wethAddress = getParamPerNetwork(config.WETH, <eEthereumNetwork>currentNetwork); | ||||||
|   if (wethAddress) { |   if (wethAddress) { | ||||||
|     return wethAddress; |     return wethAddress; | ||||||
|  | @ -95,7 +95,7 @@ export const getWethAddress = async (config: ICommonConfiguration) => { | ||||||
| 
 | 
 | ||||||
| export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { | export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { | ||||||
|   const { |   const { | ||||||
|     ProtocolGlobalParams: {UsdAddress}, |     ProtocolGlobalParams: { UsdAddress }, | ||||||
|     LendingRateOracleRatesCommon, |     LendingRateOracleRatesCommon, | ||||||
|     ReserveAssets, |     ReserveAssets, | ||||||
|   } = poolConfig; |   } = poolConfig; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import {Contract} from 'ethers'; | import { Contract } from 'ethers'; | ||||||
| import {DRE} from './misc-utils'; | import { DRE } from './misc-utils'; | ||||||
| import { | import { | ||||||
|   tEthereumAddress, |   tEthereumAddress, | ||||||
|   eContractid, |   eContractid, | ||||||
|  | @ -12,11 +12,11 @@ import { | ||||||
|   eEthereumNetwork, |   eEthereumNetwork, | ||||||
| } from './types'; | } from './types'; | ||||||
| 
 | 
 | ||||||
| import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; | import { MintableERC20 } from '../types/MintableERC20'; | ||||||
| import {MockContract} from 'ethereum-waffle'; | import { MockContract } from 'ethereum-waffle'; | ||||||
| import {getReservesConfigByPool} from './configuration'; | import { getReservesConfigByPool } from './configuration'; | ||||||
| import {getFirstSigner} from './contracts-getters'; | import { getFirstSigner } from './contracts-getters'; | ||||||
| import {ZERO_ADDRESS} from './constants'; | import { ZERO_ADDRESS } from './constants'; | ||||||
| import { | import { | ||||||
|   AaveProtocolDataProviderFactory, |   AaveProtocolDataProviderFactory, | ||||||
|   ATokenFactory, |   ATokenFactory, | ||||||
|  | @ -30,10 +30,9 @@ import { | ||||||
|   LendingPoolCollateralManagerFactory, |   LendingPoolCollateralManagerFactory, | ||||||
|   LendingPoolConfiguratorFactory, |   LendingPoolConfiguratorFactory, | ||||||
|   LendingPoolFactory, |   LendingPoolFactory, | ||||||
|   LendingPoolLibraryAddresses, |  | ||||||
|   LendingRateOracleFactory, |   LendingRateOracleFactory, | ||||||
|   MintableDelegationErc20Factory, |   MintableDelegationERC20Factory, | ||||||
|   MintableErc20Factory, |   MintableERC20Factory, | ||||||
|   MockAggregatorFactory, |   MockAggregatorFactory, | ||||||
|   MockATokenFactory, |   MockATokenFactory, | ||||||
|   MockFlashLoanReceiverFactory, |   MockFlashLoanReceiverFactory, | ||||||
|  | @ -48,8 +47,8 @@ import { | ||||||
|   UniswapRepayAdapterFactory, |   UniswapRepayAdapterFactory, | ||||||
|   VariableDebtTokenFactory, |   VariableDebtTokenFactory, | ||||||
|   WalletBalanceProviderFactory, |   WalletBalanceProviderFactory, | ||||||
|   Weth9MockedFactory, |   WETH9MockedFactory, | ||||||
|   WethGatewayFactory, |   WETHGatewayFactory, | ||||||
| } from '../types'; | } from '../types'; | ||||||
| import { | import { | ||||||
|   withSaveAndVerify, |   withSaveAndVerify, | ||||||
|  | @ -57,11 +56,11 @@ import { | ||||||
|   linkBytecode, |   linkBytecode, | ||||||
|   insertContractAddressInDb, |   insertContractAddressInDb, | ||||||
| } from './contracts-helpers'; | } from './contracts-helpers'; | ||||||
| import {StableAndVariableTokensHelperFactory} from '../types/StableAndVariableTokensHelperFactory'; | import { StableAndVariableTokensHelperFactory } from '../types/StableAndVariableTokensHelperFactory'; | ||||||
| import {MintableDelegationErc20} from '../types/MintableDelegationErc20'; | import { MintableDelegationERC20 } from '../types/MintableDelegationERC20'; | ||||||
| import {readArtifact as buidlerReadArtifact} from '@nomiclabs/buidler/plugins'; | import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins'; | ||||||
| import {HardhatRuntimeEnvironment} from 'hardhat/types'; | import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||||||
| import {verifyContract} from './etherscan-verification'; | import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory'; | ||||||
| 
 | 
 | ||||||
| const readArtifact = async (id: string) => { | const readArtifact = async (id: string) => { | ||||||
|   if (DRE.network.name === eEthereumNetwork.buidlerevm) { |   if (DRE.network.name === eEthereumNetwork.buidlerevm) { | ||||||
|  | @ -275,7 +274,7 @@ export const deployMintableERC20 = async ( | ||||||
|   verify?: boolean |   verify?: boolean | ||||||
| ): Promise<MintableERC20> => | ): Promise<MintableERC20> => | ||||||
|   withSaveAndVerify( |   withSaveAndVerify( | ||||||
|     await new MintableErc20Factory(await getFirstSigner()).deploy(...args), |     await new MintableERC20Factory(await getFirstSigner()).deploy(...args), | ||||||
|     eContractid.MintableERC20, |     eContractid.MintableERC20, | ||||||
|     args, |     args, | ||||||
|     verify |     verify | ||||||
|  | @ -284,9 +283,9 @@ export const deployMintableERC20 = async ( | ||||||
| export const deployMintableDelegationERC20 = async ( | export const deployMintableDelegationERC20 = async ( | ||||||
|   args: [string, string, string], |   args: [string, string, string], | ||||||
|   verify?: boolean |   verify?: boolean | ||||||
| ): Promise<MintableDelegationErc20> => | ): Promise<MintableDelegationERC20> => | ||||||
|   withSaveAndVerify( |   withSaveAndVerify( | ||||||
|     await new MintableDelegationErc20Factory(await getFirstSigner()).deploy(...args), |     await new MintableDelegationERC20Factory(await getFirstSigner()).deploy(...args), | ||||||
|     eContractid.MintableDelegationERC20, |     eContractid.MintableDelegationERC20, | ||||||
|     args, |     args, | ||||||
|     verify |     verify | ||||||
|  | @ -377,20 +376,15 @@ export const deployDelegationAwareAToken = async ( | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const deployAllMockTokens = async (verify?: boolean) => { | export const deployAllMockTokens = async (verify?: boolean) => { | ||||||
|   const tokens: {[symbol: string]: MockContract | MintableERC20} = {}; |   const tokens: { [symbol: string]: MockContract | MintableERC20 } = {}; | ||||||
| 
 | 
 | ||||||
|   const protoConfigData = getReservesConfigByPool(AavePools.proto); |   const protoConfigData = getReservesConfigByPool(AavePools.proto); | ||||||
|   const secondaryConfigData = getReservesConfigByPool(AavePools.secondary); |  | ||||||
| 
 | 
 | ||||||
|   for (const tokenSymbol of Object.keys(TokenContractId)) { |   for (const tokenSymbol of Object.keys(TokenContractId)) { | ||||||
|     let decimals = '18'; |     let decimals = '18'; | ||||||
| 
 | 
 | ||||||
|     let configData = (<any>protoConfigData)[tokenSymbol]; |     let configData = (<any>protoConfigData)[tokenSymbol]; | ||||||
| 
 | 
 | ||||||
|     if (!configData) { |  | ||||||
|       configData = (<any>secondaryConfigData)[tokenSymbol]; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     tokens[tokenSymbol] = await deployMintableERC20( |     tokens[tokenSymbol] = await deployMintableERC20( | ||||||
|       [tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals], |       [tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals], | ||||||
|       verify |       verify | ||||||
|  | @ -400,7 +394,7 @@ export const deployAllMockTokens = async (verify?: boolean) => { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const deployMockTokens = async (config: PoolConfiguration, verify?: boolean) => { | export const deployMockTokens = async (config: PoolConfiguration, verify?: boolean) => { | ||||||
|   const tokens: {[symbol: string]: MockContract | MintableERC20} = {}; |   const tokens: { [symbol: string]: MockContract | MintableERC20 } = {}; | ||||||
|   const defaultDecimals = 18; |   const defaultDecimals = 18; | ||||||
| 
 | 
 | ||||||
|   const configData = config.ReservesConfig; |   const configData = config.ReservesConfig; | ||||||
|  | @ -447,7 +441,7 @@ export const deployWETHGateway = async ( | ||||||
|   verify?: boolean |   verify?: boolean | ||||||
| ) => | ) => | ||||||
|   withSaveAndVerify( |   withSaveAndVerify( | ||||||
|     await new WethGatewayFactory(await getFirstSigner()).deploy(...args), |     await new WETHGatewayFactory(await getFirstSigner()).deploy(...args), | ||||||
|     eContractid.WETHGateway, |     eContractid.WETHGateway, | ||||||
|     args, |     args, | ||||||
|     verify |     verify | ||||||
|  | @ -466,7 +460,7 @@ export const deployMockStableDebtToken = async ( | ||||||
| 
 | 
 | ||||||
| export const deployWETHMocked = async (verify?: boolean) => | export const deployWETHMocked = async (verify?: boolean) => | ||||||
|   withSaveAndVerify( |   withSaveAndVerify( | ||||||
|     await new Weth9MockedFactory(await getFirstSigner()).deploy(), |     await new WETH9MockedFactory(await getFirstSigner()).deploy(), | ||||||
|     eContractid.WETHMocked, |     eContractid.WETHMocked, | ||||||
|     [], |     [], | ||||||
|     verify |     verify | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ import { | ||||||
|   LendingPoolConfiguratorFactory, |   LendingPoolConfiguratorFactory, | ||||||
|   LendingPoolFactory, |   LendingPoolFactory, | ||||||
|   LendingRateOracleFactory, |   LendingRateOracleFactory, | ||||||
|   MintableErc20Factory, |   MintableERC20Factory, | ||||||
|   MockATokenFactory, |   MockATokenFactory, | ||||||
|   MockFlashLoanReceiverFactory, |   MockFlashLoanReceiverFactory, | ||||||
|   MockStableDebtTokenFactory, |   MockStableDebtTokenFactory, | ||||||
|  | @ -27,13 +27,13 @@ import { | ||||||
|   UniswapRepayAdapterFactory, |   UniswapRepayAdapterFactory, | ||||||
|   VariableDebtTokenFactory, |   VariableDebtTokenFactory, | ||||||
|   WalletBalanceProviderFactory, |   WalletBalanceProviderFactory, | ||||||
|   Weth9MockedFactory, |   WETH9MockedFactory, | ||||||
|   WethGatewayFactory, |   WETHGatewayFactory, | ||||||
| } from '../types'; | } from '../types'; | ||||||
| import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory'; | import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory'; | ||||||
| import {MockTokenMap} from './contracts-helpers'; | import { MockTokenMap } from './contracts-helpers'; | ||||||
| import {DRE, getDb} from './misc-utils'; | import { DRE, getDb } from './misc-utils'; | ||||||
| import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types'; | import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types'; | ||||||
| 
 | 
 | ||||||
| export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0]; | export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0]; | ||||||
| 
 | 
 | ||||||
|  | @ -88,15 +88,15 @@ export const getVariableDebtToken = async (address?: tEthereumAddress) => | ||||||
|     await getFirstSigner() |     await getFirstSigner() | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
| export const getMintableErc20 = async (address: tEthereumAddress) => | export const getMintableERC20 = async (address: tEthereumAddress) => | ||||||
|   await MintableErc20Factory.connect( |   await MintableERC20Factory.connect( | ||||||
|     address || |     address || | ||||||
|       (await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()).address, |       (await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()).address, | ||||||
|     await getFirstSigner() |     await getFirstSigner() | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
| export const getIErc20Detailed = async (address: tEthereumAddress) => | export const getIErc20Detailed = async (address: tEthereumAddress) => | ||||||
|   await Ierc20DetailedFactory.connect( |   await IERC20DetailedFactory.connect( | ||||||
|     address || |     address || | ||||||
|       (await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()).address, |       (await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()).address, | ||||||
|     await getFirstSigner() |     await getFirstSigner() | ||||||
|  | @ -143,7 +143,7 @@ export const getMockedTokens = async (config: PoolConfiguration) => { | ||||||
|     async (acc, tokenSymbol) => { |     async (acc, tokenSymbol) => { | ||||||
|       const accumulator = await acc; |       const accumulator = await acc; | ||||||
|       const address = db.get(`${tokenSymbol.toUpperCase()}.${DRE.network.name}`).value().address; |       const address = db.get(`${tokenSymbol.toUpperCase()}.${DRE.network.name}`).value().address; | ||||||
|       accumulator[tokenSymbol] = await getMintableErc20(address); |       accumulator[tokenSymbol] = await getMintableERC20(address); | ||||||
|       return Promise.resolve(acc); |       return Promise.resolve(acc); | ||||||
|     }, |     }, | ||||||
|     Promise.resolve({}) |     Promise.resolve({}) | ||||||
|  | @ -157,7 +157,7 @@ export const getAllMockedTokens = async () => { | ||||||
|     async (acc, tokenSymbol) => { |     async (acc, tokenSymbol) => { | ||||||
|       const accumulator = await acc; |       const accumulator = await acc; | ||||||
|       const address = db.get(`${tokenSymbol.toUpperCase()}.${DRE.network.name}`).value().address; |       const address = db.get(`${tokenSymbol.toUpperCase()}.${DRE.network.name}`).value().address; | ||||||
|       accumulator[tokenSymbol] = await getMintableErc20(address); |       accumulator[tokenSymbol] = await getMintableERC20(address); | ||||||
|       return Promise.resolve(acc); |       return Promise.resolve(acc); | ||||||
|     }, |     }, | ||||||
|     Promise.resolve({}) |     Promise.resolve({}) | ||||||
|  | @ -169,9 +169,9 @@ export const getPairsTokenAggregator = ( | ||||||
|   allAssetsAddresses: { |   allAssetsAddresses: { | ||||||
|     [tokenSymbol: string]: tEthereumAddress; |     [tokenSymbol: string]: tEthereumAddress; | ||||||
|   }, |   }, | ||||||
|   aggregatorsAddresses: {[tokenSymbol: string]: tEthereumAddress} |   aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress } | ||||||
| ): [string[], string[]] => { | ): [string[], string[]] => { | ||||||
|   const {ETH, USD, WETH, ...assetsAddressesWithoutEth} = allAssetsAddresses; |   const { ETH, USD, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses; | ||||||
| 
 | 
 | ||||||
|   const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { |   const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { | ||||||
|     if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') { |     if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') { | ||||||
|  | @ -237,14 +237,14 @@ export const getATokensAndRatesHelper = async (address?: tEthereumAddress) => | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
| export const getWETHGateway = async (address?: tEthereumAddress) => | export const getWETHGateway = async (address?: tEthereumAddress) => | ||||||
|   await WethGatewayFactory.connect( |   await WETHGatewayFactory.connect( | ||||||
|     address || |     address || | ||||||
|       (await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()).address, |       (await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()).address, | ||||||
|     await getFirstSigner() |     await getFirstSigner() | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
| export const getWETHMocked = async (address?: tEthereumAddress) => | export const getWETHMocked = async (address?: tEthereumAddress) => | ||||||
|   await Weth9MockedFactory.connect( |   await WETH9MockedFactory.connect( | ||||||
|     address || (await getDb().get(`${eContractid.WETHMocked}.${DRE.network.name}`).value()).address, |     address || (await getDb().get(`${eContractid.WETHMocked}.${DRE.network.name}`).value()).address, | ||||||
|     await getFirstSigner() |     await getFirstSigner() | ||||||
|   ); |   ); | ||||||
|  | @ -326,7 +326,7 @@ export const getLendingPoolCollateralManager = async (address?: tEthereumAddress | ||||||
| export const getAddressById = async (id: string) => | export const getAddressById = async (id: string) => | ||||||
|   (await getDb().get(`${id}.${DRE.network.name}`).value()).address; |   (await getDb().get(`${id}.${DRE.network.name}`).value()).address; | ||||||
| 
 | 
 | ||||||
| export const getChainlinkPriceProvider = async (address?: tEthereumAddress) => | export const getAaveOracle = async (address?: tEthereumAddress) => | ||||||
|   await AaveOracleFactory.connect( |   await AaveOracleFactory.connect( | ||||||
|     address || (await getDb().get(`${eContractid.AaveOracle}.${DRE.network.name}`).value()).address, |     address || (await getDb().get(`${eContractid.AaveOracle}.${DRE.network.name}`).value()).address, | ||||||
|     await getFirstSigner() |     await getFirstSigner() | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| import {Contract, Signer, utils, ethers, BigNumberish} from 'ethers'; | import { Contract, Signer, utils, ethers , BigNumberish} from 'ethers'; | ||||||
| import {signTypedData_v4} from 'eth-sig-util'; | import { signTypedData_v4 } from 'eth-sig-util'; | ||||||
| import {fromRpcSig, ECDSASignature} from 'ethereumjs-util'; | import { fromRpcSig, ECDSASignature } from 'ethereumjs-util'; | ||||||
| import BigNumber from 'bignumber.js'; | import BigNumber from 'bignumber.js'; | ||||||
| import {getDb, DRE, waitForTx} from './misc-utils'; | import { getDb, DRE, waitForTx } from './misc-utils'; | ||||||
| import { | import { | ||||||
|   tEthereumAddress, |   tEthereumAddress, | ||||||
|   eContractid, |   eContractid, | ||||||
|  | @ -12,13 +12,13 @@ import { | ||||||
|   iParamsPerNetwork, |   iParamsPerNetwork, | ||||||
|   iParamsPerPool, |   iParamsPerPool, | ||||||
| } from './types'; | } from './types'; | ||||||
| import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; | import { MintableERC20 } from '../types/MintableERC20'; | ||||||
| import {Artifact} from 'hardhat/types'; | import { Artifact } from 'hardhat/types'; | ||||||
| import {Artifact as BuidlerArtifact} from '@nomiclabs/buidler/types'; | import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types'; | ||||||
| import {verifyContract} from './etherscan-verification'; | import { verifyContract } from './etherscan-verification'; | ||||||
| import {getIErc20Detailed} from './contracts-getters'; | import { getIErc20Detailed } from './contracts-getters'; | ||||||
| 
 | 
 | ||||||
| export type MockTokenMap = {[symbol: string]: MintableERC20}; | export type MockTokenMap = { [symbol: string]: MintableERC20 }; | ||||||
| 
 | 
 | ||||||
| export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => { | export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => { | ||||||
|   const currentNetwork = DRE.network.name; |   const currentNetwork = DRE.network.name; | ||||||
|  | @ -131,7 +131,7 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const getParamPerNetwork = <T>( | export const getParamPerNetwork = <T>( | ||||||
|   {kovan, ropsten, main, buidlerevm, coverage, tenderlyMain}: iParamsPerNetwork<T>, |   { kovan, ropsten, main, buidlerevm, coverage, tenderlyMain }: iParamsPerNetwork<T>, | ||||||
|   network: eEthereumNetwork |   network: eEthereumNetwork | ||||||
| ) => { | ) => { | ||||||
|   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; |   const MAINNET_FORK = process.env.MAINNET_FORK === 'true'; | ||||||
|  | @ -157,7 +157,7 @@ export const getParamPerNetwork = <T>( | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const getParamPerPool = <T>({proto}: iParamsPerPool<T>, pool: AavePools) => { | export const getParamPerPool = <T>({ proto }: iParamsPerPool<T>, pool: AavePools) => { | ||||||
|   switch (pool) { |   switch (pool) { | ||||||
|     case AavePools.proto: |     case AavePools.proto: | ||||||
|       return proto; |       return proto; | ||||||
|  | @ -194,17 +194,17 @@ export const buildPermitParams = ( | ||||||
| ) => ({ | ) => ({ | ||||||
|   types: { |   types: { | ||||||
|     EIP712Domain: [ |     EIP712Domain: [ | ||||||
|       {name: 'name', type: 'string'}, |       { name: 'name', type: 'string' }, | ||||||
|       {name: 'version', type: 'string'}, |       { name: 'version', type: 'string' }, | ||||||
|       {name: 'chainId', type: 'uint256'}, |       { name: 'chainId', type: 'uint256' }, | ||||||
|       {name: 'verifyingContract', type: 'address'}, |       { name: 'verifyingContract', type: 'address' }, | ||||||
|     ], |     ], | ||||||
|     Permit: [ |     Permit: [ | ||||||
|       {name: 'owner', type: 'address'}, |       { name: 'owner', type: 'address' }, | ||||||
|       {name: 'spender', type: 'address'}, |       { name: 'spender', type: 'address' }, | ||||||
|       {name: 'value', type: 'uint256'}, |       { name: 'value', type: 'uint256' }, | ||||||
|       {name: 'nonce', type: 'uint256'}, |       { name: 'nonce', type: 'uint256' }, | ||||||
|       {name: 'deadline', type: 'uint256'}, |       { name: 'deadline', type: 'uint256' }, | ||||||
|     ], |     ], | ||||||
|   }, |   }, | ||||||
|   primaryType: 'Permit' as const, |   primaryType: 'Permit' as const, | ||||||
|  |  | ||||||
|  | @ -1,16 +1,17 @@ | ||||||
| import {iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types'; | import { iMultiPoolsAssets, IReserveParams, tEthereumAddress } from './types'; | ||||||
| import {AaveProtocolDataProvider} from '../types/AaveProtocolDataProvider'; | import { AaveProtocolDataProvider } from '../types/AaveProtocolDataProvider'; | ||||||
| import {chunk, waitForTx} from './misc-utils'; | import { chunk, waitForTx } from './misc-utils'; | ||||||
| import { | import { | ||||||
|   getATokensAndRatesHelper, |   getATokensAndRatesHelper, | ||||||
|   getLendingPoolAddressesProvider, |   getLendingPoolAddressesProvider, | ||||||
|   getStableAndVariableTokensHelper, |   getStableAndVariableTokensHelper, | ||||||
| } from './contracts-getters'; | } from './contracts-getters'; | ||||||
| import {rawInsertContractAddressInDb} from './contracts-helpers'; | import { rawInsertContractAddressInDb } from './contracts-helpers'; | ||||||
|  | import { BigNumberish } from 'ethers'; | ||||||
| 
 | 
 | ||||||
| export const initReservesByHelper = async ( | export const initReservesByHelper = async ( | ||||||
|   reservesParams: iMultiPoolsAssets<IReserveParams>, |   reservesParams: iMultiPoolsAssets<IReserveParams>, | ||||||
|   tokenAddresses: {[symbol: string]: tEthereumAddress}, |   tokenAddresses: { [symbol: string]: tEthereumAddress }, | ||||||
|   admin: tEthereumAddress, |   admin: tEthereumAddress, | ||||||
|   incentivesController: tEthereumAddress |   incentivesController: tEthereumAddress | ||||||
| ) => { | ) => { | ||||||
|  | @ -48,10 +49,16 @@ export const initReservesByHelper = async ( | ||||||
|     // Prepare data
 |     // Prepare data
 | ||||||
|     const tokens: string[] = []; |     const tokens: string[] = []; | ||||||
|     const symbols: string[] = []; |     const symbols: string[] = []; | ||||||
|     const strategyRates: string[][] = []; |     const strategyRates: [ | ||||||
|  |       BigNumberish, | ||||||
|  |       BigNumberish, | ||||||
|  |       BigNumberish, | ||||||
|  |       BigNumberish, | ||||||
|  |       BigNumberish | ||||||
|  |     ][] = []; | ||||||
|     const reservesDecimals: string[] = []; |     const reservesDecimals: string[] = []; | ||||||
| 
 | 
 | ||||||
|     for (let [assetSymbol, {reserveDecimals}] of reservesChunk) { |     for (let [assetSymbol, { reserveDecimals }] of reservesChunk) { | ||||||
|       const assetAddressIndex = Object.keys(tokenAddresses).findIndex( |       const assetAddressIndex = Object.keys(tokenAddresses).findIndex( | ||||||
|         (value) => value === assetSymbol |         (value) => value === assetSymbol | ||||||
|       ); |       ); | ||||||
|  | @ -151,9 +158,9 @@ export const getPairsTokenAggregator = ( | ||||||
|   allAssetsAddresses: { |   allAssetsAddresses: { | ||||||
|     [tokenSymbol: string]: tEthereumAddress; |     [tokenSymbol: string]: tEthereumAddress; | ||||||
|   }, |   }, | ||||||
|   aggregatorsAddresses: {[tokenSymbol: string]: tEthereumAddress} |   aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress } | ||||||
| ): [string[], string[]] => { | ): [string[], string[]] => { | ||||||
|   const {ETH, USD, WETH, ...assetsAddressesWithoutEth} = allAssetsAddresses; |   const { ETH, USD, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses; | ||||||
| 
 | 
 | ||||||
|   const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { |   const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => { | ||||||
|     if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') { |     if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') { | ||||||
|  | @ -176,7 +183,7 @@ export const getPairsTokenAggregator = ( | ||||||
| 
 | 
 | ||||||
| export const enableReservesToBorrowByHelper = async ( | export const enableReservesToBorrowByHelper = async ( | ||||||
|   reservesParams: iMultiPoolsAssets<IReserveParams>, |   reservesParams: iMultiPoolsAssets<IReserveParams>, | ||||||
|   tokenAddresses: {[symbol: string]: tEthereumAddress}, |   tokenAddresses: { [symbol: string]: tEthereumAddress }, | ||||||
|   helpers: AaveProtocolDataProvider, |   helpers: AaveProtocolDataProvider, | ||||||
|   admin: tEthereumAddress |   admin: tEthereumAddress | ||||||
| ) => { | ) => { | ||||||
|  | @ -187,7 +194,7 @@ export const enableReservesToBorrowByHelper = async ( | ||||||
|   const stableEnabled: boolean[] = []; |   const stableEnabled: boolean[] = []; | ||||||
| 
 | 
 | ||||||
|   // Prepare data
 |   // Prepare data
 | ||||||
|   for (const [assetSymbol, {borrowingEnabled, stableBorrowRateEnabled}] of Object.entries( |   for (const [assetSymbol, { borrowingEnabled, stableBorrowRateEnabled }] of Object.entries( | ||||||
|     reservesParams |     reservesParams | ||||||
|   ) as [string, IReserveParams][]) { |   ) as [string, IReserveParams][]) { | ||||||
|     if (!borrowingEnabled) continue; |     if (!borrowingEnabled) continue; | ||||||
|  | @ -197,7 +204,7 @@ export const enableReservesToBorrowByHelper = async ( | ||||||
|     const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[ |     const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[ | ||||||
|       assetAddressIndex |       assetAddressIndex | ||||||
|     ]; |     ]; | ||||||
|     const {borrowingEnabled: borrowingAlreadyEnabled} = await helpers.getReserveConfigurationData( |     const { borrowingEnabled: borrowingAlreadyEnabled } = await helpers.getReserveConfigurationData( | ||||||
|       tokenAddress |       tokenAddress | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|  | @ -226,7 +233,7 @@ export const enableReservesToBorrowByHelper = async ( | ||||||
|           await atokenAndRatesDeployer.enableBorrowingOnReserves( |           await atokenAndRatesDeployer.enableBorrowingOnReserves( | ||||||
|             chunkedTokens[chunkIndex], |             chunkedTokens[chunkIndex], | ||||||
|             chunkedStableEnabled[chunkIndex], |             chunkedStableEnabled[chunkIndex], | ||||||
|             {gasLimit: 12000000} |             { gasLimit: 12000000 } | ||||||
|           ) |           ) | ||||||
|         ); |         ); | ||||||
|       } catch (error) { |       } catch (error) { | ||||||
|  | @ -243,7 +250,7 @@ export const enableReservesToBorrowByHelper = async ( | ||||||
| 
 | 
 | ||||||
| export const enableReservesAsCollateralByHelper = async ( | export const enableReservesAsCollateralByHelper = async ( | ||||||
|   reservesParams: iMultiPoolsAssets<IReserveParams>, |   reservesParams: iMultiPoolsAssets<IReserveParams>, | ||||||
|   tokenAddresses: {[symbol: string]: tEthereumAddress}, |   tokenAddresses: { [symbol: string]: tEthereumAddress }, | ||||||
|   helpers: AaveProtocolDataProvider, |   helpers: AaveProtocolDataProvider, | ||||||
|   admin: tEthereumAddress |   admin: tEthereumAddress | ||||||
| ) => { | ) => { | ||||||
|  | @ -257,7 +264,7 @@ export const enableReservesAsCollateralByHelper = async ( | ||||||
| 
 | 
 | ||||||
|   for (const [ |   for (const [ | ||||||
|     assetSymbol, |     assetSymbol, | ||||||
|     {baseLTVAsCollateral, liquidationBonus, liquidationThreshold}, |     { baseLTVAsCollateral, liquidationBonus, liquidationThreshold }, | ||||||
|   ] of Object.entries(reservesParams) as [string, IReserveParams][]) { |   ] of Object.entries(reservesParams) as [string, IReserveParams][]) { | ||||||
|     if (baseLTVAsCollateral === '-1') continue; |     if (baseLTVAsCollateral === '-1') continue; | ||||||
| 
 | 
 | ||||||
|  | @ -267,7 +274,7 @@ export const enableReservesAsCollateralByHelper = async ( | ||||||
|     const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[ |     const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[ | ||||||
|       assetAddressIndex |       assetAddressIndex | ||||||
|     ]; |     ]; | ||||||
|     const {usageAsCollateralEnabled: alreadyEnabled} = await helpers.getReserveConfigurationData( |     const { usageAsCollateralEnabled: alreadyEnabled } = await helpers.getReserveConfigurationData( | ||||||
|       tokenAddress |       tokenAddress | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|  | @ -302,7 +309,7 @@ export const enableReservesAsCollateralByHelper = async ( | ||||||
|           chunkedBase[chunkIndex], |           chunkedBase[chunkIndex], | ||||||
|           chunkedliquidationThresholds[chunkIndex], |           chunkedliquidationThresholds[chunkIndex], | ||||||
|           chunkedliquidationBonuses[chunkIndex], |           chunkedliquidationBonuses[chunkIndex], | ||||||
|           {gasLimit: 12000000} |           { gasLimit: 12000000 } | ||||||
|         ) |         ) | ||||||
|       ); |       ); | ||||||
|       console.log(`  - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`); |       console.log(`  - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`); | ||||||
|  |  | ||||||
|  | @ -22,7 +22,6 @@ export enum EthereumNetworkNames { | ||||||
| 
 | 
 | ||||||
| export enum AavePools { | export enum AavePools { | ||||||
|   proto = 'proto', |   proto = 'proto', | ||||||
|   secondary = 'secondary', |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export enum eContractid { | export enum eContractid { | ||||||
|  | @ -191,7 +190,6 @@ export interface iAssetBase<T> { | ||||||
|   SUSD: T; |   SUSD: T; | ||||||
|   AAVE: T; |   AAVE: T; | ||||||
|   BAT: T; |   BAT: T; | ||||||
|   REP: T; |  | ||||||
|   MKR: T; |   MKR: T; | ||||||
|   LINK: T; |   LINK: T; | ||||||
|   KNC: T; |   KNC: T; | ||||||
|  | @ -205,13 +203,6 @@ export interface iAssetBase<T> { | ||||||
|   USD: T; |   USD: T; | ||||||
|   REN: T; |   REN: T; | ||||||
|   ENJ: T; |   ENJ: T; | ||||||
| 
 |  | ||||||
|   UNI_DAI_ETH: T; |  | ||||||
|   UNI_USDC_ETH: T; |  | ||||||
|   UNI_SETH_ETH: T; |  | ||||||
|   UNI_LEND_ETH: T; |  | ||||||
|   UNI_MKR_ETH: T; |  | ||||||
|   UNI_LINK_ETH: T; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>; | export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>; | ||||||
|  | @ -227,7 +218,6 @@ export type iAavePoolAssets<T> = Pick< | ||||||
|   | 'SUSD' |   | 'SUSD' | ||||||
|   | 'AAVE' |   | 'AAVE' | ||||||
|   | 'BAT' |   | 'BAT' | ||||||
|   | 'REP' |  | ||||||
|   | 'MKR' |   | 'MKR' | ||||||
|   | 'LINK' |   | 'LINK' | ||||||
|   | 'KNC' |   | 'KNC' | ||||||
|  | @ -243,25 +233,6 @@ export type iAavePoolAssets<T> = Pick< | ||||||
|   | 'ENJ' |   | 'ENJ' | ||||||
| >; | >; | ||||||
| 
 | 
 | ||||||
| export type iUniAssets<T> = Pick< |  | ||||||
|   iAssetBase<T>, |  | ||||||
|   'UNI_DAI_ETH' | 'UNI_USDC_ETH' | 'UNI_SETH_ETH' | 'UNI_LEND_ETH' | 'UNI_MKR_ETH' | 'UNI_LINK_ETH' |  | ||||||
| >; |  | ||||||
| 
 |  | ||||||
| export type iAaveSecondPoolAssets<T> = Pick< |  | ||||||
|   iAssetBase<T>, |  | ||||||
|   | 'WETH' |  | ||||||
|   | 'DAI' |  | ||||||
|   | 'USDC' |  | ||||||
|   | 'USDT' |  | ||||||
|   | 'UNI_DAI_ETH' |  | ||||||
|   | 'UNI_USDC_ETH' |  | ||||||
|   | 'UNI_SETH_ETH' |  | ||||||
|   | 'UNI_LEND_ETH' |  | ||||||
|   | 'UNI_MKR_ETH' |  | ||||||
|   | 'UNI_LINK_ETH' |  | ||||||
| >; |  | ||||||
| 
 |  | ||||||
| export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>; | export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>; | ||||||
| 
 | 
 | ||||||
| export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>; | export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>; | ||||||
|  | @ -283,7 +254,6 @@ export enum TokenContractId { | ||||||
|   LINK = 'LINK', |   LINK = 'LINK', | ||||||
|   KNC = 'KNC', |   KNC = 'KNC', | ||||||
|   MANA = 'MANA', |   MANA = 'MANA', | ||||||
|   REP = 'REP', |  | ||||||
|   REN = 'REN', |   REN = 'REN', | ||||||
|   SNX = 'SNX', |   SNX = 'SNX', | ||||||
|   BUSD = 'BUSD', |   BUSD = 'BUSD', | ||||||
|  | @ -291,12 +261,6 @@ export enum TokenContractId { | ||||||
|   YFI = 'YFI', |   YFI = 'YFI', | ||||||
|   UNI = 'UNI', |   UNI = 'UNI', | ||||||
|   ENJ = 'ENJ', |   ENJ = 'ENJ', | ||||||
|   UNI_DAI_ETH = 'UNI_DAI_ETH', |  | ||||||
|   UNI_USDC_ETH = 'UNI_USDC_ETH', |  | ||||||
|   UNI_SETH_ETH = 'UNI_SETH_ETH', |  | ||||||
|   UNI_LINK_ETH = 'UNI_LINK_ETH', |  | ||||||
|   UNI_MKR_ETH = 'UNI_MKR_ETH', |  | ||||||
|   UNI_LEND_ETH = 'UNI_LEND_ETH', |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {} | export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {} | ||||||
|  | @ -373,7 +337,6 @@ export interface IProtocolGlobalConfig { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface IMocksConfig { | export interface IMocksConfig { | ||||||
|   ChainlinkAggregatorPrices: iAssetBase<string>; |  | ||||||
|   AllAssetsInitialPrices: iAssetBase<string>; |   AllAssetsInitialPrices: iAssetBase<string>; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -404,20 +367,14 @@ export interface ICommonConfiguration { | ||||||
|   ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>; |   ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>; | ||||||
|   ReservesConfig: iMultiPoolsAssets<IReserveParams>; |   ReservesConfig: iMultiPoolsAssets<IReserveParams>; | ||||||
|   ATokenDomainSeparator: iParamsPerNetwork<string>; |   ATokenDomainSeparator: iParamsPerNetwork<string>; | ||||||
|   ProxyPriceProvider: iParamsPerNetwork<tEthereumAddress>; |  | ||||||
|   WETH: iParamsPerNetwork<tEthereumAddress>; |   WETH: iParamsPerNetwork<tEthereumAddress>; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface IAaveConfiguration extends ICommonConfiguration { | export interface IAaveConfiguration extends ICommonConfiguration { | ||||||
|   ReservesConfig: iAavePoolAssets<IReserveParams>; |   ReservesConfig: iAavePoolAssets<IReserveParams>; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| export interface IUniswapConfiguration extends ICommonConfiguration { |  | ||||||
|   ReservesConfig: iAaveSecondPoolAssets<IReserveParams>; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export interface ITokenAddress { | export interface ITokenAddress { | ||||||
|   [token: string]: tEthereumAddress; |   [token: string]: tEthereumAddress; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration | IUniswapConfiguration; | export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration; | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import BigNumber from 'bignumber.js'; | import BigNumber from 'bignumber.js'; | ||||||
| import {oneEther, oneRay, RAY, ZERO_ADDRESS} from '../../helpers/constants'; | import { oneEther, oneRay, RAY, ZERO_ADDRESS } from '../../helpers/constants'; | ||||||
| import {ICommonConfiguration, EthereumNetwork, eEthereumNetwork} from '../../helpers/types'; | import { ICommonConfiguration, EthereumNetwork, eEthereumNetwork } from '../../helpers/types'; | ||||||
| 
 | 
 | ||||||
| const MOCK_CHAINLINK_AGGREGATORS_PRICES = { | const MOCK_CHAINLINK_AGGREGATORS_PRICES = { | ||||||
|   AAVE: oneEther.multipliedBy('0.003620948469').toFixed(), |   AAVE: oneEther.multipliedBy('0.003620948469').toFixed(), | ||||||
|  | @ -13,7 +13,6 @@ const MOCK_CHAINLINK_AGGREGATORS_PRICES = { | ||||||
|   MANA: oneEther.multipliedBy('0.000158').toFixed(), |   MANA: oneEther.multipliedBy('0.000158').toFixed(), | ||||||
|   MKR: oneEther.multipliedBy('2.508581').toFixed(), |   MKR: oneEther.multipliedBy('2.508581').toFixed(), | ||||||
|   REN: oneEther.multipliedBy('0.00065133').toFixed(), |   REN: oneEther.multipliedBy('0.00065133').toFixed(), | ||||||
|   REP: oneEther.multipliedBy('0.048235').toFixed(), |  | ||||||
|   SNX: oneEther.multipliedBy('0.00442616').toFixed(), |   SNX: oneEther.multipliedBy('0.00442616').toFixed(), | ||||||
|   SUSD: oneEther.multipliedBy('0.00364714136416').toFixed(), |   SUSD: oneEther.multipliedBy('0.00364714136416').toFixed(), | ||||||
|   TUSD: oneEther.multipliedBy('0.00364714136416').toFixed(), |   TUSD: oneEther.multipliedBy('0.00364714136416').toFixed(), | ||||||
|  | @ -25,12 +24,6 @@ const MOCK_CHAINLINK_AGGREGATORS_PRICES = { | ||||||
|   YFI: oneEther.multipliedBy('22.407436').toFixed(), |   YFI: oneEther.multipliedBy('22.407436').toFixed(), | ||||||
|   ZRX: oneEther.multipliedBy('0.001151').toFixed(), |   ZRX: oneEther.multipliedBy('0.001151').toFixed(), | ||||||
|   USD: '5848466240000000', |   USD: '5848466240000000', | ||||||
|   UNI_DAI_ETH: oneEther.multipliedBy('2.1').toFixed(), |  | ||||||
|   UNI_USDC_ETH: oneEther.multipliedBy('2.1').toFixed(), |  | ||||||
|   UNI_SETH_ETH: oneEther.multipliedBy('2.1').toFixed(), |  | ||||||
|   UNI_LEND_ETH: oneEther.multipliedBy('2.1').toFixed(), |  | ||||||
|   UNI_LINK_ETH: oneEther.multipliedBy('2.1').toFixed(), |  | ||||||
|   UNI_MKR_ETH: oneEther.multipliedBy('2.1').toFixed(), |  | ||||||
| }; | }; | ||||||
| // ----------------
 | // ----------------
 | ||||||
| // PROTOCOL GLOBAL PARAMS
 | // PROTOCOL GLOBAL PARAMS
 | ||||||
|  | @ -57,9 +50,6 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|   // ----------------
 |   // ----------------
 | ||||||
| 
 | 
 | ||||||
|   Mocks: { |   Mocks: { | ||||||
|     ChainlinkAggregatorPrices: { |  | ||||||
|       ...MOCK_CHAINLINK_AGGREGATORS_PRICES, |  | ||||||
|     }, |  | ||||||
|     AllAssetsInitialPrices: { |     AllAssetsInitialPrices: { | ||||||
|       ...MOCK_CHAINLINK_AGGREGATORS_PRICES, |       ...MOCK_CHAINLINK_AGGREGATORS_PRICES, | ||||||
|     }, |     }, | ||||||
|  | @ -96,9 +86,6 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|     KNC: { |     KNC: { | ||||||
|       borrowRate: oneRay.multipliedBy(0.03).toFixed(), |       borrowRate: oneRay.multipliedBy(0.03).toFixed(), | ||||||
|     }, |     }, | ||||||
|     REP: { |  | ||||||
|       borrowRate: oneRay.multipliedBy(0.03).toFixed(), |  | ||||||
|     }, |  | ||||||
|     MKR: { |     MKR: { | ||||||
|       borrowRate: oneRay.multipliedBy(0.03).toFixed(), |       borrowRate: oneRay.multipliedBy(0.03).toFixed(), | ||||||
|     }, |     }, | ||||||
|  | @ -168,8 +155,8 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|     [eEthereumNetwork.buidlerevm]: '', |     [eEthereumNetwork.buidlerevm]: '', | ||||||
|     [eEthereumNetwork.kovan]: '0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a', |     [eEthereumNetwork.kovan]: '0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a', | ||||||
|     [eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b', |     [eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b', | ||||||
|     [eEthereumNetwork.main]: '', |     [eEthereumNetwork.main]: ZERO_ADDRESS, | ||||||
|     [eEthereumNetwork.tenderlyMain]: '', |     [eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS, | ||||||
|   }, |   }, | ||||||
|   TokenDistributor: { |   TokenDistributor: { | ||||||
|     [eEthereumNetwork.coverage]: '', |     [eEthereumNetwork.coverage]: '', | ||||||
|  | @ -184,8 +171,8 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|     [eEthereumNetwork.coverage]: '', |     [eEthereumNetwork.coverage]: '', | ||||||
|     [eEthereumNetwork.hardhat]: '', |     [eEthereumNetwork.hardhat]: '', | ||||||
|     [eEthereumNetwork.buidlerevm]: '', |     [eEthereumNetwork.buidlerevm]: '', | ||||||
|     [EthereumNetwork.kovan]: '0x276C4793F2EE3D5Bf18C5b879529dD4270BA4814', |     [EthereumNetwork.kovan]: '0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1', | ||||||
|     [EthereumNetwork.ropsten]: '0x657372A559c30d236F011239fF9fbB6D76718271', |     [EthereumNetwork.ropsten]: ZERO_ADDRESS, | ||||||
|     [EthereumNetwork.main]: ZERO_ADDRESS, |     [EthereumNetwork.main]: ZERO_ADDRESS, | ||||||
|     [EthereumNetwork.tenderlyMain]: ZERO_ADDRESS, |     [EthereumNetwork.tenderlyMain]: ZERO_ADDRESS, | ||||||
|   }, |   }, | ||||||
|  | @ -213,7 +200,6 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|       MANA: '0x1b93D8E109cfeDcBb3Cc74eD761DE286d5771511', |       MANA: '0x1b93D8E109cfeDcBb3Cc74eD761DE286d5771511', | ||||||
|       MKR: '0x0B156192e04bAD92B6C1C13cf8739d14D78D5701', |       MKR: '0x0B156192e04bAD92B6C1C13cf8739d14D78D5701', | ||||||
|       REN: '0xF1939BECE7708382b5fb5e559f630CB8B39a10ee', |       REN: '0xF1939BECE7708382b5fb5e559f630CB8B39a10ee', | ||||||
|       REP: '0x3A7e6117F2979EFf81855de32819FBba48a63e9e', |  | ||||||
|       SNX: '0xF9A76ae7a1075Fe7d646b06fF05Bd48b9FA5582e', |       SNX: '0xF9A76ae7a1075Fe7d646b06fF05Bd48b9FA5582e', | ||||||
|       SUSD: '0xb343e7a1aF578FA35632435243D814e7497622f7', |       SUSD: '0xb343e7a1aF578FA35632435243D814e7497622f7', | ||||||
|       TUSD: '0x7aeCF1c19661d12E962b69eBC8f6b2E63a55C660', |       TUSD: '0x7aeCF1c19661d12E962b69eBC8f6b2E63a55C660', | ||||||
|  | @ -224,12 +210,6 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|       YFI: '0xC5d1B1DEb2992738C0273408ac43e1e906086B6C', |       YFI: '0xC5d1B1DEb2992738C0273408ac43e1e906086B6C', | ||||||
|       ZRX: '0xBc3f28Ccc21E9b5856E81E6372aFf57307E2E883', |       ZRX: '0xBc3f28Ccc21E9b5856E81E6372aFf57307E2E883', | ||||||
|       USD: '0x9326BFA02ADD2366b30bacB125260Af641031331', |       USD: '0x9326BFA02ADD2366b30bacB125260Af641031331', | ||||||
|       UNI_DAI_ETH: '0x0338C40020Bf886c11406115fD1ba205Ef1D9Ff9', |  | ||||||
|       UNI_LEND_ETH: '0xB996b1a11BA0aACc4deA57f7f92d1722428f2E90', |  | ||||||
|       UNI_LINK_ETH: '0x267490eE9Ad21dfE839aE73A8B1c8C9A36F60d33', |  | ||||||
|       UNI_MKR_ETH: '0x6eBF25AB0A18B8F6243619f1AE6b94373169A069', |  | ||||||
|       UNI_SETH_ETH: '0xc5F1eA001c1570783b3af418fa775237Eb129EDC', |  | ||||||
|       UNI_USDC_ETH: '0x7f5E5D34591e9a70D187BBA94260C30B92aC0961', |  | ||||||
|     }, |     }, | ||||||
|     [EthereumNetwork.ropsten]: { |     [EthereumNetwork.ropsten]: { | ||||||
|       AAVE: ZERO_ADDRESS, |       AAVE: ZERO_ADDRESS, | ||||||
|  | @ -242,7 +222,6 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|       MANA: '0xDab909dedB72573c626481fC98CEE1152b81DEC2', |       MANA: '0xDab909dedB72573c626481fC98CEE1152b81DEC2', | ||||||
|       MKR: '0x811B1f727F8F4aE899774B568d2e72916D91F392', |       MKR: '0x811B1f727F8F4aE899774B568d2e72916D91F392', | ||||||
|       REN: ZERO_ADDRESS, |       REN: ZERO_ADDRESS, | ||||||
|       REP: '0xa949ee9ba80c0f381481f2eab538bc5547a5ac67', |  | ||||||
|       SNX: '0xA95674a8Ed9aa9D2E445eb0024a9aa05ab44f6bf', |       SNX: '0xA95674a8Ed9aa9D2E445eb0024a9aa05ab44f6bf', | ||||||
|       SUSD: '0xe054b4aee7ac7645642dd52f1c892ff0128c98f0', |       SUSD: '0xe054b4aee7ac7645642dd52f1c892ff0128c98f0', | ||||||
|       TUSD: '0x523ac85618df56e940534443125ef16daf785620', |       TUSD: '0x523ac85618df56e940534443125ef16daf785620', | ||||||
|  | @ -252,71 +231,51 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|       WBTC: '0x5b8B87A0abA4be247e660B0e0143bB30Cdf566AF', |       WBTC: '0x5b8B87A0abA4be247e660B0e0143bB30Cdf566AF', | ||||||
|       YFI: ZERO_ADDRESS, |       YFI: ZERO_ADDRESS, | ||||||
|       ZRX: '0x1d0052e4ae5b4ae4563cbac50edc3627ca0460d7', |       ZRX: '0x1d0052e4ae5b4ae4563cbac50edc3627ca0460d7', | ||||||
|       UNI_DAI_ETH: '0x16048819e3f77b7112eB033624A0bA9d33743028', |  | ||||||
|       UNI_LEND_ETH: '0x43c44B27376Afedee06Bae2A003e979FC3B3Da6C', |  | ||||||
|       UNI_LINK_ETH: '0xb60c29714146EA3539261f599Eb30f62904108Fa', |  | ||||||
|       UNI_MKR_ETH: '0x594ae5421f378b8B4AF9e758C461d2A1FF990BC5', |  | ||||||
|       UNI_SETH_ETH: '0x23Ee5188806BD2D31103368B0EA0259bc6706Af1', |  | ||||||
|       UNI_USDC_ETH: '0x6952A2678D574073DB97963886c2F38CD09C8Ba3', |  | ||||||
|       USD: '0x8468b2bDCE073A157E560AA4D9CcF6dB1DB98507', |       USD: '0x8468b2bDCE073A157E560AA4D9CcF6dB1DB98507', | ||||||
|     }, |     }, | ||||||
|     [EthereumNetwork.main]: { |     [EthereumNetwork.main]: { | ||||||
|       AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012', |       AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012', | ||||||
|       BAT: '0x9b4e2579895efa2b4765063310Dc4109a7641129', |       BAT: '0x0d16d4528239e9ee52fa531af613AcdB23D88c94', | ||||||
|       BUSD: '0x5d4BB541EED49D0290730b4aB332aA46bd27d888', |       BUSD: '0x614715d2Af89E6EC99A233818275142cE88d1Cfd', | ||||||
|       DAI: '0x037E8F2125bF532F3e228991e051c8A7253B642c', |       DAI: '0x773616E4d11A78F511299002da57A0a94577F1f4', | ||||||
|       ENJ: '0x24D9aB51950F3d62E9144fdC2f3135DAA6Ce8D1B', |       ENJ: '0x24D9aB51950F3d62E9144fdC2f3135DAA6Ce8D1B', | ||||||
|       KNC: '0xd0e785973390fF8E77a83961efDb4F271E6B8152', |       KNC: '0x656c0544eF4C98A6a98491833A89204Abb045d6b', | ||||||
|       LINK: '0xeCfA53A8bdA4F0c4dd39c55CC8deF3757aCFDD07', |       LINK: '0xDC530D9457755926550b59e8ECcdaE7624181557', | ||||||
|       MANA: '0xc89c4ed8f52Bb17314022f6c0dCB26210C905C97', |       MANA: '0x82A44D92D6c329826dc557c5E1Be6ebeC5D5FeB9', | ||||||
|       MKR: '0xda3d675d50ff6c555973c4f0424964e1f6a4e7d3', |       MKR: '0x24551a8Fb2A7211A25a17B1481f043A8a8adC7f2', | ||||||
|       REN: '0x3147D7203354Dc06D9fd350c7a2437bcA92387a4', |       REN: '0x3147D7203354Dc06D9fd350c7a2437bcA92387a4', | ||||||
|       REP: '0xb8b513d9cf440C1b6f5C7142120d611C94fC220c', |       SNX: '0x79291A9d692Df95334B1a0B3B4AE6bC606782f8c', | ||||||
|       SNX: '0xE23d1142dE4E83C08bb048bcab54d50907390828', |       SUSD: '0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757', | ||||||
|       SUSD: '0x6d626Ff97f0E89F6f983dE425dc5B24A18DE26Ea', |       TUSD: '0x3886BA987236181D98F2401c507Fb8BeA7871dF2', | ||||||
|       TUSD: '0x73ead35fd6A572EF763B13Be65a9db96f7643577', |  | ||||||
|       UNI: '0xD6aA3D25116d8dA79Ea0246c4826EB951872e02e', |       UNI: '0xD6aA3D25116d8dA79Ea0246c4826EB951872e02e', | ||||||
|       USDC: '0xdE54467873c3BCAA76421061036053e371721708', |       USDC: '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4', | ||||||
|       USDT: '0xa874fe207DF445ff19E7482C746C4D3fD0CB9AcE', |       USDT: '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46', | ||||||
|       WBTC: '0x0133Aa47B6197D0BA090Bf2CD96626Eb71fFd13c', |       WBTC: '0xdeb288F737066589598e9214E782fa5A8eD689e8', | ||||||
|       YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4', |       YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4', | ||||||
|       ZRX: '0xA0F9D94f060836756FFC84Db4C78d097cA8C23E8', |       ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962', | ||||||
|       UNI_DAI_ETH: '0x1bAB293850289Bf161C5DA79ff3d1F02A950555b', |       USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', | ||||||
|       UNI_LEND_ETH: '0xF4C8Db2d999b024bBB6c6022566503eD41f2AC1E', |  | ||||||
|       UNI_LINK_ETH: '0xE2A639Beb647d7F709ca805ABa760bBEfdbE37e3', |  | ||||||
|       UNI_MKR_ETH: '0xEe40a5E8F3732bE6ECDb5A90e23D0b7bF0D4a73c', |  | ||||||
|       UNI_SETH_ETH: '0x517D40E49660c7705b2e99eEFA6d7B0E9Ba5BF10', |  | ||||||
|       UNI_USDC_ETH: '0x444315Ee92F2bb3579293C17B07194227fA99bF0', |  | ||||||
|       USD: '0x59b826c214aBa7125bFA52970d97736c105Cc375', |  | ||||||
|     }, |     }, | ||||||
|     [EthereumNetwork.tenderlyMain]: { |     [EthereumNetwork.tenderlyMain]: { | ||||||
|       AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012', |       AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012', | ||||||
|       BAT: '0x9b4e2579895efa2b4765063310Dc4109a7641129', |       BAT: '0x0d16d4528239e9ee52fa531af613AcdB23D88c94', | ||||||
|       BUSD: '0x5d4BB541EED49D0290730b4aB332aA46bd27d888', |       BUSD: '0x614715d2Af89E6EC99A233818275142cE88d1Cfd', | ||||||
|       DAI: '0x037E8F2125bF532F3e228991e051c8A7253B642c', |       DAI: '0x773616E4d11A78F511299002da57A0a94577F1f4', | ||||||
|       ENJ: '0x24D9aB51950F3d62E9144fdC2f3135DAA6Ce8D1B', |       ENJ: '0x24D9aB51950F3d62E9144fdC2f3135DAA6Ce8D1B', | ||||||
|       KNC: '0xd0e785973390fF8E77a83961efDb4F271E6B8152', |       KNC: '0x656c0544eF4C98A6a98491833A89204Abb045d6b', | ||||||
|       LINK: '0xeCfA53A8bdA4F0c4dd39c55CC8deF3757aCFDD07', |       LINK: '0xDC530D9457755926550b59e8ECcdaE7624181557', | ||||||
|       MANA: '0xc89c4ed8f52Bb17314022f6c0dCB26210C905C97', |       MANA: '0x82A44D92D6c329826dc557c5E1Be6ebeC5D5FeB9', | ||||||
|       MKR: '0xda3d675d50ff6c555973c4f0424964e1f6a4e7d3', |       MKR: '0x24551a8Fb2A7211A25a17B1481f043A8a8adC7f2', | ||||||
|       REN: '0x3147D7203354Dc06D9fd350c7a2437bcA92387a4', |       REN: '0x3147D7203354Dc06D9fd350c7a2437bcA92387a4', | ||||||
|       REP: '0xb8b513d9cf440C1b6f5C7142120d611C94fC220c', |       SNX: '0x79291A9d692Df95334B1a0B3B4AE6bC606782f8c', | ||||||
|       SNX: '0xE23d1142dE4E83C08bb048bcab54d50907390828', |       SUSD: '0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757', | ||||||
|       SUSD: '0x6d626Ff97f0E89F6f983dE425dc5B24A18DE26Ea', |       TUSD: '0x3886BA987236181D98F2401c507Fb8BeA7871dF2', | ||||||
|       TUSD: '0x73ead35fd6A572EF763B13Be65a9db96f7643577', |  | ||||||
|       UNI: '0xD6aA3D25116d8dA79Ea0246c4826EB951872e02e', |       UNI: '0xD6aA3D25116d8dA79Ea0246c4826EB951872e02e', | ||||||
|       USDC: '0xdE54467873c3BCAA76421061036053e371721708', |       USDC: '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4', | ||||||
|       USDT: '0xa874fe207DF445ff19E7482C746C4D3fD0CB9AcE', |       USDT: '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46', | ||||||
|       WBTC: '0x0133Aa47B6197D0BA090Bf2CD96626Eb71fFd13c', |       WBTC: '0xdeb288F737066589598e9214E782fa5A8eD689e8', | ||||||
|       YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4', |       YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4', | ||||||
|       ZRX: '0xA0F9D94f060836756FFC84Db4C78d097cA8C23E8', |       ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962', | ||||||
|       UNI_DAI_ETH: '0x1bAB293850289Bf161C5DA79ff3d1F02A950555b', |       USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', | ||||||
|       UNI_LEND_ETH: '0xF4C8Db2d999b024bBB6c6022566503eD41f2AC1E', |  | ||||||
|       UNI_LINK_ETH: '0xE2A639Beb647d7F709ca805ABa760bBEfdbE37e3', |  | ||||||
|       UNI_MKR_ETH: '0xEe40a5E8F3732bE6ECDb5A90e23D0b7bF0D4a73c', |  | ||||||
|       UNI_SETH_ETH: '0x517D40E49660c7705b2e99eEFA6d7B0E9Ba5BF10', |  | ||||||
|       UNI_USDC_ETH: '0x444315Ee92F2bb3579293C17B07194227fA99bF0', |  | ||||||
|       USD: '0x59b826c214aBa7125bFA52970d97736c105Cc375', |  | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|   ReserveAssets: { |   ReserveAssets: { | ||||||
|  | @ -333,23 +292,14 @@ export const CommonsConfig: ICommonConfiguration = { | ||||||
|     [eEthereumNetwork.coverage]: |     [eEthereumNetwork.coverage]: | ||||||
|       '0x95b73a72c6ecf4ccbbba5178800023260bad8e75cdccdb8e4827a2977a37c820', |       '0x95b73a72c6ecf4ccbbba5178800023260bad8e75cdccdb8e4827a2977a37c820', | ||||||
|     [eEthereumNetwork.hardhat]: |     [eEthereumNetwork.hardhat]: | ||||||
|       '0xa14895ab432a9d0712a041fdcea77f7f65826945dc90bf29ea819c2a01e7c5f9', |       '0xbae024d959c6a022dc5ed37294cd39c141034b2ae5f02a955cce75c930a81bf5', | ||||||
|     [eEthereumNetwork.buidlerevm]: |     [eEthereumNetwork.buidlerevm]: | ||||||
|       '0xa14895ab432a9d0712a041fdcea77f7f65826945dc90bf29ea819c2a01e7c5f9', |       '0xbae024d959c6a022dc5ed37294cd39c141034b2ae5f02a955cce75c930a81bf5', | ||||||
|     [eEthereumNetwork.kovan]: '', |     [eEthereumNetwork.kovan]: '', | ||||||
|     [eEthereumNetwork.ropsten]: '', |     [eEthereumNetwork.ropsten]: '', | ||||||
|     [eEthereumNetwork.main]: '', |     [eEthereumNetwork.main]: '', | ||||||
|     [eEthereumNetwork.tenderlyMain]: '', |     [eEthereumNetwork.tenderlyMain]: '', | ||||||
|   }, |   }, | ||||||
|   ProxyPriceProvider: { |  | ||||||
|     [eEthereumNetwork.coverage]: '', |  | ||||||
|     [eEthereumNetwork.hardhat]: '', |  | ||||||
|     [eEthereumNetwork.buidlerevm]: '', |  | ||||||
|     [eEthereumNetwork.kovan]: '0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1', |  | ||||||
|     [eEthereumNetwork.ropsten]: '', |  | ||||||
|     [eEthereumNetwork.main]: '', |  | ||||||
|     [eEthereumNetwork.tenderlyMain]: '', |  | ||||||
|   }, |  | ||||||
|   WETH: { |   WETH: { | ||||||
|     [eEthereumNetwork.coverage]: '', // deployed in local evm
 |     [eEthereumNetwork.coverage]: '', // deployed in local evm
 | ||||||
|     [eEthereumNetwork.hardhat]: '', // deployed in local evm
 |     [eEthereumNetwork.hardhat]: '', // deployed in local evm
 | ||||||
|  |  | ||||||
|  | @ -16,7 +16,6 @@ import { | ||||||
|   strategyMANA, |   strategyMANA, | ||||||
|   strategyMKR, |   strategyMKR, | ||||||
|   strategyREN, |   strategyREN, | ||||||
|   strategyREP, |  | ||||||
|   strategySNX, |   strategySNX, | ||||||
|   strategyUNI, |   strategyUNI, | ||||||
|   strategyWBTC, |   strategyWBTC, | ||||||
|  | @ -43,7 +42,6 @@ export const AaveConfig: IAaveConfiguration = { | ||||||
|     MANA: strategyMANA, |     MANA: strategyMANA, | ||||||
|     MKR: strategyMKR, |     MKR: strategyMKR, | ||||||
|     REN: strategyREN, |     REN: strategyREN, | ||||||
|     REP: strategyREP, |  | ||||||
|     SNX: strategySNX, |     SNX: strategySNX, | ||||||
|     SUSD: stablecoinStrategySUSD, |     SUSD: stablecoinStrategySUSD, | ||||||
|     TUSD: stablecoinStrategyTUSD, |     TUSD: stablecoinStrategyTUSD, | ||||||
|  | @ -70,7 +68,6 @@ export const AaveConfig: IAaveConfiguration = { | ||||||
|       MANA: '0x738Dc6380157429e957d223e6333Dc385c85Fec7', |       MANA: '0x738Dc6380157429e957d223e6333Dc385c85Fec7', | ||||||
|       MKR: '0x61e4CAE3DA7FD189e52a4879C7B8067D7C2Cc0FA', |       MKR: '0x61e4CAE3DA7FD189e52a4879C7B8067D7C2Cc0FA', | ||||||
|       REN: '0x5eebf65A6746eed38042353Ba84c8e37eD58Ac6f', |       REN: '0x5eebf65A6746eed38042353Ba84c8e37eD58Ac6f', | ||||||
|       REP: '0x260071C8D61DAf730758f8BD0d6370353956AE0E', |  | ||||||
|       SNX: '0x7FDb81B0b8a010dd4FFc57C3fecbf145BA8Bd947', |       SNX: '0x7FDb81B0b8a010dd4FFc57C3fecbf145BA8Bd947', | ||||||
|       SUSD: '0x99b267b9D96616f906D53c26dECf3C5672401282', |       SUSD: '0x99b267b9D96616f906D53c26dECf3C5672401282', | ||||||
|       TUSD: '0x016750AC630F711882812f24Dba6c95b9D35856d', |       TUSD: '0x016750AC630F711882812f24Dba6c95b9D35856d', | ||||||
|  | @ -93,7 +90,6 @@ export const AaveConfig: IAaveConfiguration = { | ||||||
|       MANA: '0x78b1F763857C8645E46eAdD9540882905ff32Db7', |       MANA: '0x78b1F763857C8645E46eAdD9540882905ff32Db7', | ||||||
|       MKR: '0x2eA9df3bABe04451c9C3B06a2c844587c59d9C37', |       MKR: '0x2eA9df3bABe04451c9C3B06a2c844587c59d9C37', | ||||||
|       REN: ZERO_ADDRESS, |       REN: ZERO_ADDRESS, | ||||||
|       REP: '0xBeb13523503d35F9b3708ca577CdCCAdbFB236bD', |  | ||||||
|       SNX: '0xF80Aa7e2Fda4DA065C55B8061767F729dA1476c7', |       SNX: '0xF80Aa7e2Fda4DA065C55B8061767F729dA1476c7', | ||||||
|       SUSD: '0xc374eB17f665914c714Ac4cdC8AF3a3474228cc5', |       SUSD: '0xc374eB17f665914c714Ac4cdC8AF3a3474228cc5', | ||||||
|       TUSD: '0xa2EA00Df6d8594DBc76b79beFe22db9043b8896F', |       TUSD: '0xa2EA00Df6d8594DBc76b79beFe22db9043b8896F', | ||||||
|  | @ -109,47 +105,45 @@ export const AaveConfig: IAaveConfiguration = { | ||||||
|       AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9', |       AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9', | ||||||
|       BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef', |       BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef', | ||||||
|       BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53', |       BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53', | ||||||
|       DAI: '0x6b175474e89094c44da98b954eedeac495271d0f', |       DAI: '0x6B175474E89094C44Da98b954EedeAC495271d0F', | ||||||
|       ENJ: '0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c', |       ENJ: '0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c', | ||||||
|       KNC: '0xdd974d5c2e2928dea5f71b9825b8b646686bd200', |       KNC: '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', | ||||||
|       LINK: '0x514910771af9ca656af840dff83e8264ecf986ca', |       LINK: '0x514910771AF9Ca656af840dff83E8264EcF986CA', | ||||||
|       MANA: '0x0f5d2fb29fb7d3cfee444a200298f468908cc942', |       MANA: '0x0F5D2fB29fb7d3CFeE444a200298f468908cC942', | ||||||
|       MKR: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2', |       MKR: '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2', | ||||||
|       REN: '0x408e41876cCCDC0F92210600ef50372656052a38', |       REN: '0x408e41876cCCDC0F92210600ef50372656052a38', | ||||||
|       REP: '0x1985365e9f78359a9B6AD760e32412f4a445E862', |  | ||||||
|       SNX: '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F', |       SNX: '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F', | ||||||
|       SUSD: '0x57ab1ec28d129707052df4df418d58a2d46d5f51', |       SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51', | ||||||
|       TUSD: '0x0000000000085d4780B73119b644AE5ecd22b376', |       TUSD: '0x0000000000085d4780B73119b644AE5ecd22b376', | ||||||
|       UNI: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984', |       UNI: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984', | ||||||
|       USDC: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', |       USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', | ||||||
|       USDT: '0xdac17f958d2ee523a2206206994597c13d831ec7', |       USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', | ||||||
|       WBTC: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', |       WBTC: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', | ||||||
|       WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', |       WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', | ||||||
|       YFI: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', |       YFI: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', | ||||||
|       ZRX: '0xe41d2489571d322189246dafa5ebde1f4699f498', |       ZRX: '0xE41d2489571d322189246DaFA5ebDe1F4699F498', | ||||||
|     }, |     }, | ||||||
|     [EthereumNetwork.tenderlyMain]: { |     [EthereumNetwork.tenderlyMain]: { | ||||||
|       AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9', |       AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9', | ||||||
|       BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef', |       BAT: '0x0d8775f648430679a709e98d2b0cb6250d2887ef', | ||||||
|       BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53', |       BUSD: '0x4Fabb145d64652a948d72533023f6E7A623C7C53', | ||||||
|       DAI: '0x6b175474e89094c44da98b954eedeac495271d0f', |       DAI: '0x6B175474E89094C44Da98b954EedeAC495271d0F', | ||||||
|       ENJ: '0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c', |       ENJ: '0xF629cBd94d3791C9250152BD8dfBDF380E2a3B9c', | ||||||
|       KNC: '0xdd974d5c2e2928dea5f71b9825b8b646686bd200', |       KNC: '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', | ||||||
|       LINK: '0x514910771af9ca656af840dff83e8264ecf986ca', |       LINK: '0x514910771AF9Ca656af840dff83E8264EcF986CA', | ||||||
|       MANA: '0x0f5d2fb29fb7d3cfee444a200298f468908cc942', |       MANA: '0x0F5D2fB29fb7d3CFeE444a200298f468908cC942', | ||||||
|       MKR: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2', |       MKR: '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2', | ||||||
|       REN: '0x408e41876cCCDC0F92210600ef50372656052a38', |       REN: '0x408e41876cCCDC0F92210600ef50372656052a38', | ||||||
|       REP: '0x1985365e9f78359a9B6AD760e32412f4a445E862', |  | ||||||
|       SNX: '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F', |       SNX: '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F', | ||||||
|       SUSD: '0x57ab1ec28d129707052df4df418d58a2d46d5f51', |       SUSD: '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51', | ||||||
|       TUSD: '0x0000000000085d4780B73119b644AE5ecd22b376', |       TUSD: '0x0000000000085d4780B73119b644AE5ecd22b376', | ||||||
|       UNI: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984', |       UNI: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984', | ||||||
|       USDC: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', |       USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', | ||||||
|       USDT: '0xdac17f958d2ee523a2206206994597c13d831ec7', |       USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', | ||||||
|       WBTC: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', |       WBTC: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', | ||||||
|       WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', |       WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', | ||||||
|       YFI: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', |       YFI: '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', | ||||||
|       ZRX: '0xe41d2489571d322189246dafa5ebde1f4699f498', |       ZRX: '0xE41d2489571d322189246DaFA5ebDe1F4699F498', | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -116,14 +116,6 @@ export const strategyREN: IReserveParams = { | ||||||
|   stableBorrowRateEnabled: false, |   stableBorrowRateEnabled: false, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const strategyREP: IReserveParams = { |  | ||||||
|   ...strategyBase, |  | ||||||
|   baseLTVAsCollateral: '3500', |  | ||||||
|   variableRateSlope1: new BigNumber(0.07).multipliedBy(oneRay).toFixed(), |  | ||||||
|   variableRateSlope2: new BigNumber(3).multipliedBy(oneRay).toFixed(), |  | ||||||
|   borrowingEnabled: true, |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| export const stablecoinStrategySUSD: IReserveParams = { | export const stablecoinStrategySUSD: IReserveParams = { | ||||||
|   baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), |   baseVariableBorrowRate: new BigNumber(0.01).multipliedBy(oneRay).toFixed(), | ||||||
|   variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), |   variableRateSlope1: new BigNumber(0.04).multipliedBy(oneRay).toFixed(), | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								modules/tenderly/tenderly.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								modules/tenderly/tenderly.d.ts
									
									
									
									
										vendored
									
									
								
							|  | @ -1,26 +1,7 @@ | ||||||
| import 'hardhat/types/config'; | import 'hardhat/types/config'; | ||||||
| import 'hardhat/types/runtime'; | import 'hardhat/types/runtime'; | ||||||
| 
 | 
 | ||||||
| import {TenderlyConfig} from './types'; | import { TenderlyConfig } from './types'; | ||||||
| 
 |  | ||||||
| declare module 'hardhat/types/runtime' { |  | ||||||
|   export interface HardhatRuntimeEnvironment { |  | ||||||
|     tenderly: { |  | ||||||
|       verify: (...contracts) => Promise<void>; |  | ||||||
|       push: (...contracts) => Promise<void>; |  | ||||||
|       persistArtifacts: (...contracts) => Promise<void>; |  | ||||||
|     }; |  | ||||||
|     tenderlyRPC: { |  | ||||||
|       verify: (...contracts) => Promise<void>; |  | ||||||
|       resetFork: () => string | undefined; |  | ||||||
|       getHead: () => string | undefined; |  | ||||||
|       setHead: (head: string | undefined) => void; |  | ||||||
|       getFork: () => string | undefined; |  | ||||||
|       setFork: (fork: string | undefined) => void; |  | ||||||
|     }; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| declare module 'hardhat/types/config' { | declare module 'hardhat/types/config' { | ||||||
|   export interface HardhatUserConfig { |   export interface HardhatUserConfig { | ||||||
|     tenderly?: TenderlyConfig; |     tenderly?: TenderlyConfig; | ||||||
|  |  | ||||||
							
								
								
									
										10880
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10880
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										12
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								package.json
									
									
									
									
									
								
							|  | @ -34,7 +34,7 @@ | ||||||
|     "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave", |     "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave", | ||||||
|     "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify", |     "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify", | ||||||
|     "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet", |     "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet", | ||||||
|     "aave:fork:main": "MAINNET_FORK=true npm run compile && hardhat aave:mainnet", |     "aave:fork:main": "npm run compile && MAINNET_FORK=true  hardhat aave:mainnet", | ||||||
|     "aave:main:full:migration": "npm run hardhat:main -- aave:mainnet --verify", |     "aave:main:full:migration": "npm run hardhat:main -- aave:mainnet --verify", | ||||||
|     "dev:prettier": "prettier --write .", |     "dev:prettier": "prettier --write .", | ||||||
|     "ci:test": "npm run compile && npm run test", |     "ci:test": "npm run compile && npm run test", | ||||||
|  | @ -60,7 +60,7 @@ | ||||||
|     "@openzeppelin/contracts": "3.1.0", |     "@openzeppelin/contracts": "3.1.0", | ||||||
|     "@tenderly/hardhat-tenderly": "^1.1.0-beta.3", |     "@tenderly/hardhat-tenderly": "^1.1.0-beta.3", | ||||||
|     "@typechain/ethers-v4": "1.0.0", |     "@typechain/ethers-v4": "1.0.0", | ||||||
|     "@typechain/ethers-v5": "^1.0.0", |     "@typechain/ethers-v5": "^2.0.0", | ||||||
|     "@typechain/truffle-v4": "2.0.2", |     "@typechain/truffle-v4": "2.0.2", | ||||||
|     "@typechain/truffle-v5": "2.0.2", |     "@typechain/truffle-v5": "2.0.2", | ||||||
|     "@typechain/web3-v1": "1.0.0", |     "@typechain/web3-v1": "1.0.0", | ||||||
|  | @ -77,7 +77,7 @@ | ||||||
|     "eth-sig-util": "2.5.3", |     "eth-sig-util": "2.5.3", | ||||||
|     "ethereum-waffle": "3.0.2", |     "ethereum-waffle": "3.0.2", | ||||||
|     "ethereumjs-util": "7.0.2", |     "ethereumjs-util": "7.0.2", | ||||||
|     "ethers": "5.0.8", |     "ethers": "^5.0.19", | ||||||
|     "globby": "^11.0.1", |     "globby": "^11.0.1", | ||||||
|     "hardhat": "^2.0.2", |     "hardhat": "^2.0.2", | ||||||
|     "hardhat-gas-reporter": "^1.0.0", |     "hardhat-gas-reporter": "^1.0.0", | ||||||
|  | @ -89,13 +89,13 @@ | ||||||
|     "pretty-quick": "^2.0.1", |     "pretty-quick": "^2.0.1", | ||||||
|     "solidity-coverage": "0.7.10", |     "solidity-coverage": "0.7.10", | ||||||
|     "temp-hardhat-etherscan": "^2.0.2", |     "temp-hardhat-etherscan": "^2.0.2", | ||||||
|     "ts-generator": "0.0.8", |     "ts-generator": "^0.1.1", | ||||||
|     "ts-node": "^8.10.2", |     "ts-node": "^8.10.2", | ||||||
|     "tslint": "^6.1.2", |     "tslint": "^6.1.2", | ||||||
|     "tslint-config-prettier": "^1.18.0", |     "tslint-config-prettier": "^1.18.0", | ||||||
|     "tslint-plugin-prettier": "^2.3.0", |     "tslint-plugin-prettier": "^2.3.0", | ||||||
|     "typechain": "2.0.0", |     "typechain": "^4.0.0", | ||||||
|     "typescript": "^3.9.3" |     "typescript": "^4.0.5" | ||||||
|   }, |   }, | ||||||
|   "husky": { |   "husky": { | ||||||
|     "hooks": { |     "hooks": { | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|     await localBRE.run('set-DRE'); |     await localBRE.run('set-DRE'); | ||||||
|     const poolConfig = loadPoolConfig(pool); |     const poolConfig = loadPoolConfig(pool); | ||||||
|     const { |     const { | ||||||
|       Mocks: {ChainlinkAggregatorPrices, AllAssetsInitialPrices}, |       Mocks: {AllAssetsInitialPrices}, | ||||||
|       ProtocolGlobalParams: {UsdAddress, MockUsdPriceInWei}, |       ProtocolGlobalParams: {UsdAddress, MockUsdPriceInWei}, | ||||||
|       LendingRateOracleRatesCommon, |       LendingRateOracleRatesCommon, | ||||||
|     } = poolConfig as ICommonConfiguration; |     } = poolConfig as ICommonConfiguration; | ||||||
|  | @ -48,7 +48,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|     await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei)); |     await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei)); | ||||||
|     await setInitialAssetPricesInOracle(AllAssetsInitialPrices, mockTokensAddress, fallbackOracle); |     await setInitialAssetPricesInOracle(AllAssetsInitialPrices, mockTokensAddress, fallbackOracle); | ||||||
| 
 | 
 | ||||||
|     const mockAggregators = await deployAllMockAggregators(ChainlinkAggregatorPrices, verify); |     const mockAggregators = await deployAllMockAggregators(AllAssetsInitialPrices, verify); | ||||||
| 
 | 
 | ||||||
|     const allTokenAddresses = getAllTokenAddresses(mockTokens); |     const allTokenAddresses = getAllTokenAddresses(mockTokens); | ||||||
|     const allAggregatorsAddresses = getAllAggregatorsAddresses(mockAggregators); |     const allAggregatorsAddresses = getAllAggregatorsAddresses(mockAggregators); | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import {task} from 'hardhat/config'; | import {task} from 'hardhat/config'; | ||||||
| import {getEthersSignersAddresses, getParamPerNetwork} from '../../helpers/contracts-helpers'; | import {getParamPerNetwork} from '../../helpers/contracts-helpers'; | ||||||
| import { | import { | ||||||
|   deployLendingPoolAddressesProvider, |   deployLendingPoolAddressesProvider, | ||||||
|   deployLendingPoolAddressesProviderRegistry, |   deployLendingPoolAddressesProviderRegistry, | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| import {task} from 'hardhat/config'; | import { task } from 'hardhat/config'; | ||||||
| import {getEthersSignersAddresses, getParamPerNetwork} from '../../helpers/contracts-helpers'; | import { getParamPerNetwork } from '../../helpers/contracts-helpers'; | ||||||
| import {deployAaveOracle, deployLendingRateOracle} from '../../helpers/contracts-deployments'; | import { deployAaveOracle, deployLendingRateOracle } from '../../helpers/contracts-deployments'; | ||||||
| import {setInitialMarketRatesInRatesOracleByHelper} from '../../helpers/oracles-helpers'; | import { setInitialMarketRatesInRatesOracleByHelper } from '../../helpers/oracles-helpers'; | ||||||
| import {ICommonConfiguration, eEthereumNetwork, SymbolMap} from '../../helpers/types'; | import { ICommonConfiguration, eEthereumNetwork, SymbolMap } from '../../helpers/types'; | ||||||
| import {waitForTx, filterMapBy, notFalsyOrZeroAddress} from '../../helpers/misc-utils'; | import { waitForTx, notFalsyOrZeroAddress } from '../../helpers/misc-utils'; | ||||||
| import { | import { | ||||||
|   ConfigNames, |   ConfigNames, | ||||||
|   loadPoolConfig, |   loadPoolConfig, | ||||||
|  | @ -11,9 +11,8 @@ import { | ||||||
|   getGenesisPoolAdmin, |   getGenesisPoolAdmin, | ||||||
|   getLendingRateOracles, |   getLendingRateOracles, | ||||||
| } from '../../helpers/configuration'; | } from '../../helpers/configuration'; | ||||||
| import {exit} from 'process'; |  | ||||||
| import { | import { | ||||||
|   getChainlinkPriceProvider, |   getAaveOracle, | ||||||
|   getLendingPoolAddressesProvider, |   getLendingPoolAddressesProvider, | ||||||
|   getLendingRateOracle, |   getLendingRateOracle, | ||||||
|   getPairsTokenAggregator, |   getPairsTokenAggregator, | ||||||
|  | @ -22,13 +21,13 @@ import { | ||||||
| task('full:deploy-oracles', 'Deploy oracles for dev enviroment') | task('full:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|   .addFlag('verify', 'Verify contracts at Etherscan') |   .addFlag('verify', 'Verify contracts at Etherscan') | ||||||
|   .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) |   .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) | ||||||
|   .setAction(async ({verify, pool}, DRE) => { |   .setAction(async ({ verify, pool }, DRE) => { | ||||||
|     try { |     try { | ||||||
|       await DRE.run('set-DRE'); |       await DRE.run('set-DRE'); | ||||||
|       const network = <eEthereumNetwork>DRE.network.name; |       const network = <eEthereumNetwork>DRE.network.name; | ||||||
|       const poolConfig = loadPoolConfig(pool); |       const poolConfig = loadPoolConfig(pool); | ||||||
|       const { |       const { | ||||||
|         ProtocolGlobalParams: {UsdAddress}, |         ProtocolGlobalParams: { UsdAddress }, | ||||||
|         ReserveAssets, |         ReserveAssets, | ||||||
|         FallbackOracle, |         FallbackOracle, | ||||||
|         ChainlinkAggregator, |         ChainlinkAggregator, | ||||||
|  | @ -36,7 +35,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|       const lendingRateOracles = getLendingRateOracles(poolConfig); |       const lendingRateOracles = getLendingRateOracles(poolConfig); | ||||||
|       const addressesProvider = await getLendingPoolAddressesProvider(); |       const addressesProvider = await getLendingPoolAddressesProvider(); | ||||||
|       const admin = await getGenesisPoolAdmin(poolConfig); |       const admin = await getGenesisPoolAdmin(poolConfig); | ||||||
|       const proxyPriceProviderAddress = getParamPerNetwork(poolConfig.ProxyPriceProvider, network); |       const aaveOracleAddress = getParamPerNetwork(poolConfig.AaveOracle, network); | ||||||
|       const lendingRateOracleAddress = getParamPerNetwork(poolConfig.LendingRateOracle, network); |       const lendingRateOracleAddress = getParamPerNetwork(poolConfig.LendingRateOracle, network); | ||||||
|       const fallbackOracleAddress = await getParamPerNetwork(FallbackOracle, network); |       const fallbackOracleAddress = await getParamPerNetwork(FallbackOracle, network); | ||||||
|       const reserveAssets = await getParamPerNetwork(ReserveAssets, network); |       const reserveAssets = await getParamPerNetwork(ReserveAssets, network); | ||||||
|  | @ -48,8 +47,8 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|       }; |       }; | ||||||
|       const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators); |       const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators); | ||||||
| 
 | 
 | ||||||
|       const chainlinkProviderPriceProvider = notFalsyOrZeroAddress(proxyPriceProviderAddress) |       const aaveOracle = notFalsyOrZeroAddress(aaveOracleAddress) | ||||||
|         ? await getChainlinkPriceProvider(proxyPriceProviderAddress) |         ? await getAaveOracle(aaveOracleAddress) | ||||||
|         : await deployAaveOracle( |         : await deployAaveOracle( | ||||||
|             [tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)], |             [tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)], | ||||||
|             verify |             verify | ||||||
|  | @ -57,7 +56,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|       const lendingRateOracle = notFalsyOrZeroAddress(lendingRateOracleAddress) |       const lendingRateOracle = notFalsyOrZeroAddress(lendingRateOracleAddress) | ||||||
|         ? await getLendingRateOracle(lendingRateOracleAddress) |         ? await getLendingRateOracle(lendingRateOracleAddress) | ||||||
|         : await deployLendingRateOracle(verify); |         : await deployLendingRateOracle(verify); | ||||||
|       const {USD, ...tokensAddressesWithoutUsd} = tokensToWatch; |       const { USD, ...tokensAddressesWithoutUsd } = tokensToWatch; | ||||||
| 
 | 
 | ||||||
|       if (!lendingRateOracleAddress) { |       if (!lendingRateOracleAddress) { | ||||||
|         await setInitialMarketRatesInRatesOracleByHelper( |         await setInitialMarketRatesInRatesOracleByHelper( | ||||||
|  | @ -69,9 +68,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment') | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       // Register the proxy price provider on the addressesProvider
 |       // Register the proxy price provider on the addressesProvider
 | ||||||
|       await waitForTx( |       await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address)); | ||||||
|         await addressesProvider.setPriceOracle(chainlinkProviderPriceProvider.address) |  | ||||||
|       ); |  | ||||||
|       await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); |       await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); | ||||||
|     } catch (error) { |     } catch (error) { | ||||||
|       if (DRE.network.name.includes('tenderly')) { |       if (DRE.network.name.includes('tenderly')) { | ||||||
|  |  | ||||||
|  | @ -1,7 +1,5 @@ | ||||||
| import {ExternalProvider} from '@ethersproject/providers'; | import { task } from 'hardhat/config'; | ||||||
| 
 | import { setDRE } from '../../helpers/misc-utils'; | ||||||
| import {task} from 'hardhat/config'; |  | ||||||
| import {setDRE} from '../../helpers/misc-utils'; |  | ||||||
| 
 | 
 | ||||||
| task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction( | task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction( | ||||||
|   async (_, _DRE) => { |   async (_, _DRE) => { | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import rawBRE from 'hardhat'; | import rawBRE from 'hardhat'; | ||||||
| import {MockContract} from 'ethereum-waffle'; | import { MockContract } from 'ethereum-waffle'; | ||||||
| import { | import { | ||||||
|   insertContractAddressInDb, |   insertContractAddressInDb, | ||||||
|   getEthersSigners, |   getEthersSigners, | ||||||
|  | @ -26,43 +26,42 @@ import { | ||||||
|   deployUniswapLiquiditySwapAdapter, |   deployUniswapLiquiditySwapAdapter, | ||||||
|   deployUniswapRepayAdapter, |   deployUniswapRepayAdapter, | ||||||
| } from '../helpers/contracts-deployments'; | } from '../helpers/contracts-deployments'; | ||||||
| import {Signer} from 'ethers'; | import { Signer } from 'ethers'; | ||||||
| import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types'; | import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../helpers/types'; | ||||||
| import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; | import { MintableERC20 } from '../types/MintableERC20'; | ||||||
| import {getReservesConfigByPool} from '../helpers/configuration'; | import { getReservesConfigByPool } from '../helpers/configuration'; | ||||||
| import {initializeMakeSuite} from './helpers/make-suite'; | import { initializeMakeSuite } from './helpers/make-suite'; | ||||||
| 
 | 
 | ||||||
| import { | import { | ||||||
|   setInitialAssetPricesInOracle, |   setInitialAssetPricesInOracle, | ||||||
|   deployAllMockAggregators, |   deployAllMockAggregators, | ||||||
|   setInitialMarketRatesInRatesOracleByHelper, |   setInitialMarketRatesInRatesOracleByHelper, | ||||||
| } from '../helpers/oracles-helpers'; | } from '../helpers/oracles-helpers'; | ||||||
| import {DRE, waitForTx} from '../helpers/misc-utils'; | import { DRE, waitForTx } from '../helpers/misc-utils'; | ||||||
| import { | import { | ||||||
|   initReservesByHelper, |   initReservesByHelper, | ||||||
|   enableReservesToBorrowByHelper, |   enableReservesToBorrowByHelper, | ||||||
|   enableReservesAsCollateralByHelper, |   enableReservesAsCollateralByHelper, | ||||||
| } from '../helpers/init-helpers'; | } from '../helpers/init-helpers'; | ||||||
| import AaveConfig from '../markets/aave'; | import AaveConfig from '../markets/aave'; | ||||||
| import {ZERO_ADDRESS} from '../helpers/constants'; | import { ZERO_ADDRESS } from '../helpers/constants'; | ||||||
| import { | import { | ||||||
|   getLendingPool, |   getLendingPool, | ||||||
|   getLendingPoolConfiguratorProxy, |   getLendingPoolConfiguratorProxy, | ||||||
|   getPairsTokenAggregator, |   getPairsTokenAggregator, | ||||||
| } from '../helpers/contracts-getters'; | } from '../helpers/contracts-getters'; | ||||||
| import {Weth9Mocked} from '../types/Weth9Mocked'; | import { WETH9Mocked } from '../types/WETH9Mocked'; | ||||||
| 
 | 
 | ||||||
| const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei; | const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei; | ||||||
| const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices; | const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices; | ||||||
| const USD_ADDRESS = AaveConfig.ProtocolGlobalParams.UsdAddress; | const USD_ADDRESS = AaveConfig.ProtocolGlobalParams.UsdAddress; | ||||||
| const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig.Mocks.ChainlinkAggregatorPrices; | const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices; | ||||||
| const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig.LendingRateOracleRatesCommon; | const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig.LendingRateOracleRatesCommon; | ||||||
| 
 | 
 | ||||||
| const deployAllMockTokens = async (deployer: Signer) => { | const deployAllMockTokens = async (deployer: Signer) => { | ||||||
|   const tokens: {[symbol: string]: MockContract | MintableERC20 | Weth9Mocked} = {}; |   const tokens: { [symbol: string]: MockContract | MintableERC20 | WETH9Mocked } = {}; | ||||||
| 
 | 
 | ||||||
|   const protoConfigData = getReservesConfigByPool(AavePools.proto); |   const protoConfigData = getReservesConfigByPool(AavePools.proto); | ||||||
|   const secondaryConfigData = getReservesConfigByPool(AavePools.secondary); |  | ||||||
| 
 | 
 | ||||||
|   for (const tokenSymbol of Object.keys(TokenContractId)) { |   for (const tokenSymbol of Object.keys(TokenContractId)) { | ||||||
|     if (tokenSymbol === 'WETH') { |     if (tokenSymbol === 'WETH') { | ||||||
|  | @ -74,10 +73,6 @@ const deployAllMockTokens = async (deployer: Signer) => { | ||||||
| 
 | 
 | ||||||
|     let configData = (<any>protoConfigData)[tokenSymbol]; |     let configData = (<any>protoConfigData)[tokenSymbol]; | ||||||
| 
 | 
 | ||||||
|     if (!configData) { |  | ||||||
|       configData = (<any>secondaryConfigData)[tokenSymbol]; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (!configData) { |     if (!configData) { | ||||||
|       decimals = 18; |       decimals = 18; | ||||||
|     } |     } | ||||||
|  | @ -98,10 +93,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
|   const aaveAdmin = await deployer.getAddress(); |   const aaveAdmin = await deployer.getAddress(); | ||||||
| 
 | 
 | ||||||
|   const mockTokens = await deployAllMockTokens(deployer); |   const mockTokens = await deployAllMockTokens(deployer); | ||||||
|   const mockTokenAddress = Object.keys(mockTokens).reduce<{[key: string]: string}>((acc, key) => { |  | ||||||
|     acc[key] = mockTokens[key].address; |  | ||||||
|     return acc; |  | ||||||
|   }, {}); |  | ||||||
| 
 | 
 | ||||||
|   const addressesProvider = await deployLendingPoolAddressesProvider(); |   const addressesProvider = await deployLendingPoolAddressesProvider(); | ||||||
|   await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin)); |   await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin)); | ||||||
|  | @ -160,7 +151,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
|       SUSD: mockTokens.SUSD.address, |       SUSD: mockTokens.SUSD.address, | ||||||
|       AAVE: mockTokens.AAVE.address, |       AAVE: mockTokens.AAVE.address, | ||||||
|       BAT: mockTokens.BAT.address, |       BAT: mockTokens.BAT.address, | ||||||
|       REP: mockTokens.REP.address, |  | ||||||
|       MKR: mockTokens.MKR.address, |       MKR: mockTokens.MKR.address, | ||||||
|       LINK: mockTokens.LINK.address, |       LINK: mockTokens.LINK.address, | ||||||
|       KNC: mockTokens.KNC.address, |       KNC: mockTokens.KNC.address, | ||||||
|  | @ -174,13 +164,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
|       UNI: mockTokens.UNI.address, |       UNI: mockTokens.UNI.address, | ||||||
|       ENJ: mockTokens.ENJ.address, |       ENJ: mockTokens.ENJ.address, | ||||||
|       USD: USD_ADDRESS, |       USD: USD_ADDRESS, | ||||||
| 
 |  | ||||||
|       UNI_DAI_ETH: mockTokens.UNI_DAI_ETH.address, |  | ||||||
|       UNI_USDC_ETH: mockTokens.UNI_USDC_ETH.address, |  | ||||||
|       UNI_SETH_ETH: mockTokens.UNI_SETH_ETH.address, |  | ||||||
|       UNI_LEND_ETH: mockTokens.UNI_LEND_ETH.address, |  | ||||||
|       UNI_MKR_ETH: mockTokens.UNI_MKR_ETH.address, |  | ||||||
|       UNI_LINK_ETH: mockTokens.UNI_LINK_ETH.address, |  | ||||||
|     }, |     }, | ||||||
|     fallbackOracle |     fallbackOracle | ||||||
|   ); |   ); | ||||||
|  | @ -188,14 +171,14 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
|   const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES); |   const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES); | ||||||
| 
 | 
 | ||||||
|   const allTokenAddresses = Object.entries(mockTokens).reduce( |   const allTokenAddresses = Object.entries(mockTokens).reduce( | ||||||
|     (accum: {[tokenSymbol: string]: tEthereumAddress}, [tokenSymbol, tokenContract]) => ({ |     (accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({ | ||||||
|       ...accum, |       ...accum, | ||||||
|       [tokenSymbol]: tokenContract.address, |       [tokenSymbol]: tokenContract.address, | ||||||
|     }), |     }), | ||||||
|     {} |     {} | ||||||
|   ); |   ); | ||||||
|   const allAggregatorsAddresses = Object.entries(mockAggregators).reduce( |   const allAggregatorsAddresses = Object.entries(mockAggregators).reduce( | ||||||
|     (accum: {[tokenSymbol: string]: tEthereumAddress}, [tokenSymbol, aggregator]) => ({ |     (accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, aggregator]) => ({ | ||||||
|       ...accum, |       ...accum, | ||||||
|       [tokenSymbol]: aggregator.address, |       [tokenSymbol]: aggregator.address, | ||||||
|     }), |     }), | ||||||
|  | @ -204,18 +187,13 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
| 
 | 
 | ||||||
|   const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); |   const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); | ||||||
| 
 | 
 | ||||||
|   const aaveOracle = await deployAaveOracle([ |   await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]); | ||||||
|     tokens, |  | ||||||
|     aggregators, |  | ||||||
|     fallbackOracle.address, |  | ||||||
|     mockTokens.WETH.address, |  | ||||||
|   ]); |  | ||||||
|   await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address)); |   await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address)); | ||||||
| 
 | 
 | ||||||
|   const lendingRateOracle = await deployLendingRateOracle(); |   const lendingRateOracle = await deployLendingRateOracle(); | ||||||
|   await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); |   await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); | ||||||
| 
 | 
 | ||||||
|   const {USD, ...tokensAddressesWithoutUsd} = allTokenAddresses; |   const { USD, ...tokensAddressesWithoutUsd } = allTokenAddresses; | ||||||
|   const allReservesAddresses = { |   const allReservesAddresses = { | ||||||
|     ...tokensAddressesWithoutUsd, |     ...tokensAddressesWithoutUsd, | ||||||
|   }; |   }; | ||||||
|  | @ -226,16 +204,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
|     aaveAdmin |     aaveAdmin | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|   const { |  | ||||||
|     UNI_DAI_ETH, |  | ||||||
|     UNI_USDC_ETH, |  | ||||||
|     UNI_SETH_ETH, |  | ||||||
|     UNI_LINK_ETH, |  | ||||||
|     UNI_MKR_ETH, |  | ||||||
|     UNI_LEND_ETH, |  | ||||||
|     ...protoPoolReservesAddresses |  | ||||||
|   } = <{[symbol: string]: tEthereumAddress}>allReservesAddresses; |  | ||||||
| 
 |  | ||||||
|   const reservesParams = getReservesConfigByPool(AavePools.proto); |   const reservesParams = getReservesConfigByPool(AavePools.proto); | ||||||
| 
 | 
 | ||||||
|   const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address); |   const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address); | ||||||
|  | @ -244,16 +212,11 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { | ||||||
|   const admin = await deployer.getAddress(); |   const admin = await deployer.getAddress(); | ||||||
| 
 | 
 | ||||||
|   console.log('Initialize configuration'); |   console.log('Initialize configuration'); | ||||||
|   await initReservesByHelper(reservesParams, protoPoolReservesAddresses, admin, ZERO_ADDRESS); |   await initReservesByHelper(reservesParams, allReservesAddresses, admin, ZERO_ADDRESS); | ||||||
|   await enableReservesToBorrowByHelper( |   await enableReservesToBorrowByHelper(reservesParams, allReservesAddresses, testHelpers, admin); | ||||||
|     reservesParams, |  | ||||||
|     protoPoolReservesAddresses, |  | ||||||
|     testHelpers, |  | ||||||
|     admin |  | ||||||
|   ); |  | ||||||
|   await enableReservesAsCollateralByHelper( |   await enableReservesAsCollateralByHelper( | ||||||
|     reservesParams, |     reservesParams, | ||||||
|     protoPoolReservesAddresses, |     allReservesAddresses, | ||||||
|     testHelpers, |     testHelpers, | ||||||
|     admin |     admin | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|  | @ -1,38 +1,33 @@ | ||||||
| import {MAX_UINT_AMOUNT, ZERO_ADDRESS} from '../helpers/constants'; | import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../helpers/constants'; | ||||||
| import {BUIDLEREVM_CHAINID} from '../helpers/buidler-constants'; | import { BUIDLEREVM_CHAINID } from '../helpers/buidler-constants'; | ||||||
| import {buildPermitParams, getSignatureFromTypedData} from '../helpers/contracts-helpers'; | import { buildPermitParams, getSignatureFromTypedData } from '../helpers/contracts-helpers'; | ||||||
| import {expect} from 'chai'; | import { expect } from 'chai'; | ||||||
| import {ethers} from 'ethers'; | import { ethers } from 'ethers'; | ||||||
| import {eEthereumNetwork} from '../helpers/types'; | import { makeSuite, TestEnv } from './helpers/make-suite'; | ||||||
| import {makeSuite, TestEnv} from './helpers/make-suite'; | import { DRE } from '../helpers/misc-utils'; | ||||||
| import {DRE} from '../helpers/misc-utils'; | import { waitForTx } from '../helpers/misc-utils'; | ||||||
| import { | import { _TypedDataEncoder } from 'ethers/lib/utils'; | ||||||
|   ConfigNames, |  | ||||||
|   getATokenDomainSeparatorPerNetwork, |  | ||||||
|   loadPoolConfig, |  | ||||||
| } from '../helpers/configuration'; |  | ||||||
| import {waitForTx} from '../helpers/misc-utils'; |  | ||||||
| 
 | 
 | ||||||
| const {parseEther} = ethers.utils; | const { parseEther } = ethers.utils; | ||||||
| 
 | 
 | ||||||
| makeSuite('AToken: Permit', (testEnv: TestEnv) => { | makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   const poolConfig = loadPoolConfig(ConfigNames.Commons); |  | ||||||
| 
 |  | ||||||
|   it('Checks the domain separator', async () => { |   it('Checks the domain separator', async () => { | ||||||
|     const DOMAIN_SEPARATOR_ENCODED = getATokenDomainSeparatorPerNetwork( |     const { aDai } = testEnv; | ||||||
|       eEthereumNetwork.hardhat, |  | ||||||
|       poolConfig |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     const {aDai} = testEnv; |  | ||||||
| 
 |  | ||||||
|     const separator = await aDai.DOMAIN_SEPARATOR(); |     const separator = await aDai.DOMAIN_SEPARATOR(); | ||||||
| 
 | 
 | ||||||
|     expect(separator).to.be.equal(DOMAIN_SEPARATOR_ENCODED, 'Invalid domain separator'); |     const domain = { | ||||||
|  |       name: await aDai.name(), | ||||||
|  |       version: '1', | ||||||
|  |       chainId: DRE.network.config.chainId, | ||||||
|  |       verifyingContract: aDai.address, | ||||||
|  |     }; | ||||||
|  |     const domainSeparator = _TypedDataEncoder.hashDomain(domain); | ||||||
|  | 
 | ||||||
|  |     expect(separator).to.be.equal(domainSeparator, 'Invalid domain separator'); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Get aDAI for tests', async () => { |   it('Get aDAI for tests', async () => { | ||||||
|     const {dai, pool, deployer} = testEnv; |     const { dai, pool, deployer } = testEnv; | ||||||
| 
 | 
 | ||||||
|     await dai.mint(parseEther('20000')); |     await dai.mint(parseEther('20000')); | ||||||
|     await dai.approve(pool.address, parseEther('20000')); |     await dai.approve(pool.address, parseEther('20000')); | ||||||
|  | @ -41,7 +36,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Reverts submitting a permit with 0 expiration', async () => { |   it('Reverts submitting a permit with 0 expiration', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -73,7 +68,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       'INVALID_ALLOWANCE_BEFORE_PERMIT' |       'INVALID_ALLOWANCE_BEFORE_PERMIT' | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     await expect( |     await expect( | ||||||
|       aDai |       aDai | ||||||
|  | @ -88,7 +83,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Submits a permit with maximum expiration length', async () => { |   it('Submits a permit with maximum expiration length', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -118,7 +113,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       'INVALID_ALLOWANCE_BEFORE_PERMIT' |       'INVALID_ALLOWANCE_BEFORE_PERMIT' | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     await waitForTx( |     await waitForTx( | ||||||
|       await aDai |       await aDai | ||||||
|  | @ -130,7 +125,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Cancels the previous permit', async () => { |   it('Cancels the previous permit', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -155,7 +150,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       throw new Error('INVALID_OWNER_PK'); |       throw new Error('INVALID_OWNER_PK'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     expect((await aDai.allowance(owner.address, spender.address)).toString()).to.be.equal( |     expect((await aDai.allowance(owner.address, spender.address)).toString()).to.be.equal( | ||||||
|       ethers.utils.parseEther('2'), |       ethers.utils.parseEther('2'), | ||||||
|  | @ -176,7 +171,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Tries to submit a permit with invalid nonce', async () => { |   it('Tries to submit a permit with invalid nonce', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -201,7 +196,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       throw new Error('INVALID_OWNER_PK'); |       throw new Error('INVALID_OWNER_PK'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     await expect( |     await expect( | ||||||
|       aDai |       aDai | ||||||
|  | @ -211,7 +206,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Tries to submit a permit with invalid expiration (previous to the current block)', async () => { |   it('Tries to submit a permit with invalid expiration (previous to the current block)', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -236,7 +231,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       throw new Error('INVALID_OWNER_PK'); |       throw new Error('INVALID_OWNER_PK'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     await expect( |     await expect( | ||||||
|       aDai |       aDai | ||||||
|  | @ -246,7 +241,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Tries to submit a permit with invalid signature', async () => { |   it('Tries to submit a permit with invalid signature', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -271,7 +266,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       throw new Error('INVALID_OWNER_PK'); |       throw new Error('INVALID_OWNER_PK'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     await expect( |     await expect( | ||||||
|       aDai |       aDai | ||||||
|  | @ -281,7 +276,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Tries to submit a permit with invalid owner', async () => { |   it('Tries to submit a permit with invalid owner', async () => { | ||||||
|     const {aDai, deployer, users} = testEnv; |     const { aDai, deployer, users } = testEnv; | ||||||
|     const owner = deployer; |     const owner = deployer; | ||||||
|     const spender = users[1]; |     const spender = users[1]; | ||||||
| 
 | 
 | ||||||
|  | @ -306,7 +301,7 @@ makeSuite('AToken: Permit', (testEnv: TestEnv) => { | ||||||
|       throw new Error('INVALID_OWNER_PK'); |       throw new Error('INVALID_OWNER_PK'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const {v, r, s} = getSignatureFromTypedData(ownerPrivateKey, msgParams); |     const { v, r, s } = getSignatureFromTypedData(ownerPrivateKey, msgParams); | ||||||
| 
 | 
 | ||||||
|     await expect( |     await expect( | ||||||
|       aDai |       aDai | ||||||
|  |  | ||||||
|  | @ -1,34 +1,34 @@ | ||||||
| import {MAX_UINT_AMOUNT, ZERO_ADDRESS} from '../helpers/constants'; | import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../helpers/constants'; | ||||||
| import {BUIDLEREVM_CHAINID} from '../helpers/buidler-constants'; | import { BUIDLEREVM_CHAINID } from '../helpers/buidler-constants'; | ||||||
| import {buildPermitParams, getSignatureFromTypedData} from '../helpers/contracts-helpers'; | import { buildPermitParams, getSignatureFromTypedData } from '../helpers/contracts-helpers'; | ||||||
| import {expect} from 'chai'; | import { expect } from 'chai'; | ||||||
| import {ethers} from 'ethers'; | import { ethers } from 'ethers'; | ||||||
| import {eEthereumNetwork, ProtocolErrors} from '../helpers/types'; | import { eEthereumNetwork, ProtocolErrors } from '../helpers/types'; | ||||||
| import {makeSuite, TestEnv} from './helpers/make-suite'; | import { makeSuite, TestEnv } from './helpers/make-suite'; | ||||||
| import {DRE} from '../helpers/misc-utils'; | import { DRE } from '../helpers/misc-utils'; | ||||||
| import { | import { | ||||||
|   ConfigNames, |   ConfigNames, | ||||||
|   getATokenDomainSeparatorPerNetwork, |   getATokenDomainSeparatorPerNetwork, | ||||||
|   loadPoolConfig, |   loadPoolConfig, | ||||||
| } from '../helpers/configuration'; | } from '../helpers/configuration'; | ||||||
| import {waitForTx} from '../helpers/misc-utils'; | import { waitForTx } from '../helpers/misc-utils'; | ||||||
| import { | import { | ||||||
|   deployDelegationAwareAToken, |   deployDelegationAwareAToken, | ||||||
|   deployMintableDelegationERC20, |   deployMintableDelegationERC20, | ||||||
| } from '../helpers/contracts-deployments'; | } from '../helpers/contracts-deployments'; | ||||||
| import {DelegationAwareATokenFactory} from '../types'; | import { DelegationAwareATokenFactory } from '../types'; | ||||||
| import {DelegationAwareAToken} from '../types/DelegationAwareAToken'; | import { DelegationAwareAToken } from '../types/DelegationAwareAToken'; | ||||||
| import {MintableDelegationErc20} from '../types/MintableDelegationErc20'; | import { MintableDelegationERC20 } from '../types/MintableDelegationERC20'; | ||||||
| 
 | 
 | ||||||
| const {parseEther} = ethers.utils; | const { parseEther } = ethers.utils; | ||||||
| 
 | 
 | ||||||
| makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => { | makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => { | ||||||
|   const poolConfig = loadPoolConfig(ConfigNames.Commons); |   const poolConfig = loadPoolConfig(ConfigNames.Commons); | ||||||
|   let delegationAToken = <DelegationAwareAToken>{}; |   let delegationAToken = <DelegationAwareAToken>{}; | ||||||
|   let delegationERC20 = <MintableDelegationErc20>{}; |   let delegationERC20 = <MintableDelegationERC20>{}; | ||||||
| 
 | 
 | ||||||
|   it('Deploys a new MintableDelegationERC20 and a DelegationAwareAToken', async () => { |   it('Deploys a new MintableDelegationERC20 and a DelegationAwareAToken', async () => { | ||||||
|     const {pool} = testEnv; |     const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|     delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']); |     delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']); | ||||||
| 
 | 
 | ||||||
|  | @ -39,7 +39,7 @@ makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Tries to delegate with the caller not being the Aave admin', async () => { |   it('Tries to delegate with the caller not being the Aave admin', async () => { | ||||||
|     const {users} = testEnv; |     const { users } = testEnv; | ||||||
| 
 | 
 | ||||||
|     await expect( |     await expect( | ||||||
|       delegationAToken.connect(users[1].signer).delegateUnderlyingTo(users[2].address) |       delegationAToken.connect(users[1].signer).delegateUnderlyingTo(users[2].address) | ||||||
|  | @ -47,7 +47,7 @@ makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => { | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Tries to delegate to user 2', async () => { |   it('Tries to delegate to user 2', async () => { | ||||||
|     const {users} = testEnv; |     const { users } = testEnv; | ||||||
| 
 | 
 | ||||||
|     await delegationAToken.delegateUnderlyingTo(users[2].address); |     await delegationAToken.delegateUnderlyingTo(users[2].address); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -15,26 +15,26 @@ import { | ||||||
|   calcExpectedUserDataAfterSwapRateMode, |   calcExpectedUserDataAfterSwapRateMode, | ||||||
|   calcExpectedUserDataAfterWithdraw, |   calcExpectedUserDataAfterWithdraw, | ||||||
| } from './utils/calculations'; | } from './utils/calculations'; | ||||||
| import {getReserveAddressFromSymbol, getReserveData, getUserData} from './utils/helpers'; | import { getReserveAddressFromSymbol, getReserveData, getUserData } from './utils/helpers'; | ||||||
| 
 | 
 | ||||||
| import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers'; | import { convertToCurrencyDecimals } from '../../helpers/contracts-helpers'; | ||||||
| import { | import { | ||||||
|   getAToken, |   getAToken, | ||||||
|   getMintableErc20, |   getMintableERC20, | ||||||
|   getStableDebtToken, |   getStableDebtToken, | ||||||
|   getVariableDebtToken, |   getVariableDebtToken, | ||||||
| } from '../../helpers/contracts-getters'; | } from '../../helpers/contracts-getters'; | ||||||
| import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants'; | import { MAX_UINT_AMOUNT, ONE_YEAR } from '../../helpers/constants'; | ||||||
| import {SignerWithAddress, TestEnv} from './make-suite'; | import { SignerWithAddress, TestEnv } from './make-suite'; | ||||||
| import {DRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils'; | import { DRE, increaseTime, timeLatest, waitForTx } from '../../helpers/misc-utils'; | ||||||
| 
 | 
 | ||||||
| import chai from 'chai'; | import chai from 'chai'; | ||||||
| import {ReserveData, UserReserveData} from './utils/interfaces'; | import { ReserveData, UserReserveData } from './utils/interfaces'; | ||||||
| import {ContractReceipt} from 'ethers'; | import { ContractReceipt } from 'ethers'; | ||||||
| import {AToken} from '../../types/AToken'; | import { AToken } from '../../types/AToken'; | ||||||
| import {RateMode, tEthereumAddress} from '../../helpers/types'; | import { RateMode, tEthereumAddress } from '../../helpers/types'; | ||||||
| 
 | 
 | ||||||
| const {expect} = chai; | const { expect } = chai; | ||||||
| 
 | 
 | ||||||
| const almostEqualOrEqual = function ( | const almostEqualOrEqual = function ( | ||||||
|   this: any, |   this: any, | ||||||
|  | @ -115,7 +115,7 @@ export const configuration: ActionsConfig = <ActionsConfig>{}; | ||||||
| export const mint = async (reserveSymbol: string, amount: string, user: SignerWithAddress) => { | export const mint = async (reserveSymbol: string, amount: string, user: SignerWithAddress) => { | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const token = await getMintableErc20(reserve); |   const token = await getMintableERC20(reserve); | ||||||
| 
 | 
 | ||||||
|   await waitForTx( |   await waitForTx( | ||||||
|     await token.connect(user.signer).mint(await convertToCurrencyDecimals(reserve, amount)) |     await token.connect(user.signer).mint(await convertToCurrencyDecimals(reserve, amount)) | ||||||
|  | @ -123,10 +123,10 @@ export const mint = async (reserveSymbol: string, amount: string, user: SignerWi | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const approve = async (reserveSymbol: string, user: SignerWithAddress, testEnv: TestEnv) => { | export const approve = async (reserveSymbol: string, user: SignerWithAddress, testEnv: TestEnv) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const token = await getMintableErc20(reserve); |   const token = await getMintableERC20(reserve); | ||||||
| 
 | 
 | ||||||
|   await token.connect(user.signer).approve(pool.address, '100000000000000000000000000000'); |   await token.connect(user.signer).approve(pool.address, '100000000000000000000000000000'); | ||||||
| }; | }; | ||||||
|  | @ -141,7 +141,7 @@ export const deposit = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|  | @ -149,7 +149,7 @@ export const deposit = async ( | ||||||
| 
 | 
 | ||||||
|   const txOptions: any = {}; |   const txOptions: any = {}; | ||||||
| 
 | 
 | ||||||
|   const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData( |   const { reserveData: reserveDataBefore, userData: userDataBefore } = await getContractsData( | ||||||
|     reserve, |     reserve, | ||||||
|     onBehalfOf, |     onBehalfOf, | ||||||
|     testEnv, |     testEnv, | ||||||
|  | @ -172,7 +172,7 @@ export const deposit = async ( | ||||||
|       timestamp, |       timestamp, | ||||||
|     } = await getContractsData(reserve, onBehalfOf, testEnv, sender.address); |     } = await getContractsData(reserve, onBehalfOf, testEnv, sender.address); | ||||||
| 
 | 
 | ||||||
|     const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult); |     const { txCost, txTimestamp } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     const expectedReserveData = calcExpectedReserveDataAfterDeposit( |     const expectedReserveData = calcExpectedReserveDataAfterDeposit( | ||||||
|       amountToDeposit.toString(), |       amountToDeposit.toString(), | ||||||
|  | @ -217,7 +217,7 @@ export const withdraw = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const { |   const { | ||||||
|     aTokenInstance, |     aTokenInstance, | ||||||
|  | @ -245,7 +245,7 @@ export const withdraw = async ( | ||||||
|       timestamp, |       timestamp, | ||||||
|     } = await getContractsData(reserve, user.address, testEnv); |     } = await getContractsData(reserve, user.address, testEnv); | ||||||
| 
 | 
 | ||||||
|     const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult); |     const { txCost, txTimestamp } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     const expectedReserveData = calcExpectedReserveDataAfterWithdraw( |     const expectedReserveData = calcExpectedReserveDataAfterWithdraw( | ||||||
|       amountToWithdraw, |       amountToWithdraw, | ||||||
|  | @ -291,7 +291,7 @@ export const delegateBorrowAllowance = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const reserveAddress: tEthereumAddress = await getReserveAddressFromSymbol(reserve); |   const reserveAddress: tEthereumAddress = await getReserveAddressFromSymbol(reserve); | ||||||
| 
 | 
 | ||||||
|  | @ -334,11 +334,11 @@ export const borrow = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData( |   const { reserveData: reserveDataBefore, userData: userDataBefore } = await getContractsData( | ||||||
|     reserve, |     reserve, | ||||||
|     onBehalfOf, |     onBehalfOf, | ||||||
|     testEnv, |     testEnv, | ||||||
|  | @ -354,7 +354,7 @@ export const borrow = async ( | ||||||
|         .borrow(reserve, amountToBorrow, interestRateMode, '0', onBehalfOf) |         .borrow(reserve, amountToBorrow, interestRateMode, '0', onBehalfOf) | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult); |     const { txCost, txTimestamp } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     if (timeTravel) { |     if (timeTravel) { | ||||||
|       const secondsToTravel = new BigNumber(timeTravel).multipliedBy(ONE_YEAR).div(365).toNumber(); |       const secondsToTravel = new BigNumber(timeTravel).multipliedBy(ONE_YEAR).div(365).toNumber(); | ||||||
|  | @ -429,10 +429,10 @@ export const repay = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData( |   const { reserveData: reserveDataBefore, userData: userDataBefore } = await getContractsData( | ||||||
|     reserve, |     reserve, | ||||||
|     onBehalfOf.address, |     onBehalfOf.address, | ||||||
|     testEnv |     testEnv | ||||||
|  | @ -461,7 +461,7 @@ export const repay = async ( | ||||||
|         .repay(reserve, amountToRepay, rateMode, onBehalfOf.address, txOptions) |         .repay(reserve, amountToRepay, rateMode, onBehalfOf.address, txOptions) | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult); |     const { txCost, txTimestamp } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     const { |     const { | ||||||
|       reserveData: reserveDataAfter, |       reserveData: reserveDataAfter, | ||||||
|  | @ -520,11 +520,11 @@ export const setUseAsCollateral = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData( |   const { reserveData: reserveDataBefore, userData: userDataBefore } = await getContractsData( | ||||||
|     reserve, |     reserve, | ||||||
|     user.address, |     user.address, | ||||||
|     testEnv |     testEnv | ||||||
|  | @ -537,9 +537,9 @@ export const setUseAsCollateral = async ( | ||||||
|       await pool.connect(user.signer).setUserUseReserveAsCollateral(reserve, useAsCollateralBool) |       await pool.connect(user.signer).setUserUseReserveAsCollateral(reserve, useAsCollateralBool) | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {txCost} = await getTxCostAndTimestamp(txResult); |     const { txCost } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     const {userData: userDataAfter} = await getContractsData(reserve, user.address, testEnv); |     const { userData: userDataAfter } = await getContractsData(reserve, user.address, testEnv); | ||||||
| 
 | 
 | ||||||
|     const expectedUserData = calcExpectedUserDataAfterSetUseAsCollateral( |     const expectedUserData = calcExpectedUserDataAfterSetUseAsCollateral( | ||||||
|       useAsCollateral.toLocaleLowerCase() === 'true', |       useAsCollateral.toLocaleLowerCase() === 'true', | ||||||
|  | @ -576,11 +576,11 @@ export const swapBorrowRateMode = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData( |   const { reserveData: reserveDataBefore, userData: userDataBefore } = await getContractsData( | ||||||
|     reserve, |     reserve, | ||||||
|     user.address, |     user.address, | ||||||
|     testEnv |     testEnv | ||||||
|  | @ -591,9 +591,9 @@ export const swapBorrowRateMode = async ( | ||||||
|       await pool.connect(user.signer).swapBorrowRateMode(reserve, rateMode) |       await pool.connect(user.signer).swapBorrowRateMode(reserve, rateMode) | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult); |     const { txCost, txTimestamp } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     const {reserveData: reserveDataAfter, userData: userDataAfter} = await getContractsData( |     const { reserveData: reserveDataAfter, userData: userDataAfter } = await getContractsData( | ||||||
|       reserve, |       reserve, | ||||||
|       user.address, |       user.address, | ||||||
|       testEnv |       testEnv | ||||||
|  | @ -641,11 +641,11 @@ export const rebalanceStableBorrowRate = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   revertMessage?: string |   revertMessage?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool} = testEnv; |   const { pool } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData( |   const { reserveData: reserveDataBefore, userData: userDataBefore } = await getContractsData( | ||||||
|     reserve, |     reserve, | ||||||
|     target.address, |     target.address, | ||||||
|     testEnv |     testEnv | ||||||
|  | @ -656,9 +656,9 @@ export const rebalanceStableBorrowRate = async ( | ||||||
|       await pool.connect(user.signer).rebalanceStableBorrowRate(reserve, target.address) |       await pool.connect(user.signer).rebalanceStableBorrowRate(reserve, target.address) | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult); |     const { txCost, txTimestamp } = await getTxCostAndTimestamp(txResult); | ||||||
| 
 | 
 | ||||||
|     const {reserveData: reserveDataAfter, userData: userDataAfter} = await getContractsData( |     const { reserveData: reserveDataAfter, userData: userDataAfter } = await getContractsData( | ||||||
|       reserve, |       reserve, | ||||||
|       target.address, |       target.address, | ||||||
|       testEnv |       testEnv | ||||||
|  | @ -721,7 +721,7 @@ const getDataBeforeAction = async ( | ||||||
| ): Promise<ActionData> => { | ): Promise<ActionData> => { | ||||||
|   const reserve = await getReserveAddressFromSymbol(reserveSymbol); |   const reserve = await getReserveAddressFromSymbol(reserveSymbol); | ||||||
| 
 | 
 | ||||||
|   const {reserveData, userData} = await getContractsData(reserve, user, testEnv); |   const { reserveData, userData } = await getContractsData(reserve, user, testEnv); | ||||||
|   const aTokenInstance = await getAToken(reserveData.aTokenAddress); |   const aTokenInstance = await getAToken(reserveData.aTokenAddress); | ||||||
|   return { |   return { | ||||||
|     reserve, |     reserve, | ||||||
|  | @ -742,7 +742,7 @@ export const getTxCostAndTimestamp = async (tx: ContractReceipt) => { | ||||||
|     txInfo.gasPrice.toString() |     txInfo.gasPrice.toString() | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|   return {txCost, txTimestamp}; |   return { txCost, txTimestamp }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const getContractsData = async ( | export const getContractsData = async ( | ||||||
|  | @ -751,7 +751,7 @@ export const getContractsData = async ( | ||||||
|   testEnv: TestEnv, |   testEnv: TestEnv, | ||||||
|   sender?: string |   sender?: string | ||||||
| ) => { | ) => { | ||||||
|   const {pool, helpersContract} = testEnv; |   const { pool, helpersContract } = testEnv; | ||||||
| 
 | 
 | ||||||
|   const [userData, reserveData, timestamp] = await Promise.all([ |   const [userData, reserveData, timestamp] = await Promise.all([ | ||||||
|     getUserData(pool, helpersContract, reserve, user, sender || user), |     getUserData(pool, helpersContract, reserve, user, sender || user), | ||||||
|  |  | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| import {evmRevert, evmSnapshot, DRE} from '../../helpers/misc-utils'; | import { evmRevert, evmSnapshot, DRE } from '../../helpers/misc-utils'; | ||||||
| import {Signer} from 'ethers'; | import { Signer } from 'ethers'; | ||||||
| import { | import { | ||||||
|   getLendingPool, |   getLendingPool, | ||||||
|   getLendingPoolAddressesProvider, |   getLendingPoolAddressesProvider, | ||||||
|   getAaveProtocolDataProvider, |   getAaveProtocolDataProvider, | ||||||
|   getAToken, |   getAToken, | ||||||
|   getMintableErc20, |   getMintableERC20, | ||||||
|   getLendingPoolConfiguratorProxy, |   getLendingPoolConfiguratorProxy, | ||||||
|   getPriceOracle, |   getPriceOracle, | ||||||
|   getLendingPoolAddressesProviderRegistry, |   getLendingPoolAddressesProviderRegistry, | ||||||
|  | @ -14,26 +14,26 @@ import { | ||||||
|   getUniswapLiquiditySwapAdapter, |   getUniswapLiquiditySwapAdapter, | ||||||
|   getUniswapRepayAdapter, |   getUniswapRepayAdapter, | ||||||
| } from '../../helpers/contracts-getters'; | } from '../../helpers/contracts-getters'; | ||||||
| import {tEthereumAddress} from '../../helpers/types'; | import { tEthereumAddress } from '../../helpers/types'; | ||||||
| import {LendingPool} from '../../types/LendingPool'; | import { LendingPool } from '../../types/LendingPool'; | ||||||
| import {AaveProtocolDataProvider} from '../../types/AaveProtocolDataProvider'; | import { AaveProtocolDataProvider } from '../../types/AaveProtocolDataProvider'; | ||||||
| import {MintableErc20 as MintableERC20} from '../../types/MintableErc20'; | import { MintableERC20 } from '../../types/MintableERC20'; | ||||||
| import {AToken} from '../../types/AToken'; | import { AToken } from '../../types/AToken'; | ||||||
| import {LendingPoolConfigurator} from '../../types/LendingPoolConfigurator'; | import { LendingPoolConfigurator } from '../../types/LendingPoolConfigurator'; | ||||||
| 
 | 
 | ||||||
| import chai from 'chai'; | import chai from 'chai'; | ||||||
| // @ts-ignore
 | // @ts-ignore
 | ||||||
| import bignumberChai from 'chai-bignumber'; | import bignumberChai from 'chai-bignumber'; | ||||||
| import {almostEqual} from './almost-equal'; | import { almostEqual } from './almost-equal'; | ||||||
| import {PriceOracle} from '../../types/PriceOracle'; | import { PriceOracle } from '../../types/PriceOracle'; | ||||||
| import {LendingPoolAddressesProvider} from '../../types/LendingPoolAddressesProvider'; | import { LendingPoolAddressesProvider } from '../../types/LendingPoolAddressesProvider'; | ||||||
| import {LendingPoolAddressesProviderRegistry} from '../../types/LendingPoolAddressesProviderRegistry'; | import { LendingPoolAddressesProviderRegistry } from '../../types/LendingPoolAddressesProviderRegistry'; | ||||||
| import {getEthersSigners} from '../../helpers/contracts-helpers'; | import { getEthersSigners } from '../../helpers/contracts-helpers'; | ||||||
| import {UniswapLiquiditySwapAdapter} from '../../types/UniswapLiquiditySwapAdapter'; | import { UniswapLiquiditySwapAdapter } from '../../types/UniswapLiquiditySwapAdapter'; | ||||||
| import {UniswapRepayAdapter} from '../../types/UniswapRepayAdapter'; | import { UniswapRepayAdapter } from '../../types/UniswapRepayAdapter'; | ||||||
| import {Weth9Mocked} from '../../types/Weth9Mocked'; | import { WETH9Mocked } from '../../types/WETH9Mocked'; | ||||||
| import {WethGateway} from '../../types/WethGateway'; | import { WETHGateway } from '../../types/WETHGateway'; | ||||||
| import {solidity} from 'ethereum-waffle'; | import { solidity } from 'ethereum-waffle'; | ||||||
| 
 | 
 | ||||||
| chai.use(bignumberChai()); | chai.use(bignumberChai()); | ||||||
| chai.use(almostEqual()); | chai.use(almostEqual()); | ||||||
|  | @ -50,7 +50,7 @@ export interface TestEnv { | ||||||
|   configurator: LendingPoolConfigurator; |   configurator: LendingPoolConfigurator; | ||||||
|   oracle: PriceOracle; |   oracle: PriceOracle; | ||||||
|   helpersContract: AaveProtocolDataProvider; |   helpersContract: AaveProtocolDataProvider; | ||||||
|   weth: Weth9Mocked; |   weth: WETH9Mocked; | ||||||
|   aWETH: AToken; |   aWETH: AToken; | ||||||
|   dai: MintableERC20; |   dai: MintableERC20; | ||||||
|   aDai: AToken; |   aDai: AToken; | ||||||
|  | @ -60,7 +60,7 @@ export interface TestEnv { | ||||||
|   uniswapLiquiditySwapAdapter: UniswapLiquiditySwapAdapter; |   uniswapLiquiditySwapAdapter: UniswapLiquiditySwapAdapter; | ||||||
|   uniswapRepayAdapter: UniswapRepayAdapter; |   uniswapRepayAdapter: UniswapRepayAdapter; | ||||||
|   registry: LendingPoolAddressesProviderRegistry; |   registry: LendingPoolAddressesProviderRegistry; | ||||||
|   wethGateway: WethGateway; |   wethGateway: WETHGateway; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| let buidlerevmSnapshotId: string = '0x1'; | let buidlerevmSnapshotId: string = '0x1'; | ||||||
|  | @ -77,7 +77,7 @@ const testEnv: TestEnv = { | ||||||
|   configurator: {} as LendingPoolConfigurator, |   configurator: {} as LendingPoolConfigurator, | ||||||
|   helpersContract: {} as AaveProtocolDataProvider, |   helpersContract: {} as AaveProtocolDataProvider, | ||||||
|   oracle: {} as PriceOracle, |   oracle: {} as PriceOracle, | ||||||
|   weth: {} as Weth9Mocked, |   weth: {} as WETH9Mocked, | ||||||
|   aWETH: {} as AToken, |   aWETH: {} as AToken, | ||||||
|   dai: {} as MintableERC20, |   dai: {} as MintableERC20, | ||||||
|   aDai: {} as AToken, |   aDai: {} as AToken, | ||||||
|  | @ -87,7 +87,7 @@ const testEnv: TestEnv = { | ||||||
|   uniswapLiquiditySwapAdapter: {} as UniswapLiquiditySwapAdapter, |   uniswapLiquiditySwapAdapter: {} as UniswapLiquiditySwapAdapter, | ||||||
|   uniswapRepayAdapter: {} as UniswapRepayAdapter, |   uniswapRepayAdapter: {} as UniswapRepayAdapter, | ||||||
|   registry: {} as LendingPoolAddressesProviderRegistry, |   registry: {} as LendingPoolAddressesProviderRegistry, | ||||||
|   wethGateway: {} as WethGateway, |   wethGateway: {} as WETHGateway, | ||||||
| } as TestEnv; | } as TestEnv; | ||||||
| 
 | 
 | ||||||
| export async function initializeMakeSuite() { | export async function initializeMakeSuite() { | ||||||
|  | @ -136,9 +136,9 @@ export async function initializeMakeSuite() { | ||||||
|   testEnv.aDai = await getAToken(aDaiAddress); |   testEnv.aDai = await getAToken(aDaiAddress); | ||||||
|   testEnv.aWETH = await getAToken(aWEthAddress); |   testEnv.aWETH = await getAToken(aWEthAddress); | ||||||
| 
 | 
 | ||||||
|   testEnv.dai = await getMintableErc20(daiAddress); |   testEnv.dai = await getMintableERC20(daiAddress); | ||||||
|   testEnv.usdc = await getMintableErc20(usdcAddress); |   testEnv.usdc = await getMintableERC20(usdcAddress); | ||||||
|   testEnv.aave = await getMintableErc20(aaveAddress); |   testEnv.aave = await getMintableERC20(aaveAddress); | ||||||
|   testEnv.weth = await getWETHMocked(wethAddress); |   testEnv.weth = await getWETHMocked(wethAddress); | ||||||
|   testEnv.wethGateway = await getWETHGateway(); |   testEnv.wethGateway = await getWETHGateway(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,17 +1,17 @@ | ||||||
| import {LendingPool} from '../../../types/LendingPool'; | import { LendingPool } from '../../../types/LendingPool'; | ||||||
| import {ReserveData, UserReserveData} from './interfaces'; | import { ReserveData, UserReserveData } from './interfaces'; | ||||||
| import { | import { | ||||||
|   getLendingRateOracle, |   getLendingRateOracle, | ||||||
|   getIErc20Detailed, |   getIErc20Detailed, | ||||||
|   getMintableErc20, |   getMintableERC20, | ||||||
|   getAToken, |   getAToken, | ||||||
|   getStableDebtToken, |   getStableDebtToken, | ||||||
|   getVariableDebtToken, |   getVariableDebtToken, | ||||||
| } from '../../../helpers/contracts-getters'; | } from '../../../helpers/contracts-getters'; | ||||||
| import {tEthereumAddress} from '../../../helpers/types'; | import { tEthereumAddress } from '../../../helpers/types'; | ||||||
| import BigNumber from 'bignumber.js'; | import BigNumber from 'bignumber.js'; | ||||||
| import {getDb, DRE} from '../../../helpers/misc-utils'; | import { getDb, DRE } from '../../../helpers/misc-utils'; | ||||||
| import {AaveProtocolDataProvider} from '../../../types/AaveProtocolDataProvider'; | import { AaveProtocolDataProvider } from '../../../types/AaveProtocolDataProvider'; | ||||||
| 
 | 
 | ||||||
| export const getReserveData = async ( | export const getReserveData = async ( | ||||||
|   helper: AaveProtocolDataProvider, |   helper: AaveProtocolDataProvider, | ||||||
|  | @ -27,7 +27,7 @@ export const getReserveData = async ( | ||||||
|   const stableDebtToken = await getStableDebtToken(tokenAddresses.stableDebtTokenAddress); |   const stableDebtToken = await getStableDebtToken(tokenAddresses.stableDebtTokenAddress); | ||||||
|   const variableDebtToken = await getVariableDebtToken(tokenAddresses.variableDebtTokenAddress); |   const variableDebtToken = await getVariableDebtToken(tokenAddresses.variableDebtTokenAddress); | ||||||
| 
 | 
 | ||||||
|   const {0: principalStableDebt} = await stableDebtToken.getSupplyData(); |   const { 0: principalStableDebt } = await stableDebtToken.getSupplyData(); | ||||||
|   const totalStableDebtLastUpdated = await stableDebtToken.getTotalSupplyLastUpdated(); |   const totalStableDebtLastUpdated = await stableDebtToken.getTotalSupplyLastUpdated(); | ||||||
| 
 | 
 | ||||||
|   const scaledVariableDebt = await variableDebtToken.scaledTotalSupply(); |   const scaledVariableDebt = await variableDebtToken.scaledTotalSupply(); | ||||||
|  | @ -84,7 +84,7 @@ export const getUserData = async ( | ||||||
|     getATokenUserData(reserve, user, helper), |     getATokenUserData(reserve, user, helper), | ||||||
|   ]); |   ]); | ||||||
| 
 | 
 | ||||||
|   const token = await getMintableErc20(reserve); |   const token = await getMintableERC20(reserve); | ||||||
|   const walletBalance = new BigNumber((await token.balanceOf(sender || user)).toString()); |   const walletBalance = new BigNumber((await token.balanceOf(sender || user)).toString()); | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|  | @ -103,7 +103,7 @@ export const getUserData = async ( | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const getReserveAddressFromSymbol = async (symbol: string) => { | export const getReserveAddressFromSymbol = async (symbol: string) => { | ||||||
|   const token = await getMintableErc20( |   const token = await getMintableERC20( | ||||||
|     (await getDb().get(`${symbol}.${DRE.network.name}`).value()).address |     (await getDb().get(`${symbol}.${DRE.network.name}`).value()).address | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,8 @@ | ||||||
|     "strict": true, |     "strict": true, | ||||||
|     "esModuleInterop": true, |     "esModuleInterop": true, | ||||||
|     "outDir": "dist", |     "outDir": "dist", | ||||||
|     "noImplicitAny": false |     "noImplicitAny": false, | ||||||
|  |     "resolveJsonModule": true | ||||||
|   }, |   }, | ||||||
|   "include": ["./scripts", "./test", "./tasks"], |   "include": ["./scripts", "./test", "./tasks"], | ||||||
|   "files": [ |   "files": [ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Gerardo Nardelli
						Gerardo Nardelli