Skip to content

Commit 343db67

Browse files
committed
include app fees in breakdown
1 parent 04dfd78 commit 343db67

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

packages/ui/src/components/widgets/TokenWidget/FeeBreakdownTooltip.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ export const FeeBreakdownTooltip: FC<FeeBreakdownTooltipProps> = ({
5151

5252
const fillGasLabel = destinationGas?.name ?? 'Fill Gas'
5353

54+
// App fee
55+
const appFee = feeBreakdown?.breakdown?.find((fee) => fee.id === 'app-fee')
56+
const appFeeUsd =
57+
appFee?.usd.value ??
58+
(quote?.fees?.app?.amountUsd !== undefined
59+
? Number(quote.fees.app.amountUsd)
60+
: undefined)
61+
5462
const tokenAmountFormatted = formatDollar(
5563
currencyInAmount !== undefined ? Number(currencyInAmount) : undefined
5664
)
@@ -63,6 +71,9 @@ export const FeeBreakdownTooltip: FC<FeeBreakdownTooltipProps> = ({
6371
const fillGasFormatted = formatDollar(
6472
fillGasUsd !== undefined ? Math.abs(fillGasUsd) : undefined
6573
)
74+
const appFeeFormatted = formatDollar(
75+
appFeeUsd !== undefined ? Math.abs(appFeeUsd) : undefined
76+
)
6677

6778
return (
6879
<Tooltip
@@ -106,7 +117,7 @@ export const FeeBreakdownTooltip: FC<FeeBreakdownTooltipProps> = ({
106117

107118
{/* Fill Gas Row */}
108119
{fillGasUsd !== undefined && fillGasFormatted !== '-' && (
109-
<Flex align="center" css={{ width: '100%' }}>
120+
<Flex align="center" css={{ width: '100%', mb: '2' }}>
110121
<Text style="subtitle2" color="subtle" css={{ mr: 'auto' }}>
111122
{fillGasLabel}
112123
</Text>
@@ -119,6 +130,22 @@ export const FeeBreakdownTooltip: FC<FeeBreakdownTooltipProps> = ({
119130
)}
120131
</Flex>
121132
)}
133+
134+
{/* App Fee Row */}
135+
{appFeeUsd !== undefined && appFeeFormatted !== '-' && (
136+
<Flex align="center" css={{ width: '100%' }}>
137+
<Text style="subtitle2" color="subtle" css={{ mr: 'auto' }}>
138+
{appFee?.name ?? 'App Fee'}
139+
</Text>
140+
{feeBreakdown?.isGasSponsored && appFeeUsd === 0 ? (
141+
<Text style="subtitle2" color="success">
142+
Free
143+
</Text>
144+
) : (
145+
<Text style="subtitle2">{appFeeFormatted}</Text>
146+
)}
147+
</Flex>
148+
)}
122149
</Flex>
123150
}
124151
{...tooltipProps}

0 commit comments

Comments
 (0)