Fix account borrow issue in perp_liq_force_cancel_orders (#557)
This commit is contained in:
parent
10113443df
commit
898788909e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue