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.
This commit is contained in:
ghubstan 2021-09-17 16:25:37 -03:00
parent fae1852220
commit 484f882077
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
3 changed files with 14 additions and 1 deletions

View File

@ -188,7 +188,7 @@ public class TradeFormat {
private static final Function<TradeInfo, String> tradeCostFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatOfferVolume(t.getOffer().getVolume())
? formatOfferVolume(t.getTradeVolume())
: formatSatoshis(t.getTradeAmountAsLong());
private static final BiFunction<TradeInfo, Boolean, String> bsqReceiveAddress = (t, showBsqBuyerAddress) -> {

View File

@ -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 class TradeInfo implements Payload {
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 class TradeInfo implements Payload {
.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 class TradeInfo implements Payload {
.setPayoutTxId(payoutTxId == null ? "" : payoutTxId)
.setTradeAmountAsLong(tradeAmountAsLong)
.setTradePrice(tradePrice)
.setTradeVolume(tradeVolume)
.setTradingPeerNodeAddress(tradingPeerNodeAddress)
.setState(state)
.setPhase(phase)
@ -199,6 +203,7 @@ public class TradeInfo implements Payload {
.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 class TradeInfo implements Payload {
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 class TradeInfo implements Payload {
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 class TradeInfo implements Payload {
", payoutTxId='" + payoutTxId + '\'' + "\n" +
", tradeAmountAsLong='" + tradeAmountAsLong + '\'' + "\n" +
", tradePrice='" + tradePrice + '\'' + "\n" +
", tradeVolume='" + tradeVolume + '\'' + "\n" +
", tradingPeerNodeAddress='" + tradingPeerNodeAddress + '\'' + "\n" +
", state='" + state + '\'' + "\n" +
", phase='" + phase + '\'' + "\n" +

View File

@ -409,6 +409,7 @@ message TradeInfo {
bool isWithdrawn = 23;
string contractAsJson = 24;
ContractInfo contract = 25;
uint64 tradeVolume = 26;
}
message ContractInfo {