diff --git a/projects/dex-ui/src/tokens/useAllTokenBalance.tsx b/projects/dex-ui/src/tokens/useAllTokenBalance.tsx index c1e5f6286e..813a3b214d 100644 --- a/projects/dex-ui/src/tokens/useAllTokenBalance.tsx +++ b/projects/dex-ui/src/tokens/useAllTokenBalance.tsx @@ -85,11 +85,11 @@ export const useAllTokensBalance = () => { for (let i = 0; i < res.length; i++) { const value = res[i]; const token = tokensToLoad[i]; - balances[token.symbol] = token.fromBlockchain(value); + balances[token.address] = token.fromBlockchain(value); // set the balance in the query cache too - setQueryData(queryKeys.tokenBalance(token.symbol), () => { - return { [token.symbol]: balances[token.symbol] } + setQueryData(queryKeys.tokenBalance(token.address), () => { + return { [token.address]: balances[token.address] } }) } diff --git a/projects/dex-ui/src/tokens/useSiloBalance.tsx b/projects/dex-ui/src/tokens/useSiloBalance.tsx index aa17e293cf..da1e15b9db 100644 --- a/projects/dex-ui/src/tokens/useSiloBalance.tsx +++ b/projects/dex-ui/src/tokens/useSiloBalance.tsx @@ -9,7 +9,7 @@ export const useSiloBalance = (token: Token) => { const sdk = useSdk(); const { data, isLoading, error, refetch, isFetching } = useScopedQuery({ - queryKey: queryKeys.siloBalance(token.symbol), + queryKey: queryKeys.siloBalance(token.address), queryFn: async (): Promise => { let balance: TokenValue; @@ -40,7 +40,7 @@ export const useSiloBalanceMany = (tokens: Token[]) => { const setQueryData = useSetScopedQueryData(); const { data, isLoading, error, refetch, isFetching } = useScopedQuery({ - queryKey: queryKeys.siloBalanceMany(tokens.map((t) => t.symbol)), + queryKey: queryKeys.siloBalanceMany(tokens.map((t) => t.address)), queryFn: async () => { const resultMap: Record = {}; if (!address) return resultMap; @@ -70,17 +70,15 @@ export const useSiloBalanceMany = (tokens: Token[]) => { ) ); - console.log("resulst: ", results); - results.forEach((val) => { - resultMap[val.token.symbol] = val.amount; + resultMap[val.token.address] = val.amount; - // merge data into [scope, 'silo', token.symbol] + // merge data into [scope, 'silo', token.address] setQueryData(queryKeys.siloBalancesAll, (oldData) => { - if (!oldData) return { [val.token.symbol]: val.amount }; - return { ...oldData, [val.token.symbol]: val.amount }; + if (!oldData) return { [val.token.address]: val.amount }; + return { ...oldData, [val.token.address]: val.amount }; }); - setQueryData(queryKeys.siloBalance(val.token.symbol), () => { + setQueryData(queryKeys.siloBalance(val.token.address), () => { return val.amount; }); }); diff --git a/projects/dex-ui/src/tokens/useTokenBalance.tsx b/projects/dex-ui/src/tokens/useTokenBalance.tsx index f9006a9009..b1242234c6 100644 --- a/projects/dex-ui/src/tokens/useTokenBalance.tsx +++ b/projects/dex-ui/src/tokens/useTokenBalance.tsx @@ -10,7 +10,7 @@ export const useTokenBalance = (token: Token | undefined) => { const setQueryData = useSetScopedQueryData(); const { data, isLoading, error, refetch, isFetching } = useScopedQuery({ - queryKey: queryKeys.tokenBalance(token?.symbol), + queryKey: queryKeys.tokenBalance(token?.address), queryFn: async () => { if (!token) return; @@ -23,7 +23,7 @@ export const useTokenBalance = (token: Token | undefined) => { } const result = { - [token.symbol]: balance + [token.address]: balance }; // Also update the cache of "ALL" token query diff --git a/projects/dex-ui/src/utils/query/queryKeys.ts b/projects/dex-ui/src/utils/query/queryKeys.ts index 7b1b1bd39d..1e2b4feea9 100644 --- a/projects/dex-ui/src/utils/query/queryKeys.ts +++ b/projects/dex-ui/src/utils/query/queryKeys.ts @@ -7,7 +7,6 @@ export const queryKeys = { tokenAddress || "invalid", spender ], - lpSummary: (lpAddresses: string[]) => ["token", "lpSummary", ...lpAddresses], lpSummaryAll: ["token", "lpSummary"], // wells @@ -24,11 +23,11 @@ export const queryKeys = { // token balance tokenBalancesAll: ["token", "balance"], - tokenBalance: (symbol: string | undefined) => ["token", "balance", "external", symbol || "invalid"], - tokenBalanceInternal: (symbol: string | undefined) => ["token", "balance", "internal", symbol || "invalid"], + tokenBalance: (address: string | undefined) => ["token", "balance", "external", address || "invalid"], + tokenBalanceInternal: (address: string | undefined) => ["token", "balance", "internal", address || "invalid"], siloBalancesAll: ["silo", "balance"], - siloBalance: (symbol: string) => ["silo", "balance", symbol], - siloBalanceMany: (symbols: string[]) => ["silo", "balance", ...symbols], + siloBalance: (address: string) => ["silo", "balance", address], + siloBalanceMany: (addresses: string[]) => ["silo", "balance", ...addresses], } as const;