MCPcopy
hub / github.com/bisq-network/bisq / getBsqInUsd

Method getBsqInUsd

desktop/src/main/java/bisq/desktop/util/GUIUtil.java:1360–1376  ·  view source on GitHub ↗
(Price bsqPrice,
                                     Coin bsqAmount,
                                     PriceFeedService priceFeedService,
                                     BsqFormatter bsqFormatter)

Source from the content-addressed store, hash-verified

1358 }
1359
1360 public static String getBsqInUsd(Price bsqPrice,
1361 Coin bsqAmount,
1362 PriceFeedService priceFeedService,
1363 BsqFormatter bsqFormatter) {
1364 MarketPrice usdMarketPrice = priceFeedService.getMarketPrice("USD");
1365 if (usdMarketPrice == null) {
1366 return Res.get("shared.na");
1367 }
1368 long usdMarketPriceAsLong = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(usdMarketPrice.getPrice(),
1369 Fiat.SMALLEST_UNIT_EXPONENT));
1370 Price usdPrice = Price.valueOf("USD", usdMarketPriceAsLong);
1371 String bsqAmountAsString = bsqFormatter.formatCoin(bsqAmount);
1372 Volume bsqAmountAsVolume = Volume.parse(bsqAmountAsString, "BSQ");
1373 Coin requiredBtc = bsqPrice.getAmountByVolume(bsqAmountAsVolume);
1374 Volume volumeByAmount = usdPrice.getVolumeByAmount(requiredBtc);
1375 return VolumeUtil.formatAverageVolumeWithCode(volumeByAmount);
1376 }
1377
1378 public static MaterialDesignIcon getIconForSignState(AccountAgeWitnessService.SignState state) {
1379 if (state.equals(AccountAgeWitnessService.SignState.PEER_INITIAL)) {

Callers 1

testGetBsqInUsdMethod · 0.95

Calls 11

getMethod · 0.95
roundDoubleToLongMethod · 0.95
scaleUpByPowerOf10Method · 0.95
valueOfMethod · 0.95
parseMethod · 0.95
getVolumeByAmountMethod · 0.95
getAmountByVolumeMethod · 0.80
formatCoinMethod · 0.65
getMarketPriceMethod · 0.45
getPriceMethod · 0.45

Tested by 1

testGetBsqInUsdMethod · 0.76