diff --git a/lib/cli/commands/removeallorders.ts b/lib/cli/commands/removeallorders.ts index 7bad3281b..8d2c42fe2 100644 --- a/lib/cli/commands/removeallorders.ts +++ b/lib/cli/commands/removeallorders.ts @@ -16,10 +16,10 @@ const formatOutput = (response: RemoveAllOrdersResponse.AsObject) => { } if (response.removedOrderIdsList.length) { - response.removedOrderIdsList.forEach((removedOrder => console.log(`Cancelled order with id ${removedOrder}`))); + response.removedOrderIdsList.forEach((removedOrder => console.log(`Removed order with id ${removedOrder}`))); } if (response.onHoldOrderIdsList.length) { - response.onHoldOrderIdsList.forEach((onHoldOrder => console.log(`Failed to cancel order with id ${onHoldOrder}`))); + response.onHoldOrderIdsList.forEach((id => console.log(`Order with id ${id} has a hold for a pending swap and will be removed afterwards`))); } }; diff --git a/lib/orderbook/OrderBook.ts b/lib/orderbook/OrderBook.ts index 9e2b1fe39..bc8f86838 100644 --- a/lib/orderbook/OrderBook.ts +++ b/lib/orderbook/OrderBook.ts @@ -831,10 +831,10 @@ class OrderBook extends EventEmitter { const onHoldOrderLocalIds = []; for (const localId of this.localIdMap.keys()) { - try { - this.removeOwnOrderByLocalId(localId, true); + const onHoldIndicator = this.removeOwnOrderByLocalId(localId, true); + if (onHoldIndicator === 0) { removedOrderLocalIds.push(localId); - } catch (ex) { + } else { onHoldOrderLocalIds.push(localId); } } @@ -876,12 +876,15 @@ class OrderBook extends EventEmitter { throw errors.QUANTITY_ON_HOLD(localId, order.hold); } - this.removeOwnOrder({ - orderId: order.id, - pairId: order.pairId, - quantityToRemove: removableQuantity, - }); - remainingQuantityToRemove -= removableQuantity; + if (removableQuantity > 0) { + // we can remove any portion of the order that's not on hold up front + this.removeOwnOrder({ + orderId: order.id, + pairId: order.pairId, + quantityToRemove: removableQuantity, + }); + remainingQuantityToRemove -= removableQuantity; + } const failedHandler = (deal: SwapDeal) => { if (deal.orderId === order.id) {