This commit is contained in:
boufni95 2024-07-14 16:38:25 +02:00
parent a7cf6d62ac
commit 7dce63af7d

View file

@ -79,11 +79,11 @@ export class LiquidityProvider {
Connect = async () => { Connect = async () => {
await new Promise(res => setTimeout(res, 2000)) await new Promise(res => setTimeout(res, 2000))
this.log("ready")
const res = await this.GetUserState() const res = await this.GetUserState()
if (res.status === 'ERROR') { if (res.status === 'ERROR' && res.reason !== 'timeout') {
return return
} }
this.log("provider ready with balance:", res.status === 'OK' ? res.balance : 0)
this.ready = true this.ready = true
this.queue.forEach(q => q('ready')) this.queue.forEach(q => q('ready'))
this.log("subbing to user operations") this.log("subbing to user operations")
@ -101,9 +101,9 @@ export class LiquidityProvider {
} }
GetUserState = async () => { GetUserState = async () => {
const res = await this.client.GetUserInfo() 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') {
this.log("error getting user info", res) this.log("error getting user info", res.reason)
return res return res
} }
this.utils.stateBundler.AddBalancePoint('providerBalance', res.balance) this.utils.stateBundler.AddBalancePoint('providerBalance', res.balance)