From 9d5ea3db4c413d5915401fabcfffc791cdda1709 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 1 Nov 2023 08:36:05 -0400 Subject: [PATCH] adjust amount by smallest volume increments --- core/src/main/java/haveno/core/util/coin/CoinUtil.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/haveno/core/util/coin/CoinUtil.java b/core/src/main/java/haveno/core/util/coin/CoinUtil.java index ecdbdc15d0..eb81819825 100644 --- a/core/src/main/java/haveno/core/util/coin/CoinUtil.java +++ b/core/src/main/java/haveno/core/util/coin/CoinUtil.java @@ -166,8 +166,10 @@ public class CoinUtil { long adjustedAmount = HavenoUtils.centinerosToAtomicUnits(Math.round(HavenoUtils.atomicUnitsToCentineros(amountByVolume) / 10000d) * 10000).longValueExact(); // If we are above our trade limit we reduce the amount by the smallestUnitForAmount + BigInteger smallestUnitForAmountUnadjusted = price.getAmountByVolume(smallestUnitForVolume); while (adjustedAmount > maxTradeLimit) { adjustedAmount -= smallestUnitForAmount.longValueExact(); + adjustedAmount -= smallestUnitForAmountUnadjusted.longValueExact(); } adjustedAmount = Math.max(minTradeAmount, adjustedAmount); adjustedAmount = Math.min(maxTradeLimit, adjustedAmount);