@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
@@ -50,16 +50,16 @@ class AdminClient extends velocityClient_1.VelocityClient {
50
50
  if (stateAccountRPCResponse.value !== null) {
51
51
  throw new Error('Clearing house already initialized');
52
52
  }
53
- const [driftStatePublicKey] = await (0, pda_1.getVelocityStateAccountPublicKeyAndNonce)(this.program.programId);
53
+ const [velocityStatePublicKey] = await (0, pda_1.getVelocityStateAccountPublicKeyAndNonce)(this.program.programId);
54
54
  const initializeIx = await this.program.instruction.initialize({
55
55
  accounts: {
56
56
  admin: this.isSubscribed
57
57
  ? this.getStateAccount().coldAdmin
58
58
  : this.wallet.publicKey,
59
- state: driftStatePublicKey,
59
+ state: velocityStatePublicKey,
60
60
  quoteAssetMint: usdcMint,
61
61
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
62
- driftSigner: this.getSignerPublicKey(),
62
+ velocitySigner: this.getSignerPublicKey(),
63
63
  systemProgram: anchor.web3.SystemProgram.programId,
64
64
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
65
65
  },
@@ -99,7 +99,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
99
99
  spotMarket,
100
100
  spotMarketVault,
101
101
  insuranceFundVault,
102
- driftSigner: this.getSignerPublicKey(),
102
+ velocitySigner: this.getSignerPublicKey(),
103
103
  spotMarketMint: mint,
104
104
  oracle,
105
105
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
@@ -128,7 +128,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
128
128
  spotMarket: spotMarketPublicKey,
129
129
  spotMarketVault: spotMarketVaultPublicKey,
130
130
  insuranceFundVault: insuranceFundVaultPublicKey,
131
- driftSigner: this.getSignerPublicKey(),
131
+ velocitySigner: this.getSignerPublicKey(),
132
132
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
133
133
  },
134
134
  });
@@ -344,7 +344,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
344
344
  ? this.getStateAccount().coldAdmin
345
345
  : this.wallet.publicKey,
346
346
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
347
- oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
347
+ oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
348
348
  },
349
349
  });
350
350
  }
@@ -381,7 +381,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
381
381
  state: await this.getStatePublicKey(),
382
382
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
383
383
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
384
- oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
384
+ oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
385
385
  },
386
386
  });
387
387
  }
@@ -467,14 +467,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
467
467
  }
468
468
  async getRepegAmmCurveIx(newPeg, perpMarketIndex) {
469
469
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
470
- const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
470
+ const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
471
471
  return await this.program.instruction.repegAmmCurve(newPeg, {
472
472
  accounts: {
473
473
  state: await this.getStatePublicKey(),
474
474
  admin: this.isSubscribed
475
475
  ? this.getStateAccount().coldAdmin
476
476
  : this.wallet.publicKey,
477
- oracle: ammData.oracle,
477
+ oracle: perpMarketAccount.oracle,
478
478
  perpMarket: perpMarketPublicKey,
479
479
  },
480
480
  });
@@ -486,7 +486,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
486
486
  return txSig;
487
487
  }
488
488
  async getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex) {
489
- const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
489
+ const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
490
490
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
491
491
  return await this.program.instruction.updatePerpMarketAmmOracleTwap({
492
492
  accounts: {
@@ -494,7 +494,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
494
494
  admin: this.isSubscribed
495
495
  ? this.getStateAccount().coldAdmin
496
496
  : this.wallet.publicKey,
497
- oracle: ammData.oracle,
497
+ oracle: perpMarketAccount.oracle,
498
498
  perpMarket: perpMarketPublicKey,
499
499
  },
500
500
  });
@@ -506,7 +506,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
506
506
  return txSig;
507
507
  }
508
508
  async getResetPerpMarketAmmOracleTwapIx(perpMarketIndex) {
509
- const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
509
+ const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
510
510
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
511
511
  return await this.program.instruction.resetPerpMarketAmmOracleTwap({
512
512
  accounts: {
@@ -514,7 +514,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
514
514
  admin: this.isSubscribed
515
515
  ? this.getStateAccount().coldAdmin
516
516
  : this.wallet.publicKey,
517
- oracle: ammData.oracle,
517
+ oracle: perpMarketAccount.oracle,
518
518
  perpMarket: perpMarketPublicKey,
519
519
  },
520
520
  });
@@ -542,7 +542,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
542
542
  state: await this.getStatePublicKey(),
543
543
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
544
544
  sourceVault,
545
- driftSigner: this.getSignerPublicKey(),
545
+ velocitySigner: this.getSignerPublicKey(),
546
546
  quoteSpotMarket: spotMarket.pubkey,
547
547
  spotMarketVault: spotMarket.vault,
548
548
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -672,7 +672,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
672
672
  state: await this.getStatePublicKey(),
673
673
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
674
674
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
675
- oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
675
+ oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
676
676
  },
677
677
  });
678
678
  }
@@ -1104,7 +1104,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1104
1104
  state: await this.getStatePublicKey(),
1105
1105
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
1106
1106
  oracle: oracle,
1107
- oldOracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
1107
+ oldOracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
1108
1108
  ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
1109
1109
  },
1110
1110
  });
@@ -1714,7 +1714,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1714
1714
  spotMarketVault: await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, outMarketIndex),
1715
1715
  ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, inMarketIndex, outMarketIndex),
1716
1716
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1717
- driftSigner: this.getStateAccount().signer,
1717
+ velocitySigner: this.getStateAccount().signer,
1718
1718
  },
1719
1719
  remainingAccounts,
1720
1720
  });
@@ -1743,7 +1743,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1743
1743
  insuranceFundVault: spotMarket.insuranceFund.vault,
1744
1744
  recipientTokenAccount,
1745
1745
  tokenProgram: tokenProgramId,
1746
- driftSigner: this.getSignerPublicKey(),
1746
+ velocitySigner: this.getSignerPublicKey(),
1747
1747
  },
1748
1748
  remainingAccounts,
1749
1749
  });
@@ -2063,7 +2063,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
2063
2063
  insuranceFundVault: spotMarket.insuranceFund.vault,
2064
2064
  userTokenAccount: userTokenAccountPublicKey,
2065
2065
  tokenProgram: this.getTokenProgramForSpotMarket(spotMarket),
2066
- driftSigner: this.getSignerPublicKey(),
2066
+ velocitySigner: this.getSignerPublicKey(),
2067
2067
  },
2068
2068
  });
2069
2069
  }
@@ -2399,7 +2399,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
2399
2399
  ];
2400
2400
  }
2401
2401
  /**
2402
- * Get the drift begin_swap and end_swap instructions
2402
+ * Get the velocity begin_swap and end_swap instructions
2403
2403
  *
2404
2404
  * @param outMarketIndex the market index of the token you're buying
2405
2405
  * @param inMarketIndex the market index of the token you're selling
@@ -2605,7 +2605,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
2605
2605
  spotMarketVault: withdrawSpotMarket.vault,
2606
2606
  tokenProgram: withdrawTokenProgram,
2607
2607
  mint: withdrawSpotMarket.mint,
2608
- driftSigner: (0, pda_1.getVelocitySignerPublicKey)(this.program.programId),
2608
+ velocitySigner: (0, pda_1.getVelocitySignerPublicKey)(this.program.programId),
2609
2609
  oracle: withdrawSpotMarket.oracle,
2610
2610
  },
2611
2611
  });
@@ -4,13 +4,11 @@ import StrictEventEmitter from 'strict-event-emitter-types';
4
4
  import { EventEmitter } from 'events';
5
5
  export declare class AuctionSubscriber {
6
6
  private velocityClient;
7
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
- private get driftClient();
9
7
  private opts;
10
8
  private resubOpts?;
11
9
  eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
12
10
  private subscriber;
13
- constructor({ velocityClient, driftClient, opts, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
11
+ constructor({ velocityClient, opts, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
14
12
  subscribe(): Promise<void>;
15
13
  unsubscribe(): Promise<void>;
16
14
  }
@@ -5,13 +5,9 @@ const memcmp_1 = require("../memcmp");
5
5
  const events_1 = require("events");
6
6
  const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
7
7
  class AuctionSubscriber {
8
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
9
- get driftClient() {
10
- return this.velocityClient;
11
- }
12
- constructor({ velocityClient, driftClient, opts, resubTimeoutMs, logResubMessages, }) {
8
+ constructor({ velocityClient, opts, resubTimeoutMs, logResubMessages, }) {
13
9
  // Type-system guarantees at least one of the two is supplied.
14
- this.velocityClient = (velocityClient !== null && velocityClient !== void 0 ? velocityClient : driftClient);
10
+ this.velocityClient = velocityClient;
15
11
  this.opts = opts || this.velocityClient.opts;
16
12
  this.eventEmitter = new events_1.EventEmitter();
17
13
  this.resubOpts = { resubTimeoutMs, logResubMessages };
@@ -4,14 +4,12 @@ import StrictEventEmitter from 'strict-event-emitter-types';
4
4
  import { EventEmitter } from 'events';
5
5
  export declare class AuctionSubscriberGrpc {
6
6
  private velocityClient;
7
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
- private get driftClient();
9
7
  private opts;
10
8
  private resubOpts?;
11
9
  private grpcConfigs?;
12
10
  eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
13
11
  private subscriber;
14
- constructor({ velocityClient, driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
12
+ constructor({ velocityClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
15
13
  subscribe(): Promise<void>;
16
14
  unsubscribe(): Promise<void>;
17
15
  }
@@ -5,13 +5,9 @@ const memcmp_1 = require("../memcmp");
5
5
  const events_1 = require("events");
6
6
  const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSubscriber");
7
7
  class AuctionSubscriberGrpc {
8
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
9
- get driftClient() {
10
- return this.velocityClient;
11
- }
12
- constructor({ velocityClient, driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }) {
8
+ constructor({ velocityClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }) {
13
9
  // Type-system guarantees at least one of the two is supplied.
14
- this.velocityClient = (velocityClient !== null && velocityClient !== void 0 ? velocityClient : driftClient);
10
+ this.velocityClient = velocityClient;
15
11
  this.opts = opts || this.velocityClient.opts;
16
12
  this.eventEmitter = new events_1.EventEmitter();
17
13
  this.resubOpts = { resubTimeoutMs, logResubMessages };
@@ -2,14 +2,15 @@ import { GrpcConfigs } from '../accounts/types';
2
2
  import { VelocityClient } from '../velocityClient';
3
3
  import { UserAccount } from '../types';
4
4
  import { ConfirmOptions, PublicKey } from '@solana/web3.js';
5
- import { AtLeastOne } from '../util/deprecatedAlias';
6
5
  type AuctionSubscriberConfigBase = {
7
6
  opts?: ConfirmOptions;
8
7
  resubTimeoutMs?: number;
9
8
  logResubMessages?: boolean;
10
9
  grpcConfigs?: GrpcConfigs;
11
10
  };
12
- export type AuctionSubscriberConfig = AuctionSubscriberConfigBase & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
11
+ export type AuctionSubscriberConfig = AuctionSubscriberConfigBase & {
12
+ velocityClient: VelocityClient;
13
+ };
13
14
  export interface AuctionSubscriberEvents {
14
15
  onAccountUpdate: (account: UserAccount, pubkey: PublicKey, slot: number) => void;
15
16
  }
@@ -4,25 +4,17 @@ import { PerpMarketConfig } from './constants/perpMarkets';
4
4
  import { SpotMarketConfig } from './constants/spotMarkets';
5
5
  import { OracleInfo } from './oracles/types';
6
6
  import { Program } from './isomorphic/anchor';
7
- import { Drift } from './idl/drift';
8
- export type VelocityProgram = Program<Drift>;
9
- /** @deprecated Use `VelocityProgram` instead. `DriftProgram` will be removed in a future major. */
10
- export type DriftProgram = VelocityProgram;
7
+ import { Velocity } from './idl/velocity';
8
+ export type VelocityProgram = Program<Velocity>;
11
9
  export type VelocityEnv = 'devnet' | 'mainnet-beta';
12
- /** @deprecated Use `VelocityEnv` instead. `DriftEnv` will be removed in a future major. */
13
- export type DriftEnv = VelocityEnv;
14
10
  /** Widened env type accepted by `initialize()`; `'master'` is a legacy alias for `'devnet'`. */
15
11
  export type LegacyVelocityEnv = VelocityEnv | 'master';
16
12
  export interface VelocityConfig {
17
13
  ENV: VelocityEnv;
18
14
  PYTH_ORACLE_MAPPING_ADDRESS: string;
19
15
  VELOCITY_PROGRAM_ID: string;
20
- /** @deprecated Use `VELOCITY_PROGRAM_ID` instead. Kept on the config shape so existing callers reading this field continue to work; will be removed in a future major. */
21
- DRIFT_PROGRAM_ID: string;
22
16
  JIT_PROXY_PROGRAM_ID?: string;
23
17
  VELOCITY_ORACLE_RECEIVER_ID: string;
24
- /** @deprecated Use `VELOCITY_ORACLE_RECEIVER_ID` instead. Kept on the config shape so existing callers reading this field continue to work; will be removed in a future major. */
25
- DRIFT_ORACLE_RECEIVER_ID: string;
26
18
  QUOTE_MINT_ADDRESS: string;
27
19
  V2_ALPHA_TICKET_MINT_ADDRESS: string;
28
20
  PERP_MARKETS: PerpMarketConfig[];
@@ -32,17 +24,9 @@ export interface VelocityConfig {
32
24
  MARKET_LOOKUP_TABLES: string[];
33
25
  SB_ON_DEMAND_PID: PublicKey;
34
26
  }
35
- /** @deprecated Use `VelocityConfig` instead. `DriftConfig` will be removed in a future major. */
36
- export type DriftConfig = VelocityConfig;
37
- export declare const VELOCITY_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
38
- /** @deprecated Use `VELOCITY_PROGRAM_ID` instead. `DRIFT_PROGRAM_ID` will be removed in a future major. */
39
- export declare const DRIFT_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
27
+ export declare const VELOCITY_PROGRAM_ID = "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
40
28
  export declare const VELOCITY_DEVNET_PROGRAM_ID = "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
41
- /** @deprecated Use `VELOCITY_DEVNET_PROGRAM_ID` instead. `DRIFT_DEVNET_PROGRAM_ID` will be removed in a future major. */
42
- export declare const DRIFT_DEVNET_PROGRAM_ID = "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
43
29
  export declare const VELOCITY_ORACLE_RECEIVER_ID = "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha";
44
- /** @deprecated Use `VELOCITY_ORACLE_RECEIVER_ID` instead. `DRIFT_ORACLE_RECEIVER_ID` will be removed in a future major. */
45
- export declare const DRIFT_ORACLE_RECEIVER_ID = "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha";
46
30
  export declare const PTYH_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
47
31
  export declare const SB_ON_DEMAND_DEVNET_PID: PublicKey;
48
32
  export declare const SB_ON_DEMAND_MAINNET_PID: PublicKey;
@@ -52,6 +36,13 @@ export declare const configs: {
52
36
  [key in VelocityEnv]: VelocityConfig;
53
37
  };
54
38
  export declare const getConfig: () => VelocityConfig;
39
+ /**
40
+ * Allows customization of the SDK's environment and endpoints. You can pass individual settings to override the settings with your own presets.
41
+ *
42
+ * Defaults to master environment if you don't use this function.
43
+ * @param props
44
+ * @returns
45
+ */
55
46
  export declare const initialize: (props: {
56
47
  env: LegacyVelocityEnv;
57
48
  overrideEnv?: Partial<VelocityConfig>;
@@ -1,19 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findAllMarketAndOracles = exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = exports.DEFAULT_CONFIRMATION_OPTS = exports.PYTH_LAZER_STORAGE_ACCOUNT_KEY = exports.SB_ON_DEMAND_MAINNET_PID = exports.SB_ON_DEMAND_DEVNET_PID = exports.PTYH_LAZER_PROGRAM_ID = exports.DRIFT_ORACLE_RECEIVER_ID = exports.VELOCITY_ORACLE_RECEIVER_ID = exports.DRIFT_DEVNET_PROGRAM_ID = exports.VELOCITY_DEVNET_PROGRAM_ID = exports.DRIFT_PROGRAM_ID = exports.VELOCITY_PROGRAM_ID = void 0;
3
+ exports.findAllMarketAndOracles = exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = exports.DEFAULT_CONFIRMATION_OPTS = exports.PYTH_LAZER_STORAGE_ACCOUNT_KEY = exports.SB_ON_DEMAND_MAINNET_PID = exports.SB_ON_DEMAND_DEVNET_PID = exports.PTYH_LAZER_PROGRAM_ID = exports.VELOCITY_ORACLE_RECEIVER_ID = exports.VELOCITY_DEVNET_PROGRAM_ID = exports.VELOCITY_PROGRAM_ID = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const perpMarkets_1 = require("./constants/perpMarkets");
6
6
  const spotMarkets_1 = require("./constants/spotMarkets");
7
7
  const oracleId_1 = require("./oracles/oracleId");
8
- exports.VELOCITY_PROGRAM_ID = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH';
9
- /** @deprecated Use `VELOCITY_PROGRAM_ID` instead. `DRIFT_PROGRAM_ID` will be removed in a future major. */
10
- exports.DRIFT_PROGRAM_ID = exports.VELOCITY_PROGRAM_ID;
8
+ exports.VELOCITY_PROGRAM_ID = 'vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P';
11
9
  exports.VELOCITY_DEVNET_PROGRAM_ID = 'vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P';
12
- /** @deprecated Use `VELOCITY_DEVNET_PROGRAM_ID` instead. `DRIFT_DEVNET_PROGRAM_ID` will be removed in a future major. */
13
- exports.DRIFT_DEVNET_PROGRAM_ID = exports.VELOCITY_DEVNET_PROGRAM_ID;
14
10
  exports.VELOCITY_ORACLE_RECEIVER_ID = 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha';
15
- /** @deprecated Use `VELOCITY_ORACLE_RECEIVER_ID` instead. `DRIFT_ORACLE_RECEIVER_ID` will be removed in a future major. */
16
- exports.DRIFT_ORACLE_RECEIVER_ID = exports.VELOCITY_ORACLE_RECEIVER_ID;
17
11
  exports.PTYH_LAZER_PROGRAM_ID = 'pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt';
18
12
  exports.SB_ON_DEMAND_DEVNET_PID = new web3_js_1.PublicKey('Aio4gaXjXzJNVLtzwtNVmSqGKpANtXhybbkhtAC94ji2');
19
13
  exports.SB_ON_DEMAND_MAINNET_PID = new web3_js_1.PublicKey('SBondMDrcV3K4kxZR1HNVT7osZxAHVHgYXL5Ze1oMUv');
@@ -27,8 +21,6 @@ exports.configs = {
27
21
  ENV: 'devnet',
28
22
  PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
29
23
  VELOCITY_PROGRAM_ID: exports.VELOCITY_DEVNET_PROGRAM_ID,
30
- /** @deprecated Read `VELOCITY_PROGRAM_ID` instead. */
31
- DRIFT_PROGRAM_ID: exports.VELOCITY_DEVNET_PROGRAM_ID,
32
24
  JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
33
25
  QUOTE_MINT_ADDRESS: '8FfvSRKMZRDHrCBy142XMUXrKEkXnxDQ4YmJv7xbAw8Q',
34
26
  V2_ALPHA_TICKET_MINT_ADDRESS: 'DeEiGWfCMP9psnLGkxGrBBMEAW5Jv8bBGMN8DCtFRCyB',
@@ -38,16 +30,12 @@ exports.configs = {
38
30
  MARKET_LOOKUP_TABLE: 'FaMS3U4uBojvGn5FSDEPimddcXsCfwkKsFgMVVnDdxGb',
39
31
  MARKET_LOOKUP_TABLES: ['FaMS3U4uBojvGn5FSDEPimddcXsCfwkKsFgMVVnDdxGb'],
40
32
  VELOCITY_ORACLE_RECEIVER_ID: exports.VELOCITY_ORACLE_RECEIVER_ID,
41
- /** @deprecated Read `VELOCITY_ORACLE_RECEIVER_ID` instead. */
42
- DRIFT_ORACLE_RECEIVER_ID: exports.VELOCITY_ORACLE_RECEIVER_ID,
43
33
  SB_ON_DEMAND_PID: exports.SB_ON_DEMAND_DEVNET_PID,
44
34
  },
45
35
  'mainnet-beta': {
46
36
  ENV: 'mainnet-beta',
47
37
  PYTH_ORACLE_MAPPING_ADDRESS: 'AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J',
48
38
  VELOCITY_PROGRAM_ID: exports.VELOCITY_PROGRAM_ID,
49
- /** @deprecated Read `VELOCITY_PROGRAM_ID` instead. */
50
- DRIFT_PROGRAM_ID: exports.VELOCITY_PROGRAM_ID,
51
39
  JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
52
40
  QUOTE_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
53
41
  V2_ALPHA_TICKET_MINT_ADDRESS: 'Cmvhycb6LQvvzaShGw4iDHRLzeSSryioAsU98DSSkMNa',
@@ -60,8 +48,6 @@ exports.configs = {
60
48
  'EiWSskK5HXnBTptiS5DH6gpAJRVNQ3cAhTKBGaiaysAb',
61
49
  ],
62
50
  VELOCITY_ORACLE_RECEIVER_ID: exports.VELOCITY_ORACLE_RECEIVER_ID,
63
- /** @deprecated Read `VELOCITY_ORACLE_RECEIVER_ID` instead. */
64
- DRIFT_ORACLE_RECEIVER_ID: exports.VELOCITY_ORACLE_RECEIVER_ID,
65
51
  SB_ON_DEMAND_PID: exports.SB_ON_DEMAND_MAINNET_PID,
66
52
  },
67
53
  };
@@ -75,24 +61,11 @@ exports.getConfig = getConfig;
75
61
  * @param props
76
62
  * @returns
77
63
  */
78
- /**
79
- * Mirror a canonical/deprecated alias pair so the resolved config carries the
80
- * same value under both keys regardless of which one the caller overrode.
81
- */
82
- const mirrorAlias = (merged, override, canon, deprecated) => {
83
- var _a, _b;
84
- const value = (_b = (_a = override[canon]) !== null && _a !== void 0 ? _a : override[deprecated]) !== null && _b !== void 0 ? _b : merged[canon];
85
- merged[canon] = value;
86
- merged[deprecated] = value;
87
- };
88
64
  const initialize = (props) => {
89
65
  var _a;
90
66
  const override = (_a = props.overrideEnv) !== null && _a !== void 0 ? _a : {};
91
67
  const normalizedEnv = props.env === 'master' ? 'devnet' : props.env;
92
- const merged = { ...exports.configs[normalizedEnv], ...override };
93
- mirrorAlias(merged, override, 'VELOCITY_PROGRAM_ID', 'DRIFT_PROGRAM_ID');
94
- mirrorAlias(merged, override, 'VELOCITY_ORACLE_RECEIVER_ID', 'DRIFT_ORACLE_RECEIVER_ID');
95
- currentConfig = merged;
68
+ currentConfig = { ...exports.configs[normalizedEnv], ...override };
96
69
  return currentConfig;
97
70
  };
98
71
  exports.initialize = initialize;
@@ -132,9 +105,9 @@ async function findAllMarketAndOracles(program) {
132
105
  for (const perpMarketProgramAccount of perpMarketProgramAccounts) {
133
106
  const perpMarket = perpMarketProgramAccount.account;
134
107
  perpMarketIndexes.push(perpMarket.marketIndex);
135
- oracleInfos.set((0, oracleId_1.getOracleId)(perpMarket.amm.oracle, perpMarket.amm.oracleSource), {
136
- publicKey: perpMarket.amm.oracle,
137
- source: perpMarket.amm.oracleSource,
108
+ oracleInfos.set((0, oracleId_1.getOracleId)(perpMarket.oracle, perpMarket.oracleSource), {
109
+ publicKey: perpMarket.oracle,
110
+ source: perpMarket.oracleSource,
138
111
  });
139
112
  }
140
113
  for (const spotMarketProgramAccount of spotMarketProgramAccounts) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="bn.js" />
2
2
  /**
3
- * Max APR for DRIFT IF vault.
3
+ * Max APR for VELOCITY IF vault.
4
4
  */
5
5
  export declare const MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV: import("bn.js");
@@ -4,6 +4,6 @@ exports.MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV = void 0;
4
4
  const numericConstants_1 = require("./numericConstants");
5
5
  // follows program constant MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV in math/constants.rs
6
6
  /**
7
- * Max APR for DRIFT IF vault.
7
+ * Max APR for VELOCITY IF vault.
8
8
  */
9
9
  exports.MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV = numericConstants_1.PERCENTAGE_PRECISION.divn(22);
@@ -4,8 +4,6 @@ import { ConstituentAccount } from '../types';
4
4
  import { VelocityClient } from '../velocityClient';
5
5
  export type ConstituentMapConfig = {
6
6
  velocityClient?: VelocityClient;
7
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
- driftClient?: VelocityClient;
9
7
  connection?: Connection;
10
8
  subscriptionConfig: {
11
9
  type: 'polling';
@@ -9,20 +9,20 @@ const pda_1 = require("../addresses/pda");
9
9
  const MAX_CONSTITUENT_SIZE_BYTES = 480; // TODO: update this when account is finalized
10
10
  class ConstituentMap {
11
11
  constructor(config) {
12
- var _a, _b, _c;
12
+ var _a, _b;
13
13
  this.constituentMap = new Map();
14
14
  this.constituentIndexToKeyMap = new Map();
15
15
  this.spotMarketIndexToKeyMap = new Map();
16
- const velocityClient = (_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient;
16
+ const velocityClient = config.velocityClient;
17
17
  if (!velocityClient) {
18
- throw new Error('ConstituentMap: velocityClient (or deprecated driftClient) must be provided');
18
+ throw new Error('ConstituentMap: velocityClient must be provided');
19
19
  }
20
20
  this.velocityClient = velocityClient;
21
21
  this.additionalFilters = config.additionalFilters;
22
22
  this.commitment = config.subscriptionConfig.commitment;
23
23
  this.connection = config.connection || this.velocityClient.connection;
24
- this.lpPoolId = (_b = config.lpPoolId) !== null && _b !== void 0 ? _b : 0;
25
- this.decoder = (_c = config.decoder) !== null && _c !== void 0 ? _c : 'base64+zstd';
24
+ this.lpPoolId = (_a = config.lpPoolId) !== null && _a !== void 0 ? _a : 0;
25
+ this.decoder = (_b = config.decoder) !== null && _b !== void 0 ? _b : 'base64+zstd';
26
26
  if (config.subscriptionConfig.type === 'polling') {
27
27
  this.constituentAccountSubscriber =
28
28
  new pollingConstituentAccountSubscriber_1.PollingConstituentAccountSubscriber(this, this.velocityClient.program, config.subscriptionConfig.frequency, config.subscriptionConfig.commitment, this.getFilters());
@@ -5,20 +5,18 @@ import type { AccountMeta, Connection, PublicKey, TransactionInstruction } from
5
5
  import * as pdas from '../addresses/pda';
6
6
  import * as constants from '../constants';
7
7
  import { CustomBorshCoder } from '../decode/customCoder';
8
- import type { Drift } from '../idl/drift';
8
+ import type { Velocity } from '../idl/velocity';
9
9
  import type { UserAccount } from '../types';
10
10
  import type { VelocityProgram } from '../config';
11
11
  import type { BN } from '@coral-xyz/anchor';
12
12
  import * as remainingAccounts from './remainingAccounts';
13
13
  import * as signedMsg from './signedMsg';
14
14
  export type VelocityCoreContext = {
15
- /** Drift program id. */
15
+ /** Velocity program id. */
16
16
  programId: PublicKey;
17
- /** Anchor IDL json for Drift (defaults to bundled `idl/drift.json`). */
18
- idl?: Drift;
17
+ /** Anchor IDL json for Velocity (defaults to bundled `idl/velocity.json`). */
18
+ idl?: Velocity;
19
19
  };
20
- /** @deprecated Use `VelocityCoreContext` instead. `DriftCoreContext` will be removed in a future major. */
21
- export type DriftCoreContext = VelocityCoreContext;
22
20
  /**
23
21
  * VelocityCore is the minimal, core SDK surface:
24
22
  * - No subscriptions / polling / websockets.
@@ -34,11 +32,11 @@ export declare class VelocityCore {
34
32
  /** Re-export remaining-accounts logic (pure). */
35
33
  static readonly remainingAccounts: typeof remainingAccounts;
36
34
  static readonly signedMsg: typeof signedMsg;
37
- static defaultIdl(): Drift;
38
- static coder(idl?: Drift): CustomBorshCoder;
39
- /** Decode a Drift `User` account buffer without creating a Program. */
35
+ static defaultIdl(): Velocity;
36
+ static coder(idl?: Velocity): CustomBorshCoder;
37
+ /** Decode a Velocity `User` account buffer without creating a Program. */
40
38
  static decodeUserAccount(buffer: Buffer): UserAccount;
41
- /** Fetch and decode a Drift `User` account. */
39
+ /** Fetch and decode a Velocity `User` account. */
42
40
  static fetchUserAccount(connection: Connection, userAccountPublicKey: PublicKey): Promise<UserAccount | null>;
43
41
  static buildDepositInstruction(args: {
44
42
  program: VelocityProgram;
@@ -63,7 +61,7 @@ export declare class VelocityCore {
63
61
  state: PublicKey;
64
62
  spotMarket: PublicKey;
65
63
  spotMarketVault: PublicKey;
66
- driftSigner: PublicKey;
64
+ velocitySigner: PublicKey;
67
65
  user: PublicKey;
68
66
  userStats: PublicKey;
69
67
  userTokenAccount: PublicKey;
@@ -224,7 +222,3 @@ export declare class VelocityCore {
224
222
  */
225
223
  static buildInstructions(_ctx: VelocityCoreContext): TransactionInstruction[];
226
224
  }
227
- /** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
228
- export declare const DriftCore: typeof VelocityCore;
229
- /** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
230
- export type DriftCore = VelocityCore;
@@ -26,12 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.DriftCore = exports.VelocityCore = void 0;
29
+ exports.VelocityCore = void 0;
30
30
  const pdas = __importStar(require("../addresses/pda"));
31
31
  const constants = __importStar(require("../constants"));
32
32
  const user_1 = require("../decode/user");
33
33
  const customCoder_1 = require("../decode/customCoder");
34
- const drift_json_1 = __importDefault(require("../idl/drift.json"));
34
+ const velocity_json_1 = __importDefault(require("../idl/velocity.json"));
35
35
  const fetch_1 = require("../accounts/fetch");
36
36
  const deposit_1 = require("./instructions/deposit");
37
37
  const withdraw_1 = require("./instructions/withdraw");
@@ -53,16 +53,16 @@ const signedMsg = __importStar(require("./signedMsg"));
53
53
  */
54
54
  class VelocityCore {
55
55
  static defaultIdl() {
56
- return drift_json_1.default;
56
+ return velocity_json_1.default;
57
57
  }
58
58
  static coder(idl = VelocityCore.defaultIdl()) {
59
59
  return new customCoder_1.CustomBorshCoder(idl);
60
60
  }
61
- /** Decode a Drift `User` account buffer without creating a Program. */
61
+ /** Decode a Velocity `User` account buffer without creating a Program. */
62
62
  static decodeUserAccount(buffer) {
63
63
  return (0, user_1.decodeUser)(buffer);
64
64
  }
65
- /** Fetch and decode a Drift `User` account. */
65
+ /** Fetch and decode a Velocity `User` account. */
66
66
  static async fetchUserAccount(connection, userAccountPublicKey) {
67
67
  const data = await (0, fetch_1.fetchAccount)(connection, userAccountPublicKey);
68
68
  return data ? VelocityCore.decodeUserAccount(data) : null;
@@ -136,5 +136,3 @@ VelocityCore.constants = constants;
136
136
  /** Re-export remaining-accounts logic (pure). */
137
137
  VelocityCore.remainingAccounts = remainingAccounts;
138
138
  VelocityCore.signedMsg = signedMsg;
139
- /** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
140
- exports.DriftCore = VelocityCore;
@@ -10,7 +10,7 @@ export declare function buildWithdrawInstruction(args: {
10
10
  state: PublicKey;
11
11
  spotMarket: PublicKey;
12
12
  spotMarketVault: PublicKey;
13
- driftSigner: PublicKey;
13
+ velocitySigner: PublicKey;
14
14
  user: PublicKey;
15
15
  userStats: PublicKey;
16
16
  userTokenAccount: PublicKey;
@@ -7,7 +7,7 @@ async function buildWithdrawInstruction(args) {
7
7
  state: args.state,
8
8
  spotMarket: args.spotMarket,
9
9
  spotMarketVault: args.spotMarketVault,
10
- driftSigner: args.driftSigner,
10
+ velocitySigner: args.velocitySigner,
11
11
  user: args.user,
12
12
  userStats: args.userStats,
13
13
  userTokenAccount: args.userTokenAccount,
@@ -75,9 +75,9 @@ function addPerpMarketToRemainingAccountMaps(ctx, marketIndex, writable, oracleA
75
75
  isSigner: false,
76
76
  isWritable: writable,
77
77
  });
78
- const oracleWritable = writable && (0, types_1.isVariant)(perpMarketAccount.amm.oracleSource, 'prelaunch');
79
- oracleAccountMap.set(perpMarketAccount.amm.oracle.toString(), {
80
- pubkey: perpMarketAccount.amm.oracle,
78
+ const oracleWritable = writable && (0, types_1.isVariant)(perpMarketAccount.oracleSource, 'prelaunch');
79
+ oracleAccountMap.set(perpMarketAccount.oracle.toString(), {
80
+ pubkey: perpMarketAccount.oracle,
81
81
  isSigner: false,
82
82
  isWritable: oracleWritable,
83
83
  });
@@ -120,8 +120,8 @@ function decodeUser(buffer) {
120
120
  const orders = [];
121
121
  for (let i = 0; i < 32; i++) {
122
122
  // skip order if it's not open
123
- if (buffer.readUint8(offset + 82) !== 1) {
124
- offset += 96;
123
+ if (buffer.readUint8(offset + 86) !== 1) {
124
+ offset += 104;
125
125
  continue;
126
126
  }
127
127
  const slot = readUnsignedBigInt64LE(buffer, offset);
@@ -142,8 +142,8 @@ function decodeUser(buffer) {
142
142
  offset += 8;
143
143
  const maxTs = readSignedBigInt64LE(buffer, offset);
144
144
  offset += 8;
145
- const oraclePriceOffset = buffer.readInt32LE(offset);
146
- offset += 4;
145
+ const oraclePriceOffset = readSignedBigInt64LE(buffer, offset);
146
+ offset += 8;
147
147
  const orderId = buffer.readUInt32LE(offset);
148
148
  offset += 4;
149
149
  const marketIndex = buffer.readUInt16LE(offset);
@@ -231,7 +231,7 @@ function decodeUser(buffer) {
231
231
  offset += 1;
232
232
  const bitFlags = buffer.readUint8(offset);
233
233
  offset += 1;
234
- offset += 1; // padding
234
+ offset += 5; // padding
235
235
  orders.push({
236
236
  slot,
237
237
  price,