Fix account borrow issue in perp_liq_force_cancel_orders (#557)
This commit is contained in:
parent
10113443df
commit
898788909e
|
@ -10,18 +10,18 @@ pub fn perp_liq_force_cancel_orders(
|
||||||
limit: u8,
|
limit: u8,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut account = ctx.accounts.account.load_full_mut()?;
|
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()?;
|
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
|
// 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)?;
|
let liquidatable = account.check_liquidatable(&health_cache)?;
|
||||||
if account.fixed.is_operational()
|
if account.fixed.is_operational()
|
||||||
&& liquidatable != CheckLiquidatable::Liquidatable
|
&& liquidatable != CheckLiquidatable::Liquidatable
|
||||||
|
@ -29,10 +29,6 @@ pub fn perp_liq_force_cancel_orders(
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
health_cache
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cancel orders
|
// Cancel orders
|
||||||
|
|
Loading…
Reference in New Issue