File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -1570,14 +1570,21 @@ export class DriftClient {
15701570 perpMarketIndex : number ,
15711571 marginRatio : number ,
15721572 subAccountId = 0 ,
1573- txParams ?: TxParams
1573+ txParams ?: TxParams ,
1574+ enterHighLeverageMode ?: boolean
15741575 ) : Promise < TransactionSignature > {
1575- const ix = await this . getUpdateUserPerpPositionCustomMarginRatioIx (
1576+ const ixs = [ ] ;
1577+ if ( enterHighLeverageMode ) {
1578+ const enableIx = await this . getEnableHighLeverageModeIx ( subAccountId ) ;
1579+ ixs . push ( enableIx ) ;
1580+ }
1581+ const updateIx = await this . getUpdateUserPerpPositionCustomMarginRatioIx (
15761582 perpMarketIndex ,
15771583 marginRatio ,
15781584 subAccountId
15791585 ) ;
1580- const tx = await this . buildTransaction ( ix , txParams ?? this . txParams ) ;
1586+ ixs . push ( updateIx ) ;
1587+ const tx = await this . buildTransaction ( ixs , txParams ?? this . txParams ) ;
15811588 const { txSig } = await this . sendTransaction ( tx , [ ] , this . opts ) ;
15821589 return txSig ;
15831590 }
@@ -4958,9 +4965,8 @@ export class DriftClient {
49584965 subAccountId ?: number
49594966 ) : Promise < TransactionSignature > {
49604967 const { txSig, slot } = await this . sendTransaction (
4961- (
4962- await this . preparePlaceSpotOrderTx ( orderParams , txParams , subAccountId )
4963- ) . placeSpotOrderTx ,
4968+ ( await this . preparePlaceSpotOrderTx ( orderParams , txParams , subAccountId ) )
4969+ . placeSpotOrderTx ,
49644970 [ ] ,
49654971 this . opts ,
49664972 false
Original file line number Diff line number Diff line change @@ -1027,7 +1027,6 @@ export class User {
10271027
10281028 if ( marketIndex === undefined || marketIndex === QUOTE_SPOT_MARKET_INDEX ) {
10291029 if ( netQuoteValue . gt ( ZERO ) ) {
1030-
10311030 totalAssetValue = totalAssetValue . add ( netQuoteValue ) ;
10321031 } else {
10331032 totalLiabilityValue = totalLiabilityValue . add ( netQuoteValue . abs ( ) ) ;
@@ -2465,7 +2464,10 @@ export class User {
24652464 const marginRequirement = this . getInitialMarginRequirement (
24662465 enterHighLeverageMode
24672466 ) ;
2468- const marginRatio = Math . max ( currentPosition . maxMarginRatio , this . getUserAccount ( ) . maxMarginRatio ) ;
2467+ const marginRatio = Math . max (
2468+ currentPosition . maxMarginRatio ,
2469+ this . getUserAccount ( ) . maxMarginRatio
2470+ ) ;
24692471 const marginFreedByClosing = perpLiabilityValue
24702472 . mul ( new BN ( marginRatio ) )
24712473 . div ( MARGIN_PRECISION ) ;
You can’t perform that action at this time.
0 commit comments