diff --git a/feeadjuster/feeadjuster.py b/feeadjuster/feeadjuster.py index 8b0772d..e28f288 100755 --- a/feeadjuster/feeadjuster.py +++ b/feeadjuster/feeadjuster.py @@ -21,13 +21,15 @@ def get_adjusted_percentage(plugin: Plugin, scid: str): """ channel = plugin.adj_balances[scid] min_liquidity = min(channel["total"] / 2, int(plugin.big_enough_liquidity)) + theirs = channel["total"] - channel["our"] + if channel["our"] >= min_liquidity and theirs >= min_liquidity: + # the liquidity is just okay + return 0.5 if channel["our"] < min_liquidity: - percentage = channel["our"] / min_liquidity / 2 - elif channel["total"] - channel["our"] < min_liquidity: - percentage = (min_liquidity + channel["our"] - channel["total"]) / min_liquidity / 2 + 0.5 - else: - percentage = 0.5 - return percentage + # our liquidity is too low + return channel["our"] / min_liquidity / 2 + # their liquidity is too low + return (min_liquidity - theirs) / min_liquidity / 2 + 0.5 def get_ratio_soft(our_percentage): diff --git a/feeadjuster/test_feeadjuster.py b/feeadjuster/test_feeadjuster.py index a185b1a..6481620 100644 --- a/feeadjuster/test_feeadjuster.py +++ b/feeadjuster/test_feeadjuster.py @@ -278,6 +278,7 @@ def test_feeadjuster_big_enough_liquidity(node_factory): # Let's move another 0.003btc -> the channels will be at 0.006btc amount = 300000000 pay(l1, l3, amount) + l2.wait_for_htlcs() assert not l2.daemon.is_in_log("Adjusted fees", log_offset) # Sending another 0.0033btc will result in a channel balance of 0.0093btc