diff --git a/typescript/infra/scripts/warp-routes/monitor/metrics.ts b/typescript/infra/scripts/warp-routes/monitor/metrics.ts index 52c2604f96..4879415f60 100644 --- a/typescript/infra/scripts/warp-routes/monitor/metrics.ts +++ b/typescript/infra/scripts/warp-routes/monitor/metrics.ts @@ -59,6 +59,7 @@ export function updateTokenBalanceMetrics( warpCore: WarpCore, token: Token, balanceInfo: WarpRouteBalance, + collateralTokenSymbol: string, ) { const metrics: WarpRouteMetrics = { chain_name: token.chainName, @@ -67,7 +68,7 @@ export function updateTokenBalanceMetrics( wallet_address: token.addressOrDenom, token_standard: token.standard, warp_route_id: createWarpRouteConfigId( - token.symbol, + collateralTokenSymbol, warpCore.getTokenChains(), ), related_chain_names: warpCore diff --git a/typescript/infra/scripts/warp-routes/monitor/monitor-warp-route-balances.ts b/typescript/infra/scripts/warp-routes/monitor/monitor-warp-route-balances.ts index 4eecc1f736..b8ba3e3f8d 100644 --- a/typescript/infra/scripts/warp-routes/monitor/monitor-warp-route-balances.ts +++ b/typescript/infra/scripts/warp-routes/monitor/monitor-warp-route-balances.ts @@ -89,12 +89,18 @@ async function pollAndUpdateWarpRouteMetrics( chainMetadata, apiKey: await getCoinGeckoApiKey(), }); + const collateralTokenSymbol = getWarpRouteCollateralTokenSymbol(warpCore); while (true) { await tryFn(async () => { await Promise.all( warpCore.tokens.map((token) => - updateTokenMetrics(warpCore, token, tokenPriceGetter), + updateTokenMetrics( + warpCore, + token, + tokenPriceGetter, + collateralTokenSymbol, + ), ), ); }, 'Updating warp route metrics'); @@ -107,6 +113,7 @@ async function updateTokenMetrics( warpCore: WarpCore, token: Token, tokenPriceGetter: CoinGeckoTokenPriceGetter, + collateralTokenSymbol: string, ) { const promises = [ tryFn(async () => { @@ -118,7 +125,12 @@ async function updateTokenMetrics( if (!balanceInfo) { return; } - updateTokenBalanceMetrics(warpCore, token, balanceInfo); + updateTokenBalanceMetrics( + warpCore, + token, + balanceInfo, + collateralTokenSymbol, + ); }, 'Getting bridged balance and value'), ]; @@ -310,6 +322,18 @@ async function getCoinGeckoApiKey(): Promise { return apiKey; } +function getWarpRouteCollateralTokenSymbol(warpCore: WarpCore): string { + const collateralToken = warpCore.tokens.find( + (token) => + token.isCollateralized() || + token.standard === TokenStandard.EvmHypXERC20Lockbox, + ); + if (!collateralToken) { + throw new Error('No collateral token found in warp route'); + } + return collateralToken.symbol; +} + main().catch((err) => { logger.error('Error in main:', err); process.exit(1);