Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

serum-vial

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serum-vial - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

@@ -307,2 +307,3 @@ "use strict";

_addOpenOrdersForImmediateMakerFills(l3Diff, timestamp, slot) {
const openOrdersToAdd = [];
for (const item of l3Diff) {

@@ -315,3 +316,3 @@ // for maker fills check first if there's existing open order for it

if (hasMatchingOpenOrder === false) {
var openMessage = {
const openMessage = {
type: 'open',

@@ -331,14 +332,17 @@ market: this._options.symbol,

};
const matchingL3Index = l3Diff.findIndex((i) => i.orderId === item.orderId);
// insert open order before first matching l3 index if it exists
if (matchingL3Index !== -1) {
l3Diff.splice(matchingL3Index, 0, openMessage);
}
else {
// if there's not matching fill/done l3 add open order at the end
l3Diff.push(openMessage);
}
openOrdersToAdd.push(openMessage);
}
}
}
for (const openOrder of openOrdersToAdd) {
const matchingL3Index = l3Diff.findIndex((i) => i.type === 'fill' && i.maker === true && i.orderId === openOrder.orderId);
// insert open order before first matching l3 index if it exists
if (matchingL3Index !== -1) {
l3Diff.splice(matchingL3Index, 0, openOrder);
}
else {
// if there's not matching fill/done l3 add open order at the end
l3Diff.push(openOrder);
}
}
}

@@ -399,25 +403,2 @@ reset() {

if (item.type === 'done') {
if (item.reason === 'canceled') {
const matchingOrder = ordersMap.get(item.orderId);
if (matchingOrder !== undefined) {
if (matchingOrder.price !== item.price) {
logger_1.logger.log('warn', 'Done(cancel) message with incorrect price', {
market: this._options.symbol,
doneMessage: item,
matchingOrder,
slot: item.slot
});
return false;
}
if (matchingOrder.size !== item.sizeRemaining) {
logger_1.logger.log('warn', 'Done(cancel) message with incorrect sizeRemaining', {
market: this._options.symbol,
doneMessage: item,
matchingOrder,
slot: item.slot
});
return false;
}
}
}
ordersMap.delete(item.orderId);

@@ -592,6 +573,10 @@ }

accountSlot: openOrdersSlot,
sizeRemaining: reason === 'canceled' ? this._getDoneSize(event).toFixed(this._options.sizeDecimalPlaces) : undefined,
price: reason === 'canceled'
? this._options.market.priceLotsToNumber(event.orderId.ushrn(64)).toFixed(this._options.priceDecimalPlaces)
: undefined
sizeRemaining: undefined,
price: undefined
// sizeRemaining:
// reason === 'canceled' ? this._getDoneSize(event).toFixed(this._options.sizeDecimalPlaces) : undefined,
// price:
// reason === 'canceled'
// ? this._options.market.priceLotsToNumber(event.orderId.ushrn(64)).toFixed(this._options.priceDecimalPlaces)
// : undefined
};

@@ -598,0 +583,0 @@ return doneMessage;

{
"name": "serum-vial",
"version": "1.3.0",
"version": "1.3.1",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=15"

@@ -433,2 +433,4 @@ import { EVENT_QUEUE_LAYOUT, Market, Orderbook, getLayoutVersion } from '@project-serum/serum'

) {
const openOrdersToAdd: Open[] = []
for (const item of l3Diff) {

@@ -441,3 +443,3 @@ // for maker fills check first if there's existing open order for it

if (hasMatchingOpenOrder === false) {
var openMessage: Open = {
const openMessage: Open = {
type: 'open',

@@ -458,13 +460,19 @@ market: this._options.symbol,

const matchingL3Index = l3Diff.findIndex((i) => i.orderId === item.orderId)
// insert open order before first matching l3 index if it exists
if (matchingL3Index !== -1) {
l3Diff.splice(matchingL3Index, 0, openMessage)
} else {
// if there's not matching fill/done l3 add open order at the end
l3Diff.push(openMessage)
}
openOrdersToAdd.push(openMessage)
}
}
}
for (const openOrder of openOrdersToAdd) {
const matchingL3Index = l3Diff.findIndex(
(i) => i.type === 'fill' && i.maker === true && i.orderId === openOrder.orderId
)
// insert open order before first matching l3 index if it exists
if (matchingL3Index !== -1) {
l3Diff.splice(matchingL3Index, 0, openOrder)
} else {
// if there's not matching fill/done l3 add open order at the end
l3Diff.push(openOrder)
}
}
}

@@ -536,29 +544,2 @@

if (item.type === 'done') {
if (item.reason === 'canceled') {
const matchingOrder = ordersMap.get(item.orderId)
if (matchingOrder !== undefined) {
if (matchingOrder.price !== item.price) {
logger.log('warn', 'Done(cancel) message with incorrect price', {
market: this._options.symbol,
doneMessage: item,
matchingOrder,
slot: item.slot
})
return false
}
if (matchingOrder.size !== item.sizeRemaining) {
logger.log('warn', 'Done(cancel) message with incorrect sizeRemaining', {
market: this._options.symbol,
doneMessage: item,
matchingOrder,
slot: item.slot
})
return false
}
}
}
ordersMap.delete(item.orderId)

@@ -771,10 +752,11 @@ }

accountSlot: openOrdersSlot,
sizeRemaining:
reason === 'canceled' ? this._getDoneSize(event).toFixed(this._options.sizeDecimalPlaces) : undefined,
price:
reason === 'canceled'
? this._options.market.priceLotsToNumber(event.orderId.ushrn(64)).toFixed(this._options.priceDecimalPlaces)
: undefined
sizeRemaining: undefined,
price: undefined
// sizeRemaining:
// reason === 'canceled' ? this._getDoneSize(event).toFixed(this._options.sizeDecimalPlaces) : undefined,
// price:
// reason === 'canceled'
// ? this._options.market.priceLotsToNumber(event.orderId.ushrn(64)).toFixed(this._options.priceDecimalPlaces)
// : undefined
}
return doneMessage

@@ -781,0 +763,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet