From 4f4552248db0a61498abaa408e3c6fbc3742bdbd Mon Sep 17 00:00:00 2001 From: boufni95 Date: Thu, 20 Jun 2024 19:53:46 +0200 Subject: [PATCH] up --- src/services/lnd/liquidityProvider.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/services/lnd/liquidityProvider.ts b/src/services/lnd/liquidityProvider.ts index 3ae478c8..dccd0484 100644 --- a/src/services/lnd/liquidityProvider.ts +++ b/src/services/lnd/liquidityProvider.ts @@ -28,7 +28,9 @@ export class LiquidityProvider { constructor(pubDestination: string, invoicePaidCb: InvoicePaidCb) { if (!pubDestination) { this.log("No pub provider to liquidity provider, will not be initialized") + return } + this.log("connecting to liquidity provider", pubDestination) this.pubDestination = pubDestination this.invoicePaidCb = invoicePaidCb this.client = newNostrClient({ @@ -71,14 +73,22 @@ export class LiquidityProvider { } GetLatestMaxWithdrawable = async (fetch = false) => { - if (fetch || this.latestMaxWithdrawable === null) { + if (this.latestMaxWithdrawable === null) { + this.log("liquidity provider is not ready yet") + return 0 + } + if (fetch) { await this.CheckUserState() } return this.latestMaxWithdrawable || 0 } GetLatestBalance = async (fetch = false) => { - if (fetch || this.latestBalance === null) { + if (this.latestMaxWithdrawable === null) { + this.log("liquidity provider is not ready yet") + return 0 + } + if (fetch) { await this.CheckUserState() } return this.latestBalance || 0