Skip to content

Commit 92b88a3

Browse files
committed
fix prices
1 parent ac1faae commit 92b88a3

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/utils/aggregate.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,15 @@ export const aggregateData = async (
291291

292292
const uniqueTokenPromises = Promise.all(
293293
txs.map(async (tx) => {
294-
let { token, chain, is_usd_volume, origin_chain } = tx;
294+
const { token, chain, origin_chain, is_usd_volume } = tx;
295+
if (is_usd_volume) return;
296+
if (!token) return;
295297
const isSolanaAddress = checkSolanaAddress(token);
296-
chain = isSolanaAddress ? "solana" : origin_chain ?? chain;
297-
if (!is_usd_volume) {
298-
if (!token || !chain) return;
299-
const tokenL = isSolanaAddress ? token : token.toLowerCase();
300-
uniqueTokens[transformTokens[chain]?.[tokenL] ?? `${chain}:${tokenL}`] = true;
301-
}
298+
const priceChain = (isSolanaAddress ? "solana" : chain) ?? origin_chain;
299+
if (!priceChain) return;
300+
const tokenL = priceChain === "solana" || origin_chain === "solana" ? token : token.toLowerCase();
301+
const key = transformTokens[priceChain]?.[tokenL] ?? `${priceChain}:${tokenL}`;
302+
uniqueTokens[key] = true;
302303
})
303304
);
304305
await uniqueTokenPromises;
@@ -340,9 +341,15 @@ export const aggregateData = async (
340341
usdValue = rawUsdValue;
341342
tokenKey = `${chain}:${token}`;
342343
} else {
343-
const tokenL = chain === "solana" || origin_chain === "solana" ? token : token.toLowerCase();
344-
const transformedDecimals = transformTokenDecimals[chain]?.[tokenL] ?? null;
345-
tokenKey = transformTokens[chain]?.[tokenL] ?? `${chain}:${tokenL}`;
344+
const isSolanaAddress = checkSolanaAddress(token);
345+
const priceChain = (isSolanaAddress ? "solana" : chain) ?? origin_chain;
346+
if (!priceChain) {
347+
console.log(`Skipping token with unknown chain for pricing`, tx);
348+
return;
349+
}
350+
const tokenL = priceChain === "solana" || origin_chain === "solana" ? token : token.toLowerCase();
351+
const transformedDecimals = transformTokenDecimals[priceChain]?.[tokenL] ?? null;
352+
tokenKey = transformTokens[priceChain]?.[tokenL] ?? `${priceChain}:${tokenL}`;
346353
if (blacklist.includes(tokenKey)) {
347354
console.log(`${tokenKey} in blacklist. Skipping`);
348355
return;

0 commit comments

Comments
 (0)