Skip to content

Commit bf5249c

Browse files
committed
chore: version 1.3.6
1 parent 5df4066 commit bf5249c

File tree

10 files changed

+105
-28
lines changed

10 files changed

+105
-28
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [1.3.6] - 2025-09-26
2+
3+
### Fixed
4+
5+
- ETH price
6+
- TX reverted tracking
7+
8+
### Added
9+
10+
- More error tracking
11+
112
## [1.3.5] - 2025-09-25
213

314
### Fix

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reserve-protocol/react-zapper",
3-
"version": "1.3.5",
3+
"version": "1.3.6",
44
"type": "module",
55
"description": "React component for DTF minting with zap functionality",
66
"main": "dist/index.cjs.js",

src/components/updaters/token-balances-updater.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { atom, useAtomValue, useSetAtom } from 'jotai'
22
import { useEffect } from 'react'
3-
import { Address, erc20Abi, formatUnits } from 'viem'
3+
import { Address, erc20Abi, ethAddress, formatUnits } from 'viem'
44
import { useBalance } from 'wagmi'
55
import { useWatchReadContracts } from '../../hooks/use-watch-read-contracts'
66
import {
@@ -75,7 +75,7 @@ export const TokenBalancesUpdater = ({
7575
return prev
7676
}, {} as Record<string, TokenBalance>)
7777

78-
balances['0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'] = {
78+
balances[ethAddress] = {
7979
balance: balance ? balance.formatted : '0',
8080
value: balance ? balance.value : 0n,
8181
decimals: 18,

src/components/zap-mint/buy/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const Buy = () => {
7676
useTrackQuoteErrorUX({
7777
tokenIn: selectedToken.address,
7878
tokenOut: indexDTF?.id || '',
79+
source: data?.source,
7980
zapError: zapperErrorMessage,
8081
})
8182

src/components/zap-mint/submit-zap.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useAtom, useAtomValue, useSetAtom } from 'jotai'
22
import { useCallback, useEffect } from 'react'
3-
import { Address, erc20Abi } from 'viem'
3+
import { Address, erc20Abi, Hex } from 'viem'
4+
import { mainnet } from 'viem/chains'
45
import { useSendTransaction, useWaitForTransactionReceipt } from 'wagmi'
56
import useContractWrite from '../../hooks/useContractWrite'
67
import useWatchTransaction from '../../hooks/useWatchTransaction'
@@ -9,6 +10,7 @@ import { formatCurrency } from '../../utils/format'
910
import {
1011
useTrackIndexDTFZap,
1112
useTrackIndexDTFZapClick,
13+
useTrackIndexDTFZapError,
1214
} from '../../utils/tracking'
1315
import FusionTokenLogo from '../fusion-token-logo'
1416
import TransactionButton, {
@@ -27,7 +29,6 @@ import {
2729
import ZapDustWarningCheckbox from './zap-dust-warning-checkbox'
2830
import ZapErrorMsg, { ZapTxErrorMsg } from './zap-error-msg'
2931
import ZapPriceImpactWarningCheckbox from './zap-warning-checkbox'
30-
import { mainnet } from 'viem/chains'
3132

3233
const LoadingButton = ({
3334
fetchingZapper,
@@ -169,7 +170,7 @@ const SubmitZapButton = ({
169170

170171
setInputAmountCached(inputAmount)
171172
sendTransaction({
172-
data: tx.data as Address,
173+
data: tx.data as Hex,
173174
gas: BigInt(gas ?? 0) * multiplier || undefined,
174175
to: tx.to as Address,
175176
value: BigInt(tx.value),
@@ -180,8 +181,6 @@ const SubmitZapButton = ({
180181
readyToSubmit,
181182
inputAmount,
182183
gas,
183-
tx?.to,
184-
tx?.value,
185184
chainId,
186185
setInputAmountCached,
187186
sendTransaction,
@@ -222,6 +221,13 @@ const SubmitZapButton = ({
222221
setOngoingTx,
223222
])
224223

224+
useTrackIndexDTFZapError({
225+
tokenIn: tokenIn,
226+
tokenOut: tokenOut,
227+
zapError: error?.message?.split('\n')[0] || error?.name || '',
228+
source,
229+
})
230+
225231
return (
226232
<div className="flex flex-col gap-1">
227233
<ZapPriceImpactWarningCheckbox priceImpact={truePriceImpact} />

src/components/zap-mint/zap-error-msg.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import TransactionError from '../transaction-error'
22
import { useAtomValue } from 'jotai'
33
import { zapperCurrentTabAtom, zapSwapEndpointAtom } from './atom'
44
import Copy from '../ui/copy'
5-
// import { Link } from 'react-router-dom' // Removed router dependency
6-
// import { getFolioRoute } from '../../utils' // Removed routing
75
import { indexDTFAtom } from '../../state/atoms'
8-
// import { ROUTES } from '../../utils/constants' // Removed routing
96

107
const SWAP_ERROR_MSG =
118
'Sorry, we’re having a hard time finding a route that makes sense for you. Please try again in a bit.'
@@ -69,11 +66,7 @@ const ZapErrorMsg = ({ error }: { error?: string }) => {
6966
export const ZapTxErrorMsg = ({ error }: { error?: Error | null }) => {
7067
if (!error) return null
7168

72-
const errorMsg =
73-
Object.entries(ERROR_MAP).find(([key]) =>
74-
error?.message?.toLowerCase().includes(key.toLowerCase())
75-
)?.[1] || error?.message
76-
69+
const errorMsg = error?.message
7770
const newError = new Error(errorMsg)
7871

7972
return (

src/hooks/usePrice.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useQuery } from '@tanstack/react-query'
2-
import { Address } from 'viem'
2+
import { Address, ethAddress, zeroAddress } from 'viem'
33
import { useAtomValue } from 'jotai'
44
import { apiUrlAtom } from '@/state/atoms'
55

@@ -13,12 +13,15 @@ export function usePrice(
1313
): number | null {
1414
const atomUrl = useAtomValue(apiUrlAtom)
1515
const { data } = useQuery({
16-
queryKey: ['chainlinkPrice', chainId, tokenAddress, apiUrl, atomUrl],
16+
queryKey: ['reserveAPIPrice', chainId, tokenAddress, apiUrl, atomUrl],
1717
queryFn: async () => {
1818
if (!tokenAddress) return null
1919

20+
const transformedTokenAddress =
21+
tokenAddress === ethAddress ? zeroAddress : tokenAddress
22+
2023
const baseUrl = apiUrl || atomUrl
21-
const url = `${baseUrl}current/prices?chainId=${chainId}&tokens=${tokenAddress}`
24+
const url = `${baseUrl}current/prices?chainId=${chainId}&tokens=${transformedTokenAddress}`
2225

2326
try {
2427
const response = await fetch(url)

src/hooks/useWatchTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ const useWatchTransaction = ({
4545
})
4646

4747
useEffect(() => {
48-
if (!hash || !data) return
48+
if (!hash) return
4949

5050
const notificationKey = `${hash}-${status}`
5151

5252
if (notifiedRef.current[notificationKey]) return
5353

54-
if (status === 'success') {
54+
if (status === 'success' && data) {
5555
notifiedRef.current[notificationKey] = true
5656
notify(
5757
successMessage?.title ?? `Transaction confirmed`,

src/utils/constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Address } from 'viem'
1+
import { Address, ethAddress } from 'viem'
22
import { ChainId } from './chains'
33
import { Token } from '..'
44

55
const reducedMainnetTokens = [
66
{
7-
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' as Address,
7+
address: ethAddress,
88
symbol: 'ETH',
99
name: 'Ether',
1010
decimals: 18,
@@ -28,7 +28,7 @@ const reducedMainnetTokens = [
2828

2929
const reducedBaseTokens = [
3030
{
31-
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' as Address,
31+
address: ethAddress,
3232
symbol: 'ETH',
3333
name: 'Ether',
3434
decimals: 18,
@@ -52,7 +52,7 @@ const reducedBaseTokens = [
5252

5353
const reducedArbitrumTokens = [
5454
{
55-
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' as Address,
55+
address: ethAddress,
5656
symbol: 'ETH',
5757
name: 'Ether',
5858
decimals: 18,
@@ -76,7 +76,7 @@ const reducedArbitrumTokens = [
7676

7777
const bscTokens = [
7878
{
79-
address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' as Address,
79+
address: ethAddress,
8080
symbol: 'BNB',
8181
name: 'BNB',
8282
decimals: 18,

src/utils/tracking.ts

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ mixpanel.init(MIXPANEL_TOKEN, {
1313
track_pageview: true,
1414
})
1515

16-
export const mixpanelTrack = (event: string, data?: Record<string, unknown>) => {
16+
export const mixpanelTrack = (
17+
event: string,
18+
data?: Record<string, unknown>
19+
) => {
1720
try {
1821
mixpanel.track(event, data)
1922
} catch (error) {
@@ -207,10 +210,12 @@ export const useTrackQuoteErrorUX = ({
207210
tokenIn,
208211
tokenOut,
209212
zapError,
213+
source,
210214
}: {
211215
tokenIn: string
212216
tokenOut: string
213217
zapError: string
218+
source?: 'zap' | 'odos'
214219
}) => {
215220
const chainId = useAtomValue(chainIdAtom)
216221
const account = useAtomValue(walletAtom)
@@ -232,7 +237,65 @@ export const useTrackQuoteErrorUX = ({
232237
tokenIn,
233238
tokenOut,
234239
userError: zapError,
240+
source,
235241
})
236242
}
237-
}, [zapError, account, tokenIn, tokenOut, indexDTF, currentTab, endpoint, chainId])
243+
}, [
244+
zapError,
245+
account,
246+
tokenIn,
247+
tokenOut,
248+
indexDTF,
249+
currentTab,
250+
endpoint,
251+
chainId,
252+
source,
253+
])
254+
}
255+
256+
export const useTrackIndexDTFZapError = ({
257+
tokenIn,
258+
tokenOut,
259+
zapError,
260+
source,
261+
}: {
262+
tokenIn: string
263+
tokenOut: string
264+
zapError: string
265+
source?: 'zap' | 'odos'
266+
}) => {
267+
const chainId = useAtomValue(chainIdAtom)
268+
const account = useAtomValue(walletAtom)
269+
const indexDTF = useAtomValue(indexDTFAtom)
270+
const currentTab = useAtomValue(zapperCurrentTabAtom)
271+
const endpoint = useAtomValue(zapSwapEndpointAtom)
272+
273+
useEffect(() => {
274+
if (zapError) {
275+
mixpanelTrack('index-dtf-zap-swap', {
276+
event: 'index-dtf-zap-swap',
277+
wa: account,
278+
ca: tokenIn,
279+
ticker: indexDTF?.token.symbol || '',
280+
chainId,
281+
type: currentTab,
282+
endpoint,
283+
status: 'user_tx_error',
284+
tokenIn,
285+
tokenOut,
286+
userError: zapError,
287+
source,
288+
})
289+
}
290+
}, [
291+
zapError,
292+
account,
293+
tokenIn,
294+
tokenOut,
295+
indexDTF,
296+
currentTab,
297+
endpoint,
298+
chainId,
299+
source,
300+
])
238301
}

0 commit comments

Comments
 (0)