Skip to content

Commit

Permalink
Consider partially filled orders invalid by enforcing that the remain…
Browse files Browse the repository at this point in the history
…ingFillableAmount = fillableAmount
  • Loading branch information
fabioberger committed Aug 2, 2019
1 parent beaa983 commit 560ec9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion zeroex/order_validator.go
Expand Up @@ -381,7 +381,10 @@ func (o *OrderValidator) BatchValidate(rawSignedOrders []*SignedOrder, areNewOrd
})
continue
case OSFillable:
if fillableTakerAssetAmount.Cmp(big.NewInt(0)) == 0 {
remainingTakerAssetAmount := big.NewInt(0).Sub(signedOrder.TakerAssetAmount, orderInfo.OrderTakerAssetFilledAmount)
// If `fillableTakerAssetAmount` != `remainingTakerAssetAmount`, the order is partially fillable. We consider
// partially fillable orders as invalid
if fillableTakerAssetAmount.Cmp(remainingTakerAssetAmount) != 0 {
validationResults.Rejected = append(validationResults.Rejected, &RejectedOrderInfo{
OrderHash: orderHash,
SignedOrder: signedOrder,
Expand Down
1 change: 0 additions & 1 deletion zeroex/orderwatch/order_watcher.go
Expand Up @@ -622,7 +622,6 @@ func (w *Watcher) generateOrderEventsIfChanged(hashToOrderWithTxHashes map[commo
} else if oldFillableAmount.Cmp(big.NewInt(0)) == 1 && !oldAmountIsMoreThenNewAmount {
// The order is now fillable for more then it was before. E.g.:
// 1. A fill txn reverted (block-reorg)
// 2. Traders added missing balance/allowance increasing the order's fillability
orderEvent := &zeroex.OrderEvent{
OrderHash: acceptedOrderInfo.OrderHash,
SignedOrder: order.SignedOrder,
Expand Down

0 comments on commit 560ec9d

Please sign in to comment.