Added permit domain check test. Update typechain and typescript to support new ethers 5 generated typings. Updated ethers to support _TypedDataEncoder for domain hash.

This commit is contained in:
David Racero 2020-11-18 19:18:02 +01:00
parent 61b935ce41
commit 53d92ccfe4
19 changed files with 5698 additions and 5744 deletions

View File

@ -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;

View File

@ -12,7 +12,7 @@ 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';
@ -30,10 +30,9 @@ import {
LendingPoolCollateralManagerFactory, LendingPoolCollateralManagerFactory,
LendingPoolConfiguratorFactory, LendingPoolConfiguratorFactory,
LendingPoolFactory, LendingPoolFactory,
LendingPoolLibraryAddresses,
LendingRateOracleFactory, LendingRateOracleFactory,
MintableDelegationErc20Factory, MintableDelegationERC20Factory,
MintableErc20Factory, MintableERC20Factory,
MockAggregatorFactory, MockAggregatorFactory,
MockATokenFactory, MockATokenFactory,
MockFlashLoanReceiverFactory, MockFlashLoanReceiverFactory,
@ -45,8 +44,8 @@ import {
StableDebtTokenFactory, StableDebtTokenFactory,
VariableDebtTokenFactory, VariableDebtTokenFactory,
WalletBalanceProviderFactory, WalletBalanceProviderFactory,
Weth9MockedFactory, WETH9MockedFactory,
WethGatewayFactory, WETHGatewayFactory,
} from '../types'; } from '../types';
import { import {
withSaveAndVerify, withSaveAndVerify,
@ -55,10 +54,10 @@ import {
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) {
@ -272,7 +271,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
@ -281,9 +280,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
@ -439,7 +438,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
@ -458,7 +457,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

View File

@ -12,7 +12,7 @@ import {
LendingPoolConfiguratorFactory, LendingPoolConfiguratorFactory,
LendingPoolFactory, LendingPoolFactory,
LendingRateOracleFactory, LendingRateOracleFactory,
MintableErc20Factory, MintableERC20Factory,
MockATokenFactory, MockATokenFactory,
MockFlashLoanReceiverFactory, MockFlashLoanReceiverFactory,
MockStableDebtTokenFactory, MockStableDebtTokenFactory,
@ -24,10 +24,10 @@ import {
StableDebtTokenFactory, StableDebtTokenFactory,
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';
@ -85,15 +85,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()
@ -140,7 +140,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({})
@ -154,7 +154,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({})
@ -234,14 +234,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()
); );
@ -323,7 +323,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()

View File

@ -12,7 +12,7 @@ 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';

View File

@ -7,6 +7,7 @@ import {
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>,
@ -48,7 +49,13 @@ 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) {

View File

@ -364,7 +364,6 @@ 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>;
} }

View File

@ -155,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]: '',
@ -171,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,
}, },
@ -300,15 +300,6 @@ export const CommonsConfig: ICommonConfiguration = {
[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

View File

@ -2,25 +2,6 @@ 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;

10798
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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": {

View File

@ -12,7 +12,7 @@ import {
getLendingRateOracles, getLendingRateOracles,
} from '../../helpers/configuration'; } from '../../helpers/configuration';
import { import {
getChainlinkPriceProvider, getAaveOracle,
getLendingPoolAddressesProvider, getLendingPoolAddressesProvider,
getLendingRateOracle, getLendingRateOracle,
getPairsTokenAggregator, getPairsTokenAggregator,
@ -35,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);
@ -47,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
@ -68,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')) {

View File

@ -1,5 +1,3 @@
import {ExternalProvider} from '@ethersproject/providers';
import { task } from 'hardhat/config'; import { task } from 'hardhat/config';
import { setDRE } from '../../helpers/misc-utils'; import { setDRE } from '../../helpers/misc-utils';

View File

@ -25,7 +25,7 @@ import {
} 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';
@ -47,7 +47,7 @@ import {
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;
@ -56,7 +56,7 @@ const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig.Mocks.AllAssetsInitialPrice
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);
@ -181,7 +181,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
}), }),
{} {}
); );
console.log(allTokenAddresses, allAggregatorsAddresses);
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses); const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);

View File

@ -3,32 +3,27 @@ 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 {
ConfigNames,
getATokenDomainSeparatorPerNetwork,
loadPoolConfig,
} from '../helpers/configuration';
import { waitForTx } from '../helpers/misc-utils'; import { waitForTx } from '../helpers/misc-utils';
import { _TypedDataEncoder } from 'ethers/lib/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(
eEthereumNetwork.hardhat,
poolConfig
);
const { aDai } = testEnv; 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 () => {

View File

@ -18,14 +18,14 @@ import {
} 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;

View File

@ -20,7 +20,7 @@ import {getReserveAddressFromSymbol, getReserveData, getUserData} from './utils/
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';
@ -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))
@ -126,7 +126,7 @@ export const approve = async (reserveSymbol: string, user: SignerWithAddress, te
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');
}; };

View File

@ -5,7 +5,7 @@ import {
getLendingPoolAddressesProvider, getLendingPoolAddressesProvider,
getAaveProtocolDataProvider, getAaveProtocolDataProvider,
getAToken, getAToken,
getMintableErc20, getMintableERC20,
getLendingPoolConfiguratorProxy, getLendingPoolConfiguratorProxy,
getPriceOracle, getPriceOracle,
getLendingPoolAddressesProviderRegistry, getLendingPoolAddressesProviderRegistry,
@ -15,7 +15,7 @@ import {
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';
@ -27,8 +27,8 @@ 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 {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());
@ -46,7 +46,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;
@ -54,7 +54,7 @@ export interface TestEnv {
aave: MintableERC20; aave: MintableERC20;
addressesProvider: LendingPoolAddressesProvider; addressesProvider: LendingPoolAddressesProvider;
registry: LendingPoolAddressesProviderRegistry; registry: LendingPoolAddressesProviderRegistry;
wethGateway: WethGateway; wethGateway: WETHGateway;
} }
let buidlerevmSnapshotId: string = '0x1'; let buidlerevmSnapshotId: string = '0x1';
@ -71,7 +71,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,
@ -79,7 +79,7 @@ const testEnv: TestEnv = {
aave: {} as MintableERC20, aave: {} as MintableERC20,
addressesProvider: {} as LendingPoolAddressesProvider, addressesProvider: {} as LendingPoolAddressesProvider,
registry: {} as LendingPoolAddressesProviderRegistry, registry: {} as LendingPoolAddressesProviderRegistry,
wethGateway: {} as WethGateway, wethGateway: {} as WETHGateway,
} as TestEnv; } as TestEnv;
export async function initializeMakeSuite() { export async function initializeMakeSuite() {
@ -128,9 +128,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();
} }

View File

@ -3,7 +3,7 @@ import {ReserveData, UserReserveData} from './interfaces';
import { import {
getLendingRateOracle, getLendingRateOracle,
getIErc20Detailed, getIErc20Detailed,
getMintableErc20, getMintableERC20,
getAToken, getAToken,
getStableDebtToken, getStableDebtToken,
getVariableDebtToken, getVariableDebtToken,
@ -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
); );

View File

@ -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": [