From ddab2fadf96d68a9ccec832236ce92ca31e11a27 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 24 Sep 2025 18:12:20 -0400 Subject: [PATCH] Fix doubled fee display on crypto quote page - Use same fee estimation logic on quote display as during payment creation - Call estimate_monero_fee_for_quote() for XMR to get doubled fee - Call estimate_dogecoin_fee_for_quote() for DOGE to get doubled fee - Fallback to doubled settings value for other coins - Ensures "Processing Fee (inbound + outbound)" shows correct doubled amount --- make_post_sell/views/crypto.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/make_post_sell/views/crypto.py b/make_post_sell/views/crypto.py index 4efe03f..af4478e 100644 --- a/make_post_sell/views/crypto.py +++ b/make_post_sell/views/crypto.py @@ -558,9 +558,32 @@ def crypto_quote(request): # Estimate base amount and fee (this is approximate since we don't store it separately) settings = request.registry.settings - fee_buffer = float( - settings.get(f"{coin_type.lower()}.fee_buffer", coin_info["default_fee_buffer"]) - ) + + # Calculate the fee the same way it was calculated during payment creation + if coin_type == "XMR" and crypto_payment.shop_sweep_to_address: + # Calculate base amount from the total + base_amount_crypto = float(crypto_payment.invoice.total) / float( + crypto_payment.rate_locked_usd_per_coin + ) + base_amount_piconero = int( + base_amount_crypto * coin_info["smallest_unit_divisor"] + ) + fee_buffer = estimate_monero_fee_for_quote( + settings, crypto_payment.shop_sweep_to_address, base_amount_piconero + ) + elif coin_type == "DOGE": + fee_buffer = estimate_dogecoin_fee_for_quote(settings) + else: + # Fallback to settings (but double it since all fees are doubled now) + fee_buffer = ( + float( + settings.get( + f"{coin_type.lower()}.fee_buffer", coin_info["default_fee_buffer"] + ) + ) + * 2 + ) + amount_crypto_base = amount_crypto_with_fee - fee_buffer return {