Health: Avoid overflow panic in health ratio for tiny liabs

Spotted by microwavedcola
This commit is contained in:
Christian Kamm 2022-09-23 12:04:14 +02:00
parent bb6790e678
commit f6c9a93ac5
1 changed files with 2 additions and 1 deletions

View File

@ -878,7 +878,8 @@ impl HealthCache {
let (assets, liabs) = self.health_assets_and_liabs(health_type);
let hundred = I80F48::from(100);
if liabs > 0 {
cm!(hundred * (assets - liabs) / liabs)
// feel free to saturate to MAX for tiny liabs
cm!(hundred * (assets - liabs)).saturating_div(liabs)
} else {
I80F48::MAX
}