mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Finished migration of basic structure of scenarios and deposit story.
This commit is contained in:
parent
0b17abc6eb
commit
ef3e5b2cbb
|
@ -1,4 +1,4 @@
|
||||||
import {Contract, Signer, utils} from "ethers";
|
import {Contract, Signer, utils, ethers} from "ethers";
|
||||||
|
|
||||||
import {getDb, BRE} from "./misc-utils";
|
import {getDb, BRE} from "./misc-utils";
|
||||||
import {
|
import {
|
||||||
|
@ -415,7 +415,7 @@ export const getAToken = async (address?: tEthereumAddress) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMintableErc20 = async (address?: tEthereumAddress) => {
|
export const getMintableErc20 = async (address: tEthereumAddress) => {
|
||||||
return await getContract<MintableErc20>(
|
return await getContract<MintableErc20>(
|
||||||
eContractid.MintableERC20,
|
eContractid.MintableERC20,
|
||||||
address ||
|
address ||
|
||||||
|
@ -427,7 +427,7 @@ export const getMintableErc20 = async (address?: tEthereumAddress) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getIErc20Detailed = async (address?: tEthereumAddress) => {
|
export const getIErc20Detailed = async (address: tEthereumAddress) => {
|
||||||
return await getContract<Ierc20Detailed>(
|
return await getContract<Ierc20Detailed>(
|
||||||
eContractid.IERC20Detailed,
|
eContractid.IERC20Detailed,
|
||||||
address ||
|
address ||
|
||||||
|
@ -491,6 +491,18 @@ export const getTokenDistributor = async (address?: tEthereumAddress) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getLendingRateOracle = async (address?: tEthereumAddress) => {
|
||||||
|
return await getContract<LendingRateOracle>(
|
||||||
|
eContractid.LendingRateOracle,
|
||||||
|
address ||
|
||||||
|
(
|
||||||
|
await getDb()
|
||||||
|
.get(`${eContractid.LendingRateOracle}.${BRE.network.name}`)
|
||||||
|
.value()
|
||||||
|
).address
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const linkBytecode = (artifact: Artifact, libraries: any) => {
|
const linkBytecode = (artifact: Artifact, libraries: any) => {
|
||||||
let bytecode = artifact.bytecode;
|
let bytecode = artifact.bytecode;
|
||||||
|
|
||||||
|
@ -551,18 +563,14 @@ export const convertToCurrencyDecimals = async (
|
||||||
amount: string
|
amount: string
|
||||||
) => {
|
) => {
|
||||||
const isEth = tokenAddress === MOCK_ETH_ADDRESS;
|
const isEth = tokenAddress === MOCK_ETH_ADDRESS;
|
||||||
let decimals = new BigNumber(18);
|
let decimals = "18";
|
||||||
|
|
||||||
if (!isEth) {
|
if (!isEth) {
|
||||||
const token = await getIErc20Detailed(tokenAddress);
|
const token = await getIErc20Detailed(tokenAddress);
|
||||||
decimals = new BigNumber(await token.decimals());
|
decimals = (await token.decimals()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const currencyUnit = new BigNumber(10).pow(decimals);
|
return ethers.utils.parseUnits(amount, decimals);
|
||||||
const amountInCurrencyDecimals = new BigNumber(amount).multipliedBy(
|
|
||||||
currencyUnit
|
|
||||||
);
|
|
||||||
return amountInCurrencyDecimals.toFixed();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const convertToCurrencyUnits = async (
|
export const convertToCurrencyUnits = async (
|
||||||
|
|
|
@ -31,6 +31,7 @@ import {
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
deployAaveProtocolTestHelpers,
|
deployAaveProtocolTestHelpers,
|
||||||
getEthersSigners,
|
getEthersSigners,
|
||||||
|
registerContractInJsonDb,
|
||||||
} from "../helpers/contracts-helpers";
|
} from "../helpers/contracts-helpers";
|
||||||
import {LendingPoolAddressesProvider} from "../types/LendingPoolAddressesProvider";
|
import {LendingPoolAddressesProvider} from "../types/LendingPoolAddressesProvider";
|
||||||
import {Wallet, ContractTransaction, ethers, Signer} from "ethers";
|
import {Wallet, ContractTransaction, ethers, Signer} from "ethers";
|
||||||
|
@ -58,8 +59,6 @@ import {
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
} from "../helpers/constants";
|
} from "../helpers/constants";
|
||||||
import {PriceOracle} from "../types/PriceOracle";
|
import {PriceOracle} from "../types/PriceOracle";
|
||||||
// @ts-ignore
|
|
||||||
import {accounts} from "../test-wallets.js";
|
|
||||||
import {MockAggregator} from "../types/MockAggregator";
|
import {MockAggregator} from "../types/MockAggregator";
|
||||||
import {LendingRateOracle} from "../types/LendingRateOracle";
|
import {LendingRateOracle} from "../types/LendingRateOracle";
|
||||||
import {LendingPoolCore} from "../types/LendingPoolCore";
|
import {LendingPoolCore} from "../types/LendingPoolCore";
|
||||||
|
@ -75,6 +74,10 @@ const deployAllMockTokens = async (deployer: Signer) => {
|
||||||
tokenSymbol,
|
tokenSymbol,
|
||||||
18,
|
18,
|
||||||
]);
|
]);
|
||||||
|
await registerContractInJsonDb(
|
||||||
|
tokenSymbol.toUpperCase(),
|
||||||
|
tokens[tokenSymbol]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +348,7 @@ const enableReservesAsCollateral = async (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const waitForTx = async (tx: ContractTransaction) => await tx.wait();
|
export const waitForTx = async (tx: ContractTransaction) => await tx.wait();
|
||||||
|
|
||||||
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
console.time("setup");
|
console.time("setup");
|
||||||
|
|
|
@ -1,234 +1,238 @@
|
||||||
// import {convertToCurrencyDecimals} from '../../utils/misc-utils';
|
import BigNumber from "bignumber.js";
|
||||||
// import {
|
|
||||||
// LendingPoolInstance,
|
|
||||||
// LendingPoolCoreInstance,
|
|
||||||
// ATokenContract,
|
|
||||||
// ATokenInstance,
|
|
||||||
// ERC20Instance,
|
|
||||||
// ERC20DetailedInstance,
|
|
||||||
// MintableERC20Instance,
|
|
||||||
// } from '../../utils/typechain-types/truffle-contracts';
|
|
||||||
// import BigNumber from 'bignumber.js';
|
|
||||||
// import {getTruffleContractInstance} from '../../utils/truffle/truffle-core-utils';
|
|
||||||
// import {ContractId} from '../../utils/types';
|
|
||||||
// import {
|
|
||||||
// calcExpectedReserveDataAfterDeposit,
|
|
||||||
// calcExpectedReserveDataAfterRedeem,
|
|
||||||
// calcExpectedUserDataAfterDeposit,
|
|
||||||
// calcExpectedUserDataAfterRedeem,
|
|
||||||
// calcExpectedReserveDataAfterBorrow,
|
|
||||||
// calcExpectedUserDataAfterBorrow,
|
|
||||||
// calcExpectedReserveDataAfterRepay,
|
|
||||||
// calcExpectedUserDataAfterRepay,
|
|
||||||
// calcExpectedUserDataAfterSetUseAsCollateral,
|
|
||||||
// calcExpectedUserDataAfterSwapRateMode,
|
|
||||||
// calcExpectedReserveDataAfterSwapRateMode,
|
|
||||||
// calcExpectedReserveDataAfterStableRateRebalance,
|
|
||||||
// calcExpectedUserDataAfterStableRateRebalance,
|
|
||||||
// calcExpectedUsersDataAfterRedirectInterest,
|
|
||||||
// } from '../utils/calculations';
|
|
||||||
// import {getReserveAddressFromSymbol, getReserveData, getUserData} from '../utils/helpers';
|
|
||||||
// import {UserReserveData, ReserveData} from '../utils/interfaces';
|
|
||||||
// import {ONE_YEAR, MAX_UINT_AMOUNT, NIL_ADDRESS} from '../../utils/constants';
|
|
||||||
// import {TransactionObject} from 'web3/eth/types';
|
|
||||||
|
|
||||||
// const {time, expectRevert} = require('@openzeppelin/test-helpers');
|
import {
|
||||||
|
calcExpectedReserveDataAfterDeposit,
|
||||||
|
calcExpectedReserveDataAfterRedeem,
|
||||||
|
calcExpectedUserDataAfterDeposit,
|
||||||
|
calcExpectedUserDataAfterRedeem,
|
||||||
|
calcExpectedReserveDataAfterBorrow,
|
||||||
|
calcExpectedUserDataAfterBorrow,
|
||||||
|
calcExpectedReserveDataAfterRepay,
|
||||||
|
calcExpectedUserDataAfterRepay,
|
||||||
|
calcExpectedUserDataAfterSetUseAsCollateral,
|
||||||
|
calcExpectedUserDataAfterSwapRateMode,
|
||||||
|
calcExpectedReserveDataAfterSwapRateMode,
|
||||||
|
calcExpectedReserveDataAfterStableRateRebalance,
|
||||||
|
calcExpectedUserDataAfterStableRateRebalance,
|
||||||
|
calcExpectedUsersDataAfterRedirectInterest,
|
||||||
|
} from "./utils/calculations";
|
||||||
|
import {
|
||||||
|
getReserveAddressFromSymbol,
|
||||||
|
getReserveData,
|
||||||
|
getUserData,
|
||||||
|
} from "./utils/helpers";
|
||||||
|
|
||||||
// const truffleAssert = require('truffle-assertions');
|
import {
|
||||||
|
getMintableErc20,
|
||||||
|
convertToCurrencyDecimals,
|
||||||
|
} from "../../helpers/contracts-helpers";
|
||||||
|
import {MOCK_ETH_ADDRESS} from "../../helpers/constants";
|
||||||
|
import {TestEnv, SignerWithAddress} from "./make-suite";
|
||||||
|
import {BRE} from "../../helpers/misc-utils";
|
||||||
|
|
||||||
// const chai = require('chai');
|
import chai from "chai";
|
||||||
|
import {ReserveData, UserReserveData} from "./utils/interfaces";
|
||||||
|
import {waitForTx} from "../__setup.spec";
|
||||||
|
import {ContractReceipt} from "ethers/contract";
|
||||||
|
import {ethers} from "ethers";
|
||||||
|
|
||||||
// const {expect} = chai;
|
const {expect} = chai;
|
||||||
|
|
||||||
// const almostEqualOrEqual = function(
|
const timeLatest = async () => {
|
||||||
// this: any,
|
const block = await BRE.ethers.provider.getBlock("latest");
|
||||||
// expected: ReserveData | UserReserveData,
|
return new BigNumber(block.timestamp);
|
||||||
// actual: ReserveData | UserReserveData
|
};
|
||||||
// ) {
|
|
||||||
// const keys = Object.keys(actual);
|
|
||||||
|
|
||||||
// keys.forEach(key => {
|
const almostEqualOrEqual = function (
|
||||||
// if (
|
this: any,
|
||||||
// key === 'lastUpdateTimestamp' ||
|
expected: ReserveData | UserReserveData,
|
||||||
// key === 'marketStableRate' ||
|
actual: ReserveData | UserReserveData
|
||||||
// key === 'symbol' ||
|
) {
|
||||||
// key === 'aTokenAddress' ||
|
const keys = Object.keys(actual);
|
||||||
// key === 'initialATokenExchangeRate' ||
|
|
||||||
// key === 'decimals'
|
|
||||||
// ) {
|
|
||||||
// //skipping consistency check on accessory data
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.assert(actual[key] != undefined, `Property ${key} is undefined in the actual data`);
|
keys.forEach((key) => {
|
||||||
// expect(expected[key] != undefined, `Property ${key} is undefined in the expected data`);
|
if (
|
||||||
|
key === "lastUpdateTimestamp" ||
|
||||||
|
key === "marketStableRate" ||
|
||||||
|
key === "symbol" ||
|
||||||
|
key === "aTokenAddress" ||
|
||||||
|
key === "initialATokenExchangeRate" ||
|
||||||
|
key === "decimals"
|
||||||
|
) {
|
||||||
|
// skipping consistency check on accessory data
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if (actual[key] instanceof BigNumber) {
|
this.assert(
|
||||||
// const actualValue = (<BigNumber>actual[key]).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
actual[key] != undefined,
|
||||||
// const expectedValue = (<BigNumber>expected[key]).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
`Property ${key} is undefined in the actual data`
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
expected[key] != undefined,
|
||||||
|
`Property ${key} is undefined in the expected data`
|
||||||
|
);
|
||||||
|
|
||||||
// this.assert(
|
if (actual[key] instanceof BigNumber) {
|
||||||
// actualValue.eq(expectedValue) ||
|
const actualValue = (<BigNumber>actual[key]).decimalPlaces(
|
||||||
// actualValue.plus(1).eq(expectedValue) ||
|
0,
|
||||||
// actualValue.eq(expectedValue.plus(1)) ||
|
BigNumber.ROUND_DOWN
|
||||||
// actualValue.plus(2).eq(expectedValue) ||
|
);
|
||||||
// actualValue.eq(expectedValue.plus(2)) ||
|
const expectedValue = (<BigNumber>expected[key]).decimalPlaces(
|
||||||
// actualValue.plus(3).eq(expectedValue) ||
|
0,
|
||||||
// actualValue.eq(expectedValue.plus(3)),
|
BigNumber.ROUND_DOWN
|
||||||
// `expected #{act} to be almost equal or equal #{exp} for property ${key}`,
|
);
|
||||||
// `expected #{act} to be almost equal or equal #{exp} for property ${key}`,
|
|
||||||
// expectedValue.toFixed(0),
|
|
||||||
// actualValue.toFixed(0)
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// this.assert(
|
|
||||||
// actual[key] !== null &&
|
|
||||||
// expected[key] !== null &&
|
|
||||||
// actual[key].toString() === expected[key].toString(),
|
|
||||||
// `expected #{act} to be equal #{exp} for property ${key}`,
|
|
||||||
// `expected #{act} to be equal #{exp} for property ${key}`,
|
|
||||||
// expected[key],
|
|
||||||
// actual[key]
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
// chai.use(function(chai: any, utils: any) {
|
this.assert(
|
||||||
// chai.Assertion.overwriteMethod('almostEqualOrEqual', function(original: any) {
|
actualValue.eq(expectedValue) ||
|
||||||
// return function(this: any, expected: ReserveData | UserReserveData) {
|
actualValue.plus(1).eq(expectedValue) ||
|
||||||
// const actual = (expected as ReserveData)
|
actualValue.eq(expectedValue.plus(1)) ||
|
||||||
// ? <ReserveData>this._obj
|
actualValue.plus(2).eq(expectedValue) ||
|
||||||
// : <UserReserveData>this._obj;
|
actualValue.eq(expectedValue.plus(2)) ||
|
||||||
|
actualValue.plus(3).eq(expectedValue) ||
|
||||||
|
actualValue.eq(expectedValue.plus(3)),
|
||||||
|
`expected #{act} to be almost equal or equal #{exp} for property ${key}`,
|
||||||
|
`expected #{act} to be almost equal or equal #{exp} for property ${key}`,
|
||||||
|
expectedValue.toFixed(0),
|
||||||
|
actualValue.toFixed(0)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.assert(
|
||||||
|
actual[key] !== null &&
|
||||||
|
expected[key] !== null &&
|
||||||
|
actual[key].toString() === expected[key].toString(),
|
||||||
|
`expected #{act} to be equal #{exp} for property ${key}`,
|
||||||
|
`expected #{act} to be equal #{exp} for property ${key}`,
|
||||||
|
expected[key],
|
||||||
|
actual[key]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// almostEqualOrEqual.apply(this, [expected, actual]);
|
chai.use(function (chai: any, utils: any) {
|
||||||
// };
|
chai.Assertion.overwriteMethod("almostEqualOrEqual", function (
|
||||||
// });
|
original: any
|
||||||
// });
|
) {
|
||||||
|
return function (this: any, expected: ReserveData | UserReserveData) {
|
||||||
|
const actual = (expected as ReserveData)
|
||||||
|
? <ReserveData>this._obj
|
||||||
|
: <UserReserveData>this._obj;
|
||||||
|
|
||||||
// interface ActionsConfig {
|
almostEqualOrEqual.apply(this, [expected, actual]);
|
||||||
// lendingPoolInstance: LendingPoolInstance;
|
};
|
||||||
// lendingPoolCoreInstance: LendingPoolCoreInstance;
|
});
|
||||||
// ethereumAddress: string;
|
});
|
||||||
// artifacts: Truffle.Artifacts;
|
|
||||||
// web3: Web3;
|
|
||||||
// skipIntegrityCheck: boolean;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export const configuration: ActionsConfig = <ActionsConfig>{};
|
interface ActionsConfig {
|
||||||
|
skipIntegrityCheck: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// export const mint = async (reserveSymbol: string, amount: string, user: string) => {
|
export const configuration: ActionsConfig = <ActionsConfig>{};
|
||||||
// const {ethereumAddress, artifacts} = configuration;
|
|
||||||
|
|
||||||
// const reserve = await getReserveAddressFromSymbol(reserveSymbol, artifacts);
|
export const mint = async (
|
||||||
|
reserveSymbol: string,
|
||||||
|
amount: string,
|
||||||
|
user: SignerWithAddress
|
||||||
|
) => {
|
||||||
|
const reserve = await getReserveAddressFromSymbol(reserveSymbol);
|
||||||
|
|
||||||
// if (ethereumAddress === reserve.toLowerCase()) {
|
if (MOCK_ETH_ADDRESS.toLowerCase() === reserve.toLowerCase()) {
|
||||||
// throw 'Cannot mint ethereum. Mint action is most likely not needed in this story';
|
throw "Cannot mint ethereum. Mint action is most likely not needed in this story";
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const tokenInstance: MintableERC20Instance = await getTruffleContractInstance(
|
const token = await getMintableErc20(reserve);
|
||||||
// artifacts,
|
|
||||||
// ContractId.MintableERC20,
|
|
||||||
// reserve
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const tokensToMint = await convertToCurrencyDecimals(reserve, amount);
|
await waitForTx(
|
||||||
|
await token
|
||||||
|
.connect(user.signer)
|
||||||
|
.mint(await convertToCurrencyDecimals(reserve, amount))
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// const txOptions: any = {
|
export const approve = async (
|
||||||
// from: user,
|
reserveSymbol: string,
|
||||||
// };
|
user: SignerWithAddress,
|
||||||
// await tokenInstance.mint(tokensToMint, txOptions);
|
testEnv: TestEnv
|
||||||
// };
|
) => {
|
||||||
|
const {core} = testEnv;
|
||||||
|
const reserve = await getReserveAddressFromSymbol(reserveSymbol);
|
||||||
|
|
||||||
// export const approve = async (reserveSymbol: string, user: string) => {
|
if (MOCK_ETH_ADDRESS.toLowerCase() === reserve.toLowerCase()) {
|
||||||
// const {ethereumAddress, artifacts} = configuration;
|
throw "Cannot mint ethereum. Mint action is most likely not needed in this story";
|
||||||
|
}
|
||||||
|
|
||||||
// const reserve = await getReserveAddressFromSymbol(reserveSymbol, artifacts);
|
const token = await getMintableErc20(reserve);
|
||||||
|
|
||||||
// if (ethereumAddress === reserve) {
|
await token
|
||||||
// throw 'Cannot mint ethereum. Mint action is most likely not needed in this story';
|
.connect(user.signer)
|
||||||
// }
|
.approve(core.address, "100000000000000000000000000000");
|
||||||
|
};
|
||||||
|
|
||||||
// const tokenInstance: ERC20Instance = await getTruffleContractInstance(
|
export const deposit = async (
|
||||||
// artifacts,
|
reserveSymbol: string,
|
||||||
// ContractId.ERC20,
|
amount: string,
|
||||||
// reserve
|
user: SignerWithAddress,
|
||||||
// );
|
sendValue: string,
|
||||||
|
expectedResult: string,
|
||||||
|
testEnv: TestEnv,
|
||||||
|
revertMessage?: string
|
||||||
|
) => {
|
||||||
|
const {pool} = testEnv;
|
||||||
|
|
||||||
// const txOptions: any = {
|
const reserve = await getReserveAddressFromSymbol(reserveSymbol);
|
||||||
// from: user,
|
|
||||||
// };
|
|
||||||
// await tokenInstance.approve(
|
|
||||||
// configuration.lendingPoolCoreInstance.address,
|
|
||||||
// '100000000000000000000000000000',
|
|
||||||
// txOptions
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const deposit = async (
|
const amountToDeposit = await convertToCurrencyDecimals(reserve, amount);
|
||||||
// reserveSymbol: string,
|
|
||||||
// amount: string,
|
|
||||||
// user: string,
|
|
||||||
// sendValue: string,
|
|
||||||
// expectedResult: string,
|
|
||||||
// revertMessage?: string
|
|
||||||
// ) => {
|
|
||||||
// const {ethereumAddress, lendingPoolInstance, artifacts} = configuration;
|
|
||||||
|
|
||||||
// const reserve = await getReserveAddressFromSymbol(reserveSymbol, artifacts);
|
const txOptions: any = {};
|
||||||
|
|
||||||
|
const {
|
||||||
|
reserveData: reserveDataBefore,
|
||||||
|
userData: userDataBefore,
|
||||||
|
} = await getContractsData(reserve, user.address, testEnv);
|
||||||
|
|
||||||
// const amountToDeposit = await convertToCurrencyDecimals(reserve, amount);
|
if (MOCK_ETH_ADDRESS === reserve) {
|
||||||
|
if (sendValue) {
|
||||||
|
const valueToSend = await convertToCurrencyDecimals(reserve, sendValue);
|
||||||
|
txOptions.value = valueToSend;
|
||||||
|
} else {
|
||||||
|
txOptions.value = amountToDeposit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (expectedResult === "success") {
|
||||||
|
const txResult = await waitForTx(
|
||||||
|
await await pool
|
||||||
|
.connect(user.signer)
|
||||||
|
.deposit(reserve, amountToDeposit, "0", txOptions)
|
||||||
|
);
|
||||||
|
|
||||||
// const txOptions: any = {
|
const {
|
||||||
// from: user,
|
reserveData: reserveDataAfter,
|
||||||
// };
|
userData: userDataAfter,
|
||||||
|
timestamp,
|
||||||
|
} = await getContractsData(reserve, user.address, testEnv);
|
||||||
|
|
||||||
// const {reserveData: reserveDataBefore, userData: userDataBefore} = await getContractsData(
|
const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult);
|
||||||
// reserve,
|
|
||||||
// user
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
const expectedReserveData = calcExpectedReserveDataAfterDeposit(
|
||||||
|
amountToDeposit.toString(),
|
||||||
|
reserveDataBefore,
|
||||||
|
txTimestamp
|
||||||
|
);
|
||||||
|
|
||||||
// if (ethereumAddress === reserve) {
|
const expectedUserReserveData = calcExpectedUserDataAfterDeposit(
|
||||||
// if (sendValue) {
|
amountToDeposit.toString(),
|
||||||
// const valueToSend = await convertToCurrencyDecimals(reserve, sendValue);
|
reserveDataBefore,
|
||||||
// txOptions.value = valueToSend;
|
expectedReserveData,
|
||||||
// } else {
|
userDataBefore,
|
||||||
// txOptions.value = amountToDeposit;
|
txTimestamp,
|
||||||
// }
|
timestamp,
|
||||||
// }
|
txCost
|
||||||
// if (expectedResult === 'success') {
|
);
|
||||||
// const txResult = await lendingPoolInstance.deposit(reserve, amountToDeposit, '0', txOptions);
|
|
||||||
|
|
||||||
// const {
|
expectEqual(reserveDataAfter, expectedReserveData);
|
||||||
// reserveData: reserveDataAfter,
|
expectEqual(userDataAfter, expectedUserReserveData);
|
||||||
// userData: userDataAfter,
|
|
||||||
// timestamp,
|
|
||||||
// } = await getContractsData(reserve, user);
|
|
||||||
|
|
||||||
// const {txCost, txTimestamp} = await getTxCostAndTimestamp(txResult);
|
// truffleAssert.eventEmitted(txResult, "Deposit", (ev: any) => {
|
||||||
|
|
||||||
// const expectedReserveData = calcExpectedReserveDataAfterDeposit(
|
|
||||||
// amountToDeposit,
|
|
||||||
// reserveDataBefore,
|
|
||||||
// txTimestamp
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const expectedUserReserveData = calcExpectedUserDataAfterDeposit(
|
|
||||||
// amountToDeposit,
|
|
||||||
// reserveDataBefore,
|
|
||||||
// expectedReserveData,
|
|
||||||
// userDataBefore,
|
|
||||||
// txTimestamp,
|
|
||||||
// timestamp,
|
|
||||||
// txCost
|
|
||||||
// );
|
|
||||||
|
|
||||||
// expectEqual(reserveDataAfter, expectedReserveData);
|
|
||||||
// expectEqual(userDataAfter, expectedUserReserveData);
|
|
||||||
|
|
||||||
// truffleAssert.eventEmitted(txResult, 'Deposit', (ev: any) => {
|
|
||||||
// const {_reserve, _user, _amount} = ev;
|
// const {_reserve, _user, _amount} = ev;
|
||||||
// return (
|
// return (
|
||||||
// _reserve === reserve &&
|
// _reserve === reserve &&
|
||||||
|
@ -236,13 +240,15 @@
|
||||||
// new BigNumber(_amount).isEqualTo(new BigNumber(amountToDeposit))
|
// new BigNumber(_amount).isEqualTo(new BigNumber(amountToDeposit))
|
||||||
// );
|
// );
|
||||||
// });
|
// });
|
||||||
// } else if (expectedResult === 'revert') {
|
} else if (expectedResult === "revert") {
|
||||||
// await expectRevert(
|
await expect(
|
||||||
// lendingPoolInstance.deposit(reserve, amountToDeposit, '0', txOptions),
|
pool
|
||||||
// revertMessage
|
.connect(user.signer)
|
||||||
// );
|
.deposit(reserve, amountToDeposit, "0", txOptions),
|
||||||
// }
|
revertMessage
|
||||||
// };
|
).to.be.reverted;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// export const redeem = async (
|
// export const redeem = async (
|
||||||
// reserveSymbol: string,
|
// reserveSymbol: string,
|
||||||
|
@ -809,14 +815,15 @@
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const expectEqual = (
|
const expectEqual = (
|
||||||
// actual: UserReserveData | ReserveData,
|
actual: UserReserveData | ReserveData,
|
||||||
// expected: UserReserveData | ReserveData
|
expected: UserReserveData | ReserveData
|
||||||
// ) => {
|
) => {
|
||||||
// if (!configuration.skipIntegrityCheck) {
|
if (!configuration.skipIntegrityCheck) {
|
||||||
// expect(actual).to.be.almostEqualOrEqual(expected);
|
// @ts-ignore
|
||||||
// }
|
expect(actual).to.be.almostEqualOrEqual(expected);
|
||||||
// };
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// interface ActionData {
|
// interface ActionData {
|
||||||
// reserve: string;
|
// reserve: string;
|
||||||
|
@ -854,31 +861,35 @@
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const getTxCostAndTimestamp = async (tx: any) => {
|
const getTxCostAndTimestamp = async (tx: ContractReceipt) => {
|
||||||
// const txTimestamp = new BigNumber((await web3.eth.getBlock(tx.receipt.blockNumber)).timestamp);
|
if (!tx.blockNumber || !tx.transactionHash || !tx.cumulativeGasUsed) {
|
||||||
|
throw new Error("No tx blocknumber");
|
||||||
|
}
|
||||||
|
const txTimestamp = new BigNumber(
|
||||||
|
(await BRE.ethers.provider.getBlock(tx.blockNumber)).timestamp
|
||||||
|
);
|
||||||
|
|
||||||
// const txInfo = await configuration.web3.eth.getTransaction(tx.receipt.transactionHash);
|
const txInfo = await BRE.ethers.provider.getTransaction(tx.transactionHash);
|
||||||
// const txCost = new BigNumber(tx.receipt.gasUsed).multipliedBy(txInfo.gasPrice);
|
const txCost = new BigNumber(tx.cumulativeGasUsed.toString()).multipliedBy(
|
||||||
|
txInfo.gasPrice.toString()
|
||||||
|
);
|
||||||
|
|
||||||
// return {txCost, txTimestamp};
|
return {txCost, txTimestamp};
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const getContractsData = async (reserve: string, user: string) => {
|
const getContractsData = async (
|
||||||
// const [reserveData, userData, timestamp] = await Promise.all([
|
reserve: string,
|
||||||
// getReserveData(configuration.lendingPoolInstance, reserve, artifacts),
|
user: string,
|
||||||
// getUserData(
|
testEnv: TestEnv
|
||||||
// configuration.lendingPoolInstance,
|
) => {
|
||||||
// configuration.lendingPoolCoreInstance,
|
const {pool, core} = testEnv;
|
||||||
// reserve,
|
const reserveData = await getReserveData(pool, reserve);
|
||||||
// user,
|
const userData = await getUserData(pool, core, reserve, user);
|
||||||
// artifacts
|
const timestamp = await timeLatest();
|
||||||
// ),
|
|
||||||
// time.latest(),
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// return {
|
return {
|
||||||
// reserveData,
|
reserveData,
|
||||||
// userData,
|
userData,
|
||||||
// timestamp: new BigNumber(timestamp),
|
timestamp: new BigNumber(timestamp),
|
||||||
// };
|
};
|
||||||
// };
|
};
|
||||||
|
|
|
@ -1,169 +1,190 @@
|
||||||
// import {
|
import {TestEnv, SignerWithAddress} from "./make-suite";
|
||||||
// deposit,
|
import {mint, approve, deposit} from "./actions";
|
||||||
// mint,
|
|
||||||
// approve,
|
|
||||||
// redeem,
|
|
||||||
// borrow,
|
|
||||||
// repay,
|
|
||||||
// setUseAsCollateral,
|
|
||||||
// swapBorrowRateMode,
|
|
||||||
// rebalanceStableBorrowRate,
|
|
||||||
// allowInterestRedirectionTo,
|
|
||||||
// redirectInterestStream,
|
|
||||||
// redirectInterestStreamOf,
|
|
||||||
// } from '../actions';
|
|
||||||
// import {on} from 'cluster';
|
|
||||||
// import { RateMode } from '../../utils/types';
|
|
||||||
|
|
||||||
// export interface Action {
|
export interface Action {
|
||||||
// name: string;
|
name: string;
|
||||||
// args?: any;
|
args?: any;
|
||||||
// expected: string;
|
expected: string;
|
||||||
// revertMessage?: string;
|
revertMessage?: string;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// export interface Story {
|
export interface Story {
|
||||||
// description: string;
|
description: string;
|
||||||
// actions: Action[];
|
actions: Action[];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// export interface Scenario {
|
export interface Scenario {
|
||||||
// title: string;
|
title: string;
|
||||||
// description: string;
|
description: string;
|
||||||
// stories: Story[];
|
stories: Story[];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// export const executeStory = async (story: Story, users: string[]) => {
|
export const executeStory = async (story: Story, testEnv: TestEnv) => {
|
||||||
// for (const action of story.actions) {
|
for (const action of story.actions) {
|
||||||
// await executeAction(action, users);
|
const {users} = testEnv;
|
||||||
// }
|
await executeAction(action, users, testEnv);
|
||||||
// };
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// const executeAction = async (action: Action, users: string[]) => {
|
const executeAction = async (
|
||||||
// const {reserve, user} = action.args;
|
action: Action,
|
||||||
// const {name, expected, revertMessage} = action;
|
users: SignerWithAddress[],
|
||||||
|
testEnv: TestEnv
|
||||||
|
) => {
|
||||||
|
const {reserve, user} = action.args;
|
||||||
|
const {name, expected, revertMessage} = action;
|
||||||
|
|
||||||
// if (!name || name === '') {
|
if (!name || name === "") {
|
||||||
// throw 'Action name is missing';
|
throw "Action name is missing";
|
||||||
// }
|
}
|
||||||
// if (!reserve || reserve === '') {
|
if (!reserve || reserve === "") {
|
||||||
// throw 'Invalid reserve selected for deposit';
|
throw "Invalid reserve selected for deposit";
|
||||||
// }
|
}
|
||||||
// if (!user || user === '') {
|
if (!user || user === "") {
|
||||||
// throw `Invalid user selected to deposit into the ${reserve} reserve`;
|
throw `Invalid user selected to deposit into the ${reserve} reserve`;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (!expected || expected === '') {
|
if (!expected || expected === "") {
|
||||||
// throw `An expected resut for action ${name} is required`;
|
throw `An expected resut for action ${name} is required`;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const userAddress = users[parseInt(user)];
|
const userAddress = users[parseInt(user)];
|
||||||
|
|
||||||
// switch (name) {
|
switch (name) {
|
||||||
// case 'mint':
|
case "mint":
|
||||||
// const {amount} = action.args;
|
const {amount} = action.args;
|
||||||
|
|
||||||
// if (!amount || amount === '') {
|
if (!amount || amount === "") {
|
||||||
// throw `Invalid amount of ${reserve} to mint`;
|
throw `Invalid amount of ${reserve} to mint`;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// await mint(reserve, amount, userAddress);
|
await mint(reserve, amount, userAddress);
|
||||||
// break;
|
break;
|
||||||
|
|
||||||
// case 'approve':
|
case "approve":
|
||||||
// await approve(reserve, userAddress);
|
await approve(reserve, userAddress, testEnv);
|
||||||
// break;
|
break;
|
||||||
|
|
||||||
// case 'deposit':
|
case "deposit":
|
||||||
// {
|
{
|
||||||
// const {amount, sendValue} = action.args;
|
const {amount, sendValue} = action.args;
|
||||||
|
|
||||||
// if (!amount || amount === '') {
|
if (!amount || amount === "") {
|
||||||
// throw `Invalid amount to deposit into the ${reserve} reserve`;
|
throw `Invalid amount to deposit into the ${reserve} reserve`;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// await deposit(reserve, amount, userAddress, sendValue, expected, revertMessage);
|
await deposit(
|
||||||
// }
|
reserve,
|
||||||
// break;
|
amount,
|
||||||
|
userAddress,
|
||||||
|
sendValue,
|
||||||
|
expected,
|
||||||
|
testEnv,
|
||||||
|
revertMessage
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// case 'redeem':
|
// case "redeem":
|
||||||
// {
|
// {
|
||||||
// const {amount} = action.args;
|
// const {amount} = action.args;
|
||||||
|
|
||||||
// if (!amount || amount === '') {
|
// if (!amount || amount === "") {
|
||||||
// throw `Invalid amount to redeem from the ${reserve} reserve`;
|
// throw `Invalid amount to redeem from the ${reserve} reserve`;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// await redeem(reserve, amount, userAddress, expected, revertMessage);
|
// await redeem(reserve, amount, userAddress, expected, revertMessage);
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
// case 'borrow':
|
// case "borrow":
|
||||||
// {
|
// {
|
||||||
// const {amount, borrowRateMode, timeTravel} = action.args;
|
// const {amount, borrowRateMode, timeTravel} = action.args;
|
||||||
|
|
||||||
// if (!amount || amount === '') {
|
// if (!amount || amount === "") {
|
||||||
// throw `Invalid amount to borrow from the ${reserve} reserve`;
|
// throw `Invalid amount to borrow from the ${reserve} reserve`;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// let rateMode: string = RateMode.None;
|
// let rateMode: string = RateMode.None;
|
||||||
|
|
||||||
// if (borrowRateMode === 'none') {
|
// if (borrowRateMode === "none") {
|
||||||
// RateMode.None;
|
// RateMode.None;
|
||||||
// } else if (borrowRateMode === 'stable') {
|
// } else if (borrowRateMode === "stable") {
|
||||||
// rateMode = RateMode.Stable;
|
// rateMode = RateMode.Stable;
|
||||||
// } else if (borrowRateMode === 'variable') {
|
// } else if (borrowRateMode === "variable") {
|
||||||
// rateMode = RateMode.Variable;
|
// rateMode = RateMode.Variable;
|
||||||
// } else {
|
// } else {
|
||||||
// //random value, to test improper selection of the parameter
|
// //random value, to test improper selection of the parameter
|
||||||
// rateMode = '4';
|
// rateMode = "4";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// await borrow(reserve, amount, rateMode, userAddress, timeTravel, expected, revertMessage);
|
// await borrow(
|
||||||
|
// reserve,
|
||||||
|
// amount,
|
||||||
|
// rateMode,
|
||||||
|
// userAddress,
|
||||||
|
// timeTravel,
|
||||||
|
// expected,
|
||||||
|
// revertMessage
|
||||||
|
// );
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'repay':
|
// case "repay":
|
||||||
// {
|
// {
|
||||||
// const {amount, sendValue} = action.args;
|
// const {amount, sendValue} = action.args;
|
||||||
// let {onBehalfOf} = action.args;
|
// let {onBehalfOf} = action.args;
|
||||||
|
|
||||||
// if (!amount || amount === '') {
|
// if (!amount || amount === "") {
|
||||||
// throw `Invalid amount to repay into the ${reserve} reserve`;
|
// throw `Invalid amount to repay into the ${reserve} reserve`;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if (!onBehalfOf || onBehalfOf === '') {
|
// if (!onBehalfOf || onBehalfOf === "") {
|
||||||
// console.log(
|
// console.log(
|
||||||
// 'WARNING: No onBehalfOf specified for a repay action. Defaulting to the repayer address'
|
// "WARNING: No onBehalfOf specified for a repay action. Defaulting to the repayer address"
|
||||||
// );
|
// );
|
||||||
// onBehalfOf = userAddress;
|
// onBehalfOf = userAddress;
|
||||||
// } else {
|
// } else {
|
||||||
// onBehalfOf = users[parseInt(onBehalfOf)];
|
// onBehalfOf = users[parseInt(onBehalfOf)];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// await repay(reserve, amount, userAddress, onBehalfOf, sendValue, expected, revertMessage);
|
// await repay(
|
||||||
|
// reserve,
|
||||||
|
// amount,
|
||||||
|
// userAddress,
|
||||||
|
// onBehalfOf,
|
||||||
|
// sendValue,
|
||||||
|
// expected,
|
||||||
|
// revertMessage
|
||||||
|
// );
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'setUseAsCollateral':
|
// case "setUseAsCollateral":
|
||||||
// {
|
// {
|
||||||
// const {useAsCollateral} = action.args;
|
// const {useAsCollateral} = action.args;
|
||||||
|
|
||||||
// if (!useAsCollateral || useAsCollateral === '') {
|
// if (!useAsCollateral || useAsCollateral === "") {
|
||||||
// throw `A valid value for useAsCollateral needs to be set when calling setUseReserveAsCollateral on reserve ${reserve}`;
|
// throw `A valid value for useAsCollateral needs to be set when calling setUseReserveAsCollateral on reserve ${reserve}`;
|
||||||
// }
|
// }
|
||||||
// await setUseAsCollateral(reserve, userAddress, useAsCollateral, expected, revertMessage);
|
// await setUseAsCollateral(
|
||||||
|
// reserve,
|
||||||
|
// userAddress,
|
||||||
|
// useAsCollateral,
|
||||||
|
// expected,
|
||||||
|
// revertMessage
|
||||||
|
// );
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'swapBorrowRateMode':
|
// case "swapBorrowRateMode":
|
||||||
// await swapBorrowRateMode(reserve, userAddress, expected, revertMessage);
|
// await swapBorrowRateMode(reserve, userAddress, expected, revertMessage);
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'rebalanceStableBorrowRate':
|
// case "rebalanceStableBorrowRate":
|
||||||
// {
|
// {
|
||||||
// const {target} = action.args;
|
// const {target} = action.args;
|
||||||
|
|
||||||
// if (!target || target === '') {
|
// if (!target || target === "") {
|
||||||
// throw `A target must be selected when trying to rebalance a stable rate`;
|
// throw `A target must be selected when trying to rebalance a stable rate`;
|
||||||
// }
|
// }
|
||||||
// const targetAddress = users[parseInt(target)];
|
// const targetAddress = users[parseInt(target)];
|
||||||
|
@ -178,27 +199,33 @@
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'redirectInterestStream':
|
// case "redirectInterestStream":
|
||||||
// {
|
// {
|
||||||
// const {to} = action.args;
|
// const {to} = action.args;
|
||||||
|
|
||||||
// if (!to || to === '') {
|
// if (!to || to === "") {
|
||||||
// throw `A target must be selected when trying to redirect the interest`;
|
// throw `A target must be selected when trying to redirect the interest`;
|
||||||
// }
|
// }
|
||||||
// const toAddress = users[parseInt(to)];
|
// const toAddress = users[parseInt(to)];
|
||||||
|
|
||||||
// await redirectInterestStream(reserve, userAddress, toAddress, expected, revertMessage);
|
// await redirectInterestStream(
|
||||||
|
// reserve,
|
||||||
|
// userAddress,
|
||||||
|
// toAddress,
|
||||||
|
// expected,
|
||||||
|
// revertMessage
|
||||||
|
// );
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'redirectInterestStreamOf':
|
// case "redirectInterestStreamOf":
|
||||||
// {
|
// {
|
||||||
// const {from, to} = action.args;
|
// const {from, to} = action.args;
|
||||||
|
|
||||||
// if (!from || from === '') {
|
// if (!from || from === "") {
|
||||||
// throw `A from address must be specified when trying to redirect the interest`;
|
// throw `A from address must be specified when trying to redirect the interest`;
|
||||||
// }
|
// }
|
||||||
// if (!to || to === '') {
|
// if (!to || to === "") {
|
||||||
// throw `A target must be selected when trying to redirect the interest`;
|
// throw `A target must be selected when trying to redirect the interest`;
|
||||||
// }
|
// }
|
||||||
// const toAddress = users[parseInt(to)];
|
// const toAddress = users[parseInt(to)];
|
||||||
|
@ -215,19 +242,25 @@
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// case 'allowInterestRedirectionTo':
|
// case "allowInterestRedirectionTo":
|
||||||
// {
|
// {
|
||||||
// const {to} = action.args;
|
// const {to} = action.args;
|
||||||
|
|
||||||
// if (!to || to === '') {
|
// if (!to || to === "") {
|
||||||
// throw `A target must be selected when trying to redirect the interest`;
|
// throw `A target must be selected when trying to redirect the interest`;
|
||||||
// }
|
// }
|
||||||
// const toAddress = users[parseInt(to)];
|
// const toAddress = users[parseInt(to)];
|
||||||
|
|
||||||
// await allowInterestRedirectionTo(reserve, userAddress, toAddress, expected, revertMessage);
|
// await allowInterestRedirectionTo(
|
||||||
|
// reserve,
|
||||||
|
// userAddress,
|
||||||
|
// toAddress,
|
||||||
|
// expected,
|
||||||
|
// revertMessage
|
||||||
|
// );
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
// default:
|
default:
|
||||||
// throw `Invalid action requested: ${name}`;
|
throw `Invalid action requested: ${name}`;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,172 +1,159 @@
|
||||||
// import {
|
import {LendingPool} from "../../../types/LendingPool";
|
||||||
// ERC20DetailedInstance,
|
import {ReserveData, UserReserveData} from "./interfaces";
|
||||||
// LendingPoolInstance,
|
import {
|
||||||
// LendingRateOracleInstance,
|
getLendingRateOracle,
|
||||||
// ATokenInstance,
|
getIErc20Detailed,
|
||||||
// LendingPoolCoreInstance,
|
getMintableErc20,
|
||||||
// } from '../../utils/typechain-types/truffle-contracts';
|
getAToken,
|
||||||
// import {getTruffleContractInstance} from '../../utils/truffle/truffle-core-utils';
|
} from "../../../helpers/contracts-helpers";
|
||||||
// import {ContractId} from '../../utils/types';
|
import {MOCK_ETH_ADDRESS, ZERO_ADDRESS} from "../../../helpers/constants";
|
||||||
// import {ReserveData, UserReserveData} from './interfaces';
|
import {tEthereumAddress} from "../../../helpers/types";
|
||||||
// import BigNumber from 'bignumber.js';
|
import BigNumber from "bignumber.js";
|
||||||
// import {configuration} from '../actions';
|
import {getDb, BRE} from "../../../helpers/misc-utils";
|
||||||
// import {NIL_ADDRESS, ETHEREUM_ADDRESS} from '../../utils/constants';
|
import {LendingPoolCore} from "../../../types/LendingPoolCore";
|
||||||
|
|
||||||
// export const getReserveData = async (
|
export const getReserveData = async (
|
||||||
// poolInstance: LendingPoolInstance,
|
pool: LendingPool,
|
||||||
// reserve: string,
|
reserve: tEthereumAddress
|
||||||
// artifacts: Truffle.Artifacts
|
): Promise<ReserveData> => {
|
||||||
// ): Promise<ReserveData> => {
|
const data: any = await pool.getReserveData(reserve);
|
||||||
// const data: any = await poolInstance.getReserveData(reserve);
|
const rateOracle = await getLendingRateOracle();
|
||||||
// const rateOracle: LendingRateOracleInstance = await getTruffleContractInstance(
|
|
||||||
// artifacts,
|
|
||||||
// ContractId.LendingRateOracle
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const rate = await rateOracle.getMarketBorrowRate(reserve);
|
const rate = (await rateOracle.getMarketBorrowRate(reserve)).toString();
|
||||||
|
|
||||||
// const isEthReserve = reserve === ETHEREUM_ADDRESS;
|
const isEthReserve = reserve === MOCK_ETH_ADDRESS;
|
||||||
// let symbol = 'ETH';
|
let symbol = "ETH";
|
||||||
// let decimals = new BigNumber(18);
|
let decimals = new BigNumber(18);
|
||||||
// if (!isEthReserve) {
|
if (!isEthReserve) {
|
||||||
// const contractInstance: ERC20DetailedInstance = await getTruffleContractInstance(
|
const token = await getIErc20Detailed(reserve);
|
||||||
// artifacts,
|
symbol = await token.symbol();
|
||||||
// ContractId.ERC20Detailed,
|
decimals = new BigNumber(await token.decimals());
|
||||||
// reserve
|
}
|
||||||
// );
|
|
||||||
// symbol = await contractInstance.symbol();
|
|
||||||
// decimals = new BigNumber(await contractInstance.decimals());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return {
|
return {
|
||||||
// totalLiquidity: new BigNumber(data.totalLiquidity),
|
totalLiquidity: new BigNumber(data.totalLiquidity),
|
||||||
// availableLiquidity: new BigNumber(data.availableLiquidity),
|
availableLiquidity: new BigNumber(data.availableLiquidity),
|
||||||
// totalBorrowsStable: new BigNumber(data.totalBorrowsStable),
|
totalBorrowsStable: new BigNumber(data.totalBorrowsStable),
|
||||||
// totalBorrowsVariable: new BigNumber(data.totalBorrowsVariable),
|
totalBorrowsVariable: new BigNumber(data.totalBorrowsVariable),
|
||||||
// liquidityRate: new BigNumber(data.liquidityRate),
|
liquidityRate: new BigNumber(data.liquidityRate),
|
||||||
// variableBorrowRate: new BigNumber(data.variableBorrowRate),
|
variableBorrowRate: new BigNumber(data.variableBorrowRate),
|
||||||
// stableBorrowRate: new BigNumber(data.stableBorrowRate),
|
stableBorrowRate: new BigNumber(data.stableBorrowRate),
|
||||||
// averageStableBorrowRate: new BigNumber(data.averageStableBorrowRate),
|
averageStableBorrowRate: new BigNumber(data.averageStableBorrowRate),
|
||||||
// utilizationRate: new BigNumber(data.utilizationRate),
|
utilizationRate: new BigNumber(data.utilizationRate),
|
||||||
// liquidityIndex: new BigNumber(data.liquidityIndex),
|
liquidityIndex: new BigNumber(data.liquidityIndex),
|
||||||
// variableBorrowIndex: new BigNumber(data.variableBorrowIndex),
|
variableBorrowIndex: new BigNumber(data.variableBorrowIndex),
|
||||||
// lastUpdateTimestamp: new BigNumber(data.lastUpdateTimestamp),
|
lastUpdateTimestamp: new BigNumber(data.lastUpdateTimestamp),
|
||||||
// address: reserve,
|
address: reserve,
|
||||||
// aTokenAddress: data.aTokenAddress,
|
aTokenAddress: data.aTokenAddress,
|
||||||
// symbol,
|
symbol,
|
||||||
// decimals,
|
decimals,
|
||||||
// marketStableRate: new BigNumber(rate),
|
marketStableRate: new BigNumber(rate),
|
||||||
// };
|
};
|
||||||
// };
|
};
|
||||||
|
|
||||||
// export const getUserData = async (
|
export const getUserData = async (
|
||||||
// poolInstance: LendingPoolInstance,
|
pool: LendingPool,
|
||||||
// coreInstance: LendingPoolCoreInstance,
|
core: LendingPoolCore,
|
||||||
// reserve: string,
|
reserve: string,
|
||||||
// user: string,
|
user: string
|
||||||
// artifacts: Truffle.Artifacts
|
): Promise<UserReserveData> => {
|
||||||
// ): Promise<UserReserveData> => {
|
const [data, aTokenData] = await Promise.all([
|
||||||
// const {web3} = configuration;
|
pool.getUserReserveData(reserve, user),
|
||||||
|
getATokenUserData(reserve, user, core),
|
||||||
|
]);
|
||||||
|
|
||||||
// const [data, aTokenData] = await Promise.all([
|
const [
|
||||||
// poolInstance.getUserReserveData(reserve, user),
|
userIndex,
|
||||||
// getATokenUserData(reserve, user, coreInstance),
|
redirectedBalance,
|
||||||
// ]);
|
principalATokenBalance,
|
||||||
|
redirectionAddressRedirectedBalance,
|
||||||
|
interestRedirectionAddress,
|
||||||
|
] = aTokenData;
|
||||||
|
|
||||||
// const [
|
let walletBalance;
|
||||||
// userIndex,
|
|
||||||
// redirectedBalance,
|
|
||||||
// principalATokenBalance,
|
|
||||||
// redirectionAddressRedirectedBalance,
|
|
||||||
// interestRedirectionAddress,
|
|
||||||
// ] = aTokenData;
|
|
||||||
|
|
||||||
// let walletBalance;
|
if (reserve === MOCK_ETH_ADDRESS) {
|
||||||
|
walletBalance = new BigNumber(
|
||||||
|
(await BRE.ethers.provider.getBalance(user)).toString()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const token = await getMintableErc20(reserve);
|
||||||
|
walletBalance = new BigNumber((await token.balanceOf(user)).toString());
|
||||||
|
}
|
||||||
|
|
||||||
// if (reserve === ETHEREUM_ADDRESS) {
|
const userData: any = data;
|
||||||
// walletBalance = new BigNumber(await web3.eth.getBalance(user));
|
|
||||||
// } else {
|
|
||||||
// const reserveInstance: ERC20DetailedInstance = await getTruffleContractInstance(
|
|
||||||
// artifacts,
|
|
||||||
// ContractId.ERC20Detailed,
|
|
||||||
// reserve
|
|
||||||
// );
|
|
||||||
// walletBalance = new BigNumber(await reserveInstance.balanceOf(user));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const userData : any = data
|
return {
|
||||||
|
principalATokenBalance: new BigNumber(principalATokenBalance),
|
||||||
|
interestRedirectionAddress,
|
||||||
|
redirectionAddressRedirectedBalance: new BigNumber(
|
||||||
|
redirectionAddressRedirectedBalance
|
||||||
|
),
|
||||||
|
redirectedBalance: new BigNumber(redirectedBalance),
|
||||||
|
currentATokenUserIndex: new BigNumber(userIndex),
|
||||||
|
currentATokenBalance: new BigNumber(userData.currentATokenBalance),
|
||||||
|
currentBorrowBalance: new BigNumber(userData.currentBorrowBalance),
|
||||||
|
principalBorrowBalance: new BigNumber(userData.principalBorrowBalance),
|
||||||
|
borrowRateMode: userData.borrowRateMode.toString(),
|
||||||
|
borrowRate: new BigNumber(userData.borrowRate),
|
||||||
|
liquidityRate: new BigNumber(userData.liquidityRate),
|
||||||
|
originationFee: new BigNumber(userData.originationFee),
|
||||||
|
variableBorrowIndex: new BigNumber(userData.variableBorrowIndex),
|
||||||
|
lastUpdateTimestamp: new BigNumber(userData.lastUpdateTimestamp),
|
||||||
|
usageAsCollateralEnabled: userData.usageAsCollateralEnabled,
|
||||||
|
walletBalance,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// return {
|
export const getReserveAddressFromSymbol = async (symbol: string) => {
|
||||||
// principalATokenBalance: new BigNumber(principalATokenBalance),
|
if (symbol.toUpperCase() === "ETH") {
|
||||||
// interestRedirectionAddress,
|
return MOCK_ETH_ADDRESS;
|
||||||
// redirectionAddressRedirectedBalance: new BigNumber(redirectionAddressRedirectedBalance),
|
}
|
||||||
// redirectedBalance: new BigNumber(redirectedBalance),
|
|
||||||
// currentATokenUserIndex: new BigNumber(userIndex),
|
|
||||||
// currentATokenBalance: new BigNumber(userData.currentATokenBalance),
|
|
||||||
// currentBorrowBalance: new BigNumber(userData.currentBorrowBalance),
|
|
||||||
// principalBorrowBalance: new BigNumber(userData.principalBorrowBalance),
|
|
||||||
// borrowRateMode: userData.borrowRateMode.toString(),
|
|
||||||
// borrowRate: new BigNumber(userData.borrowRate),
|
|
||||||
// liquidityRate: new BigNumber(userData.liquidityRate),
|
|
||||||
// originationFee: new BigNumber(userData.originationFee),
|
|
||||||
// variableBorrowIndex: new BigNumber(userData.variableBorrowIndex),
|
|
||||||
// lastUpdateTimestamp: new BigNumber(userData.lastUpdateTimestamp),
|
|
||||||
// usageAsCollateralEnabled: userData.usageAsCollateralEnabled,
|
|
||||||
// walletBalance,
|
|
||||||
// };
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const getReserveAddressFromSymbol = async (symbol: string, artifacts: Truffle.Artifacts) => {
|
const token = await getMintableErc20(
|
||||||
// if (symbol.toUpperCase() === 'ETH') {
|
(await getDb().get(`${symbol}.${BRE.network.name}`).value()).address
|
||||||
// return ETHEREUM_ADDRESS;
|
);
|
||||||
// }
|
|
||||||
|
|
||||||
// const contractName: string = 'Mock' + symbol.toUpperCase();
|
if (!token) {
|
||||||
|
throw `Could not find instance for contract ${symbol}`;
|
||||||
|
}
|
||||||
|
return token.address;
|
||||||
|
};
|
||||||
|
|
||||||
// const contractInstance: ERC20DetailedInstance = await getTruffleContractInstance(artifacts, <
|
const getATokenUserData = async (
|
||||||
// ContractId
|
reserve: string,
|
||||||
// >contractName);
|
user: string,
|
||||||
|
core: LendingPoolCore
|
||||||
|
) => {
|
||||||
|
const aTokenAddress: string = await core.getReserveATokenAddress(reserve);
|
||||||
|
|
||||||
// if (!contractInstance) {
|
const aToken = await getAToken(aTokenAddress);
|
||||||
// throw `Could not find instance for contract ${contractName}`;
|
const [
|
||||||
// }
|
userIndex,
|
||||||
// return contractInstance.address;
|
interestRedirectionAddress,
|
||||||
// };
|
redirectedBalance,
|
||||||
|
principalTokenBalance,
|
||||||
|
] = await Promise.all([
|
||||||
|
aToken.getUserIndex(user),
|
||||||
|
aToken.getInterestRedirectionAddress(user),
|
||||||
|
aToken.getRedirectedBalance(user),
|
||||||
|
aToken.principalBalanceOf(user),
|
||||||
|
]);
|
||||||
|
|
||||||
// const getATokenUserData = async (
|
const redirectionAddressRedirectedBalance =
|
||||||
// reserve: string,
|
interestRedirectionAddress !== ZERO_ADDRESS
|
||||||
// user: string,
|
? new BigNumber(
|
||||||
// coreInstance: LendingPoolCoreInstance
|
(
|
||||||
// ) => {
|
await aToken.getRedirectedBalance(interestRedirectionAddress)
|
||||||
// const aTokenAddress: string = await coreInstance.getReserveATokenAddress(reserve);
|
).toString()
|
||||||
|
)
|
||||||
|
: new BigNumber("0");
|
||||||
|
|
||||||
// const aTokenInstance: ATokenInstance = await getTruffleContractInstance(
|
return [
|
||||||
// artifacts,
|
userIndex.toString(),
|
||||||
// ContractId.AToken,
|
redirectedBalance.toString(),
|
||||||
// aTokenAddress
|
principalTokenBalance.toString(),
|
||||||
// );
|
redirectionAddressRedirectedBalance.toString(),
|
||||||
// const [
|
interestRedirectionAddress,
|
||||||
// userIndex,
|
];
|
||||||
// interestRedirectionAddress,
|
};
|
||||||
// redirectedBalance,
|
|
||||||
// principalTokenBalance,
|
|
||||||
// ] = await Promise.all([
|
|
||||||
// aTokenInstance.getUserIndex(user),
|
|
||||||
// aTokenInstance.getInterestRedirectionAddress(user),
|
|
||||||
// aTokenInstance.getRedirectedBalance(user),
|
|
||||||
// aTokenInstance.principalBalanceOf(user),
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// const redirectionAddressRedirectedBalance =
|
|
||||||
// interestRedirectionAddress !== NIL_ADDRESS
|
|
||||||
// ? new BigNumber(await aTokenInstance.getRedirectedBalance(interestRedirectionAddress))
|
|
||||||
// : new BigNumber('0');
|
|
||||||
|
|
||||||
// return [
|
|
||||||
// userIndex.toString(),
|
|
||||||
// redirectedBalance.toString(),
|
|
||||||
// principalTokenBalance.toString(),
|
|
||||||
// redirectionAddressRedirectedBalance.toString(),
|
|
||||||
// interestRedirectionAddress,
|
|
||||||
// ];
|
|
||||||
// };
|
|
||||||
|
|
|
@ -1,80 +1,102 @@
|
||||||
// import {RAY, WAD, HALF_RAY, HALF_WAD, WAD_RAY_RATIO} from "../../utils/constants"
|
import BigNumber from "bignumber.js";
|
||||||
// import BigNumber from "bignumber.js"
|
import {
|
||||||
|
RAY,
|
||||||
|
WAD,
|
||||||
|
HALF_RAY,
|
||||||
|
HALF_WAD,
|
||||||
|
WAD_RAY_RATIO,
|
||||||
|
} from "../../../helpers/constants";
|
||||||
|
|
||||||
|
declare module "bignumber.js" {
|
||||||
|
interface BigNumber {
|
||||||
|
ray: () => BigNumber;
|
||||||
|
wad: () => BigNumber;
|
||||||
|
halfRay: () => BigNumber;
|
||||||
|
halfWad: () => BigNumber;
|
||||||
|
wadMul: (a: BigNumber) => BigNumber;
|
||||||
|
wadDiv: (a: BigNumber) => BigNumber;
|
||||||
|
rayMul: (a: BigNumber) => BigNumber;
|
||||||
|
rayDiv: (a: BigNumber) => BigNumber;
|
||||||
|
rayToWad: () => BigNumber;
|
||||||
|
wadToRay: () => BigNumber;
|
||||||
|
rayPow: (n: BigNumber) => BigNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// declare module "bignumber.js" {
|
BigNumber.prototype.ray = (): BigNumber => {
|
||||||
// interface BigNumber {
|
return new BigNumber(RAY).decimalPlaces(0);
|
||||||
// ray: () => BigNumber
|
};
|
||||||
// wad: () => BigNumber
|
BigNumber.prototype.wad = (): BigNumber => {
|
||||||
// halfRay: () => BigNumber
|
return new BigNumber(WAD).decimalPlaces(0);
|
||||||
// halfWad: () => BigNumber
|
};
|
||||||
// wadMul: (a: BigNumber) => BigNumber
|
|
||||||
// wadDiv: (a: BigNumber) => BigNumber
|
|
||||||
// rayMul: (a: BigNumber) => BigNumber
|
|
||||||
// rayDiv: (a: BigNumber) => BigNumber
|
|
||||||
// rayToWad: () => BigNumber
|
|
||||||
// wadToRay: () => BigNumber
|
|
||||||
// rayPow: (n: BigNumber) => BigNumber
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// BigNumber.prototype.ray = (): BigNumber => {
|
BigNumber.prototype.halfRay = (): BigNumber => {
|
||||||
// return new BigNumber(RAY).decimalPlaces(0)
|
return new BigNumber(HALF_RAY).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
// }
|
};
|
||||||
// BigNumber.prototype.wad = (): BigNumber => {
|
|
||||||
// return new BigNumber(WAD).decimalPlaces(0)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// BigNumber.prototype.halfRay = (): BigNumber => {
|
BigNumber.prototype.halfWad = (): BigNumber => {
|
||||||
// return new BigNumber(HALF_RAY).decimalPlaces(0, BigNumber.ROUND_DOWN)
|
return new BigNumber(HALF_WAD).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
// }
|
};
|
||||||
|
|
||||||
// BigNumber.prototype.halfWad = (): BigNumber => {
|
BigNumber.prototype.wadMul = function (b: BigNumber): BigNumber {
|
||||||
// return new BigNumber(HALF_WAD).decimalPlaces(0, BigNumber.ROUND_DOWN)
|
return this.halfWad()
|
||||||
// }
|
.plus(this.multipliedBy(b))
|
||||||
|
.div(WAD)
|
||||||
|
.decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
|
};
|
||||||
|
|
||||||
// BigNumber.prototype.wadMul = function(b: BigNumber): BigNumber {
|
BigNumber.prototype.wadDiv = function (a: BigNumber): BigNumber {
|
||||||
// return this.halfWad().plus(this.multipliedBy(b)).div(WAD).decimalPlaces(0,BigNumber.ROUND_DOWN)
|
const halfA = a.div(2).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
// }
|
|
||||||
|
|
||||||
// BigNumber.prototype.wadDiv = function(a: BigNumber) : BigNumber {
|
return halfA
|
||||||
// const halfA = a.div(2).decimalPlaces(0,BigNumber.ROUND_DOWN)
|
.plus(this.multipliedBy(WAD))
|
||||||
|
.div(a)
|
||||||
|
.decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
|
};
|
||||||
|
|
||||||
// return halfA.plus(this.multipliedBy(WAD)).div(a).decimalPlaces(0, BigNumber.ROUND_DOWN)
|
BigNumber.prototype.rayMul = function (a: BigNumber): BigNumber {
|
||||||
// }
|
return this.halfRay()
|
||||||
|
.plus(this.multipliedBy(a))
|
||||||
|
.div(RAY)
|
||||||
|
.decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
|
};
|
||||||
|
|
||||||
// BigNumber.prototype.rayMul = function(a: BigNumber) : BigNumber {
|
BigNumber.prototype.rayDiv = function (a: BigNumber): BigNumber {
|
||||||
// return this.halfRay().plus(this.multipliedBy(a)).div(RAY).decimalPlaces(0, BigNumber.ROUND_DOWN)
|
const halfA = a.div(2).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
// }
|
|
||||||
|
|
||||||
// BigNumber.prototype.rayDiv = function(a: BigNumber) : BigNumber{
|
return halfA
|
||||||
// const halfA = a.div(2).decimalPlaces(0,BigNumber.ROUND_DOWN)
|
.plus(this.multipliedBy(RAY))
|
||||||
|
.decimalPlaces(0, BigNumber.ROUND_DOWN)
|
||||||
|
.div(a)
|
||||||
|
.decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
|
};
|
||||||
|
|
||||||
// return halfA.plus(this.multipliedBy(RAY)).decimalPlaces(0,BigNumber.ROUND_DOWN).div(a).decimalPlaces(0,BigNumber.ROUND_DOWN)
|
BigNumber.prototype.rayToWad = function (): BigNumber {
|
||||||
// }
|
const halfRatio = new BigNumber(WAD_RAY_RATIO).div(2);
|
||||||
|
|
||||||
// BigNumber.prototype.rayToWad = function(): BigNumber{
|
return halfRatio
|
||||||
// const halfRatio = new BigNumber(WAD_RAY_RATIO).div(2);
|
.plus(this)
|
||||||
|
.div(WAD_RAY_RATIO)
|
||||||
|
.decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
|
};
|
||||||
|
|
||||||
// return halfRatio.plus(this).div(WAD_RAY_RATIO).decimalPlaces(0, BigNumber.ROUND_DOWN)
|
BigNumber.prototype.wadToRay = function (): BigNumber {
|
||||||
// }
|
return this.multipliedBy(WAD_RAY_RATIO).decimalPlaces(
|
||||||
|
0,
|
||||||
|
BigNumber.ROUND_DOWN
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// BigNumber.prototype.wadToRay = function() : BigNumber {
|
BigNumber.prototype.rayPow = function (n: BigNumber): BigNumber {
|
||||||
// return this.multipliedBy(WAD_RAY_RATIO).decimalPlaces(0, BigNumber.ROUND_DOWN)
|
let z = !n.modulo(2).eq(0) ? this : new BigNumber(RAY);
|
||||||
// }
|
let x = new BigNumber(this);
|
||||||
|
|
||||||
|
for (n = n.div(2); !n.eq(0); n = n.div(2)) {
|
||||||
|
x = x.rayMul(x);
|
||||||
|
|
||||||
// BigNumber.prototype.rayPow = function(n: BigNumber) : BigNumber {
|
if (!n.modulo(2).eq(0)) {
|
||||||
|
z = z.rayMul(x);
|
||||||
// let z = !n.modulo(2).eq(0) ? this : new BigNumber(RAY);
|
}
|
||||||
// let x = new BigNumber(this)
|
}
|
||||||
|
return z;
|
||||||
// for (n = n.div(2); !n.eq(0); n = n.div(2)) {
|
};
|
||||||
// x = x.rayMul(x);
|
|
||||||
|
|
||||||
// if (!n.modulo(2).eq(0)) {
|
|
||||||
// z = z.rayMul(x);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return z;
|
|
||||||
// }
|
|
||||||
|
|
|
@ -1,56 +1,36 @@
|
||||||
// import {ITestEnvWithoutInstances} from '../utils/types';
|
import {configuration as actionsConfiguration} from "./helpers/actions";
|
||||||
|
import {configuration as calculationsConfiguration} from "./helpers/utils/calculations";
|
||||||
|
|
||||||
// import {testEnvProviderWithoutInstances} from '../utils/truffle/dlp-tests-env';
|
import fs from "fs";
|
||||||
// import {configuration as actionsConfiguration, deposit} from './actions';
|
import BigNumber from "bignumber.js";
|
||||||
// import {configuration as calculationsConfiguration} from './utils/calculations';
|
import {makeSuite} from "./helpers/make-suite";
|
||||||
// import {executeStory} from './engine/scenario-engine';
|
import {MOCK_ETH_ADDRESS, getReservesConfigByPool} from "../helpers/constants";
|
||||||
// import fs from 'fs';
|
import {AavePools, iAavePoolAssets, IReserveParams} from "../helpers/types";
|
||||||
// import BigNumber from 'bignumber.js';
|
import {executeStory} from "./helpers/scenario-engine";
|
||||||
// import {ETHEREUM_ADDRESS} from '../utils/constants';
|
|
||||||
|
|
||||||
// BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN});
|
BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN});
|
||||||
|
|
||||||
// const scenarioFolder = './test/scenarios/';
|
const scenarioFolder = "./test/helpers/scenarios/";
|
||||||
|
|
||||||
// fs.readdirSync(scenarioFolder).forEach(file => {
|
fs.readdirSync(scenarioFolder).forEach((file) => {
|
||||||
// // if (file !== "interest-redirection-negatives.json" &&
|
if (file !== "deposit.json") return;
|
||||||
// // file !== "interest-redirection.json" ) return
|
|
||||||
|
|
||||||
// const scenario = require(`./scenarios/${file}`);
|
const scenario = require(`./helpers/scenarios/${file}`);
|
||||||
|
|
||||||
// contract(scenario.title, async ([deployer, ...users]) => {
|
makeSuite(scenario.title, async (testEnv) => {
|
||||||
// let _testEnvProvider: ITestEnvWithoutInstances;
|
before("Initializing configuration", async () => {
|
||||||
|
actionsConfiguration.skipIntegrityCheck = false; //set this to true to execute solidity-coverage
|
||||||
|
|
||||||
// before('Initializing configuration', async () => {
|
calculationsConfiguration.reservesParams = <
|
||||||
// console.time('setup-test');
|
iAavePoolAssets<IReserveParams>
|
||||||
// _testEnvProvider = await testEnvProviderWithoutInstances(artifacts, [deployer, ...users]);
|
>getReservesConfigByPool(AavePools.proto);
|
||||||
|
calculationsConfiguration.ethereumAddress = MOCK_ETH_ADDRESS;
|
||||||
|
});
|
||||||
|
|
||||||
// const {
|
for (const story of scenario.stories) {
|
||||||
// getWeb3,
|
it(story.description, async () => {
|
||||||
// getAavePoolReservesParams,
|
await executeStory(story, testEnv);
|
||||||
// getLendingPoolInstance,
|
});
|
||||||
// getLendingPoolCoreInstance,
|
}
|
||||||
// } = _testEnvProvider;
|
});
|
||||||
|
});
|
||||||
// const instances = await Promise.all([getLendingPoolInstance(), getLendingPoolCoreInstance()]);
|
|
||||||
|
|
||||||
// actionsConfiguration.lendingPoolInstance = instances[0];
|
|
||||||
// actionsConfiguration.lendingPoolCoreInstance = instances[1];
|
|
||||||
// actionsConfiguration.ethereumAddress = ETHEREUM_ADDRESS;
|
|
||||||
// actionsConfiguration.artifacts = artifacts;
|
|
||||||
// actionsConfiguration.web3 = await getWeb3();
|
|
||||||
// actionsConfiguration.skipIntegrityCheck = false; //set this to true to execute solidity-coverage
|
|
||||||
|
|
||||||
// calculationsConfiguration.reservesParams = await getAavePoolReservesParams();
|
|
||||||
// calculationsConfiguration.web3 = actionsConfiguration.web3;
|
|
||||||
// calculationsConfiguration.ethereumAddress = actionsConfiguration.ethereumAddress;
|
|
||||||
// console.time('setup-test');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// for (const story of scenario.stories) {
|
|
||||||
// it(story.description, async () => {
|
|
||||||
// await executeStory(story, users);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user