@drift-labs/sdk 2.119.0-beta.3 → 2.119.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/bun.lock +1 -1
- package/lib/browser/driftClient.d.ts +11 -11
- package/lib/browser/driftClient.js +32 -11
- package/lib/browser/idl/drift.json +23 -4
- package/lib/browser/math/spotBalance.d.ts +2 -0
- package/lib/browser/math/spotBalance.js +33 -1
- package/lib/browser/orderParams.d.ts +1 -0
- package/lib/browser/orderParams.js +5 -1
- package/lib/browser/tx/txHandler.d.ts +6 -1
- package/lib/browser/tx/txHandler.js +43 -2
- package/lib/browser/tx/txParamProcessor.d.ts +3 -2
- package/lib/browser/tx/txParamProcessor.js +11 -7
- package/lib/browser/tx/utils.d.ts +1 -1
- package/lib/browser/tx/utils.js +2 -16
- package/lib/browser/types.d.ts +5 -1
- package/lib/browser/types.js +7 -2
- package/lib/browser/user.js +2 -26
- package/lib/node/driftClient.d.ts +11 -11
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +32 -11
- package/lib/node/idl/drift.json +23 -4
- package/lib/node/math/spotBalance.d.ts +2 -0
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +33 -1
- package/lib/node/orderParams.d.ts +1 -0
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +5 -1
- package/lib/node/tx/txHandler.d.ts +6 -1
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +43 -2
- package/lib/node/tx/txParamProcessor.d.ts +3 -2
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +11 -7
- package/lib/node/tx/utils.d.ts +1 -1
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +2 -16
- package/lib/node/types.d.ts +5 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +7 -2
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +2 -26
- package/package.json +1 -1
- package/src/driftClient.ts +54 -19
- package/src/idl/drift.json +24 -5
- package/src/math/spotBalance.ts +82 -0
- package/src/orderParams.ts +5 -0
- package/src/tx/txHandler.ts +82 -9
- package/src/tx/txParamProcessor.ts +14 -6
- package/src/tx/utils.ts +1 -34
- package/src/types.ts +7 -2
- package/src/user.ts +13 -62
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.119.0-beta.
|
|
1
|
+
2.119.0-beta.5
|
package/bun.lock
CHANGED
|
@@ -1176,4 +1176,4 @@
|
|
|
1176
1176
|
|
|
1177
1177
|
"@solworks/soltoolkit-sdk/@solana/web3.js/rpc-websockets/@types/ws/@types/node": ["@types/node@22.13.8", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-G3EfaZS+iOGYWLLRCEAXdWK9my08oHNZ+FHluRiggIYJPOXzhOiDgpVCUHaUvyIC5/fj7C/p637jdzC666AOKQ=="],
|
|
1178
1178
|
}
|
|
1179
|
-
}
|
|
1179
|
+
}
|
|
@@ -586,13 +586,13 @@ export declare class DriftClient {
|
|
|
586
586
|
takerStats: PublicKey;
|
|
587
587
|
takerUserAccount: UserAccount;
|
|
588
588
|
signingAuthority: PublicKey;
|
|
589
|
-
}, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
589
|
+
}, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, includeHighLeverageModeConfig?: boolean, txParams?: TxParams): Promise<TransactionSignature>;
|
|
590
590
|
getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams: SignedMsgOrderParams, marketIndex: number, takerInfo: {
|
|
591
591
|
taker: PublicKey;
|
|
592
592
|
takerStats: PublicKey;
|
|
593
593
|
takerUserAccount: UserAccount;
|
|
594
594
|
signingAuthority: PublicKey;
|
|
595
|
-
}, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>;
|
|
595
|
+
}, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, includeHighLeverageModeConfig?: boolean): Promise<TransactionInstruction[]>;
|
|
596
596
|
placeAndMakeSignedMsgPerpOrder(signedSignedMsgOrderParams: SignedMsgOrderParams, signedMsgOrderUuid: Uint8Array, takerInfo: {
|
|
597
597
|
taker: PublicKey;
|
|
598
598
|
takerStats: PublicKey;
|
|
@@ -649,7 +649,7 @@ export declare class DriftClient {
|
|
|
649
649
|
* @param orderParams.auctionEndPrice:
|
|
650
650
|
* @param orderParams.reduceOnly:
|
|
651
651
|
* @param orderParams.postOnly:
|
|
652
|
-
* @param orderParams.
|
|
652
|
+
* @param orderParams.bitFlags:
|
|
653
653
|
* @param orderParams.policy:
|
|
654
654
|
* @param orderParams.maxTs:
|
|
655
655
|
* @returns
|
|
@@ -667,11 +667,11 @@ export declare class DriftClient {
|
|
|
667
667
|
auctionEndPrice?: BN;
|
|
668
668
|
reduceOnly?: boolean;
|
|
669
669
|
postOnly?: boolean;
|
|
670
|
-
|
|
670
|
+
bitFlags?: number;
|
|
671
671
|
maxTs?: BN;
|
|
672
672
|
policy?: number;
|
|
673
673
|
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
674
|
-
getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly,
|
|
674
|
+
getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, bitFlags, maxTs, policy, }: {
|
|
675
675
|
orderId: number;
|
|
676
676
|
newDirection?: PositionDirection;
|
|
677
677
|
newBaseAmount?: BN;
|
|
@@ -684,7 +684,7 @@ export declare class DriftClient {
|
|
|
684
684
|
auctionEndPrice?: BN;
|
|
685
685
|
reduceOnly?: boolean;
|
|
686
686
|
postOnly?: boolean;
|
|
687
|
-
|
|
687
|
+
bitFlags?: number;
|
|
688
688
|
maxTs?: BN;
|
|
689
689
|
policy?: number;
|
|
690
690
|
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
@@ -701,7 +701,7 @@ export declare class DriftClient {
|
|
|
701
701
|
* @param orderParams.auctionEndPrice: Only required if order type changed to market from something else
|
|
702
702
|
* @param orderParams.reduceOnly:
|
|
703
703
|
* @param orderParams.postOnly:
|
|
704
|
-
* @param orderParams.
|
|
704
|
+
* @param orderParams.bitFlags:
|
|
705
705
|
* @param orderParams.policy:
|
|
706
706
|
* @param orderParams.maxTs:
|
|
707
707
|
* @returns
|
|
@@ -719,11 +719,11 @@ export declare class DriftClient {
|
|
|
719
719
|
auctionEndPrice?: BN;
|
|
720
720
|
reduceOnly?: boolean;
|
|
721
721
|
postOnly?: boolean;
|
|
722
|
-
|
|
722
|
+
bitFlags?: number;
|
|
723
723
|
policy?: ModifyOrderPolicy;
|
|
724
724
|
maxTs?: BN;
|
|
725
725
|
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
726
|
-
getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly,
|
|
726
|
+
getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, bitFlags, maxTs, policy, }: {
|
|
727
727
|
userOrderId: number;
|
|
728
728
|
newDirection?: PositionDirection;
|
|
729
729
|
newBaseAmount?: BN;
|
|
@@ -736,7 +736,7 @@ export declare class DriftClient {
|
|
|
736
736
|
auctionEndPrice?: BN;
|
|
737
737
|
reduceOnly?: boolean;
|
|
738
738
|
postOnly?: boolean;
|
|
739
|
-
|
|
739
|
+
bitFlags?: number;
|
|
740
740
|
policy?: ModifyOrderPolicy;
|
|
741
741
|
maxTs?: BN;
|
|
742
742
|
txParams?: TxParams;
|
|
@@ -754,7 +754,7 @@ export declare class DriftClient {
|
|
|
754
754
|
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams, optionalIxs?: TransactionInstruction[]): Promise<TransactionSignature>;
|
|
755
755
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
756
756
|
settleMultiplePNLs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature>;
|
|
757
|
-
settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature[]>;
|
|
757
|
+
settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams, optionalIxs?: TransactionInstruction[]): Promise<TransactionSignature[]>;
|
|
758
758
|
settleMultiplePNLsIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode): Promise<TransactionInstruction>;
|
|
759
759
|
getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
760
760
|
setUserStatusToBeingLiquidated(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionSignature>;
|
|
@@ -2091,6 +2091,13 @@ class DriftClient {
|
|
|
2091
2091
|
? [depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.depositMarketIndex]
|
|
2092
2092
|
: undefined,
|
|
2093
2093
|
});
|
|
2094
|
+
if ((0, orderParams_1.isUpdateHighLeverageMode)(orderParams.bitFlags)) {
|
|
2095
|
+
remainingAccounts.push({
|
|
2096
|
+
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
2097
|
+
isWritable: true,
|
|
2098
|
+
isSigner: false,
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2094
2101
|
return await this.program.instruction.placePerpOrder(orderParams, {
|
|
2095
2102
|
accounts: {
|
|
2096
2103
|
state: await this.getStatePublicKey(),
|
|
@@ -3324,6 +3331,13 @@ class DriftClient {
|
|
|
3324
3331
|
});
|
|
3325
3332
|
}
|
|
3326
3333
|
}
|
|
3334
|
+
if ((0, orderParams_1.isUpdateHighLeverageMode)(orderParams.bitFlags)) {
|
|
3335
|
+
remainingAccounts.push({
|
|
3336
|
+
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
3337
|
+
isWritable: true,
|
|
3338
|
+
isSigner: false,
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3327
3341
|
let optionalParams = null;
|
|
3328
3342
|
if (auctionDurationPercentage || successCondition) {
|
|
3329
3343
|
optionalParams =
|
|
@@ -3418,17 +3432,24 @@ class DriftClient {
|
|
|
3418
3432
|
signMessage(message, keypair = this.wallet.payer) {
|
|
3419
3433
|
return Buffer.from(tweetnacl_1.default.sign.detached(message, keypair.secretKey));
|
|
3420
3434
|
}
|
|
3421
|
-
async placeSignedMsgTakerOrder(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideCustomIxIndex, txParams) {
|
|
3422
|
-
const ixs = await this.getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs, overrideCustomIxIndex);
|
|
3435
|
+
async placeSignedMsgTakerOrder(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideCustomIxIndex, includeHighLeverageModeConfig, txParams) {
|
|
3436
|
+
const ixs = await this.getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs, overrideCustomIxIndex, includeHighLeverageModeConfig);
|
|
3423
3437
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
|
|
3424
3438
|
return txSig;
|
|
3425
3439
|
}
|
|
3426
|
-
async getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideCustomIxIndex) {
|
|
3440
|
+
async getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideCustomIxIndex, includeHighLeverageModeConfig) {
|
|
3427
3441
|
const remainingAccounts = this.getRemainingAccounts({
|
|
3428
3442
|
userAccounts: [takerInfo.takerUserAccount],
|
|
3429
3443
|
useMarketLastSlotCache: false,
|
|
3430
3444
|
readablePerpMarketIndex: marketIndex,
|
|
3431
3445
|
});
|
|
3446
|
+
if (includeHighLeverageModeConfig) {
|
|
3447
|
+
remainingAccounts.push({
|
|
3448
|
+
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
3449
|
+
isWritable: true,
|
|
3450
|
+
isSigner: false,
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3432
3453
|
const messageLengthBuffer = Buffer.alloc(2);
|
|
3433
3454
|
messageLengthBuffer.writeUInt16LE(signedSignedMsgOrderParams.orderParams.length);
|
|
3434
3455
|
const signedMsgIxData = Buffer.concat([
|
|
@@ -3677,7 +3698,7 @@ class DriftClient {
|
|
|
3677
3698
|
* @param orderParams.auctionEndPrice:
|
|
3678
3699
|
* @param orderParams.reduceOnly:
|
|
3679
3700
|
* @param orderParams.postOnly:
|
|
3680
|
-
* @param orderParams.
|
|
3701
|
+
* @param orderParams.bitFlags:
|
|
3681
3702
|
* @param orderParams.policy:
|
|
3682
3703
|
* @param orderParams.maxTs:
|
|
3683
3704
|
* @returns
|
|
@@ -3686,7 +3707,7 @@ class DriftClient {
|
|
|
3686
3707
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getModifyOrderIx(orderParams, subAccountId), txParams), [], this.opts);
|
|
3687
3708
|
return txSig;
|
|
3688
3709
|
}
|
|
3689
|
-
async getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly,
|
|
3710
|
+
async getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, bitFlags, maxTs, policy, }, subAccountId) {
|
|
3690
3711
|
const user = await this.getUserAccountPublicKey(subAccountId);
|
|
3691
3712
|
const remainingAccounts = this.getRemainingAccounts({
|
|
3692
3713
|
userAccounts: [this.getUserAccount(subAccountId)],
|
|
@@ -3704,7 +3725,7 @@ class DriftClient {
|
|
|
3704
3725
|
auctionEndPrice: auctionEndPrice || null,
|
|
3705
3726
|
reduceOnly: reduceOnly != undefined ? reduceOnly : null,
|
|
3706
3727
|
postOnly: postOnly != undefined ? postOnly : null,
|
|
3707
|
-
|
|
3728
|
+
bitFlags: bitFlags != undefined ? bitFlags : null,
|
|
3708
3729
|
policy: policy || null,
|
|
3709
3730
|
maxTs: maxTs || null,
|
|
3710
3731
|
};
|
|
@@ -3731,7 +3752,7 @@ class DriftClient {
|
|
|
3731
3752
|
* @param orderParams.auctionEndPrice: Only required if order type changed to market from something else
|
|
3732
3753
|
* @param orderParams.reduceOnly:
|
|
3733
3754
|
* @param orderParams.postOnly:
|
|
3734
|
-
* @param orderParams.
|
|
3755
|
+
* @param orderParams.bitFlags:
|
|
3735
3756
|
* @param orderParams.policy:
|
|
3736
3757
|
* @param orderParams.maxTs:
|
|
3737
3758
|
* @returns
|
|
@@ -3740,7 +3761,7 @@ class DriftClient {
|
|
|
3740
3761
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getModifyOrderByUserIdIx(orderParams, subAccountId), txParams), [], this.opts);
|
|
3741
3762
|
return txSig;
|
|
3742
3763
|
}
|
|
3743
|
-
async getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly,
|
|
3764
|
+
async getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, bitFlags, maxTs, policy, }, subAccountId) {
|
|
3744
3765
|
const user = await this.getUserAccountPublicKey(subAccountId);
|
|
3745
3766
|
const remainingAccounts = this.getRemainingAccounts({
|
|
3746
3767
|
userAccounts: [this.getUserAccount(subAccountId)],
|
|
@@ -3758,7 +3779,7 @@ class DriftClient {
|
|
|
3758
3779
|
auctionEndPrice: auctionEndPrice || null,
|
|
3759
3780
|
reduceOnly: reduceOnly || false,
|
|
3760
3781
|
postOnly: postOnly || null,
|
|
3761
|
-
|
|
3782
|
+
bitFlags: bitFlags || null,
|
|
3762
3783
|
policy: policy || null,
|
|
3763
3784
|
maxTs: maxTs || null,
|
|
3764
3785
|
};
|
|
@@ -3832,7 +3853,7 @@ class DriftClient {
|
|
|
3832
3853
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.settleMultiplePNLsIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndexes, mode), txParams), [], this.opts);
|
|
3833
3854
|
return txSig;
|
|
3834
3855
|
}
|
|
3835
|
-
async settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey, settleeUserAccount, marketIndexes, mode, txParams) {
|
|
3856
|
+
async settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey, settleeUserAccount, marketIndexes, mode, txParams, optionalIxs) {
|
|
3836
3857
|
// need multiple TXs because settling more than 4 markets won't fit in a single TX
|
|
3837
3858
|
const txsToSign = [];
|
|
3838
3859
|
const marketIndexesInFourGroups = [];
|
|
@@ -3845,7 +3866,7 @@ class DriftClient {
|
|
|
3845
3866
|
const tx = await this.buildTransaction(ix, {
|
|
3846
3867
|
...txParams,
|
|
3847
3868
|
computeUnits,
|
|
3848
|
-
});
|
|
3869
|
+
}, undefined, undefined, undefined, undefined, optionalIxs);
|
|
3849
3870
|
txsToSign.push(tx);
|
|
3850
3871
|
}
|
|
3851
3872
|
const txsMap = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.118.0",
|
|
2
|
+
"version": "2.118.0-beta.1",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -9436,8 +9436,8 @@
|
|
|
9436
9436
|
}
|
|
9437
9437
|
},
|
|
9438
9438
|
{
|
|
9439
|
-
"name": "
|
|
9440
|
-
"type": "
|
|
9439
|
+
"name": "bitFlags",
|
|
9440
|
+
"type": "u8"
|
|
9441
9441
|
},
|
|
9442
9442
|
{
|
|
9443
9443
|
"name": "maxTs",
|
|
@@ -9636,7 +9636,7 @@
|
|
|
9636
9636
|
{
|
|
9637
9637
|
"name": "immediateOrCancel",
|
|
9638
9638
|
"type": {
|
|
9639
|
-
"option": "
|
|
9639
|
+
"option": "u8"
|
|
9640
9640
|
}
|
|
9641
9641
|
},
|
|
9642
9642
|
{
|
|
@@ -11714,6 +11714,20 @@
|
|
|
11714
11714
|
]
|
|
11715
11715
|
}
|
|
11716
11716
|
},
|
|
11717
|
+
{
|
|
11718
|
+
"name": "OrderParamsBitFlag",
|
|
11719
|
+
"type": {
|
|
11720
|
+
"kind": "enum",
|
|
11721
|
+
"variants": [
|
|
11722
|
+
{
|
|
11723
|
+
"name": "ImmediateOrCancel"
|
|
11724
|
+
},
|
|
11725
|
+
{
|
|
11726
|
+
"name": "UpdateHighLeverageMode"
|
|
11727
|
+
}
|
|
11728
|
+
]
|
|
11729
|
+
}
|
|
11730
|
+
},
|
|
11717
11731
|
{
|
|
11718
11732
|
"name": "PostOnlyParam",
|
|
11719
11733
|
"type": {
|
|
@@ -15078,6 +15092,11 @@
|
|
|
15078
15092
|
"code": 6313,
|
|
15079
15093
|
"name": "InvalidSignedMsgUserOrdersResize",
|
|
15080
15094
|
"msg": "Invalid SignedMsgUserOrders resize"
|
|
15095
|
+
},
|
|
15096
|
+
{
|
|
15097
|
+
"code": 6314,
|
|
15098
|
+
"name": "CouldNotDeserializeHighLeverageModeConfig",
|
|
15099
|
+
"msg": "Could not deserialize high leverage mode config"
|
|
15081
15100
|
}
|
|
15082
15101
|
],
|
|
15083
15102
|
"metadata": {
|
|
@@ -81,3 +81,5 @@ export declare function calculateWithdrawLimit(spotMarket: SpotMarketAccount, no
|
|
|
81
81
|
currentDepositAmount: any;
|
|
82
82
|
currentBorrowAmount: any;
|
|
83
83
|
};
|
|
84
|
+
export declare function getSpotAssetValue(tokenAmount: BN, strictOraclePrice: StrictOraclePrice, spotMarketAccount: SpotMarketAccount, maxMarginRatio: number, marginCategory?: MarginCategory): BN;
|
|
85
|
+
export declare function getSpotLiabilityValue(tokenAmount: BN, strictOraclePrice: StrictOraclePrice, spotMarketAccount: SpotMarketAccount, maxMarginRatio: number, marginCategory?: MarginCategory, liquidationBuffer?: BN): BN;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateWithdrawLimit = exports.calculateTokenUtilizationLimits = exports.calculateInterestAccumulated = exports.calculateBorrowRate = exports.calculateDepositRate = exports.calculateInterestRate = exports.calculateSpotMarketBorrowCapacity = exports.calculateUtilization = exports.calculateLiabilityWeight = exports.calculateScaledInitialAssetWeight = exports.calculateAssetWeight = exports.getTokenValue = exports.getStrictTokenValue = exports.getSignedTokenAmount = exports.getTokenAmount = exports.getBalance = void 0;
|
|
3
|
+
exports.getSpotLiabilityValue = exports.getSpotAssetValue = exports.calculateWithdrawLimit = exports.calculateTokenUtilizationLimits = exports.calculateInterestAccumulated = exports.calculateBorrowRate = exports.calculateDepositRate = exports.calculateInterestRate = exports.calculateSpotMarketBorrowCapacity = exports.calculateUtilization = exports.calculateLiabilityWeight = exports.calculateScaledInitialAssetWeight = exports.calculateAssetWeight = exports.getTokenValue = exports.getStrictTokenValue = exports.getSignedTokenAmount = exports.getTokenAmount = exports.getBalance = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
6
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
@@ -377,3 +377,35 @@ function calculateWithdrawLimit(spotMarket, now) {
|
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
exports.calculateWithdrawLimit = calculateWithdrawLimit;
|
|
380
|
+
function getSpotAssetValue(tokenAmount, strictOraclePrice, spotMarketAccount, maxMarginRatio, marginCategory) {
|
|
381
|
+
let assetValue = getStrictTokenValue(tokenAmount, spotMarketAccount.decimals, strictOraclePrice);
|
|
382
|
+
if (marginCategory !== undefined) {
|
|
383
|
+
let weight = calculateAssetWeight(tokenAmount, strictOraclePrice.current, spotMarketAccount, marginCategory);
|
|
384
|
+
if (marginCategory === 'Initial' &&
|
|
385
|
+
spotMarketAccount.marketIndex !== numericConstants_1.QUOTE_SPOT_MARKET_INDEX) {
|
|
386
|
+
const userCustomAssetWeight = anchor_1.BN.max(numericConstants_1.ZERO, numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION.subn(maxMarginRatio));
|
|
387
|
+
weight = anchor_1.BN.min(weight, userCustomAssetWeight);
|
|
388
|
+
}
|
|
389
|
+
assetValue = assetValue.mul(weight).div(numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION);
|
|
390
|
+
}
|
|
391
|
+
return assetValue;
|
|
392
|
+
}
|
|
393
|
+
exports.getSpotAssetValue = getSpotAssetValue;
|
|
394
|
+
function getSpotLiabilityValue(tokenAmount, strictOraclePrice, spotMarketAccount, maxMarginRatio, marginCategory, liquidationBuffer) {
|
|
395
|
+
let liabilityValue = getStrictTokenValue(tokenAmount, spotMarketAccount.decimals, strictOraclePrice);
|
|
396
|
+
if (marginCategory !== undefined) {
|
|
397
|
+
let weight = calculateLiabilityWeight(tokenAmount, spotMarketAccount, marginCategory);
|
|
398
|
+
if (marginCategory === 'Initial' &&
|
|
399
|
+
spotMarketAccount.marketIndex !== numericConstants_1.QUOTE_SPOT_MARKET_INDEX) {
|
|
400
|
+
weight = anchor_1.BN.max(weight, numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION.addn(maxMarginRatio));
|
|
401
|
+
}
|
|
402
|
+
if (liquidationBuffer !== undefined) {
|
|
403
|
+
weight = weight.add(liquidationBuffer);
|
|
404
|
+
}
|
|
405
|
+
liabilityValue = liabilityValue
|
|
406
|
+
.mul(weight)
|
|
407
|
+
.div(numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION);
|
|
408
|
+
}
|
|
409
|
+
return liabilityValue;
|
|
410
|
+
}
|
|
411
|
+
exports.getSpotLiabilityValue = getSpotLiabilityValue;
|
|
@@ -27,3 +27,4 @@ export declare function getMarketOrderParams(params: Omit<OptionalOrderParams, '
|
|
|
27
27
|
* @returns
|
|
28
28
|
*/
|
|
29
29
|
export declare function getOrderParams(optionalOrderParams: OptionalOrderParams, overridingParams?: Record<string, any>): OrderParams;
|
|
30
|
+
export declare function isUpdateHighLeverageMode(bitFlags: number): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrderParams = exports.getMarketOrderParams = exports.getTriggerLimitOrderParams = exports.getTriggerMarketOrderParams = exports.getLimitOrderParams = void 0;
|
|
3
|
+
exports.isUpdateHighLeverageMode = exports.getOrderParams = exports.getMarketOrderParams = exports.getTriggerLimitOrderParams = exports.getTriggerMarketOrderParams = exports.getLimitOrderParams = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
function getLimitOrderParams(params) {
|
|
6
6
|
return getOrderParams(Object.assign({}, params, {
|
|
@@ -42,3 +42,7 @@ function getOrderParams(optionalOrderParams, overridingParams = {}) {
|
|
|
42
42
|
return Object.assign({}, types_1.DefaultOrderParams, optionalOrderParams, overridingParams);
|
|
43
43
|
}
|
|
44
44
|
exports.getOrderParams = getOrderParams;
|
|
45
|
+
function isUpdateHighLeverageMode(bitFlags) {
|
|
46
|
+
return (bitFlags & types_1.OrderParamsBitFlag.UpdateHighLeverageMode) !== 0;
|
|
47
|
+
}
|
|
48
|
+
exports.isUpdateHighLeverageMode = isUpdateHighLeverageMode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, Commitment, ConfirmOptions, Connection, Signer, Transaction, TransactionInstruction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
1
|
+
import { AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, Commitment, ConfirmOptions, Connection, Signer, SimulatedTransactionResponse, Transaction, TransactionInstruction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
import { DriftClientMetricsEvents, IWallet, MappedRecord, SignedTxData, TxParams } from '../types';
|
|
3
3
|
export declare const COMPUTE_UNITS_DEFAULT = 200000;
|
|
4
4
|
export type TxBuildingProps = {
|
|
@@ -13,6 +13,7 @@ export type TxBuildingProps = {
|
|
|
13
13
|
recentBlockhash?: BlockhashWithExpiryBlockHeight;
|
|
14
14
|
wallet?: IWallet;
|
|
15
15
|
optionalIxs?: TransactionInstruction[];
|
|
16
|
+
simulatedTx?: SimulatedTransactionResponse;
|
|
16
17
|
};
|
|
17
18
|
export type TxHandlerConfig = {
|
|
18
19
|
blockhashCachingEnabled?: boolean;
|
|
@@ -152,4 +153,8 @@ export declare class TxHandler {
|
|
|
152
153
|
signedTxMap: MappedRecord<T, Transaction | VersionedTransaction>;
|
|
153
154
|
signedTxData: SignedTxData[];
|
|
154
155
|
}>;
|
|
156
|
+
simulateAndCalculateInstructions(txBuildingProps: TxBuildingProps, optionalInstructions?: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTables?: AddressLookupTableAccount[]): Promise<[
|
|
157
|
+
TransactionInstruction[],
|
|
158
|
+
SimulatedTransactionResponse | undefined
|
|
159
|
+
]>;
|
|
155
160
|
}
|
|
@@ -209,6 +209,7 @@ class TxHandler {
|
|
|
209
209
|
},
|
|
210
210
|
processParams: {
|
|
211
211
|
connection: this.connection,
|
|
212
|
+
simulatedTx: txBuildingProps.simulatedTx,
|
|
212
213
|
},
|
|
213
214
|
});
|
|
214
215
|
return processedTxParams;
|
|
@@ -292,9 +293,16 @@ class TxHandler {
|
|
|
292
293
|
? instructions
|
|
293
294
|
: [instructions];
|
|
294
295
|
let instructionsToUse;
|
|
295
|
-
|
|
296
|
+
let simulatedTx;
|
|
297
|
+
// add optional ixs if there's room and it doesn't fail simulation (usually oracle cranks)
|
|
296
298
|
if (props.optionalIxs && txVersion === 0) {
|
|
297
|
-
instructionsToUse
|
|
299
|
+
[instructionsToUse, simulatedTx] =
|
|
300
|
+
await this.simulateAndCalculateInstructions({
|
|
301
|
+
...props,
|
|
302
|
+
instructions: instructionsArray,
|
|
303
|
+
txVersion,
|
|
304
|
+
lookupTables,
|
|
305
|
+
}, props.optionalIxs, txVersion === 0, lookupTables);
|
|
298
306
|
}
|
|
299
307
|
else {
|
|
300
308
|
instructionsToUse = instructionsArray;
|
|
@@ -303,6 +311,7 @@ class TxHandler {
|
|
|
303
311
|
const processedTxParams = await this.getProcessedTransactionParams({
|
|
304
312
|
...props,
|
|
305
313
|
instructions: instructionsToUse,
|
|
314
|
+
simulatedTx: simulatedTx,
|
|
306
315
|
});
|
|
307
316
|
baseTxParams = {
|
|
308
317
|
...baseTxParams,
|
|
@@ -460,5 +469,37 @@ class TxHandler {
|
|
|
460
469
|
: this.getSignedTransactionMap(builtTxs, props.wallet));
|
|
461
470
|
return preppedTransactions;
|
|
462
471
|
}
|
|
472
|
+
async simulateAndCalculateInstructions(txBuildingProps, optionalInstructions = [], versionedTransaction = true, addressLookupTables = []) {
|
|
473
|
+
var _a;
|
|
474
|
+
const baseInstructions = Array.isArray(txBuildingProps.instructions)
|
|
475
|
+
? txBuildingProps.instructions
|
|
476
|
+
: [txBuildingProps.instructions];
|
|
477
|
+
if (optionalInstructions.length === 0) {
|
|
478
|
+
return [baseInstructions, undefined];
|
|
479
|
+
}
|
|
480
|
+
let allInstructions = [...optionalInstructions, ...baseInstructions];
|
|
481
|
+
let txSize = (0, utils_1.getSizeOfTransaction)(allInstructions, versionedTransaction, addressLookupTables);
|
|
482
|
+
while (txSize > utils_1.MAX_TX_BYTE_SIZE &&
|
|
483
|
+
allInstructions.length > baseInstructions.length) {
|
|
484
|
+
allInstructions = allInstructions.slice(1);
|
|
485
|
+
txSize = (0, utils_1.getSizeOfTransaction)(allInstructions, versionedTransaction, addressLookupTables);
|
|
486
|
+
}
|
|
487
|
+
const tx = await this.buildTransaction({
|
|
488
|
+
...txBuildingProps,
|
|
489
|
+
optionalIxs: undefined,
|
|
490
|
+
instructions: allInstructions,
|
|
491
|
+
});
|
|
492
|
+
const simulatedTx = await this.connection.simulateTransaction(tx);
|
|
493
|
+
if ((_a = simulatedTx.value) === null || _a === void 0 ? void 0 : _a.err) {
|
|
494
|
+
const tx = await this.buildTransaction({
|
|
495
|
+
...txBuildingProps,
|
|
496
|
+
optionalIxs: undefined,
|
|
497
|
+
instructions: baseInstructions,
|
|
498
|
+
});
|
|
499
|
+
const simulationWithoutOptionalIxs = await this.connection.simulateTransaction(tx);
|
|
500
|
+
return [baseInstructions, simulationWithoutOptionalIxs.value];
|
|
501
|
+
}
|
|
502
|
+
return [allInstructions, simulatedTx.value];
|
|
503
|
+
}
|
|
463
504
|
}
|
|
464
505
|
exports.TxHandler = TxHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection, VersionedTransaction } from '@solana/web3.js';
|
|
1
|
+
import { Connection, SimulatedTransactionResponse, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
import { BaseTxParams, ProcessingTxParams } from '..';
|
|
3
3
|
type TransactionBuildingProps = {
|
|
4
4
|
txParams: BaseTxParams;
|
|
@@ -9,7 +9,7 @@ type TransactionBuildingProps = {
|
|
|
9
9
|
export declare class TransactionParamProcessor {
|
|
10
10
|
private static getComputeUnitsFromSim;
|
|
11
11
|
static getTxSimComputeUnits(tx: VersionedTransaction, connection: Connection, bufferMultiplier: number, // Making this a mandatory param to force the user to remember that simulated CU's can be inaccurate and a buffer should be applied
|
|
12
|
-
lowerBoundCu?: number): Promise<{
|
|
12
|
+
lowerBoundCu?: number, simulatedTx?: SimulatedTransactionResponse): Promise<{
|
|
13
13
|
success: boolean;
|
|
14
14
|
computeUnits: number;
|
|
15
15
|
}>;
|
|
@@ -18,6 +18,7 @@ export declare class TransactionParamProcessor {
|
|
|
18
18
|
processConfig: ProcessingTxParams;
|
|
19
19
|
processParams: {
|
|
20
20
|
connection: Connection;
|
|
21
|
+
simulatedTx?: SimulatedTransactionResponse;
|
|
21
22
|
};
|
|
22
23
|
txBuilder: (baseTransactionProps: TransactionBuildingProps) => Promise<VersionedTransaction>;
|
|
23
24
|
}): Promise<BaseTxParams>;
|
|
@@ -16,16 +16,20 @@ class TransactionParamProcessor {
|
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
18
|
static async getTxSimComputeUnits(tx, connection, bufferMultiplier, // Making this a mandatory param to force the user to remember that simulated CU's can be inaccurate and a buffer should be applied
|
|
19
|
-
lowerBoundCu) {
|
|
20
|
-
var _a, _b
|
|
19
|
+
lowerBoundCu, simulatedTx) {
|
|
20
|
+
var _a, _b;
|
|
21
21
|
try {
|
|
22
22
|
if (TEST_SIMS_ALWAYS_FAIL)
|
|
23
23
|
throw new Error('Test Error::SIMS_ALWAYS_FAIL');
|
|
24
|
-
const simTxResult =
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const simTxResult = simulatedTx
|
|
25
|
+
? {
|
|
26
|
+
value: simulatedTx,
|
|
27
|
+
}
|
|
28
|
+
: await connection.simulateTransaction(tx, {
|
|
29
|
+
replaceRecentBlockhash: true, // This is important to ensure that the blockhash is not too new.. Otherwise we will very often receive a "blockHashNotFound" error
|
|
30
|
+
});
|
|
27
31
|
if ((_a = simTxResult === null || simTxResult === void 0 ? void 0 : simTxResult.value) === null || _a === void 0 ? void 0 : _a.err) {
|
|
28
|
-
throw
|
|
32
|
+
throw (_b = simTxResult === null || simTxResult === void 0 ? void 0 : simTxResult.value) === null || _b === void 0 ? void 0 : _b.err;
|
|
29
33
|
}
|
|
30
34
|
const computeUnits = await this.getComputeUnitsFromSim(simTxResult);
|
|
31
35
|
// Apply the buffer, but round down to the MAX_COMPUTE_UNITS, and round up to the nearest whole number
|
|
@@ -63,7 +67,7 @@ class TransactionParamProcessor {
|
|
|
63
67
|
const txToSim = await txBuilder({
|
|
64
68
|
txParams: { ...finalTxParams, computeUnits: MAX_COMPUTE_UNITS },
|
|
65
69
|
});
|
|
66
|
-
const txSimComputeUnitsResult = await this.getTxSimComputeUnits(txToSim, processProps.connection, (_a = processConfig === null || processConfig === void 0 ? void 0 : processConfig.computeUnitsBufferMultiplier) !== null && _a !== void 0 ? _a : COMPUTE_UNIT_BUFFER_FACTOR);
|
|
70
|
+
const txSimComputeUnitsResult = await this.getTxSimComputeUnits(txToSim, processProps.connection, (_a = processConfig === null || processConfig === void 0 ? void 0 : processConfig.computeUnitsBufferMultiplier) !== null && _a !== void 0 ? _a : COMPUTE_UNIT_BUFFER_FACTOR, undefined, processProps.simulatedTx);
|
|
67
71
|
if (txSimComputeUnitsResult.success) {
|
|
68
72
|
// Adjust the transaction based on the simulated compute units
|
|
69
73
|
finalTxParams.computeUnits = txSimComputeUnitsResult.computeUnits;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AddressLookupTableAccount, Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
export declare const MAX_TX_BYTE_SIZE = 1232;
|
|
2
3
|
export declare const isVersionedTransaction: (tx: Transaction | VersionedTransaction) => boolean;
|
|
3
4
|
export declare const getSizeOfTransaction: (instructions: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTables?: AddressLookupTableAccount[]) => number;
|
|
4
|
-
export declare const getCombinedInstructions: (baseInstructions: TransactionInstruction[], optionalInstructions?: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTables?: AddressLookupTableAccount[]) => TransactionInstruction[];
|
package/lib/browser/tx/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSizeOfTransaction = exports.isVersionedTransaction = exports.MAX_TX_BYTE_SIZE = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
|
|
5
|
+
exports.MAX_TX_BYTE_SIZE = 1232;
|
|
6
6
|
const isVersionedTransaction = (tx) => {
|
|
7
7
|
const version = tx === null || tx === void 0 ? void 0 : tx.version;
|
|
8
8
|
const isVersionedTx = tx instanceof web3_js_1.VersionedTransaction || version !== undefined;
|
|
@@ -63,20 +63,6 @@ const getSizeOfTransaction = (instructions, versionedTransaction = true, address
|
|
|
63
63
|
numberOfAddressLookups);
|
|
64
64
|
};
|
|
65
65
|
exports.getSizeOfTransaction = getSizeOfTransaction;
|
|
66
|
-
const getCombinedInstructions = (baseInstructions, optionalInstructions = [], versionedTransaction = true, addressLookupTables = []) => {
|
|
67
|
-
if (optionalInstructions.length === 0) {
|
|
68
|
-
return baseInstructions;
|
|
69
|
-
}
|
|
70
|
-
let allInstructions = [...optionalInstructions, ...baseInstructions];
|
|
71
|
-
let txSize = (0, exports.getSizeOfTransaction)(allInstructions, versionedTransaction, addressLookupTables);
|
|
72
|
-
while (txSize > MAX_SIZE &&
|
|
73
|
-
allInstructions.length > baseInstructions.length) {
|
|
74
|
-
allInstructions = allInstructions.slice(1);
|
|
75
|
-
txSize = (0, exports.getSizeOfTransaction)(allInstructions, versionedTransaction, addressLookupTables);
|
|
76
|
-
}
|
|
77
|
-
return allInstructions;
|
|
78
|
-
};
|
|
79
|
-
exports.getCombinedInstructions = getCombinedInstructions;
|
|
80
66
|
function getSizeOfCompressedU16(n) {
|
|
81
67
|
return 1 + Number(n >= 128) + Number(n >= 16384);
|
|
82
68
|
}
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -1172,7 +1172,7 @@ export type OrderParams = {
|
|
|
1172
1172
|
marketIndex: number;
|
|
1173
1173
|
reduceOnly: boolean;
|
|
1174
1174
|
postOnly: PostOnlyParams;
|
|
1175
|
-
|
|
1175
|
+
bitFlags: number;
|
|
1176
1176
|
triggerPrice: BN | null;
|
|
1177
1177
|
triggerCondition: OrderTriggerCondition;
|
|
1178
1178
|
oraclePriceOffset: number | null;
|
|
@@ -1195,6 +1195,10 @@ export declare class PostOnlyParams {
|
|
|
1195
1195
|
slide: {};
|
|
1196
1196
|
};
|
|
1197
1197
|
}
|
|
1198
|
+
export declare class OrderParamsBitFlag {
|
|
1199
|
+
static readonly ImmediateOrCancel = 1;
|
|
1200
|
+
static readonly UpdateHighLeverageMode = 2;
|
|
1201
|
+
}
|
|
1198
1202
|
export type NecessaryOrderParams = {
|
|
1199
1203
|
orderType: OrderType;
|
|
1200
1204
|
marketIndex: number;
|
package/lib/browser/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SwapReduceOnly = exports.PlaceAndTakeOrderSuccessCondition = exports.FuelOverflowStatus = exports.ReferrerStatus = exports.DefaultOrderParams = exports.ModifyOrderPolicy = exports.PostOnlyParams = exports.LiquidationType = exports.LPAction = exports.TradeSide = exports.getVariant = exports.isOneOfVariant = exports.isVariant = exports.SettlePnlMode = exports.StakeAction = exports.SpotFulfillmentConfigStatus = exports.SettlePnlExplanation = exports.DepositExplanation = exports.SpotFulfillmentStatus = exports.SpotFulfillmentType = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderBitFlag = exports.OrderStatus = exports.MarketType = exports.OrderType = exports.OracleSourceNum = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.SpotBalanceType = exports.SwapDirection = exports.AssetTier = exports.ContractTier = exports.ContractType = exports.MarginMode = exports.UserStatus = exports.InsuranceFundOperation = exports.SpotOperation = exports.PerpOperation = exports.MarketStatus = exports.ExchangeStatus = void 0;
|
|
3
|
+
exports.SwapReduceOnly = exports.PlaceAndTakeOrderSuccessCondition = exports.FuelOverflowStatus = exports.ReferrerStatus = exports.DefaultOrderParams = exports.ModifyOrderPolicy = exports.OrderParamsBitFlag = exports.PostOnlyParams = exports.LiquidationType = exports.LPAction = exports.TradeSide = exports.getVariant = exports.isOneOfVariant = exports.isVariant = exports.SettlePnlMode = exports.StakeAction = exports.SpotFulfillmentConfigStatus = exports.SettlePnlExplanation = exports.DepositExplanation = exports.SpotFulfillmentStatus = exports.SpotFulfillmentType = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderBitFlag = exports.OrderStatus = exports.MarketType = exports.OrderType = exports.OracleSourceNum = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.SpotBalanceType = exports.SwapDirection = exports.AssetTier = exports.ContractTier = exports.ContractType = exports.MarginMode = exports.UserStatus = exports.InsuranceFundOperation = exports.SpotOperation = exports.PerpOperation = exports.MarketStatus = exports.ExchangeStatus = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
// # Utility Types / Enums / Constants
|
|
6
6
|
var ExchangeStatus;
|
|
@@ -342,6 +342,11 @@ PostOnlyParams.NONE = { none: {} };
|
|
|
342
342
|
PostOnlyParams.MUST_POST_ONLY = { mustPostOnly: {} }; // Tx fails if order can't be post only
|
|
343
343
|
PostOnlyParams.TRY_POST_ONLY = { tryPostOnly: {} }; // Tx succeeds and order not placed if can't be post only
|
|
344
344
|
PostOnlyParams.SLIDE = { slide: {} }; // Modify price to be post only if can't be post only
|
|
345
|
+
class OrderParamsBitFlag {
|
|
346
|
+
}
|
|
347
|
+
exports.OrderParamsBitFlag = OrderParamsBitFlag;
|
|
348
|
+
OrderParamsBitFlag.ImmediateOrCancel = 1;
|
|
349
|
+
OrderParamsBitFlag.UpdateHighLeverageMode = 2;
|
|
345
350
|
var ModifyOrderPolicy;
|
|
346
351
|
(function (ModifyOrderPolicy) {
|
|
347
352
|
ModifyOrderPolicy[ModifyOrderPolicy["MustModify"] = 1] = "MustModify";
|
|
@@ -357,7 +362,7 @@ exports.DefaultOrderParams = {
|
|
|
357
362
|
marketIndex: 0,
|
|
358
363
|
reduceOnly: false,
|
|
359
364
|
postOnly: PostOnlyParams.NONE,
|
|
360
|
-
|
|
365
|
+
bitFlags: 0,
|
|
361
366
|
triggerPrice: null,
|
|
362
367
|
triggerCondition: OrderTriggerCondition.ABOVE,
|
|
363
368
|
oraclePriceOffset: null,
|