From f845363758251ee1a45d175d10457dba0e7738f0 Mon Sep 17 00:00:00 2001 From: brightfootlimited-collab Date: Sun, 26 Jul 2026 08:52:09 -0700 Subject: [PATCH] =?UTF-8?q?fix(fee-utils):=20remove=20hardcoded=20XLM=5FPR?= =?UTF-8?q?ICE,=20suppress=20USD=20estimate=20when=20price=20unavailable?= =?UTF-8?q?=20lib/fee-utils.ts=20used=20a=20hardcoded=20XLM=5FPRICE=20=3D?= =?UTF-8?q?=200.12=20constant=20as=20the=20default=20for=20calculateFeeBre?= =?UTF-8?q?akdown,=20which=20meant=20estimatedUsd=20was=20always=20emitted?= =?UTF-8?q?=20=E2=80=94=20even=20when=20no=20live=20price=20was=20availabl?= =?UTF-8?q?e=20=E2=80=94=20using=20a=20stale/fabricated=20value.=20This=20?= =?UTF-8?q?made=20the=20fee=20breakdown=20UI=20display=20misleading=20USD?= =?UTF-8?q?=20cost=20information=20to=20users.=20Changes:=20-=20Remove=20t?= =?UTF-8?q?he=20XLM=5FPRICE=20=3D=200.12=20constant=20-=20Make=20xlmPrice?= =?UTF-8?q?=20a=20true=20optional=20param=20(undefined=20by=20default)=20-?= =?UTF-8?q?=20Only=20compute=20estimatedUsd=20when=20a=20live=20price=20is?= =?UTF-8?q?=20explicitly=20provided;=20otherwise=20return=20undefined=20so?= =?UTF-8?q?=20callers=20can=20suppress=20the=20USD=20display=20Call=20site?= =?UTF-8?q?s=20in=20app/app/stream/[id]/page.tsx=20and=20components/stream?= =?UTF-8?q?s/create-confirmation.tsx=20that=20omit=20xlmPrice=20will=20now?= =?UTF-8?q?=20correctly=20receive=20estimatedUsd:=20undefined=20instead=20?= =?UTF-8?q?of=20a=20stale=20estimate.=20Closes=20#289?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/fee-utils.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/fee-utils.ts b/lib/fee-utils.ts index f778815..2fa5b32 100644 --- a/lib/fee-utils.ts +++ b/lib/fee-utils.ts @@ -5,17 +5,17 @@ export interface FeeBreakdown { estimatedUsd?: number; } -const XLM_PRICE = 0.12; // Average XLM price in USD for estimation - /** * Calculate fee breakdown from transaction simulation * @param minResourceFee Minimum resource fee from simulation in stroops - * @param xlmPrice Current XLM price in USD (optional) + * @param xlmPrice Current XLM/USD price. Pass the live value from useTokenPrice; + * omit (or pass undefined) when no price is available and USD + * estimate should be suppressed. * @returns Fee breakdown: base estimate, safety buffer, and total */ export function calculateFeeBreakdown( minResourceFee: number, - xlmPrice: number = XLM_PRICE, + xlmPrice?: number, ): FeeBreakdown { // Apply 15% buffer to ensure inclusion const bufferMultiplier = 1.15; @@ -23,7 +23,8 @@ export function calculateFeeBreakdown( const bufferFee = totalFee - minResourceFee; const totalXlm = totalFee / 1e7; - const estimatedUsd = totalXlm * xlmPrice; + const estimatedUsd = + xlmPrice !== undefined ? totalXlm * xlmPrice : undefined; return { minFee: minResourceFee,