From 484f882077364c5bc11a8f1c71b33458504a591e Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:25:37 -0300 Subject: [PATCH 1/4] Show frozen fiat trade cost in CLI console This is a bug fix for the CLI's displayed fiat trade cost value, which should be trade.volume, not offer.volume. Offer volume varies with BTC volatility, and the CLI should be showing the trade.volume value instead, frozen when the contract is made. --- cli/src/main/java/bisq/cli/TradeFormat.java | 2 +- .../src/main/java/bisq/core/api/model/TradeInfo.java | 12 ++++++++++++ proto/src/main/proto/grpc.proto | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/src/main/java/bisq/cli/TradeFormat.java b/cli/src/main/java/bisq/cli/TradeFormat.java index dbf8dbf4b86..90ad3b3846a 100644 --- a/cli/src/main/java/bisq/cli/TradeFormat.java +++ b/cli/src/main/java/bisq/cli/TradeFormat.java @@ -188,7 +188,7 @@ private static String formatTradeData(String format, private static final Function tradeCostFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC") - ? formatOfferVolume(t.getOffer().getVolume()) + ? formatOfferVolume(t.getTradeVolume()) : formatSatoshis(t.getTradeAmountAsLong()); private static final BiFunction bsqReceiveAddress = (t, showBsqBuyerAddress) -> { diff --git a/core/src/main/java/bisq/core/api/model/TradeInfo.java b/core/src/main/java/bisq/core/api/model/TradeInfo.java index 5779baf348e..38bf15256d2 100644 --- a/core/src/main/java/bisq/core/api/model/TradeInfo.java +++ b/core/src/main/java/bisq/core/api/model/TradeInfo.java @@ -51,6 +51,7 @@ public class TradeInfo implements Payload { private final String payoutTxId; private final long tradeAmountAsLong; private final long tradePrice; + private final long tradeVolume; private final String tradingPeerNodeAddress; private final String state; private final String phase; @@ -78,6 +79,7 @@ public TradeInfo(TradeInfoBuilder builder) { this.payoutTxId = builder.payoutTxId; this.tradeAmountAsLong = builder.tradeAmountAsLong; this.tradePrice = builder.tradePrice; + this.tradeVolume = builder.tradeVolume; this.tradingPeerNodeAddress = builder.tradingPeerNodeAddress; this.state = builder.state; this.phase = builder.phase; @@ -133,6 +135,7 @@ public static TradeInfo toTradeInfo(Trade trade, String role, boolean isMyOffer) .withPayoutTxId(trade.getPayoutTxId()) .withTradeAmountAsLong(trade.getTradeAmountAsLong()) .withTradePrice(trade.getTradePrice().getValue()) + .withTradeVolume(trade.getTradeVolume() == null ? 0 : trade.getTradeVolume().getValue()) .withTradingPeerNodeAddress(Objects.requireNonNull( trade.getTradingPeerNodeAddress()).getHostNameWithoutPostFix()) .withState(trade.getState().name()) @@ -169,6 +172,7 @@ public bisq.proto.grpc.TradeInfo toProtoMessage() { .setPayoutTxId(payoutTxId == null ? "" : payoutTxId) .setTradeAmountAsLong(tradeAmountAsLong) .setTradePrice(tradePrice) + .setTradeVolume(tradeVolume) .setTradingPeerNodeAddress(tradingPeerNodeAddress) .setState(state) .setPhase(phase) @@ -199,6 +203,7 @@ public static TradeInfo fromProto(bisq.proto.grpc.TradeInfo proto) { .withPayoutTxId(proto.getPayoutTxId()) .withTradeAmountAsLong(proto.getTradeAmountAsLong()) .withTradePrice(proto.getTradePrice()) + .withTradeVolume(proto.getTradeVolume()) .withTradePeriodState(proto.getTradePeriodState()) .withState(proto.getState()) .withPhase(proto.getPhase()) @@ -234,6 +239,7 @@ public static class TradeInfoBuilder { private String payoutTxId; private long tradeAmountAsLong; private long tradePrice; + private long tradeVolume; private String tradingPeerNodeAddress; private String state; private String phase; @@ -312,6 +318,11 @@ public TradeInfoBuilder withTradePrice(long tradePrice) { return this; } + public TradeInfoBuilder withTradeVolume(long tradeVolume) { + this.tradeVolume = tradeVolume; + return this; + } + public TradeInfoBuilder withTradePeriodState(String tradePeriodState) { this.tradePeriodState = tradePeriodState; return this; @@ -392,6 +403,7 @@ public String toString() { ", payoutTxId='" + payoutTxId + '\'' + "\n" + ", tradeAmountAsLong='" + tradeAmountAsLong + '\'' + "\n" + ", tradePrice='" + tradePrice + '\'' + "\n" + + ", tradeVolume='" + tradeVolume + '\'' + "\n" + ", tradingPeerNodeAddress='" + tradingPeerNodeAddress + '\'' + "\n" + ", state='" + state + '\'' + "\n" + ", phase='" + phase + '\'' + "\n" + diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 21221eda452..84e6ee18ad3 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -409,6 +409,7 @@ message TradeInfo { bool isWithdrawn = 23; string contractAsJson = 24; ContractInfo contract = 25; + uint64 tradeVolume = 26; } message ContractInfo { From a0f3d0a44c996bc81636b9152b0aabc560333bb0 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:28:07 -0300 Subject: [PATCH 2/4] Show correct altcoin trade amount (volume) in CLI console This is a bug fix for the CLI's displayed altcoin trade amount value, which should be trade.volume, not offer.volume. It has been hidden by the stability of the BSQ price, and exposed while testing API support for XMR trades. --- cli/src/main/java/bisq/cli/TradeFormat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/main/java/bisq/cli/TradeFormat.java b/cli/src/main/java/bisq/cli/TradeFormat.java index 90ad3b3846a..00c0c297eb3 100644 --- a/cli/src/main/java/bisq/cli/TradeFormat.java +++ b/cli/src/main/java/bisq/cli/TradeFormat.java @@ -164,7 +164,7 @@ private static String formatTradeData(String format, private static final Function amountFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC") ? formatSatoshis(t.getTradeAmountAsLong()) - : formatCryptoCurrencyOfferVolume(t.getOffer().getVolume()); + : formatCryptoCurrencyOfferVolume(t.getTradeVolume()); private static final BiFunction makerTakerMinerTxFeeFormat = (t, isTaker) -> { if (isTaker) { From 542aa774b07ed5fa5f2d6f4e1d9744510fa98e9b Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 18 Sep 2021 12:40:58 -0300 Subject: [PATCH 3/4] Fix typo in help text --- cli/src/main/java/bisq/cli/CliMain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/main/java/bisq/cli/CliMain.java b/cli/src/main/java/bisq/cli/CliMain.java index bd57db2e9c9..7a52f9a4cc8 100644 --- a/cli/src/main/java/bisq/cli/CliMain.java +++ b/cli/src/main/java/bisq/cli/CliMain.java @@ -781,7 +781,7 @@ private static void printHelp(OptionParser parser, @SuppressWarnings("SameParame stream.println(); stream.format(rowFormat, editoffer.name(), "--offer-id= \\", "Edit offer with id"); stream.format(rowFormat, "", "[--fixed-price=] \\", ""); - stream.format(rowFormat, "", "[--market-price=margin=] \\", ""); + stream.format(rowFormat, "", "[--market-price-margin=] \\", ""); stream.format(rowFormat, "", "[--trigger-price=] \\", ""); stream.format(rowFormat, "", "[--enabled=]", ""); stream.println(); From 55cb126e4f1a591dc6f88e0f41c9eab550849e2b Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 18 Sep 2021 13:40:55 -0300 Subject: [PATCH 4/4] Show trade.price in margin based altcoin 'gettrade' console output Fixes problem simlar to other CLI output changes in this PR. CLI's 'gettrade' output should show contracted trade.price instead of moving offer.price value for price margin based altcoin offers. This fixed bug did not affect any fiat or BSQ trades, only price margin based XMR trades, and API support for XMR trading has not yet been released. --- cli/src/main/java/bisq/cli/TradeFormat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/main/java/bisq/cli/TradeFormat.java b/cli/src/main/java/bisq/cli/TradeFormat.java index 00c0c297eb3..57248f4da02 100644 --- a/cli/src/main/java/bisq/cli/TradeFormat.java +++ b/cli/src/main/java/bisq/cli/TradeFormat.java @@ -159,7 +159,7 @@ private static String formatTradeData(String format, private static final Function priceFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC") ? formatPrice(t.getTradePrice()) - : formatCryptoCurrencyPrice(t.getOffer().getPrice()); + : formatCryptoCurrencyPrice(t.getTradePrice()); private static final Function amountFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC")