mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Merge branch 'master' into Development
# Conflicts: # core/src/main/java/io/bisq/core/provider/fee/FeeService.java # gui/src/main/java/io/bisq/gui/main/dao/DaoView.java
This commit is contained in:
commit
a43ab663db
14 changed files with 43 additions and 39 deletions
|
@ -41,6 +41,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
@Slf4j
|
||||
public class Offer implements NetworkPayload, PersistablePayload {
|
||||
|
||||
// We allow max. 2 % difference between own offerPayload price calculation and takers calculation.
|
||||
// Market price might be different at maker's and takers side so we need a bit of tolerance.
|
||||
// The tolerance will get smaller once we have multiple price feeds avoiding fast price fluctuations
|
||||
// from one provider.
|
||||
final static double PRICE_TOLERANCE = 0.02;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -173,11 +179,11 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||
checkArgument(takersTradePrice > 0, "takersTradePrice must be positive");
|
||||
|
||||
double factor = (double) takersTradePrice / (double) offerPrice.getValue();
|
||||
// We allow max. 1 % difference between own offerPayload price calculation and takers calculation.
|
||||
// We allow max. 2 % difference between own offerPayload price calculation and takers calculation.
|
||||
// Market price might be different at maker's and takers side so we need a bit of tolerance.
|
||||
// The tolerance will get smaller once we have multiple price feeds avoiding fast price fluctuations
|
||||
// from one provider.
|
||||
if (Math.abs(1 - factor) > 0.01) {
|
||||
if (Math.abs(1 - factor) > PRICE_TOLERANCE) {
|
||||
String msg = "Taker's trade price is too far away from our calculated price based on the market price.\n" +
|
||||
"tradePrice=" + tradePrice.getValue() + "\n" +
|
||||
"offerPrice=" + offerPrice.getValue();
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class OfferAvailabilityProtocol {
|
||||
private static final Logger log = LoggerFactory.getLogger(OfferAvailabilityProtocol.class);
|
||||
|
||||
private static final long TIMEOUT_SEC = 60;
|
||||
private static final long TIMEOUT_SEC = 90;
|
||||
|
||||
private final OfferAvailabilityModel model;
|
||||
private final ResultHandler resultHandler;
|
||||
|
|
|
@ -45,18 +45,20 @@ public class BroadcastMakerFeeTx extends Task<PlaceOfferModel> {
|
|||
try {
|
||||
runInterceptHook();
|
||||
final Transaction transaction = model.getTransaction();
|
||||
|
||||
// TODO Try to republish tx?
|
||||
Timer timeoutTimer = UserThread.runAfter(() -> {
|
||||
log.warn("Broadcast not completed after 5 sec. We go on with the trade protocol.");
|
||||
model.getOffer().setState(Offer.State.OFFER_FEE_PAID);
|
||||
complete();
|
||||
}, 5);
|
||||
}, 20);
|
||||
|
||||
model.getTradeWalletService().broadcastTx(model.getTransaction(),
|
||||
new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
public void onSuccess(Transaction tx) {
|
||||
timeoutTimer.stop();
|
||||
if (!completed) {
|
||||
timeoutTimer.stop();
|
||||
log.debug("Broadcast of offer fee payment succeeded: transaction = " + tx.toString());
|
||||
|
||||
if (transaction.getHashAsString().equals(tx.getHashAsString())) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class FeeService {
|
|||
|
||||
// DEFAULT_TX_FEE used in FeeRequestService for non-BTC currencies and for BTC only if we cannot access fee service
|
||||
// fees are per byte
|
||||
public static final long BTC_DEFAULT_TX_FEE = 100; // fees are between 50-400 sat/byte so we try to stay in average
|
||||
public static final long BTC_DEFAULT_TX_FEE = 100; // fees are between 20-400 sat/byte so we try to stay in average
|
||||
public static final long LTC_DEFAULT_TX_FEE = LTC_REFERENCE_DEFAULT_MIN_TX_FEE.value / 200;
|
||||
public static final long DOGE_DEFAULT_TX_FEE = DOGE_REFERENCE_DEFAULT_MIN_TX_FEE.value / 200; // 200 bytes tx -> 200*5_000_000L=1_000_000_000 (1 DOGE)
|
||||
public static final long DASH_DEFAULT_TX_FEE = DASH_REFERENCE_DEFAULT_MIN_TX_FEE.value / 200; // 200 bytes tx -> 200*50=10000
|
||||
|
@ -67,8 +67,8 @@ public class FeeService {
|
|||
|
||||
private static final long MIN_MAKER_FEE_IN_MBSQ = 50; // about 0.05 EUR if 1 BSQ = 1 EUR
|
||||
private static final long MIN_TAKER_FEE_IN_MBSQ = 50;
|
||||
private static final long DEFAULT_MAKER_FEE_IN_MBSQ = 2000; // about 2 USD at BTC price 10000 USD for 1 BTC if 1 BSQ = 1 USD -> 10% of BTC fee
|
||||
private static final long DEFAULT_TAKER_FEE_IN_MBSQ = 2000;
|
||||
private static final long DEFAULT_MAKER_FEE_IN_MBSQ = 500; // about 0.5 EUR if 1 BSQ = 1 EUR
|
||||
private static final long DEFAULT_TAKER_FEE_IN_MBSQ = 750;
|
||||
|
||||
|
||||
// 0.00216 btc is for 3 x tx fee for taker -> about 2 EUR!
|
||||
|
@ -101,10 +101,10 @@ public class FeeService {
|
|||
*/
|
||||
switch (baseCurrencyCode) {
|
||||
case "BTC":
|
||||
MIN_MAKER_FEE_IN_BASE_CUR = 20_000; // 2 USD at BTC price 10000 USD
|
||||
MIN_MAKER_FEE_IN_BASE_CUR = 20_000; // 3 USD at BTC price 15000 USD
|
||||
MIN_TAKER_FEE_IN_BASE_CUR = 20_000;
|
||||
DEFAULT_MAKER_FEE_IN_BASE_CUR = 200_000; // 20 USD at BTC price 10000 USD for 1 BTC (maxTradeAmount)
|
||||
DEFAULT_TAKER_FEE_IN_BASE_CUR = 200_000; // 20 USD at BTC price 10000 USD
|
||||
DEFAULT_MAKER_FEE_IN_BASE_CUR = 200_000; // 7.5 USD at BTC price 15000 USD for 0.25 BTC (maxTradeAmount for most fiat trades)
|
||||
DEFAULT_TAKER_FEE_IN_BASE_CUR = 200_000;
|
||||
txFeePerByte = BTC_DEFAULT_TX_FEE;
|
||||
break;
|
||||
case "LTC":
|
||||
|
|
|
@ -54,8 +54,7 @@ import javafx.scene.input.KeyEvent;
|
|||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
@ -63,8 +62,10 @@ import java.util.List;
|
|||
import static javafx.scene.layout.AnchorPane.*;
|
||||
|
||||
@FxmlView
|
||||
@Slf4j
|
||||
public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MainView.class);
|
||||
// If after 20 sec we have not got connected we show "open network settings" button
|
||||
private final static int SHOW_TOR_SETTINGS_DELAY_SEC = 30;
|
||||
|
||||
public static StackPane getRootContainer() {
|
||||
return MainView.rootContainer;
|
||||
|
@ -485,11 +486,10 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
|||
splashP2PNetworkIcon.setManaged(false);
|
||||
HBox.setMargin(splashP2PNetworkIcon, new Insets(0, 0, 5, 0));
|
||||
|
||||
// If after 20 sec we have not got connected we show "open network settings" button
|
||||
Timer showTorNetworkSettingsTimer = UserThread.runAfter(() -> {
|
||||
showTorNetworkSettingsButton.setVisible(true);
|
||||
showTorNetworkSettingsButton.setManaged(true);
|
||||
}, 20);
|
||||
}, SHOW_TOR_SETTINGS_DELAY_SEC);
|
||||
|
||||
splashP2PNetworkIconIdListener = (ov, oldValue, newValue) -> {
|
||||
splashP2PNetworkIcon.setId(newValue);
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.bisq.gui.main.dao;
|
|||
|
||||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.core.app.BisqEnvironment;
|
||||
import io.bisq.gui.Navigation;
|
||||
import io.bisq.gui.common.model.Activatable;
|
||||
import io.bisq.gui.common.view.*;
|
||||
|
@ -63,7 +64,7 @@ public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
votingTab.setClosable(false);
|
||||
root.getTabs().addAll(compensationTab, votingTab);
|
||||
|
||||
if (!DevEnv.DAO_PHASE2_ACTIVATED) {
|
||||
if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq() || !DevEnv.DAO_PHASE2_ACTIVATED) {
|
||||
votingTab.setDisable(true);
|
||||
compensationTab.setDisable(true);
|
||||
}
|
||||
|
|
|
@ -721,7 +721,6 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
}
|
||||
|
||||
public void swapTradeToSavings() {
|
||||
log.error("swapTradeToSavings, offerId={}", offerId);
|
||||
btcWalletService.resetAddressEntriesForOpenOffer(offerId);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.JesusMcCloud.netlayer</groupId>
|
||||
<artifactId>tor.native</artifactId>
|
||||
<version>e7195748</version>
|
||||
<version>1c9d80e</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
|
@ -636,7 +636,7 @@ public class Connection implements MessageListener {
|
|||
closeConnectionReason = CloseConnectionReason.RESET;
|
||||
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
|
||||
closeConnectionReason = CloseConnectionReason.SOCKET_TIMEOUT;
|
||||
log.warn("Shut down caused by exception {} on connection={}", e.toString(), connection);
|
||||
log.info("Shut down caused by exception {} on connection={}", e.toString(), connection);
|
||||
} else if (e instanceof EOFException) {
|
||||
closeConnectionReason = CloseConnectionReason.TERMINATED;
|
||||
log.warn("Shut down caused by exception {} on connection={}", e.toString(), connection);
|
||||
|
|
|
@ -18,6 +18,5 @@
|
|||
package io.bisq.provider;
|
||||
|
||||
public class ProviderVersion {
|
||||
// Bisq v0.6.1 did not change anything relevant for that project so we stick with 0.6.0
|
||||
public static final String VERSION = "0.6.0";
|
||||
public static final String VERSION = "0.6.1";
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.LinkedList;
|
|||
//TODO consider alternative https://www.bitgo.com/api/v1/tx/fee?numBlocks=3
|
||||
@Slf4j
|
||||
public class BtcFeesProvider {
|
||||
static int CAPACITY = 12; // we request each 5 min. so we take average of last hour
|
||||
static int MAX_BLOCKS = 20;
|
||||
static int CAPACITY = 6; // we request each 5 min. so we take average of last 30 min.
|
||||
static int MAX_BLOCKS = 15;
|
||||
|
||||
private final HttpClient httpClient;
|
||||
LinkedList<Long> fees = new LinkedList<>();
|
||||
|
|
|
@ -39,12 +39,12 @@ public class PriceRequestService {
|
|||
private static final Logger log = LoggerFactory.getLogger(PriceRequestService.class);
|
||||
|
||||
// We adjust request time to fit into BitcoinAverage developer plan (45k request per month).
|
||||
// We get 42514 request be below numbers.
|
||||
private static final long INTERVAL_BTC_AV_LOCAL_MS = 90_000; // 90 sec
|
||||
private static final long INTERVAL_BTC_AV_GLOBAL_MS = 210_000; // 3.5 min
|
||||
// We get 42514 (29760+12754) request with below numbers.
|
||||
private static final long INTERVAL_BTC_AV_LOCAL_MS = 90_000; // 90 sec; 29760 requests for 31 days
|
||||
private static final long INTERVAL_BTC_AV_GLOBAL_MS = 210_000; // 3.5 min; 12754 requests for 31 days
|
||||
|
||||
private static final long INTERVAL_POLONIEX_MS = 60_000; // 1 min
|
||||
private static final long INTERVAL_COIN_MARKET_CAP_MS = 300_000; // 5 min
|
||||
private static final long INTERVAL_COIN_MARKET_CAP_MS = 300_000; // 5 min that data structure is quite heavy so we don't request too often.
|
||||
private static final long MARKET_PRICE_TTL_SEC = 1800; // 30 min
|
||||
|
||||
private final Timer timerBtcAverageLocal = new Timer();
|
||||
|
|
|
@ -138,23 +138,21 @@ public class SeedNodeMain extends BisqExecutable {
|
|||
|
||||
UserThread.runPeriodically(() -> {
|
||||
Profiler.printSystemLoad(log);
|
||||
long usedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
if (!stopped) {
|
||||
if (usedMemoryInMB > (maxMemory - 100)) {
|
||||
long usedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
if (usedMemoryInMB > (maxMemory * 0.8)) {
|
||||
log.warn("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" +
|
||||
"We are over our memory warn limit and call the GC. usedMemoryInMB: {}" +
|
||||
"\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n",
|
||||
usedMemoryInMB);
|
||||
System.gc();
|
||||
usedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
Profiler.printSystemLoad(log);
|
||||
}
|
||||
|
||||
final long finalUsedMemoryInMB = usedMemoryInMB;
|
||||
UserThread.runAfter(() -> {
|
||||
if (finalUsedMemoryInMB > maxMemory)
|
||||
if (Profiler.getUsedMemoryInMB() > maxMemory)
|
||||
restart(bisqEnvironment);
|
||||
}, 1);
|
||||
}, 5);
|
||||
}
|
||||
}, CHECK_MEMORY_PERIOD_SEC);
|
||||
|
||||
|
|
|
@ -133,20 +133,19 @@ public class StatisticsMain extends BisqExecutable {
|
|||
|
||||
UserThread.runPeriodically(() -> {
|
||||
Profiler.printSystemLoad(log);
|
||||
long usedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
if (!stopped) {
|
||||
if (usedMemoryInMB > (maxMemory - 100)) {
|
||||
long usedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
if (usedMemoryInMB > (maxMemory * 0.8)) {
|
||||
log.warn("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" +
|
||||
"We are over our memory warn limit and call the GC. usedMemoryInMB: {}" +
|
||||
"\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n",
|
||||
usedMemoryInMB);
|
||||
System.gc();
|
||||
usedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
Profiler.printSystemLoad(log);
|
||||
}
|
||||
|
||||
final long finalUsedMemoryInMB = usedMemoryInMB;
|
||||
UserThread.runAfter(() -> {
|
||||
final long finalUsedMemoryInMB = Profiler.getUsedMemoryInMB();
|
||||
if (finalUsedMemoryInMB > maxMemory) {
|
||||
log.error("\n\n############################################################\n" +
|
||||
"We shut down as we are over our memory limit. usedMemoryInMB: {}" +
|
||||
|
@ -154,7 +153,7 @@ public class StatisticsMain extends BisqExecutable {
|
|||
finalUsedMemoryInMB);
|
||||
System.exit(EXIT_FAILURE);
|
||||
}
|
||||
}, 1);
|
||||
}, 5);
|
||||
}
|
||||
}, CHECK_MEMORY_PERIOD_SEC);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue