@velocity-exchange/sdk 0.0.5 → 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 (383) hide show
  1. package/.prettierignore +1 -1
  2. package/CHANGELOG.md +20 -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/dlob/DLOB.d.ts +1 -1
  40. package/lib/browser/dlob/DLOB.js +6 -6
  41. package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -2
  42. package/lib/browser/dlob/DLOBSubscriber.js +2 -7
  43. package/lib/browser/dlob/orderBookLevels.js +7 -7
  44. package/lib/browser/dlob/types.d.ts +0 -2
  45. package/lib/browser/events/eventSubscriber.d.ts +1 -1
  46. package/lib/browser/events/eventsServerLogProvider.js +2 -2
  47. package/lib/browser/events/parse.js +14 -14
  48. package/lib/browser/events/types.d.ts +3 -5
  49. package/lib/browser/events/types.js +1 -1
  50. package/lib/browser/idl/{drift.d.ts → velocity.d.ts} +1042 -767
  51. package/lib/browser/idl/{drift.json → velocity.json} +1033 -758
  52. package/lib/browser/index.d.ts +1 -1
  53. package/lib/browser/index.js +1 -2
  54. package/lib/browser/math/amm.d.ts +10 -10
  55. package/lib/browser/math/amm.js +29 -28
  56. package/lib/browser/math/auction.js +16 -12
  57. package/lib/browser/math/builder.d.ts +18 -1
  58. package/lib/browser/math/builder.js +32 -1
  59. package/lib/browser/math/funding.js +26 -26
  60. package/lib/browser/math/margin.d.ts +4 -4
  61. package/lib/browser/math/margin.js +15 -15
  62. package/lib/browser/math/market.js +13 -13
  63. package/lib/browser/math/oracles.d.ts +4 -4
  64. package/lib/browser/math/oracles.js +23 -23
  65. package/lib/browser/math/orders.d.ts +2 -2
  66. package/lib/browser/math/orders.js +9 -9
  67. package/lib/browser/math/position.js +4 -4
  68. package/lib/browser/math/superStake.d.ts +8 -10
  69. package/lib/browser/math/superStake.js +18 -20
  70. package/lib/browser/math/trade.js +5 -5
  71. package/lib/browser/math/utils.d.ts +1 -1
  72. package/lib/browser/math/utils.js +1 -1
  73. package/lib/browser/oracles/pythLazerClient.js +2 -2
  74. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +0 -2
  75. package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -12
  76. package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
  77. package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
  78. package/lib/browser/orderSubscriber/types.d.ts +0 -2
  79. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -5
  80. package/lib/browser/priorityFee/priorityFeeSubscriber.js +7 -15
  81. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
  82. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +3 -11
  83. package/lib/browser/priorityFee/types.d.ts +3 -8
  84. package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
  85. package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +1 -3
  86. package/lib/browser/pyth/pythLazerSubscriber.d.ts +1 -1
  87. package/lib/browser/pyth/pythLazerSubscriber.js +1 -1
  88. package/lib/browser/swap/UnifiedSwapClient.js +1 -1
  89. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
  90. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +2 -6
  91. package/lib/browser/swift/swiftOrderSubscriber.d.ts +6 -5
  92. package/lib/browser/swift/swiftOrderSubscriber.js +5 -11
  93. package/lib/browser/types.d.ts +79 -91
  94. package/lib/browser/types.js +4 -0
  95. package/lib/browser/user.d.ts +1 -3
  96. package/lib/browser/user.js +19 -23
  97. package/lib/browser/userConfig.d.ts +3 -2
  98. package/lib/browser/userMap/WebsocketSubscription.js +1 -1
  99. package/lib/browser/userMap/grpcSubscription.js +1 -1
  100. package/lib/browser/userMap/referrerMap.d.ts +0 -2
  101. package/lib/browser/userMap/referrerMap.js +0 -4
  102. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +0 -2
  103. package/lib/browser/userMap/revenueShareEscrowMap.js +0 -4
  104. package/lib/browser/userMap/userMap.d.ts +2 -4
  105. package/lib/browser/userMap/userMap.js +10 -14
  106. package/lib/browser/userMap/userMapConfig.d.ts +3 -2
  107. package/lib/browser/userMap/userStatsMap.d.ts +0 -2
  108. package/lib/browser/userMap/userStatsMap.js +0 -4
  109. package/lib/browser/userStats.d.ts +0 -2
  110. package/lib/browser/userStats.js +10 -14
  111. package/lib/browser/userStatsConfig.d.ts +3 -2
  112. package/lib/browser/util/ed25519Utils.d.ts +1 -1
  113. package/lib/browser/util/ed25519Utils.js +1 -1
  114. package/lib/browser/velocityClient.d.ts +53 -38
  115. package/lib/browser/velocityClient.js +258 -196
  116. package/lib/browser/velocityClientConfig.d.ts +0 -8
  117. package/lib/node/accounts/grpcProgramAccountSubscriber.js +1 -1
  118. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
  119. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  120. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
  121. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
  122. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  123. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
  124. package/lib/node/accounts/laserProgramAccountSubscriber.js +1 -1
  125. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
  126. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  127. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
  128. package/lib/node/accounts/types.d.ts +2 -8
  129. package/lib/node/accounts/types.d.ts.map +1 -1
  130. package/lib/node/accounts/utils.js +2 -2
  131. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
  132. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  133. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
  134. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
  135. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  136. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
  137. package/lib/node/addresses/pda.d.ts +1 -7
  138. package/lib/node/addresses/pda.d.ts.map +1 -1
  139. package/lib/node/addresses/pda.js +4 -10
  140. package/lib/node/adminClient.d.ts +1 -1
  141. package/lib/node/adminClient.js +21 -21
  142. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -3
  143. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  144. package/lib/node/auctionSubscriber/auctionSubscriber.js +2 -6
  145. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
  146. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  147. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
  148. package/lib/node/auctionSubscriber/types.d.ts +3 -2
  149. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  150. package/lib/node/config.d.ts +10 -19
  151. package/lib/node/config.d.ts.map +1 -1
  152. package/lib/node/config.js +6 -33
  153. package/lib/node/constants/insuranceFund.d.ts +1 -1
  154. package/lib/node/constants/insuranceFund.js +1 -1
  155. package/lib/node/constituentMap/constituentMap.d.ts +0 -2
  156. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  157. package/lib/node/constituentMap/constituentMap.js +5 -5
  158. package/lib/node/core/VelocityCore.d.ts +9 -15
  159. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  160. package/lib/node/core/VelocityCore.js +5 -7
  161. package/lib/node/core/instructions/withdraw.d.ts +1 -1
  162. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  163. package/lib/node/core/instructions/withdraw.js +1 -1
  164. package/lib/node/core/remainingAccounts.js +3 -3
  165. package/lib/node/dlob/DLOB.d.ts +1 -1
  166. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  167. package/lib/node/dlob/DLOB.js +6 -6
  168. package/lib/node/dlob/DLOBSubscriber.d.ts +0 -2
  169. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  170. package/lib/node/dlob/DLOBSubscriber.js +2 -7
  171. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  172. package/lib/node/dlob/orderBookLevels.js +7 -7
  173. package/lib/node/dlob/types.d.ts +0 -2
  174. package/lib/node/dlob/types.d.ts.map +1 -1
  175. package/lib/node/events/eventSubscriber.d.ts +1 -1
  176. package/lib/node/events/eventsServerLogProvider.js +2 -2
  177. package/lib/node/events/parse.d.ts.map +1 -1
  178. package/lib/node/events/parse.js +14 -14
  179. package/lib/node/events/types.d.ts +3 -5
  180. package/lib/node/events/types.d.ts.map +1 -1
  181. package/lib/node/events/types.js +1 -1
  182. package/lib/node/idl/{drift.d.ts → velocity.d.ts} +1043 -768
  183. package/lib/node/idl/velocity.d.ts.map +1 -0
  184. package/lib/node/idl/{drift.json → velocity.json} +1033 -758
  185. package/lib/node/index.d.ts +1 -1
  186. package/lib/node/index.d.ts.map +1 -1
  187. package/lib/node/index.js +1 -2
  188. package/lib/node/math/amm.d.ts +10 -10
  189. package/lib/node/math/amm.d.ts.map +1 -1
  190. package/lib/node/math/amm.js +29 -28
  191. package/lib/node/math/auction.d.ts.map +1 -1
  192. package/lib/node/math/auction.js +16 -12
  193. package/lib/node/math/builder.d.ts +18 -1
  194. package/lib/node/math/builder.d.ts.map +1 -1
  195. package/lib/node/math/builder.js +32 -1
  196. package/lib/node/math/funding.d.ts.map +1 -1
  197. package/lib/node/math/funding.js +26 -26
  198. package/lib/node/math/margin.d.ts +4 -4
  199. package/lib/node/math/margin.d.ts.map +1 -1
  200. package/lib/node/math/margin.js +15 -15
  201. package/lib/node/math/market.d.ts.map +1 -1
  202. package/lib/node/math/market.js +13 -13
  203. package/lib/node/math/oracles.d.ts +4 -4
  204. package/lib/node/math/oracles.d.ts.map +1 -1
  205. package/lib/node/math/oracles.js +23 -23
  206. package/lib/node/math/orders.d.ts +2 -2
  207. package/lib/node/math/orders.d.ts.map +1 -1
  208. package/lib/node/math/orders.js +9 -9
  209. package/lib/node/math/position.d.ts.map +1 -1
  210. package/lib/node/math/position.js +4 -4
  211. package/lib/node/math/superStake.d.ts +8 -10
  212. package/lib/node/math/superStake.d.ts.map +1 -1
  213. package/lib/node/math/superStake.js +18 -20
  214. package/lib/node/math/trade.d.ts.map +1 -1
  215. package/lib/node/math/trade.js +5 -5
  216. package/lib/node/math/utils.d.ts +1 -1
  217. package/lib/node/math/utils.js +1 -1
  218. package/lib/node/oracles/pythLazerClient.js +2 -2
  219. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +0 -2
  220. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  221. package/lib/node/orderSubscriber/OrderSubscriber.js +8 -12
  222. package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
  223. package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
  224. package/lib/node/orderSubscriber/types.d.ts +0 -2
  225. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  226. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -5
  227. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  228. package/lib/node/priorityFee/priorityFeeSubscriber.js +7 -15
  229. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
  230. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  231. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +3 -11
  232. package/lib/node/priorityFee/types.d.ts +3 -8
  233. package/lib/node/priorityFee/types.d.ts.map +1 -1
  234. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
  235. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
  236. package/lib/node/priorityFee/velocityPriorityFeeMethod.js +1 -3
  237. package/lib/node/pyth/pythLazerSubscriber.d.ts +1 -1
  238. package/lib/node/pyth/pythLazerSubscriber.js +1 -1
  239. package/lib/node/swap/UnifiedSwapClient.js +1 -1
  240. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
  241. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  242. package/lib/node/swift/signedMsgUserAccountSubscriber.js +2 -6
  243. package/lib/node/swift/swiftOrderSubscriber.d.ts +6 -5
  244. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  245. package/lib/node/swift/swiftOrderSubscriber.js +5 -11
  246. package/lib/node/types.d.ts +79 -91
  247. package/lib/node/types.d.ts.map +1 -1
  248. package/lib/node/types.js +4 -0
  249. package/lib/node/user.d.ts +1 -3
  250. package/lib/node/user.d.ts.map +1 -1
  251. package/lib/node/user.js +19 -23
  252. package/lib/node/userConfig.d.ts +3 -2
  253. package/lib/node/userConfig.d.ts.map +1 -1
  254. package/lib/node/userMap/WebsocketSubscription.js +1 -1
  255. package/lib/node/userMap/grpcSubscription.js +1 -1
  256. package/lib/node/userMap/referrerMap.d.ts +0 -2
  257. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  258. package/lib/node/userMap/referrerMap.js +0 -4
  259. package/lib/node/userMap/revenueShareEscrowMap.d.ts +0 -2
  260. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  261. package/lib/node/userMap/revenueShareEscrowMap.js +0 -4
  262. package/lib/node/userMap/userMap.d.ts +2 -4
  263. package/lib/node/userMap/userMap.d.ts.map +1 -1
  264. package/lib/node/userMap/userMap.js +10 -14
  265. package/lib/node/userMap/userMapConfig.d.ts +3 -2
  266. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  267. package/lib/node/userMap/userStatsMap.d.ts +0 -2
  268. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  269. package/lib/node/userMap/userStatsMap.js +0 -4
  270. package/lib/node/userStats.d.ts +0 -2
  271. package/lib/node/userStats.d.ts.map +1 -1
  272. package/lib/node/userStats.js +10 -14
  273. package/lib/node/userStatsConfig.d.ts +3 -2
  274. package/lib/node/userStatsConfig.d.ts.map +1 -1
  275. package/lib/node/util/ed25519Utils.d.ts +1 -1
  276. package/lib/node/util/ed25519Utils.js +1 -1
  277. package/lib/node/velocityClient.d.ts +53 -38
  278. package/lib/node/velocityClient.d.ts.map +1 -1
  279. package/lib/node/velocityClient.js +258 -196
  280. package/lib/node/velocityClientConfig.d.ts +0 -8
  281. package/lib/node/velocityClientConfig.d.ts.map +1 -1
  282. package/package.json +6 -7
  283. package/scripts/deposit-isolated-positions.ts +2 -2
  284. package/scripts/find-flagged-users.ts +1 -1
  285. package/scripts/grpc-client-test-comparison.ts +4 -4
  286. package/scripts/grpc-multiuser-client-test-comparison.ts +2 -2
  287. package/scripts/single-grpc-client-test.ts +3 -3
  288. package/scripts/updateVersion.js +4 -4
  289. package/scripts/withdraw-isolated-positions.ts +2 -2
  290. package/src/accounts/grpcProgramAccountSubscriber.ts +1 -1
  291. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +0 -7
  292. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +4 -11
  293. package/src/accounts/laserProgramAccountSubscriber.ts +1 -1
  294. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +4 -11
  295. package/src/accounts/types.ts +2 -9
  296. package/src/accounts/utils.ts +2 -2
  297. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +4 -11
  298. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +4 -11
  299. package/src/addresses/pda.ts +3 -13
  300. package/src/adminClient.ts +21 -21
  301. package/src/auctionSubscriber/auctionSubscriber.ts +1 -6
  302. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +1 -6
  303. package/src/auctionSubscriber/types.ts +3 -3
  304. package/src/config.ts +8 -67
  305. package/src/constants/insuranceFund.ts +1 -1
  306. package/src/constituentMap/constituentMap.ts +2 -6
  307. package/src/core/VelocityCore.ts +11 -20
  308. package/src/core/instructions/withdraw.ts +2 -2
  309. package/src/core/remainingAccounts.ts +3 -3
  310. package/src/dlob/DLOB.ts +6 -6
  311. package/src/dlob/DLOBSubscriber.ts +2 -8
  312. package/src/dlob/orderBookLevels.ts +12 -6
  313. package/src/dlob/types.ts +0 -2
  314. package/src/events/eventSubscriber.ts +1 -1
  315. package/src/events/eventsServerLogProvider.ts +2 -2
  316. package/src/events/parse.ts +14 -14
  317. package/src/events/types.ts +4 -7
  318. package/src/idl/{drift.json → velocity.json} +1033 -758
  319. package/src/idl/{drift.ts → velocity.ts} +1035 -760
  320. package/src/index.ts +1 -4
  321. package/src/margin/README.md +2 -2
  322. package/src/math/amm.ts +43 -21
  323. package/src/math/auction.ts +16 -12
  324. package/src/math/builder.ts +45 -1
  325. package/src/math/funding.ts +46 -43
  326. package/src/math/margin.ts +15 -15
  327. package/src/math/market.ts +21 -13
  328. package/src/math/oracles.ts +29 -26
  329. package/src/math/orders.ts +18 -5
  330. package/src/math/position.ts +9 -3
  331. package/src/math/superStake.ts +21 -24
  332. package/src/math/trade.ts +9 -1
  333. package/src/math/utils.ts +1 -1
  334. package/src/oracles/pythLazerClient.ts +3 -3
  335. package/src/orderSubscriber/OrderSubscriber.ts +2 -8
  336. package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
  337. package/src/orderSubscriber/grpcSubscription.ts +2 -2
  338. package/src/orderSubscriber/types.ts +0 -2
  339. package/src/priorityFee/priorityFeeSubscriber.ts +5 -12
  340. package/src/priorityFee/priorityFeeSubscriberMap.ts +2 -10
  341. package/src/priorityFee/types.ts +3 -13
  342. package/src/priorityFee/velocityPriorityFeeMethod.ts +0 -12
  343. package/src/pyth/pythLazerSubscriber.ts +1 -1
  344. package/src/swap/UnifiedSwapClient.ts +1 -1
  345. package/src/swift/signedMsgUserAccountSubscriber.ts +2 -8
  346. package/src/swift/swiftOrderSubscriber.ts +7 -12
  347. package/src/types.ts +84 -102
  348. package/src/user.ts +9 -14
  349. package/src/userConfig.ts +1 -3
  350. package/src/userMap/WebsocketSubscription.ts +1 -1
  351. package/src/userMap/grpcSubscription.ts +1 -1
  352. package/src/userMap/referrerMap.ts +0 -4
  353. package/src/userMap/revenueShareEscrowMap.ts +0 -4
  354. package/src/userMap/userMap.ts +3 -7
  355. package/src/userMap/userMapConfig.ts +3 -3
  356. package/src/userMap/userStatsMap.ts +0 -4
  357. package/src/userStats.ts +1 -5
  358. package/src/userStatsConfig.ts +3 -3
  359. package/src/util/ed25519Utils.ts +1 -1
  360. package/src/velocityClient.ts +339 -225
  361. package/src/velocityClientConfig.ts +0 -10
  362. package/tests/{DriftCore → VelocityCore}/decode.test.ts +1 -1
  363. package/tests/{DriftCore → VelocityCore}/fill_trigger.test.ts +1 -1
  364. package/tests/{DriftCore → VelocityCore}/instructions.test.ts +1 -1
  365. package/tests/{DriftCore → VelocityCore}/pdas.test.ts +4 -2
  366. package/tests/ci/verifyConstants.ts +24 -27
  367. package/tests/decode/test.ts +2 -2
  368. package/tests/dlob/helpers.ts +5 -9
  369. package/tests/events/parseLogsForCuUsage.ts +15 -15
  370. package/tests/user/helpers.ts +9 -9
  371. package/tests/user/test.ts +13 -10
  372. package/lib/browser/util/deprecatedAlias.d.ts +0 -26
  373. package/lib/browser/util/deprecatedAlias.js +0 -10
  374. package/lib/node/idl/drift.d.ts.map +0 -1
  375. package/lib/node/util/deprecatedAlias.d.ts +0 -27
  376. package/lib/node/util/deprecatedAlias.d.ts.map +0 -1
  377. package/lib/node/util/deprecatedAlias.js +0 -10
  378. package/src/util/deprecatedAlias.ts +0 -21
  379. /package/lib/browser/idl/{drift.js → velocity.js} +0 -0
  380. /package/lib/node/idl/{drift.js → velocity.js} +0 -0
  381. /package/tests/{DriftCore → VelocityCore}/perp_orders.test.ts +0 -0
  382. /package/tests/{DriftCore → VelocityCore}/remainingAccounts.test.ts +0 -0
  383. /package/tests/{DriftCore → VelocityCore}/settlement_liquidation.test.ts +0 -0
@@ -23,10 +23,6 @@ export class PriorityFeeSubscriber {
23
23
  frequencyMs: number;
24
24
  addresses: string[];
25
25
  velocityMarkets?: VelocityMarketInfo[];
26
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
27
- public get driftMarkets(): VelocityMarketInfo[] | undefined {
28
- return this.velocityMarkets;
29
- }
30
26
  customStrategy?: PriorityFeeStrategy;
31
27
  averageStrategy = new AverageOverSlotsStrategy();
32
28
  maxStrategy = new MaxOverSlotsStrategy();
@@ -36,10 +32,6 @@ export class PriorityFeeSubscriber {
36
32
  priorityFeeMultiplier?: number;
37
33
 
38
34
  velocityPriorityFeeEndpoint?: string;
39
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
40
- public get driftPriorityFeeEndpoint(): string | undefined {
41
- return this.velocityPriorityFeeEndpoint;
42
- }
43
35
  heliusRpcUrl?: string;
44
36
  lastHeliusSample?: HeliusPriorityFeeLevels;
45
37
 
@@ -58,7 +50,7 @@ export class PriorityFeeSubscriber {
58
50
  this.addresses = config.addresses
59
51
  ? config.addresses.map((address) => address.toBase58())
60
52
  : [];
61
- this.velocityMarkets = config.velocityMarkets ?? config.driftMarkets;
53
+ this.velocityMarkets = config.velocityMarkets;
62
54
 
63
55
  if (config.customStrategy) {
64
56
  this.customStrategy = config.customStrategy;
@@ -84,7 +76,8 @@ export class PriorityFeeSubscriber {
84
76
  }
85
77
  } else if (this.priorityFeeMethod === PriorityFeeMethod.VELOCITY) {
86
78
  this.velocityPriorityFeeEndpoint =
87
- config.velocityPriorityFeeEndpoint ?? config.driftPriorityFeeEndpoint;
79
+ config.velocityPriorityFeeEndpoint ??
80
+ config.velocityPriorityFeeEndpoint;
88
81
  }
89
82
  }
90
83
 
@@ -146,7 +139,7 @@ export class PriorityFeeSubscriber {
146
139
  }
147
140
  }
148
141
 
149
- private async loadForDrift(): Promise<void> {
142
+ private async loadForVelocity(): Promise<void> {
150
143
  if (!this.velocityMarkets) {
151
144
  return;
152
145
  }
@@ -228,7 +221,7 @@ export class PriorityFeeSubscriber {
228
221
  } else if (this.priorityFeeMethod === PriorityFeeMethod.HELIUS) {
229
222
  await this.loadForHelius();
230
223
  } else if (this.priorityFeeMethod === PriorityFeeMethod.VELOCITY) {
231
- await this.loadForDrift();
224
+ await this.loadForVelocity();
232
225
  } else {
233
226
  throw new Error(`${this.priorityFeeMethod} load not implemented`);
234
227
  }
@@ -17,15 +17,7 @@ export class PriorityFeeSubscriberMap {
17
17
  intervalId?: ReturnType<typeof setTimeout>;
18
18
 
19
19
  velocityMarkets?: VelocityMarketInfo[];
20
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
21
- public get driftMarkets(): VelocityMarketInfo[] | undefined {
22
- return this.velocityMarkets;
23
- }
24
20
  velocityPriorityFeeEndpoint: string;
25
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
26
- public get driftPriorityFeeEndpoint(): string {
27
- return this.velocityPriorityFeeEndpoint;
28
- }
29
21
  feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>; // marketType -> marketIndex -> priority fee
30
22
 
31
23
  public constructor(config: PriorityFeeSubscriberMapConfig) {
@@ -33,8 +25,8 @@ export class PriorityFeeSubscriberMap {
33
25
  config.frequencyMs ?? DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
34
26
  // Type-system guarantees at least one of the two is supplied.
35
27
  this.velocityPriorityFeeEndpoint = (config.velocityPriorityFeeEndpoint ??
36
- config.driftPriorityFeeEndpoint)!;
37
- this.velocityMarkets = config.velocityMarkets ?? config.driftMarkets;
28
+ config.velocityPriorityFeeEndpoint)!;
29
+ this.velocityMarkets = config.velocityMarkets;
38
30
  this.feesMap = new Map<string, Map<number, VelocityPriorityFeeLevels>>();
39
31
  this.feesMap.set('perp', new Map<number, VelocityPriorityFeeLevels>());
40
32
  this.feesMap.set('spot', new Map<number, VelocityPriorityFeeLevels>());
@@ -5,7 +5,6 @@ import {
5
5
  VelocityMarketInfo,
6
6
  VelocityPriorityFeeResponse,
7
7
  } from './velocityPriorityFeeMethod';
8
- import { AtLeastOne } from '../util/deprecatedAlias';
9
8
 
10
9
  export const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10_000;
11
10
 
@@ -35,8 +34,6 @@ export type PriorityFeeSubscriberConfig = {
35
34
  addresses?: PublicKey[];
36
35
  /// market type and index, optionally provide at initialization time if using priorityFeeMethod.VELOCITY
37
36
  velocityMarkets?: VelocityMarketInfo[];
38
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
39
- driftMarkets?: VelocityMarketInfo[];
40
37
  /// custom strategy to calculate priority fees, defaults to AVERAGE
41
38
  customStrategy?: PriorityFeeStrategy;
42
39
  /// method for fetching priority fee samples
@@ -47,8 +44,6 @@ export type PriorityFeeSubscriberConfig = {
47
44
  heliusRpcUrl?: string;
48
45
  /// url for Velocity cached priority fee endpoint, required if using priorityFeeMethod.VELOCITY
49
46
  velocityPriorityFeeEndpoint?: string;
50
- /** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
51
- driftPriorityFeeEndpoint?: string;
52
47
  /// clamp any returned priority fee value to this value.
53
48
  maxFeeMicroLamports?: number;
54
49
  /// multiplier applied to priority fee before maxFeeMicroLamports, defaults to 1.0
@@ -60,15 +55,10 @@ type PriorityFeeSubscriberMapConfigBase = {
60
55
  frequencyMs?: number;
61
56
  /// market type and associated market index to query
62
57
  velocityMarkets?: VelocityMarketInfo[];
63
- /** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
64
- driftMarkets?: VelocityMarketInfo[];
65
58
  };
66
59
 
67
60
  /// url for Velocity cached priority fee endpoint
68
61
  export type PriorityFeeSubscriberMapConfig =
69
- PriorityFeeSubscriberMapConfigBase &
70
- AtLeastOne<
71
- 'velocityPriorityFeeEndpoint',
72
- 'driftPriorityFeeEndpoint',
73
- string
74
- >;
62
+ PriorityFeeSubscriberMapConfigBase & {
63
+ velocityPriorityFeeEndpoint: string;
64
+ };
@@ -6,9 +6,6 @@ export type VelocityMarketInfo = {
6
6
  marketIndex: number;
7
7
  };
8
8
 
9
- /** @deprecated Use `VelocityMarketInfo` instead. `DriftMarketInfo` will be removed in a future major. */
10
- export type DriftMarketInfo = VelocityMarketInfo;
11
-
12
9
  export type VelocityPriorityFeeLevels = {
13
10
  [key in HeliusPriorityLevel]: number;
14
11
  } & {
@@ -16,14 +13,8 @@ export type VelocityPriorityFeeLevels = {
16
13
  marketIndex: number;
17
14
  };
18
15
 
19
- /** @deprecated Use `VelocityPriorityFeeLevels` instead. `DriftPriorityFeeLevels` will be removed in a future major. */
20
- export type DriftPriorityFeeLevels = VelocityPriorityFeeLevels;
21
-
22
16
  export type VelocityPriorityFeeResponse = VelocityPriorityFeeLevels[];
23
17
 
24
- /** @deprecated Use `VelocityPriorityFeeResponse` instead. `DriftPriorityFeeResponse` will be removed in a future major. */
25
- export type DriftPriorityFeeResponse = VelocityPriorityFeeResponse;
26
-
27
18
  export async function fetchVelocityPriorityFee(
28
19
  url: string,
29
20
  marketTypes: string[],
@@ -49,6 +40,3 @@ export async function fetchVelocityPriorityFee(
49
40
 
50
41
  return [];
51
42
  }
52
-
53
- /** @deprecated Use `fetchVelocityPriorityFee` instead. `fetchDriftPriorityFee` will be removed in a future major. */
54
- export const fetchDriftPriorityFee = fetchVelocityPriorityFee;
@@ -50,7 +50,7 @@ export class PythLazerSubscriber {
50
50
  * @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
51
51
  * @param token - Authentication token for Pyth Lazer API
52
52
  * @param priceFeedArrays - Array of price feed configurations to subscribe to
53
- * @param env - Drift environment (mainnet-beta, devnet, etc.)
53
+ * @param env - Velocity environment (mainnet-beta, devnet, etc.)
54
54
  * @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
55
55
  * @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
56
56
  * @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
@@ -270,7 +270,7 @@ export class UnifiedSwapClient {
270
270
  slippageBps,
271
271
  swapMode: isExactOut ? TitanSwapMode.ExactOut : TitanSwapMode.ExactIn,
272
272
  onlyDirectRoutes,
273
- sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for drift instructions
273
+ sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for velocity instructions
274
274
  });
275
275
 
276
276
  swapInstructions = titanClient.getTitanInstructions({
@@ -4,7 +4,6 @@ import { SignedMsgOrderId, SignedMsgUserOrdersAccount } from '../types';
4
4
  import { Commitment, Context, PublicKey } from '@solana/web3.js';
5
5
  import { ResubOpts } from '../accounts/types';
6
6
  import { VelocityClient } from '../velocityClient';
7
- import { AtLeastOne } from '../util/deprecatedAlias';
8
7
  import StrictEventEmitter from 'strict-event-emitter-types';
9
8
  import { EventEmitter } from 'events';
10
9
 
@@ -13,7 +12,7 @@ export type SignedMsgUserOrdersAccountSubscriberConfig = {
13
12
  resubOpts?: ResubOpts;
14
13
  decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
15
14
  resyncIntervalMs?: number;
16
- } & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
15
+ } & { velocityClient: VelocityClient };
17
16
 
18
17
  export interface SignedMsgUserOrdersAccountSubscriberEvents {
19
18
  onAccountUpdate: (
@@ -31,10 +30,6 @@ export interface SignedMsgUserOrdersAccountSubscriberEvents {
31
30
 
32
31
  export class SignedMsgUserOrdersAccountSubscriber {
33
32
  protected velocityClient: VelocityClient;
34
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
35
- protected get driftClient(): VelocityClient {
36
- return this.velocityClient;
37
- }
38
33
  protected commitment: Commitment;
39
34
  protected resubOpts?: ResubOpts;
40
35
  protected resyncTimeoutId?: ReturnType<typeof setTimeout>;
@@ -60,7 +55,6 @@ export class SignedMsgUserOrdersAccountSubscriber {
60
55
 
61
56
  constructor({
62
57
  velocityClient,
63
- driftClient,
64
58
  commitment,
65
59
  resubOpts,
66
60
  decodeFn,
@@ -69,7 +63,7 @@ export class SignedMsgUserOrdersAccountSubscriber {
69
63
  this.commitment = commitment ?? 'confirmed';
70
64
  this.resubOpts = resubOpts;
71
65
  // Type-system guarantees at least one of the two is supplied.
72
- this.velocityClient = (velocityClient ?? driftClient)!;
66
+ this.velocityClient = velocityClient!;
73
67
  this.decodeFn =
74
68
  decodeFn ??
75
69
  (
@@ -4,7 +4,6 @@ import {
4
4
  } from '../constants/perpMarkets';
5
5
  import { VelocityClient } from '../velocityClient';
6
6
  import { VelocityEnv } from '../config';
7
- import { AtLeastOne } from '../util/deprecatedAlias';
8
7
  import {
9
8
  getUserAccountPublicKey,
10
9
  getUserStatsAccountPublicKey,
@@ -33,16 +32,16 @@ type SwiftOrderSubscriberConfigBase = {
33
32
  endpoint?: string;
34
33
  marketIndexes: number[];
35
34
  /**
36
- In the future, this will be used for verifying $DRIFT stake as we add
35
+ In the future, this will be used for verifying $VELOCITY stake as we add
37
36
  authentication for delegate signers
38
37
  For now, pass a new keypair or a keypair to an empty wallet
39
38
  */
40
39
  keypair: Keypair;
41
40
  };
42
41
 
43
- export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase &
44
- AtLeastOne<'velocityEnv', 'driftEnv', VelocityEnv> &
45
- AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
42
+ export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase & {
43
+ velocityEnv: VelocityEnv;
44
+ } & { velocityClient: VelocityClient };
46
45
 
47
46
  /**
48
47
  * Swift order message received from WebSocket
@@ -74,10 +73,6 @@ export class SwiftOrderSubscriber {
74
73
  private readonly heartbeatIntervalMs = 60000;
75
74
  private ws: WebSocket | null = null;
76
75
  private velocityClient: VelocityClient;
77
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
78
- private get driftClient(): VelocityClient {
79
- return this.velocityClient;
80
- }
81
76
  public userAccountGetter?: AccountGetter; // In practice, this for now is just an OrderSubscriber or a UserMap
82
77
  public onOrder: (
83
78
  orderMessageRaw: SwiftOrderMessage,
@@ -91,7 +86,7 @@ export class SwiftOrderSubscriber {
91
86
 
92
87
  constructor(private config: SwiftOrderSubscriberConfig) {
93
88
  // Type-system guarantees at least one of the two is supplied.
94
- this.velocityClient = (config.velocityClient ?? config.driftClient)!;
89
+ this.velocityClient = config.velocityClient!;
95
90
  this.userAccountGetter = config.userAccountGetter;
96
91
  }
97
92
 
@@ -105,7 +100,7 @@ export class SwiftOrderSubscriber {
105
100
  }
106
101
 
107
102
  getSymbolForMarketIndex(marketIndex: number): string {
108
- const env = this.config.velocityEnv ?? this.config.driftEnv;
103
+ const env = this.config.velocityEnv;
109
104
  const markets = env === 'devnet' ? DevnetPerpMarkets : MainnetPerpMarkets;
110
105
  return markets[marketIndex].symbol;
111
106
  }
@@ -162,7 +157,7 @@ export class SwiftOrderSubscriber {
162
157
  ): Promise<void> {
163
158
  this.onOrder = onOrder;
164
159
 
165
- const env = this.config.velocityEnv ?? this.config.driftEnv;
160
+ const env = this.config.velocityEnv;
166
161
  const endpoint =
167
162
  this.config.endpoint ??
168
163
  (env === 'devnet'
package/src/types.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Shared TypeScript types for the Drift SDK.
2
+ * Shared TypeScript types for the Velocity SDK.
3
3
  *
4
4
  * Contains TypeScript mirrors of all on-chain account structs (UserAccount, PerpMarketAccount,
5
5
  * SpotMarketAccount, StateAccount, OracleData, etc.), instruction parameter types (OrderParams,
6
6
  * ModifyOrderParams), enums (MarketType, OrderType, PositionDirection, OracleSource), and
7
7
  * precision constants used throughout the SDK.
8
8
  *
9
- * The authoritative layout source is `sdk/src/idl/drift.json` (generated from the program).
9
+ * The authoritative layout source is `sdk/src/idl/velocity.json` (generated from the program).
10
10
  * Do not edit struct shapes here without a corresponding on-chain change.
11
11
  */
12
12
  import {
@@ -385,9 +385,8 @@ export type SpotInterestRecord = {
385
385
  maxBorrowRate: number;
386
386
  };
387
387
 
388
- export type CurveRecord = {
388
+ export type AmmCurveChanged = {
389
389
  ts: BN;
390
- recordId: BN;
391
390
  marketIndex: number;
392
391
  pegMultiplierBefore: BN;
393
392
  baseAssetReserveBefore: BN;
@@ -397,15 +396,9 @@ export type CurveRecord = {
397
396
  baseAssetReserveAfter: BN;
398
397
  quoteAssetReserveAfter: BN;
399
398
  sqrtKAfter: BN;
400
- baseAssetAmountLong: BN;
401
- baseAssetAmountShort: BN;
402
- baseAssetAmountWithAmm: BN;
403
- totalFee: BN;
404
- totalFeeMinusDistributions: BN;
405
399
  adjustmentCost: BN;
406
- numberOfUsers: BN;
400
+ totalFeeMinusDistributionsAfter: BN;
407
401
  oraclePrice: BN;
408
- fillRecord: BN;
409
402
  };
410
403
 
411
404
  export declare type InsuranceFundRecord = {
@@ -447,7 +440,6 @@ export type FundingRateRecord = {
447
440
  cumulativeFundingRateShort: BN;
448
441
  oraclePriceTwap: BN;
449
442
  markPriceTwap: BN;
450
- periodRevenue: BN;
451
443
  baseAssetAmountWithAmm: BN;
452
444
  };
453
445
 
@@ -816,13 +808,13 @@ export type PerpMarketAccount = {
816
808
  pubkey: PublicKey;
817
809
  name: number[];
818
810
  amm: AMM;
811
+ marketStats: MarketStats;
819
812
  numberOfUsersWithBase: number;
820
813
  numberOfUsers: number;
821
814
  marginRatioInitial: number;
822
815
  marginRatioMaintenance: number;
823
816
  nextFillRecordId: BN;
824
817
  nextFundingRateRecordId: BN;
825
- nextCurveRecordId: BN;
826
818
  pnlPool: PoolBalance;
827
819
  liquidatorFee: number;
828
820
  ifLiquidationFee: number;
@@ -844,12 +836,41 @@ export type PerpMarketAccount = {
844
836
 
845
837
  lastFillPrice: BN;
846
838
 
847
- lpPoolId: number;
848
- lpFeeTransferScalar: number;
849
- lpExchangeFeeExcluscionScalar: number;
850
- lpStatus: number;
851
- lpPausedOperations: number;
839
+ hedgeConfig: {
840
+ poolId: number;
841
+ status: number;
842
+ pausedOperations: number;
843
+ exchangeFeeExclusionScalar: number;
844
+ feeTransferScalar: number;
845
+ };
852
846
  marketConfig: number;
847
+
848
+ // Fields migrated off AMM to top-level PerpMarket
849
+ oracle: PublicKey;
850
+ oracleSource: OracleSource;
851
+ oracleSlotDelayOverride: number;
852
+ oracleLowRiskSlotDelayOverride: number;
853
+ baseAssetAmountLong: BN;
854
+ baseAssetAmountShort: BN;
855
+ quoteAssetAmount: BN;
856
+ quoteEntryAmountLong: BN;
857
+ quoteEntryAmountShort: BN;
858
+ quoteBreakEvenAmountLong: BN;
859
+ quoteBreakEvenAmountShort: BN;
860
+ totalSocialLoss: BN;
861
+ maxOpenInterest: BN;
862
+ totalExchangeFee: BN;
863
+ totalLiquidationFee: BN;
864
+ cumulativeFundingRateLong: BN;
865
+ cumulativeFundingRateShort: BN;
866
+ lastFundingRate: BN;
867
+ lastFundingRateLong: BN;
868
+ lastFundingRateShort: BN;
869
+ lastFundingRateTs: BN;
870
+ netUnsettledFundingPnl: BN;
871
+ lastFundingOracleTwap: BN;
872
+ orderStepSize: BN;
873
+ orderTickSize: BN;
853
874
  };
854
875
 
855
876
  export type HistoricalOracleData = {
@@ -960,97 +981,58 @@ export type PoolBalance = {
960
981
  };
961
982
 
962
983
  export type AMM = {
984
+ feePool: PoolBalance;
963
985
  baseAssetReserve: BN;
964
- sqrtK: BN;
965
- cumulativeFundingRate: BN;
966
- lastFundingRate: BN;
967
- lastFundingRateTs: BN;
968
- lastMarkPriceTwap: BN;
969
- lastMarkPriceTwap5Min: BN;
970
- lastMarkPriceTwapTs: BN;
971
- lastTradeTs: BN;
972
-
973
- oracle: PublicKey;
974
- oracleSource: OracleSource;
975
- historicalOracleData: HistoricalOracleData;
976
-
977
- lastOracleReservePriceSpreadPct: BN;
978
- lastOracleConfPct: BN;
979
-
980
- fundingPeriod: BN;
981
986
  quoteAssetReserve: BN;
987
+ concentrationCoef: BN;
988
+ minBaseAssetReserve: BN;
989
+ maxBaseAssetReserve: BN;
990
+ sqrtK: BN;
982
991
  pegMultiplier: BN;
983
- cumulativeFundingRateLong: BN;
984
- cumulativeFundingRateShort: BN;
985
- last24HAvgFundingRate: BN;
986
- lastFundingRateShort: BN;
987
- lastFundingRateLong: BN;
988
-
989
- totalLiquidationFee: BN;
992
+ terminalQuoteAssetReserve: BN;
993
+ baseAssetAmountWithAmm: BN;
994
+ totalFee: BN;
995
+ totalMmFee: BN;
990
996
  totalFeeMinusDistributions: BN;
991
997
  totalFeeWithdrawn: BN;
992
- totalFee: BN;
993
- mmOracleSequenceId: BN;
994
- orderStepSize: BN;
995
- orderTickSize: BN;
998
+ lastUpdateSlot: BN;
999
+ netRevenueSinceLastFunding: BN;
1000
+ lastCumulativeFundingRateLong: BN;
1001
+ lastCumulativeFundingRateShort: BN;
1002
+ baseSpread: number;
1003
+ maxSpread: number;
996
1004
  maxFillReserveFraction: number;
997
1005
  maxSlippageRatio: number;
998
- baseSpread: number;
999
1006
  curveUpdateIntensity: number;
1000
- baseAssetAmountWithAmm: BN;
1001
- baseAssetAmountLong: BN;
1002
- baseAssetAmountShort: BN;
1003
- quoteAssetAmount: BN;
1004
- terminalQuoteAssetReserve: BN;
1005
- concentrationCoef: BN;
1006
- feePool: PoolBalance;
1007
- totalExchangeFee: BN;
1008
- totalMmFee: BN;
1009
- netRevenueSinceLastFunding: BN;
1010
- lastUpdateSlot: BN;
1011
- lastOracleNormalisedPrice: BN;
1012
- lastOracleValid: boolean;
1013
- lastBidPriceTwap: BN;
1014
- lastAskPriceTwap: BN;
1015
- longSpread: number;
1016
- shortSpread: number;
1017
- maxSpread: number;
1018
-
1019
1007
  ammJitIntensity: number;
1020
- maxOpenInterest: BN;
1021
- maxBaseAssetReserve: BN;
1022
- minBaseAssetReserve: BN;
1023
- totalSocialLoss: BN;
1024
-
1025
- quoteBreakEvenAmountLong: BN;
1026
- quoteBreakEvenAmountShort: BN;
1027
- quoteEntryAmountLong: BN;
1028
- quoteEntryAmountShort: BN;
1008
+ ammSpreadAdjustment: number;
1009
+ ammInventorySpreadAdjustment: number;
1010
+ referencePriceOffsetDeadbandPct: number;
1011
+ };
1029
1012
 
1013
+ export type MarketStats = {
1014
+ lastMarkPriceTwap: BN;
1015
+ lastMarkPriceTwap5Min: BN;
1016
+ lastMarkPriceTwapTs: BN;
1017
+ lastBidPriceTwap: BN;
1018
+ lastAskPriceTwap: BN;
1030
1019
  markStd: BN;
1031
1020
  oracleStd: BN;
1021
+ lastOracleConfPct: BN;
1022
+ volume24H: BN;
1032
1023
  longIntensityVolume: BN;
1033
1024
  shortIntensityVolume: BN;
1034
- volume24H: BN;
1025
+ lastTradeTs: BN;
1026
+ last24HAvgFundingRate: BN;
1027
+ fundingPeriod: BN;
1035
1028
  minOrderSize: BN;
1036
1029
  mmOraclePrice: BN;
1037
1030
  mmOracleSlot: BN;
1038
-
1039
- bidBaseAssetReserve: BN;
1040
- bidQuoteAssetReserve: BN;
1041
- askBaseAssetReserve: BN;
1042
- askQuoteAssetReserve: BN;
1043
-
1044
- netUnsettledFundingPnl: BN;
1045
- referencePriceOffset: number;
1046
-
1047
- oracleLowRiskSlotDelayOverride: number;
1048
- oracleSlotDelayOverride: number;
1049
- ammSpreadAdjustment: number;
1050
- ammInventorySpreadAdjustment: number;
1051
-
1052
- lastFundingOracleTwap: BN;
1053
- referencePriceOffsetDeadbandPct: number;
1031
+ mmOracleSequenceId: BN;
1032
+ lastOracleNormalisedPrice: BN;
1033
+ lastReferencePriceOffset: number;
1034
+ lastOracleValid: boolean;
1035
+ historicalOracleData: HistoricalOracleData;
1054
1036
  };
1055
1037
 
1056
1038
  // # User Account Types
@@ -1086,14 +1068,13 @@ export type UserStatsAccount = {
1086
1068
  totalFeeRebate: BN;
1087
1069
  totalTokenDiscount: BN;
1088
1070
  totalRefereeDiscount: BN;
1089
- totalReferrerReward: BN;
1090
- current_epoch_referrer_reward: BN;
1091
1071
  };
1092
1072
  referrer: PublicKey;
1093
1073
  referrerStatus: number;
1094
1074
  authority: PublicKey;
1095
1075
  ifStakedQuoteAssetAmount: BN;
1096
1076
  ifStakedGovTokenAmount: BN;
1077
+ delegatePermissions: number;
1097
1078
  };
1098
1079
 
1099
1080
  export type UserAccount = {
@@ -1183,6 +1164,10 @@ export type OrderParams = {
1183
1164
  maxTs: BN | null;
1184
1165
  auctionStartPrice: BN | null;
1185
1166
  auctionEndPrice: BN | null;
1167
+ /** index into the placing user's RevenueShareEscrow.approved_builders list (non-swift builder codes) */
1168
+ builderIdx?: number | null;
1169
+ /** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
1170
+ builderFeeTenthBps?: number | null;
1186
1171
  };
1187
1172
 
1188
1173
  export class PostOnlyParams {
@@ -1276,6 +1261,8 @@ export const DefaultOrderParams: OrderParams = {
1276
1261
  maxTs: null,
1277
1262
  auctionStartPrice: null,
1278
1263
  auctionEndPrice: null,
1264
+ builderIdx: null,
1265
+ builderFeeTenthBps: null,
1279
1266
  };
1280
1267
 
1281
1268
  export type SignedMsgOrderParamsMessage = {
@@ -1331,6 +1318,8 @@ export type ReferrerInfo = {
1331
1318
  export enum ReferrerStatus {
1332
1319
  IsReferrer = 1,
1333
1320
  IsReferred = 2,
1321
+ /** set when the user's RevenueShareEscrow was initialized with a referrer */
1322
+ BuilderReferral = 4,
1334
1323
  }
1335
1324
 
1336
1325
  export enum PlaceAndTakeOrderSuccessCondition {
@@ -1508,9 +1497,6 @@ export interface VelocityClientMetricsEvents {
1508
1497
  preTxSigned: void;
1509
1498
  }
1510
1499
 
1511
- /** @deprecated Use `VelocityClientMetricsEvents` instead. `DriftClientMetricsEvents` will be removed in a future major. */
1512
- export interface DriftClientMetricsEvents extends VelocityClientMetricsEvents {}
1513
-
1514
1500
  export type SignedTxData = {
1515
1501
  txSig: string;
1516
1502
  signedTx: Transaction | VersionedTransaction;
@@ -1547,7 +1533,7 @@ export type IfRebalanceConfigParams = {
1547
1533
  };
1548
1534
 
1549
1535
  /* Represents proof of a signed msg taker order
1550
- * It can be provided to drift program to fill a signed msg order
1536
+ * It can be provided to velocity program to fill a signed msg order
1551
1537
  */
1552
1538
  export interface SignedMsgOrderParams {
1553
1539
  /**
@@ -1581,10 +1567,6 @@ export type RevenueShareAccount = {
1581
1567
  export type RevenueShareEscrowAccount = {
1582
1568
  authority: PublicKey;
1583
1569
  referrer: PublicKey;
1584
- referrerBoostExpireTs: number;
1585
- referrerRewardOffset: number;
1586
- refereeFeeNumeratorOffset: number;
1587
- referrerBoostNumerator: number;
1588
1570
  reservedFixed: number[];
1589
1571
  orders: RevenueShareOrder[];
1590
1572
  approvedBuilders: BuilderInfo[];