mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-22 02:34:57 +00:00
always round offer amounts to 4 decimal places
This commit is contained in:
parent
130a45c99a
commit
fac901331f
2 changed files with 11 additions and 13 deletions
|
@ -151,11 +151,9 @@ public class CreateOfferService {
|
|||
throw new IllegalArgumentException("Must provide fixed price");
|
||||
}
|
||||
|
||||
// adjust amount and min amount for fixed-price offer
|
||||
if (fixedPrice != null) {
|
||||
amount = CoinUtil.getRoundedAmount(amount, fixedPrice, null, currencyCode, paymentAccount.getPaymentMethod().getId());
|
||||
minAmount = CoinUtil.getRoundedAmount(minAmount, fixedPrice, null, currencyCode, paymentAccount.getPaymentMethod().getId());
|
||||
}
|
||||
// adjust amount and min amount
|
||||
amount = CoinUtil.getRoundedAmount(amount, fixedPrice, null, currencyCode, paymentAccount.getPaymentMethod().getId());
|
||||
minAmount = CoinUtil.getRoundedAmount(minAmount, fixedPrice, null, currencyCode, paymentAccount.getPaymentMethod().getId());
|
||||
|
||||
// generate one-time challenge for private offer
|
||||
String challenge = null;
|
||||
|
|
|
@ -76,14 +76,14 @@ public class CoinUtil {
|
|||
}
|
||||
|
||||
public static BigInteger getRoundedAmount(BigInteger amount, Price price, Long maxTradeLimit, String currencyCode, String paymentMethodId) {
|
||||
if (PaymentMethod.isRoundedForAtmCash(paymentMethodId)) {
|
||||
return getRoundedAtmCashAmount(amount, price, maxTradeLimit);
|
||||
} else if (CurrencyUtil.isVolumeRoundedToNearestUnit(currencyCode)) {
|
||||
return getRoundedAmountUnit(amount, price, maxTradeLimit);
|
||||
} else if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
return getRoundedAmount4Decimals(amount, price, maxTradeLimit);
|
||||
if (price != null) {
|
||||
if (PaymentMethod.isRoundedForAtmCash(paymentMethodId)) {
|
||||
return getRoundedAtmCashAmount(amount, price, maxTradeLimit);
|
||||
} else if (CurrencyUtil.isVolumeRoundedToNearestUnit(currencyCode)) {
|
||||
return getRoundedAmountUnit(amount, price, maxTradeLimit);
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
return getRoundedAmount4Decimals(amount, maxTradeLimit);
|
||||
}
|
||||
|
||||
public static BigInteger getRoundedAtmCashAmount(BigInteger amount, Price price, Long maxTradeLimit) {
|
||||
|
@ -103,7 +103,7 @@ public class CoinUtil {
|
|||
return getAdjustedAmount(amount, price, maxTradeLimit, 1);
|
||||
}
|
||||
|
||||
public static BigInteger getRoundedAmount4Decimals(BigInteger amount, Price price, Long maxTradeLimit) {
|
||||
public static BigInteger getRoundedAmount4Decimals(BigInteger amount, Long maxTradeLimit) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.####");
|
||||
double roundedXmrAmount = Double.parseDouble(decimalFormat.format(HavenoUtils.atomicUnitsToXmr(amount)));
|
||||
return HavenoUtils.xmrToAtomicUnits(roundedXmrAmount);
|
||||
|
|
Loading…
Reference in a new issue