mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-28 09:24:15 -04:00
limit sell offers to unsigned buy limit then warn within release windows
This commit is contained in:
parent
a63118d5eb
commit
f91f213cd2
8 changed files with 116 additions and 15 deletions
|
@ -380,7 +380,7 @@ public class HavenoApp extends Application implements UncaughtExceptionHandler {
|
|||
// if no warning popup has been shown yet, prompt user if they really intend to shut down
|
||||
String key = "popup.info.shutDownQuery";
|
||||
if (injector.getInstance(Preferences.class).showAgain(key) && !DevEnv.isDevMode()) {
|
||||
new Popup().headLine(Res.get("popup.info.shutDownQuery"))
|
||||
new Popup().headLine(Res.get(key))
|
||||
.actionButtonText(Res.get("shared.yes"))
|
||||
.onAction(() -> resp.complete(true))
|
||||
.closeButtonText(Res.get("shared.no"))
|
||||
|
|
|
@ -455,6 +455,12 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
}
|
||||
|
||||
long getMaxTradeLimit() {
|
||||
|
||||
// disallow offers which no buyer can take due to trade limits on release
|
||||
if (HavenoUtils.isReleasedWithinDays(HavenoUtils.RELEASE_LIMIT_DAYS)) {
|
||||
return accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrencyCode.get(), OfferDirection.BUY);
|
||||
}
|
||||
|
||||
if (paymentAccount != null) {
|
||||
return accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrencyCode.get(), direction);
|
||||
} else {
|
||||
|
@ -586,6 +592,10 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public BigInteger getMaxUnsignedBuyLimit() {
|
||||
return BigInteger.valueOf(accountAgeWitnessService.getUnsignedTradeLimit(paymentAccount.getPaymentMethod(), tradeCurrencyCode.get(), OfferDirection.BUY));
|
||||
}
|
||||
|
||||
protected ReadOnlyObjectProperty<BigInteger> getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
|
|
@ -1012,7 +1012,24 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
|
||||
nextButton.setOnAction(e -> {
|
||||
if (model.isPriceInRange()) {
|
||||
onShowPayFundsScreen();
|
||||
|
||||
// warn if sell offer exceeds unsigned buy limit within release window
|
||||
boolean isSellOffer = model.getDataModel().isSellOffer();
|
||||
boolean exceedsUnsignedBuyLimit = model.getDataModel().getAmount().get().compareTo(model.getDataModel().getMaxUnsignedBuyLimit()) > 0;
|
||||
String key = "popup.warning.tradeLimitDueAccountAgeRestriction.seller.exceedsUnsignedBuyLimit";
|
||||
if (isSellOffer && exceedsUnsignedBuyLimit && DontShowAgainLookup.showAgain(key) && HavenoUtils.isReleasedWithinDays(HavenoUtils.WARN_ON_OFFER_EXCEEDS_UNSIGNED_BUY_LIMIT_DAYS)) {
|
||||
new Popup().information(Res.get(key,
|
||||
HavenoUtils.formatXmr(model.getDataModel().getMaxUnsignedBuyLimit(), true),
|
||||
Res.get("offerbook.warning.newVersionAnnouncement")))
|
||||
.closeButtonText(Res.get("shared.cancel"))
|
||||
.actionButtonText(Res.get("shared.ok"))
|
||||
.onAction(this::onShowPayFundsScreen)
|
||||
.width(900)
|
||||
.dontShowAgainId(key)
|
||||
.show();
|
||||
} else {
|
||||
onShowPayFundsScreen();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -81,6 +81,9 @@ import org.bitcoinj.core.Coin;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.math.BigInteger;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
|
@ -692,11 +695,32 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
} else {
|
||||
amount.set(HavenoUtils.formatXmr(xmrValidator.getMaxTradeLimit()));
|
||||
boolean isBuy = dataModel.getDirection() == OfferDirection.BUY;
|
||||
new Popup().information(Res.get(isBuy ? "popup.warning.tradeLimitDueAccountAgeRestriction.buyer" : "popup.warning.tradeLimitDueAccountAgeRestriction.seller",
|
||||
HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true),
|
||||
Res.get("offerbook.warning.newVersionAnnouncement")))
|
||||
.width(900)
|
||||
.show();
|
||||
boolean isSellerWithinReleaseWindow = !isBuy && HavenoUtils.isReleasedWithinDays(HavenoUtils.RELEASE_LIMIT_DAYS);
|
||||
if (isSellerWithinReleaseWindow) {
|
||||
|
||||
// format release date plus days
|
||||
Date releaseDate = HavenoUtils.getReleaseDate();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(releaseDate);
|
||||
c.add(Calendar.DATE, HavenoUtils.RELEASE_LIMIT_DAYS);
|
||||
Date releaseDatePlusDays = c.getTime();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("MMMM d, yyyy");
|
||||
String releaseDatePlusDaysAsString = formatter.format(releaseDatePlusDays);
|
||||
|
||||
// popup temporary restriction
|
||||
new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.seller.releaseLimit",
|
||||
HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true),
|
||||
releaseDatePlusDaysAsString,
|
||||
Res.get("offerbook.warning.newVersionAnnouncement")))
|
||||
.width(900)
|
||||
.show();
|
||||
} else {
|
||||
new Popup().information(Res.get(isBuy ? "popup.warning.tradeLimitDueAccountAgeRestriction.buyer" : "popup.warning.tradeLimitDueAccountAgeRestriction.seller",
|
||||
HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true),
|
||||
Res.get("offerbook.warning.newVersionAnnouncement")))
|
||||
.width(900)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
// We want to trigger a recalculation of the volume
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue