@drift-labs/sdk 2.87.0-beta.5 → 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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.87.0-beta.5
1
+ 2.87.0-beta.6
@@ -1,6 +1,7 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { BN } from '@coral-xyz/anchor';
4
+ import { SpotMarketAccount } from '..';
4
5
  export declare function getDriftStateAccountPublicKeyAndNonce(programId: PublicKey): Promise<[PublicKey, number]>;
5
6
  export declare function getDriftStateAccountPublicKey(programId: PublicKey): Promise<PublicKey>;
6
7
  export declare function getUserAccountPublicKeyAndNonce(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<[PublicKey, number]>;
@@ -22,3 +23,4 @@ export declare function getReferrerNamePublicKeySync(programId: PublicKey, nameB
22
23
  export declare function getProtocolIfSharesTransferConfigPublicKey(programId: PublicKey): PublicKey;
23
24
  export declare function getPrelaunchOraclePublicKey(programId: PublicKey, marketIndex: number): PublicKey;
24
25
  export declare function getPythPullOraclePublicKey(progarmId: PublicKey, feedId: Uint8Array): PublicKey;
26
+ export declare function getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
@@ -23,9 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
26
+ exports.getTokenProgramForSpotMarket = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
27
27
  const web3_js_1 = require("@solana/web3.js");
28
28
  const anchor = __importStar(require("@coral-xyz/anchor"));
29
+ const spl_token_1 = require("@solana/spl-token");
29
30
  async function getDriftStateAccountPublicKeyAndNonce(programId) {
30
31
  return web3_js_1.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('drift_state'))], programId);
31
32
  }
@@ -158,3 +159,10 @@ function getPythPullOraclePublicKey(progarmId, feedId) {
158
159
  ], progarmId)[0];
159
160
  }
160
161
  exports.getPythPullOraclePublicKey = getPythPullOraclePublicKey;
162
+ function getTokenProgramForSpotMarket(spotMarketAccount) {
163
+ if (spotMarketAccount.tokenProgram === 1) {
164
+ return spl_token_1.TOKEN_2022_PROGRAM_ID;
165
+ }
166
+ return spl_token_1.TOKEN_PROGRAM_ID;
167
+ }
168
+ exports.getTokenProgramForSpotMarket = getTokenProgramForSpotMarket;
@@ -82,6 +82,7 @@ class AdminClient extends driftClient_1.DriftClient {
82
82
  const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
83
83
  const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
84
84
  const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
85
+ const tokenProgram = (await this.connection.getAccountInfo(mint)).owner;
85
86
  const nameBuffer = (0, userName_1.encodeName)(name);
86
87
  const initializeIx = await this.program.instruction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, nameBuffer, {
87
88
  accounts: {
@@ -97,7 +98,7 @@ class AdminClient extends driftClient_1.DriftClient {
97
98
  oracle,
98
99
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
99
100
  systemProgram: anchor.web3.SystemProgram.programId,
100
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
101
+ tokenProgram,
101
102
  },
102
103
  });
103
104
  return initializeIx;
@@ -78,7 +78,7 @@ class BankrunConnection {
78
78
  }
79
79
  async getTokenAccount(publicKey) {
80
80
  const info = await this.getAccountInfo(publicKey);
81
- return (0, spl_token_1.unpackAccount)(publicKey, info, spl_token_1.TOKEN_PROGRAM_ID);
81
+ return (0, spl_token_1.unpackAccount)(publicKey, info, info.owner);
82
82
  }
83
83
  async getMultipleAccountsInfo(publicKeys, _commitmentOrConfig) {
84
84
  const accountInfos = [];
@@ -39,6 +39,16 @@ exports.DevnetSpotMarkets = [
39
39
  serumMarket: new web3_js_1.PublicKey('AGsmbVu3MS9u68GEYABWosQQCZwmLcBHu4pWEuBYH7Za'),
40
40
  pythFeedId: '0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
41
41
  },
42
+ {
43
+ symbol: 'PYUSD',
44
+ marketIndex: 3,
45
+ oracle: new web3_js_1.PublicKey('HpMoKp3TCd3QT4MWYUKk2zCBwmhr5Df45fB6wdxYqEeh'),
46
+ oracleSource: __1.OracleSource.PYTH_PULL,
47
+ mint: new web3_js_1.PublicKey('GLfF72ZCUnS6N9iDJw8kedHzd6WFVf3VbpwdKKy76FRk'),
48
+ precision: new __1.BN(10).pow(numericConstants_1.SIX),
49
+ precisionExp: numericConstants_1.SIX,
50
+ pythFeedId: '0xc1da1b73d7f01e7ddd54b3766cf7fcd644395ad14f70aa706ec5384c59e76692',
51
+ },
42
52
  ];
43
53
  exports.MainnetSpotMarkets = [
44
54
  {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { BN, DLOBNode, OraclePriceData, PerpMarketAccount } from '..';
3
3
  import { PublicKey } from '@solana/web3.js';
4
- type liquiditySource = 'serum' | 'vamm' | 'dlob' | 'phoenix';
4
+ type liquiditySource = 'serum' | 'vamm' | 'dlob' | 'phoenix' | 'openbook';
5
5
  export type L2Level = {
6
6
  price: BN;
7
7
  size: BN;
@@ -230,8 +230,8 @@ export declare class DriftClient {
230
230
  * @param useNative
231
231
  */
232
232
  getAssociatedTokenAccount(marketIndex: number, useNative?: boolean): Promise<PublicKey>;
233
- createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey): TransactionInstruction;
234
- createDepositTxn(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<ReturnType<typeof this.buildTransaction>>;
233
+ createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: anchor.web3.PublicKey): TransactionInstruction;
234
+ createDepositTxn(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<VersionedTransaction | Transaction>;
235
235
  /**
236
236
  * Deposit funds into the given spot market
237
237
  *
@@ -250,6 +250,7 @@ export declare class DriftClient {
250
250
  signers: Signer[];
251
251
  pubkey: PublicKey;
252
252
  }>;
253
+ addTokenMintToRemainingAccounts(spotMarketAccount: SpotMarketAccount, remainingAccounts: AccountMeta[]): void;
253
254
  getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey): anchor.web3.TransactionInstruction;
254
255
  createInitializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number): Promise<[Transaction | VersionedTransaction, PublicKey]>;
255
256
  /**
@@ -662,7 +663,7 @@ export declare class DriftClient {
662
663
  getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
663
664
  initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
664
665
  getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
665
- getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey, fromSubAccount?: boolean): Promise<TransactionInstruction>;
666
+ getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
666
667
  /**
667
668
  * Add to an insurance fund stake and optionally initialize the account
668
669
  */
@@ -689,8 +690,8 @@ export declare class DriftClient {
689
690
  requestRemoveInsuranceFundStake(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
690
691
  cancelRequestRemoveInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
691
692
  removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
692
- settleRevenueToInsuranceFund(spotMarketIndex: number, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
693
- getSettleRevenueToInsuranceFundIx(spotMarketIndex: number, subAccountId?: number): Promise<TransactionInstruction>;
693
+ settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
694
+ getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
694
695
  resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
695
696
  getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
696
697
  getDepositIntoSpotMarketRevenuePoolIx(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
@@ -52,6 +52,7 @@ const spotPosition_1 = require("./math/spotPosition");
52
52
  const market_1 = require("./math/market");
53
53
  const fetch_1 = require("./accounts/fetch");
54
54
  const spotMarket_1 = require("./math/spotMarket");
55
+ const pda_2 = require("./addresses/pda");
55
56
  const memcmp_1 = require("./memcmp");
56
57
  const marinade_1 = require("./marinade");
57
58
  const orderParams_1 = require("./orderParams");
@@ -1062,7 +1063,7 @@ class DriftClient {
1062
1063
  const mint = spotMarket.mint;
1063
1064
  return await (0, spl_token_1.getAssociatedTokenAddress)(mint, this.wallet.publicKey);
1064
1065
  }
1065
- createAssociatedTokenAccountIdempotentInstruction(account, payer, owner, mint) {
1066
+ createAssociatedTokenAccountIdempotentInstruction(account, payer, owner, mint, tokenProgram = spl_token_1.TOKEN_PROGRAM_ID) {
1066
1067
  return new web3_js_1.TransactionInstruction({
1067
1068
  keys: [
1068
1069
  { pubkey: payer, isSigner: true, isWritable: true },
@@ -1074,7 +1075,7 @@ class DriftClient {
1074
1075
  isSigner: false,
1075
1076
  isWritable: false,
1076
1077
  },
1077
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
1078
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
1078
1079
  ],
1079
1080
  programId: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
1080
1081
  data: Buffer.from([0x1]),
@@ -1133,6 +1134,8 @@ class DriftClient {
1133
1134
  });
1134
1135
  }
1135
1136
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
1137
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
1138
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(spotMarketAccount);
1136
1139
  return await this.program.instruction.deposit(marketIndex, amount, reduceOnly, {
1137
1140
  accounts: {
1138
1141
  state: await this.getStatePublicKey(),
@@ -1142,7 +1145,7 @@ class DriftClient {
1142
1145
  userStats: this.getUserStatsAccountPublicKey(),
1143
1146
  userTokenAccount: userTokenAccount,
1144
1147
  authority: this.wallet.publicKey,
1145
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1148
+ tokenProgram,
1146
1149
  },
1147
1150
  remainingAccounts,
1148
1151
  });
@@ -1184,6 +1187,15 @@ class DriftClient {
1184
1187
  result.ixs.push((0, spl_token_1.createInitializeAccountInstruction)(wrappedSolAccount, spotMarkets_1.WRAPPED_SOL_MINT, authority));
1185
1188
  return result;
1186
1189
  }
1190
+ addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts) {
1191
+ if (spotMarketAccount.tokenProgram === 1) {
1192
+ remainingAccounts.push({
1193
+ pubkey: spotMarketAccount.mint,
1194
+ isSigner: false,
1195
+ isWritable: false,
1196
+ });
1197
+ }
1198
+ }
1187
1199
  getAssociatedTokenAccountCreationIx(tokenMintAddress, associatedTokenAddress) {
1188
1200
  return (0, spl_token_1.createAssociatedTokenAccountInstruction)(this.wallet.publicKey, associatedTokenAddress, this.wallet.publicKey, tokenMintAddress);
1189
1201
  }
@@ -1347,6 +1359,8 @@ class DriftClient {
1347
1359
  readableSpotMarketIndexes: [numericConstants_1.QUOTE_SPOT_MARKET_INDEX],
1348
1360
  });
1349
1361
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
1362
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
1363
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(spotMarketAccount);
1350
1364
  return await this.program.instruction.withdraw(marketIndex, amount, reduceOnly, {
1351
1365
  accounts: {
1352
1366
  state: await this.getStatePublicKey(),
@@ -1357,7 +1371,7 @@ class DriftClient {
1357
1371
  userStats: this.getUserStatsAccountPublicKey(),
1358
1372
  userTokenAccount: userTokenAccount,
1359
1373
  authority: this.wallet.publicKey,
1360
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1374
+ tokenProgram,
1361
1375
  },
1362
1376
  remainingAccounts,
1363
1377
  });
@@ -2357,14 +2371,16 @@ class DriftClient {
2357
2371
  outAssociatedTokenAccount = await this.getAssociatedTokenAccount(outMarket.marketIndex, false);
2358
2372
  const accountInfo = await this.connection.getAccountInfo(outAssociatedTokenAccount);
2359
2373
  if (!accountInfo) {
2360
- preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(outAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, outMarket.mint));
2374
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(outMarket);
2375
+ preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(outAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, outMarket.mint, tokenProgram));
2361
2376
  }
2362
2377
  }
2363
2378
  if (!inAssociatedTokenAccount) {
2364
2379
  inAssociatedTokenAccount = await this.getAssociatedTokenAccount(inMarket.marketIndex, false);
2365
2380
  const accountInfo = await this.connection.getAccountInfo(inAssociatedTokenAccount);
2366
2381
  if (!accountInfo) {
2367
- preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(inAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, inMarket.mint));
2382
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(outMarket);
2383
+ preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(inAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, inMarket.mint, tokenProgram));
2368
2384
  }
2369
2385
  }
2370
2386
  const { beginSwapIx, endSwapIx } = await this.getSwapIx({
@@ -2479,6 +2495,27 @@ class DriftClient {
2479
2495
  });
2480
2496
  const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
2481
2497
  const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
2498
+ const outTokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(outSpotMarket);
2499
+ const inTokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(inSpotMarket);
2500
+ if (!outTokenProgram.equals(inTokenProgram)) {
2501
+ remainingAccounts.push({
2502
+ pubkey: outTokenProgram,
2503
+ isWritable: false,
2504
+ isSigner: false,
2505
+ });
2506
+ }
2507
+ if (outSpotMarket.tokenProgram === 1 || inSpotMarket.tokenProgram === 1) {
2508
+ remainingAccounts.push({
2509
+ pubkey: inSpotMarket.mint,
2510
+ isWritable: false,
2511
+ isSigner: false,
2512
+ });
2513
+ remainingAccounts.push({
2514
+ pubkey: outSpotMarket.mint,
2515
+ isWritable: false,
2516
+ isSigner: false,
2517
+ });
2518
+ }
2482
2519
  const beginSwapIx = await this.program.instruction.beginSwap(inMarketIndex, outMarketIndex, amountIn, {
2483
2520
  accounts: {
2484
2521
  state: await this.getStatePublicKey(),
@@ -2489,7 +2526,7 @@ class DriftClient {
2489
2526
  inSpotMarketVault: inSpotMarket.vault,
2490
2527
  inTokenAccount,
2491
2528
  outTokenAccount,
2492
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2529
+ tokenProgram: inTokenProgram,
2493
2530
  driftSigner: this.getStateAccount().signer,
2494
2531
  instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
2495
2532
  },
@@ -2505,7 +2542,7 @@ class DriftClient {
2505
2542
  inSpotMarketVault: inSpotMarket.vault,
2506
2543
  inTokenAccount,
2507
2544
  outTokenAccount,
2508
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
2545
+ tokenProgram: inTokenProgram,
2509
2546
  driftSigner: this.getStateAccount().signer,
2510
2547
  instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
2511
2548
  },
@@ -3315,6 +3352,7 @@ class DriftClient {
3315
3352
  writableSpotMarketIndexes: [marketIndex],
3316
3353
  });
3317
3354
  const spotMarket = this.getSpotMarketAccount(marketIndex);
3355
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
3318
3356
  return await this.program.instruction.resolveSpotBankruptcy(marketIndex, {
3319
3357
  accounts: {
3320
3358
  state: await this.getStatePublicKey(),
@@ -3444,14 +3482,12 @@ class DriftClient {
3444
3482
  },
3445
3483
  });
3446
3484
  }
3447
- async getAddInsuranceFundStakeIx(marketIndex, amount, collateralAccountPublicKey, fromSubAccount) {
3485
+ async getAddInsuranceFundStakeIx(marketIndex, amount, collateralAccountPublicKey) {
3448
3486
  const spotMarket = this.getSpotMarketAccount(marketIndex);
3449
3487
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
3450
- const remainingAccounts = this.getRemainingAccounts({
3451
- userAccounts: fromSubAccount ? [this.getUserAccount()] : [],
3452
- useMarketLastSlotCache: fromSubAccount ? true : false,
3453
- writableSpotMarketIndexes: [marketIndex],
3454
- });
3488
+ const remainingAccounts = [];
3489
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
3490
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(spotMarket);
3455
3491
  const ix = this.program.instruction.addInsuranceFundStake(marketIndex, amount, {
3456
3492
  accounts: {
3457
3493
  state: await this.getStatePublicKey(),
@@ -3463,7 +3499,7 @@ class DriftClient {
3463
3499
  insuranceFundVault: spotMarket.insuranceFund.vault,
3464
3500
  driftSigner: this.getSignerPublicKey(),
3465
3501
  userTokenAccount: collateralAccountPublicKey,
3466
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3502
+ tokenProgram,
3467
3503
  },
3468
3504
  remainingAccounts,
3469
3505
  });
@@ -3500,7 +3536,7 @@ class DriftClient {
3500
3536
  const initializeIx = await this.getInitializeInsuranceFundStakeIx(marketIndex);
3501
3537
  addIfStakeIxs.push(initializeIx);
3502
3538
  }
3503
- const addFundsIx = await this.getAddInsuranceFundStakeIx(marketIndex, amount, tokenAccount, fromSubaccount);
3539
+ const addFundsIx = await this.getAddInsuranceFundStakeIx(marketIndex, amount, tokenAccount);
3504
3540
  addIfStakeIxs.push(addFundsIx);
3505
3541
  if (createWSOLTokenAccount) {
3506
3542
  addIfStakeIxs.push((0, spl_token_1.createCloseAccountInstruction)(tokenAccount, this.wallet.publicKey, this.wallet.publicKey, []));
@@ -3512,10 +3548,6 @@ class DriftClient {
3512
3548
  async requestRemoveInsuranceFundStake(marketIndex, amount, txParams) {
3513
3549
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
3514
3550
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
3515
- const remainingAccounts = this.getRemainingAccounts({
3516
- userAccounts: [],
3517
- writableSpotMarketIndexes: [marketIndex],
3518
- });
3519
3551
  const ix = await this.program.instruction.requestRemoveInsuranceFundStake(marketIndex, amount, {
3520
3552
  accounts: {
3521
3553
  state: await this.getStatePublicKey(),
@@ -3525,7 +3557,6 @@ class DriftClient {
3525
3557
  authority: this.wallet.publicKey,
3526
3558
  insuranceFundVault: spotMarketAccount.insuranceFund.vault,
3527
3559
  },
3528
- remainingAccounts,
3529
3560
  });
3530
3561
  const tx = await this.buildTransaction(ix, txParams);
3531
3562
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
@@ -3534,11 +3565,6 @@ class DriftClient {
3534
3565
  async cancelRequestRemoveInsuranceFundStake(marketIndex, txParams) {
3535
3566
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
3536
3567
  const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
3537
- const remainingAccounts = this.getRemainingAccounts({
3538
- userAccounts: [this.getUserAccount()],
3539
- useMarketLastSlotCache: true,
3540
- writableSpotMarketIndexes: [marketIndex],
3541
- });
3542
3568
  const ix = await this.program.instruction.cancelRequestRemoveInsuranceFundStake(marketIndex, {
3543
3569
  accounts: {
3544
3570
  state: await this.getStatePublicKey(),
@@ -3548,7 +3574,6 @@ class DriftClient {
3548
3574
  authority: this.wallet.publicKey,
3549
3575
  insuranceFundVault: spotMarketAccount.insuranceFund.vault,
3550
3576
  },
3551
- remainingAccounts,
3552
3577
  });
3553
3578
  const tx = await this.buildTransaction(ix, txParams);
3554
3579
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
@@ -3577,10 +3602,9 @@ class DriftClient {
3577
3602
  removeIfStakeIxs.push(createTokenAccountIx);
3578
3603
  }
3579
3604
  }
3580
- const remainingAccounts = this.getRemainingAccounts({
3581
- userAccounts: [],
3582
- writableSpotMarketIndexes: [marketIndex],
3583
- });
3605
+ const remainingAccounts = [];
3606
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
3607
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(spotMarketAccount);
3584
3608
  const removeStakeIx = await this.program.instruction.removeInsuranceFundStake(marketIndex, {
3585
3609
  accounts: {
3586
3610
  state: await this.getStatePublicKey(),
@@ -3591,7 +3615,7 @@ class DriftClient {
3591
3615
  insuranceFundVault: spotMarketAccount.insuranceFund.vault,
3592
3616
  driftSigner: this.getSignerPublicKey(),
3593
3617
  userTokenAccount: tokenAccount,
3594
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3618
+ tokenProgram,
3595
3619
  },
3596
3620
  remainingAccounts,
3597
3621
  });
@@ -3604,18 +3628,15 @@ class DriftClient {
3604
3628
  const { txSig } = await this.sendTransaction(tx, additionalSigners, this.opts);
3605
3629
  return txSig;
3606
3630
  }
3607
- async settleRevenueToInsuranceFund(spotMarketIndex, subAccountId, txParams) {
3608
- const tx = await this.buildTransaction(await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex, subAccountId), txParams);
3631
+ async settleRevenueToInsuranceFund(spotMarketIndex, txParams) {
3632
+ const tx = await this.buildTransaction(await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex), txParams);
3609
3633
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
3610
3634
  return txSig;
3611
3635
  }
3612
- async getSettleRevenueToInsuranceFundIx(spotMarketIndex, subAccountId) {
3636
+ async getSettleRevenueToInsuranceFundIx(spotMarketIndex) {
3613
3637
  const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
3614
- const remainingAccounts = this.getRemainingAccounts({
3615
- userAccounts: [this.getUserAccount(subAccountId)],
3616
- useMarketLastSlotCache: true,
3617
- writableSpotMarketIndexes: [spotMarketIndex],
3618
- });
3638
+ const remainingAccounts = [];
3639
+ this.addTokenMintToRemainingAccounts(spotMarketAccount, remainingAccounts);
3619
3640
  const ix = await this.program.instruction.settleRevenueToInsuranceFund(spotMarketIndex, {
3620
3641
  accounts: {
3621
3642
  state: await this.getStatePublicKey(),
@@ -3655,6 +3676,9 @@ class DriftClient {
3655
3676
  }
3656
3677
  async getDepositIntoSpotMarketRevenuePoolIx(marketIndex, amount, userTokenAccountPublicKey) {
3657
3678
  const spotMarket = await this.getSpotMarketAccount(marketIndex);
3679
+ const remainingAccounts = [];
3680
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
3681
+ const tokenProgram = (0, pda_2.getTokenProgramForSpotMarket)(spotMarket);
3658
3682
  const ix = await this.program.instruction.depositIntoSpotMarketRevenuePool(amount, {
3659
3683
  accounts: {
3660
3684
  state: await this.getStatePublicKey(),
@@ -3662,7 +3686,7 @@ class DriftClient {
3662
3686
  authority: this.wallet.publicKey,
3663
3687
  spotMarketVault: spotMarket.vault,
3664
3688
  userTokenAccount: userTokenAccountPublicKey,
3665
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
3689
+ tokenProgram,
3666
3690
  },
3667
3691
  });
3668
3692
  return ix;
@@ -3878,10 +3902,18 @@ class DriftClient {
3878
3902
  if (!pullIx) {
3879
3903
  return undefined;
3880
3904
  }
3881
- const tx = await this.buildTransaction(pullIx, undefined, 0, [
3882
- await this.fetchMarketLookupTableAccount(),
3883
- ]);
3884
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
3905
+ const tx = await (0, on_demand_1.asV0Tx)({
3906
+ connection: this.connection,
3907
+ ixs: [pullIx],
3908
+ payer: this.wallet.publicKey,
3909
+ computeUnitLimitMultiple: 1.3,
3910
+ lookupTables: [await this.fetchMarketLookupTableAccount()],
3911
+ });
3912
+ const { txSig } = await this.sendTransaction(tx, [], {
3913
+ commitment: 'processed',
3914
+ skipPreflight: true,
3915
+ maxRetries: 0,
3916
+ });
3885
3917
  return txSig;
3886
3918
  }
3887
3919
  async getBuildEncodedVaaIxs(vaa, guardianSet) {
@@ -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,6 +12792,11 @@
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": {