From d339e421f82de9e2996e45e71d745d81dff2f3f0 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf <1028334+nikhilsaraf@users.noreply.github.com> Date: Sat, 1 Dec 2018 16:16:11 -0800 Subject: [PATCH] fix op_underfunded issue, fixes #69 (#70) --- plugins/sellSideStrategy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/sellSideStrategy.go b/plugins/sellSideStrategy.go index d68c31d75..0e08385f7 100644 --- a/plugins/sellSideStrategy.go +++ b/plugins/sellSideStrategy.go @@ -293,7 +293,9 @@ func (s *sellSideStrategy) UpdateWithOps(offers []horizon.Offer) (ops []build.Tr return nil, nil, fmt.Errorf("unable to update existing offers or create new offers: %s", e) } if op != nil { - if hitCapacityLimit && isModify { + reducedOrderSize := isModify && targetAmount.AsFloat() < utils.AmountStringAsFloat(offers[i].Amount) + hitCapacityLimitModify := isModify && hitCapacityLimit + if reducedOrderSize || hitCapacityLimitModify { // prepend operations that reduce the size of an existing order because they decrease our liabilities ops = append([]build.TransactionMutator{op}, ops...) } else {