From e3bfb8e4f0847f64cb4e673bb5c95048fb3224c8 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sun, 28 Sep 2025 16:21:07 -0400 Subject: [PATCH] Improve Dogecoin fee estimation to reduce overly high fees The fee estimation was calculating ~/bin/bash.20 fees when it should be much lower. Changes: - Use 6 block target (~1 hour) instead of 2 blocks for cheaper estimates - Reduce transaction size estimate from 0.5KB to 0.25KB (more realistic for DOGE) - Lower fallback fee from 0.01 DOGE to 0.002 DOGE (~/bin/bash.0006 vs /bin/bash.003) - Update development.ini default to match new lower fallback This should reduce typical fee estimates from ~/bin/bash.20 to ~/bin/bash.02-0.05 range, making Dogecoin payments more cost-effective for users while still covering both inbound and sweep transaction costs. --- development.ini | 4 ++-- make_post_sell/views/crypto.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/development.ini b/development.ini index 68c182c..8a5c5c5 100644 --- a/development.ini +++ b/development.ini @@ -93,8 +93,8 @@ dogecoin.rpc_pass = ${MPS_DOGECOIN_RPC_PASS:-change_this_password_in_production} dogecoin.confirmations.petty = ${MPS_DOGECOIN_CONFIRMATIONS_PETTY:-2} dogecoin.confirmations.mid = ${MPS_DOGECOIN_CONFIRMATIONS_MID:-6} dogecoin.confirmations.high = ${MPS_DOGECOIN_CONFIRMATIONS_HIGH:-20} -# Fee buffer for customer payments (in DOGE) -dogecoin.fee_buffer = ${MPS_DOGECOIN_FEE_BUFFER:-0.01} +# Fee buffer for customer payments (in DOGE) - reduced from 0.01 to 0.002 for more reasonable fees +dogecoin.fee_buffer = ${MPS_DOGECOIN_FEE_BUFFER:-0.002} dogecoin.rate_source_url = ${MPS_DOGECOIN_RATE_SOURCE_URL:-https://api.coingecko.com/api/v3/simple/price?ids=dogecoin&vs_currencies=usd} # set this to the path of your private DKIM key. diff --git a/make_post_sell/views/crypto.py b/make_post_sell/views/crypto.py index 91fbfb4..ab4c672 100644 --- a/make_post_sell/views/crypto.py +++ b/make_post_sell/views/crypto.py @@ -1094,20 +1094,23 @@ def estimate_dogecoin_fee_for_quote(settings): client = get_dogecoin_client_from_settings(settings) # Use estimatesmartfee to get current network fee estimate - fee_estimate_result = client._call("estimatesmartfee", [2]) # 2 block target + # Use 6 block target (~1 hour) instead of 2 blocks for cheaper fees + fee_estimate_result = client._call("estimatesmartfee", [6]) if fee_estimate_result and "feerate" in fee_estimate_result: - # feerate is in DOGE per KB, estimate transaction size as ~0.5KB - estimated_fee_doge = float(fee_estimate_result["feerate"]) * 0.5 + # feerate is in DOGE per KB, estimate transaction size as ~0.25KB (more realistic) + # Typical DOGE transaction is ~225 bytes, not 500 bytes + estimated_fee_doge = float(fee_estimate_result["feerate"]) * 0.25 # Double the fee to cover both inbound (customer) and outbound (sweep) transactions total_fee_doge = estimated_fee_doge * 2 return Decimal(str(total_fee_doge)) else: # Fallback to hardcoded fee if estimatesmartfee fails, doubled for inbound + outbound - fallback_fee = float(settings.get("dogecoin.fee_buffer", "0.01")) * 2 + # Reduce fallback from 0.01 to 0.002 DOGE (~$0.0006 vs $0.003) + fallback_fee = float(settings.get("dogecoin.fee_buffer", "0.002")) * 2 return Decimal(str(fallback_fee)) except Exception as e: # Fallback to hardcoded fee if RPC call fails, doubled for inbound + outbound - fallback_fee = float(settings.get("dogecoin.fee_buffer", "0.01")) * 2 + fallback_fee = float(settings.get("dogecoin.fee_buffer", "0.002")) * 2 return Decimal(str(fallback_fee))