mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Prevent BSQ offers below dust limit
This commit is contained in:
parent
d339f4274d
commit
e7a059950e
@ -121,6 +121,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
||||
protected final ObjectProperty<Coin> minAmount = new SimpleObjectProperty<>();
|
||||
protected final ObjectProperty<Price> price = new SimpleObjectProperty<>();
|
||||
protected final ObjectProperty<Volume> volume = new SimpleObjectProperty<>();
|
||||
protected final ObjectProperty<Volume> minVolume = new SimpleObjectProperty<>();
|
||||
|
||||
// Percentage value of buyer security deposit. E.g. 0.01 means 1% of trade amount
|
||||
protected final DoubleProperty buyerSecurityDeposit = new SimpleDoubleProperty();
|
||||
@ -427,6 +428,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
||||
void onPaymentAccountSelected(PaymentAccount paymentAccount) {
|
||||
if (paymentAccount != null && !this.paymentAccount.equals(paymentAccount)) {
|
||||
volume.set(null);
|
||||
minVolume.set(null);
|
||||
price.set(null);
|
||||
marketPriceMargin = 0;
|
||||
preferences.setSelectedPaymentAccountForCreateOffer(paymentAccount);
|
||||
@ -458,6 +460,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
||||
if (tradeCurrency != null) {
|
||||
if (!this.tradeCurrency.equals(tradeCurrency)) {
|
||||
volume.set(null);
|
||||
minVolume.set(null);
|
||||
price.set(null);
|
||||
marketPriceMargin = 0;
|
||||
}
|
||||
@ -591,15 +594,11 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
||||
!amount.get().isZero() &&
|
||||
!price.get().isZero()) {
|
||||
try {
|
||||
Volume volumeByAmount = price.get().getVolumeByAmount(amount.get());
|
||||
|
||||
// For HalCash we want multiple of 10 EUR
|
||||
if (isHalCashAccount())
|
||||
volumeByAmount = OfferUtil.getAdjustedVolumeForHalCash(volumeByAmount);
|
||||
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
|
||||
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount);
|
||||
Volume volumeByAmount = calculateVolumeForAmount(amount);
|
||||
|
||||
volume.set(volumeByAmount);
|
||||
|
||||
calculateMinVolume();
|
||||
} catch (Throwable t) {
|
||||
log.error(t.toString());
|
||||
}
|
||||
@ -608,6 +607,33 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
||||
updateBalance();
|
||||
}
|
||||
|
||||
void calculateMinVolume() {
|
||||
if (price.get() != null &&
|
||||
minAmount.get() != null &&
|
||||
!minAmount.get().isZero() &&
|
||||
!price.get().isZero()) {
|
||||
try {
|
||||
Volume volumeByAmount = calculateVolumeForAmount(minAmount);
|
||||
|
||||
minVolume.set(volumeByAmount);
|
||||
|
||||
} catch (Throwable t) {
|
||||
log.error(t.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Volume calculateVolumeForAmount(ObjectProperty<Coin> minAmount) {
|
||||
Volume volumeByAmount = price.get().getVolumeByAmount(minAmount.get());
|
||||
|
||||
// For HalCash we want multiple of 10 EUR
|
||||
if (isHalCashAccount())
|
||||
volumeByAmount = OfferUtil.getAdjustedVolumeForHalCash(volumeByAmount);
|
||||
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
|
||||
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount);
|
||||
return volumeByAmount;
|
||||
}
|
||||
|
||||
void calculateAmount() {
|
||||
if (volume.get() != null &&
|
||||
price.get() != null &&
|
||||
@ -711,6 +737,10 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
||||
return volume;
|
||||
}
|
||||
|
||||
ReadOnlyObjectProperty<Volume> getMinVolume() {
|
||||
return minVolume;
|
||||
}
|
||||
|
||||
protected void setMinAmount(Coin minAmount) {
|
||||
this.minAmount.set(minAmount);
|
||||
}
|
||||
|
@ -227,7 +227,6 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
minAmount.set(amount.get());
|
||||
onFocusOutPriceAsPercentageTextField(true, false);
|
||||
applyMakerFee();
|
||||
updateButtonDisableState();
|
||||
setAmountToModel();
|
||||
setMinAmountToModel();
|
||||
setPriceToModel();
|
||||
@ -743,6 +742,18 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
Coin minAmountAsCoin = dataModel.getMinAmount().get();
|
||||
syncMinAmountWithAmount = minAmountAsCoin != null && minAmountAsCoin.equals(dataModel.getAmount().get());
|
||||
setMinAmountToModel();
|
||||
|
||||
dataModel.calculateMinVolume();
|
||||
|
||||
if (dataModel.getMinVolume().get() != null) {
|
||||
InputValidator.ValidationResult minVolumeResult = isVolumeInputValid(
|
||||
btcFormatter.formatVolume(dataModel.getMinVolume().get()));
|
||||
|
||||
volumeValidationResult.set(minVolumeResult);
|
||||
|
||||
updateButtonDisableState();
|
||||
}
|
||||
|
||||
this.minAmount.set(btcFormatter.formatCoin(minAmountAsCoin));
|
||||
|
||||
if (!dataModel.isMinAmountLessOrEqualAmount()) {
|
||||
@ -1167,6 +1178,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
dataModel.getPrice().get() != null &&
|
||||
dataModel.getPrice().get().getValue() != 0 &&
|
||||
isVolumeInputValid(volume.get()).isValid &&
|
||||
isVolumeInputValid(btcFormatter.formatVolume(dataModel.getMinVolume().get())).isValid &&
|
||||
dataModel.isMinAmountLessOrEqualAmount();
|
||||
|
||||
isNextButtonDisabled.set(!inputDataValid);
|
||||
|
@ -99,6 +99,7 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
||||
minAmount.set(null);
|
||||
price.set(null);
|
||||
volume.set(null);
|
||||
minVolume.set(null);
|
||||
buyerSecurityDeposit.set(0);
|
||||
paymentAccounts.clear();
|
||||
paymentAccount = null;
|
||||
|
Loading…
Reference in New Issue
Block a user