From e6f491c8ac8c9541095303dbb4475445836ce5b3 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 7 Jan 2020 16:32:24 +0100 Subject: [PATCH] Add information if minimum trading fee or minimum security deposit is used --- .../resources/i18n/displayStrings.properties | 4 ++- .../main/offer/MutableOfferViewModel.java | 12 +++++-- .../offer/takeoffer/TakeOfferViewModel.java | 14 ++++++-- .../pendingtrades/PendingTradesViewModel.java | 23 ++++++++++-- .../main/java/bisq/desktop/util/GUIUtil.java | 12 +++++-- .../java/bisq/desktop/util/GUIUtilTest.java | 36 +++++++++++++++++++ 6 files changed, 88 insertions(+), 13 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index fea926a09e..8f3e9e6a0c 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -170,6 +170,7 @@ shared.viewContractAsJson=View contract in JSON format shared.contract.title=Contract for trade with ID: {0} shared.paymentDetails=BTC {0} payment details shared.securityDeposit=Security deposit +shared.securityDepositLowerCase=security deposit shared.yourSecurityDeposit=Your security deposit shared.contract=Contract shared.messageArrived=Message arrived. @@ -214,6 +215,7 @@ shared.arbitrator=Arbitrator shared.refundAgent=Arbitrator shared.refundAgentForSupportStaff=Refund agent shared.delayedPayoutTxId=Refund collateral transaction ID +shared.tradeFee=trading fee #################################################################### @@ -2738,7 +2740,7 @@ URL: \"{0}\" guiUtil.openWebBrowser.doOpen=Open the web page and don't ask again guiUtil.openWebBrowser.copyUrl=Copy URL and cancel guiUtil.ofTradeAmount=of trade amount - +guiUtil.minValue=minimum {0} is used #################################################################### # Component specific diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java index d892b7f2c9..640beb88dd 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -48,6 +48,7 @@ import bisq.core.offer.OfferPayload; import bisq.core.offer.OfferRestrictions; import bisq.core.offer.OfferUtil; import bisq.core.payment.PaymentAccount; +import bisq.core.provider.fee.FeeService; import bisq.core.provider.price.MarketPrice; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; @@ -970,7 +971,10 @@ public abstract class MutableOfferViewModel ext public String getSecurityDepositInfo() { return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) + - GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get()); + GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), + dataModel.getAmount().get(), + Restrictions.getMinBuyerSecurityDepositAsCoin(), + Res.get("shared.securityDepositLowerCase")); } public String getSecurityDepositWithCode() { @@ -982,7 +986,9 @@ public abstract class MutableOfferViewModel ext final Coin makerFeeAsCoin = dataModel.getMakerFee(); final String makerFee = getFormatterForMakerFee().formatCoinWithCode(makerFeeAsCoin); if (dataModel.isCurrencyForMakerFeeBtc()) - return makerFee + GUIUtil.getPercentageOfTradeAmount(makerFeeAsCoin, dataModel.getAmount().get()); + return makerFee + GUIUtil.getPercentageOfTradeAmount(makerFeeAsCoin, dataModel.getAmount().get(), + FeeService.getMinMakerFee(dataModel.isCurrencyForMakerFeeBtc()), + Res.get("shared.tradeFee")); else return makerFee + " (" + Res.get("shared.tradingFeeInBsqInfo", btcFormatter.formatCoinWithCode(makerFeeAsCoin)) + ")"; } @@ -1018,7 +1024,7 @@ public abstract class MutableOfferViewModel ext public String getTxFee() { Coin txFeeAsCoin = dataModel.getTxFee(); return btcFormatter.formatCoinWithCode(txFeeAsCoin) + - GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get()); + GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get(), Coin.ZERO, ""); } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java index 55cae99dcd..80aa57dc7f 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java @@ -29,6 +29,7 @@ import bisq.desktop.util.GUIUtil; import bisq.desktop.util.validation.BtcValidator; import bisq.core.account.witness.AccountAgeWitnessService; +import bisq.core.btc.wallet.Restrictions; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.monetary.Price; @@ -39,6 +40,7 @@ import bisq.core.offer.OfferRestrictions; import bisq.core.offer.OfferUtil; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.provider.fee.FeeService; import bisq.core.provider.price.PriceFeedService; import bisq.core.trade.Trade; import bisq.core.user.Preferences; @@ -707,7 +709,10 @@ class TakeOfferViewModel extends ActivatableWithDataModel im public String getSecurityDepositInfo() { return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) + - GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get()); + GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), + dataModel.getAmount().get(), + Restrictions.getMinBuyerSecurityDepositAsCoin(), + Res.get("shared.securityDepositLowerCase")); } public String getSecurityDepositWithCode() { @@ -719,7 +724,9 @@ class TakeOfferViewModel extends ActivatableWithDataModel im final Coin takerFeeAsCoin = dataModel.getTakerFee(); final String takerFee = getFormatterForTakerFee().formatCoinWithCode(takerFeeAsCoin); if (dataModel.isCurrencyForTakerFeeBtc()) - return takerFee + GUIUtil.getPercentageOfTradeAmount(takerFeeAsCoin, dataModel.getAmount().get()); + return takerFee + GUIUtil.getPercentageOfTradeAmount(takerFeeAsCoin, dataModel.getAmount().get(), + FeeService.getMinTakerFee(dataModel.isCurrencyForTakerFeeBtc()), + Res.get("shared.tradeFee")); else return takerFee + " (" + Res.get("shared.tradingFeeInBsqInfo", btcFormatter.formatCoinWithCode(takerFeeAsCoin)) + ")"; } @@ -743,7 +750,8 @@ class TakeOfferViewModel extends ActivatableWithDataModel im public String getTxFee() { Coin txFeeAsCoin = dataModel.getTotalTxFee(); return btcFormatter.formatCoinWithCode(txFeeAsCoin) + - GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get()); + GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get(), + Coin.ZERO, ""); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java index 97b1426a95..b932fa4adb 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -24,10 +24,12 @@ import bisq.desktop.util.GUIUtil; import bisq.core.account.witness.AccountAgeWitness; import bisq.core.account.witness.AccountAgeWitnessService; +import bisq.core.btc.wallet.Restrictions; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.network.MessageState; import bisq.core.offer.Offer; +import bisq.core.provider.fee.FeeService; import bisq.core.trade.Contract; import bisq.core.trade.Trade; import bisq.core.trade.closed.ClosedTradableManager; @@ -291,7 +293,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel