Skip to content

Commit

Permalink
fix: sanitize health factor (#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsign authored May 5, 2024
1 parent ed232dc commit bf669cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/handlers/updateBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit bf669cb

Please sign in to comment.