@velocity-exchange/sdk 0.0.1 → 0.0.3

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 (161) hide show
  1. package/README.md +5 -6
  2. package/bunfig.toml +3 -0
  3. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +4 -2
  4. package/lib/browser/auctionSubscriber/auctionSubscriber.js +9 -4
  5. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
  6. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  7. package/lib/browser/auctionSubscriber/types.d.ts +4 -2
  8. package/lib/browser/config.d.ts +3 -8
  9. package/lib/browser/config.js +14 -22
  10. package/lib/browser/constituentMap/constituentMap.d.ts +4 -2
  11. package/lib/browser/constituentMap/constituentMap.js +14 -10
  12. package/lib/browser/core/VelocityCore.d.ts +4 -0
  13. package/lib/browser/core/VelocityCore.js +3 -1
  14. package/lib/browser/dlob/DLOBSubscriber.d.ts +3 -1
  15. package/lib/browser/dlob/DLOBSubscriber.js +19 -10
  16. package/lib/browser/dlob/types.d.ts +3 -1
  17. package/lib/browser/idl/drift.d.ts +54 -1
  18. package/lib/browser/idl/drift.json +6046 -803
  19. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -1
  20. package/lib/browser/orderSubscriber/OrderSubscriber.js +19 -11
  21. package/lib/browser/orderSubscriber/types.d.ts +3 -1
  22. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +4 -2
  23. package/lib/browser/priorityFee/priorityFeeSubscriber.js +15 -11
  24. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
  25. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +18 -18
  26. package/lib/browser/priorityFee/types.d.ts +9 -5
  27. package/lib/browser/priorityFee/types.js +1 -1
  28. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
  29. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
  30. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
  31. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +10 -5
  32. package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -4
  33. package/lib/browser/swift/swiftOrderSubscriber.js +19 -11
  34. package/lib/browser/user.d.ts +3 -1
  35. package/lib/browser/user.js +93 -86
  36. package/lib/browser/userConfig.d.ts +4 -2
  37. package/lib/browser/userMap/referrerMap.d.ts +5 -3
  38. package/lib/browser/userMap/referrerMap.js +18 -14
  39. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +5 -3
  40. package/lib/browser/userMap/revenueShareEscrowMap.js +18 -14
  41. package/lib/browser/userMap/userMap.d.ts +3 -1
  42. package/lib/browser/userMap/userMap.js +24 -19
  43. package/lib/browser/userMap/userMapConfig.d.ts +4 -2
  44. package/lib/browser/userMap/userStatsMap.d.ts +5 -3
  45. package/lib/browser/userMap/userStatsMap.js +15 -11
  46. package/lib/browser/userStats.d.ts +3 -1
  47. package/lib/browser/userStats.js +21 -15
  48. package/lib/browser/userStatsConfig.d.ts +4 -2
  49. package/lib/browser/util/deprecatedAlias.d.ts +26 -0
  50. package/lib/browser/util/deprecatedAlias.js +10 -0
  51. package/lib/browser/velocityClient.js +5 -5
  52. package/lib/browser/velocityClientConfig.d.ts +7 -4
  53. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +4 -2
  54. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  55. package/lib/node/auctionSubscriber/auctionSubscriber.js +9 -4
  56. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
  57. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  58. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  59. package/lib/node/auctionSubscriber/types.d.ts +4 -2
  60. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  61. package/lib/node/config.d.ts +3 -8
  62. package/lib/node/config.d.ts.map +1 -1
  63. package/lib/node/config.js +14 -22
  64. package/lib/node/constituentMap/constituentMap.d.ts +4 -2
  65. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  66. package/lib/node/constituentMap/constituentMap.js +14 -10
  67. package/lib/node/core/VelocityCore.d.ts +4 -0
  68. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  69. package/lib/node/core/VelocityCore.js +3 -1
  70. package/lib/node/dlob/DLOBSubscriber.d.ts +3 -1
  71. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  72. package/lib/node/dlob/DLOBSubscriber.js +19 -10
  73. package/lib/node/dlob/types.d.ts +3 -1
  74. package/lib/node/dlob/types.d.ts.map +1 -1
  75. package/lib/node/idl/drift.d.ts +54 -1
  76. package/lib/node/idl/drift.d.ts.map +1 -1
  77. package/lib/node/idl/drift.json +6046 -803
  78. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +3 -1
  79. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  80. package/lib/node/orderSubscriber/OrderSubscriber.js +19 -11
  81. package/lib/node/orderSubscriber/types.d.ts +3 -1
  82. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  83. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +4 -2
  84. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  85. package/lib/node/priorityFee/priorityFeeSubscriber.js +15 -11
  86. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
  87. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  88. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +18 -18
  89. package/lib/node/priorityFee/types.d.ts +9 -5
  90. package/lib/node/priorityFee/types.d.ts.map +1 -1
  91. package/lib/node/priorityFee/types.js +1 -1
  92. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
  93. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
  94. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
  95. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
  96. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  97. package/lib/node/swift/signedMsgUserAccountSubscriber.js +10 -5
  98. package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -4
  99. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  100. package/lib/node/swift/swiftOrderSubscriber.js +19 -11
  101. package/lib/node/user.d.ts +3 -1
  102. package/lib/node/user.d.ts.map +1 -1
  103. package/lib/node/user.js +93 -86
  104. package/lib/node/userConfig.d.ts +4 -2
  105. package/lib/node/userConfig.d.ts.map +1 -1
  106. package/lib/node/userMap/referrerMap.d.ts +5 -3
  107. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  108. package/lib/node/userMap/referrerMap.js +18 -14
  109. package/lib/node/userMap/revenueShareEscrowMap.d.ts +5 -3
  110. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  111. package/lib/node/userMap/revenueShareEscrowMap.js +18 -14
  112. package/lib/node/userMap/userMap.d.ts +3 -1
  113. package/lib/node/userMap/userMap.d.ts.map +1 -1
  114. package/lib/node/userMap/userMap.js +24 -19
  115. package/lib/node/userMap/userMapConfig.d.ts +4 -2
  116. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  117. package/lib/node/userMap/userStatsMap.d.ts +5 -3
  118. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  119. package/lib/node/userMap/userStatsMap.js +15 -11
  120. package/lib/node/userStats.d.ts +3 -1
  121. package/lib/node/userStats.d.ts.map +1 -1
  122. package/lib/node/userStats.js +21 -15
  123. package/lib/node/userStatsConfig.d.ts +4 -2
  124. package/lib/node/userStatsConfig.d.ts.map +1 -1
  125. package/lib/node/util/deprecatedAlias.d.ts +27 -0
  126. package/lib/node/util/deprecatedAlias.d.ts.map +1 -0
  127. package/lib/node/util/deprecatedAlias.js +10 -0
  128. package/lib/node/velocityClient.js +5 -5
  129. package/lib/node/velocityClientConfig.d.ts +7 -4
  130. package/lib/node/velocityClientConfig.d.ts.map +1 -1
  131. package/package.json +2 -3
  132. package/src/auctionSubscriber/auctionSubscriber.ts +12 -6
  133. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -6
  134. package/src/auctionSubscriber/types.ts +5 -2
  135. package/src/config.ts +35 -27
  136. package/src/constituentMap/constituentMap.ts +17 -9
  137. package/src/core/VelocityCore.ts +6 -0
  138. package/src/dlob/DLOBSubscriber.ts +21 -11
  139. package/src/dlob/types.ts +3 -1
  140. package/src/idl/drift.json +23940 -18697
  141. package/src/idl/drift.ts +54 -1
  142. package/src/orderSubscriber/OrderSubscriber.ts +17 -7
  143. package/src/orderSubscriber/types.ts +3 -1
  144. package/src/priorityFee/priorityFeeSubscriber.ts +13 -9
  145. package/src/priorityFee/priorityFeeSubscriberMap.ts +23 -25
  146. package/src/priorityFee/types.ts +14 -9
  147. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +10 -23
  148. package/src/swift/signedMsgUserAccountSubscriber.ts +22 -14
  149. package/src/swift/swiftOrderSubscriber.ts +24 -16
  150. package/src/user.ts +93 -82
  151. package/src/userConfig.ts +5 -2
  152. package/src/userMap/referrerMap.ts +19 -15
  153. package/src/userMap/revenueShareEscrowMap.ts +20 -16
  154. package/src/userMap/userMap.ts +20 -15
  155. package/src/userMap/userMapConfig.ts +6 -3
  156. package/src/userMap/userStatsMap.ts +19 -15
  157. package/src/userStats.ts +13 -7
  158. package/src/userStatsConfig.ts +5 -2
  159. package/src/util/deprecatedAlias.ts +25 -0
  160. package/src/velocityClient.ts +6 -6
  161. package/src/velocityClientConfig.ts +25 -42
@@ -13,7 +13,9 @@ import StrictEventEmitter from 'strict-event-emitter-types';
13
13
  import { EventEmitter } from 'events';
14
14
  import { grpcSubscription } from './grpcSubscription';
15
15
  export declare class OrderSubscriber {
16
- driftClient: VelocityClient;
16
+ velocityClient: VelocityClient;
17
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
18
+ get driftClient(): VelocityClient;
17
19
  usersAccounts: Map<string, {
18
20
  slot: number;
19
21
  userAccount: UserAccount;
@@ -1 +1 @@
1
- {"version":3,"file":"OrderSubscriber.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/OrderSubscriber.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAMvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAyB,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,qBAAa,eAAe;IAC3B,WAAW,EAAE,cAAc,CAAC;IAC5B,aAAa;cAA2B,MAAM;qBAAe,WAAW;OAAM;IAC9E,YAAY,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;IAC7E,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IAEtE,YAAY,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,oBAAoB,EAAE,MAAM,IAAI,CAAC;IAEjC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAA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C,OAAO,IAAI,MAAM;IAIX,SAAS,CAAC,oBAAoB,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOrD,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAIzC"}
@@ -14,10 +14,18 @@ const grpcSubscription_1 = require("./grpcSubscription");
14
14
  const orders_1 = require("../math/orders");
15
15
  const numericConstants_1 = require("../constants/numericConstants");
16
16
  class OrderSubscriber {
17
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
18
+ get driftClient() {
19
+ return this.velocityClient;
20
+ }
17
21
  constructor(config) {
18
- var _a, _b, _c, _d, _e;
22
+ var _a, _b, _c, _d, _e, _f;
19
23
  this.usersAccounts = new Map();
20
- this.driftClient = config.driftClient;
24
+ const velocityClient = (_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient;
25
+ if (!velocityClient) {
26
+ throw new Error('OrderSubscriber: velocityClient (or deprecated driftClient) must be provided');
27
+ }
28
+ this.velocityClient = velocityClient;
21
29
  this.commitment = config.subscriptionConfig.commitment || 'processed';
22
30
  if (config.subscriptionConfig.type === 'polling') {
23
31
  this.subscription = new PollingSubscription_1.PollingSubscription({
@@ -31,8 +39,8 @@ class OrderSubscriber {
31
39
  grpcConfigs: config.subscriptionConfig.grpcConfigs,
32
40
  skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
33
41
  resubOpts: {
34
- resubTimeoutMs: (_a = config.subscriptionConfig) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs,
35
- logResubMessages: (_b = config.subscriptionConfig) === null || _b === void 0 ? void 0 : _b.logResubMessages,
42
+ resubTimeoutMs: (_b = config.subscriptionConfig) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs,
43
+ logResubMessages: (_c = config.subscriptionConfig) === null || _c === void 0 ? void 0 : _c.logResubMessages,
36
44
  },
37
45
  resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
38
46
  decoded: config.decodeData,
@@ -44,18 +52,18 @@ class OrderSubscriber {
44
52
  commitment: this.commitment,
45
53
  skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
46
54
  resubOpts: {
47
- resubTimeoutMs: (_c = config.subscriptionConfig) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs,
48
- logResubMessages: (_d = config.subscriptionConfig) === null || _d === void 0 ? void 0 : _d.logResubMessages,
55
+ resubTimeoutMs: (_d = config.subscriptionConfig) === null || _d === void 0 ? void 0 : _d.resubTimeoutMs,
56
+ logResubMessages: (_e = config.subscriptionConfig) === null || _e === void 0 ? void 0 : _e.logResubMessages,
49
57
  },
50
58
  resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
51
59
  decoded: config.decodeData,
52
60
  });
53
61
  }
54
- if ((_e = config.fastDecode) !== null && _e !== void 0 ? _e : true) {
62
+ if ((_f = config.fastDecode) !== null && _f !== void 0 ? _f : true) {
55
63
  this.decodeFn = (name, data) => (0, user_1.decodeUser)(data);
56
64
  }
57
65
  else {
58
- this.decodeFn = this.driftClient.program.account.user.coder.accounts.decodeUnchecked.bind(this.driftClient.program.account.user.coder.accounts);
66
+ this.decodeFn = this.velocityClient.program.account.user.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.user.coder.accounts);
59
67
  }
60
68
  this.eventEmitter = new events_1.EventEmitter();
61
69
  this.fetchAllNonIdleUsers = config.fetchAllNonIdleUsers;
@@ -75,7 +83,7 @@ class OrderSubscriber {
75
83
  : [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithOrderFilter)()];
76
84
  try {
77
85
  const rpcRequestArgs = [
78
- this.driftClient.program.programId.toBase58(),
86
+ this.velocityClient.program.programId.toBase58(),
79
87
  {
80
88
  commitment: this.commitment,
81
89
  filters,
@@ -85,7 +93,7 @@ class OrderSubscriber {
85
93
  ];
86
94
  const rpcJSONResponse =
87
95
  // @ts-ignore
88
- await this.driftClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
96
+ await this.velocityClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
89
97
  const rpcResponseAndContext = rpcJSONResponse.result;
90
98
  const slot = rpcResponseAndContext.context.slot;
91
99
  for (const programAccount of rpcResponseAndContext.value) {
@@ -174,7 +182,7 @@ class OrderSubscriber {
174
182
  return (_a = this.mostRecentSlot) !== null && _a !== void 0 ? _a : 0;
175
183
  }
176
184
  async addPubkey(userAccountPublicKey) {
177
- const accountInfo = await this.driftClient.connection.getAccountInfoAndContext(userAccountPublicKey, this.commitment);
185
+ const accountInfo = await this.velocityClient.connection.getAccountInfoAndContext(userAccountPublicKey, this.commitment);
178
186
  if (accountInfo) {
179
187
  this.tryUpdateUserAccount(userAccountPublicKey.toString(), 'buffer', accountInfo.value.data, accountInfo.context.slot);
180
188
  }
@@ -3,7 +3,9 @@ import { Order, UserAccount } from '../types';
3
3
  import { VelocityClient } from '../velocityClient';
4
4
  import { GrpcConfigs } from '../accounts/types';
5
5
  export type OrderSubscriberConfig = {
6
- driftClient: VelocityClient;
6
+ velocityClient?: VelocityClient;
7
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
+ driftClient?: VelocityClient;
7
9
  subscriptionConfig: {
8
10
  type: 'polling';
9
11
  frequency: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IACnC,WAAW,EAAE,cAAc,CAAC;IAC5B,kBAAkB,EACf;QACA,IAAI,EAAE,SA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EACtB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,KAClC,IAAI,CAAC;IACV,WAAW,EAAE,CACZ,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,KAClC,IAAI,CAAC;IACV,cAAc,EAAE,CACf,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,KAClC,IAAI,CAAC;CACV"}
@@ -8,7 +8,9 @@ export declare class PriorityFeeSubscriber {
8
8
  connection: Connection;
9
9
  frequencyMs: number;
10
10
  addresses: string[];
11
- driftMarkets?: VelocityMarketInfo[];
11
+ velocityMarkets?: VelocityMarketInfo[];
12
+ /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
13
+ get driftMarkets(): VelocityMarketInfo[] | undefined;
12
14
  customStrategy?: PriorityFeeStrategy;
13
15
  averageStrategy: AverageOverSlotsStrategy;
14
16
  maxStrategy: MaxOverSlotsStrategy;
@@ -44,6 +46,6 @@ export declare class PriorityFeeSubscriber {
44
46
  load(): Promise<void>;
45
47
  unsubscribe(): Promise<void>;
46
48
  updateAddresses(addresses: PublicKey[]): void;
47
- updateMarketTypeAndIndex(driftMarkets: VelocityMarketInfo[]): void;
49
+ updateMarketTypeAndIndex(velocityMarkets: VelocityMarketInfo[]): void;
48
50
  }
49
51
  //# sourceMappingURL=priorityFeeSubscriber.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"priorityFeeSubscriber.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/priorityFeeSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAEN,iBAAiB,EACjB,mBAAmB,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CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2HAA2H;IAC3H,IAAW,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAExD;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAE3C,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAE3C,iBAAiB,SAAK;IACtB,wBAAwB,SAAK;IAC7B,qBAAqB,SAAK;IAC1B,qBAAqB,SAAK;IAC1B,YAAY,SAAK;gBAEE,MAAM,EAAE,2BAA2B;IAiDzC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;YASzB,aAAa;YAkBb,aAAa;YAmBb,YAAY;IAkBnB,iBAAiB,IAAI,MAAM,GAAG,SAAS;IAIvC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAIlD,wBAAwB,IAAI,MAAM;IAIlC,2BAA2B,CAAC,wBAAwB,EAAE,MAAM;IAI5D,oBAAoB,CAAC,WAAW,EAAE,mBAAmB;IAIrD,yBAAyB,CAC/B,KAAK,GAAE,mBAAgD,GACrD,MAAM;IAUF,uBAAuB,IAAI,MAAM;IASjC,oBAAoB,IAAI,MAAM;IAQ9B,oBAAoB,IAAI,MAAM;IAQxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBrB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE;IAItC,wBAAwB,CAAC,eAAe,EAAE,kBAAkB,EAAE;CAGrE"}
@@ -8,12 +8,16 @@ const solanaPriorityFeeMethod_1 = require("./solanaPriorityFeeMethod");
8
8
  const heliusPriorityFeeMethod_1 = require("./heliusPriorityFeeMethod");
9
9
  const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
10
10
  class PriorityFeeSubscriber {
11
+ /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
12
+ get driftMarkets() {
13
+ return this.velocityMarkets;
14
+ }
11
15
  /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
12
16
  get driftPriorityFeeEndpoint() {
13
17
  return this.velocityPriorityFeeEndpoint;
14
18
  }
15
19
  constructor(config) {
16
- var _a, _b, _c, _d;
20
+ var _a, _b, _c, _d, _e;
17
21
  this.averageStrategy = new averageOverSlotsStrategy_1.AverageOverSlotsStrategy();
18
22
  this.maxStrategy = new maxOverSlotsStrategy_1.MaxOverSlotsStrategy();
19
23
  this.priorityFeeMethod = types_1.PriorityFeeMethod.SOLANA;
@@ -28,14 +32,14 @@ class PriorityFeeSubscriber {
28
32
  this.addresses = config.addresses
29
33
  ? config.addresses.map((address) => address.toBase58())
30
34
  : [];
31
- this.driftMarkets = config.driftMarkets;
35
+ this.velocityMarkets = (_b = config.velocityMarkets) !== null && _b !== void 0 ? _b : config.driftMarkets;
32
36
  if (config.customStrategy) {
33
37
  this.customStrategy = config.customStrategy;
34
38
  }
35
39
  else {
36
40
  this.customStrategy = this.averageStrategy;
37
41
  }
38
- this.lookbackDistance = (_b = config.slotsToCheck) !== null && _b !== void 0 ? _b : 50;
42
+ this.lookbackDistance = (_c = config.slotsToCheck) !== null && _c !== void 0 ? _c : 50;
39
43
  if (config.priorityFeeMethod) {
40
44
  this.priorityFeeMethod = config.priorityFeeMethod;
41
45
  if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
@@ -51,9 +55,9 @@ class PriorityFeeSubscriber {
51
55
  this.heliusRpcUrl = config.heliusRpcUrl;
52
56
  }
53
57
  }
54
- else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.DRIFT) {
58
+ else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
55
59
  this.velocityPriorityFeeEndpoint =
56
- (_c = config.velocityPriorityFeeEndpoint) !== null && _c !== void 0 ? _c : config.driftPriorityFeeEndpoint;
60
+ (_d = config.velocityPriorityFeeEndpoint) !== null && _d !== void 0 ? _d : config.driftPriorityFeeEndpoint;
57
61
  }
58
62
  }
59
63
  if (this.priorityFeeMethod === types_1.PriorityFeeMethod.SOLANA) {
@@ -62,7 +66,7 @@ class PriorityFeeSubscriber {
62
66
  }
63
67
  }
64
68
  this.maxFeeMicroLamports = config.maxFeeMicroLamports;
65
- this.priorityFeeMultiplier = (_d = config.priorityFeeMultiplier) !== null && _d !== void 0 ? _d : 1.0;
69
+ this.priorityFeeMultiplier = (_e = config.priorityFeeMultiplier) !== null && _e !== void 0 ? _e : 1.0;
66
70
  }
67
71
  async subscribe() {
68
72
  if (this.intervalId) {
@@ -98,10 +102,10 @@ class PriorityFeeSubscriber {
98
102
  }
99
103
  }
100
104
  async loadForDrift() {
101
- if (!this.driftMarkets) {
105
+ if (!this.velocityMarkets) {
102
106
  return;
103
107
  }
104
- const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.driftMarkets.map((m) => m.marketType), this.driftMarkets.map((m) => m.marketIndex));
108
+ const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
105
109
  if (sample.length > 0) {
106
110
  this.lastAvgStrategyResult = sample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM];
107
111
  this.lastMaxStrategyResult = sample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.UNSAFE_MAX];
@@ -164,7 +168,7 @@ class PriorityFeeSubscriber {
164
168
  else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
165
169
  await this.loadForHelius();
166
170
  }
167
- else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.DRIFT) {
171
+ else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
168
172
  await this.loadForDrift();
169
173
  }
170
174
  else {
@@ -186,8 +190,8 @@ class PriorityFeeSubscriber {
186
190
  updateAddresses(addresses) {
187
191
  this.addresses = addresses.map((k) => k.toBase58());
188
192
  }
189
- updateMarketTypeAndIndex(driftMarkets) {
190
- this.driftMarkets = driftMarkets;
193
+ updateMarketTypeAndIndex(velocityMarkets) {
194
+ this.velocityMarkets = velocityMarkets;
191
195
  }
192
196
  }
193
197
  exports.PriorityFeeSubscriber = PriorityFeeSubscriber;
@@ -1,42 +1,44 @@
1
1
  import { VelocityMarketInfo, VelocityPriorityFeeLevels } from './velocityPriorityFeeMethod';
2
2
  import { PriorityFeeSubscriberMapConfig } from './types';
3
3
  /**
4
- * takes advantage of /batchPriorityFees endpoint from drift hosted priority fee service
4
+ * takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
5
5
  */
6
6
  export declare class PriorityFeeSubscriberMap {
7
7
  frequencyMs: number;
8
8
  intervalId?: ReturnType<typeof setTimeout>;
9
- driftMarkets?: VelocityMarketInfo[];
10
- velocityPriorityFeeEndpoint?: string;
9
+ velocityMarkets?: VelocityMarketInfo[];
10
+ /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
11
+ get driftMarkets(): VelocityMarketInfo[] | undefined;
12
+ velocityPriorityFeeEndpoint: string;
11
13
  /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
12
- get driftPriorityFeeEndpoint(): string | undefined;
14
+ get driftPriorityFeeEndpoint(): string;
13
15
  feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>;
14
16
  constructor(config: PriorityFeeSubscriberMapConfig);
15
17
  private updateFeesMap;
16
18
  subscribe(): Promise<void>;
17
19
  unsubscribe(): Promise<void>;
18
20
  load(): Promise<void>;
19
- updateMarketTypeAndIndex(driftMarkets: VelocityMarketInfo[]): void;
21
+ updateMarketTypeAndIndex(velocityMarkets: VelocityMarketInfo[]): void;
20
22
  getPriorityFees(marketType: string, marketIndex: number): VelocityPriorityFeeLevels | undefined;
21
23
  }
22
24
  /** Example usage:
23
25
  async function main() {
24
- const driftMarkets: VelocityMarketInfo[] = [
26
+ const velocityMarkets: VelocityMarketInfo[] = [
25
27
  { marketType: 'perp', marketIndex: 0 },
26
28
  { marketType: 'perp', marketIndex: 1 },
27
29
  { marketType: 'spot', marketIndex: 2 }
28
30
  ];
29
31
 
30
32
  const subscriber = new PriorityFeeSubscriberMap({
31
- velocityPriorityFeeEndpoint: 'https://dlob.drift.trade',
33
+ velocityPriorityFeeEndpoint: 'https://dlob.velocity.trade',
32
34
  frequencyMs: 5000,
33
- driftMarkets
35
+ velocityMarkets
34
36
  });
35
37
  await subscriber.subscribe();
36
38
 
37
39
  for (let i = 0; i < 20; i++) {
38
40
  await new Promise(resolve => setTimeout(resolve, 1000));
39
- driftMarkets.forEach(market => {
41
+ velocityMarkets.forEach(market => {
40
42
  const fees = subscriber.getPriorityFees(market.marketType, market.marketIndex);
41
43
  console.log(`Priority fees for ${market.marketType} market ${market.marketIndex}:`, fees);
42
44
  });
@@ -1 +1 @@
1
- {"version":3,"file":"priorityFeeSubscriberMap.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/priorityFeeSubscriberMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EAGzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEN,8BAA8B,EAC9B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,wBAAwB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAE3C,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACpC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2HAA2H;IAC3H,IAAW,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAExD;IACD,OAAO,EAAE,GAAG,CAAC,M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,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,wBAAwB,CAAC,eAAe,EAAE,kBAAkB,EAAE;IAI9D,eAAe,CACrB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GACjB,yBAAyB,GAAG,SAAS;CAGxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BE"}
@@ -4,24 +4,24 @@ exports.PriorityFeeSubscriberMap = void 0;
4
4
  const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
5
5
  const types_1 = require("./types");
6
6
  /**
7
- * takes advantage of /batchPriorityFees endpoint from drift hosted priority fee service
7
+ * takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
8
8
  */
9
9
  class PriorityFeeSubscriberMap {
10
+ /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
11
+ get driftMarkets() {
12
+ return this.velocityMarkets;
13
+ }
10
14
  /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
11
15
  get driftPriorityFeeEndpoint() {
12
16
  return this.velocityPriorityFeeEndpoint;
13
17
  }
14
18
  constructor(config) {
15
- var _a, _b;
16
- this.frequencyMs = config.frequencyMs;
19
+ var _a, _b, _c;
17
20
  this.frequencyMs =
18
21
  (_a = config.frequencyMs) !== null && _a !== void 0 ? _a : types_1.DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
19
- const endpoint = (_b = config.velocityPriorityFeeEndpoint) !== null && _b !== void 0 ? _b : config.driftPriorityFeeEndpoint;
20
- if (!endpoint) {
21
- throw new Error('PriorityFeeSubscriberMap: velocityPriorityFeeEndpoint (or deprecated driftPriorityFeeEndpoint) must be provided');
22
- }
23
- this.velocityPriorityFeeEndpoint = endpoint;
24
- this.driftMarkets = config.driftMarkets;
22
+ // Type-system guarantees at least one of the two is supplied.
23
+ this.velocityPriorityFeeEndpoint = ((_b = config.velocityPriorityFeeEndpoint) !== null && _b !== void 0 ? _b : config.driftPriorityFeeEndpoint);
24
+ this.velocityMarkets = (_c = config.velocityMarkets) !== null && _c !== void 0 ? _c : config.driftMarkets;
25
25
  this.feesMap = new Map();
26
26
  this.feesMap.set('perp', new Map());
27
27
  this.feesMap.set('spot', new Map());
@@ -46,18 +46,18 @@ class PriorityFeeSubscriberMap {
46
46
  }
47
47
  async load() {
48
48
  try {
49
- if (!this.driftMarkets) {
49
+ if (!this.velocityMarkets) {
50
50
  return;
51
51
  }
52
- const fees = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.driftMarkets.map((m) => m.marketType), this.driftMarkets.map((m) => m.marketIndex));
52
+ const fees = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
53
53
  this.updateFeesMap(fees);
54
54
  }
55
55
  catch (e) {
56
- console.error('Error fetching drift priority fees', e);
56
+ console.error('Error fetching priority fees', e);
57
57
  }
58
58
  }
59
- updateMarketTypeAndIndex(driftMarkets) {
60
- this.driftMarkets = driftMarkets;
59
+ updateMarketTypeAndIndex(velocityMarkets) {
60
+ this.velocityMarkets = velocityMarkets;
61
61
  }
62
62
  getPriorityFees(marketType, marketIndex) {
63
63
  var _a;
@@ -67,22 +67,22 @@ class PriorityFeeSubscriberMap {
67
67
  exports.PriorityFeeSubscriberMap = PriorityFeeSubscriberMap;
68
68
  /** Example usage:
69
69
  async function main() {
70
- const driftMarkets: VelocityMarketInfo[] = [
70
+ const velocityMarkets: VelocityMarketInfo[] = [
71
71
  { marketType: 'perp', marketIndex: 0 },
72
72
  { marketType: 'perp', marketIndex: 1 },
73
73
  { marketType: 'spot', marketIndex: 2 }
74
74
  ];
75
75
 
76
76
  const subscriber = new PriorityFeeSubscriberMap({
77
- velocityPriorityFeeEndpoint: 'https://dlob.drift.trade',
77
+ velocityPriorityFeeEndpoint: 'https://dlob.velocity.trade',
78
78
  frequencyMs: 5000,
79
- driftMarkets
79
+ velocityMarkets
80
80
  });
81
81
  await subscriber.subscribe();
82
82
 
83
83
  for (let i = 0; i < 20; i++) {
84
84
  await new Promise(resolve => setTimeout(resolve, 1000));
85
- driftMarkets.forEach(market => {
85
+ velocityMarkets.forEach(market => {
86
86
  const fees = subscriber.getPriorityFees(market.marketType, market.marketIndex);
87
87
  console.log(`Priority fees for ${market.marketType} market ${market.marketIndex}:`, fees);
88
88
  });
@@ -2,6 +2,7 @@ import { Connection, PublicKey } from '@solana/web3.js';
2
2
  import { SolanaPriorityFeeResponse } from './solanaPriorityFeeMethod';
3
3
  import { HeliusPriorityFeeResponse } from './heliusPriorityFeeMethod';
4
4
  import { VelocityMarketInfo, VelocityPriorityFeeResponse } from './velocityPriorityFeeMethod';
5
+ import { AtLeastOne } from '../util/deprecatedAlias';
5
6
  export declare const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10000;
6
7
  export interface PriorityFeeStrategy {
7
8
  calculate(samples: SolanaPriorityFeeResponse[] | HeliusPriorityFeeResponse | VelocityPriorityFeeResponse): number;
@@ -9,12 +10,14 @@ export interface PriorityFeeStrategy {
9
10
  export declare enum PriorityFeeMethod {
10
11
  SOLANA = "solana",
11
12
  HELIUS = "helius",
12
- DRIFT = "drift"
13
+ VELOCITY = "velocity"
13
14
  }
14
15
  export type PriorityFeeSubscriberConfig = {
15
16
  connection?: Connection;
16
17
  frequencyMs?: number;
17
18
  addresses?: PublicKey[];
19
+ velocityMarkets?: VelocityMarketInfo[];
20
+ /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
18
21
  driftMarkets?: VelocityMarketInfo[];
19
22
  customStrategy?: PriorityFeeStrategy;
20
23
  priorityFeeMethod?: PriorityFeeMethod;
@@ -26,11 +29,12 @@ export type PriorityFeeSubscriberConfig = {
26
29
  maxFeeMicroLamports?: number;
27
30
  priorityFeeMultiplier?: number;
28
31
  };
29
- export type PriorityFeeSubscriberMapConfig = {
32
+ type PriorityFeeSubscriberMapConfigBase = {
30
33
  frequencyMs?: number;
34
+ velocityMarkets?: VelocityMarketInfo[];
35
+ /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
31
36
  driftMarkets?: VelocityMarketInfo[];
32
- velocityPriorityFeeEndpoint?: string;
33
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
34
- driftPriorityFeeEndpoint?: string;
35
37
  };
38
+ export type PriorityFeeSubscriberMapConfig = PriorityFeeSubscriberMapConfigBase & AtLeastOne<'velocityPriorityFeeEndpoint', 'driftPriorityFeeEndpoint', string>;
39
+ export {};
36
40
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,qCAAqC,QAAS,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAGnC,SAAS,CACR,OAAO,EACJ,yBAAyB,EAAE,GAC3B,yBAAyB,GACzB,2BAA2B,GAC5B,MAAM,CAAC;CACV;AAED,oBAAY,iBAAiB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,KAAK,UAAU;CACf;AAED,MAAM,MAAM,2BAA2B,GAAG;IAEzC,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IAExB,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEpC,cAAc,CA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AAW,CAAC,EAAE,MAAM,CAAC;IAErB,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IAExB,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,mGAAmG;IACnG,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEpC,cAAc,CAAC,EAAE,mBAAmB,CAAC;IAErC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2HAA2H;IAC3H,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,KAAK,kCAAkC,GAAG;IAEzC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,mGAAmG;IACnG,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACpC,CAAC;AAGF,MAAM,MAAM,8BAA8B,GAAG,kCAAkC,GAC9E,UAAU,CAAC,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC"}
@@ -6,5 +6,5 @@ var PriorityFeeMethod;
6
6
  (function (PriorityFeeMethod) {
7
7
  PriorityFeeMethod["SOLANA"] = "solana";
8
8
  PriorityFeeMethod["HELIUS"] = "helius";
9
- PriorityFeeMethod["DRIFT"] = "drift";
9
+ PriorityFeeMethod["VELOCITY"] = "velocity";
10
10
  })(PriorityFeeMethod || (exports.PriorityFeeMethod = PriorityFeeMethod = {}));
@@ -1,21 +1,12 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Commitment } from '@solana/web3.js';
4
1
  import { grpcProgramAccountSubscriber } from '../accounts/grpcProgramAccountSubscriber';
5
- import { GrpcConfigs, ResubOpts } from '../accounts/types';
2
+ import { GrpcConfigs } from '../accounts/types';
6
3
  import { SignedMsgUserOrdersAccount } from '../types';
7
- import { SignedMsgUserOrdersAccountSubscriber } from './signedMsgUserAccountSubscriber';
8
- import { VelocityClient } from '../velocityClient';
4
+ import { SignedMsgUserOrdersAccountSubscriber, SignedMsgUserOrdersAccountSubscriberConfig } from './signedMsgUserAccountSubscriber';
9
5
  export declare class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrdersAccountSubscriber {
10
6
  private grpcConfigs;
11
7
  subscriber: grpcProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
12
- constructor({ grpcConfigs, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }: {
8
+ constructor({ grpcConfigs, ...rest }: SignedMsgUserOrdersAccountSubscriberConfig & {
13
9
  grpcConfigs: GrpcConfigs;
14
- driftClient: VelocityClient;
15
- commitment?: Commitment;
16
- resubOpts?: ResubOpts;
17
- decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
18
- resyncIntervalMs?: number;
19
10
  });
20
11
  subscribe(): Promise<void>;
21
12
  unsubscribe(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"grpcSignedMsgUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/swift/grpcSignedMsgUserAccountSubscriber.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,oCAAoC,EAAE,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,wCAAyC,SAAQ,oCAAoC;IACjG,OAAO,CAAC,WAAW,CAAc;IACxB,UAAU,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;gBAElE,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,GAChB,EAAE;QACF,WAAW,EAAE,WAAW,CAAC;QACzB,WAAW,EAAE,cAAc,CAAC;QAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,0BAA0B,CAAC;QACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC1B;IAWY,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAgD1B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CASzC"}
1
+ {"version":3,"file":"grpcSignedMsgUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/swift/grpcSignedMsgUserAccountSubscriber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EACN,oCAAoC,EACpC,0CAA0C,EAC1C,MAAM,kCAAkC,CAAC;AAE1C,qBAAa,wCAAyC,SAAQ,oCAAoC;IACjG,OAAO,CAAC,WAAW,CAAc;IACxB,UAAU,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;gBAElE,EACX,WAAW,EACX,GAAG,IAAI,EACP,EAAE,0CAA0C,GAAG;QAC/C,WAAW,EAAE,WAAW,CAAC;KACzB;IAKY,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAgD1B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CASzC"}
@@ -5,20 +5,14 @@ const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSu
5
5
  const memcmp_1 = require("../memcmp");
6
6
  const signedMsgUserAccountSubscriber_1 = require("./signedMsgUserAccountSubscriber");
7
7
  class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubscriber_1.SignedMsgUserOrdersAccountSubscriber {
8
- constructor({ grpcConfigs, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
9
- super({
10
- driftClient,
11
- commitment,
12
- resubOpts,
13
- decodeFn,
14
- resyncIntervalMs,
15
- });
8
+ constructor({ grpcConfigs, ...rest }) {
9
+ super(rest);
16
10
  this.grpcConfigs = grpcConfigs;
17
11
  }
18
12
  async subscribe() {
19
13
  if (!this.subscriber) {
20
14
  this.subscriber =
21
- await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.driftClient.program, this.decodeFn, {
15
+ await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
22
16
  filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
23
17
  }, this.resubOpts);
24
18
  }
@@ -6,14 +6,23 @@ import { SignedMsgOrderId, SignedMsgUserOrdersAccount } from '../types';
6
6
  import { Commitment, PublicKey } from '@solana/web3.js';
7
7
  import { ResubOpts } from '../accounts/types';
8
8
  import { VelocityClient } from '../velocityClient';
9
+ import { AtLeastOne } from '../util/deprecatedAlias';
9
10
  import StrictEventEmitter from 'strict-event-emitter-types';
10
11
  import { EventEmitter } from 'events';
12
+ export type SignedMsgUserOrdersAccountSubscriberConfig = {
13
+ commitment?: Commitment;
14
+ resubOpts?: ResubOpts;
15
+ decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
16
+ resyncIntervalMs?: number;
17
+ } & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
11
18
  export interface SignedMsgUserOrdersAccountSubscriberEvents {
12
19
  onAccountUpdate: (activeSignedMsgOrderIds: SignedMsgOrderId[], authorityPubkey: PublicKey, slot: number) => void;
13
20
  newSignedMsgOrderIds: (newSignedMsgOrderIds: SignedMsgOrderId[], authorityPubkey: PublicKey, slot: number) => void;
14
21
  }
15
22
  export declare class SignedMsgUserOrdersAccountSubscriber {
16
- protected driftClient: VelocityClient;
23
+ protected velocityClient: VelocityClient;
24
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
25
+ protected get driftClient(): VelocityClient;
17
26
  protected commitment: Commitment;
18
27
  protected resubOpts?: ResubOpts;
19
28
  protected resyncTimeoutId?: ReturnType<typeof setTimeout>;
@@ -28,13 +37,7 @@ export declare class SignedMsgUserOrdersAccountSubscriber {
28
37
  fetchPromiseResolver: () => void;
29
38
  protected subscriber: WebSocketProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
30
39
  eventEmitter: StrictEventEmitter<EventEmitter, SignedMsgUserOrdersAccountSubscriberEvents>;
31
- constructor({ driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }: {
32
- driftClient: VelocityClient;
33
- commitment?: Commitment;
34
- resubOpts?: ResubOpts;
35
- decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
36
- resyncIntervalMs?: number;
37
- });
40
+ constructor({ velocityClient, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }: SignedMsgUserOrdersAccountSubscriberConfig);
38
41
  subscribe(): Promise<void>;
39
42
  fetch(): Promise<void>;
40
43
  tryUpdateSignedMsgUserOrdersAccount(data: Buffer | SignedMsgUserOrdersAccount, dataType: 'buffer' | 'decoded', slot: number, skipEventEmitting?: boolean): void;
@@ -1 +1 @@
1
- {"version":3,"file":"signedMsgUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/swift/signedMsgUserAccountSubscriber.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,+CAA+C,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE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AC;gBAEU,EACX,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,GAChB,EAAE,0CAA0C;IAkBhC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAmDjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0C5B,mCAAmC,CAClC,IAAI,EAAE,MAAM,GAAG,0BAA0B,EACzC,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAC9B,IAAI,EAAE,MAAM,EACZ,iBAAiB,UAAQ,GACvB,IAAI;IAwDM,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CASzC"}
@@ -5,13 +5,18 @@ const memcmp_1 = require("../memcmp");
5
5
  const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
6
6
  const events_1 = require("events");
7
7
  class SignedMsgUserOrdersAccountSubscriber {
8
- constructor({ driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
8
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
9
+ get driftClient() {
10
+ return this.velocityClient;
11
+ }
12
+ constructor({ velocityClient, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
9
13
  this.signedMsgUserOrderAccounts = new Map();
10
14
  this.commitment = commitment !== null && commitment !== void 0 ? commitment : 'confirmed';
11
15
  this.resubOpts = resubOpts;
12
- this.driftClient = driftClient;
16
+ // Type-system guarantees at least one of the two is supplied.
17
+ this.velocityClient = (velocityClient !== null && velocityClient !== void 0 ? velocityClient : driftClient);
13
18
  this.decodeFn =
14
- decodeFn !== null && decodeFn !== void 0 ? decodeFn : this.driftClient.program.account.signedMsgUserOrders.coder.accounts.decodeUnchecked.bind(this.driftClient.program.account.signedMsgUserOrders.coder
19
+ decodeFn !== null && decodeFn !== void 0 ? decodeFn : this.velocityClient.program.account.signedMsgUserOrders.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.signedMsgUserOrders.coder
15
20
  .accounts);
16
21
  this.resyncIntervalMs = resyncIntervalMs;
17
22
  this.eventEmitter = new events_1.EventEmitter();
@@ -21,7 +26,7 @@ class SignedMsgUserOrdersAccountSubscriber {
21
26
  if (!this.subscriber) {
22
27
  const filters = [(0, memcmp_1.getSignedMsgUserOrdersFilter)()];
23
28
  this.subscriber =
24
- new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.driftClient.program, this.decodeFn, {
29
+ new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
25
30
  filters,
26
31
  commitment: this.commitment,
27
32
  }, this.resubOpts);
@@ -57,7 +62,7 @@ class SignedMsgUserOrdersAccountSubscriber {
57
62
  });
58
63
  const skipEventEmitting = this.signedMsgUserOrderAccounts.size === 0;
59
64
  try {
60
- const rpcResponseAndContext = await this.driftClient.connection.getProgramAccounts(this.driftClient.program.programId, {
65
+ const rpcResponseAndContext = await this.velocityClient.connection.getProgramAccounts(this.velocityClient.program.programId, {
61
66
  commitment: this.commitment,
62
67
  filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
63
68
  encoding: 'base64',