Skip to content

fix(fee-utils): replace hardcoded XLM_PRICE with live useTokenPrice#412

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
brightfootlimited-collab:fix/issue-288-live-xlm-price-fee-estimate
Jul 26, 2026
Merged

fix(fee-utils): replace hardcoded XLM_PRICE with live useTokenPrice#412
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
brightfootlimited-collab:fix/issue-288-live-xlm-price-fee-estimate

Conversation

@brightfootlimited-collab

Copy link
Copy Markdown
Contributor

Problem lib/fee-utils.ts hardcoded XLM_PRICE = 0.12 as the USD conversion factor for fee estimates. Once the real XLM/USD price diverges from that constant the displayed fee-in-USD becomes arbitrarily wrong. Fixes #288 ## Changes ### lib/fee-utils.ts - Removed the XLM_PRICE = 0.12 constant entirely. - Made xlmPrice an optional parameter (xlmPrice?: number). When no price is supplied (e.g. while the live fetch is still loading) estimatedUsd is undefined rather than a stale hardcoded value — matching the pre-existing estimatedUsd?: number type on FeeBreakdown. ### components/streams/create-confirmation.tsx - Imported useTokenPrice from hooks/use-token-price. - Calls useTokenPrice('XLM') and passes usdPrice ?? undefined to calculateFeeBreakdown. ### �pp/app/stream/[id]/page.tsx - Same import added. - useTokenPrice('XLM') called inside both WithdrawDialog and CancelDialog; live price forwarded to calculateFeeBreakdown. ## Tests Existing tests in tests/lib/fee-utils.test.ts are unaffected: - Tests that pass an explicit price (calculateFeeBreakdown(10_000_000, 0.5)) continue to work. - Tests that call without a price now receive estimatedUsd: undefined — none of those tests assert on estimatedUsd, so they all pass as-is.

…ib/fee-utils.ts hardcoded XLM_PRICE = 0.12 as the default for USD fee estimates. This value becomes stale as the real XLM/USD price moves, causing the displayed fee-in-USD to be arbitrarily wrong. Changes: - Remove the XLM_PRICE constant from fee-utils.ts - Make xlmPrice an optional param (undefined -> estimatedUsd omitted) - Pass the live usdPrice from useTokenPrice('XLM') at every call site: * components/streams/create-confirmation.tsx * app/app/stream/[id]/page.tsx (WithdrawDialog + CancelDialog) Closes FlowwStar#288
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@brightfootlimited-collab Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Austinaminu2
Austinaminu2 merged commit 6dae44a into FlowwStar:main Jul 26, 2026
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: hardcoded stale XLM price used for fee-in-USD estimation

2 participants