mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Fixed rebalance tests
This commit is contained in:
parent
dd1982010c
commit
d68261c1bc
|
@ -351,9 +351,6 @@ export const borrow = async (
|
||||||
txCost
|
txCost
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(userDataAfter.stableBorrowRate.toFixed(), expectedUserData.stableBorrowRate.toFixed());
|
|
||||||
console.log(userDataAfter.principalStableBorrowBalance.toFixed(), expectedUserData.principalStableBorrowBalance.toFixed());
|
|
||||||
|
|
||||||
expectEqual(reserveDataAfter, expectedReserveData);
|
expectEqual(reserveDataAfter, expectedReserveData);
|
||||||
expectEqual(userDataAfter, expectedUserData);
|
expectEqual(userDataAfter, expectedUserData);
|
||||||
|
|
||||||
|
|
|
@ -953,14 +953,25 @@ export const calcExpectedReserveDataAfterStableRateRebalance = (
|
||||||
|
|
||||||
expectedReserveData.availableLiquidity = reserveDataBeforeAction.availableLiquidity;
|
expectedReserveData.availableLiquidity = reserveDataBeforeAction.availableLiquidity;
|
||||||
|
|
||||||
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
|
//removing the stable liquidity at the old rate
|
||||||
|
|
||||||
|
const avgRateBefore = calcExpectedAverageStableBorrowRate(
|
||||||
reserveDataBeforeAction.averageStableBorrowRate,
|
reserveDataBeforeAction.averageStableBorrowRate,
|
||||||
reserveDataBeforeAction.totalBorrowsStable,
|
reserveDataBeforeAction.totalBorrowsStable.plus(debtAccrued),
|
||||||
debtAccrued,
|
stableBorrowBalance.negated(),
|
||||||
userDataBeforeAction.stableBorrowRate
|
userDataBeforeAction.stableBorrowRate
|
||||||
);
|
);
|
||||||
|
// adding it again at the new rate
|
||||||
|
|
||||||
|
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
|
||||||
|
avgRateBefore,
|
||||||
|
reserveDataBeforeAction.totalBorrowsStable.minus(userDataBeforeAction.principalStableBorrowBalance),
|
||||||
|
stableBorrowBalance,
|
||||||
|
reserveDataBeforeAction.stableBorrowRate
|
||||||
|
);
|
||||||
|
|
||||||
expectedReserveData.totalBorrowsVariable = reserveDataBeforeAction.totalBorrowsVariable;
|
expectedReserveData.totalBorrowsVariable = reserveDataBeforeAction.totalBorrowsVariable;
|
||||||
|
expectedReserveData.totalBorrowsStable = reserveDataBeforeAction.totalBorrowsStable.plus(debtAccrued);
|
||||||
|
|
||||||
expectedReserveData.utilizationRate = calcExpectedUtilizationRate(
|
expectedReserveData.utilizationRate = calcExpectedUtilizationRate(
|
||||||
expectedReserveData.totalBorrowsStable,
|
expectedReserveData.totalBorrowsStable,
|
||||||
|
@ -1013,6 +1024,8 @@ export const calcExpectedUserDataAfterStableRateRebalance = (
|
||||||
txTimestamp
|
txTimestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expectedUserData.stableRateLastUpdated = txTimestamp;
|
||||||
|
|
||||||
expectedUserData.principalVariableBorrowBalance =
|
expectedUserData.principalVariableBorrowBalance =
|
||||||
userDataBeforeAction.principalVariableBorrowBalance;
|
userDataBeforeAction.principalVariableBorrowBalance;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN});
|
||||||
|
|
||||||
const scenarioFolder = './test/helpers/scenarios/';
|
const scenarioFolder = './test/helpers/scenarios/';
|
||||||
|
|
||||||
const selectedScenarios: string[] = ['swap-rate-mode.json'];
|
const selectedScenarios: string[] = ['rebalance-stable-rate.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