mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +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 static bisq.common.util.MathUtils.exactMultiply;
|
||||
import static bisq.common.util.MathUtils.roundDoubleToLong;
|
||||
import static bisq.common.util.MathUtils.scaleUpByPowerOf10;
|
||||
import static bisq.core.locale.CurrencyUtil.isCryptoCurrency;
|
||||
|
@ -84,6 +85,7 @@ class CoreOffersService {
|
|||
return offers;
|
||||
}
|
||||
|
||||
// Create offer with a random offer id.
|
||||
Offer createOffer(String currencyCode,
|
||||
String directionAsString,
|
||||
String priceAsString,
|
||||
|
@ -119,42 +121,7 @@ class CoreOffersService {
|
|||
resultHandler);
|
||||
}
|
||||
|
||||
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,
|
||||
marketPriceMargin,
|
||||
buyerSecurityDeposit,
|
||||
paymentAccount);
|
||||
|
||||
// TODO give user chance to examine offer before placing it (placeoffer)
|
||||
openOfferManager.placeOffer(offer,
|
||||
buyerSecurityDeposit,
|
||||
useSavingsWallet,
|
||||
resultHandler,
|
||||
log::error);
|
||||
|
||||
return offer;
|
||||
}
|
||||
|
||||
// Create offer for given offer id.
|
||||
Offer createOffer(String offerId,
|
||||
String currencyCode,
|
||||
Direction direction,
|
||||
|
@ -177,7 +144,7 @@ class CoreOffersService {
|
|||
price,
|
||||
useDefaultTxFee,
|
||||
useMarketBasedPrice,
|
||||
marketPriceMargin,
|
||||
exactMultiply(marketPriceMargin, 0.01),
|
||||
buyerSecurityDeposit,
|
||||
paymentAccount);
|
||||
|
||||
|
@ -190,6 +157,43 @@ class CoreOffersService {
|
|||
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) {
|
||||
int precision = isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT;
|
||||
double priceAsDouble = new BigDecimal(priceAsString).doubleValue();
|
||||
|
|
Loading…
Add table
Reference in a new issue