Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 7850cbe

Browse files
committed
feat: add swap_data field to track swap details in useHandleSwap
1 parent f248e7c commit 7850cbe

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

libs/shared/providers/src/swapper/hooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { useQuery, useQueryClient } from '@tanstack/react-query';
1212
import { waitForTransactionReceipt } from '@wagmi/core';
1313
import { uniq } from 'ramda';
14+
import { formatUnits } from 'viem';
1415
import { mainnet } from 'viem/chains';
1516
import { useAccount, useConfig } from 'wagmi';
1617

@@ -711,6 +712,7 @@ export const useHandleSwap = () => {
711712
swap_token: tokenIn.symbol,
712713
swap_to: tokenOut.symbol,
713714
swap_amount: amountIn,
715+
swap_data: `${formatUnits(amountIn, tokenIn.decimals)} ${tokenIn.symbol} -> ${formatUnits(amountOut, tokenOut.decimals)} ${tokenOut.symbol} with ${selectedSwapRoute.action}`,
714716
});
715717
queryClient.invalidateQueries();
716718
setSwapState((state) => ({

libs/shared/providers/src/swapper/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export type SwapTrackEvent =
207207
swap_token: string;
208208
swap_to: string;
209209
swap_amount: bigint;
210+
swap_data: string;
210211
}
211212
| {
212213
name: 'swap_failed';

0 commit comments

Comments
 (0)