@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/.prettierignore CHANGED
@@ -1 +1 @@
1
- src/idl/drift.ts
1
+ src/idl/velocity.ts
package/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.5...sdk-v0.1.0) (2026-06-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * add builder codes on non swift ([#68](https://github.com/drift-labs/protocol-v2-shadow/issues/68)) ([2df4034](https://github.com/drift-labs/protocol-v2-shadow/commit/2df4034b2162f0df060b21453a16566f9de24f4f))
9
+ * add transfer deposit by delegate ([16386ca](https://github.com/drift-labs/protocol-v2-shadow/commit/16386cad98a2a48d9a8a249ff75c9ce646e9fcac))
10
+ * decouple AMM from rest of codebase ([84aba6d](https://github.com/drift-labs/protocol-v2-shadow/commit/84aba6d0c17ef97069185d82b74671bde6619919))
11
+ * rebrand drift to velocity ([9c330b1](https://github.com/drift-labs/protocol-v2-shadow/commit/9c330b17cda7170482cc8b75ad3d1b3c137a8d32))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * resolve eslint unused-var and prettier formatting failures ([a3a1e3e](https://github.com/drift-labs/protocol-v2-shadow/commit/a3a1e3e1cbf68f35a7c39ea335927d0136c5bce1))
17
+
18
+
19
+ ### Refactors
20
+
21
+ * gather vAMM and hedge into a single VLP module ([905edc3](https://github.com/drift-labs/protocol-v2-shadow/commit/905edc338b453a1ce0ebb4dd9a13be97c66aa66d))
22
+
23
+ ## [0.0.5](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.4...sdk-v0.0.5) (2026-05-28)
24
+
25
+
26
+ ### Refactors
27
+
28
+ * increase oracle_price_offset to i64 ([#51](https://github.com/drift-labs/protocol-v2-shadow/issues/51)) ([d04039a](https://github.com/drift-labs/protocol-v2-shadow/commit/d04039a22b2ff37d05afd8fe271b9913d66689e1))
29
+
30
+ ## [0.0.4](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.3...sdk-v0.0.4) (2026-05-28)
31
+
32
+
33
+ ### Refactors
34
+
35
+ * increase oracle_price_offset to i64 ([#51](https://github.com/drift-labs/protocol-v2-shadow/issues/51)) ([d04039a](https://github.com/drift-labs/protocol-v2-shadow/commit/d04039a22b2ff37d05afd8fe271b9913d66689e1))
package/README.md CHANGED
@@ -19,20 +19,20 @@ npm i @velocity-exchange/sdk
19
19
 
20
20
  ## Getting Started
21
21
 
22
- _Start here if you're integrating with Drift!_
22
+ _Start here if you're integrating with Velocity!_
23
23
 
24
- - [Drift v2-teacher + API Docs](https://drift-labs.github.io/v2-teacher/)
24
+ - [Velocity v2-teacher + API Docs](https://drift-labs.github.io/v2-teacher/)
25
25
  - Docs and examples for using the SDK in Typescript and Python
26
- - Useful concepts and examples when integrating Drift
27
- - Docs for Drift's "Data API"
26
+ - Useful concepts and examples when integrating Velocity
27
+ - Docs for Velocity's "Data API"
28
28
  - [Typescript API docs](https://drift-labs.github.io/protocol-v2/sdk/)
29
- - JSDoc automated documentation for the Drift v2 Typescript SDK
30
- - [Drift docs](https://docs.drift.trade/)
31
- - Comprehensive universal docs for Drift
29
+ - JSDoc automated documentation for the Velocity v2 Typescript SDK
30
+ - [Velocity docs](https://docs.drift.trade/)
31
+ - Comprehensive universal docs for Velocity
32
32
 
33
33
  ---
34
34
 
35
- The below is a light overview of using Solana and Drift's typescript sdk. If you want comprehensive docs with examples of how to integrate with Drift you should use the [v2-teacher docs](https://drift-labs.github.io/v2-teacher/).
35
+ The below is a light overview of using Solana and Velocity's typescript sdk. If you want comprehensive docs with examples of how to integrate with Velocity you should use the [v2-teacher docs](https://drift-labs.github.io/v2-teacher/).
36
36
 
37
37
  ### Setting up a wallet for your program
38
38
 
@@ -40,7 +40,7 @@ The below is a light overview of using Solana and Drift's typescript sdk. If you
40
40
  # Generate a keypair
41
41
  solana-keygen new
42
42
 
43
- # Get the pubkey for the new wallet (You will need to send USDC to this address to Deposit into Drift (only on mainnet - devnet has a faucet for USDC))
43
+ # Get the pubkey for the new wallet (You will need to send USDC to this address to Deposit into Velocity (only on mainnet - devnet has a faucet for USDC))
44
44
  solana address
45
45
 
46
46
  # Put the private key into your .env to be used by your bot
@@ -52,14 +52,14 @@ echo BOT_PRIVATE_KEY=`cat ~/.config/solana/id.json` >> .env
52
52
 
53
53
  ### BN / Precision
54
54
 
55
- The Drift SDK uses BigNum (BN), using [this package](https://github.com/indutny/bn.js/), to represent numerical values. This is because Solana tokens tend to use levels of precision which are too precise for standard Javascript floating point numbers to handle. All numbers in BN are represented as integers, and we will often denote the `precision` of the number so that it can be converted back down to a regular number.
55
+ The Velocity SDK uses BigNum (BN), using [this package](https://github.com/indutny/bn.js/), to represent numerical values. This is because Solana tokens tend to use levels of precision which are too precise for standard Javascript floating point numbers to handle. All numbers in BN are represented as integers, and we will often denote the `precision` of the number so that it can be converted back down to a regular number.
56
56
 
57
57
  ```bash
58
58
  Example:
59
59
  a BigNum: 10,500,000, with precision 10^6, is equal to 10.5 because 10,500,000 / 10^6 = 10.5.
60
60
  ```
61
61
 
62
- The Drift SDK uses some common precisions, which are available as constants to import from the SDK.
62
+ The Velocity SDK uses some common precisions, which are available as constants to import from the SDK.
63
63
 
64
64
  | Precision Name | Value |
65
65
  | --------------------- | ----- |
@@ -99,7 +99,7 @@ import { getAssociatedTokenAddress, TOKEN_PROGRAM_ID } from '@solana/spl-token';
99
99
  import { Connection, Keypair, PublicKey } from '@solana/web3.js';
100
100
  import {
101
101
  calculateReservePrice,
102
- DriftClient,
102
+ VelocityClient,
103
103
  User,
104
104
  initialize,
105
105
  PositionDirection,
@@ -132,7 +132,7 @@ const main = async () => {
132
132
  const env = 'devnet';
133
133
  // const env = 'mainnet-beta';
134
134
 
135
- // Initialize Drift SDK
135
+ // Initialize Velocity SDK
136
136
  const sdkConfig = initialize({ env });
137
137
 
138
138
  // Set up the Wallet and Provider
@@ -169,30 +169,30 @@ const main = async () => {
169
169
  provider.wallet.publicKey.toString()
170
170
  );
171
171
 
172
- // Set up the Drift Client
173
- const driftPublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
172
+ // Set up the Velocity Client
173
+ const velocityPublicKey = new PublicKey(sdkConfig.VELOCITY_PROGRAM_ID);
174
174
  const bulkAccountLoader = new BulkAccountLoader(
175
175
  provider.connection,
176
176
  'confirmed',
177
177
  1000
178
178
  );
179
- const driftClient = new DriftClient({
179
+ const velocityClient = new VelocityClient({
180
180
  connection: provider.connection,
181
181
  wallet: provider.wallet,
182
- programID: driftPublicKey,
182
+ programID: velocityPublicKey,
183
183
  accountSubscription: {
184
184
  type: 'polling',
185
185
  accountLoader: bulkAccountLoader,
186
186
  },
187
187
  });
188
- await driftClient.subscribe();
188
+ await velocityClient.subscribe();
189
189
 
190
- console.log('subscribed to driftClient');
190
+ console.log('subscribed to velocityClient');
191
191
 
192
192
  // Set up user client
193
193
  const user = new User({
194
- driftClient: driftClient,
195
- userAccountPublicKey: await driftClient.getUserAccountPublicKey(),
194
+ velocityClient: velocityClient,
195
+ userAccountPublicKey: await velocityClient.getUserAccountPublicKey(),
196
196
  accountSubscription: {
197
197
  type: 'polling',
198
198
  accountLoader: bulkAccountLoader,
@@ -206,13 +206,13 @@ const main = async () => {
206
206
  console.log(
207
207
  'initializing to',
208
208
  env,
209
- ' drift account for',
209
+ ' velocity account for',
210
210
  provider.wallet.publicKey.toString()
211
211
  );
212
212
 
213
- //// Create a Drift V2 account by Depositing some USDC ($10,000 in this case)
213
+ //// Create a Velocity V2 account by Depositing some USDC ($10,000 in this case)
214
214
  const depositAmount = new BN(10000).mul(QUOTE_PRECISION);
215
- await driftClient.initializeUserAccountAndDepositCollateral(
215
+ await velocityClient.initializeUserAccountAndDepositCollateral(
216
216
  depositAmount,
217
217
  await getTokenAddress(
218
218
  usdcTokenAddress.toString(),
@@ -232,8 +232,8 @@ const main = async () => {
232
232
 
233
233
  // Get vAMM bid and ask price
234
234
  const [bid, ask] = calculateBidAskPrice(
235
- driftClient.getPerpMarketAccount(marketIndex).amm,
236
- driftClient.getOracleDataForPerpMarket(marketIndex)
235
+ velocityClient.getPerpMarketAccount(marketIndex).amm,
236
+ velocityClient.getOracleDataForPerpMarket(marketIndex)
237
237
  );
238
238
 
239
239
  const formattedBidPrice = convertToNumber(bid, PRICE_PRECISION);
@@ -244,12 +244,12 @@ const main = async () => {
244
244
  `vAMM bid: $${formattedBidPrice} and ask: $${formattedAskPrice}`
245
245
  );
246
246
 
247
- const solMarketAccount = driftClient.getPerpMarketAccount(
247
+ const solMarketAccount = velocityClient.getPerpMarketAccount(
248
248
  solMarketInfo.marketIndex
249
249
  );
250
250
  console.log(env, `Placing a 1 SOL-PERP LONG order`);
251
251
 
252
- const txSig = await driftClient.placePerpOrder(
252
+ const txSig = await velocityClient.placePerpOrder(
253
253
  getMarketOrderParams({
254
254
  baseAssetAmount: new BN(1).mul(BASE_PRECISION),
255
255
  direction: PositionDirection.LONG,
@@ -267,8 +267,8 @@ main();
267
267
 
268
268
  ## License
269
269
 
270
- Drift Protocol v2 is licensed under [Apache 2.0](./LICENSE).
270
+ Velocity Protocol v2 is licensed under [Apache 2.0](./LICENSE).
271
271
 
272
272
  Unless you explicitly state otherwise, any contribution intentionally submitted
273
- for inclusion in Drift SDK by you, as defined in the Apache-2.0 license, shall be
273
+ for inclusion in Velocity SDK by you, as defined in the Apache-2.0 license, shall be
274
274
  licensed as above, without any additional terms or conditions.
package/bun.lock CHANGED
@@ -3,7 +3,7 @@
3
3
  "configVersion": 0,
4
4
  "workspaces": {
5
5
  "": {
6
- "name": "@drift-labs/sdk",
6
+ "name": "@velocity-exchange/sdk",
7
7
  "dependencies": {
8
8
  "@anchor-lang/core": "1.0.1",
9
9
  "@coral-xyz/anchor": "npm:@anchor-lang/core@1.0.1",
@@ -69,7 +69,7 @@ class grpcProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.W
69
69
  const request = {
70
70
  slots: {},
71
71
  accounts: {
72
- drift: {
72
+ velocity: {
73
73
  account: [],
74
74
  owner: [this.program.programId.toBase58()],
75
75
  filters,
@@ -10,7 +10,3 @@ export declare class grpcVelocityClientAccountSubscriber extends WebSocketVeloci
10
10
  subscribeToPerpMarketAccount(marketIndex: number): Promise<boolean>;
11
11
  subscribeToOracle(oracleInfo: OracleInfo): Promise<boolean>;
12
12
  }
13
- /** @deprecated Use `grpcVelocityClientAccountSubscriber` instead. `grpcDriftClientAccountSubscriber` will be removed in a future major. */
14
- export declare const grpcDriftClientAccountSubscriber: typeof grpcVelocityClientAccountSubscriber;
15
- /** @deprecated Use `grpcVelocityClientAccountSubscriber` instead. `grpcDriftClientAccountSubscriber` will be removed in a future major. */
16
- export type grpcDriftClientAccountSubscriber = grpcVelocityClientAccountSubscriber;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.grpcDriftClientAccountSubscriber = exports.grpcVelocityClientAccountSubscriber = void 0;
3
+ exports.grpcVelocityClientAccountSubscriber = void 0;
4
4
  const webSocketVelocityClientAccountSubscriber_1 = require("./webSocketVelocityClientAccountSubscriber");
5
5
  const config_1 = require("../config");
6
6
  const pda_1 = require("../addresses/pda");
@@ -97,5 +97,3 @@ class grpcVelocityClientAccountSubscriber extends webSocketVelocityClientAccount
97
97
  }
98
98
  }
99
99
  exports.grpcVelocityClientAccountSubscriber = grpcVelocityClientAccountSubscriber;
100
- /** @deprecated Use `grpcVelocityClientAccountSubscriber` instead. `grpcDriftClientAccountSubscriber` will be removed in a future major. */
101
- exports.grpcDriftClientAccountSubscriber = grpcVelocityClientAccountSubscriber;
@@ -63,7 +63,3 @@ export declare class grpcVelocityClientAccountSubscriberV2 implements VelocityCl
63
63
  unsubscribeFromOracles(): Promise<void>;
64
64
  unsubscribe(): Promise<void>;
65
65
  }
66
- /** @deprecated Use `grpcVelocityClientAccountSubscriberV2` instead. `grpcDriftClientAccountSubscriberV2` will be removed in a future major. */
67
- export declare const grpcDriftClientAccountSubscriberV2: typeof grpcVelocityClientAccountSubscriberV2;
68
- /** @deprecated Use `grpcVelocityClientAccountSubscriberV2` instead. `grpcDriftClientAccountSubscriberV2` will be removed in a future major. */
69
- export type grpcDriftClientAccountSubscriberV2 = grpcVelocityClientAccountSubscriberV2;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.grpcDriftClientAccountSubscriberV2 = exports.grpcVelocityClientAccountSubscriberV2 = void 0;
3
+ exports.grpcVelocityClientAccountSubscriberV2 = void 0;
4
4
  const events_1 = require("events");
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  const config_1 = require("../config");
@@ -206,7 +206,7 @@ class grpcVelocityClientAccountSubscriberV2 {
206
206
  if (!perpMarketAccount || !oracleId) {
207
207
  return undefined;
208
208
  }
209
- if (!perpMarketAccount.data.amm.oracle.equals(oracle)) {
209
+ if (!perpMarketAccount.data.oracle.equals(oracle)) {
210
210
  // If the oracle has changed, we need to update the oracle map in background
211
211
  this.setPerpOracleMap();
212
212
  }
@@ -236,12 +236,12 @@ class grpcVelocityClientAccountSubscriberV2 {
236
236
  }
237
237
  const perpMarketAccount = perpMarket.data;
238
238
  const perpMarketIndex = perpMarketAccount.marketIndex;
239
- const oracle = perpMarketAccount.amm.oracle;
240
- const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.amm.oracleSource);
239
+ const oracle = perpMarketAccount.oracle;
240
+ const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.oracleSource);
241
241
  if (!((_c = this.oracleMultiSubscriber) === null || _c === void 0 ? void 0 : _c.getAccountDataMap().has(oracleId))) {
242
242
  addOraclePromises.push(this.addOracle({
243
243
  publicKey: oracle,
244
- source: perpMarket.data.amm.oracleSource,
244
+ source: perpMarket.data.oracleSource,
245
245
  }));
246
246
  }
247
247
  this.perpOracleMap.set(perpMarketIndex, oracle);
@@ -453,5 +453,3 @@ class grpcVelocityClientAccountSubscriberV2 {
453
453
  }
454
454
  }
455
455
  exports.grpcVelocityClientAccountSubscriberV2 = grpcVelocityClientAccountSubscriberV2;
456
- /** @deprecated Use `grpcVelocityClientAccountSubscriberV2` instead. `grpcDriftClientAccountSubscriberV2` will be removed in a future major. */
457
- exports.grpcDriftClientAccountSubscriberV2 = grpcVelocityClientAccountSubscriberV2;
@@ -72,7 +72,7 @@ class LaserstreamProgramAccountSubscriber extends webSocketProgramAccountSubscri
72
72
  const request = {
73
73
  slots: {},
74
74
  accounts: {
75
- drift: {
75
+ velocity: {
76
76
  account: [],
77
77
  owner: [this.program.programId.toBase58()],
78
78
  filters,
@@ -67,7 +67,3 @@ export declare class PollingVelocityClientAccountSubscriber implements VelocityC
67
67
  getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
68
68
  updateAccountLoaderPollingFrequency(pollingFrequency: number): void;
69
69
  }
70
- /** @deprecated Use `PollingVelocityClientAccountSubscriber` instead. `PollingDriftClientAccountSubscriber` will be removed in a future major. */
71
- export declare const PollingDriftClientAccountSubscriber: typeof PollingVelocityClientAccountSubscriber;
72
- /** @deprecated Use `PollingVelocityClientAccountSubscriber` instead. `PollingDriftClientAccountSubscriber` will be removed in a future major. */
73
- export type PollingDriftClientAccountSubscriber = PollingVelocityClientAccountSubscriber;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PollingDriftClientAccountSubscriber = exports.PollingVelocityClientAccountSubscriber = void 0;
3
+ exports.PollingVelocityClientAccountSubscriber = void 0;
4
4
  const types_1 = require("./types");
5
5
  const events_1 = require("events");
6
6
  const types_2 = require("../types");
@@ -300,12 +300,12 @@ class PollingVelocityClientAccountSubscriber {
300
300
  for (const perpMarket of perpMarkets) {
301
301
  const perpMarketAccount = perpMarket.data;
302
302
  const perpMarketIndex = perpMarketAccount.marketIndex;
303
- const oracle = perpMarketAccount.amm.oracle;
304
- const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarketAccount.amm.oracleSource);
303
+ const oracle = perpMarketAccount.oracle;
304
+ const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarketAccount.oracleSource);
305
305
  if (!this.oracles.has(oracleId)) {
306
306
  oraclePromises.push(this.addOracle({
307
307
  publicKey: oracle,
308
- source: perpMarketAccount.amm.oracleSource,
308
+ source: perpMarketAccount.oracleSource,
309
309
  }));
310
310
  }
311
311
  this.perpOracleMap.set(perpMarketIndex, oracle);
@@ -392,7 +392,7 @@ class PollingVelocityClientAccountSubscriber {
392
392
  if (!perpMarketAccount || !oracle) {
393
393
  return undefined;
394
394
  }
395
- if (!perpMarketAccount.data.amm.oracle.equals(oracle)) {
395
+ if (!perpMarketAccount.data.oracle.equals(oracle)) {
396
396
  // If the oracle has changed, we need to update the oracle map in background
397
397
  this.setPerpOracleMap();
398
398
  }
@@ -416,5 +416,3 @@ class PollingVelocityClientAccountSubscriber {
416
416
  }
417
417
  }
418
418
  exports.PollingVelocityClientAccountSubscriber = PollingVelocityClientAccountSubscriber;
419
- /** @deprecated Use `PollingVelocityClientAccountSubscriber` instead. `PollingDriftClientAccountSubscriber` will be removed in a future major. */
420
- exports.PollingDriftClientAccountSubscriber = PollingVelocityClientAccountSubscriber;
@@ -8,8 +8,8 @@
8
8
  * market, oracle, and state accounts cached in memory. `User` uses a `UserAccountSubscriber`
9
9
  * for the individual User account. All subscribers implement the interfaces defined here.
10
10
  *
11
- * Implementations: `webSocketDriftClientAccountSubscriber.ts` (default),
12
- * `pollingDriftClientAccountSubscriber.ts`, `bulkAccountLoader.ts` (batched RPC).
11
+ * Implementations: `webSocketVelocityClientAccountSubscriber.ts` (default),
12
+ * `pollingVelocityClientAccountSubscriber.ts`, `bulkAccountLoader.ts` (batched RPC).
13
13
  */
14
14
  import { SpotMarketAccount, PerpMarketAccount, OracleSource, StateAccount, UserAccount, UserStatsAccount, InsuranceFundStake, ConstituentAccount } from '../types';
15
15
  import StrictEventEmitter from 'strict-event-emitter-types';
@@ -42,9 +42,6 @@ export interface VelocityClientAccountEvents {
42
42
  update: void;
43
43
  error: (e: Error) => void;
44
44
  }
45
- /** @deprecated Use `VelocityClientAccountEvents` instead. `DriftClientAccountEvents` will be removed in a future major. */
46
- export interface DriftClientAccountEvents extends VelocityClientAccountEvents {
47
- }
48
45
  export interface VelocityClientAccountSubscriber {
49
46
  eventEmitter: StrictEventEmitter<EventEmitter, VelocityClientAccountEvents>;
50
47
  isSubscribed: boolean;
@@ -66,9 +63,6 @@ export interface VelocityClientAccountSubscriber {
66
63
  getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
67
64
  updateAccountLoaderPollingFrequency?: (pollingFrequency: number) => void;
68
65
  }
69
- /** @deprecated Use `VelocityClientAccountSubscriber` instead. `DriftClientAccountSubscriber` will be removed in a future major. */
70
- export interface DriftClientAccountSubscriber extends VelocityClientAccountSubscriber {
71
- }
72
66
  export declare enum DelistedMarketSetting {
73
67
  Unsubscribe = 0,
74
68
  Subscribe = 1,
@@ -17,8 +17,8 @@ function findDelistedPerpMarketsAndOracles(perpMarkets, spotMarkets) {
17
17
  if ((0, types_1.isVariant)(perpMarket.data.status, 'delisted')) {
18
18
  delistedPerpMarketIndexes.push(perpMarket.data.marketIndex);
19
19
  delistedOracles.push({
20
- publicKey: perpMarket.data.amm.oracle,
21
- source: perpMarket.data.amm.oracleSource,
20
+ publicKey: perpMarket.data.oracle,
21
+ source: perpMarket.data.oracleSource,
22
22
  });
23
23
  }
24
24
  }
@@ -71,7 +71,3 @@ export declare class WebSocketVelocityClientAccountSubscriber implements Velocit
71
71
  getOraclePriceDataAndSlotForPerpMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
72
72
  getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
73
73
  }
74
- /** @deprecated Use `WebSocketVelocityClientAccountSubscriber` instead. `WebSocketDriftClientAccountSubscriber` will be removed in a future major. */
75
- export declare const WebSocketDriftClientAccountSubscriber: typeof WebSocketVelocityClientAccountSubscriber;
76
- /** @deprecated Use `WebSocketVelocityClientAccountSubscriber` instead. `WebSocketDriftClientAccountSubscriber` will be removed in a future major. */
77
- export type WebSocketDriftClientAccountSubscriber = WebSocketVelocityClientAccountSubscriber;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebSocketDriftClientAccountSubscriber = exports.WebSocketVelocityClientAccountSubscriber = void 0;
3
+ exports.WebSocketVelocityClientAccountSubscriber = void 0;
4
4
  const types_1 = require("./types");
5
5
  const events_1 = require("events");
6
6
  const pda_1 = require("../addresses/pda");
@@ -279,12 +279,12 @@ class WebSocketVelocityClientAccountSubscriber {
279
279
  }
280
280
  const perpMarketAccount = perpMarket.data;
281
281
  const perpMarketIndex = perpMarketAccount.marketIndex;
282
- const oracle = perpMarketAccount.amm.oracle;
283
- const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.amm.oracleSource);
282
+ const oracle = perpMarketAccount.oracle;
283
+ const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.oracleSource);
284
284
  if (!this.oracleSubscribers.has(oracleId)) {
285
285
  addOraclePromises.push(this.addOracle({
286
286
  publicKey: oracle,
287
- source: perpMarket.data.amm.oracleSource,
287
+ source: perpMarket.data.oracleSource,
288
288
  }));
289
289
  }
290
290
  this.perpOracleMap.set(perpMarketIndex, oracle);
@@ -375,7 +375,7 @@ class WebSocketVelocityClientAccountSubscriber {
375
375
  if (!perpMarketAccount || !oracleId) {
376
376
  return undefined;
377
377
  }
378
- if (!perpMarketAccount.data.amm.oracle.equals(oracle)) {
378
+ if (!perpMarketAccount.data.oracle.equals(oracle)) {
379
379
  // If the oracle has changed, we need to update the oracle map in background
380
380
  this.setPerpOracleMap();
381
381
  }
@@ -396,5 +396,3 @@ class WebSocketVelocityClientAccountSubscriber {
396
396
  }
397
397
  }
398
398
  exports.WebSocketVelocityClientAccountSubscriber = WebSocketVelocityClientAccountSubscriber;
399
- /** @deprecated Use `WebSocketVelocityClientAccountSubscriber` instead. `WebSocketDriftClientAccountSubscriber` will be removed in a future major. */
400
- exports.WebSocketDriftClientAccountSubscriber = WebSocketVelocityClientAccountSubscriber;
@@ -85,7 +85,3 @@ export declare class WebSocketVelocityClientAccountSubscriberV2 implements Veloc
85
85
  getOraclePriceDataAndSlotForPerpMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
86
86
  getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
87
87
  }
88
- /** @deprecated Use `WebSocketVelocityClientAccountSubscriberV2` instead. `WebSocketDriftClientAccountSubscriberV2` will be removed in a future major. */
89
- export declare const WebSocketDriftClientAccountSubscriberV2: typeof WebSocketVelocityClientAccountSubscriberV2;
90
- /** @deprecated Use `WebSocketVelocityClientAccountSubscriberV2` instead. `WebSocketDriftClientAccountSubscriberV2` will be removed in a future major. */
91
- export type WebSocketDriftClientAccountSubscriberV2 = WebSocketVelocityClientAccountSubscriberV2;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebSocketDriftClientAccountSubscriberV2 = exports.WebSocketVelocityClientAccountSubscriberV2 = void 0;
3
+ exports.WebSocketVelocityClientAccountSubscriberV2 = void 0;
4
4
  const types_1 = require("./types");
5
5
  const types_2 = require("../types");
6
6
  const events_1 = require("events");
@@ -330,12 +330,12 @@ class WebSocketVelocityClientAccountSubscriberV2 {
330
330
  }
331
331
  const perpMarketAccount = perpMarket.data;
332
332
  const perpMarketIndex = perpMarketAccount.marketIndex;
333
- const oracle = perpMarketAccount.amm.oracle;
334
- const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.amm.oracleSource);
333
+ const oracle = perpMarketAccount.oracle;
334
+ const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.oracleSource);
335
335
  if (!this.oracleSubscribers.has(oracleId)) {
336
336
  addOraclePromises.push(this.addOracle({
337
337
  publicKey: oracle,
338
- source: perpMarket.data.amm.oracleSource,
338
+ source: perpMarket.data.oracleSource,
339
339
  }));
340
340
  }
341
341
  this.perpOracleMap.set(perpMarketIndex, oracle);
@@ -421,7 +421,7 @@ class WebSocketVelocityClientAccountSubscriberV2 {
421
421
  if (!perpMarketAccount || !oracleId) {
422
422
  return undefined;
423
423
  }
424
- if (!perpMarketAccount.data.amm.oracle.equals(oracle)) {
424
+ if (!perpMarketAccount.data.oracle.equals(oracle)) {
425
425
  // If the oracle has changed, we need to update the oracle map in background
426
426
  this.setPerpOracleMap();
427
427
  }
@@ -442,5 +442,3 @@ class WebSocketVelocityClientAccountSubscriberV2 {
442
442
  }
443
443
  }
444
444
  exports.WebSocketVelocityClientAccountSubscriberV2 = WebSocketVelocityClientAccountSubscriberV2;
445
- /** @deprecated Use `WebSocketVelocityClientAccountSubscriberV2` instead. `WebSocketDriftClientAccountSubscriberV2` will be removed in a future major. */
446
- exports.WebSocketDriftClientAccountSubscriberV2 = WebSocketVelocityClientAccountSubscriberV2;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * PDA derivation helpers for all Drift protocol accounts.
2
+ * PDA derivation helpers for all Velocity protocol accounts.
3
3
  * Covers: User, UserStats, PerpMarket, SpotMarket, InsuranceFundStake,
4
4
  * HighLeverageModeConfig, State, and vault PDAs.
5
5
  * All functions are pure (no RPC calls).
@@ -7,11 +7,7 @@
7
7
  import { PublicKey } from '@solana/web3.js';
8
8
  import { SpotMarketAccount } from '../types';
9
9
  export declare function getVelocityStateAccountPublicKeyAndNonce(programId: PublicKey): Promise<[PublicKey, number]>;
10
- /** @deprecated Use `getVelocityStateAccountPublicKeyAndNonce` instead. `getDriftStateAccountPublicKeyAndNonce` will be removed in a future major. */
11
- export declare const getDriftStateAccountPublicKeyAndNonce: typeof getVelocityStateAccountPublicKeyAndNonce;
12
10
  export declare function getVelocityStateAccountPublicKey(programId: PublicKey): Promise<PublicKey>;
13
- /** @deprecated Use `getVelocityStateAccountPublicKey` instead. `getDriftStateAccountPublicKey` will be removed in a future major. */
14
- export declare const getDriftStateAccountPublicKey: typeof getVelocityStateAccountPublicKey;
15
11
  export declare function getUserAccountPublicKeyAndNonce(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<[PublicKey, number]>;
16
12
  export declare function getUserAccountPublicKey(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<PublicKey>;
17
13
  export declare function getUserAccountPublicKeySync(programId: PublicKey, authority: PublicKey, subAccountId?: number): PublicKey;
@@ -26,8 +22,6 @@ export declare function getSpotMarketVaultPublicKey(programId: PublicKey, market
26
22
  export declare function getInsuranceFundVaultPublicKey(programId: PublicKey, marketIndex: number): Promise<PublicKey>;
27
23
  export declare function getInsuranceFundStakeAccountPublicKey(programId: PublicKey, authority: PublicKey, marketIndex: number): PublicKey;
28
24
  export declare function getVelocitySignerPublicKey(programId: PublicKey): PublicKey;
29
- /** @deprecated Use `getVelocitySignerPublicKey` instead. `getDriftSignerPublicKey` will be removed in a future major. */
30
- export declare const getDriftSignerPublicKey: typeof getVelocitySignerPublicKey;
31
25
  export declare function getReferrerNamePublicKeySync(programId: PublicKey, nameBuffer: number[]): PublicKey;
32
26
  export declare function getProtocolIfSharesTransferConfigPublicKey(programId: PublicKey): PublicKey;
33
27
  export declare function getPrelaunchOraclePublicKey(programId: PublicKey, marketIndex: number): PublicKey;
@@ -23,9 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getLpPoolTokenTokenAccountPublicKey = exports.getConstituentCorrelationsPublicKey = exports.getAmmCachePublicKey = exports.getConstituentVaultPublicKey = exports.getConstituentPublicKey = exports.getConstituentTargetBasePublicKey = exports.getAmmConstituentMappingPublicKey = exports.getLpPoolTokenVaultPublicKey = exports.getLpPoolPublicKey = exports.getRevenueShareEscrowAccountPublicKey = exports.getRevenueShareAccountPublicKey = exports.getIfRebalanceConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getDriftSignerPublicKey = exports.getVelocitySignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSignedMsgWsDelegatesAccountPublicKey = exports.getSignedMsgUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getVelocityStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = exports.getVelocityStateAccountPublicKeyAndNonce = void 0;
26
+ exports.getLpPoolTokenTokenAccountPublicKey = exports.getConstituentCorrelationsPublicKey = exports.getAmmCachePublicKey = exports.getConstituentVaultPublicKey = exports.getConstituentPublicKey = exports.getConstituentTargetBasePublicKey = exports.getAmmConstituentMappingPublicKey = exports.getLpPoolTokenVaultPublicKey = exports.getLpPoolPublicKey = exports.getRevenueShareEscrowAccountPublicKey = exports.getRevenueShareAccountPublicKey = exports.getIfRebalanceConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getVelocitySignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSignedMsgWsDelegatesAccountPublicKey = exports.getSignedMsgUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getVelocityStateAccountPublicKey = exports.getVelocityStateAccountPublicKeyAndNonce = void 0;
27
27
  /**
28
- * PDA derivation helpers for all Drift protocol accounts.
28
+ * PDA derivation helpers for all Velocity protocol accounts.
29
29
  * Covers: User, UserStats, PerpMarket, SpotMarket, InsuranceFundStake,
30
30
  * HighLeverageModeConfig, State, and vault PDAs.
31
31
  * All functions are pure (no RPC calls).
@@ -36,17 +36,13 @@ const anchor_1 = require("../isomorphic/anchor");
36
36
  const spl_token_1 = require("@solana/spl-token");
37
37
  const types_1 = require("../types");
38
38
  async function getVelocityStateAccountPublicKeyAndNonce(programId) {
39
- return web3_js_1.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('drift_state'))], programId);
39
+ return web3_js_1.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('velocity_state'))], programId);
40
40
  }
41
41
  exports.getVelocityStateAccountPublicKeyAndNonce = getVelocityStateAccountPublicKeyAndNonce;
42
- /** @deprecated Use `getVelocityStateAccountPublicKeyAndNonce` instead. `getDriftStateAccountPublicKeyAndNonce` will be removed in a future major. */
43
- exports.getDriftStateAccountPublicKeyAndNonce = getVelocityStateAccountPublicKeyAndNonce;
44
42
  async function getVelocityStateAccountPublicKey(programId) {
45
43
  return (await getVelocityStateAccountPublicKeyAndNonce(programId))[0];
46
44
  }
47
45
  exports.getVelocityStateAccountPublicKey = getVelocityStateAccountPublicKey;
48
- /** @deprecated Use `getVelocityStateAccountPublicKey` instead. `getDriftStateAccountPublicKey` will be removed in a future major. */
49
- exports.getDriftStateAccountPublicKey = getVelocityStateAccountPublicKey;
50
46
  async function getUserAccountPublicKeyAndNonce(programId, authority, subAccountId = 0) {
51
47
  return web3_js_1.PublicKey.findProgramAddress([
52
48
  Buffer.from(anchor.utils.bytes.utf8.encode('user')),
@@ -139,11 +135,9 @@ function getInsuranceFundStakeAccountPublicKey(programId, authority, marketIndex
139
135
  }
140
136
  exports.getInsuranceFundStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey;
141
137
  function getVelocitySignerPublicKey(programId) {
142
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('drift_signer'))], programId)[0];
138
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('velocity_signer'))], programId)[0];
143
139
  }
144
140
  exports.getVelocitySignerPublicKey = getVelocitySignerPublicKey;
145
- /** @deprecated Use `getVelocitySignerPublicKey` instead. `getDriftSignerPublicKey` will be removed in a future major. */
146
- exports.getDriftSignerPublicKey = getVelocitySignerPublicKey;
147
141
  function getReferrerNamePublicKeySync(programId, nameBuffer) {
148
142
  return web3_js_1.PublicKey.findProgramAddressSync([
149
143
  Buffer.from(anchor.utils.bytes.utf8.encode('referrer_name')),
@@ -313,7 +313,7 @@ export declare class AdminClient extends VelocityClient {
313
313
  updateConstituentCorrelationData(lpPoolId: number, index1: number, index2: number, correlation: BN): Promise<TransactionSignature>;
314
314
  getUpdateConstituentCorrelationDataIx(lpPoolId: number, index1: number, index2: number, correlation: BN): Promise<TransactionInstruction[]>;
315
315
  /**
316
- * Get the drift begin_swap and end_swap instructions
316
+ * Get the velocity begin_swap and end_swap instructions
317
317
  *
318
318
  * @param outMarketIndex the market index of the token you're buying
319
319
  * @param inMarketIndex the market index of the token you're selling