Add check in case bsqPrice is 0 (thrown an exception otherwise)

This commit is contained in:
chimp1984 2020-12-10 00:12:11 -05:00
parent 63fc486896
commit fae8ddad4b
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3

View file

@ -373,11 +373,15 @@ public class OfferUtil {
tradeStatisticsManager,
30);
Price bsqPrice = tuple.second;
String inputValue = bsqFormatter.formatCoin(makerFee);
Volume makerFeeAsVolume = Volume.parse(inputValue, "BSQ");
Coin requiredBtc = bsqPrice.getAmountByVolume(makerFeeAsVolume);
Volume volumeByAmount = userCurrencyPrice.getVolumeByAmount(requiredBtc);
return Optional.of(volumeByAmount);
if (bsqPrice.isPositive()) {
String inputValue = bsqFormatter.formatCoin(makerFee);
Volume makerFeeAsVolume = Volume.parse(inputValue, "BSQ");
Coin requiredBtc = bsqPrice.getAmountByVolume(makerFeeAsVolume);
Volume volumeByAmount = userCurrencyPrice.getVolumeByAmount(requiredBtc);
return Optional.of(volumeByAmount);
} else {
return Optional.empty();
}
}
} else {
return Optional.empty();