@drift-labs/sdk 2.146.0-beta.9 → 2.147.0-beta.1

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.
Files changed (57) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +8 -1
  3. package/lib/browser/adminClient.d.ts +3 -3
  4. package/lib/browser/adminClient.js +13 -17
  5. package/lib/browser/constants/numericConstants.d.ts +2 -0
  6. package/lib/browser/constants/numericConstants.js +5 -1
  7. package/lib/browser/constants/perpMarkets.d.ts +2 -1
  8. package/lib/browser/constants/perpMarkets.js +31 -1
  9. package/lib/browser/constants/spotMarkets.d.ts +2 -0
  10. package/lib/browser/constants/spotMarkets.js +21 -14
  11. package/lib/browser/driftClient.d.ts +22 -12
  12. package/lib/browser/driftClient.js +37 -25
  13. package/lib/browser/idl/drift.json +38 -251
  14. package/lib/browser/math/superStake.d.ts +1 -1
  15. package/lib/browser/math/superStake.js +1 -1
  16. package/lib/browser/swap/UnifiedSwapClient.d.ts +28 -3
  17. package/lib/browser/swap/UnifiedSwapClient.js +2 -2
  18. package/lib/browser/types.d.ts +3 -1
  19. package/lib/browser/types.js +1 -0
  20. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  21. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +8 -1
  22. package/lib/node/adminClient.d.ts +3 -3
  23. package/lib/node/adminClient.d.ts.map +1 -1
  24. package/lib/node/adminClient.js +13 -17
  25. package/lib/node/constants/numericConstants.d.ts +2 -0
  26. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  27. package/lib/node/constants/numericConstants.js +5 -1
  28. package/lib/node/constants/perpMarkets.d.ts +2 -1
  29. package/lib/node/constants/perpMarkets.d.ts.map +1 -1
  30. package/lib/node/constants/perpMarkets.js +31 -1
  31. package/lib/node/constants/spotMarkets.d.ts +2 -0
  32. package/lib/node/constants/spotMarkets.d.ts.map +1 -1
  33. package/lib/node/constants/spotMarkets.js +21 -14
  34. package/lib/node/driftClient.d.ts +22 -12
  35. package/lib/node/driftClient.d.ts.map +1 -1
  36. package/lib/node/driftClient.js +37 -25
  37. package/lib/node/idl/drift.json +38 -251
  38. package/lib/node/math/superStake.d.ts +1 -1
  39. package/lib/node/math/superStake.js +1 -1
  40. package/lib/node/swap/UnifiedSwapClient.d.ts +28 -3
  41. package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
  42. package/lib/node/swap/UnifiedSwapClient.js +2 -2
  43. package/lib/node/types.d.ts +3 -1
  44. package/lib/node/types.d.ts.map +1 -1
  45. package/lib/node/types.js +1 -0
  46. package/package.json +1 -1
  47. package/src/accounts/grpcMultiUserAccountSubscriber.ts +8 -1
  48. package/src/adminClient.ts +28 -30
  49. package/src/constants/numericConstants.ts +5 -0
  50. package/src/constants/perpMarkets.ts +33 -3
  51. package/src/constants/spotMarkets.ts +23 -14
  52. package/src/driftClient.ts +65 -36
  53. package/src/idl/drift.json +39 -252
  54. package/src/math/superStake.ts +1 -1
  55. package/src/swap/UnifiedSwapClient.ts +25 -3
  56. package/src/types.ts +2 -0
  57. package/tests/dlob/helpers.ts +3 -3
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.145.1",
2
+ "version": "2.146.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -2020,32 +2020,6 @@
2020
2020
  }
2021
2021
  ]
2022
2022
  },
2023
- {
2024
- "name": "updateUserFuelBonus",
2025
- "accounts": [
2026
- {
2027
- "name": "state",
2028
- "isMut": false,
2029
- "isSigner": false
2030
- },
2031
- {
2032
- "name": "authority",
2033
- "isMut": false,
2034
- "isSigner": true
2035
- },
2036
- {
2037
- "name": "user",
2038
- "isMut": true,
2039
- "isSigner": false
2040
- },
2041
- {
2042
- "name": "userStats",
2043
- "isMut": true,
2044
- "isSigner": false
2045
- }
2046
- ],
2047
- "args": []
2048
- },
2049
2023
  {
2050
2024
  "name": "updateUserStatsReferrerStatus",
2051
2025
  "accounts": [
@@ -4285,11 +4259,6 @@
4285
4259
  "isMut": true,
4286
4260
  "isSigner": false
4287
4261
  },
4288
- {
4289
- "name": "ammCache",
4290
- "isMut": true,
4291
- "isSigner": false
4292
- },
4293
4262
  {
4294
4263
  "name": "oracle",
4295
4264
  "isMut": false,
@@ -4454,7 +4423,7 @@
4454
4423
  "args": []
4455
4424
  },
4456
4425
  {
4457
- "name": "resizeAmmCache",
4426
+ "name": "addMarketToAmmCache",
4458
4427
  "accounts": [
4459
4428
  {
4460
4429
  "name": "admin",
@@ -4471,6 +4440,11 @@
4471
4440
  "isMut": true,
4472
4441
  "isSigner": false
4473
4442
  },
4443
+ {
4444
+ "name": "perpMarket",
4445
+ "isMut": false,
4446
+ "isSigner": false
4447
+ },
4474
4448
  {
4475
4449
  "name": "rent",
4476
4450
  "isMut": false,
@@ -4484,6 +4458,27 @@
4484
4458
  ],
4485
4459
  "args": []
4486
4460
  },
4461
+ {
4462
+ "name": "deleteAmmCache",
4463
+ "accounts": [
4464
+ {
4465
+ "name": "admin",
4466
+ "isMut": true,
4467
+ "isSigner": true
4468
+ },
4469
+ {
4470
+ "name": "state",
4471
+ "isMut": false,
4472
+ "isSigner": false
4473
+ },
4474
+ {
4475
+ "name": "ammCache",
4476
+ "isMut": true,
4477
+ "isSigner": false
4478
+ }
4479
+ ],
4480
+ "args": []
4481
+ },
4487
4482
  {
4488
4483
  "name": "updateInitialAmmCacheInfo",
4489
4484
  "accounts": [
@@ -6109,27 +6104,6 @@
6109
6104
  }
6110
6105
  ]
6111
6106
  },
6112
- {
6113
- "name": "updateLpCooldownTime",
6114
- "accounts": [
6115
- {
6116
- "name": "admin",
6117
- "isMut": false,
6118
- "isSigner": true
6119
- },
6120
- {
6121
- "name": "state",
6122
- "isMut": true,
6123
- "isSigner": false
6124
- }
6125
- ],
6126
- "args": [
6127
- {
6128
- "name": "lpCooldownTime",
6129
- "type": "u64"
6130
- }
6131
- ]
6132
- },
6133
6107
  {
6134
6108
  "name": "updatePerpFeeStructure",
6135
6109
  "accounts": [
@@ -6705,46 +6679,6 @@
6705
6679
  }
6706
6680
  ]
6707
6681
  },
6708
- {
6709
- "name": "updatePerpMarketFuel",
6710
- "accounts": [
6711
- {
6712
- "name": "admin",
6713
- "isMut": false,
6714
- "isSigner": true
6715
- },
6716
- {
6717
- "name": "state",
6718
- "isMut": false,
6719
- "isSigner": false
6720
- },
6721
- {
6722
- "name": "perpMarket",
6723
- "isMut": true,
6724
- "isSigner": false
6725
- }
6726
- ],
6727
- "args": [
6728
- {
6729
- "name": "fuelBoostTaker",
6730
- "type": {
6731
- "option": "u8"
6732
- }
6733
- },
6734
- {
6735
- "name": "fuelBoostMaker",
6736
- "type": {
6737
- "option": "u8"
6738
- }
6739
- },
6740
- {
6741
- "name": "fuelBoostPosition",
6742
- "type": {
6743
- "option": "u8"
6744
- }
6745
- }
6746
- ]
6747
- },
6748
6682
  {
6749
6683
  "name": "updatePerpMarketProtectedMakerParams",
6750
6684
  "accounts": [
@@ -6865,115 +6799,6 @@
6865
6799
  }
6866
6800
  ]
6867
6801
  },
6868
- {
6869
- "name": "updateSpotMarketFuel",
6870
- "accounts": [
6871
- {
6872
- "name": "admin",
6873
- "isMut": false,
6874
- "isSigner": true
6875
- },
6876
- {
6877
- "name": "state",
6878
- "isMut": false,
6879
- "isSigner": false
6880
- },
6881
- {
6882
- "name": "spotMarket",
6883
- "isMut": true,
6884
- "isSigner": false
6885
- }
6886
- ],
6887
- "args": [
6888
- {
6889
- "name": "fuelBoostDeposits",
6890
- "type": {
6891
- "option": "u8"
6892
- }
6893
- },
6894
- {
6895
- "name": "fuelBoostBorrows",
6896
- "type": {
6897
- "option": "u8"
6898
- }
6899
- },
6900
- {
6901
- "name": "fuelBoostTaker",
6902
- "type": {
6903
- "option": "u8"
6904
- }
6905
- },
6906
- {
6907
- "name": "fuelBoostMaker",
6908
- "type": {
6909
- "option": "u8"
6910
- }
6911
- },
6912
- {
6913
- "name": "fuelBoostInsurance",
6914
- "type": {
6915
- "option": "u8"
6916
- }
6917
- }
6918
- ]
6919
- },
6920
- {
6921
- "name": "initUserFuel",
6922
- "accounts": [
6923
- {
6924
- "name": "admin",
6925
- "isMut": false,
6926
- "isSigner": true
6927
- },
6928
- {
6929
- "name": "state",
6930
- "isMut": false,
6931
- "isSigner": false
6932
- },
6933
- {
6934
- "name": "user",
6935
- "isMut": true,
6936
- "isSigner": false
6937
- },
6938
- {
6939
- "name": "userStats",
6940
- "isMut": true,
6941
- "isSigner": false
6942
- }
6943
- ],
6944
- "args": [
6945
- {
6946
- "name": "fuelBoostDeposits",
6947
- "type": {
6948
- "option": "i32"
6949
- }
6950
- },
6951
- {
6952
- "name": "fuelBoostBorrows",
6953
- "type": {
6954
- "option": "u32"
6955
- }
6956
- },
6957
- {
6958
- "name": "fuelBoostTaker",
6959
- "type": {
6960
- "option": "u32"
6961
- }
6962
- },
6963
- {
6964
- "name": "fuelBoostMaker",
6965
- "type": {
6966
- "option": "u32"
6967
- }
6968
- },
6969
- {
6970
- "name": "fuelBoostInsurance",
6971
- "type": {
6972
- "option": "u32"
6973
- }
6974
- }
6975
- ]
6976
- },
6977
6802
  {
6978
6803
  "name": "updateAdmin",
6979
6804
  "accounts": [
@@ -6995,27 +6820,6 @@
6995
6820
  }
6996
6821
  ]
6997
6822
  },
6998
- {
6999
- "name": "updateWhitelistMint",
7000
- "accounts": [
7001
- {
7002
- "name": "admin",
7003
- "isMut": false,
7004
- "isSigner": true
7005
- },
7006
- {
7007
- "name": "state",
7008
- "isMut": true,
7009
- "isSigner": false
7010
- }
7011
- ],
7012
- "args": [
7013
- {
7014
- "name": "whitelistMint",
7015
- "type": "publicKey"
7016
- }
7017
- ]
7018
- },
7019
6823
  {
7020
6824
  "name": "updateDiscountMint",
7021
6825
  "accounts": [
@@ -8478,32 +8282,6 @@
8478
8282
  }
8479
8283
  ]
8480
8284
  },
8481
- {
8482
- "name": "resetAmmCache",
8483
- "accounts": [
8484
- {
8485
- "name": "admin",
8486
- "isMut": true,
8487
- "isSigner": true
8488
- },
8489
- {
8490
- "name": "state",
8491
- "isMut": false,
8492
- "isSigner": false
8493
- },
8494
- {
8495
- "name": "ammCache",
8496
- "isMut": true,
8497
- "isSigner": false
8498
- },
8499
- {
8500
- "name": "systemProgram",
8501
- "isMut": false,
8502
- "isSigner": false
8503
- }
8504
- ],
8505
- "args": []
8506
- },
8507
8285
  {
8508
8286
  "name": "lpPoolSwap",
8509
8287
  "accounts": [
@@ -12267,6 +12045,10 @@
12267
12045
  "name": "oracleSlot",
12268
12046
  "type": "u64"
12269
12047
  },
12048
+ {
12049
+ "name": "marketIndex",
12050
+ "type": "u16"
12051
+ },
12270
12052
  {
12271
12053
  "name": "oracleSource",
12272
12054
  "type": "u8"
@@ -12288,7 +12070,7 @@
12288
12070
  "type": {
12289
12071
  "array": [
12290
12072
  "u8",
12291
- 36
12073
+ 34
12292
12074
  ]
12293
12075
  }
12294
12076
  }
@@ -19777,6 +19559,11 @@
19777
19559
  "code": 6343,
19778
19560
  "name": "InvalidLpPoolId",
19779
19561
  "msg": "Invalid Lp Pool Id for Operation"
19562
+ },
19563
+ {
19564
+ "code": 6344,
19565
+ "name": "MarketIndexNotFoundAmmCache",
19566
+ "msg": "MarketIndexNotFoundAmmCache"
19780
19567
  }
19781
19568
  ]
19782
- }
19569
+ }
@@ -223,7 +223,7 @@ export async function findBestJitoSolSuperStakeIxs({
223
223
  }
224
224
 
225
225
  /**
226
- * Finds best Jupiter Swap instructions for a generic lstMint
226
+ * Finds best swap instructions for a generic lstMint
227
227
  *
228
228
  * Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
229
229
  */
@@ -20,7 +20,29 @@ import {
20
20
  export type SwapMode = 'ExactIn' | 'ExactOut';
21
21
  export type SwapClientType = 'jupiter' | 'titan';
22
22
 
23
- export type UnifiedQuoteResponse = JupiterQuoteResponse | TitanQuoteResponse;
23
+ /**
24
+ * Unified quote response interface that combines properties from both Jupiter and Titan
25
+ * This provides a consistent interface while allowing for provider-specific fields
26
+ */
27
+ export interface UnifiedQuoteResponse {
28
+ // Core properties available in both providers
29
+ inputMint: string;
30
+ inAmount: string;
31
+ outputMint: string;
32
+ outAmount: string;
33
+ swapMode: SwapMode;
34
+ slippageBps: number;
35
+ routePlan: Array<{ swapInfo: any; percent: number }>;
36
+
37
+ // Optional properties that may not be available in all providers
38
+ otherAmountThreshold?: string; // Jupiter has this, Titan doesn't
39
+ priceImpactPct?: string; // Jupiter provides this, Titan doesn't (we calculate it)
40
+ platformFee?: { amount?: string; feeBps?: number }; // Format varies between providers
41
+ contextSlot?: number;
42
+ timeTaken?: number;
43
+ error?: string;
44
+ errorCode?: string;
45
+ }
24
46
 
25
47
  export interface SwapQuoteParams {
26
48
  inputMint: PublicKey;
@@ -135,7 +157,7 @@ export class UnifiedSwapClient {
135
157
  ): Promise<SwapTransactionResult> {
136
158
  if (this.clientType === 'jupiter') {
137
159
  const jupiterClient = this.client as JupiterClient;
138
- // Cast the quote to Jupiter's QuoteResponse type
160
+ // Cast the quote to Jupiter's specific QuoteResponse type
139
161
  const jupiterParams = {
140
162
  ...params,
141
163
  quote: params.quote as JupiterQuoteResponse,
@@ -213,7 +235,7 @@ export class UnifiedSwapClient {
213
235
  }
214
236
 
215
237
  if (!finalQuote) {
216
- throw new Error("Could not fetch Jupiter's quote. Please try again.");
238
+ throw new Error('Could not fetch swap quote. Please try again.');
217
239
  }
218
240
 
219
241
  // Get swap transaction and extract instructions
package/src/types.ts CHANGED
@@ -54,6 +54,7 @@ export enum PerpOperation {
54
54
  SETTLE_PNL = 8,
55
55
  SETTLE_PNL_WITH_POSITION = 16,
56
56
  LIQUIDATION = 32,
57
+ SETTLE_REV_POOL = 64,
57
58
  }
58
59
 
59
60
  export enum SpotOperation {
@@ -1891,6 +1892,7 @@ export type CacheInfo = {
1891
1892
  oracleValidity: number;
1892
1893
  lpStatusForPerpMarket: number;
1893
1894
  ammPositionScalar: number;
1895
+ marketIndex: number;
1894
1896
  };
1895
1897
 
1896
1898
  export type AmmCache = {
@@ -672,9 +672,9 @@ export class MockUserMap implements UserMapInterface {
672
672
  });
673
673
  }
674
674
 
675
- public async subscribe(): Promise<void> { }
675
+ public async subscribe(): Promise<void> {}
676
676
 
677
- public async unsubscribe(): Promise<void> { }
677
+ public async unsubscribe(): Promise<void> {}
678
678
 
679
679
  public async addPubkey(userAccountPublicKey: PublicKey): Promise<void> {
680
680
  const user = new User({
@@ -733,7 +733,7 @@ export class MockUserMap implements UserMapInterface {
733
733
  );
734
734
  }
735
735
 
736
- public async updateWithOrderRecord(_record: OrderRecord): Promise<void> { }
736
+ public async updateWithOrderRecord(_record: OrderRecord): Promise<void> {}
737
737
 
738
738
  public values(): IterableIterator<User> {
739
739
  return this.userMap.values();