Skip to content

Commit 51aae70

Browse files
committed
fix: bug with max lev available calculation
1 parent 561f47a commit 51aae70

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

sdk/src/user.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,11 @@ export class User {
484484
enterHighLeverageMode = undefined,
485485
perpPosition?: PerpPosition
486486
): BN {
487-
const userCustomMargin = Math.max(
488-
perpPosition?.maxMarginRatio ?? 0,
489-
this.getUserAccount().maxMarginRatio
490-
);
491487
const marginRatio = calculateMarketMarginRatio(
492488
this.driftClient.getPerpMarketAccount(marketIndex),
493489
baseAssetAmount,
494490
'Initial',
495-
userCustomMargin,
491+
this.getUserAccount().maxMarginRatio,
496492
enterHighLeverageMode || this.isHighLeverageMode('Initial')
497493
);
498494

@@ -2169,10 +2165,7 @@ export class User {
21692165
);
21702166
}
21712167

2172-
const userCustomMargin = Math.max(
2173-
perpPosition.maxMarginRatio,
2174-
this.getUserAccount().maxMarginRatio
2175-
);
2168+
const userCustomMargin = this.getUserAccount().maxMarginRatio;
21762169
const marginRatio = calculateMarketMarginRatio(
21772170
market,
21782171
baseAssetAmount.abs(),

0 commit comments

Comments
 (0)