mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
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:
parent
61b935ce41
commit
53d92ccfe4
|
@ -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,
|
||||||
|
@ -45,8 +44,8 @@ import {
|
||||||
StableDebtTokenFactory,
|
StableDebtTokenFactory,
|
||||||
VariableDebtTokenFactory,
|
VariableDebtTokenFactory,
|
||||||
WalletBalanceProviderFactory,
|
WalletBalanceProviderFactory,
|
||||||
Weth9MockedFactory,
|
WETH9MockedFactory,
|
||||||
WethGatewayFactory,
|
WETHGatewayFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {
|
import {
|
||||||
withSaveAndVerify,
|
withSaveAndVerify,
|
||||||
|
@ -54,11 +53,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) {
|
||||||
|
@ -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
|
||||||
|
@ -374,7 +373,7 @@ 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);
|
||||||
|
|
||||||
|
@ -392,7 +391,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;
|
||||||
|
@ -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
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
LendingPoolConfiguratorFactory,
|
LendingPoolConfiguratorFactory,
|
||||||
LendingPoolFactory,
|
LendingPoolFactory,
|
||||||
LendingRateOracleFactory,
|
LendingRateOracleFactory,
|
||||||
MintableErc20Factory,
|
MintableERC20Factory,
|
||||||
MockATokenFactory,
|
MockATokenFactory,
|
||||||
MockFlashLoanReceiverFactory,
|
MockFlashLoanReceiverFactory,
|
||||||
MockStableDebtTokenFactory,
|
MockStableDebtTokenFactory,
|
||||||
|
@ -24,13 +24,13 @@ 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';
|
||||||
|
|
||||||
export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0];
|
export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0];
|
||||||
|
|
||||||
|
@ -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({})
|
||||||
|
@ -166,9 +166,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') {
|
||||||
|
@ -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()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import {Contract, Signer, utils, ethers} from 'ethers';
|
import { Contract, Signer, utils, ethers } 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(', ')}`);
|
||||||
|
|
|
@ -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>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(),
|
||||||
|
@ -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
|
||||||
|
|
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": {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {task} from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {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, notFalsyOrZeroAddress} from '../../helpers/misc-utils';
|
import { waitForTx, notFalsyOrZeroAddress } from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
ConfigNames,
|
ConfigNames,
|
||||||
loadPoolConfig,
|
loadPoolConfig,
|
||||||
|
@ -12,7 +12,7 @@ import {
|
||||||
getLendingRateOracles,
|
getLendingRateOracles,
|
||||||
} from '../../helpers/configuration';
|
} from '../../helpers/configuration';
|
||||||
import {
|
import {
|
||||||
getChainlinkPriceProvider,
|
getAaveOracle,
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
getLendingRateOracle,
|
getLendingRateOracle,
|
||||||
getPairsTokenAggregator,
|
getPairsTokenAggregator,
|
||||||
|
@ -21,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,
|
||||||
|
@ -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
|
||||||
|
@ -56,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(
|
||||||
|
@ -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')) {
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -23,31 +23,31 @@ import {
|
||||||
deployWETHGateway,
|
deployWETHGateway,
|
||||||
deployWETHMocked,
|
deployWETHMocked,
|
||||||
} 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;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -168,20 +168,19 @@ 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,
|
||||||
}),
|
}),
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
console.log(allTokenAddresses, allAggregatorsAddresses);
|
|
||||||
|
|
||||||
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);
|
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);
|
||||||
|
|
||||||
|
@ -191,7 +190,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
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,
|
||||||
};
|
};
|
||||||
|
|
|
@ -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,35 +1,35 @@
|
||||||
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,
|
||||||
getWETHMocked,
|
getWETHMocked,
|
||||||
getWETHGateway,
|
getWETHGateway,
|
||||||
} 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 {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());
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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