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

When accepting an offer do not round the BTC amount outside range #4178

Merged
merged 1 commit into from May 11, 2020
Merged
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 @@ -361,7 +361,7 @@ void onFocusOutAmountTextField(boolean oldValue, boolean newValue, String userIn
dataModel.applyAmount(adjustedAmountForHalCash);
amount.set(btcFormatter.formatCoin(dataModel.getAmount().get()));
} else if (CurrencyUtil.isFiatCurrency(dataModel.getCurrencyCode())) {
if (!isAmountEqualMinAmount(dataModel.getAmount().get())) {
if (!isAmountEqualMinAmount(dataModel.getAmount().get()) && (!isAmountEqualMaxAmount(dataModel.getAmount().get()))) {
// We only apply the rounding if the amount is variable (minAmount is lower as amount).
// Otherwise we could get an amount lower then the minAmount set by rounding
Coin roundedAmount = OfferUtil.getRoundedFiatAmount(dataModel.getAmount().get(), tradePrice,
Expand Down Expand Up @@ -644,7 +644,8 @@ private void setAmountToModel() {
if (price != null) {
if (dataModel.isHalCashAccount()) {
amount = OfferUtil.getAdjustedAmountForHalCash(amount, price, maxTradeLimit);
} else if (CurrencyUtil.isFiatCurrency(dataModel.getCurrencyCode()) && !isAmountEqualMinAmount(amount)) {
} else if (CurrencyUtil.isFiatCurrency(dataModel.getCurrencyCode())
&& !isAmountEqualMinAmount(amount) && !isAmountEqualMaxAmount(amount)) {
// We only apply the rounding if the amount is variable (minAmount is lower as amount).
// Otherwise we could get an amount lower then the minAmount set by rounding
amount = OfferUtil.getRoundedFiatAmount(amount, price, maxTradeLimit);
Expand All @@ -658,6 +659,9 @@ private boolean isAmountEqualMinAmount(Coin amount) {
return amount.value == offer.getMinAmount().value;
}

private boolean isAmountEqualMaxAmount(Coin amount) {
return amount.value == offer.getAmount().value;
}

///////////////////////////////////////////////////////////////////////////////////////////
// Getters
Expand Down