mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Convert mktPriceMargin to %, make createAndPlaceOffer private
And move createAndPlaceOffer to bottom of class file.
This commit is contained in:
parent
96278b9bab
commit
995af0dd21
1 changed files with 41 additions and 37 deletions
|
@ -40,6 +40,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import static bisq.common.util.MathUtils.exactMultiply;
|
||||||
import static bisq.common.util.MathUtils.roundDoubleToLong;
|
import static bisq.common.util.MathUtils.roundDoubleToLong;
|
||||||
import static bisq.common.util.MathUtils.scaleUpByPowerOf10;
|
import static bisq.common.util.MathUtils.scaleUpByPowerOf10;
|
||||||
import static bisq.core.locale.CurrencyUtil.isCryptoCurrency;
|
import static bisq.core.locale.CurrencyUtil.isCryptoCurrency;
|
||||||
|
@ -84,6 +85,7 @@ class CoreOffersService {
|
||||||
return offers;
|
return offers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create offer with a random offer id.
|
||||||
Offer createOffer(String currencyCode,
|
Offer createOffer(String currencyCode,
|
||||||
String directionAsString,
|
String directionAsString,
|
||||||
String priceAsString,
|
String priceAsString,
|
||||||
|
@ -119,42 +121,7 @@ class CoreOffersService {
|
||||||
resultHandler);
|
resultHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
Offer createAndPlaceOffer(String offerId,
|
// Create offer for given offer id.
|
||||||
String currencyCode,
|
|
||||||
Direction direction,
|
|
||||||
Price price,
|
|
||||||
boolean useMarketBasedPrice,
|
|
||||||
double marketPriceMargin,
|
|
||||||
Coin amount,
|
|
||||||
Coin minAmount,
|
|
||||||
double buyerSecurityDeposit,
|
|
||||||
PaymentAccount paymentAccount,
|
|
||||||
boolean useSavingsWallet,
|
|
||||||
TransactionResultHandler resultHandler) {
|
|
||||||
Coin useDefaultTxFee = Coin.ZERO;
|
|
||||||
|
|
||||||
Offer offer = createOfferService.createAndGetOffer(offerId,
|
|
||||||
direction,
|
|
||||||
currencyCode,
|
|
||||||
amount,
|
|
||||||
minAmount,
|
|
||||||
price,
|
|
||||||
useDefaultTxFee,
|
|
||||||
useMarketBasedPrice,
|
|
||||||
marketPriceMargin,
|
|
||||||
buyerSecurityDeposit,
|
|
||||||
paymentAccount);
|
|
||||||
|
|
||||||
// TODO give user chance to examine offer before placing it (placeoffer)
|
|
||||||
openOfferManager.placeOffer(offer,
|
|
||||||
buyerSecurityDeposit,
|
|
||||||
useSavingsWallet,
|
|
||||||
resultHandler,
|
|
||||||
log::error);
|
|
||||||
|
|
||||||
return offer;
|
|
||||||
}
|
|
||||||
|
|
||||||
Offer createOffer(String offerId,
|
Offer createOffer(String offerId,
|
||||||
String currencyCode,
|
String currencyCode,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
|
@ -177,7 +144,7 @@ class CoreOffersService {
|
||||||
price,
|
price,
|
||||||
useDefaultTxFee,
|
useDefaultTxFee,
|
||||||
useMarketBasedPrice,
|
useMarketBasedPrice,
|
||||||
marketPriceMargin,
|
exactMultiply(marketPriceMargin, 0.01),
|
||||||
buyerSecurityDeposit,
|
buyerSecurityDeposit,
|
||||||
paymentAccount);
|
paymentAccount);
|
||||||
|
|
||||||
|
@ -190,6 +157,43 @@ class CoreOffersService {
|
||||||
return offer;
|
return offer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Offer createAndPlaceOffer(String offerId,
|
||||||
|
String currencyCode,
|
||||||
|
Direction direction,
|
||||||
|
Price price,
|
||||||
|
boolean useMarketBasedPrice,
|
||||||
|
double marketPriceMargin,
|
||||||
|
Coin amount,
|
||||||
|
Coin minAmount,
|
||||||
|
double buyerSecurityDeposit,
|
||||||
|
PaymentAccount paymentAccount,
|
||||||
|
boolean useSavingsWallet,
|
||||||
|
TransactionResultHandler resultHandler) {
|
||||||
|
Coin useDefaultTxFee = Coin.ZERO;
|
||||||
|
|
||||||
|
Offer offer = createOfferService.createAndGetOffer(offerId,
|
||||||
|
direction,
|
||||||
|
currencyCode,
|
||||||
|
amount,
|
||||||
|
minAmount,
|
||||||
|
price,
|
||||||
|
useDefaultTxFee,
|
||||||
|
useMarketBasedPrice,
|
||||||
|
exactMultiply(marketPriceMargin, 0.01),
|
||||||
|
buyerSecurityDeposit,
|
||||||
|
paymentAccount);
|
||||||
|
|
||||||
|
// TODO give user chance to examine offer before placing it (placeoffer)
|
||||||
|
openOfferManager.placeOffer(offer,
|
||||||
|
buyerSecurityDeposit,
|
||||||
|
useSavingsWallet,
|
||||||
|
resultHandler,
|
||||||
|
log::error);
|
||||||
|
|
||||||
|
return offer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private long priceStringToLong(String priceAsString, String currencyCode) {
|
private long priceStringToLong(String priceAsString, String currencyCode) {
|
||||||
int precision = isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT;
|
int precision = isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT;
|
||||||
double priceAsDouble = new BigDecimal(priceAsString).doubleValue();
|
double priceAsDouble = new BigDecimal(priceAsString).doubleValue();
|
||||||
|
|
Loading…
Add table
Reference in a new issue