@drift-labs/sdk 0.1.36-master.1 → 0.1.36-master.4

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/lib/admin.js CHANGED
@@ -45,7 +45,7 @@ const trade_1 = require("./math/trade");
45
45
  const amm_1 = require("./math/amm");
46
46
  const clearingHouse_2 = require("./factory/clearingHouse");
47
47
  class Admin extends clearingHouse_1.ClearingHouse {
48
- static from(connection, wallet, clearingHouseProgramId, opts = anchor_1.Provider.defaultOptions()) {
48
+ static from(connection, wallet, clearingHouseProgramId, opts = anchor_1.AnchorProvider.defaultOptions()) {
49
49
  const config = (0, clearingHouse_2.getWebSocketClearingHouseConfig)(connection, wallet, clearingHouseProgramId, opts);
50
50
  return (0, clearingHouse_2.getAdmin)(config);
51
51
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="bn.js" />
3
- import { BN, Program, Provider } from '@project-serum/anchor';
3
+ import { AnchorProvider, BN, Program } from '@project-serum/anchor';
4
4
  import { MarketsAccount, StateAccount, DepositHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, IWallet, LiquidationHistoryAccount, PositionDirection, TradeHistoryAccount, UserAccount, Market, OrderHistoryAccount, OrderStateAccount, OrderParams, Order, ExtendedCurveHistoryAccount, UserPositionsAccount } from './types';
5
5
  import { Connection, PublicKey, TransactionSignature, Keypair, ConfirmOptions, TransactionInstruction } from '@solana/web3.js';
6
6
  import { MockUSDCFaucet } from './mockUSDCFaucet';
@@ -19,7 +19,7 @@ export declare class ClearingHouse {
19
19
  connection: Connection;
20
20
  wallet: IWallet;
21
21
  program: Program;
22
- provider: Provider;
22
+ provider: AnchorProvider;
23
23
  opts?: ConfirmOptions;
24
24
  accountSubscriber: ClearingHouseAccountSubscriber;
25
25
  eventEmitter: StrictEventEmitter<EventEmitter, ClearingHouseAccountEvents>;
@@ -77,7 +77,7 @@ class ClearingHouse {
77
77
  * @param opts
78
78
  * @returns
79
79
  */
80
- static from(connection, wallet, clearingHouseProgramId, opts = anchor_1.Provider.defaultOptions()) {
80
+ static from(connection, wallet, clearingHouseProgramId, opts = anchor_1.AnchorProvider.defaultOptions()) {
81
81
  const config = (0, clearingHouse_1.getWebSocketClearingHouseConfig)(connection, wallet, clearingHouseProgramId, opts);
82
82
  return (0, clearingHouse_1.getClearingHouse)(config);
83
83
  }
@@ -185,7 +185,7 @@ class ClearingHouse {
185
185
  * @param newWallet
186
186
  */
187
187
  updateWallet(newWallet) {
188
- const newProvider = new anchor_1.Provider(this.connection, newWallet, this.opts);
188
+ const newProvider = new anchor_1.AnchorProvider(this.connection, newWallet, this.opts);
189
189
  const newProgram = new anchor_1.Program(clearing_house_json_1.default, this.program.programId, newProvider);
190
190
  // Update provider for txSender with new wallet details
191
191
  this.txSender.provider = newProvider;
@@ -352,7 +352,7 @@ class ClearingHouse {
352
352
  .add(initializeUserAccountIx)
353
353
  .add(initializeUserOrdersAccountIx)
354
354
  .add(depositCollateralIx);
355
- const txSig = yield this.program.provider.send(tx, [userPositionsAccount]);
355
+ const txSig = yield this.txSender.send(tx, [userPositionsAccount]);
356
356
  return [txSig, userAccountPublicKey];
357
357
  });
358
358
  }
@@ -367,7 +367,9 @@ class ClearingHouse {
367
367
  .add(initializeUserAccountIx)
368
368
  .add(initializeUserOrdersAccountIx)
369
369
  .add(depositCollateralIx);
370
- const txSig = yield this.program.provider.send(tx, [userPositionsAccount]);
370
+ const txSig = yield this.program.provider.sendAndConfirm(tx, [
371
+ userPositionsAccount,
372
+ ]);
371
373
  return [txSig, userAccountPublicKey];
372
374
  });
373
375
  }
@@ -30,7 +30,7 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
30
30
  const rpcAddress = process.env.RPC_ADDRESS; // can use: https://api.devnet.solana.com for devnet; https://api.mainnet-beta.solana.com for mainnet;
31
31
  const connection = new web3_js_1.Connection(rpcAddress);
32
32
  // Set up the Provider
33
- const provider = new anchor_1.Provider(connection, wallet, anchor_1.Provider.defaultOptions());
33
+ const provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
34
34
  // Check SOL Balance
35
35
  const lamportsBalance = yield connection.getBalance(wallet.publicKey);
36
36
  console.log('SOL balance:', lamportsBalance / Math.pow(10, 9));
@@ -12,7 +12,7 @@ const defaultTxSender_1 = require("../tx/defaultTxSender");
12
12
  const pollingClearingHouseAccountSubscriber_1 = require("../accounts/pollingClearingHouseAccountSubscriber");
13
13
  const admin_1 = require("../admin");
14
14
  const retryTxSender_1 = require("../tx/retryTxSender");
15
- function getWebSocketClearingHouseConfig(connection, wallet, programID, opts = anchor_1.Provider.defaultOptions(), txSenderConfig) {
15
+ function getWebSocketClearingHouseConfig(connection, wallet, programID, opts = anchor_1.AnchorProvider.defaultOptions(), txSenderConfig) {
16
16
  return {
17
17
  type: 'websocket',
18
18
  connection,
@@ -23,7 +23,7 @@ function getWebSocketClearingHouseConfig(connection, wallet, programID, opts = a
23
23
  };
24
24
  }
25
25
  exports.getWebSocketClearingHouseConfig = getWebSocketClearingHouseConfig;
26
- function getPollingClearingHouseConfig(connection, wallet, programID, accountLoader, opts = anchor_1.Provider.defaultOptions(), txSenderConfig) {
26
+ function getPollingClearingHouseConfig(connection, wallet, programID, accountLoader, opts = anchor_1.AnchorProvider.defaultOptions(), txSenderConfig) {
27
27
  return {
28
28
  type: 'polling',
29
29
  connection,
@@ -37,7 +37,7 @@ function getPollingClearingHouseConfig(connection, wallet, programID, accountLoa
37
37
  exports.getPollingClearingHouseConfig = getPollingClearingHouseConfig;
38
38
  function getClearingHouse(config) {
39
39
  var _a;
40
- const provider = new anchor_1.Provider(config.connection, config.wallet, config.opts);
40
+ const provider = new anchor_1.AnchorProvider(config.connection, config.wallet, config.opts);
41
41
  const program = new anchor_1.Program(clearing_house_json_1.default, config.programID, provider);
42
42
  let accountSubscriber;
43
43
  if (config.type === 'websocket') {
@@ -59,7 +59,7 @@ function getClearingHouse(config) {
59
59
  exports.getClearingHouse = getClearingHouse;
60
60
  function getAdmin(config) {
61
61
  var _a;
62
- const provider = new anchor_1.Provider(config.connection, config.wallet, config.opts);
62
+ const provider = new anchor_1.AnchorProvider(config.connection, config.wallet, config.opts);
63
63
  const program = new anchor_1.Program(clearing_house_json_1.default, config.programID, provider);
64
64
  let accountSubscriber;
65
65
  if (config.type === 'websocket') {