mirror of
https://github.com/ZigZagExchange/zksync-lite-market-maker.git
synced 2025-12-17 07:04:23 +01:00
bug fixes for order filling
This commit is contained in:
@@ -98,23 +98,25 @@ async function sendfillrequest(orderreceipt) {
|
|||||||
const quoteCurrency = market.split("-")[1];
|
const quoteCurrency = market.split("-")[1];
|
||||||
const side = orderreceipt[3];
|
const side = orderreceipt[3];
|
||||||
let price = orderreceipt[4];
|
let price = orderreceipt[4];
|
||||||
const baseQuantity = orderreceipt[5].toString();
|
const baseQuantity = orderreceipt[5].toPrecision(8);
|
||||||
const quoteQuantity = orderreceipt[6].toString();
|
const quoteQuantity = orderreceipt[6].toFixed(6);
|
||||||
let tokenSell, tokenBuy, sellQuantity;
|
let tokenSell, tokenBuy, sellQuantity;
|
||||||
if (side === "b") {
|
if (side === "b") {
|
||||||
price = price * 0.9999; // Add a margin of error to price
|
price = price * 0.9997; // Add a margin of error to price
|
||||||
tokenSell = baseCurrency;
|
tokenSell = baseCurrency;
|
||||||
tokenBuy = quoteCurrency;
|
tokenBuy = quoteCurrency;
|
||||||
sellQuantity = baseQuantity;
|
sellQuantity = baseQuantity;
|
||||||
} else if (side === "s") {
|
} else if (side === "s") {
|
||||||
price = price * 1.0001; // Add a margin of error to price
|
price = price * 1.0003; // Add a margin of error to price
|
||||||
tokenSell = quoteCurrency;
|
tokenSell = quoteCurrency;
|
||||||
tokenBuy = baseCurrency;
|
tokenBuy = baseCurrency;
|
||||||
sellQuantity = quoteQuantity;
|
sellQuantity = quoteQuantity;
|
||||||
}
|
}
|
||||||
const tokenRatio = {};
|
const tokenRatio = {};
|
||||||
tokenRatio[baseCurrency] = 1;
|
tokenRatio[baseCurrency] = 1;
|
||||||
tokenRatio[quoteCurrency] = parseFloat(price.toPrecision(6));
|
tokenRatio[quoteCurrency] = parseFloat(price.toFixed(6));
|
||||||
|
console.log(sellQuantity);
|
||||||
|
console.log(tokenRatio);
|
||||||
const fillOrder = await syncWallet.getOrder({
|
const fillOrder = await syncWallet.getOrder({
|
||||||
tokenSell,
|
tokenSell,
|
||||||
tokenBuy,
|
tokenBuy,
|
||||||
|
|||||||
Reference in New Issue
Block a user