Change OfferInfo proto's volume fields' type to string

This commit is contained in:
ghubstan 2022-02-18 16:43:23 -03:00
parent 2af3ac22a3
commit d42c58073f
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
3 changed files with 21 additions and 21 deletions

View File

@ -32,6 +32,7 @@ import lombok.Getter;
import lombok.ToString;
import static bisq.core.util.PriceUtil.reformatMarketPrice;
import static bisq.core.util.VolumeUtil.formatVolume;
import static java.util.Objects.requireNonNull;
@EqualsAndHashCode
@ -50,8 +51,8 @@ public class OfferInfo implements Payload {
private final double marketPriceMargin;
private final long amount;
private final long minAmount;
private final long volume;
private final long minVolume;
private final String volume;
private final String minVolume;
private final long txFee;
private final long makerFee;
private final String offerFeePaymentTxId;
@ -147,9 +148,12 @@ public class OfferInfo implements Payload {
}
private static OfferInfoBuilder getBuilder(Offer offer, boolean isMyOffer) {
var currencyCode = offer.getCurrencyCode();
var preciseOfferPrice = reformatMarketPrice(
requireNonNull(offer.getPrice()).toPlainString(),
offer.getCurrencyCode());
currencyCode);
var roundedVolume = formatVolume(requireNonNull(offer.getVolume()));
var roundedMinVolume = formatVolume(requireNonNull(offer.getMinVolume()));
return new OfferInfoBuilder()
.withId(offer.getId())
.withDirection(offer.getDirection().name())
@ -158,8 +162,8 @@ public class OfferInfo implements Payload {
.withMarketPriceMargin(offer.getMarketPriceMargin())
.withAmount(offer.getAmount().value)
.withMinAmount(offer.getMinAmount().value)
.withVolume(requireNonNull(offer.getVolume()).getValue())
.withMinVolume(requireNonNull(offer.getMinVolume()).getValue())
.withVolume(roundedVolume)
.withMinVolume(roundedMinVolume)
.withMakerFee(getMakerFee(offer, isMyOffer))
.withTxFee(offer.getTxFee().value)
.withOfferFeePaymentTxId(offer.getOfferFeePaymentTxId())
@ -206,8 +210,8 @@ public class OfferInfo implements Payload {
.setMarketPriceMargin(marketPriceMargin)
.setAmount(amount)
.setMinAmount(minAmount)
.setVolume(volume)
.setMinVolume(minVolume)
.setVolume(volume == null ? "0" : volume)
.setMinVolume(minVolume == null ? "0" : minVolume)
.setMakerFee(makerFee)
.setTxFee(txFee)
.setOfferFeePaymentTxId(isBsqSwapOffer ? "" : offerFeePaymentTxId)

View File

@ -37,8 +37,8 @@ public final class OfferInfoBuilder {
private double marketPriceMargin;
private long amount;
private long minAmount;
private long volume;
private long minVolume;
private String volume;
private String minVolume;
private long txFee;
private long makerFee;
private String offerFeePaymentTxId;
@ -97,12 +97,12 @@ public final class OfferInfoBuilder {
return this;
}
public OfferInfoBuilder withVolume(long volume) {
public OfferInfoBuilder withVolume(String volume) {
this.volume = volume;
return this;
}
public OfferInfoBuilder withMinVolume(long minVolume) {
public OfferInfoBuilder withMinVolume(String minVolume) {
this.minVolume = minVolume;
return this;
}

View File

@ -300,16 +300,12 @@ message OfferInfo {
uint64 amount = 6;
// The offer's minimum BTC amount in satoshis. One million satoshis is represented as 1000000.
uint64 minAmount = 7;
// A long representing the rounded volume of currency to be traded for BTC.
// For EUR fiat offers, a volume of 29500.000 EUR would be represented as 29500000.
// TODO: Seems to be a bug in the volume, missing one trailing decimal.
// Price has 4 "ghost" decimal places. Volume has only 3 "ghost" decimal places, e.g.,
// EUR PRICE: 295001234
// EUR VOL: 29500000
uint64 volume = 8;
// A long representing the minimum, rounded volume of currency to be traded for BTC.
// TODO: Resolve the problem mentioned above, in the volume field description.
uint64 minVolume = 9;
// The rounded volume of currency to be traded for BTC.
// Fiat volume is rounded to whole currency units (no cents). Altcoin volume is rounded to 2 decimal places.
string volume = 8;
// The rounded, minimum volume of currency to be traded for BTC.
// Fiat volume is rounded to whole currency units (no cents). Altcoin volume is rounded to 2 decimal places.
string minVolume = 9;
// A long representing the BTC buyer's security deposit in satoshis.
uint64 buyerSecurityDeposit = 10;
// A market price margin based offer's trigger price is the market BTC price at which the offer is automatically disabled.