@drift-labs/sdk 2.87.0-beta.4 → 2.87.0-beta.6

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.
@@ -119,6 +119,7 @@ import { isSpotPositionAvailable } from './math/spotPosition';
119
119
  import { calculateMarketMaxAvailableInsurance } from './math/market';
120
120
  import { fetchUserStatsAccount } from './accounts/fetch';
121
121
  import { castNumberToSpotPrecision } from './math/spotMarket';
122
+ import { getTokenProgramForSpotMarket } from './addresses/pda';
122
123
  import {
123
124
  JupiterClient,
124
125
  QuoteResponse,
@@ -148,7 +149,7 @@ import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/py
148
149
  import { getFeedIdUint8Array, trimFeedId } from './util/pythPullOracleUtils';
149
150
  import { isVersionedTransaction } from './tx/utils';
150
151
  import pythSolanaReceiverIdl from './idl/pyth_solana_receiver.json';
151
- import { PullFeed } from '@switchboard-xyz/on-demand';
152
+ import { asV0Tx, PullFeed } from '@switchboard-xyz/on-demand';
152
153
  import switchboardOnDemandIdl from './idl/switchboard_on_demand_30.json';
153
154
 
154
155
  type RemainingAccountParams = {
@@ -1829,7 +1830,8 @@ export class DriftClient {
1829
1830
  account: PublicKey,
1830
1831
  payer: PublicKey,
1831
1832
  owner: PublicKey,
1832
- mint: PublicKey
1833
+ mint: PublicKey,
1834
+ tokenProgram = TOKEN_PROGRAM_ID
1833
1835
  ): TransactionInstruction {
1834
1836
  return new TransactionInstruction({
1835
1837
  keys: [
@@ -1842,7 +1844,7 @@ export class DriftClient {
1842
1844
  isSigner: false,
1843
1845
  isWritable: false,
1844
1846
  },
1845
- { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
1847
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
1846
1848
  ],
1847
1849
  programId: ASSOCIATED_TOKEN_PROGRAM_ID,
1848
1850
  data: Buffer.from([0x1]),
@@ -1856,7 +1858,7 @@ export class DriftClient {
1856
1858
  subAccountId?: number,
1857
1859
  reduceOnly = false,
1858
1860
  txParams?: TxParams
1859
- ): Promise<ReturnType<typeof this.buildTransaction>> {
1861
+ ): Promise<VersionedTransaction | Transaction> {
1860
1862
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
1861
1863
 
1862
1864
  const isSolMarket = spotMarketAccount.mint.equals(WRAPPED_SOL_MINT);
@@ -1970,6 +1972,8 @@ export class DriftClient {
1970
1972
 
1971
1973
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
1972
1974
 
1975
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
1976
+ const tokenProgram = getTokenProgramForSpotMarket(spotMarketAccount);
1973
1977
  return await this.program.instruction.deposit(
1974
1978
  marketIndex,
1975
1979
  amount,
@@ -1983,7 +1987,7 @@ export class DriftClient {
1983
1987
  userStats: this.getUserStatsAccountPublicKey(),
1984
1988
  userTokenAccount: userTokenAccount,
1985
1989
  authority: this.wallet.publicKey,
1986
- tokenProgram: TOKEN_PROGRAM_ID,
1990
+ tokenProgram,
1987
1991
  },
1988
1992
  remainingAccounts,
1989
1993
  }
@@ -2056,6 +2060,19 @@ export class DriftClient {
2056
2060
  return result;
2057
2061
  }
2058
2062
 
2063
+ public addTokenMintToRemainingAccounts(
2064
+ spotMarketAccount: SpotMarketAccount,
2065
+ remainingAccounts: AccountMeta[]
2066
+ ) {
2067
+ if (spotMarketAccount.tokenProgram === 1) {
2068
+ remainingAccounts.push({
2069
+ pubkey: spotMarketAccount.mint,
2070
+ isSigner: false,
2071
+ isWritable: false,
2072
+ });
2073
+ }
2074
+ }
2075
+
2059
2076
  public getAssociatedTokenAccountCreationIx(
2060
2077
  tokenMintAddress: PublicKey,
2061
2078
  associatedTokenAddress: PublicKey
@@ -2468,6 +2485,9 @@ export class DriftClient {
2468
2485
 
2469
2486
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
2470
2487
 
2488
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
2489
+ const tokenProgram = getTokenProgramForSpotMarket(spotMarketAccount);
2490
+
2471
2491
  return await this.program.instruction.withdraw(
2472
2492
  marketIndex,
2473
2493
  amount,
@@ -2482,7 +2502,7 @@ export class DriftClient {
2482
2502
  userStats: this.getUserStatsAccountPublicKey(),
2483
2503
  userTokenAccount: userTokenAccount,
2484
2504
  authority: this.wallet.publicKey,
2485
- tokenProgram: TOKEN_PROGRAM_ID,
2505
+ tokenProgram,
2486
2506
  },
2487
2507
  remainingAccounts,
2488
2508
  }
@@ -4230,12 +4250,15 @@ export class DriftClient {
4230
4250
  outAssociatedTokenAccount
4231
4251
  );
4232
4252
  if (!accountInfo) {
4253
+ const tokenProgram = getTokenProgramForSpotMarket(outMarket);
4254
+
4233
4255
  preInstructions.push(
4234
4256
  this.createAssociatedTokenAccountIdempotentInstruction(
4235
4257
  outAssociatedTokenAccount,
4236
4258
  this.provider.wallet.publicKey,
4237
4259
  this.provider.wallet.publicKey,
4238
- outMarket.mint
4260
+ outMarket.mint,
4261
+ tokenProgram
4239
4262
  )
4240
4263
  );
4241
4264
  }
@@ -4251,12 +4274,15 @@ export class DriftClient {
4251
4274
  inAssociatedTokenAccount
4252
4275
  );
4253
4276
  if (!accountInfo) {
4277
+ const tokenProgram = getTokenProgramForSpotMarket(outMarket);
4278
+
4254
4279
  preInstructions.push(
4255
4280
  this.createAssociatedTokenAccountIdempotentInstruction(
4256
4281
  inAssociatedTokenAccount,
4257
4282
  this.provider.wallet.publicKey,
4258
4283
  this.provider.wallet.publicKey,
4259
- inMarket.mint
4284
+ inMarket.mint,
4285
+ tokenProgram
4260
4286
  )
4261
4287
  );
4262
4288
  }
@@ -4471,6 +4497,30 @@ export class DriftClient {
4471
4497
  const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
4472
4498
  const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
4473
4499
 
4500
+ const outTokenProgram = getTokenProgramForSpotMarket(outSpotMarket);
4501
+ const inTokenProgram = getTokenProgramForSpotMarket(inSpotMarket);
4502
+
4503
+ if (!outTokenProgram.equals(inTokenProgram)) {
4504
+ remainingAccounts.push({
4505
+ pubkey: outTokenProgram,
4506
+ isWritable: false,
4507
+ isSigner: false,
4508
+ });
4509
+ }
4510
+
4511
+ if (outSpotMarket.tokenProgram === 1 || inSpotMarket.tokenProgram === 1) {
4512
+ remainingAccounts.push({
4513
+ pubkey: inSpotMarket.mint,
4514
+ isWritable: false,
4515
+ isSigner: false,
4516
+ });
4517
+ remainingAccounts.push({
4518
+ pubkey: outSpotMarket.mint,
4519
+ isWritable: false,
4520
+ isSigner: false,
4521
+ });
4522
+ }
4523
+
4474
4524
  const beginSwapIx = await this.program.instruction.beginSwap(
4475
4525
  inMarketIndex,
4476
4526
  outMarketIndex,
@@ -4485,7 +4535,7 @@ export class DriftClient {
4485
4535
  inSpotMarketVault: inSpotMarket.vault,
4486
4536
  inTokenAccount,
4487
4537
  outTokenAccount,
4488
- tokenProgram: TOKEN_PROGRAM_ID,
4538
+ tokenProgram: inTokenProgram,
4489
4539
  driftSigner: this.getStateAccount().signer,
4490
4540
  instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
4491
4541
  },
@@ -4508,7 +4558,7 @@ export class DriftClient {
4508
4558
  inSpotMarketVault: inSpotMarket.vault,
4509
4559
  inTokenAccount,
4510
4560
  outTokenAccount,
4511
- tokenProgram: TOKEN_PROGRAM_ID,
4561
+ tokenProgram: inTokenProgram,
4512
4562
  driftSigner: this.getStateAccount().signer,
4513
4563
  instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
4514
4564
  },
@@ -6279,6 +6329,8 @@ export class DriftClient {
6279
6329
 
6280
6330
  const spotMarket = this.getSpotMarketAccount(marketIndex);
6281
6331
 
6332
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
6333
+
6282
6334
  return await this.program.instruction.resolveSpotBankruptcy(marketIndex, {
6283
6335
  accounts: {
6284
6336
  state: await this.getStatePublicKey(),
@@ -6513,8 +6565,7 @@ export class DriftClient {
6513
6565
  public async getAddInsuranceFundStakeIx(
6514
6566
  marketIndex: number,
6515
6567
  amount: BN,
6516
- collateralAccountPublicKey: PublicKey,
6517
- fromSubAccount?: boolean
6568
+ collateralAccountPublicKey: PublicKey
6518
6569
  ): Promise<TransactionInstruction> {
6519
6570
  const spotMarket = this.getSpotMarketAccount(marketIndex);
6520
6571
  const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
@@ -6523,12 +6574,9 @@ export class DriftClient {
6523
6574
  marketIndex
6524
6575
  );
6525
6576
 
6526
- const remainingAccounts = this.getRemainingAccounts({
6527
- userAccounts: fromSubAccount ? [this.getUserAccount()] : [],
6528
- useMarketLastSlotCache: fromSubAccount ? true : false,
6529
- writableSpotMarketIndexes: [marketIndex],
6530
- });
6531
-
6577
+ const remainingAccounts = [];
6578
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
6579
+ const tokenProgram = getTokenProgramForSpotMarket(spotMarket);
6532
6580
  const ix = this.program.instruction.addInsuranceFundStake(
6533
6581
  marketIndex,
6534
6582
  amount,
@@ -6543,7 +6591,7 @@ export class DriftClient {
6543
6591
  insuranceFundVault: spotMarket.insuranceFund.vault,
6544
6592
  driftSigner: this.getSignerPublicKey(),
6545
6593
  userTokenAccount: collateralAccountPublicKey,
6546
- tokenProgram: TOKEN_PROGRAM_ID,
6594
+ tokenProgram,
6547
6595
  },
6548
6596
  remainingAccounts,
6549
6597
  }
@@ -6630,8 +6678,7 @@ export class DriftClient {
6630
6678
  const addFundsIx = await this.getAddInsuranceFundStakeIx(
6631
6679
  marketIndex,
6632
6680
  amount,
6633
- tokenAccount,
6634
- fromSubaccount
6681
+ tokenAccount
6635
6682
  );
6636
6683
 
6637
6684
  addIfStakeIxs.push(addFundsIx);
@@ -6670,11 +6717,6 @@ export class DriftClient {
6670
6717
  marketIndex
6671
6718
  );
6672
6719
 
6673
- const remainingAccounts = this.getRemainingAccounts({
6674
- userAccounts: [],
6675
- writableSpotMarketIndexes: [marketIndex],
6676
- });
6677
-
6678
6720
  const ix = await this.program.instruction.requestRemoveInsuranceFundStake(
6679
6721
  marketIndex,
6680
6722
  amount,
@@ -6687,7 +6729,6 @@ export class DriftClient {
6687
6729
  authority: this.wallet.publicKey,
6688
6730
  insuranceFundVault: spotMarketAccount.insuranceFund.vault,
6689
6731
  },
6690
- remainingAccounts,
6691
6732
  }
6692
6733
  );
6693
6734
 
@@ -6708,12 +6749,6 @@ export class DriftClient {
6708
6749
  marketIndex
6709
6750
  );
6710
6751
 
6711
- const remainingAccounts = this.getRemainingAccounts({
6712
- userAccounts: [this.getUserAccount()],
6713
- useMarketLastSlotCache: true,
6714
- writableSpotMarketIndexes: [marketIndex],
6715
- });
6716
-
6717
6752
  const ix =
6718
6753
  await this.program.instruction.cancelRequestRemoveInsuranceFundStake(
6719
6754
  marketIndex,
@@ -6726,7 +6761,6 @@ export class DriftClient {
6726
6761
  authority: this.wallet.publicKey,
6727
6762
  insuranceFundVault: spotMarketAccount.insuranceFund.vault,
6728
6763
  },
6729
- remainingAccounts,
6730
6764
  }
6731
6765
  );
6732
6766
 
@@ -6780,11 +6814,9 @@ export class DriftClient {
6780
6814
  }
6781
6815
  }
6782
6816
 
6783
- const remainingAccounts = this.getRemainingAccounts({
6784
- userAccounts: [],
6785
- writableSpotMarketIndexes: [marketIndex],
6786
- });
6787
-
6817
+ const remainingAccounts = [];
6818
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
6819
+ const tokenProgram = getTokenProgramForSpotMarket(spotMarketAccount);
6788
6820
  const removeStakeIx =
6789
6821
  await this.program.instruction.removeInsuranceFundStake(marketIndex, {
6790
6822
  accounts: {
@@ -6796,7 +6828,7 @@ export class DriftClient {
6796
6828
  insuranceFundVault: spotMarketAccount.insuranceFund.vault,
6797
6829
  driftSigner: this.getSignerPublicKey(),
6798
6830
  userTokenAccount: tokenAccount,
6799
- tokenProgram: TOKEN_PROGRAM_ID,
6831
+ tokenProgram,
6800
6832
  },
6801
6833
  remainingAccounts,
6802
6834
  });
@@ -6827,14 +6859,10 @@ export class DriftClient {
6827
6859
 
6828
6860
  public async settleRevenueToInsuranceFund(
6829
6861
  spotMarketIndex: number,
6830
- subAccountId?: number,
6831
6862
  txParams?: TxParams
6832
6863
  ): Promise<TransactionSignature> {
6833
6864
  const tx = await this.buildTransaction(
6834
- await this.getSettleRevenueToInsuranceFundIx(
6835
- spotMarketIndex,
6836
- subAccountId
6837
- ),
6865
+ await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex),
6838
6866
  txParams
6839
6867
  );
6840
6868
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
@@ -6842,15 +6870,11 @@ export class DriftClient {
6842
6870
  }
6843
6871
 
6844
6872
  public async getSettleRevenueToInsuranceFundIx(
6845
- spotMarketIndex: number,
6846
- subAccountId?: number
6873
+ spotMarketIndex: number
6847
6874
  ): Promise<TransactionInstruction> {
6848
6875
  const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
6849
- const remainingAccounts = this.getRemainingAccounts({
6850
- userAccounts: [this.getUserAccount(subAccountId)],
6851
- useMarketLastSlotCache: true,
6852
- writableSpotMarketIndexes: [spotMarketIndex],
6853
- });
6876
+ const remainingAccounts = [];
6877
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
6854
6878
  const ix = await this.program.instruction.settleRevenueToInsuranceFund(
6855
6879
  spotMarketIndex,
6856
6880
  {
@@ -6920,6 +6944,10 @@ export class DriftClient {
6920
6944
  userTokenAccountPublicKey: PublicKey
6921
6945
  ): Promise<TransactionInstruction> {
6922
6946
  const spotMarket = await this.getSpotMarketAccount(marketIndex);
6947
+
6948
+ const remainingAccounts = [];
6949
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
6950
+ const tokenProgram = getTokenProgramForSpotMarket(spotMarket);
6923
6951
  const ix = await this.program.instruction.depositIntoSpotMarketRevenuePool(
6924
6952
  amount,
6925
6953
  {
@@ -6929,7 +6957,7 @@ export class DriftClient {
6929
6957
  authority: this.wallet.publicKey,
6930
6958
  spotMarketVault: spotMarket.vault,
6931
6959
  userTokenAccount: userTokenAccountPublicKey,
6932
- tokenProgram: TOKEN_PROGRAM_ID,
6960
+ tokenProgram,
6933
6961
  },
6934
6962
  }
6935
6963
  );
@@ -7320,10 +7348,18 @@ export class DriftClient {
7320
7348
  if (!pullIx) {
7321
7349
  return undefined;
7322
7350
  }
7323
- const tx = await this.buildTransaction(pullIx, undefined, 0, [
7324
- await this.fetchMarketLookupTableAccount(),
7325
- ]);
7326
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
7351
+ const tx = await asV0Tx({
7352
+ connection: this.connection,
7353
+ ixs: [pullIx],
7354
+ payer: this.wallet.publicKey,
7355
+ computeUnitLimitMultiple: 1.3,
7356
+ lookupTables: [await this.fetchMarketLookupTableAccount()],
7357
+ });
7358
+ const { txSig } = await this.sendTransaction(tx, [], {
7359
+ commitment: 'processed',
7360
+ skipPreflight: true,
7361
+ maxRetries: 0,
7362
+ });
7327
7363
  return txSig;
7328
7364
  }
7329
7365
 
@@ -2341,7 +2341,7 @@
2341
2341
  },
2342
2342
  {
2343
2343
  "name": "spotMarket",
2344
- "isMut": false,
2344
+ "isMut": true,
2345
2345
  "isSigner": false
2346
2346
  },
2347
2347
  {
@@ -2401,7 +2401,7 @@
2401
2401
  "accounts": [
2402
2402
  {
2403
2403
  "name": "spotMarket",
2404
- "isMut": false,
2404
+ "isMut": true,
2405
2405
  "isSigner": false
2406
2406
  },
2407
2407
  {
@@ -2441,7 +2441,7 @@
2441
2441
  "accounts": [
2442
2442
  {
2443
2443
  "name": "spotMarket",
2444
- "isMut": false,
2444
+ "isMut": true,
2445
2445
  "isSigner": false
2446
2446
  },
2447
2447
  {
@@ -2482,7 +2482,7 @@
2482
2482
  },
2483
2483
  {
2484
2484
  "name": "spotMarket",
2485
- "isMut": false,
2485
+ "isMut": true,
2486
2486
  "isSigner": false
2487
2487
  },
2488
2488
  {
@@ -3362,6 +3362,27 @@
3362
3362
  }
3363
3363
  ]
3364
3364
  },
3365
+ {
3366
+ "name": "initializePredictionMarket",
3367
+ "accounts": [
3368
+ {
3369
+ "name": "admin",
3370
+ "isMut": false,
3371
+ "isSigner": true
3372
+ },
3373
+ {
3374
+ "name": "state",
3375
+ "isMut": false,
3376
+ "isSigner": false
3377
+ },
3378
+ {
3379
+ "name": "perpMarket",
3380
+ "isMut": true,
3381
+ "isSigner": false
3382
+ }
3383
+ ],
3384
+ "args": []
3385
+ },
3365
3386
  {
3366
3387
  "name": "deleteInitializedPerpMarket",
3367
3388
  "accounts": [
@@ -6835,12 +6856,16 @@
6835
6856
  ],
6836
6857
  "type": "u8"
6837
6858
  },
6859
+ {
6860
+ "name": "tokenProgram",
6861
+ "type": "u8"
6862
+ },
6838
6863
  {
6839
6864
  "name": "padding",
6840
6865
  "type": {
6841
6866
  "array": [
6842
6867
  "u8",
6843
- 42
6868
+ 41
6844
6869
  ]
6845
6870
  }
6846
6871
  }
@@ -10100,6 +10125,9 @@
10100
10125
  },
10101
10126
  {
10102
10127
  "name": "Future"
10128
+ },
10129
+ {
10130
+ "name": "Prediction"
10103
10131
  }
10104
10132
  ]
10105
10133
  }
@@ -12764,9 +12792,14 @@
12764
12792
  "code": 6281,
12765
12793
  "name": "InvalidOpenbookV2Market",
12766
12794
  "msg": "InvalidOpenbookV2Market"
12795
+ },
12796
+ {
12797
+ "code": 6282,
12798
+ "name": "NonZeroTransferFee",
12799
+ "msg": "Non zero transfer fee"
12767
12800
  }
12768
12801
  ],
12769
12802
  "metadata": {
12770
12803
  "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
12771
12804
  }
12772
- }
12805
+ }
package/src/index.ts CHANGED
@@ -73,6 +73,8 @@ export * from './serum/serumFulfillmentConfigMap';
73
73
  export * from './phoenix/phoenixSubscriber';
74
74
  export * from './priorityFee';
75
75
  export * from './phoenix/phoenixFulfillmentConfigMap';
76
+ export * from './openbook/openbookV2Subscriber';
77
+ export * from './openbook/openbookV2FulfillmentConfigMap';
76
78
  export * from './tx/fastSingleTxSender';
77
79
  export * from './tx/retryTxSender';
78
80
  export * from './tx/whileValidTxSender';
@@ -5,8 +5,12 @@ import {
5
5
  SpotBalanceType,
6
6
  SpotMarketAccount,
7
7
  } from '../types';
8
- import { calculateAssetWeight, calculateLiabilityWeight } from './spotBalance';
9
- import { MARGIN_PRECISION } from '../constants/numericConstants';
8
+ import {
9
+ calculateAssetWeight,
10
+ calculateLiabilityWeight,
11
+ getTokenAmount,
12
+ } from './spotBalance';
13
+ import { MARGIN_PRECISION, ZERO } from '../constants/numericConstants';
10
14
  import { numberToSafeBN } from './utils';
11
15
 
12
16
  export function castNumberToSpotPrecision(
@@ -54,3 +58,25 @@ export function calculateSpotMarketMarginRatio(
54
58
 
55
59
  return marginRatio;
56
60
  }
61
+
62
+ /**
63
+ * Returns the maximum remaining deposit that can be made to the spot market. If the maxTokenDeposits on the market is zero then there is no limit and this function will also return zero. (so that needs to be checked)
64
+ * @param market
65
+ * @returns
66
+ */
67
+ export function calculateMaxRemainingDeposit(market: SpotMarketAccount) {
68
+ const marketMaxTokenDeposits = market.maxTokenDeposits;
69
+
70
+ if (marketMaxTokenDeposits.eq(ZERO)) {
71
+ // If the maxTokenDeposits is set to zero then that means there is no limit. Return the largest number we can to represent infinite available deposit.
72
+ return ZERO;
73
+ }
74
+
75
+ const totalDepositsTokenAmount = getTokenAmount(
76
+ market.depositBalance,
77
+ market,
78
+ SpotBalanceType.DEPOSIT
79
+ );
80
+
81
+ return marketMaxTokenDeposits.sub(totalDepositsTokenAmount);
82
+ }
@@ -0,0 +1,29 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import { OpenbookV2FulfillmentConfigAccount } from '../types';
3
+ import { DriftClient } from '../driftClient';
4
+
5
+ export class OpenbookV2FulfillmentConfigMap {
6
+ driftClient: DriftClient;
7
+ map = new Map<number, OpenbookV2FulfillmentConfigAccount>();
8
+
9
+ public constructor(driftClient: DriftClient) {
10
+ this.driftClient = driftClient;
11
+ }
12
+
13
+ public async add(
14
+ marketIndex: number,
15
+ openbookV2MarketAddress: PublicKey
16
+ ): Promise<void> {
17
+ const account = await this.driftClient.getOpenbookV2FulfillmentConfig(
18
+ openbookV2MarketAddress
19
+ );
20
+
21
+ this.map.set(marketIndex, account);
22
+ }
23
+
24
+ public get(
25
+ marketIndex: number
26
+ ): OpenbookV2FulfillmentConfigAccount | undefined {
27
+ return this.map.get(marketIndex);
28
+ }
29
+ }