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

View File

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