Skip to content

Commit 8461714

Browse files
authored
Display relayer fee token (#2549)
1 parent ea21887 commit 8461714

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

wormhole-connect/src/views/v2/Bridge/Routes/SingleRoute.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { isEmptyObject, calculateUSDPrice, millisToHumanString } from 'utils';
1919
import type { RouteData } from 'config/routes';
2020
import type { RootState } from 'store';
2121
import { formatBalance } from 'store/transferInput';
22+
import { toFixedDecimals } from 'utils/balance';
2223

2324
const useStyles = makeStyles()((theme: any) => ({
2425
container: {
@@ -63,7 +64,7 @@ const SingleRoute = (props: Props) => {
6364

6465
const destTokenConfig = useMemo(() => config.tokens[destToken], [destToken]);
6566

66-
const bridgeFee = useMemo(() => {
67+
const relayerFee = useMemo(() => {
6768
if (!quote?.relayFee) {
6869
return <></>;
6970
}
@@ -76,26 +77,33 @@ const SingleRoute = (props: Props) => {
7677
Object.values(config.tokens),
7778
);
7879

79-
const bridgePrice = calculateUSDPrice(
80+
if (!feeTokenConfig) {
81+
return <></>;
82+
}
83+
84+
const feePrice = calculateUSDPrice(
8085
relayFee,
8186
tokenPrices.data,
8287
feeTokenConfig,
8388
true,
8489
);
8590

86-
if (!bridgePrice) {
91+
if (!feePrice) {
8792
return <></>;
8893
}
8994

9095
return (
9196
<Stack direction="row" justifyContent="space-between">
9297
<Typography color={theme.palette.text.secondary} fontSize={14}>
93-
Bridge fee
98+
Relayer fee
9499
</Typography>
95100
{isFetchingQuote ? (
96101
<CircularProgress size={14} />
97102
) : (
98-
<Typography fontSize={14}>{bridgePrice}</Typography>
103+
<Typography fontSize={14}>{`${toFixedDecimals(
104+
relayFee.toString(),
105+
4,
106+
)} ${feeTokenConfig.symbol} (${feePrice})`}</Typography>
99107
)}
100108
</Stack>
101109
);
@@ -359,7 +367,7 @@ const SingleRoute = (props: Props) => {
359367
/>
360368
<CardContent>
361369
<Stack justifyContent="space-between">
362-
{bridgeFee}
370+
{relayerFee}
363371
{destinationGas}
364372
</Stack>
365373
<Stack direction="row" justifyContent="space-between">

wormhole-connect/src/views/v2/Redeem/TransactionDetails/index.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import { getExplorerLink } from 'utils/sdkv2';
2424

2525
import type { RootState } from 'store';
26+
import { toFixedDecimals } from 'utils/balance';
2627

2728
const useStyles = makeStyles()((theme: any) => ({
2829
container: {
@@ -173,26 +174,34 @@ const TransactionDetails = () => {
173174
return <></>;
174175
}
175176

176-
const bridgePrice = calculateUSDPrice(
177-
relayerFee?.fee,
177+
const feeTokenConfig = config.tokens[relayerFee.tokenKey];
178+
if (!feeTokenConfig) {
179+
return <></>;
180+
}
181+
182+
const feePrice = calculateUSDPrice(
183+
relayerFee.fee,
178184
tokenPrices.data,
179-
config.tokens[relayerFee.tokenKey],
185+
feeTokenConfig,
180186
true,
181187
);
182188

183-
if (!bridgePrice) {
189+
if (!feePrice) {
184190
return <></>;
185191
}
186192

187193
return (
188194
<Stack direction="row" justifyContent="space-between">
189195
<Typography color={theme.palette.text.secondary} fontSize={14}>
190-
Bridge fee
196+
Relayer fee
191197
</Typography>
192198
{tokenPrices.isFetching ? (
193199
<CircularProgress size={14} />
194200
) : (
195-
<Typography fontSize={14}>{bridgePrice}</Typography>
201+
<Typography fontSize={14}>{`${toFixedDecimals(
202+
relayerFee.fee.toString(),
203+
4,
204+
)} ${feeTokenConfig.symbol} (${feePrice})`}</Typography>
196205
)}
197206
</Stack>
198207
);

0 commit comments

Comments
 (0)