no negative max

This commit is contained in:
boufni95 2026-01-15 14:30:52 +00:00
parent b356d804a2
commit 07868a5a14
2 changed files with 4 additions and 2 deletions

View file

@ -164,7 +164,8 @@ export class LiquidityProvider {
const div = 1 + (serviceFeeBps / 10000) const div = 1 + (serviceFeeBps / 10000)
const maxWithoutFixed = Math.floor(balance / div) const maxWithoutFixed = Math.floor(balance / div)
const fee = balance - maxWithoutFixed const fee = balance - maxWithoutFixed
return balance - Math.max(fee, serviceFeeFloor) const m = balance - Math.max(fee, serviceFeeFloor)
return Math.max(m, 0)
} }
GetLatestBalance = () => { GetLatestBalance = () => {

View file

@ -397,7 +397,8 @@ export default class {
const div = 1 + (serviceFeeBps / 10000) const div = 1 + (serviceFeeBps / 10000)
const maxWithoutFixed = Math.floor(balance / div) const maxWithoutFixed = Math.floor(balance / div)
const fee = balance - maxWithoutFixed 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 } return { max, serviceFeeFloor, serviceFeeBps }
} }
async DecodeInvoice(req: Types.DecodeInvoiceRequest): Promise<Types.DecodeInvoiceResponse> { async DecodeInvoice(req: Types.DecodeInvoiceRequest): Promise<Types.DecodeInvoiceResponse> {