Skip to content

Commit 8e168d0

Browse files
authored
Merge pull request #763 from relayprotocol/feature/gas-subsidization-tracking
Gas subsidization tracking
2 parents bafbd4f + 0dae775 commit 8e168d0

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

.changeset/fruity-onions-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@relayprotocol/relay-kit-ui': patch
3+
---
4+
5+
Add data tracking for gas subsidization

packages/ui/src/components/widgets/SwapWidget/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,7 @@ const SwapWidget: FC<SwapWidgetProps> = ({
17201720
} else {
17211721
const swapEventData = getSwapEventData(
17221722
quote?.details,
1723+
quote?.fees,
17231724
quote?.steps
17241725
? (quote?.steps as Execute['steps'])
17251726
: null,

packages/ui/src/components/widgets/SwapWidgetRenderer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
904904
const swapEventData = {
905905
...getSwapEventData(
906906
quote?.details,
907+
quote?.fees,
907908
currentSteps ?? null,
908909
linkedWallet?.connector,
909910
quoteParameters
@@ -964,6 +965,7 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
964965
try {
965966
const swapEventData = getSwapEventData(
966967
quote?.details,
968+
quote?.fees,
967969
quote?.steps ? (quote?.steps as Execute['steps']) : null,
968970
linkedWallet?.connector,
969971
quoteParameters
@@ -1014,6 +1016,7 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
10141016
const { step, stepItem } = getCurrentStep(currentSteps)
10151017
const swapEventData = getSwapEventData(
10161018
quote?.details,
1019+
quote?.fees,
10171020
currentSteps,
10181021
linkedWallet?.connector,
10191022
quoteParameters

packages/ui/src/utils/quote.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ export const getCurrentStep = (steps?: Execute['steps'] | null) => {
268268

269269
export const getSwapEventData = (
270270
details: Execute['details'],
271+
fees: Execute['fees'],
271272
steps: Execute['steps'] | null,
272273
connector?: string,
273274
quoteParameters?: Parameters<typeof useQuote>['2']
@@ -298,9 +299,11 @@ export const getSwapEventData = (
298299
quote_id: steps ? extractQuoteId(steps) : undefined,
299300
amount_in: details?.currencyIn?.amount,
300301
currency_in: details?.currencyIn?.currency?.symbol,
302+
currency_in_address: details?.currencyIn?.currency?.address,
301303
chain_id_in: details?.currencyIn?.currency?.chainId,
302304
amount_out: details?.currencyOut?.amount,
303305
currency_out: details?.currencyOut?.currency?.symbol,
306+
currency_out_address: details?.currencyOut?.currency?.address,
304307
chain_id_out: details?.currencyOut?.currency?.chainId,
305308
currency_in_usd: details?.currencyIn?.amountUsd,
306309
currency_out_usd: details?.currencyOut?.amountUsd,
@@ -333,7 +336,11 @@ export const getSwapEventData = (
333336
})
334337
return checkStatuses
335338
})
336-
.flat()
339+
.flat(),
340+
subsidized:
341+
fees?.subsidized !== undefined && fees.subsidized.amount !== '0'
342+
? true
343+
: false
337344
}
338345
}
339346

0 commit comments

Comments
 (0)