@@ -46,6 +46,7 @@ import {
4646 convertToNumber ,
4747 OrderParams ,
4848 SignedMsgOrderParamsDelegateMessage ,
49+ OrderParamsBitFlag ,
4950} from '../sdk/src' ;
5051
5152import {
@@ -1192,6 +1193,69 @@ describe('place and make signedMsg order', () => {
11921193 await takerDriftClient . unsubscribe ( ) ;
11931194 } ) ;
11941195
1196+ it ( 'should place with high-leverage mode update' , async ( ) => {
1197+ const slot = new BN (
1198+ await bankrunContextWrapper . connection . toConnection ( ) . getSlot ( )
1199+ ) ;
1200+
1201+ const [ takerDriftClient , takerDriftClientUser ] =
1202+ await initializeNewTakerClientAndUser (
1203+ bankrunContextWrapper ,
1204+ chProgram ,
1205+ usdcMint ,
1206+ usdcAmount ,
1207+ marketIndexes ,
1208+ spotMarketIndexes ,
1209+ oracleInfos ,
1210+ bulkAccountLoader
1211+ ) ;
1212+ await takerDriftClientUser . fetchAccounts ( ) ;
1213+
1214+ const marketIndex = 0 ;
1215+ const baseAssetAmount = BASE_PRECISION ;
1216+ const takerOrderParams = getMarketOrderParams ( {
1217+ marketIndex,
1218+ direction : PositionDirection . LONG ,
1219+ baseAssetAmount,
1220+ auctionStartPrice : new BN ( 223 ) . mul ( PRICE_PRECISION ) ,
1221+ auctionEndPrice : new BN ( 227 ) . mul ( PRICE_PRECISION ) ,
1222+ auctionDuration : 10 ,
1223+ userOrderId : 1 ,
1224+ postOnly : PostOnlyParams . NONE ,
1225+ bitFlags : OrderParamsBitFlag . UpdateHighLeverageMode ,
1226+ } ) as OrderParams ;
1227+ const signedMsgSlot = slot . subn ( 5 ) ;
1228+ const uuid = Uint8Array . from ( Buffer . from ( nanoid ( 8 ) ) ) ;
1229+ const takerOrderParamsMessage : SignedMsgOrderParamsMessage = {
1230+ signedMsgOrderParams : takerOrderParams ,
1231+ subAccountId : 0 ,
1232+ slot : signedMsgSlot ,
1233+ uuid,
1234+ takeProfitOrderParams : null ,
1235+ stopLossOrderParams : null ,
1236+ } ;
1237+ const signedOrderParams = takerDriftClient . signSignedMsgOrderParamsMessage (
1238+ takerOrderParamsMessage
1239+ ) ;
1240+
1241+ await makerDriftClient . initializeHighLeverageModeConfig ( 1 ) ;
1242+ await makerDriftClient . placeSignedMsgTakerOrder (
1243+ signedOrderParams ,
1244+ marketIndex ,
1245+ {
1246+ taker : await takerDriftClient . getUserAccountPublicKey ( ) ,
1247+ takerUserAccount : takerDriftClient . getUserAccount ( ) ,
1248+ takerStats : takerDriftClient . getUserStatsAccountPublicKey ( ) ,
1249+ signingAuthority : takerDriftClient . wallet . publicKey ,
1250+ } ,
1251+ undefined ,
1252+ 2
1253+ ) ;
1254+
1255+ await takerDriftClientUser . unsubscribe ( ) ;
1256+ await takerDriftClient . unsubscribe ( ) ;
1257+ } ) ;
1258+
11951259 it ( 'should fail if auction params are not set' , async ( ) => {
11961260 slot = new BN (
11971261 await bankrunContextWrapper . connection . toConnection ( ) . getSlot ( )
0 commit comments