diff --git a/marketmaker.js b/marketmaker.js index f2e6fd4..d61192b 100644 --- a/marketmaker.js +++ b/marketmaker.js @@ -89,9 +89,11 @@ try { console.log(signKeyResult); } let accountId = await syncWallet.getAccountId(); + let account_state = await syncWallet.getAccountState(); WALLETS[accountId] = { 'ethWallet': ethWallet, 'syncWallet': syncWallet, + 'account_state': account_state, 'ORDER_BROADCASTING': false, } } @@ -101,8 +103,7 @@ try { } // Update account state loop -await updateAccountState(); -setInterval(updateAccountState, 150000); +setInterval(updateAccountState, 900000); let fillOrdersInterval, indicateLiquidityInterval; let zigzagws = new WebSocket(MM_CONFIG.zigzagWsUrl); @@ -911,23 +912,14 @@ function rememberOrder(chainId, marketId, orderId, price, sellSymbol, sellQuanti } async function updateAccountState() { - let lowBalance = false; try { - const promise = Object.keys(WALLETS).map(accountId => { - const accountState = WALLETS[accountId].syncWallet.getAccountState(); - const ethBalance = accountState?.committed?.balances?.ETH - ? ethers.utils.formatEther(accountState.committed.balances.ETH).toNumber() - : 0 - if (ethBalance < 0.01) { - lowBalance = true; - return; - } - WALLETS[accountId]['account_state'] = accountState; + Object.keys(WALLETS).forEach(accountId => { + (WALLETS[accountId]['syncWallet']).getAccountState().then((state) => { + WALLETS[accountId]['account_state'] = state; + }) }); - await Promise.all(promise); } catch(err) { // pass } - if (lowBalance) throw new Error('Your ETH balance is to low to run the marketmaker bot. You need at least 0.01 ETH!') }