Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BTC/BSQ pair offer & trading tests #5359

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c3f5669
Add api method createcryptopaymentacct
ghubstan Mar 25, 2021
27b0900
Add cli side help for createcryptopaymentacct
ghubstan Mar 25, 2021
9e035e5
Provide more offer & contract detail available to CLI.
ghubstan Mar 25, 2021
55f157f
Add BTC/BSQ pair offer & trading tests
ghubstan Mar 25, 2021
45db3cb
Remove debugging code blocks
ghubstan Mar 25, 2021
780be1a
Adjust maker gettrade output checks to new column
ghubstan Mar 26, 2021
152f459
Remove unused parameter
ghubstan Mar 26, 2021
872834a
Merge branch '02-api-trade-contract-details' into 03-add-btc-bsq-pair…
ghubstan Mar 26, 2021
aad998c
Fix maker/taker fee format bug, rename methods
ghubstan Mar 28, 2021
20d02eb
Merge branch '02-api-trade-contract-details' into 03-add-btc-bsq-pair…
ghubstan Mar 28, 2021
2d66a59
Merge branch 'master' into 01-api-add-createcryptopaymentacct
ghubstan Apr 1, 2021
58c885e
Add support for creating instant altcoin payment accounts in api
ghubstan Apr 1, 2021
4fbdc32
Remove space char
ghubstan Apr 1, 2021
6299dc3
Merge branch '01-api-add-createcryptopaymentacct' into 02-api-trade-c…
ghubstan Apr 1, 2021
6bde12b
Improve takeoffer output and failure reason messaging
ghubstan Apr 1, 2021
a1deb1d
Merge branch '02-api-trade-contract-details' into 03-add-btc-bsq-pair…
ghubstan Apr 1, 2021
b838e59
Make test dispute agent registration a test harness opt.
ghubstan Apr 1, 2021
4424deb
Implement api VerifyBsqSentToAddressReply service
ghubstan Apr 1, 2021
b2634aa
Define grpc call rate meter for CreateCryptoCurrencyPaymentAccount
ghubstan Apr 1, 2021
da99feb
Refactor apitest's bot related classes
ghubstan Apr 1, 2021
6fa4f1a
Make codacy happy
ghubstan Apr 1, 2021
10f8a91
Fix loop & log
ghubstan Apr 2, 2021
a2c9eae
Return from method, not break loop
ghubstan Apr 2, 2021
2a7e39b
Add whitespace
ghubstan Apr 2, 2021
6981990
Remove example mm bot
ghubstan Apr 2, 2021
bddc273
Fix spelling
ghubstan Apr 2, 2021
8b156db
Merge branch '02-api-trade-contract-details' into 03-add-btc-bsq-pair…
ghubstan Apr 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/main/java/bisq/cli/CurrencyFormat.java
Expand Up @@ -99,14 +99,14 @@ public static String formatMarketPrice(double price) {
return NUMBER_FORMAT.format(price);
}

public static String formatOfferPrice(long price) {
public static String formatPrice(long price) {
NUMBER_FORMAT.setMinimumFractionDigits(4);
NUMBER_FORMAT.setMaximumFractionDigits(4);
NUMBER_FORMAT.setRoundingMode(UNNECESSARY);
return NUMBER_FORMAT.format((double) price / 10_000);
}

public static String formatCryptoCurrencyOfferPrice(long price) {
public static String formatCryptoCurrencyPrice(long price) {
NUMBER_FORMAT.setMinimumFractionDigits(8);
NUMBER_FORMAT.setMaximumFractionDigits(8);
NUMBER_FORMAT.setRoundingMode(UNNECESSARY);
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/bisq/cli/TableFormat.java
Expand Up @@ -182,7 +182,7 @@ private static String formatFiatOfferTable(List<OfferInfo> offers, String fiatCu
+ offers.stream()
.map(o -> format(colDataFormat,
o.getDirection(),
formatOfferPrice(o.getPrice()),
formatPrice(o.getPrice()),
formatAmountRange(o.getMinAmount(), o.getAmount()),
formatVolumeRange(o.getMinVolume(), o.getVolume()),
o.getPaymentMethodShortName(),
Expand Down Expand Up @@ -220,7 +220,7 @@ private static String formatCryptoCurrencyOfferTable(List<OfferInfo> offers, Str
+ offers.stream()
.map(o -> format(colDataFormat,
directionFormat.apply(o),
formatCryptoCurrencyOfferPrice(o.getPrice()),
formatCryptoCurrencyPrice(o.getPrice()),
formatAmountRange(o.getMinAmount(), o.getAmount()),
formatCryptoCurrencyVolumeRange(o.getMinVolume(), o.getVolume()),
o.getPaymentMethodShortName(),
Expand Down
31 changes: 21 additions & 10 deletions cli/src/main/java/bisq/cli/TradeFormat.java
Expand Up @@ -35,6 +35,8 @@ public class TradeFormat {
private static final String YES = "YES";
private static final String NO = "NO";

// TODO add String format(List<TradeInfo> trades)

@VisibleForTesting
public static String format(TradeInfo tradeInfo) {
// Some column values might be longer than header, so we need to calculate them.
Expand Down Expand Up @@ -79,7 +81,7 @@ public static String format(TradeInfo tradeInfo) {
String headerLine = String.format(headersFormat,
/* COL_HEADER_PRICE */ priceHeaderCurrencyCode.apply(tradeInfo),
/* COL_HEADER_TRADE_AMOUNT */ baseCurrencyCode,
/* COL_HEADER_TRADE_(M||T)AKER_FEE */ makerTakerFeeHeaderCurrencyCode.apply(tradeInfo),
/* COL_HEADER_TRADE_(M||T)AKER_FEE */ makerTakerFeeHeaderCurrencyCode.apply(tradeInfo, isTaker),
/* COL_HEADER_TRADE_BUYER_COST */ counterCurrencyCode,
/* COL_HEADER_TRADE_PAYMENT_SENT */ paymentStatusHeaderCurrencyCode.apply(tradeInfo),
/* COL_HEADER_TRADE_PAYMENT_RECEIVED */ paymentStatusHeaderCurrencyCode.apply(tradeInfo));
Expand Down Expand Up @@ -132,8 +134,13 @@ private static String formatTradeData(String format,
? t.getOffer().getCounterCurrencyCode()
: t.getOffer().getBaseCurrencyCode();

private static final Function<TradeInfo, String> makerTakerFeeHeaderCurrencyCode = (t) ->
t.getIsCurrencyForTakerFeeBtc() ? "BTC" : "BSQ";
private static final BiFunction<TradeInfo, Boolean, String> makerTakerFeeHeaderCurrencyCode = (t, isTaker) -> {
if (isTaker) {
return t.getIsCurrencyForTakerFeeBtc() ? "BTC" : "BSQ";
} else {
return t.getOffer().getIsCurrencyForMakerFeeBtc() ? "BTC" : "BSQ";
}
};

private static final Function<TradeInfo, String> paymentStatusHeaderCurrencyCode = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
Expand All @@ -142,8 +149,8 @@ private static String formatTradeData(String format,

private static final Function<TradeInfo, String> priceFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatOfferPrice(t.getTradePrice())
: formatCryptoCurrencyOfferPrice(t.getOffer().getPrice());
? formatPrice(t.getTradePrice())
: formatCryptoCurrencyPrice(t.getOffer().getPrice());

private static final Function<TradeInfo, String> amountFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
Expand All @@ -159,11 +166,15 @@ private static String formatTradeData(String format,
};

private static final BiFunction<TradeInfo, Boolean, String> makerTakerFeeFormat = (t, isTaker) -> {
if (isTaker)
return t.getIsCurrencyForTakerFeeBtc() ? formatSatoshis(t.getTakerFeeAsLong()) : formatBsq(t.getTakerFeeAsLong());
else
return t.getIsCurrencyForTakerFeeBtc() ? formatSatoshis(t.getOffer().getMakerFee()) : formatBsq(t.getOffer().getMakerFee());

if (isTaker) {
return t.getIsCurrencyForTakerFeeBtc()
? formatSatoshis(t.getTakerFeeAsLong())
: formatBsq(t.getTakerFeeAsLong());
} else {
return t.getOffer().getIsCurrencyForMakerFeeBtc()
? formatSatoshis(t.getOffer().getMakerFee())
: formatBsq(t.getOffer().getMakerFee());
}
};

private static final Function<TradeInfo, String> tradeCostFormat = (t) ->
Expand Down