@drift-labs/sdk 2.42.0-beta.9 → 2.43.0-beta.0

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.41.0",
2
+ "version": "2.42.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -5890,9 +5890,7 @@
5890
5890
  "docs": [
5891
5891
  "Whether the user is active, being liquidated or bankrupt"
5892
5892
  ],
5893
- "type": {
5894
- "defined": "UserStatus"
5895
- }
5893
+ "type": "u8"
5896
5894
  },
5897
5895
  {
5898
5896
  "name": "isMarginTradingEnabled",
@@ -6106,204 +6104,6 @@
6106
6104
  }
6107
6105
  ],
6108
6106
  "types": [
6109
- {
6110
- "name": "OrderParams",
6111
- "type": {
6112
- "kind": "struct",
6113
- "fields": [
6114
- {
6115
- "name": "orderType",
6116
- "type": {
6117
- "defined": "OrderType"
6118
- }
6119
- },
6120
- {
6121
- "name": "marketType",
6122
- "type": {
6123
- "defined": "MarketType"
6124
- }
6125
- },
6126
- {
6127
- "name": "direction",
6128
- "type": {
6129
- "defined": "PositionDirection"
6130
- }
6131
- },
6132
- {
6133
- "name": "userOrderId",
6134
- "type": "u8"
6135
- },
6136
- {
6137
- "name": "baseAssetAmount",
6138
- "type": "u64"
6139
- },
6140
- {
6141
- "name": "price",
6142
- "type": "u64"
6143
- },
6144
- {
6145
- "name": "marketIndex",
6146
- "type": "u16"
6147
- },
6148
- {
6149
- "name": "reduceOnly",
6150
- "type": "bool"
6151
- },
6152
- {
6153
- "name": "postOnly",
6154
- "type": {
6155
- "defined": "PostOnlyParam"
6156
- }
6157
- },
6158
- {
6159
- "name": "immediateOrCancel",
6160
- "type": "bool"
6161
- },
6162
- {
6163
- "name": "maxTs",
6164
- "type": {
6165
- "option": "i64"
6166
- }
6167
- },
6168
- {
6169
- "name": "triggerPrice",
6170
- "type": {
6171
- "option": "u64"
6172
- }
6173
- },
6174
- {
6175
- "name": "triggerCondition",
6176
- "type": {
6177
- "defined": "OrderTriggerCondition"
6178
- }
6179
- },
6180
- {
6181
- "name": "oraclePriceOffset",
6182
- "type": {
6183
- "option": "i32"
6184
- }
6185
- },
6186
- {
6187
- "name": "auctionDuration",
6188
- "type": {
6189
- "option": "u8"
6190
- }
6191
- },
6192
- {
6193
- "name": "auctionStartPrice",
6194
- "type": {
6195
- "option": "i64"
6196
- }
6197
- },
6198
- {
6199
- "name": "auctionEndPrice",
6200
- "type": {
6201
- "option": "i64"
6202
- }
6203
- }
6204
- ]
6205
- }
6206
- },
6207
- {
6208
- "name": "ModifyOrderParams",
6209
- "type": {
6210
- "kind": "struct",
6211
- "fields": [
6212
- {
6213
- "name": "direction",
6214
- "type": {
6215
- "option": {
6216
- "defined": "PositionDirection"
6217
- }
6218
- }
6219
- },
6220
- {
6221
- "name": "baseAssetAmount",
6222
- "type": {
6223
- "option": "u64"
6224
- }
6225
- },
6226
- {
6227
- "name": "price",
6228
- "type": {
6229
- "option": "u64"
6230
- }
6231
- },
6232
- {
6233
- "name": "reduceOnly",
6234
- "type": {
6235
- "option": "bool"
6236
- }
6237
- },
6238
- {
6239
- "name": "postOnly",
6240
- "type": {
6241
- "option": {
6242
- "defined": "PostOnlyParam"
6243
- }
6244
- }
6245
- },
6246
- {
6247
- "name": "immediateOrCancel",
6248
- "type": {
6249
- "option": "bool"
6250
- }
6251
- },
6252
- {
6253
- "name": "maxTs",
6254
- "type": {
6255
- "option": "i64"
6256
- }
6257
- },
6258
- {
6259
- "name": "triggerPrice",
6260
- "type": {
6261
- "option": "u64"
6262
- }
6263
- },
6264
- {
6265
- "name": "triggerCondition",
6266
- "type": {
6267
- "option": {
6268
- "defined": "OrderTriggerCondition"
6269
- }
6270
- }
6271
- },
6272
- {
6273
- "name": "oraclePriceOffset",
6274
- "type": {
6275
- "option": "i32"
6276
- }
6277
- },
6278
- {
6279
- "name": "auctionDuration",
6280
- "type": {
6281
- "option": "u8"
6282
- }
6283
- },
6284
- {
6285
- "name": "auctionStartPrice",
6286
- "type": {
6287
- "option": "i64"
6288
- }
6289
- },
6290
- {
6291
- "name": "auctionEndPrice",
6292
- "type": {
6293
- "option": "i64"
6294
- }
6295
- },
6296
- {
6297
- "name": "policy",
6298
- "type": {
6299
- "option": {
6300
- "defined": "ModifyOrderPolicy"
6301
- }
6302
- }
6303
- }
6304
- ]
6305
- }
6306
- },
6307
6107
  {
6308
6108
  "name": "LiquidatePerpRecord",
6309
6109
  "type": {
@@ -6614,6 +6414,204 @@
6614
6414
  ]
6615
6415
  }
6616
6416
  },
6417
+ {
6418
+ "name": "OrderParams",
6419
+ "type": {
6420
+ "kind": "struct",
6421
+ "fields": [
6422
+ {
6423
+ "name": "orderType",
6424
+ "type": {
6425
+ "defined": "OrderType"
6426
+ }
6427
+ },
6428
+ {
6429
+ "name": "marketType",
6430
+ "type": {
6431
+ "defined": "MarketType"
6432
+ }
6433
+ },
6434
+ {
6435
+ "name": "direction",
6436
+ "type": {
6437
+ "defined": "PositionDirection"
6438
+ }
6439
+ },
6440
+ {
6441
+ "name": "userOrderId",
6442
+ "type": "u8"
6443
+ },
6444
+ {
6445
+ "name": "baseAssetAmount",
6446
+ "type": "u64"
6447
+ },
6448
+ {
6449
+ "name": "price",
6450
+ "type": "u64"
6451
+ },
6452
+ {
6453
+ "name": "marketIndex",
6454
+ "type": "u16"
6455
+ },
6456
+ {
6457
+ "name": "reduceOnly",
6458
+ "type": "bool"
6459
+ },
6460
+ {
6461
+ "name": "postOnly",
6462
+ "type": {
6463
+ "defined": "PostOnlyParam"
6464
+ }
6465
+ },
6466
+ {
6467
+ "name": "immediateOrCancel",
6468
+ "type": "bool"
6469
+ },
6470
+ {
6471
+ "name": "maxTs",
6472
+ "type": {
6473
+ "option": "i64"
6474
+ }
6475
+ },
6476
+ {
6477
+ "name": "triggerPrice",
6478
+ "type": {
6479
+ "option": "u64"
6480
+ }
6481
+ },
6482
+ {
6483
+ "name": "triggerCondition",
6484
+ "type": {
6485
+ "defined": "OrderTriggerCondition"
6486
+ }
6487
+ },
6488
+ {
6489
+ "name": "oraclePriceOffset",
6490
+ "type": {
6491
+ "option": "i32"
6492
+ }
6493
+ },
6494
+ {
6495
+ "name": "auctionDuration",
6496
+ "type": {
6497
+ "option": "u8"
6498
+ }
6499
+ },
6500
+ {
6501
+ "name": "auctionStartPrice",
6502
+ "type": {
6503
+ "option": "i64"
6504
+ }
6505
+ },
6506
+ {
6507
+ "name": "auctionEndPrice",
6508
+ "type": {
6509
+ "option": "i64"
6510
+ }
6511
+ }
6512
+ ]
6513
+ }
6514
+ },
6515
+ {
6516
+ "name": "ModifyOrderParams",
6517
+ "type": {
6518
+ "kind": "struct",
6519
+ "fields": [
6520
+ {
6521
+ "name": "direction",
6522
+ "type": {
6523
+ "option": {
6524
+ "defined": "PositionDirection"
6525
+ }
6526
+ }
6527
+ },
6528
+ {
6529
+ "name": "baseAssetAmount",
6530
+ "type": {
6531
+ "option": "u64"
6532
+ }
6533
+ },
6534
+ {
6535
+ "name": "price",
6536
+ "type": {
6537
+ "option": "u64"
6538
+ }
6539
+ },
6540
+ {
6541
+ "name": "reduceOnly",
6542
+ "type": {
6543
+ "option": "bool"
6544
+ }
6545
+ },
6546
+ {
6547
+ "name": "postOnly",
6548
+ "type": {
6549
+ "option": {
6550
+ "defined": "PostOnlyParam"
6551
+ }
6552
+ }
6553
+ },
6554
+ {
6555
+ "name": "immediateOrCancel",
6556
+ "type": {
6557
+ "option": "bool"
6558
+ }
6559
+ },
6560
+ {
6561
+ "name": "maxTs",
6562
+ "type": {
6563
+ "option": "i64"
6564
+ }
6565
+ },
6566
+ {
6567
+ "name": "triggerPrice",
6568
+ "type": {
6569
+ "option": "u64"
6570
+ }
6571
+ },
6572
+ {
6573
+ "name": "triggerCondition",
6574
+ "type": {
6575
+ "option": {
6576
+ "defined": "OrderTriggerCondition"
6577
+ }
6578
+ }
6579
+ },
6580
+ {
6581
+ "name": "oraclePriceOffset",
6582
+ "type": {
6583
+ "option": "i32"
6584
+ }
6585
+ },
6586
+ {
6587
+ "name": "auctionDuration",
6588
+ "type": {
6589
+ "option": "u8"
6590
+ }
6591
+ },
6592
+ {
6593
+ "name": "auctionStartPrice",
6594
+ "type": {
6595
+ "option": "i64"
6596
+ }
6597
+ },
6598
+ {
6599
+ "name": "auctionEndPrice",
6600
+ "type": {
6601
+ "option": "i64"
6602
+ }
6603
+ },
6604
+ {
6605
+ "name": "policy",
6606
+ "type": {
6607
+ "option": {
6608
+ "defined": "ModifyOrderPolicy"
6609
+ }
6610
+ }
6611
+ }
6612
+ ]
6613
+ }
6614
+ },
6617
6615
  {
6618
6616
  "name": "InsuranceClaim",
6619
6617
  "type": {
@@ -8007,40 +8005,6 @@
8007
8005
  ]
8008
8006
  }
8009
8007
  },
8010
- {
8011
- "name": "PostOnlyParam",
8012
- "type": {
8013
- "kind": "enum",
8014
- "variants": [
8015
- {
8016
- "name": "None"
8017
- },
8018
- {
8019
- "name": "MustPostOnly"
8020
- },
8021
- {
8022
- "name": "TryPostOnly"
8023
- },
8024
- {
8025
- "name": "Slide"
8026
- }
8027
- ]
8028
- }
8029
- },
8030
- {
8031
- "name": "ModifyOrderPolicy",
8032
- "type": {
8033
- "kind": "enum",
8034
- "variants": [
8035
- {
8036
- "name": "TryModify"
8037
- },
8038
- {
8039
- "name": "MustModify"
8040
- }
8041
- ]
8042
- }
8043
- },
8044
8008
  {
8045
8009
  "name": "SwapReduceOnly",
8046
8010
  "type": {
@@ -8383,6 +8347,23 @@
8383
8347
  ]
8384
8348
  }
8385
8349
  },
8350
+ {
8351
+ "name": "FillMode",
8352
+ "type": {
8353
+ "kind": "enum",
8354
+ "variants": [
8355
+ {
8356
+ "name": "Fill"
8357
+ },
8358
+ {
8359
+ "name": "PlaceAndMake"
8360
+ },
8361
+ {
8362
+ "name": "PlaceAndTake"
8363
+ }
8364
+ ]
8365
+ }
8366
+ },
8386
8367
  {
8387
8368
  "name": "PerpFulfillmentMethod",
8388
8369
  "type": {
@@ -8474,6 +8455,40 @@
8474
8455
  ]
8475
8456
  }
8476
8457
  },
8458
+ {
8459
+ "name": "PostOnlyParam",
8460
+ "type": {
8461
+ "kind": "enum",
8462
+ "variants": [
8463
+ {
8464
+ "name": "None"
8465
+ },
8466
+ {
8467
+ "name": "MustPostOnly"
8468
+ },
8469
+ {
8470
+ "name": "TryPostOnly"
8471
+ },
8472
+ {
8473
+ "name": "Slide"
8474
+ }
8475
+ ]
8476
+ }
8477
+ },
8478
+ {
8479
+ "name": "ModifyOrderPolicy",
8480
+ "type": {
8481
+ "kind": "enum",
8482
+ "variants": [
8483
+ {
8484
+ "name": "TryModify"
8485
+ },
8486
+ {
8487
+ "name": "MustModify"
8488
+ }
8489
+ ]
8490
+ }
8491
+ },
8477
8492
  {
8478
8493
  "name": "MarketStatus",
8479
8494
  "type": {
@@ -8648,9 +8663,6 @@
8648
8663
  "type": {
8649
8664
  "kind": "enum",
8650
8665
  "variants": [
8651
- {
8652
- "name": "Active"
8653
- },
8654
8666
  {
8655
8667
  "name": "BeingLiquidated"
8656
8668
  },
package/lib/index.d.ts CHANGED
@@ -33,6 +33,9 @@ export * from './factory/bigNum';
33
33
  export * from './events/types';
34
34
  export * from './events/eventSubscriber';
35
35
  export * from './events/fetchLogs';
36
+ export * from './events/txEventCache';
37
+ export * from './events/webSocketLogProvider';
38
+ export * from './events/pollingLogProvider';
36
39
  export * from './jupiter/jupiterClient';
37
40
  export * from './math/auction';
38
41
  export * from './math/spotMarket';
package/lib/index.js CHANGED
@@ -56,6 +56,9 @@ __exportStar(require("./factory/bigNum"), exports);
56
56
  __exportStar(require("./events/types"), exports);
57
57
  __exportStar(require("./events/eventSubscriber"), exports);
58
58
  __exportStar(require("./events/fetchLogs"), exports);
59
+ __exportStar(require("./events/txEventCache"), exports);
60
+ __exportStar(require("./events/webSocketLogProvider"), exports);
61
+ __exportStar(require("./events/pollingLogProvider"), exports);
59
62
  __exportStar(require("./jupiter/jupiterClient"), exports);
60
63
  __exportStar(require("./math/auction"), exports);
61
64
  __exportStar(require("./math/spotMarket"), exports);
@@ -1,9 +1,8 @@
1
- /// <reference types="node" />
2
1
  import { OrderSubscriber } from './OrderSubscriber';
3
2
  export declare class PollingSubscription {
4
3
  private orderSubscriber;
5
4
  private frequency;
6
- intervalId?: NodeJS.Timer;
5
+ intervalId?: ReturnType<typeof setTimeout>;
7
6
  constructor({ orderSubscriber, frequency, }: {
8
7
  orderSubscriber: OrderSubscriber;
9
8
  frequency: number;
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
1
  import { Connection, PublicKey } from '@solana/web3.js';
3
2
  export declare class PriorityFeeSubscriber {
4
3
  connection: Connection;
5
4
  frequencyMs: number;
6
5
  addresses: PublicKey[];
7
6
  slotsToCheck: number;
8
- intervalId?: NodeJS.Timer;
7
+ intervalId?: ReturnType<typeof setTimeout>;
9
8
  latestPriorityFee: number;
10
9
  avgPriorityFee: number;
11
10
  maxPriorityFee: number;
package/lib/types.d.ts CHANGED
@@ -41,19 +41,10 @@ export declare class MarketStatus {
41
41
  delisted: {};
42
42
  };
43
43
  }
44
- export declare class UserStatus {
45
- static readonly ACTIVE: {
46
- active: {};
47
- };
48
- static readonly BEING_LIQUIDATED: {
49
- beingLiquidated: {};
50
- };
51
- static readonly BANKRUPT: {
52
- bankrupt: {};
53
- };
54
- static readonly REDUCE_ONLY: {
55
- reduceOnly: {};
56
- };
44
+ export declare enum UserStatus {
45
+ BEING_LIQUIDATED = 1,
46
+ BANKRUPT = 2,
47
+ REDUCE_ONLY = 4
57
48
  }
58
49
  export declare class ContractType {
59
50
  static readonly PERPETUAL: {
@@ -882,7 +873,7 @@ export type UserAccount = {
882
873
  spotPositions: SpotPosition[];
883
874
  perpPositions: PerpPosition[];
884
875
  orders: Order[];
885
- status: UserStatus;
876
+ status: number;
886
877
  nextLiquidationId: number;
887
878
  nextOrderId: number;
888
879
  maxMarginRatio: number;
package/lib/types.js CHANGED
@@ -27,13 +27,12 @@ MarketStatus.WITHDRAW_PAUSED = { withdrawPaused: {} };
27
27
  MarketStatus.REDUCE_ONLY = { reduceOnly: {} };
28
28
  MarketStatus.SETTLEMENT = { settlement: {} };
29
29
  MarketStatus.DELISTED = { delisted: {} };
30
- class UserStatus {
31
- }
32
- exports.UserStatus = UserStatus;
33
- UserStatus.ACTIVE = { active: {} };
34
- UserStatus.BEING_LIQUIDATED = { beingLiquidated: {} };
35
- UserStatus.BANKRUPT = { bankrupt: {} };
36
- UserStatus.REDUCE_ONLY = { reduceOnly: {} };
30
+ var UserStatus;
31
+ (function (UserStatus) {
32
+ UserStatus[UserStatus["BEING_LIQUIDATED"] = 1] = "BEING_LIQUIDATED";
33
+ UserStatus[UserStatus["BANKRUPT"] = 2] = "BANKRUPT";
34
+ UserStatus[UserStatus["REDUCE_ONLY"] = 4] = "REDUCE_ONLY";
35
+ })(UserStatus = exports.UserStatus || (exports.UserStatus = {}));
37
36
  class ContractType {
38
37
  }
39
38
  exports.ContractType = ContractType;
package/lib/user.d.ts CHANGED
@@ -4,9 +4,9 @@ import { PublicKey } from '@solana/web3.js';
4
4
  import { EventEmitter } from 'events';
5
5
  import StrictEventEmitter from 'strict-event-emitter-types';
6
6
  import { DriftClient } from './driftClient';
7
- import { MarginCategory, Order, UserAccount, PerpPosition, SpotPosition, PerpMarketAccount, HealthComponents } from './types';
8
- import { UserAccountSubscriber, UserAccountEvents, DataAndSlot } from './accounts/types';
9
- import { PositionDirection, BN, SpotMarketAccount, MarketType } from '.';
7
+ import { HealthComponents, MarginCategory, Order, PerpMarketAccount, PerpPosition, SpotPosition, UserAccount } from './types';
8
+ import { DataAndSlot, UserAccountEvents, UserAccountSubscriber } from './accounts/types';
9
+ import { BN, MarketType, PositionDirection, SpotMarketAccount } from '.';
10
10
  import { OraclePriceData } from './oracles/types';
11
11
  import { UserConfig } from './userConfig';
12
12
  import { StrictOraclePrice } from './oracles/strictOraclePrice';
@@ -366,7 +366,7 @@ export declare class User {
366
366
  depositAmount: BN;
367
367
  maxDepositAmount: BN;
368
368
  };
369
- canMakeIdle(slot: BN, slotsBeforeIdle: BN): boolean;
369
+ canMakeIdle(slot: BN): boolean;
370
370
  getSafestTiers(): {
371
371
  perpTier: number;
372
372
  spotTier: number;