diff --git a/core/src/main/java/bisq/core/offer/CreateOfferService.java b/core/src/main/java/bisq/core/offer/CreateOfferService.java index 000ccdd5c9..3d9758c967 100644 --- a/core/src/main/java/bisq/core/offer/CreateOfferService.java +++ b/core/src/main/java/bisq/core/offer/CreateOfferService.java @@ -128,14 +128,15 @@ public class CreateOfferService { return price != null && !useMarketBasedPriceValue ? price.getValue() : 0L; } - private boolean isUseMarketBasedPriceValue(boolean useMarketBasedPrice, - String currencyCode, - PaymentAccount paymentAccount) { + public boolean isUseMarketBasedPriceValue(boolean useMarketBasedPrice, + String currencyCode, + PaymentAccount paymentAccount) { return useMarketBasedPrice && isMarketPriceAvailable(currencyCode) && !isHalCashAccount(paymentAccount); } + private boolean isHalCashAccount(PaymentAccount paymentAccount) { return paymentAccount instanceof HalCashAccount; } @@ -145,6 +146,9 @@ public class CreateOfferService { return marketPrice != null && marketPrice.isExternallyProvidedPrice(); } + public double marketPriceMarginParam(boolean useMarketBasedPriceValue, double marketPriceMargin) { + return useMarketBasedPriceValue ? marketPriceMargin : 0; + } /////////////////////////////////////////////////////////////////////////////////////////// // Private @@ -180,4 +184,5 @@ public class CreateOfferService { // MinSellerSecurityDepositAsCoin from Restrictions. return Coin.valueOf(Math.max(Restrictions.getMinSellerSecurityDepositAsCoin().value, value.value)); } + } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java index abfeee78d8..1330322e24 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java @@ -303,7 +303,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs @SuppressWarnings("ConstantConditions") Offer createAndGetOffer() { - boolean useMarketBasedPriceValue = isUseMarketBasedPriceValue(); + boolean useMarketBasedPriceValue = createOfferService.isUseMarketBasedPriceValue(useMarketBasedPrice.get(), tradeCurrencyCode.get(), paymentAccount); long priceAsLong = createOfferService.getPriceAsLong(price.get(), paymentAccount, useMarketBasedPrice.get(), tradeCurrencyCode.get()); @@ -312,7 +312,8 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs String baseCurrencyCode = isCryptoCurrency ? currencyCode : Res.getBaseCurrencyCode(); String counterCurrencyCode = isCryptoCurrency ? Res.getBaseCurrencyCode() : currencyCode; - double marketPriceMarginParam = useMarketBasedPriceValue ? marketPriceMargin : 0; + double marketPriceMarginParam = createOfferService.marketPriceMarginParam(useMarketBasedPriceValue, marketPriceMargin); + long amountAsLong = this.amount.get() != null ? this.amount.get().getValue() : 0L; long minAmountAsLong = this.minAmount.get() != null ? this.minAmount.get().getValue() : 0L;