Use marketPriceMarginParam from createOfferService

This commit is contained in:
chimp1984 2019-11-14 22:41:53 -05:00
parent 7d2016a839
commit 646808623c
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
2 changed files with 11 additions and 5 deletions

View file

@ -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));
}
}

View file

@ -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;