Skip to content

Align swap widget fee naming and signed fee display - #1115

Open
ted-palmer wants to merge 2 commits into
mainfrom
ted/int2-1322-align-swap-widget-fee-naming
Open

Align swap widget fee naming and signed fee display#1115
ted-palmer wants to merge 2 commits into
mainfrom
ted/int2-1322-align-swap-widget-fee-naming

Conversation

@ted-palmer

Copy link
Copy Markdown
Collaborator

No description provided.

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
relay-sdk-demo Ready Ready Preview Aug 28, 2026 6:35pm

Request Review

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ted-palmer's task in 1m 42s —— View job


Code Review

  • Gather context (PR diff, commit history)
  • Read changed files in full
  • Review for correctness, security, error handling, repo guidelines

Code Review — No issues found.

Reviewed 4 files (quote.ts, PriceImpactTooltip.tsx, FeeBreakdown.tsx, and the changeset), ~46 lines changed. Checked correctness, sign/precision handling, and repo guidelines compliance.

Notes from the review (all clear, no action needed):

  • formatUsdFee sign/precision logic (utils/quote.ts:23-41) is consistent with the codebase's convention that negative USD = cost and positive = benefit/reward. Zero → $0.00, sub-cent → < $0.01, and the + prefix only applies to positive values, so costs still render -$X.XX. finalValue === 0 correctly handles -0 (JS treats -0 === 0 as true), so a flipped-sign zero gas fee doesn't slip into the sub-cent branch.
  • Reward path is coherent end-to-end. parseFees now always labels the relayer fee Platform Fee, and PriceImpactTooltip.tsx:63 derives isReward = fee.id === 'relayer-fee' && fee.usd.value > 0. That lines up with getFeeColor (green for value > 0) and the + prefix, so a positive platform fee renders green +$X.XX with a green (Reward) note — matching the changeset.
  • Deposit gas collapsed summary (FeeBreakdown.tsx:66-68) still uses formatDollar(Math.abs(...)) independently of formatUsdFee, so the sign-flip changes don't double-apply there.
  • The changeset follows the repo guidelines: leads with the reader-facing outcome, names the exact strings changed, and stays customer-facing.

One thing worth being aware of (not a defect, and it matches the documented behavior in the changeset): a sub-cent cost renders as < $0.01 with no leading minus, so it reads the same as a sub-cent credit apart from color. Since color already differentiates reward (green) from cost (plain), this is fine — just flagging the intentional trade-off.
ted/int2-1322-align-swap-widget-fee-naming

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ted-palmer's task in 46s —— View job


📝 Docs Drift Check — No docs impact

This PR does not touch surfaces that require a relayprotocol/relay-docs update.

The change renames swap-widget fee display labels (e.g. "Swap Impact" → "Swap Cost", "Relay Fee" → "Platform Fee", "Network cost" → "Deposit gas") and adjusts signed/zero/sub-cent fee formatting inside FeeBreakdown / PriceImpactTooltip and the internal parseFees util. No public props, types, exports, or hooks changed. The reference docs (references/relay-kit/ui/swap-widget.mdx) document widget props, not these row labels, and the fee concepts page already uses the aligned naming ("Execution Cost", "Swap Cost", "Platform Fees").

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown

Greptile Summary

Updates swap fee terminology and makes small fee credits and charges distinguishable. The fee formatter now preserves the sign for values below one cent.

Confidence Score: 5/5

No blocking failure remains.

No accepted blocking findings remain.

T-Rex T-Rex Logs

What T-Rex did

  • The harness source was uploaded and wired to invoke parseFees.
  • The harness was executed against the parseFees implementation with +0.005 and -0.005 execution fees, revealing the parent behavior as < $0.01 for both inputs and the current behavior as +< $0.01 for +0.005 and -< $0.01 for -0.005.
  • The UI package TypeScript typecheck completed successfully.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "Keep the sign on sub-cent fee amounts" | Re-trigger Greptile

Comment thread packages/ui/src/utils/quote.ts Outdated
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ted-palmer's task in 1m 2s —— View job


Code Review

  • Gather context (PR diff, commit history)
  • Read changed files in full
  • Review for correctness, sign/precision handling, and repo guidelines

Code Review — No issues found.

Reviewed the 4 PR files (.changeset/fee-naming-signed-display.md, FeeBreakdown.tsx, PriceImpactTooltip.tsx, utils/quote.ts), ~46 lines changed. Checked correctness, sign/zero/precision handling, and repo guidelines.

The Greptile P1 (sub-cent discards sign) is resolved. Commit fa9be960 updated formatUsdFee (utils/quote.ts:27-37) so sub-cent amounts now render signed — +< $0.01 for a credit and -< $0.01 for a charge — instead of a direction-less < $0.01. The changeset was updated to match.

Verified end-to-end:

  • formatUsdFee branches (quote.ts:28-37) are exhaustive and correct: finalValue === 0$0.00 (also catches -0, since -0 === 0); Math.abs < 0.01 (and non-zero) → signed ±< $0.01, where finalValue > 0 ? '+' : '-' is unambiguous because the zero case is already handled; otherwise formatDollar with a + prefix only for positive values, so costs keep their native -$X.XX.
  • Reward path is coherent. parseFees now always labels the relayer fee Platform Fee, and PriceImpactTooltip.tsx:63 derives isReward = fee.id === 'relayer-fee' && fee.usd.value > 0, rendering a green (Reward) note next to a green +$X.XX. Gas-sponsored relayer fees resolve to { value: 0 }, so isReward is correctly false there.
  • Deposit gas collapsed summary (FeeBreakdown.tsx) still uses formatDollar(Math.abs(...)) independently, so the sign-formatting changes don't double-apply.
  • Labels ("Swap Impact" → "Swap Cost", "Relay Fee" → "Platform Fee", "Execution Fee" → "Execution Cost", "Network cost"/"Deposit Gas" → "Deposit gas") are consistent across parseFees, FeeBreakdown, and PriceImpactTooltip, and the changeset names the exact strings — compliant with the repo's changeset guidelines.

Note: the two-dot origin/main...HEAD diff surfaces unrelated drift (svm-wallet-adapter, TransactionModal polling, walletCompatibility, etc.) because this branch predates those merges on main; those are not changes introduced by this PR and were excluded from the review.
ted/int2-1322-align-swap-widget-fee-naming

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ted-palmer's task in 47s —— View job


📝 Docs Drift Check — No docs impact

This PR does not touch surfaces that require a relayprotocol/relay-docs update.

The change renames swap-widget fee display labels ("Swap Impact" → "Swap Cost", "Relay Fee" → "Platform Fee", "Execution Fee" → "Execution Cost", "Network cost" → "Deposit gas") and adjusts signed/zero/sub-cent USD fee formatting inside FeeBreakdown / PriceImpactTooltip and the internal parseFees util. No public props, types, exports, or hooks changed, so the reference docs (which document widget props, not these row labels) remain accurate.

ted/int2-1322-align-swap-widget-fee-naming

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.

1 participant