From 8e1074881fe8f2010026ec58801f82db3d84d4ef Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Fri, 30 Apr 2021 16:49:54 +0200 Subject: [PATCH 1/5] Add fiat equivalent for Total Amount & Security Deposit for both makers and sellers --- .../main/offer/MutableOfferViewModel.java | 30 +++++++++++------ .../desktop/main/offer/OfferDataModel.java | 2 +- .../main/offer/takeoffer/TakeOfferView.java | 2 +- .../offer/takeoffer/TakeOfferViewModel.java | 33 +++++++++++++------ 4 files changed, 45 insertions(+), 22 deletions(-) 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 a136f6d8456..dcd1a01d5df 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -142,7 +142,7 @@ public abstract class MutableOfferViewModel ext final StringProperty volumeDescriptionLabel = new SimpleStringProperty(); final StringProperty volumePromptLabel = new SimpleStringProperty(); final StringProperty tradeAmount = new SimpleStringProperty(); - final StringProperty totalToPay = new SimpleStringProperty(); + StringProperty totalToPay = new SimpleStringProperty(); final StringProperty errorMessage = new SimpleStringProperty(); final StringProperty tradeCurrencyCode = new SimpleStringProperty(); final StringProperty waitingForFundsText = new SimpleStringProperty(""); @@ -1006,10 +1006,13 @@ public String getSecurityDepositPopOverLabel(String depositInBTC) { } public String getSecurityDepositInfo() { - return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) + - GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), - dataModel.getAmount().get(), - Restrictions.getMinBuyerSecurityDepositAsCoin()); + return FeeUtil.getTradeFeeWithFiatEquivalentAndPercentage(offerUtil, + dataModel.getSecurityDeposit(), + dataModel.getAmount().get(), + true, + btcFormatter, + Coin.ZERO + ); } public String getSecurityDepositWithCode() { @@ -1044,11 +1047,18 @@ public String getMakerFeePercentage() { } public String getTotalToPayInfo() { - final String totalToPay = this.totalToPay.get(); - if (dataModel.isCurrencyForMakerFeeBtc()) - return totalToPay; - else - return totalToPay + " + " + bsqFormatter.formatCoinWithCode(dataModel.getMakerFee()); + if (dataModel.isCurrencyForMakerFeeBtc()) { + return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, + dataModel.totalToPayAsCoin.get(), + true, + btcFormatter); + } + else { + return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, + dataModel.totalToPayAsCoin.get(), + true, + btcFormatter) + " + " + getTradeFee(); + } } public String getFundsStructure() { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/OfferDataModel.java b/desktop/src/main/java/bisq/desktop/main/offer/OfferDataModel.java index 14e26e1451d..c502050751e 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/OfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/OfferDataModel.java @@ -47,7 +47,7 @@ public abstract class OfferDataModel extends ActivatableDataModel { @Getter protected final BooleanProperty isBtcWalletFunded = new SimpleBooleanProperty(); @Getter - protected final ObjectProperty totalToPayAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty totalToPayAsCoin = new SimpleObjectProperty<>(); @Getter protected final ObjectProperty balance = new SimpleObjectProperty<>(); @Getter diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java index d0d945c896d..1d43cdd65ed 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java @@ -520,7 +520,7 @@ private void onShowPayFundsScreen() { String tradeAmountText = model.isSeller() ? Res.get("takeOffer.takeOfferFundWalletInfo.tradeAmount", model.getTradeAmount()) : ""; String message = Res.get("takeOffer.takeOfferFundWalletInfo.msg", - model.totalToPay.get(), + model.getTotalToPayInfo(), tradeAmountText, model.getSecurityDepositInfo(), model.getTradeFee(), 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 6ed43b962e3..33cb76ad857 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 @@ -684,14 +684,20 @@ public String getAmountDescription() { } String getTradeAmount() { - return btcFormatter.formatCoinWithCode(dataModel.getAmount().get()); + return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, + dataModel.getAmount().get(), + true, + btcFormatter); } public String getSecurityDepositInfo() { - return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) + - GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), - dataModel.getAmount().get(), - Restrictions.getMinBuyerSecurityDepositAsCoin()); + return FeeUtil.getTradeFeeWithFiatEquivalentAndPercentage(offerUtil, + dataModel.getSecurityDeposit(), + dataModel.getAmount().get(), + true, + btcFormatter, + Coin.ZERO + ); } public String getSecurityDepositWithCode() { @@ -725,11 +731,18 @@ public String getTakerFeePercentage() { } public String getTotalToPayInfo() { - final String totalToPay = this.totalToPay.get(); - if (dataModel.isCurrencyForTakerFeeBtc()) - return totalToPay; - else - return totalToPay + " + " + bsqFormatter.formatCoinWithCode(dataModel.getTakerFee()); + if (dataModel.isCurrencyForTakerFeeBtc()) { + return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, + dataModel.totalToPayAsCoin.get(), + true, + btcFormatter); + } + else { + return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, + dataModel.totalToPayAsCoin.get(), + true, + btcFormatter) + " + " + getTradeFee(); + } } public String getTxFee() { From 0218803650fe49b073eca45137836ec7da1c9318 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Fri, 30 Apr 2021 16:56:41 +0200 Subject: [PATCH 2/5] Restore totalToPay as 'final' as before --- .../java/bisq/desktop/main/offer/MutableOfferViewModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dcd1a01d5df..9b65e8681cb 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -142,7 +142,7 @@ public abstract class MutableOfferViewModel ext final StringProperty volumeDescriptionLabel = new SimpleStringProperty(); final StringProperty volumePromptLabel = new SimpleStringProperty(); final StringProperty tradeAmount = new SimpleStringProperty(); - StringProperty totalToPay = new SimpleStringProperty(); + final StringProperty totalToPay = new SimpleStringProperty(); final StringProperty errorMessage = new SimpleStringProperty(); final StringProperty tradeCurrencyCode = new SimpleStringProperty(); final StringProperty waitingForFundsText = new SimpleStringProperty(""); From a1d63e35d70e5360819ff2e5d878f3d581b26d1d Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Fri, 30 Apr 2021 17:35:24 +0200 Subject: [PATCH 3/5] Notice when the security deposit is the minimum possible --- .../java/bisq/desktop/main/offer/MutableOfferViewModel.java | 2 +- .../bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 9b65e8681cb..02a02935c33 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -1011,7 +1011,7 @@ public String getSecurityDepositInfo() { dataModel.getAmount().get(), true, btcFormatter, - Coin.ZERO + Restrictions.getMinBuyerSecurityDepositAsCoin() ); } 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 33cb76ad857..52d170733ee 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 @@ -696,7 +696,7 @@ public String getSecurityDepositInfo() { dataModel.getAmount().get(), true, btcFormatter, - Coin.ZERO + Restrictions.getMinBuyerSecurityDepositAsCoin() ); } From ea8653ef8755fc205692241754224ddce5d507fd Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Fri, 30 Apr 2021 18:24:09 +0200 Subject: [PATCH 4/5] Add fiat conversion also for trade amount when making a trade to sell btc --- .../java/bisq/desktop/main/offer/MutableOfferViewModel.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 02a02935c33..77c9cd90b24 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -992,7 +992,10 @@ public TradeCurrency getTradeCurrency() { } public String getTradeAmount() { - return btcFormatter.formatCoinWithCode(dataModel.getAmount().get()); + return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, + dataModel.getAmount().get(), + true, + btcFormatter); } public String getSecurityDepositLabel() { From de74ab04defd4992fbdcb80a3291a96f1c2fce55 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Fri, 30 Apr 2021 18:46:20 +0200 Subject: [PATCH 5/5] Fix codacy issues --- .../java/bisq/desktop/main/offer/MutableOfferViewModel.java | 3 +-- .../bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) 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 77c9cd90b24..b77f2165c4b 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -1055,8 +1055,7 @@ public String getTotalToPayInfo() { dataModel.totalToPayAsCoin.get(), true, btcFormatter); - } - else { + } else { return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, dataModel.totalToPayAsCoin.get(), true, 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 52d170733ee..2e20113243f 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 @@ -736,8 +736,7 @@ public String getTotalToPayInfo() { dataModel.totalToPayAsCoin.get(), true, btcFormatter); - } - else { + } else { return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil, dataModel.totalToPayAsCoin.get(), true,