Skip to content

Commit 5f90487

Browse files
committed
fix: available positions logic update for iso
1 parent 788bdef commit 5f90487

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sdk/src/math/position.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
PositionDirection,
1515
PerpPosition,
1616
SpotMarketAccount,
17+
PositionFlag,
1718
} from '../types';
1819
import {
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

sdk/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ export type LiquidationRecord = {
504504
liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
505505
perpBankruptcy: PerpBankruptcyRecord;
506506
spotBankruptcy: SpotBankruptcyRecord;
507-
bitFlags: number;
508507
};
509508

510509
export class LiquidationType {

0 commit comments

Comments
 (0)