Fix BSQ buyer's displayed trade fee for gettrade(s) methods

API clients looking at their BSQ swap trades -- BSQ buyers
specifically -- were seeing a 0.00 BSQ trade fee, due to an
incorrect assumption BSQ sellers paid the entire BSQ trade
fee for both sides.  BSQ Swap execution via API has been
working just like the GUI (same code-base), but the reported
trade fee for the BSQ buy side was wrong.
This change shows the correct BSQ trade fee.

Partially addresses issue https://github.com/bisq-network/bisq/issues/6355
This commit is contained in:
ghubstan 2022-09-11 16:06:59 -03:00
parent 23b9e1d9c2
commit a33a6e936b
No known key found for this signature in database
GPG Key ID: E35592D6800A861E

View File

@ -25,9 +25,6 @@ import bisq.common.Payload;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import static bisq.core.offer.OfferDirection.BUY;
import static bisq.core.offer.OfferDirection.SELL;
@EqualsAndHashCode
@Getter
public class BsqSwapTradeInfo implements Payload {
@ -73,20 +70,12 @@ public class BsqSwapTradeInfo implements Payload {
var makerBtcAddress = wasMyOffer ? protocolModel.getBtcAddress() : swapPeer.getBtcAddress();
var takerBsqAddress = wasMyOffer ? swapPeer.getBsqAddress() : protocolModel.getBsqAddress();
var takerBtcAddress = wasMyOffer ? swapPeer.getBtcAddress() : protocolModel.getBtcAddress();
// A BSQ Swap trade fee is paid in full by the BTC buyer (selling BSQ).
// The transferred BSQ (payout) is reduced by the fee of the peer.
var makerTradeFee = wasMyOffer && trade.getOffer().getDirection().equals(BUY)
? trade.getMakerFeeAsLong()
: 0L;
var takerTradeFee = !wasMyOffer && trade.getOffer().getDirection().equals(SELL)
? trade.getTakerFeeAsLong()
: 0L;
return new BsqSwapTradeInfoBuilder()
.withTxId(trade.getTxId())
.withBsqTradeAmount(trade.getBsqTradeAmount())
.withBtcTradeAmount(trade.getAmountAsLong())
.withBsqMakerTradeFee(makerTradeFee)
.withBsqTakerTradeFee(takerTradeFee)
.withBsqMakerTradeFee(trade.getMakerFeeAsLong())
.withBsqTakerTradeFee(trade.getTakerFeeAsLong())
.withTxFeePerVbyte(trade.getTxFeePerVbyte())
.withMakerBsqAddress(makerBsqAddress)
.withMakerBtcAddress(makerBtcAddress)