@velocity-exchange/sdk 0.0.5 → 0.2.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 (815) hide show
  1. package/.prettierignore +1 -1
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +30 -30
  4. package/bun.lock +24 -2
  5. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
  6. package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
  7. package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  8. package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
  9. package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
  10. package/lib/browser/accounts/bulkAccountLoader.js +12 -1
  11. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
  12. package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
  13. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  14. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
  15. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  16. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  17. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  18. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +9 -3
  19. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
  20. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +19 -6
  21. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -5
  22. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +44 -23
  23. package/lib/browser/accounts/laserProgramAccountSubscriber.js +4 -1
  24. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
  25. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  26. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  27. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  28. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  29. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
  30. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  31. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
  32. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  33. package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
  34. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  35. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  36. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -5
  37. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +69 -35
  38. package/lib/browser/accounts/types.d.ts +6 -12
  39. package/lib/browser/accounts/utils.d.ts +1 -0
  40. package/lib/browser/accounts/utils.js +10 -3
  41. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
  42. package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
  43. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  44. package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
  45. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  46. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  47. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  48. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
  49. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  50. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  51. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  52. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  53. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  54. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
  55. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  56. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  57. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -8
  58. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +52 -26
  59. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -7
  60. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +49 -20
  61. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  62. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  63. package/lib/browser/addresses/marketAddresses.js +3 -2
  64. package/lib/browser/addresses/pda.d.ts +1 -9
  65. package/lib/browser/addresses/pda.js +4 -23
  66. package/lib/browser/adminClient.d.ts +25 -29
  67. package/lib/browser/adminClient.js +168 -169
  68. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +2 -4
  69. package/lib/browser/auctionSubscriber/auctionSubscriber.js +8 -10
  70. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +2 -4
  71. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +11 -10
  72. package/lib/browser/auctionSubscriber/types.d.ts +3 -2
  73. package/lib/browser/bankrun/bankrunConnection.d.ts +6 -4
  74. package/lib/browser/bankrun/bankrunConnection.js +69 -31
  75. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  76. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  77. package/lib/browser/clock/clockSubscriber.d.ts +6 -6
  78. package/lib/browser/clock/clockSubscriber.js +4 -3
  79. package/lib/browser/config.d.ts +11 -20
  80. package/lib/browser/config.js +13 -36
  81. package/lib/browser/constants/index.d.ts +1 -2
  82. package/lib/browser/constants/index.js +1 -2
  83. package/lib/browser/constants/numericConstants.d.ts +1 -3
  84. package/lib/browser/constants/numericConstants.js +3 -5
  85. package/lib/browser/constituentMap/constituentMap.d.ts +0 -2
  86. package/lib/browser/constituentMap/constituentMap.js +10 -6
  87. package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  88. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  89. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  90. package/lib/browser/core/VelocityCore.d.ts +9 -15
  91. package/lib/browser/core/VelocityCore.js +5 -7
  92. package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
  93. package/lib/browser/core/instructions/perpOrders.js +14 -0
  94. package/lib/browser/core/instructions/withdraw.d.ts +1 -1
  95. package/lib/browser/core/instructions/withdraw.js +1 -1
  96. package/lib/browser/core/remainingAccounts.d.ts +2 -2
  97. package/lib/browser/core/remainingAccounts.js +5 -5
  98. package/lib/browser/decode/user.js +9 -1
  99. package/lib/browser/dlob/DLOB.d.ts +7 -2
  100. package/lib/browser/dlob/DLOB.js +205 -142
  101. package/lib/browser/dlob/DLOBNode.d.ts +5 -2
  102. package/lib/browser/dlob/DLOBNode.js +7 -0
  103. package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -2
  104. package/lib/browser/dlob/DLOBSubscriber.js +39 -39
  105. package/lib/browser/dlob/NodeList.js +8 -7
  106. package/lib/browser/dlob/orderBookLevels.js +24 -17
  107. package/lib/browser/dlob/types.d.ts +0 -2
  108. package/lib/browser/events/eventList.js +4 -1
  109. package/lib/browser/events/eventSubscriber.d.ts +6 -3
  110. package/lib/browser/events/eventSubscriber.js +75 -26
  111. package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
  112. package/lib/browser/events/eventsServerLogProvider.js +17 -10
  113. package/lib/browser/events/fetchLogs.d.ts +1 -1
  114. package/lib/browser/events/fetchLogs.js +4 -2
  115. package/lib/browser/events/parse.js +14 -14
  116. package/lib/browser/events/pollingLogProvider.d.ts +1 -1
  117. package/lib/browser/events/pollingLogProvider.js +1 -0
  118. package/lib/browser/events/txEventCache.js +6 -2
  119. package/lib/browser/events/types.d.ts +3 -7
  120. package/lib/browser/events/types.js +1 -3
  121. package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
  122. package/lib/browser/events/webSocketLogProvider.js +5 -2
  123. package/lib/browser/factory/bigNum.js +1 -1
  124. package/lib/{node/idl/drift.d.ts → browser/idl/velocity.d.ts} +2412 -2481
  125. package/lib/browser/idl/{drift.json → velocity.json} +2265 -2333
  126. package/lib/browser/index.d.ts +1 -3
  127. package/lib/browser/index.js +1 -4
  128. package/lib/browser/jupiter/jupiterClient.d.ts +1 -1
  129. package/lib/browser/jupiter/jupiterClient.js +18 -8
  130. package/lib/browser/marginCalculation.js +1 -0
  131. package/lib/browser/math/amm.d.ts +31 -13
  132. package/lib/browser/math/amm.js +87 -31
  133. package/lib/browser/math/auction.js +16 -12
  134. package/lib/browser/math/bankruptcy.js +1 -1
  135. package/lib/browser/math/builder.d.ts +18 -1
  136. package/lib/browser/math/builder.js +32 -1
  137. package/lib/browser/math/funding.js +30 -30
  138. package/lib/browser/math/insurance.d.ts +1 -1
  139. package/lib/browser/math/insurance.js +4 -5
  140. package/lib/browser/math/margin.d.ts +3 -11
  141. package/lib/browser/math/margin.js +10 -69
  142. package/lib/browser/math/market.d.ts +4 -12
  143. package/lib/browser/math/market.js +12 -46
  144. package/lib/browser/math/oracles.d.ts +4 -7
  145. package/lib/browser/math/oracles.js +24 -37
  146. package/lib/browser/math/orders.d.ts +2 -7
  147. package/lib/browser/math/orders.js +9 -81
  148. package/lib/browser/math/position.d.ts +0 -4
  149. package/lib/browser/math/position.js +6 -11
  150. package/lib/browser/math/repeg.d.ts +0 -1
  151. package/lib/browser/math/repeg.js +1 -23
  152. package/lib/browser/math/spotBalance.d.ts +4 -4
  153. package/lib/browser/math/spotBalance.js +6 -6
  154. package/lib/browser/math/spotMarket.d.ts +0 -6
  155. package/lib/browser/math/spotMarket.js +1 -16
  156. package/lib/browser/math/spotPosition.d.ts +4 -4
  157. package/lib/browser/math/state.d.ts +0 -2
  158. package/lib/browser/math/state.js +1 -9
  159. package/lib/browser/math/superStake.d.ts +11 -63
  160. package/lib/browser/math/superStake.js +29 -28
  161. package/lib/browser/math/trade.js +7 -7
  162. package/lib/browser/math/utils.d.ts +1 -1
  163. package/lib/browser/math/utils.js +1 -1
  164. package/lib/browser/memcmp.d.ts +0 -1
  165. package/lib/browser/memcmp.js +1 -10
  166. package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
  167. package/lib/browser/oracles/pythClient.js +9 -3
  168. package/lib/browser/oracles/pythLazerClient.js +5 -4
  169. package/lib/browser/oracles/utils.d.ts +4 -0
  170. package/lib/browser/oracles/utils.js +9 -1
  171. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -3
  172. package/lib/browser/orderSubscriber/OrderSubscriber.js +16 -14
  173. package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
  174. package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
  175. package/lib/browser/orderSubscriber/types.d.ts +0 -2
  176. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  177. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +2 -6
  178. package/lib/browser/priorityFee/priorityFeeSubscriber.js +34 -18
  179. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
  180. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +3 -11
  181. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  182. package/lib/browser/priorityFee/types.d.ts +3 -8
  183. package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
  184. package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +1 -3
  185. package/lib/browser/pyth/pythLazerSubscriber.d.ts +1 -1
  186. package/lib/browser/pyth/pythLazerSubscriber.js +1 -1
  187. package/lib/browser/pyth/types.d.ts +0 -1
  188. package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
  189. package/lib/browser/slot/SlotSubscriber.js +2 -1
  190. package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
  191. package/lib/browser/slot/SlothashSubscriber.js +11 -4
  192. package/lib/browser/swap/UnifiedSwapClient.js +1 -1
  193. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  194. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  195. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +7 -7
  196. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +14 -10
  197. package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -6
  198. package/lib/browser/swift/swiftOrderSubscriber.js +15 -16
  199. package/lib/browser/testClient.js +3 -2
  200. package/lib/browser/tokenFaucet.js +16 -2
  201. package/lib/browser/tx/baseTxSender.d.ts +4 -4
  202. package/lib/browser/tx/baseTxSender.js +5 -4
  203. package/lib/browser/tx/fastSingleTxSender.d.ts +3 -3
  204. package/lib/browser/tx/fastSingleTxSender.js +9 -5
  205. package/lib/browser/tx/reportTransactionError.d.ts +2 -2
  206. package/lib/browser/tx/reportTransactionError.js +5 -1
  207. package/lib/browser/tx/retryTxSender.d.ts +1 -1
  208. package/lib/browser/tx/retryTxSender.js +4 -2
  209. package/lib/browser/tx/txHandler.d.ts +7 -1
  210. package/lib/browser/tx/txHandler.js +54 -40
  211. package/lib/browser/tx/txParamProcessor.d.ts +4 -1
  212. package/lib/browser/tx/txParamProcessor.js +6 -0
  213. package/lib/browser/tx/types.d.ts +1 -1
  214. package/lib/browser/tx/whileValidTxSender.d.ts +1 -6
  215. package/lib/browser/tx/whileValidTxSender.js +35 -13
  216. package/lib/browser/types.d.ts +102 -157
  217. package/lib/browser/types.js +6 -2
  218. package/lib/browser/user.d.ts +22 -10
  219. package/lib/browser/user.js +174 -154
  220. package/lib/browser/userConfig.d.ts +3 -2
  221. package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
  222. package/lib/browser/userMap/WebsocketSubscription.js +1 -1
  223. package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
  224. package/lib/browser/userMap/grpcSubscription.js +1 -1
  225. package/lib/browser/userMap/referrerMap.d.ts +0 -2
  226. package/lib/browser/userMap/referrerMap.js +10 -7
  227. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +0 -2
  228. package/lib/browser/userMap/revenueShareEscrowMap.js +4 -4
  229. package/lib/browser/userMap/userMap.d.ts +3 -5
  230. package/lib/browser/userMap/userMap.js +39 -30
  231. package/lib/browser/userMap/userMapConfig.d.ts +3 -2
  232. package/lib/browser/userMap/userStatsMap.d.ts +1 -3
  233. package/lib/browser/userMap/userStatsMap.js +18 -17
  234. package/lib/browser/userStats.d.ts +7 -4
  235. package/lib/browser/userStats.js +28 -18
  236. package/lib/browser/userStatsConfig.d.ts +3 -2
  237. package/lib/browser/util/TransactionConfirmationManager.js +4 -2
  238. package/lib/browser/util/chainClock.d.ts +1 -1
  239. package/lib/browser/util/computeUnits.d.ts +1 -1
  240. package/lib/browser/util/computeUnits.js +6 -1
  241. package/lib/browser/util/ed25519Utils.d.ts +1 -1
  242. package/lib/browser/util/ed25519Utils.js +1 -1
  243. package/lib/browser/velocityClient.d.ts +144 -71
  244. package/lib/browser/velocityClient.js +653 -457
  245. package/lib/browser/velocityClientConfig.d.ts +0 -8
  246. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
  247. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
  248. package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
  249. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  250. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
  251. package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
  252. package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
  253. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
  254. package/lib/node/accounts/bulkAccountLoader.js +12 -1
  255. package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
  256. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  257. package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
  258. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  259. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  260. package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
  261. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  262. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  263. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  264. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  265. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  266. package/lib/node/accounts/grpcProgramAccountSubscriber.js +9 -3
  267. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
  268. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  269. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +19 -6
  270. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -5
  271. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  272. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +44 -23
  273. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  274. package/lib/node/accounts/laserProgramAccountSubscriber.js +4 -1
  275. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  276. package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
  277. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  278. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  279. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  280. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  281. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  282. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  283. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  284. package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
  285. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  286. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  287. package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
  288. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  289. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
  290. package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
  291. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  292. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  293. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  294. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -5
  295. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  296. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +69 -35
  297. package/lib/node/accounts/types.d.ts +6 -12
  298. package/lib/node/accounts/types.d.ts.map +1 -1
  299. package/lib/node/accounts/utils.d.ts +1 -0
  300. package/lib/node/accounts/utils.d.ts.map +1 -1
  301. package/lib/node/accounts/utils.js +10 -3
  302. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
  303. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  304. package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
  305. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  306. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  307. package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
  308. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  309. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  310. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  311. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  312. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  313. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
  314. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  315. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  316. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  317. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  318. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  319. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  320. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  321. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  322. package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
  323. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  324. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  325. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  326. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -8
  327. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  328. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +52 -26
  329. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -7
  330. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  331. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +49 -20
  332. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  333. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  334. package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  335. package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
  336. package/lib/node/addresses/marketAddresses.js +3 -2
  337. package/lib/node/addresses/pda.d.ts +1 -9
  338. package/lib/node/addresses/pda.d.ts.map +1 -1
  339. package/lib/node/addresses/pda.js +4 -23
  340. package/lib/node/adminClient.d.ts +25 -29
  341. package/lib/node/adminClient.d.ts.map +1 -1
  342. package/lib/node/adminClient.js +168 -169
  343. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +2 -4
  344. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  345. package/lib/node/auctionSubscriber/auctionSubscriber.js +8 -10
  346. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +2 -4
  347. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  348. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +11 -10
  349. package/lib/node/auctionSubscriber/types.d.ts +3 -2
  350. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  351. package/lib/node/bankrun/bankrunConnection.d.ts +6 -4
  352. package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
  353. package/lib/node/bankrun/bankrunConnection.js +69 -31
  354. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  355. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
  356. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  357. package/lib/node/clock/clockSubscriber.d.ts +6 -6
  358. package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
  359. package/lib/node/clock/clockSubscriber.js +4 -3
  360. package/lib/node/config.d.ts +11 -20
  361. package/lib/node/config.d.ts.map +1 -1
  362. package/lib/node/config.js +13 -36
  363. package/lib/node/constants/index.d.ts +1 -2
  364. package/lib/node/constants/index.d.ts.map +1 -1
  365. package/lib/node/constants/index.js +1 -2
  366. package/lib/node/constants/numericConstants.d.ts +1 -3
  367. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  368. package/lib/node/constants/numericConstants.js +3 -5
  369. package/lib/node/constituentMap/constituentMap.d.ts +0 -2
  370. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  371. package/lib/node/constituentMap/constituentMap.js +10 -6
  372. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
  373. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  374. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  375. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
  376. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  377. package/lib/node/core/VelocityCore.d.ts +9 -15
  378. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  379. package/lib/node/core/VelocityCore.js +5 -7
  380. package/lib/node/core/instructions/perpOrders.d.ts +14 -0
  381. package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
  382. package/lib/node/core/instructions/perpOrders.js +14 -0
  383. package/lib/node/core/instructions/withdraw.d.ts +1 -1
  384. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  385. package/lib/node/core/instructions/withdraw.js +1 -1
  386. package/lib/node/core/remainingAccounts.d.ts +2 -2
  387. package/lib/node/core/remainingAccounts.d.ts.map +1 -1
  388. package/lib/node/core/remainingAccounts.js +5 -5
  389. package/lib/node/decode/user.d.ts.map +1 -1
  390. package/lib/node/decode/user.js +9 -1
  391. package/lib/node/dlob/DLOB.d.ts +7 -2
  392. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  393. package/lib/node/dlob/DLOB.js +205 -142
  394. package/lib/node/dlob/DLOBNode.d.ts +5 -2
  395. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  396. package/lib/node/dlob/DLOBNode.js +7 -0
  397. package/lib/node/dlob/DLOBSubscriber.d.ts +0 -2
  398. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  399. package/lib/node/dlob/DLOBSubscriber.js +39 -39
  400. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  401. package/lib/node/dlob/NodeList.js +8 -7
  402. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  403. package/lib/node/dlob/orderBookLevels.js +24 -17
  404. package/lib/node/dlob/types.d.ts +0 -2
  405. package/lib/node/dlob/types.d.ts.map +1 -1
  406. package/lib/node/events/eventList.d.ts +3 -3
  407. package/lib/node/events/eventList.d.ts.map +1 -1
  408. package/lib/node/events/eventList.js +4 -1
  409. package/lib/node/events/eventSubscriber.d.ts +6 -3
  410. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  411. package/lib/node/events/eventSubscriber.js +75 -26
  412. package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
  413. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
  414. package/lib/node/events/eventsServerLogProvider.js +17 -10
  415. package/lib/node/events/fetchLogs.d.ts +1 -1
  416. package/lib/node/events/fetchLogs.d.ts.map +1 -1
  417. package/lib/node/events/fetchLogs.js +4 -2
  418. package/lib/node/events/parse.d.ts.map +1 -1
  419. package/lib/node/events/parse.js +14 -14
  420. package/lib/node/events/pollingLogProvider.d.ts +2 -2
  421. package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
  422. package/lib/node/events/pollingLogProvider.js +1 -0
  423. package/lib/node/events/txEventCache.d.ts +3 -3
  424. package/lib/node/events/txEventCache.d.ts.map +1 -1
  425. package/lib/node/events/txEventCache.js +6 -2
  426. package/lib/node/events/types.d.ts +3 -7
  427. package/lib/node/events/types.d.ts.map +1 -1
  428. package/lib/node/events/types.js +1 -3
  429. package/lib/node/events/webSocketLogProvider.d.ts +2 -2
  430. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
  431. package/lib/node/events/webSocketLogProvider.js +5 -2
  432. package/lib/node/factory/bigNum.js +1 -1
  433. package/lib/{browser/idl/drift.d.ts → node/idl/velocity.d.ts} +2413 -2480
  434. package/lib/node/idl/velocity.d.ts.map +1 -0
  435. package/lib/node/idl/{drift.json → velocity.json} +2265 -2333
  436. package/lib/node/index.d.ts +1 -3
  437. package/lib/node/index.d.ts.map +1 -1
  438. package/lib/node/index.js +1 -4
  439. package/lib/node/jupiter/jupiterClient.d.ts +1 -1
  440. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
  441. package/lib/node/jupiter/jupiterClient.js +18 -8
  442. package/lib/node/marginCalculation.d.ts.map +1 -1
  443. package/lib/node/marginCalculation.js +1 -0
  444. package/lib/node/math/amm.d.ts +31 -13
  445. package/lib/node/math/amm.d.ts.map +1 -1
  446. package/lib/node/math/amm.js +87 -31
  447. package/lib/node/math/auction.d.ts.map +1 -1
  448. package/lib/node/math/auction.js +16 -12
  449. package/lib/node/math/bankruptcy.js +1 -1
  450. package/lib/node/math/builder.d.ts +18 -1
  451. package/lib/node/math/builder.d.ts.map +1 -1
  452. package/lib/node/math/builder.js +32 -1
  453. package/lib/node/math/funding.d.ts.map +1 -1
  454. package/lib/node/math/funding.js +30 -30
  455. package/lib/node/math/insurance.d.ts +1 -1
  456. package/lib/node/math/insurance.d.ts.map +1 -1
  457. package/lib/node/math/insurance.js +4 -5
  458. package/lib/node/math/margin.d.ts +3 -11
  459. package/lib/node/math/margin.d.ts.map +1 -1
  460. package/lib/node/math/margin.js +10 -69
  461. package/lib/node/math/market.d.ts +4 -12
  462. package/lib/node/math/market.d.ts.map +1 -1
  463. package/lib/node/math/market.js +12 -46
  464. package/lib/node/math/oracles.d.ts +4 -7
  465. package/lib/node/math/oracles.d.ts.map +1 -1
  466. package/lib/node/math/oracles.js +24 -37
  467. package/lib/node/math/orders.d.ts +2 -7
  468. package/lib/node/math/orders.d.ts.map +1 -1
  469. package/lib/node/math/orders.js +9 -81
  470. package/lib/node/math/position.d.ts +1 -5
  471. package/lib/node/math/position.d.ts.map +1 -1
  472. package/lib/node/math/position.js +6 -11
  473. package/lib/node/math/repeg.d.ts +0 -1
  474. package/lib/node/math/repeg.d.ts.map +1 -1
  475. package/lib/node/math/repeg.js +1 -23
  476. package/lib/node/math/spotBalance.d.ts +4 -4
  477. package/lib/node/math/spotBalance.d.ts.map +1 -1
  478. package/lib/node/math/spotBalance.js +6 -6
  479. package/lib/node/math/spotMarket.d.ts +0 -6
  480. package/lib/node/math/spotMarket.d.ts.map +1 -1
  481. package/lib/node/math/spotMarket.js +1 -16
  482. package/lib/node/math/spotPosition.d.ts +4 -4
  483. package/lib/node/math/spotPosition.d.ts.map +1 -1
  484. package/lib/node/math/state.d.ts +0 -2
  485. package/lib/node/math/state.d.ts.map +1 -1
  486. package/lib/node/math/state.js +1 -9
  487. package/lib/node/math/superStake.d.ts +11 -63
  488. package/lib/node/math/superStake.d.ts.map +1 -1
  489. package/lib/node/math/superStake.js +29 -28
  490. package/lib/node/math/trade.d.ts +2 -2
  491. package/lib/node/math/trade.d.ts.map +1 -1
  492. package/lib/node/math/trade.js +7 -7
  493. package/lib/node/math/utils.d.ts +1 -1
  494. package/lib/node/math/utils.js +1 -1
  495. package/lib/node/memcmp.d.ts +0 -1
  496. package/lib/node/memcmp.d.ts.map +1 -1
  497. package/lib/node/memcmp.js +1 -10
  498. package/lib/node/oracles/oracleClientCache.d.ts +1 -1
  499. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  500. package/lib/node/oracles/prelaunchOracleClient.js +3 -2
  501. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  502. package/lib/node/oracles/pythClient.js +9 -3
  503. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  504. package/lib/node/oracles/pythLazerClient.js +5 -4
  505. package/lib/node/oracles/utils.d.ts +4 -0
  506. package/lib/node/oracles/utils.d.ts.map +1 -1
  507. package/lib/node/oracles/utils.js +9 -1
  508. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -3
  509. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  510. package/lib/node/orderSubscriber/OrderSubscriber.js +16 -14
  511. package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
  512. package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
  513. package/lib/node/orderSubscriber/types.d.ts +0 -2
  514. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  515. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  516. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
  517. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +2 -6
  518. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  519. package/lib/node/priorityFee/priorityFeeSubscriber.js +34 -18
  520. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
  521. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  522. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +3 -11
  523. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  524. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
  525. package/lib/node/priorityFee/types.d.ts +3 -8
  526. package/lib/node/priorityFee/types.d.ts.map +1 -1
  527. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
  528. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
  529. package/lib/node/priorityFee/velocityPriorityFeeMethod.js +1 -3
  530. package/lib/node/pyth/pythLazerSubscriber.d.ts +1 -1
  531. package/lib/node/pyth/pythLazerSubscriber.js +1 -1
  532. package/lib/node/pyth/types.d.ts +0 -1
  533. package/lib/node/pyth/types.d.ts.map +1 -1
  534. package/lib/node/slot/SlotSubscriber.d.ts +1 -1
  535. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
  536. package/lib/node/slot/SlotSubscriber.js +2 -1
  537. package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
  538. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
  539. package/lib/node/slot/SlothashSubscriber.js +11 -4
  540. package/lib/node/swap/UnifiedSwapClient.js +1 -1
  541. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  542. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
  543. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  544. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +7 -7
  545. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  546. package/lib/node/swift/signedMsgUserAccountSubscriber.js +14 -10
  547. package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -6
  548. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  549. package/lib/node/swift/swiftOrderSubscriber.js +15 -16
  550. package/lib/node/testClient.js +3 -2
  551. package/lib/node/tokenFaucet.d.ts.map +1 -1
  552. package/lib/node/tokenFaucet.js +16 -2
  553. package/lib/node/tx/baseTxSender.d.ts +4 -4
  554. package/lib/node/tx/baseTxSender.d.ts.map +1 -1
  555. package/lib/node/tx/baseTxSender.js +5 -4
  556. package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
  557. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
  558. package/lib/node/tx/fastSingleTxSender.js +9 -5
  559. package/lib/node/tx/reportTransactionError.d.ts +2 -2
  560. package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
  561. package/lib/node/tx/reportTransactionError.js +5 -1
  562. package/lib/node/tx/retryTxSender.d.ts +1 -1
  563. package/lib/node/tx/retryTxSender.d.ts.map +1 -1
  564. package/lib/node/tx/retryTxSender.js +4 -2
  565. package/lib/node/tx/txHandler.d.ts +9 -3
  566. package/lib/node/tx/txHandler.d.ts.map +1 -1
  567. package/lib/node/tx/txHandler.js +54 -40
  568. package/lib/node/tx/txParamProcessor.d.ts +4 -1
  569. package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
  570. package/lib/node/tx/txParamProcessor.js +6 -0
  571. package/lib/node/tx/types.d.ts +1 -1
  572. package/lib/node/tx/types.d.ts.map +1 -1
  573. package/lib/node/tx/whileValidTxSender.d.ts +1 -6
  574. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
  575. package/lib/node/tx/whileValidTxSender.js +35 -13
  576. package/lib/node/types.d.ts +100 -155
  577. package/lib/node/types.d.ts.map +1 -1
  578. package/lib/node/types.js +6 -2
  579. package/lib/node/user.d.ts +22 -10
  580. package/lib/node/user.d.ts.map +1 -1
  581. package/lib/node/user.js +174 -154
  582. package/lib/node/userConfig.d.ts +3 -2
  583. package/lib/node/userConfig.d.ts.map +1 -1
  584. package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
  585. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
  586. package/lib/node/userMap/WebsocketSubscription.js +1 -1
  587. package/lib/node/userMap/grpcSubscription.d.ts +1 -1
  588. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
  589. package/lib/node/userMap/grpcSubscription.js +1 -1
  590. package/lib/node/userMap/referrerMap.d.ts +0 -2
  591. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  592. package/lib/node/userMap/referrerMap.js +10 -7
  593. package/lib/node/userMap/revenueShareEscrowMap.d.ts +0 -2
  594. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  595. package/lib/node/userMap/revenueShareEscrowMap.js +4 -4
  596. package/lib/node/userMap/userMap.d.ts +3 -5
  597. package/lib/node/userMap/userMap.d.ts.map +1 -1
  598. package/lib/node/userMap/userMap.js +39 -30
  599. package/lib/node/userMap/userMapConfig.d.ts +3 -2
  600. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  601. package/lib/node/userMap/userStatsMap.d.ts +1 -3
  602. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  603. package/lib/node/userMap/userStatsMap.js +18 -17
  604. package/lib/node/userStats.d.ts +7 -4
  605. package/lib/node/userStats.d.ts.map +1 -1
  606. package/lib/node/userStats.js +28 -18
  607. package/lib/node/userStatsConfig.d.ts +3 -2
  608. package/lib/node/userStatsConfig.d.ts.map +1 -1
  609. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
  610. package/lib/node/util/TransactionConfirmationManager.js +4 -2
  611. package/lib/node/util/chainClock.d.ts +1 -1
  612. package/lib/node/util/chainClock.d.ts.map +1 -1
  613. package/lib/node/util/computeUnits.d.ts +1 -1
  614. package/lib/node/util/computeUnits.d.ts.map +1 -1
  615. package/lib/node/util/computeUnits.js +6 -1
  616. package/lib/node/util/ed25519Utils.d.ts +1 -1
  617. package/lib/node/util/ed25519Utils.js +1 -1
  618. package/lib/node/velocityClient.d.ts +145 -72
  619. package/lib/node/velocityClient.d.ts.map +1 -1
  620. package/lib/node/velocityClient.js +653 -457
  621. package/lib/node/velocityClientConfig.d.ts +0 -8
  622. package/lib/node/velocityClientConfig.d.ts.map +1 -1
  623. package/package.json +10 -9
  624. package/scripts/deposit-isolated-positions.ts +2 -2
  625. package/scripts/find-flagged-users.ts +1 -1
  626. package/scripts/grpc-client-test-comparison.ts +4 -4
  627. package/scripts/grpc-multiuser-client-test-comparison.ts +2 -2
  628. package/scripts/single-grpc-client-test.ts +3 -3
  629. package/scripts/updateVersion.js +4 -4
  630. package/scripts/withdraw-isolated-positions.ts +2 -2
  631. package/src/accounts/basicUserAccountSubscriber.ts +7 -5
  632. package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
  633. package/src/accounts/bulkAccountLoader.ts +20 -7
  634. package/src/accounts/grpcAccountSubscriber.ts +11 -3
  635. package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
  636. package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
  637. package/src/accounts/grpcProgramAccountSubscriber.ts +12 -4
  638. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -14
  639. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +69 -49
  640. package/src/accounts/laserProgramAccountSubscriber.ts +4 -1
  641. package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
  642. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
  643. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
  644. package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
  645. package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
  646. package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
  647. package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
  648. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +80 -41
  649. package/src/accounts/types.ts +8 -13
  650. package/src/accounts/utils.ts +12 -2
  651. package/src/accounts/webSocketAccountSubscriber.ts +23 -10
  652. package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
  653. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
  654. package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
  655. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
  656. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
  657. package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
  658. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
  659. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +79 -58
  660. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +77 -45
  661. package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
  662. package/src/addresses/marketAddresses.ts +3 -2
  663. package/src/addresses/pda.ts +3 -38
  664. package/src/adminClient.ts +285 -315
  665. package/src/auctionSubscriber/auctionSubscriber.ts +8 -11
  666. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +13 -11
  667. package/src/auctionSubscriber/types.ts +3 -3
  668. package/src/bankrun/bankrunConnection.ts +83 -39
  669. package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
  670. package/src/clock/clockSubscriber.ts +10 -9
  671. package/src/config.ts +16 -70
  672. package/src/constants/index.ts +1 -2
  673. package/src/constants/numericConstants.ts +3 -3
  674. package/src/constituentMap/constituentMap.ts +10 -7
  675. package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
  676. package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
  677. package/src/core/VelocityCore.ts +11 -20
  678. package/src/core/instructions/perpOrders.ts +14 -0
  679. package/src/core/instructions/withdraw.ts +2 -2
  680. package/src/core/remainingAccounts.ts +7 -7
  681. package/src/decode/user.ts +8 -1
  682. package/src/dlob/DLOB.ts +300 -176
  683. package/src/dlob/DLOBNode.ts +23 -3
  684. package/src/dlob/DLOBSubscriber.ts +53 -42
  685. package/src/dlob/NodeList.ts +8 -7
  686. package/src/dlob/orderBookLevels.ts +51 -25
  687. package/src/dlob/types.ts +0 -2
  688. package/src/events/eventList.ts +4 -1
  689. package/src/events/eventSubscriber.ts +108 -50
  690. package/src/events/eventsServerLogProvider.ts +24 -15
  691. package/src/events/fetchLogs.ts +3 -3
  692. package/src/events/parse.ts +14 -14
  693. package/src/events/pollingLogProvider.ts +2 -2
  694. package/src/events/txEventCache.ts +8 -2
  695. package/src/events/types.ts +4 -15
  696. package/src/events/webSocketLogProvider.ts +5 -3
  697. package/src/factory/bigNum.ts +2 -2
  698. package/src/idl/{drift.json → velocity.json} +2265 -2333
  699. package/src/idl/{drift.ts → velocity.ts} +2267 -2335
  700. package/src/index.ts +1 -6
  701. package/src/jupiter/jupiterClient.ts +30 -10
  702. package/src/margin/README.md +2 -2
  703. package/src/marginCalculation.ts +1 -0
  704. package/src/math/amm.ts +217 -40
  705. package/src/math/auction.ts +16 -12
  706. package/src/math/bankruptcy.ts +1 -1
  707. package/src/math/builder.ts +45 -1
  708. package/src/math/funding.ts +51 -47
  709. package/src/math/insurance.ts +6 -8
  710. package/src/math/margin.ts +12 -119
  711. package/src/math/market.ts +16 -98
  712. package/src/math/oracles.ts +29 -43
  713. package/src/math/orders.ts +13 -109
  714. package/src/math/position.ts +6 -12
  715. package/src/math/repeg.ts +0 -29
  716. package/src/math/spotBalance.ts +14 -10
  717. package/src/math/spotMarket.ts +2 -28
  718. package/src/math/spotPosition.ts +4 -4
  719. package/src/math/state.ts +0 -8
  720. package/src/math/superStake.ts +36 -85
  721. package/src/math/trade.ts +7 -3
  722. package/src/math/utils.ts +1 -1
  723. package/src/memcmp.ts +0 -9
  724. package/src/oracles/prelaunchOracleClient.ts +7 -2
  725. package/src/oracles/pythClient.ts +12 -3
  726. package/src/oracles/pythLazerClient.ts +10 -5
  727. package/src/oracles/utils.ts +15 -0
  728. package/src/orderSubscriber/OrderSubscriber.ts +12 -12
  729. package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
  730. package/src/orderSubscriber/grpcSubscription.ts +2 -2
  731. package/src/orderSubscriber/types.ts +0 -2
  732. package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
  733. package/src/priorityFee/priorityFeeSubscriber.ts +50 -21
  734. package/src/priorityFee/priorityFeeSubscriberMap.ts +2 -10
  735. package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
  736. package/src/priorityFee/types.ts +3 -13
  737. package/src/priorityFee/velocityPriorityFeeMethod.ts +0 -12
  738. package/src/pyth/pythLazerSubscriber.ts +1 -1
  739. package/src/pyth/types.ts +0 -2
  740. package/src/slot/SlotSubscriber.ts +3 -3
  741. package/src/slot/SlothashSubscriber.ts +17 -6
  742. package/src/swap/UnifiedSwapClient.ts +1 -1
  743. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
  744. package/src/swift/signedMsgUserAccountSubscriber.ts +18 -16
  745. package/src/swift/swiftOrderSubscriber.ts +17 -21
  746. package/src/testClient.ts +2 -2
  747. package/src/tokenFaucet.ts +22 -3
  748. package/src/tx/baseTxSender.ts +10 -10
  749. package/src/tx/fastSingleTxSender.ts +12 -8
  750. package/src/tx/reportTransactionError.ts +12 -7
  751. package/src/tx/retryTxSender.ts +6 -4
  752. package/src/tx/txHandler.ts +88 -43
  753. package/src/tx/txParamProcessor.ts +18 -3
  754. package/src/tx/types.ts +1 -1
  755. package/src/tx/whileValidTxSender.ts +51 -22
  756. package/src/types.ts +119 -173
  757. package/src/user.ts +208 -165
  758. package/src/userConfig.ts +1 -3
  759. package/src/userMap/WebsocketSubscription.ts +2 -2
  760. package/src/userMap/grpcSubscription.ts +2 -2
  761. package/src/userMap/referrerMap.ts +13 -13
  762. package/src/userMap/revenueShareEscrowMap.ts +6 -5
  763. package/src/userMap/userMap.ts +46 -32
  764. package/src/userMap/userMapConfig.ts +3 -3
  765. package/src/userMap/userStatsMap.ts +32 -23
  766. package/src/userStats.ts +22 -13
  767. package/src/userStatsConfig.ts +3 -3
  768. package/src/util/TransactionConfirmationManager.ts +10 -2
  769. package/src/util/chainClock.ts +1 -1
  770. package/src/util/computeUnits.ts +7 -3
  771. package/src/util/ed25519Utils.ts +1 -1
  772. package/src/velocityClient.ts +867 -600
  773. package/src/velocityClientConfig.ts +0 -10
  774. package/tests/{DriftCore → VelocityCore}/decode.test.ts +1 -1
  775. package/tests/{DriftCore → VelocityCore}/fill_trigger.test.ts +1 -1
  776. package/tests/{DriftCore → VelocityCore}/instructions.test.ts +1 -1
  777. package/tests/{DriftCore → VelocityCore}/pdas.test.ts +4 -2
  778. package/tests/amm/test.ts +138 -0
  779. package/tests/ci/verifyConstants.ts +24 -27
  780. package/tests/decode/test.ts +2 -2
  781. package/tests/dlob/helpers.ts +11 -10
  782. package/tests/events/parseLogsForCuUsage.ts +15 -15
  783. package/tests/user/helpers.ts +9 -9
  784. package/tests/user/test.ts +13 -10
  785. package/tsconfig.json +1 -0
  786. package/lib/browser/constants/insuranceFund.d.ts +0 -5
  787. package/lib/browser/constants/insuranceFund.js +0 -9
  788. package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
  789. package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
  790. package/lib/browser/util/deprecatedAlias.d.ts +0 -26
  791. package/lib/browser/util/deprecatedAlias.js +0 -10
  792. package/lib/browser/util/tps.d.ts +0 -2
  793. package/lib/browser/util/tps.js +0 -16
  794. package/lib/node/constants/insuranceFund.d.ts +0 -6
  795. package/lib/node/constants/insuranceFund.d.ts.map +0 -1
  796. package/lib/node/constants/insuranceFund.js +0 -9
  797. package/lib/node/idl/drift.d.ts.map +0 -1
  798. package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
  799. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
  800. package/lib/node/tx/forwardOnlyTxSender.js +0 -92
  801. package/lib/node/util/deprecatedAlias.d.ts +0 -27
  802. package/lib/node/util/deprecatedAlias.d.ts.map +0 -1
  803. package/lib/node/util/deprecatedAlias.js +0 -10
  804. package/lib/node/util/tps.d.ts +0 -3
  805. package/lib/node/util/tps.d.ts.map +0 -1
  806. package/lib/node/util/tps.js +0 -16
  807. package/src/constants/insuranceFund.ts +0 -8
  808. package/src/tx/forwardOnlyTxSender.ts +0 -145
  809. package/src/util/deprecatedAlias.ts +0 -21
  810. package/src/util/tps.ts +0 -27
  811. /package/lib/browser/idl/{drift.js → velocity.js} +0 -0
  812. /package/lib/node/idl/{drift.js → velocity.js} +0 -0
  813. /package/tests/{DriftCore → VelocityCore}/perp_orders.test.ts +0 -0
  814. /package/tests/{DriftCore → VelocityCore}/remainingAccounts.test.ts +0 -0
  815. /package/tests/{DriftCore → VelocityCore}/settlement_liquidation.test.ts +0 -0
@@ -13,32 +13,27 @@ const tweetnacl_util_1 = require("tweetnacl-util");
13
13
  const ws_1 = __importDefault(require("ws"));
14
14
  const sha256_1 = require("@noble/hashes/sha256");
15
15
  class SwiftOrderSubscriber {
16
- /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
17
- get driftClient() {
18
- return this.velocityClient;
19
- }
20
16
  constructor(config) {
21
- var _a;
22
17
  this.config = config;
23
18
  this.heartbeatTimeout = null;
24
19
  this.heartbeatIntervalMs = 60000;
25
20
  this.ws = null;
26
21
  this.subscribed = false;
27
22
  // Type-system guarantees at least one of the two is supplied.
28
- this.velocityClient = ((_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient);
23
+ this.velocityClient = config.velocityClient;
29
24
  this.userAccountGetter = config.userAccountGetter;
30
25
  }
31
26
  unsubscribe() {
27
+ var _a, _b;
32
28
  if (this.subscribed) {
33
- this.ws.removeAllListeners();
34
- this.ws.terminate();
29
+ (_a = this.ws) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
30
+ (_b = this.ws) === null || _b === void 0 ? void 0 : _b.terminate();
35
31
  this.ws = null;
36
32
  this.subscribed = false;
37
33
  }
38
34
  }
39
35
  getSymbolForMarketIndex(marketIndex) {
40
- var _a;
41
- const env = (_a = this.config.velocityEnv) !== null && _a !== void 0 ? _a : this.config.driftEnv;
36
+ const env = this.config.velocityEnv;
42
37
  const markets = env === 'devnet' ? perpMarkets_1.DevnetPerpMarkets : perpMarkets_1.MainnetPerpMarkets;
43
38
  return markets[marketIndex].symbol;
44
39
  }
@@ -72,10 +67,10 @@ class SwiftOrderSubscriber {
72
67
  }
73
68
  }
74
69
  async subscribe(onOrder, acceptSanitized = false, acceptDepositTrade = false) {
75
- var _a, _b;
70
+ var _a;
76
71
  this.onOrder = onOrder;
77
- const env = (_a = this.config.velocityEnv) !== null && _a !== void 0 ? _a : this.config.driftEnv;
78
- const endpoint = (_b = this.config.endpoint) !== null && _b !== void 0 ? _b : (env === 'devnet'
72
+ const env = this.config.velocityEnv;
73
+ const endpoint = (_a = this.config.endpoint) !== null && _a !== void 0 ? _a : (env === 'devnet'
79
74
  ? 'wss://master.swift.drift.trade/ws'
80
75
  : 'wss://swift.drift.trade/ws');
81
76
  const ws = new ws_1.default(endpoint + '?pubkey=' + this.config.keypair.publicKey.toBase58());
@@ -130,8 +125,8 @@ class SwiftOrderSubscriber {
130
125
  this.reconnect();
131
126
  }, 5000);
132
127
  });
133
- ws.on('error', async (request, response) => {
134
- console.error('WS closed from error, reconnecting in 1s:', response.statusCode);
128
+ ws.on('error', async (error) => {
129
+ console.error('WS closed from error, reconnecting in 1s:', error);
135
130
  setTimeout(() => {
136
131
  if (this.heartbeatTimeout)
137
132
  clearTimeout(this.heartbeatTimeout);
@@ -187,8 +182,12 @@ class SwiftOrderSubscriber {
187
182
  this.ws.terminate();
188
183
  }
189
184
  console.log('Reconnecting to WebSocket...');
185
+ const onOrder = this.onOrder;
186
+ if (!onOrder) {
187
+ throw new Error('onOrder callback function must be set');
188
+ }
190
189
  setTimeout(() => {
191
- this.subscribe(this.onOrder);
190
+ this.subscribe(onOrder);
192
191
  }, 1000);
193
192
  }
194
193
  }
@@ -4,8 +4,9 @@ exports.TestClient = void 0;
4
4
  const adminClient_1 = require("./adminClient");
5
5
  class TestClient extends adminClient_1.AdminClient {
6
6
  constructor(config) {
7
+ var _a;
7
8
  config.txVersion = 'legacy';
8
- if (config.accountSubscription.type !== 'polling') {
9
+ if (((_a = config.accountSubscription) === null || _a === void 0 ? void 0 : _a.type) !== 'polling') {
9
10
  throw new Error('Test client must be polling');
10
11
  }
11
12
  super(config);
@@ -14,7 +15,7 @@ class TestClient extends adminClient_1.AdminClient {
14
15
  const { txSig, slot } = await super.sendTransaction(tx, additionalSigners, opts, preSigned);
15
16
  let lastFetchedSlot = this.accountSubscriber.accountLoader.mostRecentSlot;
16
17
  await this.fetchAccounts();
17
- while (lastFetchedSlot < slot) {
18
+ while (slot !== undefined && lastFetchedSlot < slot) {
18
19
  await this.fetchAccounts();
19
20
  lastFetchedSlot = this.accountSubscriber.accountLoader.mostRecentSlot;
20
21
  }
@@ -75,6 +75,9 @@ class TokenFaucet {
75
75
  },
76
76
  });
77
77
  const tx = new web3_js_1.Transaction().add(ix);
78
+ if (!this.context) {
79
+ throw new Error('TokenFaucet: initialize() requires a BankrunContextWrapper context');
80
+ }
78
81
  const txSig = await this.context.sendTransaction(tx);
79
82
  return txSig;
80
83
  }
@@ -99,6 +102,9 @@ class TokenFaucet {
99
102
  return await this.context.sendTransaction(tx);
100
103
  }
101
104
  else {
105
+ if (!this.program.provider.sendAndConfirm) {
106
+ throw new Error('TokenFaucet: program provider does not support sendAndConfirm');
107
+ }
102
108
  return await this.program.provider.sendAndConfirm(tx, [], this.opts);
103
109
  }
104
110
  }
@@ -132,7 +138,9 @@ class TokenFaucet {
132
138
  const [associatedTokenPublicKey, createAssociatedAccountIx, mintToTx] = await this.createAssociatedTokenAccountAndMintToInstructions(userPublicKey, amount);
133
139
  let associatedTokenAccountExists = false;
134
140
  try {
135
- const assosciatedTokenAccount = await this.context.connection.getAccountInfo(associatedTokenPublicKey);
141
+ const assosciatedTokenAccount = this.context
142
+ ? await this.context.connection.getAccountInfo(associatedTokenPublicKey)
143
+ : await this.connection.getAccountInfo(associatedTokenPublicKey);
136
144
  associatedTokenAccountExists = !!assosciatedTokenAccount;
137
145
  }
138
146
  catch (e) {
@@ -148,6 +156,9 @@ class TokenFaucet {
148
156
  txSig = await this.context.sendTransaction(tx);
149
157
  }
150
158
  else {
159
+ if (!this.program.provider.sendAndConfirm) {
160
+ throw new Error('TokenFaucet: program provider does not support sendAndConfirm');
161
+ }
151
162
  txSig = await this.program.provider.sendAndConfirm(tx, [], this.opts);
152
163
  }
153
164
  return [associatedTokenPublicKey, txSig];
@@ -175,7 +186,10 @@ class TokenFaucet {
175
186
  const tokenAccountKey = await this.getAssosciatedMockUSDMintAddress(props);
176
187
  props.callback(await this.getTokenAccountInfo(props));
177
188
  // Couldn't find a way to do it using anchor framework subscription — fall back to onAccountChange.
178
- this.context.connection.onAccountChange(tokenAccountKey, async (_accountInfo /* accountInfo is a buffer which we don't know how to deserialize */) => {
189
+ const subscribeConnection = this.context
190
+ ? this.context.connection
191
+ : this.connection;
192
+ subscribeConnection.onAccountChange(tokenAccountKey, async (_accountInfo /* accountInfo is a buffer which we don't know how to deserialize */) => {
179
193
  props.callback(await this.getTokenAccountInfo(props));
180
194
  });
181
195
  return true;
@@ -13,7 +13,7 @@ export declare abstract class BaseTxSender implements TxSender {
13
13
  additionalConnections: Connection[];
14
14
  timeoutCount: number;
15
15
  confirmationStrategy: ConfirmationStrategy;
16
- additionalTxSenderCallbacks: ((base58EncodedTx: string) => void)[];
16
+ additionalTxSenderCallbacks?: ((base58EncodedTx: string) => void)[];
17
17
  txHandler: TxHandler;
18
18
  trackTxLandRate?: boolean;
19
19
  throwOnTimeoutError: boolean;
@@ -28,7 +28,7 @@ export declare abstract class BaseTxSender implements TxSender {
28
28
  wallet: IWallet;
29
29
  opts?: ConfirmOptions;
30
30
  timeout?: number;
31
- additionalConnections?: any;
31
+ additionalConnections?: Connection[];
32
32
  confirmationStrategy?: ConfirmationStrategy;
33
33
  additionalTxSenderCallbacks?: ((base58EncodedTx: string) => void)[];
34
34
  txHandler?: TxHandler;
@@ -44,9 +44,9 @@ export declare abstract class BaseTxSender implements TxSender {
44
44
  sendVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
45
45
  sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
46
46
  simulateTransaction(tx: VersionedTransaction): Promise<boolean>;
47
- confirmTransactionWebSocket(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
47
+ confirmTransactionWebSocket(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult> | undefined>;
48
48
  confirmTransactionPolling(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult> | undefined>;
49
- confirmTransaction(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
49
+ confirmTransaction(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult> | undefined>;
50
50
  getTimestamp(): number;
51
51
  promiseTimeout<T>(promises: Promise<T>[], timeoutMs: number): Promise<T | null>;
52
52
  sendToAdditionalConnections(rawTx: Buffer | Uint8Array, opts: ConfirmOptions): void;
@@ -74,7 +74,7 @@ class BaseTxSender {
74
74
  signedTx = tx;
75
75
  }
76
76
  else {
77
- signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners, undefined, this.wallet);
77
+ signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : [], undefined, this.wallet);
78
78
  }
79
79
  if (opts === undefined) {
80
80
  opts = this.opts;
@@ -172,7 +172,7 @@ class BaseTxSender {
172
172
  throw new types_1.TxSendError(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`, txConstants_1.NOT_CONFIRMED_ERROR_CODE);
173
173
  }
174
174
  }
175
- return response;
175
+ return response !== null && response !== void 0 ? response : undefined;
176
176
  }
177
177
  async confirmTransactionPolling(signature, commitment = 'finalized') {
178
178
  var _a;
@@ -256,7 +256,7 @@ class BaseTxSender {
256
256
  return;
257
257
  }
258
258
  getTxLandRate() {
259
- if (!this.trackTxLandRate) {
259
+ if (!this.trackTxLandRate || !this.txSigCache) {
260
260
  return this.txLandRate;
261
261
  }
262
262
  const keys = this.txSigCache.keys();
@@ -275,8 +275,9 @@ class BaseTxSender {
275
275
  return this.txLandRate;
276
276
  }
277
277
  defaultLandRateToFeeFunc(txLandRate) {
278
+ var _a, _b;
278
279
  if (txLandRate >= BASELINE_TX_LAND_RATE ||
279
- this.txSigCache.keys().length < 3) {
280
+ ((_b = (_a = this.txSigCache) === null || _a === void 0 ? void 0 : _a.keys().length) !== null && _b !== void 0 ? _b : 0) < 3) {
280
281
  return 1;
281
282
  }
282
283
  const multiplier = 10 * Math.log10(1 + (BASELINE_TX_LAND_RATE - txLandRate) * 5);
@@ -14,18 +14,18 @@ export declare class FastSingleTxSender extends BaseTxSender {
14
14
  blockhashRefreshInterval: number;
15
15
  additionalConnections: Connection[];
16
16
  timoutCount: number;
17
- recentBlockhash: BlockhashWithExpiryBlockHeight;
17
+ recentBlockhash?: BlockhashWithExpiryBlockHeight;
18
18
  skipConfirmation: boolean;
19
19
  confirmInBackground: boolean;
20
20
  blockhashCommitment: Commitment;
21
- blockhashIntervalId: NodeJS.Timer;
21
+ blockhashIntervalId?: NodeJS.Timer;
22
22
  constructor({ connection, wallet, opts, timeout, blockhashRefreshInterval, additionalConnections, skipConfirmation, confirmInBackground, blockhashCommitment, confirmationStrategy, trackTxLandRate, txHandler, txLandRateLookbackWindowMinutes, landRateToFeeFunc, throwOnTimeoutError, }: {
23
23
  connection: Connection;
24
24
  wallet: IWallet;
25
25
  opts?: ConfirmOptions;
26
26
  timeout?: number;
27
27
  blockhashRefreshInterval?: number;
28
- additionalConnections?: any;
28
+ additionalConnections?: Connection[];
29
29
  skipConfirmation?: boolean;
30
30
  confirmInBackground?: boolean;
31
31
  blockhashCommitment?: Commitment;
@@ -46,7 +46,7 @@ class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
46
46
  }
47
47
  }
48
48
  async sendRawTransaction(rawTransaction, opts) {
49
- var _a, _b, _c;
49
+ var _a, _b;
50
50
  let txid;
51
51
  try {
52
52
  txid = await this.connection.sendRawTransaction(rawTransaction, opts);
@@ -64,15 +64,19 @@ class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
64
64
  this.confirmTransaction(txid, opts.commitment).then(async (result) => {
65
65
  var _a;
66
66
  (_a = this.txSigCache) === null || _a === void 0 ? void 0 : _a.set(txid, true);
67
- await this.checkConfirmationResultForError(txid, result === null || result === void 0 ? void 0 : result.value);
68
- slot = result.context.slot;
67
+ if (result) {
68
+ await this.checkConfirmationResultForError(txid, result.value);
69
+ slot = result.context.slot;
70
+ }
69
71
  });
70
72
  }
71
73
  else {
72
74
  const result = await this.confirmTransaction(txid, opts.commitment);
73
75
  (_b = this.txSigCache) === null || _b === void 0 ? void 0 : _b.set(txid, true);
74
- await this.checkConfirmationResultForError(txid, result === null || result === void 0 ? void 0 : result.value);
75
- slot = (_c = result === null || result === void 0 ? void 0 : result.context) === null || _c === void 0 ? void 0 : _c.slot;
76
+ if (result) {
77
+ await this.checkConfirmationResultForError(txid, result.value);
78
+ slot = result.context.slot;
79
+ }
76
80
  }
77
81
  }
78
82
  catch (e) {
@@ -16,5 +16,5 @@ export declare const throwTransactionError: (txSig: string, connection: Connecti
16
16
  * @param connection
17
17
  * @returns
18
18
  */
19
- export declare const getTransactionErrorFromTxSig: (txSig: string, connection: Connection, commitment?: Commitment) => Promise<SendTransactionError>;
20
- export declare const getTransactionError: (transactionResult: VersionedTransactionResponse) => SendTransactionError;
19
+ export declare const getTransactionErrorFromTxSig: (txSig: string, connection: Connection, commitment?: Commitment) => Promise<SendTransactionError | undefined>;
20
+ export declare const getTransactionError: (transactionResult: VersionedTransactionResponse) => SendTransactionError | undefined;
@@ -19,7 +19,11 @@ const commitmentToFinality = (commitment) => {
19
19
  }
20
20
  };
21
21
  const getTransactionResult = async (txSig, connection, commitment) => {
22
- const finality = commitmentToFinality(commitment || connection.commitment || config_1.DEFAULT_CONFIRMATION_OPTS.commitment);
22
+ const resolvedCommitment = commitment || connection.commitment || config_1.DEFAULT_CONFIRMATION_OPTS.commitment;
23
+ if (!resolvedCommitment) {
24
+ throw new Error('No commitment available when reporting transaction error. Provide a commitment, set one on the connection, or configure DEFAULT_CONFIRMATION_OPTS.');
25
+ }
26
+ const finality = commitmentToFinality(resolvedCommitment);
23
27
  return await connection.getTransaction(txSig, {
24
28
  maxSupportedTransactionVersion: 0,
25
29
  commitment: finality,
@@ -22,7 +22,7 @@ export declare class RetryTxSender extends BaseTxSender {
22
22
  opts?: ConfirmOptions;
23
23
  timeout?: number;
24
24
  retrySleep?: number;
25
- additionalConnections?: any;
25
+ additionalConnections?: Connection[];
26
26
  confirmationStrategy?: ConfirmationStrategy;
27
27
  additionalTxSenderCallbacks?: ((base58EncodedTx: string) => void)[];
28
28
  txHandler?: TxHandler;
@@ -70,8 +70,10 @@ class RetryTxSender extends baseTxSender_1.BaseTxSender {
70
70
  try {
71
71
  const result = await this.confirmTransaction(txid, opts.commitment);
72
72
  (_b = this.txSigCache) === null || _b === void 0 ? void 0 : _b.set(txid, true);
73
- await this.checkConfirmationResultForError(txid, result === null || result === void 0 ? void 0 : result.value);
74
- slot = (_c = result === null || result === void 0 ? void 0 : result.context) === null || _c === void 0 ? void 0 : _c.slot;
73
+ if (result) {
74
+ await this.checkConfirmationResultForError(txid, result.value);
75
+ slot = (_c = result.context) === null || _c === void 0 ? void 0 : _c.slot;
76
+ }
75
77
  // eslint-disable-next-line no-useless-catch
76
78
  }
77
79
  catch (e) {
@@ -17,7 +17,7 @@ export type TxBuildingProps = {
17
17
  instructions: TransactionInstruction | TransactionInstruction[];
18
18
  txVersion: TransactionVersion;
19
19
  connection: Connection;
20
- preFlightCommitment: Commitment;
20
+ preFlightCommitment?: Commitment;
21
21
  fetchAllMarketLookupTableAccounts: () => Promise<AddressLookupTableAccount[]>;
22
22
  lookupTables?: AddressLookupTableAccount[];
23
23
  forceVersionedTransaction?: boolean;
@@ -74,6 +74,12 @@ export declare class TxHandler {
74
74
  blockhash: string;
75
75
  lastValidBlockHeight: number;
76
76
  }>>;
77
+ /**
78
+ * Resolves a usable recent blockhash, preferring a caller-provided one and
79
+ * otherwise fetching the latest. Throws if no blockhash can be obtained,
80
+ * since a transaction cannot be built or signed without one.
81
+ */
82
+ private resolveRecentBlockhash;
77
83
  /**
78
84
  * Applies recent blockhash and signs a given transaction
79
85
  * @param tx
@@ -39,24 +39,24 @@ const RECENT_BLOCKHASH_STALE_TIME_MS = 2000; // Reuse blockhashes within this ti
39
39
  */
40
40
  class TxHandler {
41
41
  constructor(props) {
42
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
42
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
43
43
  this.blockHashToLastValidBlockHeightLookup = {};
44
44
  this.returnBlockHeightsWithSignedTxCallbackData = false;
45
- this.blockhashCommitment = config_1.DEFAULT_CONFIRMATION_OPTS.commitment;
45
+ this.blockhashCommitment = (_a = config_1.DEFAULT_CONFIRMATION_OPTS.commitment) !== null && _a !== void 0 ? _a : 'confirmed';
46
46
  this.getProps = (wallet, confirmationOpts) => [wallet !== null && wallet !== void 0 ? wallet : this.wallet, confirmationOpts !== null && confirmationOpts !== void 0 ? confirmationOpts : this.confirmationOptions];
47
47
  this.connection = props.connection;
48
48
  this.wallet = props.wallet;
49
49
  this.confirmationOptions = props.confirmationOptions;
50
50
  this.blockhashCommitment =
51
- (_e = (_d = (_b = (_a = props.confirmationOptions) === null || _a === void 0 ? void 0 : _a.preflightCommitment) !== null && _b !== void 0 ? _b : (_c = props === null || props === void 0 ? void 0 : props.connection) === null || _c === void 0 ? void 0 : _c.commitment) !== null && _d !== void 0 ? _d : this.blockhashCommitment) !== null && _e !== void 0 ? _e : 'confirmed';
52
- this.blockHashFetcher = ((_f = props === null || props === void 0 ? void 0 : props.config) === null || _f === void 0 ? void 0 : _f.blockhashCachingEnabled)
53
- ? new cachedBlockhashFetcher_1.CachedBlockhashFetcher(this.connection, this.blockhashCommitment, (_j = (_h = (_g = props === null || props === void 0 ? void 0 : props.config) === null || _g === void 0 ? void 0 : _g.blockhashCachingConfig) === null || _h === void 0 ? void 0 : _h.retryCount) !== null && _j !== void 0 ? _j : BLOCKHASH_FETCH_RETRY_COUNT, (_m = (_l = (_k = props === null || props === void 0 ? void 0 : props.config) === null || _k === void 0 ? void 0 : _k.blockhashCachingConfig) === null || _l === void 0 ? void 0 : _l.retrySleepTimeMs) !== null && _m !== void 0 ? _m : BLOCKHASH_FETCH_RETRY_SLEEP, (_q = (_p = (_o = props === null || props === void 0 ? void 0 : props.config) === null || _o === void 0 ? void 0 : _o.blockhashCachingConfig) === null || _p === void 0 ? void 0 : _p.staleCacheTimeMs) !== null && _q !== void 0 ? _q : RECENT_BLOCKHASH_STALE_TIME_MS)
51
+ (_f = (_e = (_c = (_b = props.confirmationOptions) === null || _b === void 0 ? void 0 : _b.preflightCommitment) !== null && _c !== void 0 ? _c : (_d = props === null || props === void 0 ? void 0 : props.connection) === null || _d === void 0 ? void 0 : _d.commitment) !== null && _e !== void 0 ? _e : this.blockhashCommitment) !== null && _f !== void 0 ? _f : 'confirmed';
52
+ this.blockHashFetcher = ((_g = props === null || props === void 0 ? void 0 : props.config) === null || _g === void 0 ? void 0 : _g.blockhashCachingEnabled)
53
+ ? new cachedBlockhashFetcher_1.CachedBlockhashFetcher(this.connection, this.blockhashCommitment, (_k = (_j = (_h = props === null || props === void 0 ? void 0 : props.config) === null || _h === void 0 ? void 0 : _h.blockhashCachingConfig) === null || _j === void 0 ? void 0 : _j.retryCount) !== null && _k !== void 0 ? _k : BLOCKHASH_FETCH_RETRY_COUNT, (_o = (_m = (_l = props === null || props === void 0 ? void 0 : props.config) === null || _l === void 0 ? void 0 : _l.blockhashCachingConfig) === null || _m === void 0 ? void 0 : _m.retrySleepTimeMs) !== null && _o !== void 0 ? _o : BLOCKHASH_FETCH_RETRY_SLEEP, (_r = (_q = (_p = props === null || props === void 0 ? void 0 : props.config) === null || _p === void 0 ? void 0 : _p.blockhashCachingConfig) === null || _q === void 0 ? void 0 : _q.staleCacheTimeMs) !== null && _r !== void 0 ? _r : RECENT_BLOCKHASH_STALE_TIME_MS)
54
54
  : new baseBlockhashFetcher_1.BaseBlockhashFetcher(this.connection, this.blockhashCommitment);
55
55
  // #Optionals
56
56
  this.returnBlockHeightsWithSignedTxCallbackData =
57
- (_s = (_r = props.opts) === null || _r === void 0 ? void 0 : _r.returnBlockHeightsWithSignedTxCallbackData) !== null && _s !== void 0 ? _s : false;
58
- this.onSignedCb = (_t = props.opts) === null || _t === void 0 ? void 0 : _t.onSignedCb;
59
- this.preSignedCb = (_u = props.opts) === null || _u === void 0 ? void 0 : _u.preSignedCb;
57
+ (_t = (_s = props.opts) === null || _s === void 0 ? void 0 : _s.returnBlockHeightsWithSignedTxCallbackData) !== null && _t !== void 0 ? _t : false;
58
+ this.onSignedCb = (_u = props.opts) === null || _u === void 0 ? void 0 : _u.onSignedCb;
59
+ this.preSignedCb = (_v = props.opts) === null || _v === void 0 ? void 0 : _v.preSignedCb;
60
60
  }
61
61
  getWallet() {
62
62
  return this.wallet;
@@ -80,6 +80,18 @@ class TxHandler {
80
80
  async getLatestBlockhashForTransaction() {
81
81
  return this.blockHashFetcher.getLatestBlockhash();
82
82
  }
83
+ /**
84
+ * Resolves a usable recent blockhash, preferring a caller-provided one and
85
+ * otherwise fetching the latest. Throws if no blockhash can be obtained,
86
+ * since a transaction cannot be built or signed without one.
87
+ */
88
+ async resolveRecentBlockhash(recentBlockhash) {
89
+ const resolved = recentBlockhash !== null && recentBlockhash !== void 0 ? recentBlockhash : (await this.getLatestBlockhashForTransaction());
90
+ if (!resolved) {
91
+ throw new Error('TxHandler: failed to fetch a recent blockhash');
92
+ }
93
+ return resolved;
94
+ }
83
95
  /**
84
96
  * Applies recent blockhash and signs a given transaction
85
97
  * @param tx
@@ -96,14 +108,12 @@ class TxHandler {
96
108
  }
97
109
  [wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
98
110
  tx.feePayer = wallet.publicKey;
99
- recentBlockhash = recentBlockhash
100
- ? recentBlockhash
101
- : await this.getLatestBlockhashForTransaction();
102
- tx.recentBlockhash = recentBlockhash.blockhash;
103
- this.addHashAndExpiryToLookup(recentBlockhash);
111
+ const resolvedBlockhash = await this.resolveRecentBlockhash(recentBlockhash);
112
+ tx.recentBlockhash = resolvedBlockhash.blockhash;
113
+ this.addHashAndExpiryToLookup(resolvedBlockhash);
104
114
  const signedTx = await this.signTx(tx, additionalSigners);
105
115
  // @ts-ignore
106
- signedTx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
116
+ signedTx.SIGNATURE_BLOCK_AND_EXPIRY = resolvedBlockhash;
107
117
  return signedTx;
108
118
  }
109
119
  isVersionedTransaction(tx) {
@@ -117,16 +127,21 @@ class TxHandler {
117
127
  return bs58_1.default.encode(Buffer.from(signedTx.signatures[0]));
118
128
  }
119
129
  else {
120
- return bs58_1.default.encode(Buffer.from(signedTx.signature));
130
+ const signature = signedTx.signature;
131
+ if (!signature) {
132
+ throw new Error('TxHandler: cannot derive txSig from an unsigned legacy transaction');
133
+ }
134
+ return bs58_1.default.encode(Buffer.from(signature));
121
135
  }
122
136
  }
123
137
  getBlockhashFromSignedTx(signedTx) {
124
- if (this.isVersionedTransaction(signedTx)) {
125
- return signedTx.message.recentBlockhash;
126
- }
127
- else {
128
- return signedTx.recentBlockhash;
138
+ const blockHash = this.isVersionedTransaction(signedTx)
139
+ ? signedTx.message.recentBlockhash
140
+ : signedTx.recentBlockhash;
141
+ if (!blockHash) {
142
+ throw new Error('TxHandler: signed transaction is missing a recentBlockhash');
129
143
  }
144
+ return blockHash;
130
145
  }
131
146
  async signTx(tx, additionalSigners, wallet) {
132
147
  var _a;
@@ -180,7 +195,7 @@ class TxHandler {
180
195
  if (this.onSignedCb) {
181
196
  this.onSignedCb(txData);
182
197
  }
183
- return;
198
+ return [];
184
199
  }
185
200
  const signedTxData = txData.map((tx) => {
186
201
  const lastValidBlockHeight = this.blockHashToLastValidBlockHeightLookup[tx.blockHash];
@@ -200,7 +215,7 @@ class TxHandler {
200
215
  * @returns
201
216
  */
202
217
  async getProcessedTransactionParams(txBuildingProps) {
203
- var _a, _b;
218
+ var _a, _b, _c, _d, _e, _f;
204
219
  const baseTxParams = {
205
220
  computeUnits: (_a = txBuildingProps === null || txBuildingProps === void 0 ? void 0 : txBuildingProps.txParams) === null || _a === void 0 ? void 0 : _a.computeUnits,
206
221
  computeUnitsPrice: (_b = txBuildingProps === null || txBuildingProps === void 0 ? void 0 : txBuildingProps.txParams) === null || _b === void 0 ? void 0 : _b.computeUnitsPrice,
@@ -216,11 +231,10 @@ class TxHandler {
216
231
  });
217
232
  },
218
233
  processConfig: {
219
- useSimulatedComputeUnits: txBuildingProps.txParams.useSimulatedComputeUnits,
220
- computeUnitsBufferMultiplier: txBuildingProps.txParams.computeUnitsBufferMultiplier,
221
- useSimulatedComputeUnitsForCUPriceCalculation: txBuildingProps.txParams
222
- .useSimulatedComputeUnitsForCUPriceCalculation,
223
- getCUPriceFromComputeUnits: txBuildingProps.txParams.getCUPriceFromComputeUnits,
234
+ useSimulatedComputeUnits: (_c = txBuildingProps.txParams) === null || _c === void 0 ? void 0 : _c.useSimulatedComputeUnits,
235
+ computeUnitsBufferMultiplier: (_d = txBuildingProps.txParams) === null || _d === void 0 ? void 0 : _d.computeUnitsBufferMultiplier,
236
+ useSimulatedComputeUnitsForCUPriceCalculation: (_e = txBuildingProps.txParams) === null || _e === void 0 ? void 0 : _e.useSimulatedComputeUnitsForCUPriceCalculation,
237
+ getCUPriceFromComputeUnits: (_f = txBuildingProps.txParams) === null || _f === void 0 ? void 0 : _f.getCUPriceFromComputeUnits,
224
238
  },
225
239
  processParams: {
226
240
  connection: this.connection,
@@ -270,8 +284,7 @@ class TxHandler {
270
284
  * @returns
271
285
  */
272
286
  async buildBulkTransactions(props) {
273
- var _a;
274
- const recentBlockhash = (_a = props === null || props === void 0 ? void 0 : props.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.getLatestBlockhashForTransaction());
287
+ const recentBlockhash = await this.resolveRecentBlockhash(props === null || props === void 0 ? void 0 : props.recentBlockhash);
275
288
  return await Promise.all(props.instructions.map((ix) => {
276
289
  if (!ix)
277
290
  return undefined;
@@ -292,7 +305,6 @@ class TxHandler {
292
305
  * @returns
293
306
  */
294
307
  async buildTransaction(props) {
295
- var _a;
296
308
  const { txVersion, txParams, connection: _connection, preFlightCommitment: _preFlightCommitment, fetchAllMarketLookupTableAccounts, forceVersionedTransaction, instructions, } = props;
297
309
  let { lookupTables } = props;
298
310
  const marketLookupTables = await fetchAllMarketLookupTableAccounts();
@@ -339,7 +351,9 @@ class TxHandler {
339
351
  // # Create Tx Instructions
340
352
  const allIx = [];
341
353
  const computeUnits = baseTxParams === null || baseTxParams === void 0 ? void 0 : baseTxParams.computeUnits;
342
- if (computeUnits > 0 && !hasSetComputeUnitLimitIx) {
354
+ if (computeUnits !== undefined &&
355
+ computeUnits > 0 &&
356
+ !hasSetComputeUnitLimitIx) {
343
357
  allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
344
358
  units: computeUnits,
345
359
  }));
@@ -350,13 +364,15 @@ class TxHandler {
350
364
  microLamports: 0,
351
365
  }));
352
366
  }
353
- else if (computeUnitsPrice > 0 && !hasSetComputeUnitPriceIx) {
367
+ else if (computeUnitsPrice !== undefined &&
368
+ computeUnitsPrice > 0 &&
369
+ !hasSetComputeUnitPriceIx) {
354
370
  allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
355
371
  microLamports: computeUnitsPrice,
356
372
  }));
357
373
  }
358
374
  allIx.push(...instructionsToUse);
359
- const recentBlockhash = (_a = props === null || props === void 0 ? void 0 : props.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.getLatestBlockhashForTransaction());
375
+ const recentBlockhash = await this.resolveRecentBlockhash(props === null || props === void 0 ? void 0 : props.recentBlockhash);
360
376
  // # Create and return Transaction
361
377
  if (txVersion === 'legacy') {
362
378
  if (forceVersionedTransaction) {
@@ -399,17 +415,15 @@ class TxHandler {
399
415
  */
400
416
  async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
401
417
  var _a, _b;
402
- recentBlockhash = recentBlockhash
403
- ? recentBlockhash
404
- : await this.getLatestBlockhashForTransaction();
405
- this.addHashAndExpiryToLookup(recentBlockhash);
418
+ const resolvedBlockhash = await this.resolveRecentBlockhash(recentBlockhash);
419
+ this.addHashAndExpiryToLookup(resolvedBlockhash);
406
420
  for (const tx of Object.values(txsMap)) {
407
421
  if (!tx)
408
422
  continue;
409
- tx.recentBlockhash = recentBlockhash.blockhash;
423
+ tx.recentBlockhash = resolvedBlockhash.blockhash;
410
424
  tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
411
425
  // @ts-ignore
412
- tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
426
+ tx.SIGNATURE_BLOCK_AND_EXPIRY = resolvedBlockhash;
413
427
  }
414
428
  return this.getSignedTransactionMap(txsMap, wallet);
415
429
  }
@@ -429,7 +443,7 @@ class TxHandler {
429
443
  acc[key] = undefined;
430
444
  return acc;
431
445
  }, {});
432
- const filteredTxEntries = txsToSignEntries.filter(([_, tx]) => !!tx);
446
+ const filteredTxEntries = txsToSignEntries.filter((entry) => !!entry[1]);
433
447
  // Extra handling for legacy transactions
434
448
  for (const [_key, tx] of filteredTxEntries) {
435
449
  if (this.isLegacyTransaction(tx)) {
@@ -10,8 +10,11 @@ export declare class TransactionParamProcessor {
10
10
  private static getComputeUnitsFromSim;
11
11
  static getTxSimComputeUnits(tx: VersionedTransaction, connection: Connection, bufferMultiplier: number, // Making this a mandatory param to force the user to remember that simulated CU's can be inaccurate and a buffer should be applied
12
12
  lowerBoundCu?: number, simulatedTx?: SimulatedTransactionResponse): Promise<{
13
- success: boolean;
13
+ success: true;
14
14
  computeUnits: number;
15
+ } | {
16
+ success: false;
17
+ computeUnits: undefined;
15
18
  }>;
16
19
  static process(props: {
17
20
  baseTxParams: BaseTxParams;
@@ -32,6 +32,9 @@ class TransactionParamProcessor {
32
32
  throw (_b = simTxResult === null || simTxResult === void 0 ? void 0 : simTxResult.value) === null || _b === void 0 ? void 0 : _b.err;
33
33
  }
34
34
  const computeUnits = await this.getComputeUnitsFromSim(simTxResult);
35
+ if (computeUnits === undefined) {
36
+ throw new Error('TransactionParamProcessor: simulation did not return units consumed');
37
+ }
35
38
  // Apply the buffer, but round down to the MAX_COMPUTE_UNITS, and round up to the nearest whole number
36
39
  let bufferedComputeUnits = Math.ceil(Math.min(computeUnits * bufferMultiplier, MAX_COMPUTE_UNITS));
37
40
  // If a lower bound CU is passed then enforce it
@@ -81,6 +84,9 @@ class TransactionParamProcessor {
81
84
  throw new Error(`encountered useSimulatedComputeUnitsForFees=true, but getComputeUnitPriceFromUnitsToUse helper method is undefined`);
82
85
  }
83
86
  const simulatedComputeUnits = finalTxParams.computeUnits;
87
+ if (simulatedComputeUnits === undefined) {
88
+ throw new Error(`encountered useSimulatedComputeUnitsForFees=true, but simulated compute units are unavailable (simulation likely failed)`);
89
+ }
84
90
  const computeUnitPrice = processConfig.getCUPriceFromComputeUnits(simulatedComputeUnits);
85
91
  console.debug(`🔧:: Adjusting compute unit price for simulated compute unit budget :: ${finalTxParams.computeUnitsPrice}=>${computeUnitPrice}`);
86
92
  finalTxParams.computeUnitsPrice = computeUnitPrice;
@@ -9,7 +9,7 @@ export declare enum ConfirmationStrategy {
9
9
  }
10
10
  export type TxSigAndSlot = {
11
11
  txSig: TransactionSignature;
12
- slot: number;
12
+ slot: number | undefined;
13
13
  };
14
14
  export interface TxSender {
15
15
  wallet: IWallet;
@@ -9,12 +9,7 @@ type ResolveReference = {
9
9
  resolve?: () => void;
10
10
  };
11
11
  export declare class WhileValidTxSender extends BaseTxSender {
12
- connection: Connection;
13
- wallet: IWallet;
14
- opts: ConfirmOptions;
15
- timeout: number;
16
12
  retrySleep: number;
17
- additionalConnections: Connection[];
18
13
  timoutCount: number;
19
14
  untilValid: Map<string, {
20
15
  blockhash: string;
@@ -27,7 +22,7 @@ export declare class WhileValidTxSender extends BaseTxSender {
27
22
  wallet: IWallet;
28
23
  opts?: ConfirmOptions;
29
24
  retrySleep?: number;
30
- additionalConnections?: any;
25
+ additionalConnections?: Connection[];
31
26
  additionalTxSenderCallbacks?: ((base58EncodedTx: string) => void)[];
32
27
  confirmationStrategy?: ConfirmationStrategy;
33
28
  txHandler?: TxHandler;