From f5b4bd9dd081091d4377289b639ab9c4a2e1a6c8 Mon Sep 17 00:00:00 2001 From: Serge Farny Date: Mon, 5 Aug 2024 14:32:37 +0100 Subject: [PATCH] Liquidator: fix an arithmetic error in client side health computation (#986) --- programs/mango-v4/src/health/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/programs/mango-v4/src/health/client.rs b/programs/mango-v4/src/health/client.rs index 0d4d7d31eb..b82b73b022 100644 --- a/programs/mango-v4/src/health/client.rs +++ b/programs/mango-v4/src/health/client.rs @@ -504,7 +504,10 @@ fn scan_right_until_less_than( if value <= target { return Ok(current); } - current = current.max(I80F48::ONE) * I80F48::from(2); + let Some(new_current) = current.max(I80F48::ONE).checked_mul(I80F48::from(2)) else { + break; + }; + current = new_current; } Err(error_msg!( "could not find amount that lead to health ratio <= 0"