Skip to content

Commit

Permalink
Merge pull request #6593 from jmacxx/limit_min_max_deviation
Browse files Browse the repository at this point in the history
Limit offer min/max amount deviation to 50%.
  • Loading branch information
alejandrogarcia83 authored Mar 11, 2023
2 parents 4e4321e + 8a41637 commit b88cd58
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ createOffer.resetToDefault=No, reset to the default 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.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.setDeposit=Set buyer's security deposit (%)
createOffer.setDepositAsBuyer=Set my security deposit as buyer (%)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ private void addOptionsGroup() {
});

nextButton.setOnAction(e -> {
if (model.isPriceInRange()) {
if (model.isPriceInRange() && model.areAmountsInRange()) {
if (DevEnv.isDaoTradingActivated())
showFeeOption();
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,27 @@ private void applyBuyerSecurityDepositOnFocusOut() {
// 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() {
if (marketPriceMargin.get() != null && !marketPriceMargin.get().isEmpty()) {
if (Math.abs(ParsingUtils.parsePercentStringToDouble(marketPriceMargin.get())) > preferences.getMaxPriceDistanceInPercent()) {
Expand Down

0 comments on commit b88cd58

Please sign in to comment.