Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower tolerated small amount #5318

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,16 @@ private long getTradeLimit(Coin maxTradeLimit,
AccountAgeWitness accountAgeWitness,
AccountAge accountAgeCategory,
OfferPayload.Direction direction,
PaymentMethod paymentMethod) {
PaymentMethod paymentMethod,
boolean isMyLimit) {
if (CurrencyUtil.isCryptoCurrency(currencyCode) ||
!PaymentMethod.hasChargebackRisk(paymentMethod, currencyCode) ||
direction == OfferPayload.Direction.SELL) {
return maxTradeLimit.value;
}

long limit = OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.value;
long limit = isMyLimit ? OfferRestrictions.TOLERATED_SMALL_AMOUNT_SELF.value :
OfferRestrictions.TOLERATED_SMALL_AMOUNT_PEER.value;
var factor = signedBuyFactor(accountAgeCategory);
if (factor > 0) {
limit = MathUtils.roundDoubleToLong((double) maxTradeLimit.value * factor);
Expand Down Expand Up @@ -509,7 +511,8 @@ public long getMyTradeLimit(PaymentAccount paymentAccount, String currencyCode,
accountAgeWitness,
accountAgeCategory,
direction,
paymentAccount.getPaymentMethod());
paymentAccount.getPaymentMethod(),
true);
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -571,14 +574,14 @@ public boolean verifyPeersTradeAmount(Offer offer,
checkNotNull(offer);

// In case we don't find the witness we check if the trade amount is above the
// TOLERATED_SMALL_TRADE_AMOUNT (0.01 BTC) and only in that case return false.
// TOLERATED_SMALL_AMOUNT_PEER and only in that case return false.
return findWitness(offer)
.map(witness -> verifyPeersTradeLimit(offer, tradeAmount, witness, new Date(), errorMessageHandler))
.orElse(isToleratedSmalleAmount(tradeAmount));
.orElse(isPeerToleratedSmallAmount(tradeAmount));
}

private boolean isToleratedSmalleAmount(Coin tradeAmount) {
return tradeAmount.value <= OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.value;
private boolean isPeerToleratedSmallAmount(Coin tradeAmount) {
return tradeAmount.value <= OfferRestrictions.TOLERATED_SMALL_AMOUNT_PEER.value;
}


Expand Down Expand Up @@ -642,7 +645,7 @@ private boolean verifyPeersTradeLimit(Offer offer,
OfferPayload.Direction direction = offer.isMyOffer(keyRing) ?
offer.getMirroredDirection() : offer.getDirection();
peersCurrentTradeLimit = getTradeLimit(defaultMaxTradeLimit, currencyCode, peersWitness,
accountAgeCategory, direction, offer.getPaymentMethod());
accountAgeCategory, direction, offer.getPaymentMethod(), false);
}
// Makers current trade limit cannot be smaller than that in the offer
boolean result = tradeAmount.value <= peersCurrentTradeLimit;
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/bisq/core/offer/OfferRestrictions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ static boolean requiresUpdate() {
return new Date().after(REQUIRE_UPDATE_DATE);
}

public static Coin TOLERATED_SMALL_TRADE_AMOUNT = Coin.parseCoin("0.01");
// These values should generally be the same. However, to avoid voiding offers created with a higher limit
// the TOLERATED_SMALL_AMOUNT_PEER value can be set to the higher limit to allow those offers to be taken
// for a while.
public static Coin TOLERATED_SMALL_AMOUNT_SELF = Coin.parseCoin("0.0025");
public static Coin TOLERATED_SMALL_AMOUNT_PEER = Coin.parseCoin("0.01");

static boolean hasOfferMandatoryCapability(Offer offer, Capability mandatoryCapability) {
Map<String, String> extraDataMap = offer.getOfferPayload().getExtraDataMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import bisq.desktop.util.validation.IBANValidator;
import bisq.desktop.util.validation.InteracETransferValidator;
import bisq.desktop.util.validation.JapanBankTransferValidator;
import bisq.desktop.util.validation.LengthValidator;
import bisq.desktop.util.validation.MoneyBeamValidator;
import bisq.desktop.util.validation.PerfectMoneyValidator;
import bisq.desktop.util.validation.PopmoneyValidator;
Expand All @@ -76,7 +77,6 @@
import bisq.desktop.util.validation.USPostalMoneyOrderValidator;
import bisq.desktop.util.validation.UpholdValidator;
import bisq.desktop.util.validation.WeChatPayValidator;
import bisq.desktop.util.validation.LengthValidator;

import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.Res;
Expand Down Expand Up @@ -271,7 +271,7 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) {

if (PaymentMethod.hasChargebackRisk(paymentAccount.getPaymentMethod(), paymentAccount.getTradeCurrencies())) {
limitsInfoKey = "payment.limits.info.withSigning";
initialLimit = formatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT);
initialLimit = formatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_AMOUNT_SELF);
}

new Popup().information(Res.get(limitsInfoKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,10 @@ void onFocusOutAmountTextField(boolean oldValue, boolean newValue) {

if (minAmount.get() != null)
minAmountValidationResult.set(isBtcInputValid(minAmount.get()));
} else if (amount.get() != null && btcValidator.getMaxTradeLimit() != null && btcValidator.getMaxTradeLimit().value == OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.value) {
} else if (amount.get() != null && btcValidator.getMaxTradeLimit() != null && btcValidator.getMaxTradeLimit().value == OfferRestrictions.TOLERATED_SMALL_AMOUNT_SELF.value) {
amount.set(btcFormatter.formatCoin(btcValidator.getMaxTradeLimit()));
new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.buyer",
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT),
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_AMOUNT_SELF),
Res.get("offerbook.warning.newVersionAnnouncement")))
.width(900)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getSigningS
Res.get("offerbook.timeSinceSigning"),
Res.get("offerbook.timeSinceSigning.help",
SignedWitnessService.SIGNER_AGE_DAYS,
formatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT))) {
formatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_AMOUNT_PEER))) {
{
setMinWidth(60);
setSortable(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,16 @@ void onFocusOutAmountTextField(boolean oldValue, boolean newValue, String userIn
if (dataModel.wouldCreateDustForMaker())
amountValidationResult.set(new InputValidator.ValidationResult(false,
Res.get("takeOffer.validation.amountLargerThanOfferAmountMinusFee")));
} else if (btcValidator.getMaxTradeLimit() != null && btcValidator.getMaxTradeLimit().value == OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.value) {
} else if (btcValidator.getMaxTradeLimit() != null && btcValidator.getMaxTradeLimit().value == OfferRestrictions.TOLERATED_SMALL_AMOUNT_PEER.value) {
if (dataModel.getDirection() == OfferPayload.Direction.BUY) {
new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.seller",
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT),
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_AMOUNT_PEER),
Res.get("offerbook.warning.newVersionAnnouncement")))
.width(900)
.show();
} else {
new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.buyer",
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT),
btcFormatter.formatCoinWithCode(OfferRestrictions.TOLERATED_SMALL_AMOUNT_PEER),
Res.get("offerbook.warning.newVersionAnnouncement")))
.width(900)
.show();
Expand Down