From 07868a5a1424b948a365473a1ff8d7b51fc9a704 Mon Sep 17 00:00:00 2001 From: boufni95 Date: Thu, 15 Jan 2026 14:30:52 +0000 Subject: [PATCH] no negative max --- src/services/main/liquidityProvider.ts | 3 ++- src/services/main/paymentManager.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/main/liquidityProvider.ts b/src/services/main/liquidityProvider.ts index b03c30f3..1f8fe2dd 100644 --- a/src/services/main/liquidityProvider.ts +++ b/src/services/main/liquidityProvider.ts @@ -164,7 +164,8 @@ export class LiquidityProvider { const div = 1 + (serviceFeeBps / 10000) const maxWithoutFixed = Math.floor(balance / div) const fee = balance - maxWithoutFixed - return balance - Math.max(fee, serviceFeeFloor) + const m = balance - Math.max(fee, serviceFeeFloor) + return Math.max(m, 0) } GetLatestBalance = () => { diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index 4d498023..3c7812db 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -397,7 +397,8 @@ export default class { const div = 1 + (serviceFeeBps / 10000) const maxWithoutFixed = Math.floor(balance / div) const fee = balance - maxWithoutFixed - const max = balance - Math.max(fee, serviceFeeFloor) + const m = balance - Math.max(fee, serviceFeeFloor) + const max = Math.max(m, 0) return { max, serviceFeeFloor, serviceFeeBps } } async DecodeInvoice(req: Types.DecodeInvoiceRequest): Promise {