Skip to content

Conversation

@thechefpenguin
Copy link
Contributor

@thechefpenguin thechefpenguin commented Nov 21, 2025


PR-Codex overview

This PR primarily focuses on refactoring and enhancing the formatCurrencyAmount function, updating components to use this new function, and improving the UI elements in various swap-related views.

Detailed summary

  • Refactored formatCurrencyAmount to handle UnifiedCurrencyAmount.
  • Updated RouteDisplayModal to simplify button element.
  • Replaced formatAmount with formatCurrencyAmount in SwapModalHeaderV2, ConfirmSwapModalV2, and SwapModalFooterV2.
  • Enhanced RoutesBreakdown UI with new button styles.
  • Added a new TradingFeeDisplay component to handle trading fee displays.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}


Note

Unifies amount formatting to support UnifiedCurrencyAmount and updates swap/confirm UI to show consistent values, dynamic/usd-denominated fees, and improved route controls.

  • Utils
    • utils/formatCurrencyAmount: accepts UnifiedCurrencyAmount, adds default locale, handles tiny values, and routes through formatLocaleNumber; formatPrice/formatRawAmount retained with minor guard.
  • Swap UI
    • SwapModalHeaderV2 and ConfirmSwapModalV2: switch to formatCurrencyAmount for input/output and slippage-adjusted amounts; minor dependency updates.
    • SwapModalFooterV2: compute LP fee USD via useStablecoinPriceAmount and show USD when available; refine dynamic fee tooltip; replace min/max display with formatCurrencyAmount; small cleanup (remove breakpoint usage).
  • InfinitySwap (Advanced Details)
    • Introduces TradingFeeDisplay to centralize fee rendering with USD values and dynamic-fee hint; integrates in TradeSummary; removes prior fee-saved block.
  • Routes UI
    • RoutesBreakdown: adds routing settings button with PoolTypeIcon; keeps route modal trigger; styling tweaks.
    • RouteDisplayModal: simplifies RoutesDisplayButtonView (no end icon) and retains routing settings access.

Written by Cursor Bugbot for commit be77b1e. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings November 21, 2025 05:32
@linear
Copy link

linear bot commented Nov 21, 2025

PAN-8624 Swap UI changes

@changeset-bot
Copy link

changeset-bot bot commented Nov 21, 2025

⚠️ No Changeset found

Latest commit: be77b1e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web Ready Ready Preview Comment Nov 21, 2025 5:54am
8 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
aptos-web Ignored Ignored Nov 21, 2025 5:54am
blog Ignored Ignored Nov 21, 2025 5:54am
bridge Ignored Ignored Nov 21, 2025 5:54am
games Ignored Ignored Nov 21, 2025 5:54am
gamification Ignored Ignored Nov 21, 2025 5:54am
solana Ignored Ignored Nov 21, 2025 5:54am
ton Ignored Ignored Nov 21, 2025 5:54am
uikit Ignored Ignored Nov 21, 2025 5:54am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements UI improvements for the Swap interface, focusing on displaying trading fees in USD and adding a routing settings button. The changes enhance user experience by showing fee values in a more familiar currency format and providing easier access to routing configuration.

Key changes:

  • Trading fees now display in USD format when available, falling back to token amounts when USD prices are unavailable
  • Added a routing settings button to the routes breakdown section for quick access to routing configuration
  • Refactored currency amount formatting to support both CurrencyAmount and UnifiedCurrencyAmount types

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/web/src/views/SwapSimplify/InfinitySwap/TradingFee.tsx Added USD value display for trading fees with fallback to token amounts
apps/web/src/views/SwapSimplify/InfinitySwap/RoutesBreakdown.tsx Added routing settings modal button and reorganized route display UI
apps/web/src/views/SwapSimplify/InfinitySwap/AdvancedSwapDetails.tsx Extracted TradingFeeDisplay component and integrated USD fee display; removed fee saved section
apps/web/src/views/Swap/components/SwapModalHeaderV2.tsx Replaced formatAmount with formatCurrencyAmount for consistent formatting
apps/web/src/views/Swap/V3Swap/containers/ConfirmSwapModalV2.tsx Updated to use formatCurrencyAmount with proper type handling
apps/web/src/views/Swap/V3Swap/components/SwapModalFooterV2.tsx Implemented USD display for trading fees and updated slippage amount formatting
apps/web/src/views/Swap/V3Swap/components/RouteDisplayModal.tsx Removed pool type icon from routes display button
apps/web/src/utils/formatCurrencyAmount.ts Enhanced to support UnifiedCurrencyAmount type and optional locale parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Calculate all derived values before any conditional returns
const lpFeeAmount = Array.isArray(priceBreakdown) ? undefined : priceBreakdown?.lpFeeAmount
const inputAmount = order?.trade?.inputAmount
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inputAmount variable is extracted but not used in the new code. This extraction appears unnecessary since inputAmount is only used in the fallback display text, which is already accessed via order.trade.inputAmount.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +26
// Convert to number for formatLocaleNumber to handle both CurrencyAmount and UnifiedCurrencyAmount
// Both types have toExact() method, so we can use toSignificant for sigFigs
const amountNumber = parseFloat(amount.toSignificant(sigFigs))
return formatLocaleNumber({
number: amountNumber,
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting to a number via parseFloat(toSignificant()) may lose precision. The original implementation passed the CurrencyAmount directly to formatLocaleNumber. Consider updating formatLocaleNumber to accept both CurrencyAmount and UnifiedCurrencyAmount types instead of converting to number.

Suggested change
// Convert to number for formatLocaleNumber to handle both CurrencyAmount and UnifiedCurrencyAmount
// Both types have toExact() method, so we can use toSignificant for sigFigs
const amountNumber = parseFloat(amount.toSignificant(sigFigs))
return formatLocaleNumber({
number: amountNumber,
// Pass amount directly to formatLocaleNumber to preserve precision
return formatLocaleNumber({
amount,

Copilot uses AI. Check for mistakes.
orderHash,
token,
blockExplorerName,
getBlockExploreLink,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently getBlockExploreLink returns a new function on each render, this might result an infinite rerenders if it is added to deps, i have fixed in this pr #12515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants