diff --git a/basicswap/db.py b/basicswap/db.py index d310f44..3498156 100644 --- a/basicswap/db.py +++ b/basicswap/db.py @@ -399,8 +399,9 @@ class XmrOffer(Table): swap_id = Column("integer", primary_key=True, autoincrement=True) offer_id = Column("blob") - a_fee_rate = Column("integer") # Chain a fee rate - b_fee_rate = Column("integer") # Chain b fee rate + # TODO: rename to from/to - values are not switched for reverse swaps + a_fee_rate = Column("integer") # Chain from fee rate + b_fee_rate = Column("integer") # Chain to fee rate # Delay before the chain a lock refund tx can be mined lock_time_1 = Column("integer") diff --git a/basicswap/interface/utils.py b/basicswap/interface/utils.py index 409f667..870a3f0 100644 --- a/basicswap/interface/utils.py +++ b/basicswap/interface/utils.py @@ -23,7 +23,7 @@ class FeeValidator: def __init__(self, **kwargs): default_low_fee_conf_target: int = 24 default_low_fee_rate: int = 0 - default_high_estimated_feerate_multiplier: float = 2.0 + default_high_estimated_feerate_multiplier: float = 4.0 default_high_fee_rate: int = self.defaultMaxFeeRate() if self._sc: chain_client_settings = self._sc.getChainClientSettings( @@ -82,7 +82,7 @@ class FeeValidator: if self._high_estimated_feerate_multiplier >= 1.0: max_feerate, max_feerate_src = self.get_fee_rate() - max_feerate = ( + max_feerate = int( self.make_int(max_feerate) * self._high_estimated_feerate_multiplier ) else: diff --git a/basicswap/interface/xmr.py b/basicswap/interface/xmr.py index a784f65..cd02b67 100644 --- a/basicswap/interface/xmr.py +++ b/basicswap/interface/xmr.py @@ -863,5 +863,5 @@ class XMRInterface(CoinInterface): self._log.error(f"listWalletTransactions failed: {e}") return [] - def validateFeeRate(self, fee_rate: int) -> bool: + def validateFeeRate(self, fee_rate: int) -> None: pass # Fee rate isn't used diff --git a/basicswap/templates/offer.html b/basicswap/templates/offer.html index 93cc370..c250945 100644 --- a/basicswap/templates/offer.html +++ b/basicswap/templates/offer.html @@ -224,7 +224,7 @@ Chain A local fee rate - {{ data.a_fee_rate_verify }} (Fee source: {{ data.a_fee_rate_verify_src }}{% if data.a_fee_warn == true %} WARNING {% endif %}) + {{ data.a_fee_rate_verify }} (Fee source: {{ data.a_fee_rate_verify_src }}{% if data.a_fee_warn == "high" %} WARNING - HIGH {% elif data.a_fee_warn == "low" %} WARNING - LOW {% elif data.a_fee_warn is defined %} WARNING {% endif %}) {% endif %} diff --git a/basicswap/ui/page_offers.py b/basicswap/ui/page_offers.py index 8daa8c6..48f33d9 100644 --- a/basicswap/ui/page_offers.py +++ b/basicswap/ui/page_offers.py @@ -768,24 +768,30 @@ def page_offer(self, url_split, post_string): ci_leader = ci_to if reverse_bid else ci_from if xmr_offer: - int_fee_rate_now, fee_source = ci_leader.get_fee_rate() + a_fee_rate_now, fee_source = ci_leader.get_fee_rate() + a_fee_rate_now = ci_leader.make_int(a_fee_rate_now) - data["xmr_type"] = True - data["a_fee_rate"] = ci_leader.format_amount(xmr_offer.a_fee_rate) - data["a_fee_rate_verify"] = ci_leader.format_amount( - int_fee_rate_now, conv_int=True + chain_a_fee_rate: int = ( + xmr_offer.b_fee_rate if reverse_bid else xmr_offer.a_fee_rate ) + data["xmr_type"] = True + data["a_fee_rate"] = ci_leader.format_amount(chain_a_fee_rate) + data["a_fee_rate_verify"] = ci_leader.format_amount(a_fee_rate_now) data["a_fee_rate_verify_src"] = fee_source - data["a_fee_warn"] = xmr_offer.a_fee_rate < int_fee_rate_now - from_fee_rate = xmr_offer.b_fee_rate if reverse_bid else xmr_offer.a_fee_rate + warning_threshold: float = 1.2 + if chain_a_fee_rate * warning_threshold < a_fee_rate_now: + data["a_fee_warn"] = "low" + elif chain_a_fee_rate > a_fee_rate_now * warning_threshold: + data["a_fee_warn"] = "high" + lock_spend_tx_vsize = ( ci_from.xmr_swap_b_lock_spend_tx_vsize() if reverse_bid else ci_from.xmr_swap_a_lock_spend_tx_vsize() ) lock_spend_tx_fee = ci_from.make_int( - from_fee_rate * lock_spend_tx_vsize / 1000, r=1 + chain_a_fee_rate * lock_spend_tx_vsize / 1000, r=1 ) data["amt_from_lock_spend_tx_fee"] = ci_from.format_amount( lock_spend_tx_fee // ci_from.COIN() diff --git a/doc/release-notes.md b/doc/release-notes.md index d8207cf..dfd8417 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -5,7 +5,7 @@ - Prevent sending bids to offers - Reject received offers, and - Prevent sending offers where the chain feerates are out of range. - - Valid feerate range is the nodes estimated feerate for confirmation in 24 blocks to 2x the estimated feerate. + - Valid feerate range is the node's estimated feerate for confirmation in 24 blocks to 4x the estimated feerate. - The minimum feerate confirmation can be adjusted with the "low_fee_conf_target" setting. - If "low_feerate" is set above 0 it is used instead of the dynamic feerate with "low_fee_conf_target" - The maximum feerate multiplier can be adjusted with the "high_estimated_feerate_multiplier" setting. @@ -13,6 +13,11 @@ - New setting "startup_delay" - Adjusts the time waited for coin daemons to start between "startup_tries". - Valid as a base setting and can be overridden per coin with chainclients settings. +- UI: + - offer page: + - Fixed feerate from other chain displayed for reversed swaps + - Added warning text for fee above 1.2 x local estimate. + 0.14.5