Skip to content

Commit

Permalink
Set the minimum payout at mediation to be 2.5% of trade amount.
Browse files Browse the repository at this point in the history
If 2.5% is less than 0.0005 BTC, then fall back to 0.0005 BTC.
  • Loading branch information
jmacxx committed Sep 19, 2022
1 parent adcbcc4 commit 11e4469
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions core/src/main/java/bisq/core/btc/wallet/Restrictions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 11e4469

Please sign in to comment.