mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 02:12:00 +01:00
Add information if minimum trading fee or minimum security deposit is used
This commit is contained in:
parent
02ac14e234
commit
e6f491c8ac
@ -170,6 +170,7 @@ shared.viewContractAsJson=View contract in JSON format
|
||||
shared.contract.title=Contract for trade with ID: {0}
|
||||
shared.paymentDetails=BTC {0} payment details
|
||||
shared.securityDeposit=Security deposit
|
||||
shared.securityDepositLowerCase=security deposit
|
||||
shared.yourSecurityDeposit=Your security deposit
|
||||
shared.contract=Contract
|
||||
shared.messageArrived=Message arrived.
|
||||
@ -214,6 +215,7 @@ shared.arbitrator=Arbitrator
|
||||
shared.refundAgent=Arbitrator
|
||||
shared.refundAgentForSupportStaff=Refund agent
|
||||
shared.delayedPayoutTxId=Refund collateral transaction ID
|
||||
shared.tradeFee=trading fee
|
||||
|
||||
|
||||
####################################################################
|
||||
@ -2738,7 +2740,7 @@ URL: \"{0}\"
|
||||
guiUtil.openWebBrowser.doOpen=Open the web page and don't ask again
|
||||
guiUtil.openWebBrowser.copyUrl=Copy URL and cancel
|
||||
guiUtil.ofTradeAmount=of trade amount
|
||||
|
||||
guiUtil.minValue=minimum {0} is used
|
||||
|
||||
####################################################################
|
||||
# Component specific
|
||||
|
@ -48,6 +48,7 @@ import bisq.core.offer.OfferPayload;
|
||||
import bisq.core.offer.OfferRestrictions;
|
||||
import bisq.core.offer.OfferUtil;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.user.Preferences;
|
||||
@ -970,7 +971,10 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
|
||||
public String getSecurityDepositInfo() {
|
||||
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
|
||||
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get());
|
||||
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(),
|
||||
dataModel.getAmount().get(),
|
||||
Restrictions.getMinBuyerSecurityDepositAsCoin(),
|
||||
Res.get("shared.securityDepositLowerCase"));
|
||||
}
|
||||
|
||||
public String getSecurityDepositWithCode() {
|
||||
@ -982,7 +986,9 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
final Coin makerFeeAsCoin = dataModel.getMakerFee();
|
||||
final String makerFee = getFormatterForMakerFee().formatCoinWithCode(makerFeeAsCoin);
|
||||
if (dataModel.isCurrencyForMakerFeeBtc())
|
||||
return makerFee + GUIUtil.getPercentageOfTradeAmount(makerFeeAsCoin, dataModel.getAmount().get());
|
||||
return makerFee + GUIUtil.getPercentageOfTradeAmount(makerFeeAsCoin, dataModel.getAmount().get(),
|
||||
FeeService.getMinMakerFee(dataModel.isCurrencyForMakerFeeBtc()),
|
||||
Res.get("shared.tradeFee"));
|
||||
else
|
||||
return makerFee + " (" + Res.get("shared.tradingFeeInBsqInfo", btcFormatter.formatCoinWithCode(makerFeeAsCoin)) + ")";
|
||||
}
|
||||
@ -1018,7 +1024,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||
public String getTxFee() {
|
||||
Coin txFeeAsCoin = dataModel.getTxFee();
|
||||
return btcFormatter.formatCoinWithCode(txFeeAsCoin) +
|
||||
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get());
|
||||
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get(), Coin.ZERO, "");
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.validation.BtcValidator;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.btc.wallet.Restrictions;
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.monetary.Price;
|
||||
@ -39,6 +40,7 @@ import bisq.core.offer.OfferRestrictions;
|
||||
import bisq.core.offer.OfferUtil;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.user.Preferences;
|
||||
@ -707,7 +709,10 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||
|
||||
public String getSecurityDepositInfo() {
|
||||
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
|
||||
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get());
|
||||
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(),
|
||||
dataModel.getAmount().get(),
|
||||
Restrictions.getMinBuyerSecurityDepositAsCoin(),
|
||||
Res.get("shared.securityDepositLowerCase"));
|
||||
}
|
||||
|
||||
public String getSecurityDepositWithCode() {
|
||||
@ -719,7 +724,9 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||
final Coin takerFeeAsCoin = dataModel.getTakerFee();
|
||||
final String takerFee = getFormatterForTakerFee().formatCoinWithCode(takerFeeAsCoin);
|
||||
if (dataModel.isCurrencyForTakerFeeBtc())
|
||||
return takerFee + GUIUtil.getPercentageOfTradeAmount(takerFeeAsCoin, dataModel.getAmount().get());
|
||||
return takerFee + GUIUtil.getPercentageOfTradeAmount(takerFeeAsCoin, dataModel.getAmount().get(),
|
||||
FeeService.getMinTakerFee(dataModel.isCurrencyForTakerFeeBtc()),
|
||||
Res.get("shared.tradeFee"));
|
||||
else
|
||||
return takerFee + " (" + Res.get("shared.tradingFeeInBsqInfo", btcFormatter.formatCoinWithCode(takerFeeAsCoin)) + ")";
|
||||
}
|
||||
@ -743,7 +750,8 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||
public String getTxFee() {
|
||||
Coin txFeeAsCoin = dataModel.getTotalTxFee();
|
||||
return btcFormatter.formatCoinWithCode(txFeeAsCoin) +
|
||||
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get());
|
||||
GUIUtil.getPercentageOfTradeAmount(txFeeAsCoin, dataModel.getAmount().get(),
|
||||
Coin.ZERO, "");
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,12 @@ import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitness;
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.btc.wallet.Restrictions;
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.network.MessageState;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.trade.Contract;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.closed.ClosedTradableManager;
|
||||
@ -291,7 +293,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||
public String getTxFee() {
|
||||
if (trade != null && trade.getTradeAmount() != null) {
|
||||
Coin txFee = dataModel.getTxFee();
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(txFee, trade.getTradeAmount());
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(txFee, trade.getTradeAmount(),
|
||||
Coin.ZERO, "");
|
||||
return btcFormatter.formatCoinWithCode(txFee) + percentage;
|
||||
} else {
|
||||
return "";
|
||||
@ -303,7 +306,13 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||
if (dataModel.isMaker() && dataModel.getOffer().isCurrencyForMakerFeeBtc() ||
|
||||
!dataModel.isMaker() && dataModel.getTrade().isCurrencyForTakerFeeBtc()) {
|
||||
Coin tradeFeeInBTC = dataModel.getTradeFeeInBTC();
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(tradeFeeInBTC, trade.getTradeAmount());
|
||||
|
||||
Coin minTradeFee = dataModel.isMaker() ?
|
||||
FeeService.getMinMakerFee(true) :
|
||||
FeeService.getMinTakerFee(true);
|
||||
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(tradeFeeInBTC, trade.getTradeAmount(),
|
||||
minTradeFee, Res.get("shared.tradeFee"));
|
||||
return btcFormatter.formatCoinWithCode(tradeFeeInBTC) + percentage;
|
||||
} else {
|
||||
return bsqFormatter.formatCoinWithCode(dataModel.getTradeFeeAsBsq());
|
||||
@ -320,7 +329,15 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||
Coin securityDeposit = dataModel.isBuyer() ?
|
||||
offer.getBuyerSecurityDeposit()
|
||||
: offer.getSellerSecurityDeposit();
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(securityDeposit, trade.getTradeAmount());
|
||||
|
||||
Coin minSecurityDeposit = dataModel.isBuyer() ?
|
||||
Restrictions.getMinBuyerSecurityDepositAsCoin() :
|
||||
Restrictions.getMinSellerSecurityDepositAsCoin();
|
||||
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(securityDeposit,
|
||||
trade.getTradeAmount(),
|
||||
minSecurityDeposit,
|
||||
Res.get("shared.securityDepositLowerCase"));
|
||||
return btcFormatter.formatCoinWithCode(securityDeposit) + percentage;
|
||||
} else {
|
||||
return "";
|
||||
|
@ -49,10 +49,10 @@ import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.user.DontShowAgainLookup;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.user.User;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
import bisq.core.util.coin.BsqFormatter;
|
||||
import bisq.core.util.coin.CoinFormatter;
|
||||
import bisq.core.util.coin.CoinUtil;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
|
||||
import bisq.network.p2p.P2PService;
|
||||
|
||||
@ -662,9 +662,15 @@ public class GUIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPercentageOfTradeAmount(Coin fee, Coin tradeAmount) {
|
||||
return " (" + getPercentage(fee, tradeAmount) +
|
||||
public static String getPercentageOfTradeAmount(Coin fee, Coin tradeAmount, Coin minFee, String feeType) {
|
||||
String result = " (" + getPercentage(fee, tradeAmount) +
|
||||
" " + Res.get("guiUtil.ofTradeAmount") + ")";
|
||||
|
||||
if (!fee.isGreaterThan(minFee)) {
|
||||
result += " - " + Res.get("guiUtil.minValue", feeType);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getPercentage(Coin part, Coin total) {
|
||||
|
@ -23,6 +23,9 @@ import bisq.core.locale.TradeCurrency;
|
||||
import bisq.core.user.DontShowAgainLookup;
|
||||
import bisq.core.user.Preferences;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.CoinMaker;
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -35,6 +38,11 @@ import org.junit.Test;
|
||||
|
||||
import static bisq.desktop.maker.TradeCurrencyMakers.bitcoin;
|
||||
import static bisq.desktop.maker.TradeCurrencyMakers.euro;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.a;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.make;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.with;
|
||||
import static org.bitcoinj.core.CoinMaker.oneBitcoin;
|
||||
import static org.bitcoinj.core.CoinMaker.satoshis;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -103,4 +111,32 @@ public class GUIUtilTest {
|
||||
assertEquals("https://www.github.com", captor.getValue().toString());
|
||||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void percentageOfTradeAmount_higherFeeAsMin() {
|
||||
|
||||
Coin fee = make(a(CoinMaker.Coin).but(with(satoshis, 20000L)));
|
||||
Coin min = make(a(CoinMaker.Coin).but(with(satoshis, 10000L)));
|
||||
|
||||
assertEquals(" (0.02% of trade amount)", GUIUtil.getPercentageOfTradeAmount(fee, oneBitcoin, min, Res.get("shared.tradeFee")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void percentageOfTradeAmount_minFee() {
|
||||
|
||||
Coin fee = make(a(CoinMaker.Coin).but(with(satoshis, 10000L)));
|
||||
Coin min = make(a(CoinMaker.Coin).but(with(satoshis, 10000L)));
|
||||
|
||||
assertEquals(" (0.01% of trade amount) - minimum trading fee is used",
|
||||
GUIUtil.getPercentageOfTradeAmount(fee, oneBitcoin, min, Res.get("shared.tradeFee")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void percentageOfTradeAmount_minFeeZERO() {
|
||||
|
||||
Coin fee = make(a(CoinMaker.Coin).but(with(satoshis, 10000L)));
|
||||
|
||||
assertEquals(" (0.01% of trade amount)",
|
||||
GUIUtil.getPercentageOfTradeAmount(fee, oneBitcoin, Coin.ZERO, ""));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user