Skip to content

Commit 9ef83f2

Browse files
committed
improve interest calculation for defaulted loans
1 parent ae388d0 commit 9ef83f2

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

x/lending/keeper/liquidation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (k Keeper) HandleLiquidation(ctx sdk.Context, loan *types.Loan) {
3232

3333
// check if the loan has defaulted
3434
if ctx.BlockTime().Unix() >= loan.MaturityTime {
35-
liquidationInterest = loan.Interest
35+
liquidationInterest = k.GetCurrentInterest(ctx, loan).Amount
3636
loan.Status = types.LoanStatus_Defaulted
3737

3838
liquidationCet = dlcMeta.DefaultLiquidationCet.Tx

x/lending/keeper/loan.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,7 @@ func (k Keeper) GetCurrentInterest(ctx sdk.Context, loan *types.Loan) sdk.Coin {
386386
repayment := k.GetRepayment(ctx, loan.VaultAddress)
387387
interest = repayment.Amount.Sub(loan.BorrowAmount).Amount
388388

389-
case types.LoanStatus_Defaulted:
390-
interest = loan.Interest
391-
392-
case types.LoanStatus_Liquidated:
389+
case types.LoanStatus_Defaulted, types.LoanStatus_Liquidated:
393390
liquidation := k.liquidationKeeper.GetLiquidation(ctx, loan.LiquidationId)
394391
interest = liquidation.DebtAmount.Amount.Sub(loan.BorrowAmount.Amount)
395392

0 commit comments

Comments
 (0)