mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix wrong calculation of percentage based security deposit
This commit is contained in:
parent
24d0baeaa6
commit
02f6475470
@ -49,8 +49,19 @@ public class CoinUtil {
|
||||
* @return The percentage value as double (e.g. 1% is 0.01)
|
||||
*/
|
||||
public static double getAsPercentPerBtc(Coin value) {
|
||||
double asDouble = value != null ? (double) value.value : 0;
|
||||
double btcAsDouble = (double) Coin.COIN.value;
|
||||
return getAsPercentPerBtc(value, Coin.COIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param part Btc amount to be converted to percent value, based on total value passed.
|
||||
* E.g. 0.1 BTC is 25% (of 0.4 BTC)
|
||||
* @param total Total Btc amount the percentage part is calculated from
|
||||
*
|
||||
* @return The percentage value as double (e.g. 1% is 0.01)
|
||||
*/
|
||||
public static double getAsPercentPerBtc(Coin part, Coin total) {
|
||||
double asDouble = part != null ? (double) part.value : 0;
|
||||
double btcAsDouble = total != null ? (double) total.value : 1;
|
||||
return MathUtils.roundDouble(asDouble / btcAsDouble, 4);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
||||
CurrencyUtil.getTradeCurrency(offer.getCurrencyCode())
|
||||
.ifPresent(c -> this.tradeCurrency = c);
|
||||
tradeCurrencyCode.set(offer.getCurrencyCode());
|
||||
buyerSecurityDeposit.set(CoinUtil.getAsPercentPerBtc(offer.getBuyerSecurityDeposit()));
|
||||
buyerSecurityDeposit.set(CoinUtil.getAsPercentPerBtc(offer.getBuyerSecurityDeposit(), offer.getAmount()));
|
||||
|
||||
this.initialState = openOffer.getState();
|
||||
PaymentAccount tmpPaymentAccount = user.getPaymentAccount(openOffer.getOffer().getMakerPaymentAccountId());
|
||||
|
Loading…
Reference in New Issue
Block a user