mirror of
https://github.com/ZigZagExchange/zksync-lite-market-maker.git
synced 2025-12-17 07:04:23 +01:00
revert
This commit is contained in:
@@ -89,9 +89,11 @@ try {
|
|||||||
console.log(signKeyResult);
|
console.log(signKeyResult);
|
||||||
}
|
}
|
||||||
let accountId = await syncWallet.getAccountId();
|
let accountId = await syncWallet.getAccountId();
|
||||||
|
let account_state = await syncWallet.getAccountState();
|
||||||
WALLETS[accountId] = {
|
WALLETS[accountId] = {
|
||||||
'ethWallet': ethWallet,
|
'ethWallet': ethWallet,
|
||||||
'syncWallet': syncWallet,
|
'syncWallet': syncWallet,
|
||||||
|
'account_state': account_state,
|
||||||
'ORDER_BROADCASTING': false,
|
'ORDER_BROADCASTING': false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,8 +103,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update account state loop
|
// Update account state loop
|
||||||
await updateAccountState();
|
setInterval(updateAccountState, 900000);
|
||||||
setInterval(updateAccountState, 150000);
|
|
||||||
|
|
||||||
let fillOrdersInterval, indicateLiquidityInterval;
|
let fillOrdersInterval, indicateLiquidityInterval;
|
||||||
let zigzagws = new WebSocket(MM_CONFIG.zigzagWsUrl);
|
let zigzagws = new WebSocket(MM_CONFIG.zigzagWsUrl);
|
||||||
@@ -911,23 +912,14 @@ function rememberOrder(chainId, marketId, orderId, price, sellSymbol, sellQuanti
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateAccountState() {
|
async function updateAccountState() {
|
||||||
let lowBalance = false;
|
|
||||||
try {
|
try {
|
||||||
const promise = Object.keys(WALLETS).map(accountId => {
|
Object.keys(WALLETS).forEach(accountId => {
|
||||||
const accountState = WALLETS[accountId].syncWallet.getAccountState();
|
(WALLETS[accountId]['syncWallet']).getAccountState().then((state) => {
|
||||||
const ethBalance = accountState?.committed?.balances?.ETH
|
WALLETS[accountId]['account_state'] = state;
|
||||||
? ethers.utils.formatEther(accountState.committed.balances.ETH).toNumber()
|
})
|
||||||
: 0
|
|
||||||
if (ethBalance < 0.01) {
|
|
||||||
lowBalance = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WALLETS[accountId]['account_state'] = accountState;
|
|
||||||
});
|
});
|
||||||
await Promise.all(promise);
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
if (lowBalance) throw new Error('Your ETH balance is to low to run the marketmaker bot. You need at least 0.01 ETH!')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user