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

@ex-master/core

Package Overview
Dependencies
Maintainers
2
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ex-master/core - npm Package Compare versions

Comparing version 0.1.58 to 0.1.59

6

bld/exchange/exchange.d.ts

@@ -8,3 +8,3 @@ /// <reference types="node" />

import { AccountBalance } from './factors';
import { OrderDescriptor, OrderPaidFee, OrderType } from './order';
import { Order, OrderDescriptor, OrderPaidFee, OrderType } from './order';
export declare type PrecisionAlignment = 'up' | 'down';

@@ -31,4 +31,4 @@ export interface Market {

canceling: number | false;
becomeInactive: Promise<void>;
becomeInactiveResolver(): void;
becomeInactive: Promise<Order>;
becomeInactiveResolver(order: Order): void;
}

@@ -35,0 +35,0 @@ export interface ExchangeOptions {

@@ -29,3 +29,4 @@ "use strict";

await this.cancelActiveOrders();
this.client.orderUpdate$.subscribe(({ id, active, filledSize, filledValue, paidFee }) => {
this.client.orderUpdate$.subscribe(order => {
let { id, active, filledSize, filledValue, paidFee } = order;
let activeOrderMap = this.activeOrderMap;

@@ -48,3 +49,3 @@ let activeOrder = activeOrderMap.get(id);

else {
activeOrder.becomeInactiveResolver();
activeOrder.becomeInactiveResolver(order);
activeOrderMap.delete(id);

@@ -265,9 +266,9 @@ }

if (this.isBalanceSufficient(descriptor)) {
await this.cancelOrder(active);
await this.checkAvailableAndOrder(group, label, descriptor);
let previousOrder = await this.cancelOrder(active);
await this.checkAvailableAndOrder(group, label, descriptor, previousOrder);
}
else {
await this.cancelOrder(active);
let previousOrder = await this.cancelOrder(active);
await this.tickBalance(active);
await this.checkAvailableAndOrder(group, label, descriptor);
await this.checkAvailableAndOrder(group, label, descriptor, previousOrder);
}

@@ -287,5 +288,10 @@ }

}
async checkAvailableAndOrder(group, label, descriptor) {
async checkAvailableAndOrder(group, label, descriptor, previousOrder) {
let { market, type, price, size } = descriptor;
let originalSize = size;
if (previousOrder &&
type === previousOrder.type &&
object_1.isEqual(market, previousOrder.market)) {
size = decimal_js_1.Decimal.max(size.sub(previousOrder.filledSize), 0);
}
if (type === 'bid') {

@@ -359,3 +365,3 @@ let value = price.mul(size);

}
async cancelOrder(order, wait = true) {
async cancelOrder(order) {
let { group, id, label, becomeInactive } = order;

@@ -365,12 +371,10 @@ this.dashboard.info(`cancel order [${group}] "${label}"`);

await this.client.cancelOrder(order);
if (wait) {
await becomeInactive;
}
return becomeInactive;
}
async cancelOrders(orders, wait) {
async cancelOrders(orders) {
if (!orders.length) {
return;
return [];
}
if (orders.length === 1) {
return this.cancelOrder(orders[0], wait);
return [await this.cancelOrder(orders[0])];
}

@@ -386,3 +390,3 @@ let ordersStr = orders

await this.client.cancelOrders(orders);
await Promise.all(orders.map(order => order.becomeInactive));
return Promise.all(orders.map(order => order.becomeInactive));
}

@@ -389,0 +393,0 @@ async cancelActiveOrders() {

{
"name": "@ex-master/core",
"version": "0.1.58",
"version": "0.1.59",
"main": "bld/index.js",

@@ -5,0 +5,0 @@ "types": "bld/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc