bug fixes for order filling

This commit is contained in:
vixidev99
2021-11-05 13:59:48 -07:00
parent 33fec2262e
commit 58940c6b64

View File

@@ -98,23 +98,25 @@ async function sendfillrequest(orderreceipt) {
const quoteCurrency = market.split("-")[1];
const side = orderreceipt[3];
let price = orderreceipt[4];
const baseQuantity = orderreceipt[5].toString();
const quoteQuantity = orderreceipt[6].toString();
const baseQuantity = orderreceipt[5].toPrecision(8);
const quoteQuantity = orderreceipt[6].toFixed(6);
let tokenSell, tokenBuy, sellQuantity;
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;
tokenBuy = quoteCurrency;
sellQuantity = baseQuantity;
} 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;
tokenBuy = baseCurrency;
sellQuantity = quoteQuantity;
}
const tokenRatio = {};
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({
tokenSell,
tokenBuy,