@velocity-exchange/sdk 0.0.3 → 0.1.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 (393) hide show
  1. package/.prettierignore +1 -1
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +30 -30
  4. package/bun.lock +1 -1
  5. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +1 -1
  6. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
  7. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
  8. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
  9. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
  10. package/lib/browser/accounts/laserProgramAccountSubscriber.js +1 -1
  11. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
  12. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
  13. package/lib/browser/accounts/types.d.ts +2 -8
  14. package/lib/browser/accounts/utils.js +2 -2
  15. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
  16. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
  17. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
  18. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
  19. package/lib/browser/addresses/pda.d.ts +1 -7
  20. package/lib/browser/addresses/pda.js +4 -10
  21. package/lib/browser/adminClient.d.ts +1 -1
  22. package/lib/browser/adminClient.js +21 -21
  23. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -3
  24. package/lib/browser/auctionSubscriber/auctionSubscriber.js +2 -6
  25. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
  26. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
  27. package/lib/browser/auctionSubscriber/types.d.ts +3 -2
  28. package/lib/browser/config.d.ts +10 -19
  29. package/lib/browser/config.js +6 -33
  30. package/lib/browser/constants/insuranceFund.d.ts +1 -1
  31. package/lib/browser/constants/insuranceFund.js +1 -1
  32. package/lib/browser/constituentMap/constituentMap.d.ts +0 -2
  33. package/lib/browser/constituentMap/constituentMap.js +5 -5
  34. package/lib/browser/core/VelocityCore.d.ts +9 -15
  35. package/lib/browser/core/VelocityCore.js +5 -7
  36. package/lib/browser/core/instructions/withdraw.d.ts +1 -1
  37. package/lib/browser/core/instructions/withdraw.js +1 -1
  38. package/lib/browser/core/remainingAccounts.js +3 -3
  39. package/lib/browser/decode/user.js +5 -5
  40. package/lib/browser/dlob/DLOB.d.ts +1 -1
  41. package/lib/browser/dlob/DLOB.js +7 -7
  42. package/lib/browser/dlob/DLOBNode.js +1 -2
  43. package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -2
  44. package/lib/browser/dlob/DLOBSubscriber.js +2 -7
  45. package/lib/browser/dlob/orderBookLevels.js +7 -7
  46. package/lib/browser/dlob/types.d.ts +0 -2
  47. package/lib/browser/events/eventSubscriber.d.ts +1 -1
  48. package/lib/browser/events/eventsServerLogProvider.js +2 -2
  49. package/lib/browser/events/parse.js +14 -14
  50. package/lib/browser/events/types.d.ts +3 -5
  51. package/lib/browser/events/types.js +1 -1
  52. package/lib/browser/idl/{drift.d.ts → velocity.d.ts} +1043 -768
  53. package/lib/browser/idl/{drift.json → velocity.json} +1034 -759
  54. package/lib/browser/index.d.ts +1 -1
  55. package/lib/browser/index.js +1 -2
  56. package/lib/browser/math/amm.d.ts +10 -10
  57. package/lib/browser/math/amm.js +29 -28
  58. package/lib/browser/math/auction.d.ts +1 -1
  59. package/lib/browser/math/auction.js +18 -21
  60. package/lib/browser/math/builder.d.ts +18 -1
  61. package/lib/browser/math/builder.js +32 -1
  62. package/lib/browser/math/funding.js +26 -26
  63. package/lib/browser/math/margin.d.ts +4 -4
  64. package/lib/browser/math/margin.js +15 -15
  65. package/lib/browser/math/market.js +13 -13
  66. package/lib/browser/math/oracles.d.ts +4 -4
  67. package/lib/browser/math/oracles.js +23 -23
  68. package/lib/browser/math/orders.d.ts +2 -2
  69. package/lib/browser/math/orders.js +12 -12
  70. package/lib/browser/math/position.js +4 -4
  71. package/lib/browser/math/superStake.d.ts +8 -10
  72. package/lib/browser/math/superStake.js +18 -20
  73. package/lib/browser/math/trade.js +5 -5
  74. package/lib/browser/math/utils.d.ts +1 -1
  75. package/lib/browser/math/utils.js +1 -1
  76. package/lib/browser/oracles/pythLazerClient.js +2 -2
  77. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +0 -2
  78. package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -12
  79. package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
  80. package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
  81. package/lib/browser/orderSubscriber/types.d.ts +0 -2
  82. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -5
  83. package/lib/browser/priorityFee/priorityFeeSubscriber.js +7 -15
  84. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
  85. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +3 -11
  86. package/lib/browser/priorityFee/types.d.ts +3 -8
  87. package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
  88. package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +1 -3
  89. package/lib/browser/pyth/pythLazerSubscriber.d.ts +1 -1
  90. package/lib/browser/pyth/pythLazerSubscriber.js +1 -1
  91. package/lib/browser/swap/UnifiedSwapClient.js +1 -1
  92. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
  93. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +2 -6
  94. package/lib/browser/swift/swiftOrderSubscriber.d.ts +6 -5
  95. package/lib/browser/swift/swiftOrderSubscriber.js +5 -11
  96. package/lib/browser/types.d.ts +81 -93
  97. package/lib/browser/types.js +4 -0
  98. package/lib/browser/user.d.ts +1 -3
  99. package/lib/browser/user.js +19 -23
  100. package/lib/browser/userConfig.d.ts +3 -2
  101. package/lib/browser/userMap/WebsocketSubscription.js +1 -1
  102. package/lib/browser/userMap/grpcSubscription.js +1 -1
  103. package/lib/browser/userMap/referrerMap.d.ts +0 -2
  104. package/lib/browser/userMap/referrerMap.js +0 -4
  105. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +0 -2
  106. package/lib/browser/userMap/revenueShareEscrowMap.js +0 -4
  107. package/lib/browser/userMap/userMap.d.ts +2 -4
  108. package/lib/browser/userMap/userMap.js +10 -14
  109. package/lib/browser/userMap/userMapConfig.d.ts +3 -2
  110. package/lib/browser/userMap/userStatsMap.d.ts +0 -2
  111. package/lib/browser/userMap/userStatsMap.js +0 -4
  112. package/lib/browser/userStats.d.ts +0 -2
  113. package/lib/browser/userStats.js +10 -14
  114. package/lib/browser/userStatsConfig.d.ts +3 -2
  115. package/lib/browser/util/ed25519Utils.d.ts +1 -1
  116. package/lib/browser/util/ed25519Utils.js +1 -1
  117. package/lib/browser/velocityClient.d.ts +59 -44
  118. package/lib/browser/velocityClient.js +259 -197
  119. package/lib/browser/velocityClientConfig.d.ts +0 -8
  120. package/lib/node/accounts/grpcProgramAccountSubscriber.js +1 -1
  121. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
  122. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  123. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
  124. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
  125. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  126. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
  127. package/lib/node/accounts/laserProgramAccountSubscriber.js +1 -1
  128. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
  129. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  130. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
  131. package/lib/node/accounts/types.d.ts +2 -8
  132. package/lib/node/accounts/types.d.ts.map +1 -1
  133. package/lib/node/accounts/utils.js +2 -2
  134. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
  135. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  136. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
  137. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
  138. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  139. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
  140. package/lib/node/addresses/pda.d.ts +1 -7
  141. package/lib/node/addresses/pda.d.ts.map +1 -1
  142. package/lib/node/addresses/pda.js +4 -10
  143. package/lib/node/adminClient.d.ts +1 -1
  144. package/lib/node/adminClient.js +21 -21
  145. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -3
  146. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  147. package/lib/node/auctionSubscriber/auctionSubscriber.js +2 -6
  148. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
  149. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  150. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
  151. package/lib/node/auctionSubscriber/types.d.ts +3 -2
  152. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  153. package/lib/node/config.d.ts +10 -19
  154. package/lib/node/config.d.ts.map +1 -1
  155. package/lib/node/config.js +6 -33
  156. package/lib/node/constants/insuranceFund.d.ts +1 -1
  157. package/lib/node/constants/insuranceFund.js +1 -1
  158. package/lib/node/constituentMap/constituentMap.d.ts +0 -2
  159. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  160. package/lib/node/constituentMap/constituentMap.js +5 -5
  161. package/lib/node/core/VelocityCore.d.ts +9 -15
  162. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  163. package/lib/node/core/VelocityCore.js +5 -7
  164. package/lib/node/core/instructions/withdraw.d.ts +1 -1
  165. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  166. package/lib/node/core/instructions/withdraw.js +1 -1
  167. package/lib/node/core/remainingAccounts.js +3 -3
  168. package/lib/node/decode/user.js +5 -5
  169. package/lib/node/dlob/DLOB.d.ts +1 -1
  170. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  171. package/lib/node/dlob/DLOB.js +7 -7
  172. package/lib/node/dlob/DLOBNode.js +1 -2
  173. package/lib/node/dlob/DLOBSubscriber.d.ts +0 -2
  174. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  175. package/lib/node/dlob/DLOBSubscriber.js +2 -7
  176. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  177. package/lib/node/dlob/orderBookLevels.js +7 -7
  178. package/lib/node/dlob/types.d.ts +0 -2
  179. package/lib/node/dlob/types.d.ts.map +1 -1
  180. package/lib/node/events/eventSubscriber.d.ts +1 -1
  181. package/lib/node/events/eventsServerLogProvider.js +2 -2
  182. package/lib/node/events/parse.d.ts.map +1 -1
  183. package/lib/node/events/parse.js +14 -14
  184. package/lib/node/events/types.d.ts +3 -5
  185. package/lib/node/events/types.d.ts.map +1 -1
  186. package/lib/node/events/types.js +1 -1
  187. package/lib/node/idl/{drift.d.ts → velocity.d.ts} +1044 -769
  188. package/lib/node/idl/velocity.d.ts.map +1 -0
  189. package/lib/node/idl/{drift.json → velocity.json} +1034 -759
  190. package/lib/node/index.d.ts +1 -1
  191. package/lib/node/index.d.ts.map +1 -1
  192. package/lib/node/index.js +1 -2
  193. package/lib/node/math/amm.d.ts +10 -10
  194. package/lib/node/math/amm.d.ts.map +1 -1
  195. package/lib/node/math/amm.js +29 -28
  196. package/lib/node/math/auction.d.ts +1 -1
  197. package/lib/node/math/auction.d.ts.map +1 -1
  198. package/lib/node/math/auction.js +18 -21
  199. package/lib/node/math/builder.d.ts +18 -1
  200. package/lib/node/math/builder.d.ts.map +1 -1
  201. package/lib/node/math/builder.js +32 -1
  202. package/lib/node/math/funding.d.ts.map +1 -1
  203. package/lib/node/math/funding.js +26 -26
  204. package/lib/node/math/margin.d.ts +4 -4
  205. package/lib/node/math/margin.d.ts.map +1 -1
  206. package/lib/node/math/margin.js +15 -15
  207. package/lib/node/math/market.d.ts.map +1 -1
  208. package/lib/node/math/market.js +13 -13
  209. package/lib/node/math/oracles.d.ts +4 -4
  210. package/lib/node/math/oracles.d.ts.map +1 -1
  211. package/lib/node/math/oracles.js +23 -23
  212. package/lib/node/math/orders.d.ts +2 -2
  213. package/lib/node/math/orders.d.ts.map +1 -1
  214. package/lib/node/math/orders.js +12 -12
  215. package/lib/node/math/position.d.ts.map +1 -1
  216. package/lib/node/math/position.js +4 -4
  217. package/lib/node/math/superStake.d.ts +8 -10
  218. package/lib/node/math/superStake.d.ts.map +1 -1
  219. package/lib/node/math/superStake.js +18 -20
  220. package/lib/node/math/trade.d.ts.map +1 -1
  221. package/lib/node/math/trade.js +5 -5
  222. package/lib/node/math/utils.d.ts +1 -1
  223. package/lib/node/math/utils.js +1 -1
  224. package/lib/node/oracles/pythLazerClient.js +2 -2
  225. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +0 -2
  226. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  227. package/lib/node/orderSubscriber/OrderSubscriber.js +8 -12
  228. package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
  229. package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
  230. package/lib/node/orderSubscriber/types.d.ts +0 -2
  231. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  232. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -5
  233. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  234. package/lib/node/priorityFee/priorityFeeSubscriber.js +7 -15
  235. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
  236. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  237. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +3 -11
  238. package/lib/node/priorityFee/types.d.ts +3 -8
  239. package/lib/node/priorityFee/types.d.ts.map +1 -1
  240. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
  241. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
  242. package/lib/node/priorityFee/velocityPriorityFeeMethod.js +1 -3
  243. package/lib/node/pyth/pythLazerSubscriber.d.ts +1 -1
  244. package/lib/node/pyth/pythLazerSubscriber.js +1 -1
  245. package/lib/node/swap/UnifiedSwapClient.js +1 -1
  246. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
  247. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  248. package/lib/node/swift/signedMsgUserAccountSubscriber.js +2 -6
  249. package/lib/node/swift/swiftOrderSubscriber.d.ts +6 -5
  250. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  251. package/lib/node/swift/swiftOrderSubscriber.js +5 -11
  252. package/lib/node/types.d.ts +81 -93
  253. package/lib/node/types.d.ts.map +1 -1
  254. package/lib/node/types.js +4 -0
  255. package/lib/node/user.d.ts +1 -3
  256. package/lib/node/user.d.ts.map +1 -1
  257. package/lib/node/user.js +19 -23
  258. package/lib/node/userConfig.d.ts +3 -2
  259. package/lib/node/userConfig.d.ts.map +1 -1
  260. package/lib/node/userMap/WebsocketSubscription.js +1 -1
  261. package/lib/node/userMap/grpcSubscription.js +1 -1
  262. package/lib/node/userMap/referrerMap.d.ts +0 -2
  263. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  264. package/lib/node/userMap/referrerMap.js +0 -4
  265. package/lib/node/userMap/revenueShareEscrowMap.d.ts +0 -2
  266. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  267. package/lib/node/userMap/revenueShareEscrowMap.js +0 -4
  268. package/lib/node/userMap/userMap.d.ts +2 -4
  269. package/lib/node/userMap/userMap.d.ts.map +1 -1
  270. package/lib/node/userMap/userMap.js +10 -14
  271. package/lib/node/userMap/userMapConfig.d.ts +3 -2
  272. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  273. package/lib/node/userMap/userStatsMap.d.ts +0 -2
  274. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  275. package/lib/node/userMap/userStatsMap.js +0 -4
  276. package/lib/node/userStats.d.ts +0 -2
  277. package/lib/node/userStats.d.ts.map +1 -1
  278. package/lib/node/userStats.js +10 -14
  279. package/lib/node/userStatsConfig.d.ts +3 -2
  280. package/lib/node/userStatsConfig.d.ts.map +1 -1
  281. package/lib/node/util/ed25519Utils.d.ts +1 -1
  282. package/lib/node/util/ed25519Utils.js +1 -1
  283. package/lib/node/velocityClient.d.ts +59 -44
  284. package/lib/node/velocityClient.d.ts.map +1 -1
  285. package/lib/node/velocityClient.js +259 -197
  286. package/lib/node/velocityClientConfig.d.ts +0 -8
  287. package/lib/node/velocityClientConfig.d.ts.map +1 -1
  288. package/package.json +6 -7
  289. package/scripts/deposit-isolated-positions.ts +2 -2
  290. package/scripts/find-flagged-users.ts +1 -1
  291. package/scripts/grpc-client-test-comparison.ts +4 -4
  292. package/scripts/grpc-multiuser-client-test-comparison.ts +2 -2
  293. package/scripts/single-grpc-client-test.ts +3 -3
  294. package/scripts/updateVersion.js +4 -4
  295. package/scripts/withdraw-isolated-positions.ts +2 -2
  296. package/src/accounts/grpcProgramAccountSubscriber.ts +1 -1
  297. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +0 -7
  298. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +4 -11
  299. package/src/accounts/laserProgramAccountSubscriber.ts +1 -1
  300. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +4 -11
  301. package/src/accounts/types.ts +2 -9
  302. package/src/accounts/utils.ts +2 -2
  303. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +4 -11
  304. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +4 -11
  305. package/src/addresses/pda.ts +3 -13
  306. package/src/adminClient.ts +21 -21
  307. package/src/auctionSubscriber/auctionSubscriber.ts +1 -6
  308. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +1 -6
  309. package/src/auctionSubscriber/types.ts +3 -3
  310. package/src/config.ts +8 -64
  311. package/src/constants/insuranceFund.ts +1 -1
  312. package/src/constituentMap/constituentMap.ts +2 -6
  313. package/src/core/VelocityCore.ts +11 -20
  314. package/src/core/instructions/withdraw.ts +2 -2
  315. package/src/core/remainingAccounts.ts +3 -3
  316. package/src/decode/user.ts +5 -5
  317. package/src/dlob/DLOB.ts +7 -7
  318. package/src/dlob/DLOBNode.ts +1 -1
  319. package/src/dlob/DLOBSubscriber.ts +2 -8
  320. package/src/dlob/orderBookLevels.ts +12 -6
  321. package/src/dlob/types.ts +0 -2
  322. package/src/events/eventSubscriber.ts +1 -1
  323. package/src/events/eventsServerLogProvider.ts +2 -2
  324. package/src/events/parse.ts +14 -14
  325. package/src/events/types.ts +4 -7
  326. package/src/idl/{drift.json → velocity.json} +1034 -759
  327. package/src/idl/{drift.ts → velocity.ts} +1036 -761
  328. package/src/index.ts +1 -4
  329. package/src/margin/README.md +2 -2
  330. package/src/math/amm.ts +43 -21
  331. package/src/math/auction.ts +19 -22
  332. package/src/math/builder.ts +45 -1
  333. package/src/math/funding.ts +46 -43
  334. package/src/math/margin.ts +15 -15
  335. package/src/math/market.ts +21 -13
  336. package/src/math/oracles.ts +29 -26
  337. package/src/math/orders.ts +21 -11
  338. package/src/math/position.ts +9 -3
  339. package/src/math/superStake.ts +21 -24
  340. package/src/math/trade.ts +9 -1
  341. package/src/math/utils.ts +1 -1
  342. package/src/oracles/pythLazerClient.ts +3 -3
  343. package/src/orderSubscriber/OrderSubscriber.ts +2 -8
  344. package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
  345. package/src/orderSubscriber/grpcSubscription.ts +2 -2
  346. package/src/orderSubscriber/types.ts +0 -2
  347. package/src/priorityFee/priorityFeeSubscriber.ts +5 -12
  348. package/src/priorityFee/priorityFeeSubscriberMap.ts +2 -10
  349. package/src/priorityFee/types.ts +4 -9
  350. package/src/priorityFee/velocityPriorityFeeMethod.ts +0 -12
  351. package/src/pyth/pythLazerSubscriber.ts +1 -1
  352. package/src/swap/UnifiedSwapClient.ts +1 -1
  353. package/src/swift/signedMsgUserAccountSubscriber.ts +2 -8
  354. package/src/swift/swiftOrderSubscriber.ts +7 -12
  355. package/src/types.ts +86 -104
  356. package/src/user.ts +9 -14
  357. package/src/userConfig.ts +1 -3
  358. package/src/userMap/WebsocketSubscription.ts +1 -1
  359. package/src/userMap/grpcSubscription.ts +1 -1
  360. package/src/userMap/referrerMap.ts +0 -4
  361. package/src/userMap/revenueShareEscrowMap.ts +0 -4
  362. package/src/userMap/userMap.ts +3 -7
  363. package/src/userMap/userMapConfig.ts +3 -3
  364. package/src/userMap/userStatsMap.ts +0 -4
  365. package/src/userStats.ts +1 -5
  366. package/src/userStatsConfig.ts +3 -3
  367. package/src/util/ed25519Utils.ts +1 -1
  368. package/src/velocityClient.ts +345 -231
  369. package/src/velocityClientConfig.ts +3 -11
  370. package/tests/{DriftCore → VelocityCore}/decode.test.ts +1 -1
  371. package/tests/{DriftCore → VelocityCore}/fill_trigger.test.ts +1 -1
  372. package/tests/{DriftCore → VelocityCore}/instructions.test.ts +1 -1
  373. package/tests/{DriftCore → VelocityCore}/pdas.test.ts +4 -2
  374. package/tests/auctions/test.ts +4 -4
  375. package/tests/ci/verifyConstants.ts +24 -27
  376. package/tests/decode/test.ts +3 -3
  377. package/tests/dlob/helpers.ts +5 -9
  378. package/tests/dlob/test.ts +5 -5
  379. package/tests/events/parseLogsForCuUsage.ts +15 -15
  380. package/tests/user/helpers.ts +10 -10
  381. package/tests/user/test.ts +13 -10
  382. package/lib/browser/util/deprecatedAlias.d.ts +0 -26
  383. package/lib/browser/util/deprecatedAlias.js +0 -10
  384. package/lib/node/idl/drift.d.ts.map +0 -1
  385. package/lib/node/util/deprecatedAlias.d.ts +0 -27
  386. package/lib/node/util/deprecatedAlias.d.ts.map +0 -1
  387. package/lib/node/util/deprecatedAlias.js +0 -10
  388. package/src/util/deprecatedAlias.ts +0 -25
  389. /package/lib/browser/idl/{drift.js → velocity.js} +0 -0
  390. /package/lib/node/idl/{drift.js → velocity.js} +0 -0
  391. /package/tests/{DriftCore → VelocityCore}/perp_orders.test.ts +0 -0
  392. /package/tests/{DriftCore → VelocityCore}/remainingAccounts.test.ts +0 -0
  393. /package/tests/{DriftCore → VelocityCore}/settlement_liquidation.test.ts +0 -0
package/src/math/trade.ts CHANGED
@@ -113,6 +113,8 @@ export function calculateTradeSlippage(
113
113
  const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } =
114
114
  calculateUpdatedAMMSpreadReserves(
115
115
  market.amm,
116
+ market.marketStats,
117
+ market.totalExchangeFee,
116
118
  direction,
117
119
  mmOraclePriceData,
118
120
  latestSlot
@@ -184,6 +186,8 @@ export function calculateTradeAcquiredAmounts(
184
186
  const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } =
185
187
  calculateUpdatedAMMSpreadReserves(
186
188
  market.amm,
189
+ market.marketStats,
190
+ market.totalExchangeFee,
187
191
  direction,
188
192
  mmOraclePriceData,
189
193
  latestSlot
@@ -274,6 +278,8 @@ export function calculateTargetPriceTrade(
274
278
  const { baseAssetReserve, quoteAssetReserve, newPeg } =
275
279
  calculateUpdatedAMMSpreadReserves(
276
280
  market.amm,
281
+ market.marketStats,
282
+ market.totalExchangeFee,
277
283
  direction,
278
284
  mmOraclePriceData,
279
285
  latestSlot
@@ -436,6 +442,8 @@ export function calculateEstimatedPerpEntryPrice(
436
442
  const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } =
437
443
  calculateUpdatedAMMSpreadReserves(
438
444
  market.amm,
445
+ market.marketStats,
446
+ market.totalExchangeFee,
439
447
  direction,
440
448
  mmOraclePriceData,
441
449
  new BN(slot)
@@ -451,7 +459,7 @@ export function calculateEstimatedPerpEntryPrice(
451
459
  market.amm.baseAssetReserve,
452
460
  market.amm.minBaseAssetReserve,
453
461
  market.amm.maxBaseAssetReserve,
454
- market.amm.orderStepSize
462
+ market.orderStepSize
455
463
  );
456
464
 
457
465
  let ammLiquidity: BN;
package/src/math/utils.ts CHANGED
@@ -104,7 +104,7 @@ export function isBNSafe(number: number): boolean {
104
104
  /**
105
105
  * Converts a number to BN makes sure the number is safe to convert to BN (that it does not overflow number after multiplying by precision)
106
106
  * @param number the number to convert to BN
107
- * @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from drift sdk)
107
+ * @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from velocity sdk)
108
108
  */
109
109
  export function numberToSafeBN(number: number, precision: BN): BN {
110
110
  // check if number has decimals
@@ -1,7 +1,7 @@
1
1
  import { Connection, Keypair, PublicKey } from '@solana/web3.js';
2
2
  import { OracleClient, OraclePriceData } from './types';
3
3
  import { AnchorProvider, BN, Program } from '../isomorphic/anchor';
4
- import { Drift } from '../idl/drift';
4
+ import { Velocity } from '../idl/velocity';
5
5
  import { VelocityProgram } from '../config';
6
6
  import {
7
7
  ONE,
@@ -10,7 +10,7 @@ import {
10
10
  TEN,
11
11
  } from '../constants/numericConstants';
12
12
  import { Wallet } from '../wallet';
13
- import driftIDL from '../idl/drift.json';
13
+ import velocityIDL from '../idl/velocity.json';
14
14
 
15
15
  export class PythLazerClient implements OracleClient {
16
16
  private connection: Connection;
@@ -35,7 +35,7 @@ export class PythLazerClient implements OracleClient {
35
35
  commitment: connection.commitment,
36
36
  }
37
37
  );
38
- this.program = new Program<Drift>(driftIDL as Drift, provider);
38
+ this.program = new Program<Velocity>(velocityIDL as Velocity, provider);
39
39
  this.decodeFunc = (
40
40
  this.program.account as any
41
41
  ).pythLazerOracle.coder.accounts.decodeUnchecked.bind(
@@ -21,10 +21,6 @@ import { ZERO } from '../constants/numericConstants';
21
21
 
22
22
  export class OrderSubscriber {
23
23
  velocityClient: VelocityClient;
24
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
25
- public get driftClient(): VelocityClient {
26
- return this.velocityClient;
27
- }
28
24
  usersAccounts = new Map<string, { slot: number; userAccount: UserAccount }>();
29
25
  subscription: PollingSubscription | WebsocketSubscription | grpcSubscription;
30
26
  commitment: Commitment;
@@ -40,11 +36,9 @@ export class OrderSubscriber {
40
36
  fetchAllNonIdleUsers?: boolean;
41
37
 
42
38
  constructor(config: OrderSubscriberConfig) {
43
- const velocityClient = config.velocityClient ?? config.driftClient;
39
+ const velocityClient = config.velocityClient;
44
40
  if (!velocityClient) {
45
- throw new Error(
46
- 'OrderSubscriber: velocityClient (or deprecated driftClient) must be provided'
47
- );
41
+ throw new Error('OrderSubscriber: velocityClient must be provided');
48
42
  }
49
43
  this.velocityClient = velocityClient;
50
44
  this.commitment = config.subscriptionConfig.commitment || 'processed';
@@ -48,7 +48,7 @@ export class WebsocketSubscription {
48
48
  this.subscriber = new WebSocketProgramAccountSubscriber<UserAccount>(
49
49
  'OrderSubscriber',
50
50
  'user',
51
- this.orderSubscriber.driftClient.program,
51
+ this.orderSubscriber.velocityClient.program,
52
52
  this.orderSubscriber.decodeFn,
53
53
  {
54
54
  filters: [getUserFilter(), getNonIdleUserFilter()],
@@ -56,7 +56,7 @@ export class grpcSubscription {
56
56
  this.grpcConfigs,
57
57
  'OrderSubscriber',
58
58
  'user',
59
- this.orderSubscriber.driftClient.program,
59
+ this.orderSubscriber.velocityClient.program,
60
60
  this.orderSubscriber.decodeFn,
61
61
  {
62
62
  filters: [getUserFilter(), getNonIdleUserFilter()],
@@ -68,7 +68,7 @@ export class grpcSubscription {
68
68
  this.grpcConfigs,
69
69
  'OrderSubscriber',
70
70
  'user',
71
- this.orderSubscriber.driftClient.program,
71
+ this.orderSubscriber.velocityClient.program,
72
72
  this.orderSubscriber.decodeFn,
73
73
  {
74
74
  filters: [getUserFilter(), getNonIdleUserFilter()],
@@ -5,8 +5,6 @@ import { GrpcConfigs } from '../accounts/types';
5
5
 
6
6
  export type OrderSubscriberConfig = {
7
7
  velocityClient?: VelocityClient;
8
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
9
- driftClient?: VelocityClient;
10
8
  subscriptionConfig:
11
9
  | {
12
10
  type: 'polling';
@@ -23,10 +23,6 @@ export class PriorityFeeSubscriber {
23
23
  frequencyMs: number;
24
24
  addresses: string[];
25
25
  velocityMarkets?: VelocityMarketInfo[];
26
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
27
- public get driftMarkets(): VelocityMarketInfo[] | undefined {
28
- return this.velocityMarkets;
29
- }
30
26
  customStrategy?: PriorityFeeStrategy;
31
27
  averageStrategy = new AverageOverSlotsStrategy();
32
28
  maxStrategy = new MaxOverSlotsStrategy();
@@ -36,10 +32,6 @@ export class PriorityFeeSubscriber {
36
32
  priorityFeeMultiplier?: number;
37
33
 
38
34
  velocityPriorityFeeEndpoint?: string;
39
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
40
- public get driftPriorityFeeEndpoint(): string | undefined {
41
- return this.velocityPriorityFeeEndpoint;
42
- }
43
35
  heliusRpcUrl?: string;
44
36
  lastHeliusSample?: HeliusPriorityFeeLevels;
45
37
 
@@ -58,7 +50,7 @@ export class PriorityFeeSubscriber {
58
50
  this.addresses = config.addresses
59
51
  ? config.addresses.map((address) => address.toBase58())
60
52
  : [];
61
- this.velocityMarkets = config.velocityMarkets ?? config.driftMarkets;
53
+ this.velocityMarkets = config.velocityMarkets;
62
54
 
63
55
  if (config.customStrategy) {
64
56
  this.customStrategy = config.customStrategy;
@@ -84,7 +76,8 @@ export class PriorityFeeSubscriber {
84
76
  }
85
77
  } else if (this.priorityFeeMethod === PriorityFeeMethod.VELOCITY) {
86
78
  this.velocityPriorityFeeEndpoint =
87
- config.velocityPriorityFeeEndpoint ?? config.driftPriorityFeeEndpoint;
79
+ config.velocityPriorityFeeEndpoint ??
80
+ config.velocityPriorityFeeEndpoint;
88
81
  }
89
82
  }
90
83
 
@@ -146,7 +139,7 @@ export class PriorityFeeSubscriber {
146
139
  }
147
140
  }
148
141
 
149
- private async loadForDrift(): Promise<void> {
142
+ private async loadForVelocity(): Promise<void> {
150
143
  if (!this.velocityMarkets) {
151
144
  return;
152
145
  }
@@ -228,7 +221,7 @@ export class PriorityFeeSubscriber {
228
221
  } else if (this.priorityFeeMethod === PriorityFeeMethod.HELIUS) {
229
222
  await this.loadForHelius();
230
223
  } else if (this.priorityFeeMethod === PriorityFeeMethod.VELOCITY) {
231
- await this.loadForDrift();
224
+ await this.loadForVelocity();
232
225
  } else {
233
226
  throw new Error(`${this.priorityFeeMethod} load not implemented`);
234
227
  }
@@ -17,15 +17,7 @@ export class PriorityFeeSubscriberMap {
17
17
  intervalId?: ReturnType<typeof setTimeout>;
18
18
 
19
19
  velocityMarkets?: VelocityMarketInfo[];
20
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
21
- public get driftMarkets(): VelocityMarketInfo[] | undefined {
22
- return this.velocityMarkets;
23
- }
24
20
  velocityPriorityFeeEndpoint: string;
25
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
26
- public get driftPriorityFeeEndpoint(): string {
27
- return this.velocityPriorityFeeEndpoint;
28
- }
29
21
  feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>; // marketType -> marketIndex -> priority fee
30
22
 
31
23
  public constructor(config: PriorityFeeSubscriberMapConfig) {
@@ -33,8 +25,8 @@ export class PriorityFeeSubscriberMap {
33
25
  config.frequencyMs ?? DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
34
26
  // Type-system guarantees at least one of the two is supplied.
35
27
  this.velocityPriorityFeeEndpoint = (config.velocityPriorityFeeEndpoint ??
36
- config.driftPriorityFeeEndpoint)!;
37
- this.velocityMarkets = config.velocityMarkets ?? config.driftMarkets;
28
+ config.velocityPriorityFeeEndpoint)!;
29
+ this.velocityMarkets = config.velocityMarkets;
38
30
  this.feesMap = new Map<string, Map<number, VelocityPriorityFeeLevels>>();
39
31
  this.feesMap.set('perp', new Map<number, VelocityPriorityFeeLevels>());
40
32
  this.feesMap.set('spot', new Map<number, VelocityPriorityFeeLevels>());
@@ -5,7 +5,6 @@ import {
5
5
  VelocityMarketInfo,
6
6
  VelocityPriorityFeeResponse,
7
7
  } from './velocityPriorityFeeMethod';
8
- import { AtLeastOne } from '../util/deprecatedAlias';
9
8
 
10
9
  export const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10_000;
11
10
 
@@ -35,8 +34,6 @@ export type PriorityFeeSubscriberConfig = {
35
34
  addresses?: PublicKey[];
36
35
  /// market type and index, optionally provide at initialization time if using priorityFeeMethod.VELOCITY
37
36
  velocityMarkets?: VelocityMarketInfo[];
38
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
39
- driftMarkets?: VelocityMarketInfo[];
40
37
  /// custom strategy to calculate priority fees, defaults to AVERAGE
41
38
  customStrategy?: PriorityFeeStrategy;
42
39
  /// method for fetching priority fee samples
@@ -47,8 +44,6 @@ export type PriorityFeeSubscriberConfig = {
47
44
  heliusRpcUrl?: string;
48
45
  /// url for Velocity cached priority fee endpoint, required if using priorityFeeMethod.VELOCITY
49
46
  velocityPriorityFeeEndpoint?: string;
50
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
51
- driftPriorityFeeEndpoint?: string;
52
47
  /// clamp any returned priority fee value to this value.
53
48
  maxFeeMicroLamports?: number;
54
49
  /// multiplier applied to priority fee before maxFeeMicroLamports, defaults to 1.0
@@ -60,10 +55,10 @@ type PriorityFeeSubscriberMapConfigBase = {
60
55
  frequencyMs?: number;
61
56
  /// market type and associated market index to query
62
57
  velocityMarkets?: VelocityMarketInfo[];
63
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
64
- driftMarkets?: VelocityMarketInfo[];
65
58
  };
66
59
 
67
60
  /// url for Velocity cached priority fee endpoint
68
- export type PriorityFeeSubscriberMapConfig = PriorityFeeSubscriberMapConfigBase &
69
- AtLeastOne<'velocityPriorityFeeEndpoint', 'driftPriorityFeeEndpoint', string>;
61
+ export type PriorityFeeSubscriberMapConfig =
62
+ PriorityFeeSubscriberMapConfigBase & {
63
+ velocityPriorityFeeEndpoint: string;
64
+ };
@@ -6,9 +6,6 @@ export type VelocityMarketInfo = {
6
6
  marketIndex: number;
7
7
  };
8
8
 
9
- /** @deprecated Use `VelocityMarketInfo` instead. `DriftMarketInfo` will be removed in a future major. */
10
- export type DriftMarketInfo = VelocityMarketInfo;
11
-
12
9
  export type VelocityPriorityFeeLevels = {
13
10
  [key in HeliusPriorityLevel]: number;
14
11
  } & {
@@ -16,14 +13,8 @@ export type VelocityPriorityFeeLevels = {
16
13
  marketIndex: number;
17
14
  };
18
15
 
19
- /** @deprecated Use `VelocityPriorityFeeLevels` instead. `DriftPriorityFeeLevels` will be removed in a future major. */
20
- export type DriftPriorityFeeLevels = VelocityPriorityFeeLevels;
21
-
22
16
  export type VelocityPriorityFeeResponse = VelocityPriorityFeeLevels[];
23
17
 
24
- /** @deprecated Use `VelocityPriorityFeeResponse` instead. `DriftPriorityFeeResponse` will be removed in a future major. */
25
- export type DriftPriorityFeeResponse = VelocityPriorityFeeResponse;
26
-
27
18
  export async function fetchVelocityPriorityFee(
28
19
  url: string,
29
20
  marketTypes: string[],
@@ -49,6 +40,3 @@ export async function fetchVelocityPriorityFee(
49
40
 
50
41
  return [];
51
42
  }
52
-
53
- /** @deprecated Use `fetchVelocityPriorityFee` instead. `fetchDriftPriorityFee` will be removed in a future major. */
54
- export const fetchDriftPriorityFee = fetchVelocityPriorityFee;
@@ -50,7 +50,7 @@ export class PythLazerSubscriber {
50
50
  * @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
51
51
  * @param token - Authentication token for Pyth Lazer API
52
52
  * @param priceFeedArrays - Array of price feed configurations to subscribe to
53
- * @param env - Drift environment (mainnet-beta, devnet, etc.)
53
+ * @param env - Velocity environment (mainnet-beta, devnet, etc.)
54
54
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
55
55
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
56
56
  * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
@@ -270,7 +270,7 @@ export class UnifiedSwapClient {
270
270
  slippageBps,
271
271
  swapMode: isExactOut ? TitanSwapMode.ExactOut : TitanSwapMode.ExactIn,
272
272
  onlyDirectRoutes,
273
- sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for drift instructions
273
+ sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for velocity instructions
274
274
  });
275
275
 
276
276
  swapInstructions = titanClient.getTitanInstructions({
@@ -4,7 +4,6 @@ import { SignedMsgOrderId, SignedMsgUserOrdersAccount } from '../types';
4
4
  import { Commitment, Context, PublicKey } from '@solana/web3.js';
5
5
  import { ResubOpts } from '../accounts/types';
6
6
  import { VelocityClient } from '../velocityClient';
7
- import { AtLeastOne } from '../util/deprecatedAlias';
8
7
  import StrictEventEmitter from 'strict-event-emitter-types';
9
8
  import { EventEmitter } from 'events';
10
9
 
@@ -13,7 +12,7 @@ export type SignedMsgUserOrdersAccountSubscriberConfig = {
13
12
  resubOpts?: ResubOpts;
14
13
  decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
15
14
  resyncIntervalMs?: number;
16
- } & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
15
+ } & { velocityClient: VelocityClient };
17
16
 
18
17
  export interface SignedMsgUserOrdersAccountSubscriberEvents {
19
18
  onAccountUpdate: (
@@ -31,10 +30,6 @@ export interface SignedMsgUserOrdersAccountSubscriberEvents {
31
30
 
32
31
  export class SignedMsgUserOrdersAccountSubscriber {
33
32
  protected velocityClient: VelocityClient;
34
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
35
- protected get driftClient(): VelocityClient {
36
- return this.velocityClient;
37
- }
38
33
  protected commitment: Commitment;
39
34
  protected resubOpts?: ResubOpts;
40
35
  protected resyncTimeoutId?: ReturnType<typeof setTimeout>;
@@ -60,7 +55,6 @@ export class SignedMsgUserOrdersAccountSubscriber {
60
55
 
61
56
  constructor({
62
57
  velocityClient,
63
- driftClient,
64
58
  commitment,
65
59
  resubOpts,
66
60
  decodeFn,
@@ -69,7 +63,7 @@ export class SignedMsgUserOrdersAccountSubscriber {
69
63
  this.commitment = commitment ?? 'confirmed';
70
64
  this.resubOpts = resubOpts;
71
65
  // Type-system guarantees at least one of the two is supplied.
72
- this.velocityClient = (velocityClient ?? driftClient)!;
66
+ this.velocityClient = velocityClient!;
73
67
  this.decodeFn =
74
68
  decodeFn ??
75
69
  (
@@ -4,7 +4,6 @@ import {
4
4
  } from '../constants/perpMarkets';
5
5
  import { VelocityClient } from '../velocityClient';
6
6
  import { VelocityEnv } from '../config';
7
- import { AtLeastOne } from '../util/deprecatedAlias';
8
7
  import {
9
8
  getUserAccountPublicKey,
10
9
  getUserStatsAccountPublicKey,
@@ -33,16 +32,16 @@ type SwiftOrderSubscriberConfigBase = {
33
32
  endpoint?: string;
34
33
  marketIndexes: number[];
35
34
  /**
36
- In the future, this will be used for verifying $DRIFT stake as we add
35
+ In the future, this will be used for verifying $VELOCITY stake as we add
37
36
  authentication for delegate signers
38
37
  For now, pass a new keypair or a keypair to an empty wallet
39
38
  */
40
39
  keypair: Keypair;
41
40
  };
42
41
 
43
- export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase &
44
- AtLeastOne<'velocityEnv', 'driftEnv', VelocityEnv> &
45
- AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
42
+ export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase & {
43
+ velocityEnv: VelocityEnv;
44
+ } & { velocityClient: VelocityClient };
46
45
 
47
46
  /**
48
47
  * Swift order message received from WebSocket
@@ -74,10 +73,6 @@ export class SwiftOrderSubscriber {
74
73
  private readonly heartbeatIntervalMs = 60000;
75
74
  private ws: WebSocket | null = null;
76
75
  private velocityClient: VelocityClient;
77
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
78
- private get driftClient(): VelocityClient {
79
- return this.velocityClient;
80
- }
81
76
  public userAccountGetter?: AccountGetter; // In practice, this for now is just an OrderSubscriber or a UserMap
82
77
  public onOrder: (
83
78
  orderMessageRaw: SwiftOrderMessage,
@@ -91,7 +86,7 @@ export class SwiftOrderSubscriber {
91
86
 
92
87
  constructor(private config: SwiftOrderSubscriberConfig) {
93
88
  // Type-system guarantees at least one of the two is supplied.
94
- this.velocityClient = (config.velocityClient ?? config.driftClient)!;
89
+ this.velocityClient = config.velocityClient!;
95
90
  this.userAccountGetter = config.userAccountGetter;
96
91
  }
97
92
 
@@ -105,7 +100,7 @@ export class SwiftOrderSubscriber {
105
100
  }
106
101
 
107
102
  getSymbolForMarketIndex(marketIndex: number): string {
108
- const env = this.config.velocityEnv ?? this.config.driftEnv;
103
+ const env = this.config.velocityEnv;
109
104
  const markets = env === 'devnet' ? DevnetPerpMarkets : MainnetPerpMarkets;
110
105
  return markets[marketIndex].symbol;
111
106
  }
@@ -162,7 +157,7 @@ export class SwiftOrderSubscriber {
162
157
  ): Promise<void> {
163
158
  this.onOrder = onOrder;
164
159
 
165
- const env = this.config.velocityEnv ?? this.config.driftEnv;
160
+ const env = this.config.velocityEnv;
166
161
  const endpoint =
167
162
  this.config.endpoint ??
168
163
  (env === 'devnet'