From f10c43b2a416c039959a1e255eaba12b87b3364b Mon Sep 17 00:00:00 2001 From: Pratik Date: Fri, 5 Aug 2022 18:14:49 +0530 Subject: [PATCH] minor refactor liquidation --- x/liquidation/keeper/liquidate_borrow.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x/liquidation/keeper/liquidate_borrow.go b/x/liquidation/keeper/liquidate_borrow.go index e85481391..64427ba58 100644 --- a/x/liquidation/keeper/liquidate_borrow.go +++ b/x/liquidation/keeper/liquidate_borrow.go @@ -28,7 +28,6 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { liqThreshold, _ := k.GetAssetRatesStats(ctx, lendPair.AssetIn) liqThresholdBridgedAssetOne, _ := k.GetAssetRatesStats(ctx, pool.FirstBridgedAssetID) liqThresholdBridgedAssetTwo, _ := k.GetAssetRatesStats(ctx, pool.SecondBridgedAssetID) - k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) if borrowPos.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { currentCollateralizationRatio, _ = k.CalculateLendCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut, assetOut) @@ -38,6 +37,7 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { if err != nil { continue } + k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) k.DeleteBorrow(ctx, v) err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, v, false) if err != nil { @@ -63,6 +63,7 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { if err != nil { continue } + k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) k.DeleteBorrow(ctx, v) err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, v, false) if err != nil { @@ -86,6 +87,7 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { if err != nil { continue } + k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) k.DeleteBorrow(ctx, v) err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, v, false) if err != nil {