diff --git a/core/src/main/resources/help/getavgbsqprice-help.txt b/core/src/main/resources/help/getavgbsqprice-help.txt index 8a8454d5e2..c87aaa1865 100644 --- a/core/src/main/resources/help/getavgbsqprice-help.txt +++ b/core/src/main/resources/help/getavgbsqprice-help.txt @@ -2,7 +2,7 @@ getavgbsqprice NAME ---- -getavgbsqprice - get average BSQ price in btc and usd +getavgbsqprice - get average bsq price in btc and usd SYNOPSIS -------- diff --git a/daemon/src/main/java/bisq/daemon/grpc/GrpcPriceService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcPriceService.java index 145f972d57..158cb80605 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/GrpcPriceService.java +++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcPriceService.java @@ -88,17 +88,7 @@ class GrpcPriceService extends PriceImplBase { try { var days = req.getDays(); Tuple2 prices = coreApi.getAverageBsqTradePrice(days); - var usdPrice = new BigDecimal(prices.first.toString()) - .setScale(Fiat.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP); - var btcPrice = new BigDecimal(prices.second.toString()) - .setScale(Altcoin.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP); - var proto = AverageBsqTradePrice.newBuilder() - .setUsdPrice(usdPrice.toString()) - .setBtcPrice(btcPrice.toString()) - .build(); - var reply = GetAverageBsqTradePriceReply.newBuilder() - .setPrice(proto) - .build(); + var reply = buildGetAverageBsqTradePriceReply(prices); responseObserver.onNext(reply); responseObserver.onCompleted(); } catch (Throwable cause) { @@ -121,4 +111,18 @@ class GrpcPriceService extends PriceImplBase { }} ))); } + + private GetAverageBsqTradePriceReply buildGetAverageBsqTradePriceReply(Tuple2 prices) { + var usdPrice = new BigDecimal(prices.first.toString()) + .setScale(Fiat.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP); + var btcPrice = new BigDecimal(prices.second.toString()) + .setScale(Altcoin.SMALLEST_UNIT_EXPONENT, RoundingMode.HALF_UP); + var proto = AverageBsqTradePrice.newBuilder() + .setUsdPrice(usdPrice.toString()) + .setBtcPrice(btcPrice.toString()) + .build(); + return GetAverageBsqTradePriceReply.newBuilder() + .setPrice(proto) + .build(); + } }