@drift-labs/sdk 2.49.0-beta.9 → 2.52.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.
Files changed (62) hide show
  1. package/VERSION +1 -1
  2. package/lib/accounts/{mockUserAccountSubscriber.d.ts → basicUserAccountSubscriber.d.ts} +2 -2
  3. package/lib/accounts/{mockUserAccountSubscriber.js → basicUserAccountSubscriber.js} +9 -6
  4. package/lib/adminClient.d.ts +1 -0
  5. package/lib/adminClient.js +8 -0
  6. package/lib/constants/perpMarkets.js +40 -0
  7. package/lib/constants/spotMarkets.js +10 -0
  8. package/lib/decode/user.d.ts +3 -0
  9. package/lib/decode/user.js +329 -0
  10. package/lib/driftClient.d.ts +5 -1
  11. package/lib/driftClient.js +28 -7
  12. package/lib/examples/loadDlob.js +10 -5
  13. package/lib/idl/drift.json +32 -2
  14. package/lib/index.d.ts +2 -1
  15. package/lib/index.js +2 -1
  16. package/lib/math/state.d.ts +5 -0
  17. package/lib/math/state.js +27 -0
  18. package/lib/math/superStake.d.ts +43 -0
  19. package/lib/math/superStake.js +64 -22
  20. package/lib/orderSubscriber/OrderSubscriber.d.ts +3 -0
  21. package/lib/orderSubscriber/OrderSubscriber.js +17 -3
  22. package/lib/orderSubscriber/WebsocketSubscription.d.ts +1 -1
  23. package/lib/orderSubscriber/WebsocketSubscription.js +8 -6
  24. package/lib/orderSubscriber/types.d.ts +4 -1
  25. package/lib/types.d.ts +2 -1
  26. package/lib/user.d.ts +2 -1
  27. package/lib/user.js +13 -5
  28. package/lib/userMap/PollingSubscription.d.ts +15 -0
  29. package/lib/userMap/PollingSubscription.js +28 -0
  30. package/lib/userMap/WebsocketSubscription.d.ts +23 -0
  31. package/lib/userMap/WebsocketSubscription.js +41 -0
  32. package/lib/userMap/userMap.d.ts +16 -18
  33. package/lib/userMap/userMap.js +73 -34
  34. package/lib/userMap/userMapConfig.d.ts +21 -0
  35. package/lib/userMap/userMapConfig.js +2 -0
  36. package/package.json +2 -1
  37. package/src/accounts/{mockUserAccountSubscriber.ts → basicUserAccountSubscriber.ts} +8 -6
  38. package/src/adminClient.ts +14 -0
  39. package/src/constants/perpMarkets.ts +40 -0
  40. package/src/constants/spotMarkets.ts +10 -0
  41. package/src/decode/user.ts +358 -0
  42. package/src/driftClient.ts +48 -7
  43. package/src/examples/loadDlob.ts +11 -6
  44. package/src/idl/drift.json +33 -3
  45. package/src/index.ts +2 -1
  46. package/src/math/state.ts +26 -0
  47. package/src/math/superStake.ts +108 -20
  48. package/src/orderSubscriber/OrderSubscriber.ts +33 -7
  49. package/src/orderSubscriber/WebsocketSubscription.ts +17 -16
  50. package/src/orderSubscriber/types.ts +15 -2
  51. package/src/types.ts +2 -1
  52. package/src/user.ts +19 -6
  53. package/src/userMap/PollingSubscription.ts +48 -0
  54. package/src/userMap/WebsocketSubscription.ts +76 -0
  55. package/src/userMap/userMap.ts +103 -70
  56. package/src/userMap/userMapConfig.ts +34 -0
  57. package/tests/amm/test.ts +6 -3
  58. package/tests/decode/test.ts +266 -0
  59. package/tests/decode/userAccountBufferStrings.ts +102 -0
  60. package/tests/dlob/helpers.ts +1 -0
  61. package/tests/dlob/test.ts +10 -8
  62. package/tests/user/helpers.ts +0 -1
@@ -581,6 +581,7 @@ export const mockStateAccount: StateAccount = {
581
581
  srmVault: PublicKey.default,
582
582
  whitelistMint: PublicKey.default,
583
583
  maxNumberOfSubAccounts: 0,
584
+ maxInitializeUserFee: 0,
584
585
  };
585
586
 
586
587
  export class MockUserMap implements UserMapInterface {
@@ -60,7 +60,6 @@ function insertOrderToDLOB(
60
60
  price,
61
61
  baseAssetAmount,
62
62
  baseAssetAmountFilled: new BN(0),
63
- quoteAssetAmount: new BN(0),
64
63
  quoteAssetAmountFilled: new BN(0),
65
64
  direction,
66
65
  reduceOnly: false,
@@ -111,7 +110,6 @@ function insertTriggerOrderToDLOB(
111
110
  price,
112
111
  baseAssetAmount,
113
112
  baseAssetAmountFilled: new BN(0),
114
- quoteAssetAmount: new BN(0),
115
113
  quoteAssetAmountFilled: new BN(0),
116
114
  direction,
117
115
  reduceOnly: false,
@@ -206,8 +204,8 @@ function printCrossedNodes(n: NodeToFill, slot: number) {
206
204
  for (const makerNode of n.makerNodes) {
207
205
  console.log(
208
206
  `makerNode: (mkt: ${isMarketOrder(
209
- makerNode.order
210
- )}, lim: ${isLimitOrder(makerNode.order)})`
207
+ makerNode.order!
208
+ )}, lim: ${isLimitOrder(makerNode.order!)})`
211
209
  );
212
210
  }
213
211
  }
@@ -2323,7 +2321,9 @@ describe('DLOB Perp Tests', () => {
2323
2321
  expect(nodesToFillBefore.length).to.equal(0);
2324
2322
 
2325
2323
  // post only bid crosses ask
2326
- const price = vAsk.add(vAsk.muln(makerRebateNumerator).divn(makerRebateDenominator));
2324
+ const price = vAsk.add(
2325
+ vAsk.muln(makerRebateNumerator).divn(makerRebateDenominator)
2326
+ );
2327
2327
  insertOrderToDLOB(
2328
2328
  dlob,
2329
2329
  user0.publicKey,
@@ -2415,7 +2415,9 @@ describe('DLOB Perp Tests', () => {
2415
2415
  expect(nodesToFillBefore.length).to.equal(0);
2416
2416
 
2417
2417
  // post only bid crosses ask
2418
- const price = vBid.sub(vAsk.muln(makerRebateNumerator).divn(makerRebateDenominator));
2418
+ const price = vBid.sub(
2419
+ vAsk.muln(makerRebateNumerator).divn(makerRebateDenominator)
2420
+ );
2419
2421
  insertOrderToDLOB(
2420
2422
  dlob,
2421
2423
  user0.publicKey,
@@ -2738,8 +2740,8 @@ describe('DLOB Perp Tests', () => {
2738
2740
  );
2739
2741
  expect(takingBids.length).to.equal(1);
2740
2742
  const triggerLimitBid = takingBids[0];
2741
- expect(isAuctionComplete(triggerLimitBid.order, slot)).to.equal(true);
2742
- expect(isRestingLimitOrder(triggerLimitBid.order, slot)).to.equal(false);
2743
+ expect(isAuctionComplete(triggerLimitBid.order!, slot)).to.equal(true);
2744
+ expect(isRestingLimitOrder(triggerLimitBid.order!, slot)).to.equal(false);
2743
2745
  });
2744
2746
 
2745
2747
  it('Test will return expired market orders to fill', () => {
@@ -26,7 +26,6 @@ export const mockOrder: Order = {
26
26
  price: ZERO,
27
27
  baseAssetAmount: ZERO,
28
28
  baseAssetAmountFilled: ZERO,
29
- quoteAssetAmount: ZERO,
30
29
  quoteAssetAmountFilled: ZERO,
31
30
  direction: PositionDirection.LONG,
32
31
  reduceOnly: false,