mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Adjust to string triggerPrice
change in API cli classes
This commit is contained in:
parent
fafe416e85
commit
68450c455f
@ -348,7 +348,7 @@ public class CliMain {
|
||||
var marketPriceMargin = opts.getMktPriceMarginAsBigDecimal();
|
||||
var securityDeposit = isSwap ? 0.00 : toSecurityDepositAsPct(opts.getSecurityDeposit());
|
||||
var makerFeeCurrencyCode = opts.getMakerFeeCurrencyCode();
|
||||
var triggerPrice = 0; // Cannot be defined until offer is in book.
|
||||
var triggerPrice = "0"; // Cannot be defined until the new offer is added to book.
|
||||
OfferInfo offer;
|
||||
if (isSwap) {
|
||||
offer = client.createBsqSwapOffer(direction,
|
||||
@ -388,7 +388,7 @@ public class CliMain {
|
||||
var fixedPrice = opts.getFixedPrice();
|
||||
var isUsingMktPriceMargin = opts.isUsingMktPriceMargin();
|
||||
var marketPriceMargin = opts.getMktPriceMarginAsBigDecimal();
|
||||
var triggerPrice = toInternalTriggerPrice(client, offerId, opts.getTriggerPriceAsBigDecimal());
|
||||
var triggerPrice = opts.getTriggerPrice();
|
||||
var enable = opts.getEnableAsSignedInt();
|
||||
var editOfferType = opts.getOfferEditType();
|
||||
client.editOffer(offerId,
|
||||
@ -789,6 +789,7 @@ public class CliMain {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static long toInternalTriggerPrice(GrpcClient client,
|
||||
String offerId,
|
||||
BigDecimal unscaledTriggerPrice) {
|
||||
|
@ -123,7 +123,7 @@ public class CurrencyFormat {
|
||||
return FRIENDLY_NUMBER_FORMAT.format(price);
|
||||
}
|
||||
|
||||
// TODO Deprecate after triggerPrice field type is changed to string.
|
||||
@Deprecated
|
||||
public static String formatPrice(long price) {
|
||||
FRIENDLY_NUMBER_FORMAT.setMinimumFractionDigits(4);
|
||||
FRIENDLY_NUMBER_FORMAT.setMaximumFractionDigits(4);
|
||||
@ -157,10 +157,12 @@ public class CurrencyFormat {
|
||||
return FRIENDLY_NUMBER_FORMAT.format((double) volume / SATOSHI_DIVISOR.doubleValue());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static long toInternalFiatPrice(BigDecimal fiatPrice) {
|
||||
return fiatPrice.multiply(new BigDecimal(10_000)).longValue();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static long toInternalCryptoCurrencyPrice(BigDecimal altcoinPrice) {
|
||||
return altcoinPrice.multiply(new BigDecimal(100_000_000)).longValue();
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public final class GrpcClient {
|
||||
securityDeposit,
|
||||
paymentAcctId,
|
||||
makerFeeCurrencyCode,
|
||||
0 /* no trigger price */);
|
||||
"0" /* no trigger price */);
|
||||
}
|
||||
|
||||
public OfferInfo createMarketBasedPricedOffer(String direction,
|
||||
@ -186,7 +186,7 @@ public final class GrpcClient {
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode,
|
||||
long triggerPrice) {
|
||||
String triggerPrice) {
|
||||
return offersServiceRequest.createOffer(direction,
|
||||
currencyCode,
|
||||
amount,
|
||||
@ -210,7 +210,7 @@ public final class GrpcClient {
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode,
|
||||
long triggerPrice) {
|
||||
String triggerPrice) {
|
||||
return offersServiceRequest.createOffer(direction,
|
||||
currencyCode,
|
||||
amount,
|
||||
@ -236,22 +236,22 @@ public final class GrpcClient {
|
||||
offersServiceRequest.editOfferPriceMargin(offerId, marketPriceMargin);
|
||||
}
|
||||
|
||||
public void editOfferTriggerPrice(String offerId, long triggerPrice) {
|
||||
public void editOfferTriggerPrice(String offerId, String triggerPrice) {
|
||||
offersServiceRequest.editOfferTriggerPrice(offerId, triggerPrice);
|
||||
}
|
||||
|
||||
public void editOffer(String offerId,
|
||||
String priceAsString,
|
||||
String price,
|
||||
boolean useMarketBasedPrice,
|
||||
double marketPriceMargin,
|
||||
long triggerPrice,
|
||||
String triggerPrice,
|
||||
int enable,
|
||||
EditType editType) {
|
||||
// Take care when using this method directly:
|
||||
// useMarketBasedPrice = true if margin based offer, false for fixed priced offer
|
||||
// scaledPriceString fmt = ######.####
|
||||
offersServiceRequest.editOffer(offerId,
|
||||
priceAsString,
|
||||
price,
|
||||
useMarketBasedPrice,
|
||||
marketPriceMargin,
|
||||
triggerPrice,
|
||||
|
@ -215,10 +215,6 @@ public class EditOfferOptionParser extends OfferIdOptionParser implements Method
|
||||
}
|
||||
}
|
||||
|
||||
public BigDecimal getTriggerPriceAsBigDecimal() {
|
||||
return new BigDecimal(getTriggerPrice());
|
||||
}
|
||||
|
||||
public String getMktPriceMargin() {
|
||||
if (offerEditType.equals(MKT_PRICE_MARGIN_ONLY)
|
||||
|| offerEditType.equals(MKT_PRICE_MARGIN_AND_ACTIVATION_STATE)
|
||||
|
@ -95,30 +95,7 @@ public class OffersServiceRequest {
|
||||
securityDeposit,
|
||||
paymentAcctId,
|
||||
makerFeeCurrencyCode,
|
||||
0 /* no trigger price */);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public OfferInfo createMarketBasedPricedOffer(String direction,
|
||||
String currencyCode,
|
||||
long amount,
|
||||
long minAmount,
|
||||
double marketPriceMargin,
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode,
|
||||
long triggerPrice) {
|
||||
return createOffer(direction,
|
||||
currencyCode,
|
||||
amount,
|
||||
minAmount,
|
||||
true,
|
||||
"0",
|
||||
marketPriceMargin,
|
||||
securityDeposit,
|
||||
paymentAcctId,
|
||||
makerFeeCurrencyCode,
|
||||
triggerPrice);
|
||||
"0" /* no trigger price */);
|
||||
}
|
||||
|
||||
public OfferInfo createOffer(String direction,
|
||||
@ -131,7 +108,7 @@ public class OffersServiceRequest {
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode,
|
||||
long triggerPrice) {
|
||||
String triggerPrice) {
|
||||
var request = CreateOfferRequest.newBuilder()
|
||||
.setDirection(direction)
|
||||
.setCurrencyCode(currencyCode)
|
||||
@ -184,7 +161,7 @@ public class OffersServiceRequest {
|
||||
MKT_PRICE_MARGIN_ONLY);
|
||||
}
|
||||
|
||||
public void editOfferTriggerPrice(String offerId, long triggerPrice) {
|
||||
public void editOfferTriggerPrice(String offerId, String triggerPrice) {
|
||||
var offer = getMyOffer(offerId);
|
||||
editOffer(offerId,
|
||||
"0.00",
|
||||
@ -199,7 +176,7 @@ public class OffersServiceRequest {
|
||||
String scaledPriceString,
|
||||
boolean useMarketBasedPrice,
|
||||
double marketPriceMargin,
|
||||
long triggerPrice,
|
||||
String triggerPrice,
|
||||
int enable,
|
||||
EditOfferRequest.EditType editType) {
|
||||
// Take care when using this method directly:
|
||||
|
@ -20,6 +20,7 @@ package bisq.cli.table.builder;
|
||||
import bisq.proto.grpc.OfferInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
@ -31,6 +32,8 @@ import bisq.cli.table.Table;
|
||||
*/
|
||||
abstract class AbstractTableBuilder {
|
||||
|
||||
protected final Function<String, String> toBlankOrNonZeroValue = (s) -> s.trim().equals("0") ? "" : s;
|
||||
|
||||
protected final TableType tableType;
|
||||
protected final List<?> protos;
|
||||
|
||||
|
@ -29,11 +29,9 @@ import javax.annotation.Nullable;
|
||||
import static bisq.cli.table.builder.TableBuilderConstants.*;
|
||||
import static bisq.cli.table.builder.TableType.OFFER_TBL;
|
||||
import static bisq.cli.table.column.AltcoinColumn.DISPLAY_MODE.ALTCOIN_OFFER_VOLUME;
|
||||
import static bisq.cli.table.column.AltcoinColumn.DISPLAY_MODE.ALTCOIN_TRIGGER_PRICE;
|
||||
import static bisq.cli.table.column.Column.JUSTIFICATION.LEFT;
|
||||
import static bisq.cli.table.column.Column.JUSTIFICATION.NONE;
|
||||
import static bisq.cli.table.column.Column.JUSTIFICATION.RIGHT;
|
||||
import static bisq.cli.table.column.FiatColumn.DISPLAY_MODE.TRIGGER_PRICE;
|
||||
import static bisq.cli.table.column.FiatColumn.DISPLAY_MODE.VOLUME;
|
||||
import static bisq.cli.table.column.ZippedStringColumns.DUPLICATION_MODE.EXCLUDE_DUPLICATES;
|
||||
import static java.lang.String.format;
|
||||
@ -84,7 +82,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
Column<Long> colFiatVolume = new FiatColumn(format("Temp Volume (%s)", fiatTradeCurrency.get()), NONE, VOLUME);
|
||||
Column<Long> colMinFiatVolume = new FiatColumn(format("Temp Min Volume (%s)", fiatTradeCurrency.get()), NONE, VOLUME);
|
||||
@Nullable
|
||||
Column<Long> colTriggerPrice = fiatTriggerPriceColumn.get();
|
||||
Column<String> colTriggerPrice = fiatTriggerPriceColumn.get();
|
||||
|
||||
// Populate columns with offer info.
|
||||
|
||||
@ -101,7 +99,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
colFiatVolume.addRow(o.getVolume());
|
||||
|
||||
if (colTriggerPrice != null)
|
||||
colTriggerPrice.addRow(o.getTriggerPrice());
|
||||
colTriggerPrice.addRow(toBlankOrNonZeroValue.apply(o.getTriggerPrice()));
|
||||
|
||||
colPaymentMethod.addRow(o.getPaymentMethodShortName());
|
||||
colCreateDate.addRow(o.getDate());
|
||||
@ -124,7 +122,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
colFiatPrice.justify(),
|
||||
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
colTriggerPrice.asStringColumn(),
|
||||
colTriggerPrice.justify(),
|
||||
colPaymentMethod,
|
||||
colCreateDate.asStringColumn(),
|
||||
colOfferId);
|
||||
@ -151,7 +149,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
NONE,
|
||||
ALTCOIN_OFFER_VOLUME);
|
||||
@Nullable
|
||||
Column<Long> colTriggerPrice = altcoinTriggerPriceColumn.get();
|
||||
Column<String> colTriggerPrice = altcoinTriggerPriceColumn.get();
|
||||
|
||||
// Populate columns with offer info.
|
||||
|
||||
@ -168,7 +166,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
colMinBtcVolume.addRow(o.getVolume());
|
||||
|
||||
if (colTriggerPrice != null)
|
||||
colTriggerPrice.addRow(o.getTriggerPrice());
|
||||
colTriggerPrice.addRow(toBlankOrNonZeroValue.apply(o.getTriggerPrice()));
|
||||
|
||||
colPaymentMethod.addRow(o.getPaymentMethodShortName());
|
||||
colCreateDate.addRow(o.getDate());
|
||||
@ -201,7 +199,7 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
colBtcPrice.justify(),
|
||||
amountRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
volumeRange.asStringColumn(EXCLUDE_DUPLICATES),
|
||||
colTriggerPrice.asStringColumn(),
|
||||
colTriggerPrice.justify(),
|
||||
colPaymentMethod,
|
||||
colCreateDate.asStringColumn(),
|
||||
colOfferId);
|
||||
@ -231,14 +229,14 @@ class OfferTableBuilder extends AbstractTableBuilder {
|
||||
? new StringColumn(COL_HEADER_ENABLED, LEFT)
|
||||
: null;
|
||||
@Nullable
|
||||
private final Supplier<FiatColumn> fiatTriggerPriceColumn = () ->
|
||||
private final Supplier<StringColumn> fiatTriggerPriceColumn = () ->
|
||||
isShowingMyOffers.get()
|
||||
? new FiatColumn(format(COL_HEADER_TRIGGER_PRICE, fiatTradeCurrency.get()), RIGHT, TRIGGER_PRICE)
|
||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, fiatTradeCurrency.get()), RIGHT)
|
||||
: null;
|
||||
@Nullable
|
||||
private final Supplier<AltcoinColumn> altcoinTriggerPriceColumn = () ->
|
||||
private final Supplier<StringColumn> altcoinTriggerPriceColumn = () ->
|
||||
isShowingMyOffers.get() && !isShowingBsqOffers.get()
|
||||
? new AltcoinColumn(format(COL_HEADER_TRIGGER_PRICE, altcoinTradeCurrency.get()), RIGHT, ALTCOIN_TRIGGER_PRICE)
|
||||
? new StringColumn(format(COL_HEADER_TRIGGER_PRICE, altcoinTradeCurrency.get()), RIGHT)
|
||||
: null;
|
||||
|
||||
private final Function<OfferInfo, String> toEnabled = (o) -> {
|
||||
|
@ -34,6 +34,7 @@ public class AltcoinColumn extends LongColumn {
|
||||
public enum DISPLAY_MODE {
|
||||
ALTCOIN_OFFER_VOLUME,
|
||||
ALTCOIN_PRICE,
|
||||
@Deprecated
|
||||
ALTCOIN_TRIGGER_PRICE
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ public class FiatColumn extends LongColumn {
|
||||
|
||||
public enum DISPLAY_MODE {
|
||||
PRICE,
|
||||
@Deprecated
|
||||
TRIGGER_PRICE,
|
||||
VOLUME
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user