mirror of
https://github.com/ZigZagExchange/zksync-lite-market-maker.git
synced 2025-12-17 23:24:19 +01:00
@@ -233,29 +233,6 @@ function isOrderFillable(order) {
|
|||||||
const expires = order[7];
|
const expires = order[7];
|
||||||
const side = order[3];
|
const side = order[3];
|
||||||
const price = order[4];
|
const price = order[4];
|
||||||
const sellCurrency = (side === 's') ? market.quoteAsset.symbol : market.baseAsset.symbol;
|
|
||||||
const sellDecimals = (side === 's') ? market.quoteAsset.decimals : market.baseAsset.decimals;
|
|
||||||
const sellQuantity = (side === 's') ? quoteQuantity : baseQuantity;
|
|
||||||
const neededBalanceBN = sellQuantity * 10**sellDecimals;
|
|
||||||
let goodWalletIds = [];
|
|
||||||
Object.keys(WALLETS).forEach(accountId => {
|
|
||||||
const walletBalance = WALLETS[accountId]['account_state'].committed.balances[sellCurrency];
|
|
||||||
if (Number(walletBalance) > (neededBalanceBN * 1.05)) {
|
|
||||||
goodWalletIds.push(accountId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (goodWalletIds.length === 0) {
|
|
||||||
return { fillable: false, reason: "badbalance" };
|
|
||||||
}
|
|
||||||
|
|
||||||
goodWalletIds = goodWalletIds.filter(accountId => {
|
|
||||||
return !WALLETS[accountId]['ORDER_BROADCASTING'];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (goodWalletIds.length === 0) {
|
|
||||||
return { fillable: false, reason: "sending order already" };
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = Date.now() / 1000 | 0;
|
const now = Date.now() / 1000 | 0;
|
||||||
|
|
||||||
@@ -286,6 +263,31 @@ function isOrderFillable(order) {
|
|||||||
else if (side == 'b' && price < quote.quotePrice) {
|
else if (side == 'b' && price < quote.quotePrice) {
|
||||||
return { fillable: false, reason: "badprice" };
|
return { fillable: false, reason: "badprice" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sellCurrency = (side === 's') ? market.quoteAsset.symbol : market.baseAsset.symbol;
|
||||||
|
const sellDecimals = (side === 's') ? market.quoteAsset.decimals : market.baseAsset.decimals;
|
||||||
|
const sellQuantity = (side === 's') ? quote.quoteQuantity : baseQuantity;
|
||||||
|
const neededBalanceBN = sellQuantity * 10**sellDecimals;
|
||||||
|
let goodWalletIds = [];
|
||||||
|
Object.keys(WALLETS).forEach(accountId => {
|
||||||
|
const walletBalance = WALLETS[accountId]['account_state'].committed.balances[sellCurrency];
|
||||||
|
if (Number(walletBalance) > (neededBalanceBN * 1.05)) {
|
||||||
|
goodWalletIds.push(accountId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (goodWalletIds.length === 0) {
|
||||||
|
return { fillable: false, reason: "badbalance" };
|
||||||
|
}
|
||||||
|
|
||||||
|
goodWalletIds = goodWalletIds.filter(accountId => {
|
||||||
|
return !WALLETS[accountId]['ORDER_BROADCASTING'];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (goodWalletIds.length === 0) {
|
||||||
|
return { fillable: false, reason: "sending order already" };
|
||||||
|
}
|
||||||
|
|
||||||
return { fillable: true, reason: null, walletId: goodWalletIds[0]};
|
return { fillable: true, reason: null, walletId: goodWalletIds[0]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user