Merge pull request #6593 from jmacxx/limit_min_max_deviation

Limit offer min/max amount deviation to 50%.
This commit is contained in:
Alejandro García 2023-03-11 15:11:12 +00:00 committed by GitHub
commit b88cd58f24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -522,6 +522,8 @@ createOffer.resetToDefault=No, reset to the default value
createOffer.useLowerValue=Yes, use my lower value createOffer.useLowerValue=Yes, use my lower value
createOffer.priceOutSideOfDeviation=The price you have entered is outside the max. allowed deviation from the market price.\nThe max. allowed deviation is {0} and can be adjusted in the preferences. createOffer.priceOutSideOfDeviation=The price you have entered is outside the max. allowed deviation from the market price.\nThe max. allowed deviation is {0} and can be adjusted in the preferences.
createOffer.changePrice=Change price createOffer.changePrice=Change price
createOffer.amountsOutSideOfDeviation=The BTC amounts ({0} - {1}) are out of range.\nThe minimum amount cannot be less than 50% of the max.
createOffer.changeAmount=Change amount
createOffer.tac=With publishing this offer I agree to trade with any trader who fulfills the conditions as defined in this screen. createOffer.tac=With publishing this offer I agree to trade with any trader who fulfills the conditions as defined in this screen.
createOffer.setDeposit=Set buyer's security deposit (%) createOffer.setDeposit=Set buyer's security deposit (%)
createOffer.setDepositAsBuyer=Set my security deposit as buyer (%) createOffer.setDepositAsBuyer=Set my security deposit as buyer (%)

View File

@ -1149,7 +1149,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
}); });
nextButton.setOnAction(e -> { nextButton.setOnAction(e -> {
if (model.isPriceInRange()) { if (model.isPriceInRange() && model.areAmountsInRange()) {
if (DevEnv.isDaoTradingActivated()) if (DevEnv.isDaoTradingActivated())
showFeeOption(); showFeeOption();
else else

View File

@ -965,6 +965,27 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public boolean areAmountsInRange() {
// Limit the minimum trade amount when creating an offer to 50% of the max amount.
// github.com/bisq-network/projects/issues/67
if (dataModel.getMinAmount().get().isLessThan(dataModel.getAmount().get().divide(2))) {
displayAmountsOutOfRangePopup();
return false;
}
return true;
}
private void displayAmountsOutOfRangePopup() {
Popup popup = new Popup();
popup.warning(Res.get("createOffer.amountsOutSideOfDeviation",
dataModel.getMinAmount().get().toPlainString(),
dataModel.getAmount().get().toPlainString()))
.actionButtonText(Res.get("createOffer.changeAmount"))
.onAction(popup::hide)
.hideCloseButton()
.show();
}
public boolean isPriceInRange() { public boolean isPriceInRange() {
if (marketPriceMargin.get() != null && !marketPriceMargin.get().isEmpty()) { if (marketPriceMargin.get() != null && !marketPriceMargin.get().isEmpty()) {
if (Math.abs(ParsingUtils.parsePercentStringToDouble(marketPriceMargin.get())) > preferences.getMaxPriceDistanceInPercent()) { if (Math.abs(ParsingUtils.parsePercentStringToDouble(marketPriceMargin.get())) > preferences.getMaxPriceDistanceInPercent()) {