From fa0c4e310c9a9d6d9613a2656b646f558096271b Mon Sep 17 00:00:00 2001 From: 0xsign <0xsign@protonmail.com> Date: Sun, 5 May 2024 09:37:33 +0200 Subject: [PATCH] fix: sanitize health factor --- src/handlers/updateBalances.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/handlers/updateBalances.ts b/src/handlers/updateBalances.ts index f5f6f2366..728947cf6 100644 --- a/src/handlers/updateBalances.ts +++ b/src/handlers/updateBalances.ts @@ -95,6 +95,7 @@ export async function updateBalances(client: ClickHouseClient, address: `0x${str for (const balance of group.balances) { balancesLength++ + balance.chain = chain // use token when available balance.address = (balance.token || balance.address).toLowerCase() // metadata @@ -165,7 +166,10 @@ export async function updateBalances(client: ClickHouseClient, address: `0x${str for (const groupIdx in balancesByGroupIdx) { const groupBalances = balancesByGroupIdx[groupIdx].map(formatBalance) - const healthFactor = balancesByGroupIdx[groupIdx]?.[0]?.healthFactor || resolveHealthFactor(groupBalances) + let healthFactor = balancesByGroupIdx[groupIdx]?.[0]?.healthFactor || resolveHealthFactor(groupBalances) + if (isNaN(healthFactor) || !isFinite(healthFactor)) { + healthFactor = undefined + } for (const balance of balancesByGroupIdx[groupIdx]) { dbBalances.push({ ...balance, healthFactor })