mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Initial fix of the borrow tests
This commit is contained in:
parent
d542f098c1
commit
d0d1db5e4d
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user