update metrics: fix divide by zero, elasticity NaN bug

This commit is contained in:
mantikoros 2022-10-08 12:16:38 -05:00
parent d00ea65279
commit e1636d0f13
2 changed files with 6 additions and 2 deletions

View File

@ -97,7 +97,11 @@ export const computeBinaryCpmmElasticity = (
)
const resultNo = getCpmmProbability(poolN, pN)
return resultYes - resultNo
// handle AMM overflow
const safeYes = Number.isFinite(resultYes) ? resultYes : 1
const safeNo = Number.isFinite(resultNo) ? resultNo : 0
return safeYes - safeNo
}
export const computeDpmElasticity = (

View File

@ -169,7 +169,7 @@ export async function updateMetricsCore() {
return 0
}
const contractRatio =
contract.flaggedByUsernames.length / (contract.uniqueBettorCount ?? 1)
contract.flaggedByUsernames.length / (contract.uniqueBettorCount || 1)
return contractRatio
})