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