File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -3753,9 +3753,11 @@ pub fn set_user_status_to_being_liquidated(
37533753 MarginContext :: liquidation ( liquidation_margin_buffer_ratio) ,
37543754 ) ?;
37553755
3756+ let mut updated_liquidation_status = false ;
37563757 if !user. is_cross_margin_being_liquidated ( )
37573758 && !margin_calculation. meets_cross_margin_requirement ( )
37583759 {
3760+ updated_liquidation_status = true ;
37593761 user. enter_cross_margin_liquidation ( slot) ?;
37603762 }
37613763
@@ -3765,9 +3767,14 @@ pub fn set_user_status_to_being_liquidated(
37653767 if !user. is_isolated_margin_being_liquidated ( * market_index) ?
37663768 && !isolated_margin_calculation. meets_margin_requirement ( )
37673769 {
3770+ updated_liquidation_status = true ;
37683771 user. enter_isolated_margin_liquidation ( * market_index, slot) ?;
37693772 }
37703773 }
37713774
3775+ if !updated_liquidation_status {
3776+ return Err ( ErrorCode :: SufficientCollateral ) ;
3777+ }
3778+
37723779 Ok ( ( ) )
37733780}
Original file line number Diff line number Diff line change @@ -10465,6 +10465,7 @@ pub mod liquidate_isolated_perp_pnl_for_deposit {
1046510465 order_step_size : 10000000 ,
1046610466 quote_asset_amount : 150 * QUOTE_PRECISION_I128 ,
1046710467 base_asset_amount_with_amm : BASE_PRECISION_I128 ,
10468+ base_asset_amount_long : BASE_PRECISION_I128 ,
1046810469 oracle : sol_oracle_price_key,
1046910470 ..AMM :: default ( )
1047010471 } ,
@@ -10594,6 +10595,7 @@ pub mod liquidate_isolated_perp_pnl_for_deposit {
1059410595
1059510596 let market_after = market_map. get_ref ( & 0 ) . unwrap ( ) ;
1059610597 assert_eq ! ( market_after. amm. total_liquidation_fee, 0 ) ;
10598+ drop ( market_after) ;
1059710599
1059810600 resolve_perp_bankruptcy (
1059910601 0 ,
Original file line number Diff line number Diff line change @@ -1112,7 +1112,7 @@ impl PerpPosition {
11121112 }
11131113
11141114 pub fn is_available ( & self ) -> bool {
1115- !self . is_open_position ( ) && !self . has_open_order ( ) && !self . has_unsettled_pnl ( ) && self . isolated_position_scaled_balance == 0
1115+ !self . is_open_position ( ) && !self . has_open_order ( ) && !self . has_unsettled_pnl ( ) && self . isolated_position_scaled_balance == 0 && ! self . is_being_liquidated ( )
11161116 }
11171117
11181118 pub fn is_open_position ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments