From 11e4469b0e0b2cc4961aad6f4d52060029ad84fa Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Sun, 18 Sep 2022 21:51:24 -0500 Subject: [PATCH] Set the minimum payout at mediation to be 2.5% of trade amount. If 2.5% is less than 0.0005 BTC, then fall back to 0.0005 BTC. --- core/src/main/java/bisq/core/btc/wallet/Restrictions.java | 7 +++++-- .../java/bisq/core/support/dispute/DisputeManager.java | 2 +- .../main/overlays/windows/DisputeSummaryWindow.java | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/btc/wallet/Restrictions.java b/core/src/main/java/bisq/core/btc/wallet/Restrictions.java index e7d4f92b6bc..6483c44a2ee 100644 --- a/core/src/main/java/bisq/core/btc/wallet/Restrictions.java +++ b/core/src/main/java/bisq/core/btc/wallet/Restrictions.java @@ -85,10 +85,13 @@ public static Coin getMinSellerSecurityDepositAsCoin() { } // This value must be lower than MIN_BUYER_SECURITY_DEPOSIT and SELLER_SECURITY_DEPOSIT - public static Coin getMinRefundAtMediatedDispute() { + public static Coin getMinRefundAtMediatedDispute(Coin tradeAmount) { if (MIN_REFUND_AT_MEDIATED_DISPUTE == null) MIN_REFUND_AT_MEDIATED_DISPUTE = Coin.parseCoin("0.0005"); // 0.0005 BTC is 30 USD @ 60000 USD/BTC - return MIN_REFUND_AT_MEDIATED_DISPUTE; + Coin twoPointFivePercentOfTradeAmount = tradeAmount.div(40); + if (twoPointFivePercentOfTradeAmount.isLessThan(MIN_REFUND_AT_MEDIATED_DISPUTE)) + return MIN_REFUND_AT_MEDIATED_DISPUTE; + return twoPointFivePercentOfTradeAmount; } public static int getLockTime(boolean isAsset) { diff --git a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java index 88f6d3eea91..8e60a967714 100644 --- a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java @@ -928,7 +928,7 @@ protected void addPriceInfoMessage(Dispute dispute, int counter) { // The amount we would get if we do a new trade with current price Coin potentialAmountAtDisputeOpening = priceAtDisputeOpening.getAmountByVolume(contract.getTradeVolume()); Coin buyerSecurityDeposit = Coin.valueOf(offerPayload.getBuyerSecurityDeposit()); - Coin minRefundAtMediatedDispute = Restrictions.getMinRefundAtMediatedDispute(); + Coin minRefundAtMediatedDispute = Restrictions.getMinRefundAtMediatedDispute(contract.getTradeAmount()); // minRefundAtMediatedDispute is always larger as buyerSecurityDeposit at mediated payout, we ignore refund agent case here as there it can be 0. Coin maxLossSecDeposit = buyerSecurityDeposit.subtract(minRefundAtMediatedDispute); Coin tradeAmount = contract.getTradeAmount(); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java index 1a5d258b981..79fcd6a0793 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java @@ -438,7 +438,7 @@ private void applyCustomAmounts(InputTextField inputTextField, boolean oldFocusV boolean isMediationDispute = getDisputeManager(dispute) instanceof MediationManager; // At mediation we require a min. payout to the losing party to keep incentive for the trader to accept the // mediated payout. For Refund agent cases we do not have that restriction. - Coin minRefundAtDispute = isMediationDispute ? Restrictions.getMinRefundAtMediatedDispute() : Coin.ZERO; + Coin minRefundAtDispute = isMediationDispute ? Restrictions.getMinRefundAtMediatedDispute(contract.getTradeAmount()) : Coin.ZERO; Offer offer = new Offer(contract.getOfferPayload()); Coin totalAvailable = contract.getTradeAmount() @@ -973,7 +973,7 @@ private void applyUiControlsToDisputeResult(Toggle selectedTradeAmountToggle) { Coin totalPot = tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit); // At mediation we require a min. payout to the losing party to keep incentive for the trader to accept the // mediated payout. For Refund agent cases we do not have that restriction. - Coin minRefundAtDispute = isMediationDispute() ? Restrictions.getMinRefundAtMediatedDispute() : Coin.ZERO; + Coin minRefundAtDispute = isMediationDispute() ? Restrictions.getMinRefundAtMediatedDispute(tradeAmount) : Coin.ZERO; Coin penalizedPortionOfTradeAmount = Coin.ZERO; try { @@ -1062,7 +1062,7 @@ private void applyDisputeResultToUiControls() { Coin sellerSecurityDeposit = offer.getSellerSecurityDeposit(); Coin tradeAmount = contract.getTradeAmount(); Coin totalPot = tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit); - Coin minRefundAtDispute = isMediationDispute() ? Restrictions.getMinRefundAtMediatedDispute() : Coin.ZERO; + Coin minRefundAtDispute = isMediationDispute() ? Restrictions.getMinRefundAtMediatedDispute(tradeAmount) : Coin.ZERO; Coin maxPayoutAmount = totalPot.subtract(minRefundAtDispute); if (disputeResult.getBuyerPayoutAmount().equals(tradeAmount.add(buyerSecurityDeposit)) && disputeResult.getSellerPayoutAmount().equals(sellerSecurityDeposit)) {