Skip to content

Commit f8b17cc

Browse files
committed
fix address
1 parent c37eabe commit f8b17cc

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/app/leverage/components/stats/use-quick-stats.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
getTokenByChainAndAddress,
3-
getTokenByChainAndSymbol,
4-
} from '@indexcoop/tokenlists'
1+
import { getTokenByChainAndSymbol } from '@indexcoop/tokenlists'
52
import { type QueryFunctionContext, useQuery } from '@tanstack/react-query'
63

74
import { formatAmount, formatDollarAmount } from '@/lib/utils'
@@ -73,11 +70,8 @@ export function useQuickStats(
7370
const baseToken = m[0]
7471
const baseCurrency = m[1].toLowerCase()
7572
try {
76-
const addressToken = getTokenByChainAndAddress(chainId, address)
77-
const chainToken = getTokenByChainAndSymbol(chainId, indexToken.symbol)
78-
const queryAddress = addressToken?.address ?? chainToken?.address ?? ''
7973
const response = await fetch(
80-
`/api/stats?address=${queryAddress}&chainId=${chainId}&symbol=${symbol}&base=${baseToken}&baseCurrency=${baseCurrency}`,
74+
`/api/stats?address=${address}&chainId=${chainId}&symbol=${symbol}&base=${baseToken}&baseCurrency=${baseCurrency}`,
8175
{ method: 'GET' },
8276
)
8377

@@ -113,18 +107,21 @@ export function useQuickStats(
113107
}
114108
}
115109

110+
const address =
111+
getTokenByChainAndSymbol(indexToken.chainId, indexToken.symbol)?.address ??
112+
''
116113
const { data, isFetching } = useQuery({
117114
queryKey: [
118115
'fetch-quick-stats',
119116
{
120117
chainId: indexToken.chainId,
121118
symbol: indexToken.symbol,
122-
address: indexToken.address,
119+
address,
123120
market,
124121
},
125122
],
126123
queryFn: fetchStats,
127-
enabled: !!indexToken.address,
124+
enabled: !!address,
128125
})
129126

130127
return {

0 commit comments

Comments
 (0)