From 5e29f7f269cf8fbdb1cc2d71fe735d6ba53cba9d Mon Sep 17 00:00:00 2001 From: nicholaspai Date: Mon, 13 Jan 2025 22:52:26 -0700 Subject: [PATCH] unique dest tokens --- api/cron-cache-gas-costs.ts | 11 +++++++++-- api/cron-cache-l1-data-fee.ts | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/api/cron-cache-gas-costs.ts b/api/cron-cache-gas-costs.ts index bd5156b83..a2e6a6da8 100644 --- a/api/cron-cache-gas-costs.ts +++ b/api/cron-cache-gas-costs.ts @@ -108,10 +108,17 @@ const handler = async ( } }; - const getOutputTokensToChain = (chainId: number) => + const getOutputTokensToChain = (chainId: number) => { + const destinationTokens = new Set(); availableRoutes .filter(({ destinationChainId }) => destinationChainId === chainId) - .map(({ destinationToken }) => destinationToken); + .forEach(({ destinationToken }) => { + if (!destinationTokens.has(destinationToken)) { + destinationTokens.add(destinationToken); + } + }); + return Array.from(destinationTokens); + }; const cacheUpdatePromise = Promise.all( mainnetChains.map(async (chain) => { diff --git a/api/cron-cache-l1-data-fee.ts b/api/cron-cache-l1-data-fee.ts index e00bdcfc9..483088469 100644 --- a/api/cron-cache-l1-data-fee.ts +++ b/api/cron-cache-l1-data-fee.ts @@ -112,10 +112,17 @@ const handler = async ( } }; - const getOutputTokensToChain = (chainId: number) => + const getOutputTokensToChain = (chainId: number) => { + const destinationTokens = new Set(); availableRoutes .filter(({ destinationChainId }) => destinationChainId === chainId) - .map(({ destinationToken }) => destinationToken); + .forEach(({ destinationToken }) => { + if (!destinationTokens.has(destinationToken)) { + destinationTokens.add(destinationToken); + } + }); + return Array.from(destinationTokens); + }; const cacheUpdatePromise = Promise.all( mainnetChains