Initial fix of the borrow tests

This commit is contained in:
The3D 2020-09-14 20:04:49 +02:00
parent d542f098c1
commit d0d1db5e4d
2 changed files with 11 additions and 19 deletions

View File

@ -30,12 +30,12 @@ export const calcExpectedUserDataAfterDeposit = (
): UserReserveData => {
const expectedUserData = <UserReserveData>{};
expectedUserData.currentStableDebt = expectedUserData.principalStableDebt = calcExpectedStableDebtTokenBalance(
expectedUserData.currentStableDebt = calcExpectedStableDebtTokenBalance(
userDataBeforeAction,
txTimestamp
);
expectedUserData.currentVariableDebt = expectedUserData.principalStableDebt = calcExpectedVariableDebtTokenBalance(
expectedUserData.currentVariableDebt = calcExpectedVariableDebtTokenBalance(
reserveDataBeforeAction,
userDataBeforeAction,
txTimestamp
@ -285,22 +285,23 @@ export const calcExpectedReserveDataAfterBorrow = (
const amountBorrowedBN = new BigNumber(amountBorrowed);
const userStableDebt = calcExpectedStableDebtTokenBalance(userDataBeforeAction, txTimestamp);
const userVariableDebt = calcExpectedVariableDebtTokenBalance(
expectedReserveData.liquidityIndex = calcExpectedLiquidityIndex(
reserveDataBeforeAction,
txTimestamp
);
expectedReserveData.variableBorrowIndex = calcExpectedVariableBorrowIndex(
reserveDataBeforeAction,
userDataBeforeAction,
txTimestamp
);
if (borrowRateMode == RateMode.Stable) {
expectedReserveData.
const debtAccrued = userStableDebt.minus(userDataBeforeAction.principalStableDebt);
expectedReserveData.totalLiquidity = reserveDataBeforeAction.totalLiquidity.plus(debtAccrued);
expectedReserveData.totalStableDebt = reserveDataBeforeAction.totalStableDebt
.plus(amountBorrowedBN)
.plus(debtAccrued);
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
reserveDataBeforeAction.averageStableBorrowRate,
@ -347,15 +348,6 @@ export const calcExpectedReserveDataAfterBorrow = (
expectedReserveData.variableBorrowRate = rates[2];
expectedReserveData.liquidityIndex = calcExpectedLiquidityIndex(
reserveDataBeforeAction,
txTimestamp
);
expectedReserveData.variableBorrowIndex = calcExpectedVariableBorrowIndex(
reserveDataBeforeAction,
txTimestamp
);
expectedReserveData.lastUpdateTimestamp = txTimestamp;
return expectedReserveData;

View File

@ -10,7 +10,7 @@ import {executeStory} from './helpers/scenario-engine';
const scenarioFolder = './test/helpers/scenarios/';
const selectedScenarios: string[] = ['withdraw.json'];
const selectedScenarios: string[] = ['borrow-repay-variable.json'];
fs.readdirSync(scenarioFolder).forEach((file) => {
if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;