Skip to content

Commit

Permalink
Revert "Fix FOK orders so status is always FILLED (#594)"
Browse files Browse the repository at this point in the history
This reverts commit 8a7e862.
  • Loading branch information
Christopher-Li committed Oct 16, 2023
1 parent a814748 commit d720ed8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ export abstract class AbstractOrderFillHandler<T> extends Handler<T> {
* 1. Stateful Orders - All cancelations are on-chain events, so the order can be `OPEN` or
* `BEST_EFFORT_CANCELED` if the order is in the CanceledOrdersCache.
* 2. Short-term FOK - FOK orders can never be `OPEN`, since they don't rest on the orderbook, so
* totalFilled cannot be < size. By the end of the block, the order will be filled, so we mark
* it as `FILLED`.
* totalFilled cannot be < size.
* 3. Short-term IOC - Protocol guarantees that an IOC order will only ever be filled in a single
* block, so status should be `CANCELED`.
* 4. Short-term Limit & Post-only - If the order is in the CanceledOrdersCache, then it should be
Expand All @@ -370,7 +369,14 @@ export abstract class AbstractOrderFillHandler<T> extends Handler<T> {
}
return OrderStatus.OPEN;
} else if (timeInForce === TimeInForce.FOK) { // 2. Short-term FOK
return OrderStatus.FILLED;
logger.error({
at: 'orderFillHandler#getOrderStatus',
message: 'FOK orders should never be partially filled',
blockHeight: this.block.height,
transactionIndex: this.indexerTendermintEvent.transactionIndex,
eventIndex: this.indexerTendermintEvent.eventIndex,
});
return OrderStatus.CANCELED;
} else if (timeInForce === TimeInForce.IOC) { // 3. Short-term IOC
return OrderStatus.CANCELED;
} else if (isCanceled) { // 4. Short-term Limit & Post-only
Expand Down
6 changes: 3 additions & 3 deletions indexer/services/ender/src/scripts/dydx_get_order_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* 1. Stateful Orders - All cancelations are on-chain events, so the order can be `OPEN` or
* `BEST_EFFORT_CANCELED` if the order is in the CanceledOrdersCache.
* 2. Short-term FOK - FOK orders can never be `OPEN`, since they don't rest on the orderbook, so
* totalFilled cannot be < size. By the end of the block, the order will be filled, so we mark
* it as `FILLED`.
* totalFilled cannot be < size.
* 3. Short-term IOC - Protocol guarantees that an IOC order will only ever be filled in a single
* block, so status should be `CANCELED`.
* 4. Short-term Limit & Post-only - If the order is in the CanceledOrdersCache, then it should be
Expand All @@ -27,7 +26,8 @@ BEGIN
RETURN 'OPEN';
END IF;
ELSIF time_in_force = 'FOK' THEN /** 2. Short-term FOK */
RETURN 'FILLED';
/** TODO(IND-439): Match knex and SQL behavior, have this log and return CANCELED */
RAISE EXCEPTION 'FOK orders should never be partially filled';
ELSIF time_in_force = 'IOC' THEN /** 3. Short-term IOC */
RETURN 'CANCELED';
ELSIF is_cancelled THEN /** 4. Short-term Limit & Postonly */
Expand Down

0 comments on commit d720ed8

Please sign in to comment.