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
This commit is contained in:
parent
d579af10a9
commit
ddab2fadf9
1 changed files with 26 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue