From 4d2406a5e182afc91d85f13c2b473bddb2e9f090 Mon Sep 17 00:00:00 2001 From: The3D Date: Wed, 15 Jul 2020 16:49:56 +0200 Subject: [PATCH] Fixed liquidation tests --- test/liquidation-underlying.spec.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/liquidation-underlying.spec.ts b/test/liquidation-underlying.spec.ts index bb3db061..be3e0401 100644 --- a/test/liquidation-underlying.spec.ts +++ b/test/liquidation-underlying.spec.ts @@ -182,6 +182,18 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', 'Invalid user debt after liquidation' ); + //the liquidity index of the principal reserve needs to be bigger than the index before + expect(daiReserveDataAfter.liquidityIndex.toString()).to.be.bignumber.gt( + daiReserveDataBefore.liquidityIndex.toString(), + 'Invalid liquidity index' + ); + + //the principal APY after a liquidation needs to be lower than the APY before + expect(daiReserveDataAfter.liquidityRate.toString()).to.be.bignumber.lt( + daiReserveDataBefore.liquidityRate.toString(), + 'Invalid liquidity APY' + ); + expect(daiReserveDataAfter.availableLiquidity.toString()).to.be.bignumber.almostEqual( new BigNumber(daiReserveDataBefore.availableLiquidity).plus(amountToLiquidate).toFixed(0), 'Invalid principal available liquidity' @@ -309,6 +321,18 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', 'Invalid user borrow balance after liquidation' ); + //the liquidity index of the principal reserve needs to be bigger than the index before + expect(usdcReserveDataAfter.liquidityIndex.toString()).to.be.bignumber.gt( + usdcReserveDataBefore.liquidityIndex.toString(), + 'Invalid liquidity index' + ); + + //the principal APY after a liquidation needs to be lower than the APY before + expect(usdcReserveDataAfter.liquidityRate.toString()).to.be.bignumber.lt( + usdcReserveDataBefore.liquidityRate.toString(), + 'Invalid liquidity APY' + ); + expect(usdcReserveDataAfter.availableLiquidity.toString()).to.be.bignumber.almostEqual( new BigNumber(usdcReserveDataBefore.availableLiquidity).plus(amountToLiquidate).toFixed(0), 'Invalid principal available liquidity'