File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414 PositionDirection ,
1515 PerpPosition ,
1616 SpotMarketAccount ,
17+ PositionFlag ,
1718} from '../types' ;
1819import {
1920 calculateUpdatedAMM ,
@@ -243,10 +244,16 @@ export function positionIsAvailable(position: PerpPosition): boolean {
243244 position . baseAssetAmount . eq ( ZERO ) &&
244245 position . openOrders === 0 &&
245246 position . quoteAssetAmount . eq ( ZERO ) &&
246- position . lpShares . eq ( ZERO )
247+ position . lpShares . eq ( ZERO ) &&
248+ position . isolatedPositionScaledBalance . eq ( ZERO )
249+ && ! positionIsBeingLiquidated ( position )
247250 ) ;
248251}
249252
253+ export function positionIsBeingLiquidated ( position : PerpPosition ) : boolean {
254+ return ( position . positionFlag & ( PositionFlag . BeingLiquidated | PositionFlag . Bankruptcy ) ) > 0 ;
255+ }
256+
250257/**
251258 *
252259 * @param userPosition
Original file line number Diff line number Diff line change @@ -504,7 +504,6 @@ export type LiquidationRecord = {
504504 liquidatePerpPnlForDeposit : LiquidatePerpPnlForDepositRecord ;
505505 perpBankruptcy : PerpBankruptcyRecord ;
506506 spotBankruptcy : SpotBankruptcyRecord ;
507- bitFlags : number ;
508507} ;
509508
510509export class LiquidationType {
You can’t perform that action at this time.
0 commit comments