up
This commit is contained in:
parent
4f4552248d
commit
72659e640c
4 changed files with 12 additions and 3 deletions
|
|
@ -102,7 +102,7 @@ export class LiquidityProvider {
|
|||
}
|
||||
this.latestMaxWithdrawable = res.max_withdrawable
|
||||
this.latestBalance = res.balance
|
||||
this.log("latest provider balance:", res.max_withdrawable)
|
||||
this.log("latest provider balance:", res.balance, "latest max withdrawable:", res.max_withdrawable)
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,9 @@ export class VoltageLSP extends LSP {
|
|||
body: JSON.stringify({ amount_msat: amtMsat, pubkey }),
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
const json = await res.json() as { fee_amount_msat: number, id: string }
|
||||
const resText = await res.text()
|
||||
this.log("fee response", resText)
|
||||
const json = JSON.parse(resText) as { fee_amount_msat: number, id: string }
|
||||
return json
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ export default class {
|
|||
const balanceEvents = await this.paymentManager.GetLndBalance()
|
||||
await this.metricsManager.NewBlockCb(height, balanceEvents)
|
||||
confirmed = await this.paymentManager.CheckNewlyConfirmedTxs(height)
|
||||
this.liquidityManager.onNewBlock()
|
||||
} catch (err: any) {
|
||||
log(ERROR, "failed to check transactions after new block", err.message || err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export class LiquidityManager {
|
|||
flashsatsLSP: FlashsatsLSP
|
||||
log = getLogger({ component: "liquidityManager" })
|
||||
channelRequested = false
|
||||
channelRequesting = false
|
||||
constructor(settings: LiquiditySettings, storage: Storage, liquidityProvider: LiquidityProvider, lnd: LND) {
|
||||
this.settings = settings
|
||||
this.storage = storage
|
||||
|
|
@ -58,14 +59,16 @@ export class LiquidityManager {
|
|||
if (existingOrder) {
|
||||
return
|
||||
}
|
||||
if (this.channelRequested) {
|
||||
if (this.channelRequested || this.channelRequesting) {
|
||||
return
|
||||
}
|
||||
this.channelRequesting = true
|
||||
this.log("checking if channel should be requested")
|
||||
const olympusOk = await this.olympusLSP.openChannelIfReady()
|
||||
if (olympusOk) {
|
||||
this.log("requested channel from olympus")
|
||||
this.channelRequested = true
|
||||
this.channelRequesting = false
|
||||
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'olympus', invoice: olympusOk.invoice, total_paid: olympusOk.totalSats, order_id: olympusOk.orderId, fees: olympusOk.fees })
|
||||
return
|
||||
}
|
||||
|
|
@ -73,6 +76,7 @@ export class LiquidityManager {
|
|||
if (voltageOk) {
|
||||
this.log("requested channel from voltage")
|
||||
this.channelRequested = true
|
||||
this.channelRequesting = false
|
||||
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'voltage', invoice: voltageOk.invoice, total_paid: voltageOk.totalSats, order_id: voltageOk.orderId, fees: voltageOk.fees })
|
||||
return
|
||||
}
|
||||
|
|
@ -81,9 +85,11 @@ export class LiquidityManager {
|
|||
if (flashsatsOk) {
|
||||
this.log("requested channel from flashsats")
|
||||
this.channelRequested = true
|
||||
this.channelRequesting = false
|
||||
await this.storage.liquidityStorage.SaveLspOrder({ service_name: 'flashsats', invoice: flashsatsOk.invoice, total_paid: flashsatsOk.totalSats, order_id: flashsatsOk.orderId, fees: flashsatsOk.fees })
|
||||
return
|
||||
}
|
||||
this.channelRequesting = false
|
||||
this.log("no channel requested")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue