diff --git a/programs/mango-v4/src/instructions/perp_liq_force_cancel_orders.rs b/programs/mango-v4/src/instructions/perp_liq_force_cancel_orders.rs index 500f9461b..f001cf78b 100644 --- a/programs/mango-v4/src/instructions/perp_liq_force_cancel_orders.rs +++ b/programs/mango-v4/src/instructions/perp_liq_force_cancel_orders.rs @@ -10,29 +10,25 @@ pub fn perp_liq_force_cancel_orders( limit: u8, ) -> Result<()> { let mut account = ctx.accounts.account.load_full_mut()?; + + let mut health_cache = { + let retriever = + new_fixed_order_account_retriever(ctx.remaining_accounts, &account.borrow())?; + new_health_cache(&account.borrow(), &retriever).context("create health cache")? + }; + let mut perp_market = ctx.accounts.perp_market.load_mut()?; // // Early return if if liquidation is not allowed or if market is not in force close // - let mut health_cache = { - let retriever = - new_fixed_order_account_retriever(ctx.remaining_accounts, &account.borrow())?; - let health_cache = - new_health_cache(&account.borrow(), &retriever).context("create health cache")?; - - { - let liquidatable = account.check_liquidatable(&health_cache)?; - if account.fixed.is_operational() - && liquidatable != CheckLiquidatable::Liquidatable - && !perp_market.is_force_close() - { - return Ok(()); - } - } - - health_cache - }; + let liquidatable = account.check_liquidatable(&health_cache)?; + if account.fixed.is_operational() + && liquidatable != CheckLiquidatable::Liquidatable + && !perp_market.is_force_close() + { + return Ok(()); + } // // Cancel orders