From 5ddbc9b8f5a7238498b035232d240c74bc3f529f Mon Sep 17 00:00:00 2001 From: boufni95 Date: Sat, 13 Jul 2024 21:37:02 +0200 Subject: [PATCH] fix --- src/services/main/liquidityProvider.ts | 8 ++++---- src/services/main/rugPullTracker.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/main/liquidityProvider.ts b/src/services/main/liquidityProvider.ts index f89efc55..d6148035 100644 --- a/src/services/main/liquidityProvider.ts +++ b/src/services/main/liquidityProvider.ts @@ -28,9 +28,9 @@ export class LiquidityProvider { queue: ((state: 'ready') => void)[] = [] utils: Utils pendingPayments: Record = {} - updateProviderBalance: (balance: number) => void + updateProviderBalance: (balance: number) => Promise // make the sub process accept client - constructor(pubDestination: string, utils: Utils, invoicePaidCb: InvoicePaidCb, updateProviderBalance: (balance: number) => void) { + constructor(pubDestination: string, utils: Utils, invoicePaidCb: InvoicePaidCb, updateProviderBalance: (balance: number) => Promise) { this.utils = utils if (!pubDestination) { this.log("No pub provider to liquidity provider, will not be initialized") @@ -192,8 +192,8 @@ export class LiquidityProvider { this.log("error paying invoice", res.reason) throw new Error(res.reason) } - delete this.pendingPayments[invoice] - this.updateProviderBalance(userInfo.balance) + + this.updateProviderBalance(userInfo.balance).then(() => { delete this.pendingPayments[invoice] }) this.utils.stateBundler.AddTxPoint('paidAnInvoice', decodedAmount, { used: 'provider', from, timeDiscount: true }) return res } catch (err) { diff --git a/src/services/main/rugPullTracker.ts b/src/services/main/rugPullTracker.ts index b0c782f9..a2717708 100644 --- a/src/services/main/rugPullTracker.ts +++ b/src/services/main/rugPullTracker.ts @@ -43,7 +43,7 @@ export class RugPullTracker { } checkForDisruption = async (pubDst: string, trackedBalance: number, providerTracker: TrackedProvider) => { - const diff = trackedBalance - providerTracker.latest_balance + const diff = providerTracker.latest_balance - trackedBalance if (diff < 0) { this.rugPulled = true if (providerTracker.latest_distruption_at_unix === 0) {