From 56be9304c24ff0f1f4246248ac45147a176bb3fd Mon Sep 17 00:00:00 2001 From: The3D Date: Mon, 21 Sep 2020 15:52:53 +0200 Subject: [PATCH] Fixed rebalance rate tests --- test/helpers/actions.ts | 16 ---------------- test/helpers/utils/calculations.ts | 8 +++++++- test/upgradeability.spec.ts | 3 ++- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index b1e60e0d..e1b55fc9 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -372,22 +372,6 @@ export const borrow = async ( timestamp ); - console.log("total debt stable exp ", expectedReserveData.totalStableDebt.toFixed()); - console.log("total debt stable act ", reserveDataAfter.totalStableDebt.toFixed()); - - console.log("total debt variable exp ", expectedReserveData.totalVariableDebt.toFixed()); - console.log("total debt variable act ", reserveDataAfter.totalVariableDebt.toFixed()); - - console.log("avl liquidity exp ", expectedReserveData.availableLiquidity.toFixed()); - console.log("avl liquidity act ", reserveDataAfter.availableLiquidity.toFixed()); - - console.log("avg borrow rate exp ", expectedReserveData.averageStableBorrowRate.toFixed()); - console.log("avl borrow rate act ", reserveDataAfter.averageStableBorrowRate.toFixed()); - - console.log("liquidity rate exp ", expectedReserveData.averageStableBorrowRate.toFixed()); - console.log("avl borrow rate act ", reserveDataAfter.averageStableBorrowRate.toFixed()); - - expectEqual(reserveDataAfter, expectedReserveData); expectEqual(userDataAfter, expectedUserData); diff --git a/test/helpers/utils/calculations.ts b/test/helpers/utils/calculations.ts index 10f1127a..be0a8c3f 100644 --- a/test/helpers/utils/calculations.ts +++ b/test/helpers/utils/calculations.ts @@ -392,12 +392,13 @@ export const calcExpectedReserveDataAfterBorrow = ( expectedReserveData.totalLiquidity ); } else { + expectedReserveData.principalStableDebt = reserveDataBeforeAction.principalStableDebt; const totalStableDebtAfterTx = calcExpectedStableDebtTokenBalance( reserveDataBeforeAction.principalStableDebt, reserveDataBeforeAction.averageStableBorrowRate, - reserveDataBeforeAction.lastUpdateTimestamp, + reserveDataBeforeAction.totalStableDebtLastUpdated, txTimestamp ); @@ -630,7 +631,9 @@ export const calcExpectedUserDataAfterBorrow = ( ); expectedUserData.scaledVariableDebt = userDataBeforeAction.scaledVariableDebt; + } else { + expectedUserData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt.plus( amountBorrowedBN.rayDiv(expectedDataAfterAction.variableBorrowIndex) ); @@ -654,6 +657,7 @@ export const calcExpectedUserDataAfterBorrow = ( expectedUserData, currentTimestamp ); + expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate; expectedUserData.usageAsCollateralEnabled = userDataBeforeAction.usageAsCollateralEnabled; @@ -952,6 +956,8 @@ export const calcExpectedReserveDataAfterStableRateRebalance = ( ): ReserveData => { const expectedReserveData: ReserveData = {}; + console.log("Rebalancing"); + expectedReserveData.address = reserveDataBeforeAction.address; const userStableDebt = calcExpectedStableDebtTokenBalance( diff --git a/test/upgradeability.spec.ts b/test/upgradeability.spec.ts index 47c452bf..29f2da40 100644 --- a/test/upgradeability.spec.ts +++ b/test/upgradeability.spec.ts @@ -23,9 +23,10 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => { const aTokenInstance = await deployContract(eContractid.MockAToken, [ pool.address, dai.address, + ZERO_ADDRESS, 'Aave Interest bearing DAI updated', 'aDAI', - ZERO_ADDRESS, + ZERO_ADDRESS ]); const stableDebtTokenInstance = await deployContract(