Skip to content

Commit 5f3793a

Browse files
authored
fix(orderbook): don't remove 0 quantity w/ hold (#1921)
This fixes a bug whereby attempting to remove an order that is entirely on hold would throw an error due to trying to remove zero quantity from an order. Instead, if the entire order is on hold we skip removing any portion that is not on hold (since there is none) and wait for the hold to be lifted and remove any quantity.
1 parent 7edae02 commit 5f3793a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: lib/orderbook/OrderBook.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -860,12 +860,15 @@ class OrderBook extends EventEmitter {
860860
throw errors.QUANTITY_ON_HOLD(localId, order.hold);
861861
}
862862

863-
this.removeOwnOrder({
864-
orderId: order.id,
865-
pairId: order.pairId,
866-
quantityToRemove: removableQuantity,
867-
});
868-
remainingQuantityToRemove -= removableQuantity;
863+
if (removableQuantity > 0) {
864+
// we can remove any portion of the order that's not on hold up front
865+
this.removeOwnOrder({
866+
orderId: order.id,
867+
pairId: order.pairId,
868+
quantityToRemove: removableQuantity,
869+
});
870+
remainingQuantityToRemove -= removableQuantity;
871+
}
869872

870873
const failedHandler = (deal: SwapDeal) => {
871874
if (deal.orderId === order.id) {

0 commit comments

Comments
 (0)