diff --git a/src/dexorder/order/orderstate.py b/src/dexorder/order/orderstate.py index 9739131..fc61d38 100644 --- a/src/dexorder/order/orderstate.py +++ b/src/dexorder/order/orderstate.py @@ -106,6 +106,7 @@ class Order: # flattenings of various static data self.order = self.status.order self.amount = self.status.order.amount + self.min_fill_amount = self.status.order.minFillAmount self.amount_is_input = self.status.order.amountIsInput self.tranche_amounts = [t.fraction_of(self.amount) for t in self.order.tranches] Order.instances[self.key] = self diff --git a/src/dexorder/order/triggers.py b/src/dexorder/order/triggers.py index b31e560..d58b109 100644 --- a/src/dexorder/order/triggers.py +++ b/src/dexorder/order/triggers.py @@ -99,7 +99,7 @@ class TrancheTrigger: self.pool_price_multiplier = None # compute status and set relevant triggers - if tranche_remaining <= 0: + if tranche_remaining == 0 or tranche_remaining < self.order.min_fill_amount: # min_fill_amount could be 0 (disabled) so we also check for the 0 case separately self.status = TrancheStatus.Filled return timestamp = current_block.get().timestamp @@ -164,7 +164,7 @@ class TrancheTrigger: def fill(self, _amount_in, _amount_out ): remaining = self.order.tranche_remaining(self.tk.tranche_index) - filled = remaining <= 0 + filled = remaining == 0 or remaining < self.order.min_fill_amount if filled: log.debug(f'tranche filled {self.tk}') self.status = TrancheStatus.Filled