From 341dc5c45cf98e0da342587ee5f90a5121bd8641 Mon Sep 17 00:00:00 2001 From: Nwatu Desmond Date: Mon, 19 Oct 2026 21:58:36 +0100 Subject: [PATCH] fix: guard withdrawals when the risk pool is drained --- contracts/risk-pool/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/risk-pool/src/lib.rs b/contracts/risk-pool/src/lib.rs index e4af65c..da5a441 100644 --- a/contracts/risk-pool/src/lib.rs +++ b/contracts/risk-pool/src/lib.rs @@ -592,7 +592,7 @@ impl RiskPool { }; let available_liquidity = total_deposited.saturating_sub(total_locked); - if available_liquidity <= 0 { panic_with_error!(&env, Error::Undercollateralized); } + if available_liquidity <= 0 { panic_with_error!(&env, Error::PoolDrained); } // Issue #621: shares * total_deposited / total_shares truncates // toward zero; if the pool has absorbed losses total_deposited // may be tiny relative to total_shares and a small redemption