@@ -17,6 +17,17 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
1717func handleCompletedLiquidations (ctx sdk.Context , k keeper.Keeper ) {
1818 // get completed liquidations
1919 liquidations := k .GetLiquidations (ctx , types .LiquidationStatus_LIQUIDATION_STATUS_LIQUIDATED )
20+ if len (liquidations ) == 0 {
21+ return
22+ }
23+
24+ // get fee rate
25+ feeRate := k .BtcBridgeKeeper ().GetFeeRate (ctx )
26+ if err := k .BtcBridgeKeeper ().CheckFeeRate (ctx , feeRate ); err != nil {
27+ k .Logger (ctx ).Info ("Failed to get fee rate to handle liquidation" , "err" , err )
28+
29+ return
30+ }
2031
2132 for _ , liquidation := range liquidations {
2233 // handle liquidated debt(repay the lending pool)
@@ -28,9 +39,9 @@ func handleCompletedLiquidations(ctx sdk.Context, k keeper.Keeper) {
2839 }
2940
3041 // build settlement tx
31- settlementTx , txHash , sigHashes , changeAmount , err := types .BuildSettlementTransaction (liquidation , k .GetLiquidationRecords (ctx , liquidation .Id ), k .ProtocolLiquidationFeeCollector (ctx ), 5 )
42+ settlementTx , txHash , sigHashes , changeAmount , err := types .BuildSettlementTransaction (liquidation , k .GetLiquidationRecords (ctx , liquidation .Id ), k .ProtocolLiquidationFeeCollector (ctx ), feeRate . Value )
3243 if err != nil {
33- k .Logger (ctx ).Info ("Failed to build settlement transaction" , "liquidation id" , liquidation .Id , "err" , err )
44+ k .Logger (ctx ).Info ("Failed to build settlement transaction" , "liquidation id" , liquidation .Id , "fee rate" , feeRate . Value , " err" , err )
3445
3546 continue
3647 }
0 commit comments