Fixed rebalance rate tests

This commit is contained in:
The3D 2020-09-21 15:52:53 +02:00
parent 6f9ff11e49
commit 56be9304c2
3 changed files with 9 additions and 18 deletions

View File

@ -372,22 +372,6 @@ export const borrow = async (
timestamp 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(reserveDataAfter, expectedReserveData);
expectEqual(userDataAfter, expectedUserData); expectEqual(userDataAfter, expectedUserData);

View File

@ -392,12 +392,13 @@ export const calcExpectedReserveDataAfterBorrow = (
expectedReserveData.totalLiquidity expectedReserveData.totalLiquidity
); );
} else { } else {
expectedReserveData.principalStableDebt = reserveDataBeforeAction.principalStableDebt; expectedReserveData.principalStableDebt = reserveDataBeforeAction.principalStableDebt;
const totalStableDebtAfterTx = calcExpectedStableDebtTokenBalance( const totalStableDebtAfterTx = calcExpectedStableDebtTokenBalance(
reserveDataBeforeAction.principalStableDebt, reserveDataBeforeAction.principalStableDebt,
reserveDataBeforeAction.averageStableBorrowRate, reserveDataBeforeAction.averageStableBorrowRate,
reserveDataBeforeAction.lastUpdateTimestamp, reserveDataBeforeAction.totalStableDebtLastUpdated,
txTimestamp txTimestamp
); );
@ -630,7 +631,9 @@ export const calcExpectedUserDataAfterBorrow = (
); );
expectedUserData.scaledVariableDebt = userDataBeforeAction.scaledVariableDebt; expectedUserData.scaledVariableDebt = userDataBeforeAction.scaledVariableDebt;
} else { } else {
expectedUserData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt.plus( expectedUserData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt.plus(
amountBorrowedBN.rayDiv(expectedDataAfterAction.variableBorrowIndex) amountBorrowedBN.rayDiv(expectedDataAfterAction.variableBorrowIndex)
); );
@ -654,6 +657,7 @@ export const calcExpectedUserDataAfterBorrow = (
expectedUserData, expectedUserData,
currentTimestamp currentTimestamp
); );
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate; expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
expectedUserData.usageAsCollateralEnabled = userDataBeforeAction.usageAsCollateralEnabled; expectedUserData.usageAsCollateralEnabled = userDataBeforeAction.usageAsCollateralEnabled;
@ -952,6 +956,8 @@ export const calcExpectedReserveDataAfterStableRateRebalance = (
): ReserveData => { ): ReserveData => {
const expectedReserveData: ReserveData = <ReserveData>{}; const expectedReserveData: ReserveData = <ReserveData>{};
console.log("Rebalancing");
expectedReserveData.address = reserveDataBeforeAction.address; expectedReserveData.address = reserveDataBeforeAction.address;
const userStableDebt = calcExpectedStableDebtTokenBalance( const userStableDebt = calcExpectedStableDebtTokenBalance(

View File

@ -23,9 +23,10 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
const aTokenInstance = await deployContract<MockAToken>(eContractid.MockAToken, [ const aTokenInstance = await deployContract<MockAToken>(eContractid.MockAToken, [
pool.address, pool.address,
dai.address, dai.address,
ZERO_ADDRESS,
'Aave Interest bearing DAI updated', 'Aave Interest bearing DAI updated',
'aDAI', 'aDAI',
ZERO_ADDRESS, ZERO_ADDRESS
]); ]);
const stableDebtTokenInstance = await deployContract<MockStableDebtToken>( const stableDebtTokenInstance = await deployContract<MockStableDebtToken>(