This commit is contained in:
shocknet-justin 2025-12-19 02:28:35 -05:00
parent 0a5f2eea93
commit 4b6216612f

View file

@ -132,9 +132,6 @@ export class LiquidityProvider {
} }
GetUserState = async () => { GetUserState = async () => {
if (!this.configured) {
throw new Error("liquidity provider not initialized")
}
const res = await Promise.race([this.client.GetUserInfo(), new Promise<Types.ResultError>(res => setTimeout(() => res({ status: 'ERROR', reason: 'timeout' }), 10 * 1000))]) const res = await Promise.race([this.client.GetUserInfo(), new Promise<Types.ResultError>(res => setTimeout(() => res({ status: 'ERROR', reason: 'timeout' }), 10 * 1000))])
if (res.status === 'ERROR') { if (res.status === 'ERROR') {
if (res.reason !== 'timeout') { if (res.reason !== 'timeout') {
@ -214,9 +211,6 @@ export class LiquidityProvider {
if (!this.IsReady()) { if (!this.IsReady()) {
throw new Error("liquidity provider is not ready yet, disabled or unreachable") throw new Error("liquidity provider is not ready yet, disabled or unreachable")
} }
if (!this.configured) {
throw new Error("liquidity provider not initialized")
}
const res = await this.client.NewInvoice({ amountSats: amount, memo, expiry }) const res = await this.client.NewInvoice({ amountSats: amount, memo, expiry })
if (res.status === 'ERROR') { if (res.status === 'ERROR') {
this.log("error creating invoice", res.reason) this.log("error creating invoice", res.reason)
@ -236,9 +230,6 @@ export class LiquidityProvider {
if (!this.IsReady()) { if (!this.IsReady()) {
throw new Error("liquidity provider is not ready yet, disabled or unreachable") throw new Error("liquidity provider is not ready yet, disabled or unreachable")
} }
if (!this.configured) {
throw new Error("liquidity provider not initialized")
}
const fees = this.GetFees() const fees = this.GetFees()
const providerServiceFee = this.GetServiceFee(decodedAmount, fees) const providerServiceFee = this.GetServiceFee(decodedAmount, fees)
if (feeLimit && providerServiceFee > feeLimit) { if (feeLimit && providerServiceFee > feeLimit) {
@ -278,9 +269,6 @@ export class LiquidityProvider {
if (!this.IsReady()) { if (!this.IsReady()) {
throw new Error("liquidity provider is not ready yet, disabled or unreachable") throw new Error("liquidity provider is not ready yet, disabled or unreachable")
} }
if (!this.configured || !this.utils.nostrSender.IsReady()) {
throw new Error("liquidity provider not initialized")
}
const res = await this.client.GetPaymentState({ invoice }) const res = await this.client.GetPaymentState({ invoice })
if (res.status === 'ERROR') { if (res.status === 'ERROR') {
this.log("error getting payment state", res.reason) this.log("error getting payment state", res.reason)
@ -293,9 +281,6 @@ export class LiquidityProvider {
if (!this.IsReady()) { if (!this.IsReady()) {
throw new Error("liquidity provider is not ready yet, disabled or unreachable") throw new Error("liquidity provider is not ready yet, disabled or unreachable")
} }
if (!this.configured || !this.utils.nostrSender.IsReady()) {
throw new Error("liquidity provider not initialized")
}
const res = await this.client.GetUserOperations({ const res = await this.client.GetUserOperations({
latestIncomingInvoice: { ts: 0, id: 0 }, latestOutgoingInvoice: { ts: 0, id: 0 }, latestIncomingInvoice: { ts: 0, id: 0 }, latestOutgoingInvoice: { ts: 0, id: 0 },
latestIncomingTx: { ts: 0, id: 0 }, latestOutgoingTx: { ts: 0, id: 0 }, latestIncomingUserToUserPayment: { ts: 0, id: 0 }, latestIncomingTx: { ts: 0, id: 0 }, latestOutgoingTx: { ts: 0, id: 0 }, latestIncomingUserToUserPayment: { ts: 0, id: 0 },