@drift-labs/sdk 2.86.0-beta.25 → 2.86.0-beta.26

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.
@@ -45,6 +45,7 @@ import {
45
45
  SettlePnlMode,
46
46
  SignedTxData,
47
47
  MappedRecord,
48
+ OpenbookV2FulfillmentConfigAccount,
48
49
  } from './types';
49
50
  import * as anchor from '@coral-xyz/anchor';
50
51
  import driftIDL from './idl/drift.json';
@@ -74,6 +75,7 @@ import {
74
75
  getDriftSignerPublicKey,
75
76
  getDriftStateAccountPublicKey,
76
77
  getInsuranceFundStakeAccountPublicKey,
78
+ getOpenbookV2FulfillmentConfigPublicKey,
77
79
  getPerpMarketPublicKey,
78
80
  getPhoenixFulfillmentConfigPublicKey,
79
81
  getPythPullOraclePublicKey,
@@ -575,6 +577,28 @@ export class DriftClient {
575
577
  ) as PhoenixV1FulfillmentConfigAccount[];
576
578
  }
577
579
 
580
+ public async getOpenbookV2FulfillmentConfig(
581
+ openbookMarket: PublicKey
582
+ ): Promise<OpenbookV2FulfillmentConfigAccount> {
583
+ const address = getOpenbookV2FulfillmentConfigPublicKey(
584
+ this.program.programId,
585
+ openbookMarket
586
+ );
587
+ return (await this.program.account.openbookV2FulfillmentConfig.fetch(
588
+ address
589
+ )) as OpenbookV2FulfillmentConfigAccount;
590
+ }
591
+
592
+ public async getOpenbookV2FulfillmentConfigs(): Promise<
593
+ OpenbookV2FulfillmentConfigAccount[]
594
+ > {
595
+ const accounts =
596
+ await this.program.account.openbookV2FulfillmentConfig.all();
597
+ return accounts.map(
598
+ (account) => account.account
599
+ ) as OpenbookV2FulfillmentConfigAccount[];
600
+ }
601
+
578
602
  public async fetchMarketLookupTableAccount(): Promise<AddressLookupTableAccount> {
579
603
  if (this.lookupTableAccount) return this.lookupTableAccount;
580
604
 
@@ -3635,7 +3659,8 @@ export class DriftClient {
3635
3659
  order?: Order,
3636
3660
  fulfillmentConfig?:
3637
3661
  | SerumV3FulfillmentConfigAccount
3638
- | PhoenixV1FulfillmentConfigAccount,
3662
+ | PhoenixV1FulfillmentConfigAccount
3663
+ | OpenbookV2FulfillmentConfigAccount,
3639
3664
  makerInfo?: MakerInfo | MakerInfo[],
3640
3665
  referrerInfo?: ReferrerInfo,
3641
3666
  txParams?: TxParams
@@ -3664,7 +3689,8 @@ export class DriftClient {
3664
3689
  order?: Order,
3665
3690
  fulfillmentConfig?:
3666
3691
  | SerumV3FulfillmentConfigAccount
3667
- | PhoenixV1FulfillmentConfigAccount,
3692
+ | PhoenixV1FulfillmentConfigAccount
3693
+ | OpenbookV2FulfillmentConfigAccount,
3668
3694
  makerInfo?: MakerInfo | MakerInfo[],
3669
3695
  referrerInfo?: ReferrerInfo,
3670
3696
  fillerPublicKey?: PublicKey
@@ -3743,6 +3769,7 @@ export class DriftClient {
3743
3769
  fulfillmentConfig?:
3744
3770
  | SerumV3FulfillmentConfigAccount
3745
3771
  | PhoenixV1FulfillmentConfigAccount
3772
+ | OpenbookV2FulfillmentConfigAccount
3746
3773
  ): void {
3747
3774
  if (fulfillmentConfig) {
3748
3775
  if ('serumProgramId' in fulfillmentConfig) {
@@ -3757,6 +3784,12 @@ export class DriftClient {
3757
3784
  remainingAccounts,
3758
3785
  fulfillmentConfig
3759
3786
  );
3787
+ } else if ('openbookV2ProgramId' in fulfillmentConfig) {
3788
+ this.addOpenbookRemainingAccounts(
3789
+ marketIndex,
3790
+ remainingAccounts,
3791
+ fulfillmentConfig
3792
+ );
3760
3793
  } else {
3761
3794
  throw Error('Invalid fulfillment config type');
3762
3795
  }
@@ -3922,6 +3955,103 @@ export class DriftClient {
3922
3955
  });
3923
3956
  }
3924
3957
 
3958
+ addOpenbookRemainingAccounts(
3959
+ marketIndex: number,
3960
+ remainingAccounts: AccountMeta[],
3961
+ fulfillmentConfig: OpenbookV2FulfillmentConfigAccount
3962
+ ): void {
3963
+ remainingAccounts.push({
3964
+ pubkey: fulfillmentConfig.pubkey,
3965
+ isWritable: false,
3966
+ isSigner: false,
3967
+ });
3968
+ remainingAccounts.push({
3969
+ pubkey: this.getSignerPublicKey(),
3970
+ isWritable: true,
3971
+ isSigner: false,
3972
+ });
3973
+ remainingAccounts.push({
3974
+ pubkey: fulfillmentConfig.openbookV2ProgramId,
3975
+ isWritable: false,
3976
+ isSigner: false,
3977
+ });
3978
+ remainingAccounts.push({
3979
+ pubkey: fulfillmentConfig.openbookV2Market,
3980
+ isWritable: true,
3981
+ isSigner: false,
3982
+ });
3983
+ remainingAccounts.push({
3984
+ pubkey: fulfillmentConfig.openbookV2MarketAuthority,
3985
+ isWritable: false,
3986
+ isSigner: false,
3987
+ });
3988
+ remainingAccounts.push({
3989
+ pubkey: fulfillmentConfig.openbookV2EventHeap,
3990
+ isWritable: true,
3991
+ isSigner: false,
3992
+ });
3993
+ remainingAccounts.push({
3994
+ pubkey: fulfillmentConfig.openbookV2Bids,
3995
+ isWritable: true,
3996
+ isSigner: false,
3997
+ });
3998
+ remainingAccounts.push({
3999
+ pubkey: fulfillmentConfig.openbookV2Asks,
4000
+ isWritable: true,
4001
+ isSigner: false,
4002
+ });
4003
+ remainingAccounts.push({
4004
+ pubkey: fulfillmentConfig.openbookV2BaseVault,
4005
+ isWritable: true,
4006
+ isSigner: false,
4007
+ });
4008
+ remainingAccounts.push({
4009
+ pubkey: fulfillmentConfig.openbookV2QuoteVault,
4010
+ isWritable: true,
4011
+ isSigner: false,
4012
+ });
4013
+ remainingAccounts.push({
4014
+ pubkey: this.getSpotMarketAccount(marketIndex).vault,
4015
+ isWritable: true,
4016
+ isSigner: false,
4017
+ });
4018
+ remainingAccounts.push({
4019
+ pubkey: this.getQuoteSpotMarketAccount().vault,
4020
+ isWritable: true,
4021
+ isSigner: false,
4022
+ });
4023
+ remainingAccounts.push({
4024
+ pubkey: TOKEN_PROGRAM_ID,
4025
+ isWritable: false,
4026
+ isSigner: false,
4027
+ });
4028
+ remainingAccounts.push({
4029
+ pubkey: SystemProgram.programId,
4030
+ isWritable: false,
4031
+ isSigner: false,
4032
+ });
4033
+ remainingAccounts.push({
4034
+ pubkey: this.getSpotMarketAccount(marketIndex).pubkey,
4035
+ isWritable: true,
4036
+ isSigner: false,
4037
+ });
4038
+ remainingAccounts.push({
4039
+ pubkey: this.getQuoteSpotMarketAccount().pubkey,
4040
+ isWritable: true,
4041
+ isSigner: false,
4042
+ });
4043
+
4044
+ if (fulfillmentConfig.remainingAccounts) {
4045
+ for (const remainingAccount of fulfillmentConfig.remainingAccounts) {
4046
+ remainingAccounts.push({
4047
+ pubkey: remainingAccount,
4048
+ isWritable: true,
4049
+ isSigner: false,
4050
+ });
4051
+ }
4052
+ }
4053
+ }
4054
+
3925
4055
  /**
3926
4056
  * Swap tokens in drift account using jupiter
3927
4057
  * @param jupiterClient jupiter client to find routes and jupiter instructions
@@ -3017,6 +3017,95 @@
3017
3017
  }
3018
3018
  ]
3019
3019
  },
3020
+ {
3021
+ "name": "initializeOpenbookV2FulfillmentConfig",
3022
+ "accounts": [
3023
+ {
3024
+ "name": "baseSpotMarket",
3025
+ "isMut": false,
3026
+ "isSigner": false
3027
+ },
3028
+ {
3029
+ "name": "quoteSpotMarket",
3030
+ "isMut": false,
3031
+ "isSigner": false
3032
+ },
3033
+ {
3034
+ "name": "state",
3035
+ "isMut": true,
3036
+ "isSigner": false
3037
+ },
3038
+ {
3039
+ "name": "openbookV2Program",
3040
+ "isMut": false,
3041
+ "isSigner": false
3042
+ },
3043
+ {
3044
+ "name": "openbookV2Market",
3045
+ "isMut": false,
3046
+ "isSigner": false
3047
+ },
3048
+ {
3049
+ "name": "driftSigner",
3050
+ "isMut": false,
3051
+ "isSigner": false
3052
+ },
3053
+ {
3054
+ "name": "openbookV2FulfillmentConfig",
3055
+ "isMut": true,
3056
+ "isSigner": false
3057
+ },
3058
+ {
3059
+ "name": "admin",
3060
+ "isMut": true,
3061
+ "isSigner": true
3062
+ },
3063
+ {
3064
+ "name": "rent",
3065
+ "isMut": false,
3066
+ "isSigner": false
3067
+ },
3068
+ {
3069
+ "name": "systemProgram",
3070
+ "isMut": false,
3071
+ "isSigner": false
3072
+ }
3073
+ ],
3074
+ "args": [
3075
+ {
3076
+ "name": "marketIndex",
3077
+ "type": "u16"
3078
+ }
3079
+ ]
3080
+ },
3081
+ {
3082
+ "name": "openbookV2FulfillmentConfigStatus",
3083
+ "accounts": [
3084
+ {
3085
+ "name": "state",
3086
+ "isMut": false,
3087
+ "isSigner": false
3088
+ },
3089
+ {
3090
+ "name": "openbookV2FulfillmentConfig",
3091
+ "isMut": true,
3092
+ "isSigner": false
3093
+ },
3094
+ {
3095
+ "name": "admin",
3096
+ "isMut": true,
3097
+ "isSigner": true
3098
+ }
3099
+ ],
3100
+ "args": [
3101
+ {
3102
+ "name": "status",
3103
+ "type": {
3104
+ "defined": "SpotFulfillmentConfigStatus"
3105
+ }
3106
+ }
3107
+ ]
3108
+ },
3020
3109
  {
3021
3110
  "name": "initializePhoenixFulfillmentConfig",
3022
3111
  "accounts": [
@@ -5631,6 +5720,75 @@
5631
5720
  }
5632
5721
  ],
5633
5722
  "accounts": [
5723
+ {
5724
+ "name": "OpenbookV2FulfillmentConfig",
5725
+ "type": {
5726
+ "kind": "struct",
5727
+ "fields": [
5728
+ {
5729
+ "name": "pubkey",
5730
+ "type": "publicKey"
5731
+ },
5732
+ {
5733
+ "name": "openbookV2ProgramId",
5734
+ "type": "publicKey"
5735
+ },
5736
+ {
5737
+ "name": "openbookV2Market",
5738
+ "type": "publicKey"
5739
+ },
5740
+ {
5741
+ "name": "openbookV2MarketAuthority",
5742
+ "type": "publicKey"
5743
+ },
5744
+ {
5745
+ "name": "openbookV2EventHeap",
5746
+ "type": "publicKey"
5747
+ },
5748
+ {
5749
+ "name": "openbookV2Bids",
5750
+ "type": "publicKey"
5751
+ },
5752
+ {
5753
+ "name": "openbookV2Asks",
5754
+ "type": "publicKey"
5755
+ },
5756
+ {
5757
+ "name": "openbookV2BaseVault",
5758
+ "type": "publicKey"
5759
+ },
5760
+ {
5761
+ "name": "openbookV2QuoteVault",
5762
+ "type": "publicKey"
5763
+ },
5764
+ {
5765
+ "name": "marketIndex",
5766
+ "type": "u16"
5767
+ },
5768
+ {
5769
+ "name": "fulfillmentType",
5770
+ "type": {
5771
+ "defined": "SpotFulfillmentType"
5772
+ }
5773
+ },
5774
+ {
5775
+ "name": "status",
5776
+ "type": {
5777
+ "defined": "SpotFulfillmentConfigStatus"
5778
+ }
5779
+ },
5780
+ {
5781
+ "name": "padding",
5782
+ "type": {
5783
+ "array": [
5784
+ "u8",
5785
+ 4
5786
+ ]
5787
+ }
5788
+ }
5789
+ ]
5790
+ }
5791
+ },
5634
5792
  {
5635
5793
  "name": "PhoenixV1FulfillmentConfig",
5636
5794
  "type": {
@@ -9269,6 +9427,9 @@
9269
9427
  },
9270
9428
  {
9271
9429
  "name": "PhoenixV1"
9430
+ },
9431
+ {
9432
+ "name": "OpenbookV2"
9272
9433
  }
9273
9434
  ]
9274
9435
  }
@@ -9540,6 +9701,9 @@
9540
9701
  },
9541
9702
  {
9542
9703
  "name": "DeriskLp"
9704
+ },
9705
+ {
9706
+ "name": "OrderFilledWithOpenbookV2"
9543
9707
  }
9544
9708
  ]
9545
9709
  }
@@ -12553,6 +12717,21 @@
12553
12717
  "code": 6278,
12554
12718
  "name": "OracleBadRemainingAccountPublicKey",
12555
12719
  "msg": "Remaining account passed is not a valid pda"
12720
+ },
12721
+ {
12722
+ "code": 6279,
12723
+ "name": "FailedOpenbookV2CPI",
12724
+ "msg": "FailedOpenbookV2CPI"
12725
+ },
12726
+ {
12727
+ "code": 6280,
12728
+ "name": "InvalidOpenbookV2Program",
12729
+ "msg": "InvalidOpenbookV2Program"
12730
+ },
12731
+ {
12732
+ "code": 6281,
12733
+ "name": "InvalidOpenbookV2Market",
12734
+ "msg": "InvalidOpenbookV2Market"
12556
12735
  }
12557
12736
  ],
12558
12737
  "metadata": {