Skip to content

Commit

Permalink
Fix BSQ buyer's displayed trade fee for gettrade(s) methods
Browse files Browse the repository at this point in the history
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 bisq-network#6355
  • Loading branch information
ghubstan committed Sep 11, 2022
1 parent 23b9e1d commit a33a6e9
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions core/src/main/java/bisq/core/api/model/BsqSwapTradeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
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 {
Expand Down Expand Up @@ -73,20 +70,12 @@ public static BsqSwapTradeInfo toBsqSwapTradeInfo(BsqSwapTrade trade,
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)
Expand Down

0 comments on commit a33a6e9

Please sign in to comment.