@velocity-exchange/sdk 0.1.0 → 0.2.1

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 (761) hide show
  1. package/CHANGELOG.md +4 -32
  2. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
  3. package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
  4. package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  5. package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
  6. package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
  7. package/lib/browser/accounts/bulkAccountLoader.js +12 -1
  8. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
  9. package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
  10. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  11. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
  12. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  13. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  14. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  15. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
  16. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
  17. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
  18. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
  19. package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
  20. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
  21. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  22. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  23. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  24. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  25. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
  26. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  27. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
  28. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  29. package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
  30. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  31. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  32. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
  33. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
  34. package/lib/browser/accounts/types.d.ts +4 -4
  35. package/lib/browser/accounts/utils.d.ts +1 -0
  36. package/lib/browser/accounts/utils.js +8 -1
  37. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
  38. package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
  39. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  40. package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
  41. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  42. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  43. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  44. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
  45. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  46. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  47. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  48. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  49. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  50. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
  51. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  52. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  53. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
  54. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
  55. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
  56. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
  57. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  58. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  59. package/lib/browser/addresses/marketAddresses.js +3 -2
  60. package/lib/browser/addresses/pda.d.ts +0 -2
  61. package/lib/browser/addresses/pda.js +1 -14
  62. package/lib/browser/adminClient.d.ts +24 -29
  63. package/lib/browser/adminClient.js +156 -157
  64. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
  65. package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
  66. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
  67. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  68. package/lib/browser/bankrun/bankrunConnection.d.ts +8 -5
  69. package/lib/browser/bankrun/bankrunConnection.js +92 -32
  70. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  71. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  72. package/lib/browser/clock/clockSubscriber.d.ts +6 -6
  73. package/lib/browser/clock/clockSubscriber.js +4 -3
  74. package/lib/browser/config.d.ts +1 -1
  75. package/lib/browser/config.js +8 -4
  76. package/lib/browser/constants/index.d.ts +1 -2
  77. package/lib/browser/constants/index.js +1 -2
  78. package/lib/browser/constants/numericConstants.d.ts +1 -2
  79. package/lib/browser/constants/numericConstants.js +7 -5
  80. package/lib/browser/constants/spotMarkets.d.ts +0 -1
  81. package/lib/browser/constituentMap/constituentMap.js +5 -1
  82. package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  83. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  84. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  85. package/lib/browser/core/VelocityCore.d.ts +0 -1
  86. package/lib/browser/core/instructions/deposit.d.ts +0 -1
  87. package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
  88. package/lib/browser/core/instructions/perpOrders.js +14 -0
  89. package/lib/browser/core/instructions/withdraw.d.ts +0 -1
  90. package/lib/browser/core/remainingAccounts.d.ts +2 -2
  91. package/lib/browser/core/remainingAccounts.js +2 -2
  92. package/lib/browser/decode/user.js +9 -1
  93. package/lib/browser/dlob/DLOB.d.ts +6 -2
  94. package/lib/browser/dlob/DLOB.js +201 -138
  95. package/lib/browser/dlob/DLOBNode.d.ts +5 -3
  96. package/lib/browser/dlob/DLOBNode.js +7 -0
  97. package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
  98. package/lib/browser/dlob/DLOBSubscriber.js +37 -32
  99. package/lib/browser/dlob/NodeList.d.ts +0 -1
  100. package/lib/browser/dlob/NodeList.js +8 -7
  101. package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
  102. package/lib/browser/dlob/orderBookLevels.js +19 -12
  103. package/lib/browser/events/eventList.d.ts +3 -3
  104. package/lib/browser/events/eventList.js +4 -1
  105. package/lib/browser/events/eventSubscriber.d.ts +5 -2
  106. package/lib/browser/events/eventSubscriber.js +75 -26
  107. package/lib/browser/events/eventsServerLogProvider.d.ts +2 -2
  108. package/lib/browser/events/eventsServerLogProvider.js +15 -8
  109. package/lib/browser/events/fetchLogs.d.ts +1 -1
  110. package/lib/browser/events/fetchLogs.js +4 -2
  111. package/lib/browser/events/pollingLogProvider.d.ts +2 -2
  112. package/lib/browser/events/pollingLogProvider.js +1 -0
  113. package/lib/browser/events/txEventCache.d.ts +3 -3
  114. package/lib/browser/events/txEventCache.js +6 -2
  115. package/lib/browser/events/types.d.ts +2 -4
  116. package/lib/browser/events/types.js +0 -2
  117. package/lib/browser/events/webSocketLogProvider.d.ts +2 -2
  118. package/lib/browser/events/webSocketLogProvider.js +5 -2
  119. package/lib/browser/factory/bigNum.d.ts +0 -1
  120. package/lib/browser/factory/bigNum.js +1 -1
  121. package/lib/browser/idl/velocity.d.ts +1243 -1586
  122. package/lib/browser/idl/velocity.json +1234 -1577
  123. package/lib/browser/index.d.ts +0 -2
  124. package/lib/browser/index.js +0 -2
  125. package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
  126. package/lib/browser/jupiter/jupiterClient.d.ts +1 -2
  127. package/lib/browser/jupiter/jupiterClient.js +18 -8
  128. package/lib/browser/marginCalculation.d.ts +0 -1
  129. package/lib/browser/marginCalculation.js +1 -0
  130. package/lib/browser/marinade/index.d.ts +2 -3
  131. package/lib/browser/marinade/index.js +5 -0
  132. package/lib/browser/math/amm.d.ts +31 -14
  133. package/lib/browser/math/amm.js +77 -22
  134. package/lib/browser/math/auction.d.ts +0 -1
  135. package/lib/browser/math/bankruptcy.js +1 -1
  136. package/lib/browser/math/conversion.d.ts +0 -1
  137. package/lib/browser/math/funding.d.ts +0 -1
  138. package/lib/browser/math/funding.js +6 -6
  139. package/lib/browser/math/insurance.d.ts +1 -2
  140. package/lib/browser/math/insurance.js +4 -5
  141. package/lib/browser/math/liquidation.d.ts +0 -1
  142. package/lib/browser/math/margin.d.ts +1 -10
  143. package/lib/browser/math/margin.js +3 -62
  144. package/lib/browser/math/market.d.ts +4 -13
  145. package/lib/browser/math/market.js +6 -40
  146. package/lib/browser/math/oracles.d.ts +0 -4
  147. package/lib/browser/math/oracles.js +1 -14
  148. package/lib/browser/math/orders.d.ts +0 -6
  149. package/lib/browser/math/orders.js +2 -74
  150. package/lib/browser/math/position.d.ts +1 -6
  151. package/lib/browser/math/position.js +5 -10
  152. package/lib/browser/math/repeg.d.ts +0 -2
  153. package/lib/browser/math/repeg.js +1 -23
  154. package/lib/browser/math/spotBalance.d.ts +4 -5
  155. package/lib/browser/math/spotBalance.js +6 -6
  156. package/lib/browser/math/spotMarket.d.ts +0 -7
  157. package/lib/browser/math/spotMarket.js +1 -16
  158. package/lib/browser/math/spotPosition.d.ts +4 -5
  159. package/lib/browser/math/state.d.ts +0 -3
  160. package/lib/browser/math/state.js +1 -9
  161. package/lib/browser/math/superStake.d.ts +3 -54
  162. package/lib/browser/math/superStake.js +16 -13
  163. package/lib/browser/math/trade.d.ts +2 -3
  164. package/lib/browser/math/trade.js +6 -6
  165. package/lib/browser/math/utils.d.ts +0 -1
  166. package/lib/browser/memcmp.d.ts +0 -1
  167. package/lib/browser/memcmp.js +1 -10
  168. package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
  169. package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
  170. package/lib/browser/oracles/pythClient.d.ts +0 -1
  171. package/lib/browser/oracles/pythClient.js +9 -3
  172. package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
  173. package/lib/browser/oracles/pythLazerClient.js +3 -2
  174. package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
  175. package/lib/browser/oracles/types.d.ts +0 -1
  176. package/lib/browser/oracles/utils.d.ts +4 -1
  177. package/lib/browser/oracles/utils.js +9 -1
  178. package/lib/browser/orderParams.d.ts +0 -1
  179. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
  180. package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
  181. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  182. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
  183. package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
  184. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  185. package/lib/browser/pyth/types.d.ts +0 -1
  186. package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
  187. package/lib/browser/slot/SlotSubscriber.js +2 -1
  188. package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
  189. package/lib/browser/slot/SlothashSubscriber.js +11 -4
  190. package/lib/browser/swap/UnifiedSwapClient.d.ts +0 -1
  191. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  192. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  193. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
  194. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
  195. package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
  196. package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
  197. package/lib/browser/testClient.js +3 -2
  198. package/lib/browser/titan/titanClient.d.ts +0 -1
  199. package/lib/browser/tokenFaucet.d.ts +0 -1
  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 +9 -3
  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 +25 -69
  217. package/lib/browser/types.js +2 -2
  218. package/lib/browser/user.d.ts +21 -8
  219. package/lib/browser/user.js +156 -132
  220. package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
  221. package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
  222. package/lib/browser/userMap/referrerMap.js +10 -3
  223. package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
  224. package/lib/browser/userMap/userMap.d.ts +1 -1
  225. package/lib/browser/userMap/userMap.js +36 -23
  226. package/lib/browser/userMap/userStatsMap.d.ts +1 -1
  227. package/lib/browser/userMap/userStatsMap.js +18 -13
  228. package/lib/browser/userStats.d.ts +7 -2
  229. package/lib/browser/userStats.js +18 -4
  230. package/lib/browser/util/TransactionConfirmationManager.js +4 -2
  231. package/lib/browser/util/chainClock.d.ts +1 -1
  232. package/lib/browser/util/computeUnits.d.ts +1 -1
  233. package/lib/browser/util/computeUnits.js +6 -1
  234. package/lib/browser/velocityClient.d.ts +93 -36
  235. package/lib/browser/velocityClient.js +414 -280
  236. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
  237. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
  238. package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
  239. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  240. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
  241. package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
  242. package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
  243. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
  244. package/lib/node/accounts/bulkAccountLoader.js +12 -1
  245. package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
  246. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  247. package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
  248. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  249. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  250. package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
  251. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  252. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  253. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  254. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  255. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  256. package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
  257. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  258. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
  259. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
  260. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  261. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
  262. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  263. package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
  264. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  265. package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
  266. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  267. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  268. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  269. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  270. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  271. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  272. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  273. package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
  274. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  275. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  276. package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
  277. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  278. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
  279. package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
  280. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  281. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  282. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  283. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
  284. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  285. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
  286. package/lib/node/accounts/types.d.ts +4 -4
  287. package/lib/node/accounts/types.d.ts.map +1 -1
  288. package/lib/node/accounts/utils.d.ts +1 -0
  289. package/lib/node/accounts/utils.d.ts.map +1 -1
  290. package/lib/node/accounts/utils.js +8 -1
  291. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
  292. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  293. package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
  294. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  295. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  296. package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
  297. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  298. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  299. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  300. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  301. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  302. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
  303. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  304. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  305. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  306. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  307. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  308. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  309. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  310. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  311. package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
  312. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  313. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  314. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  315. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
  316. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  317. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
  318. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
  319. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  320. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
  321. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  322. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  323. package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  324. package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
  325. package/lib/node/addresses/marketAddresses.js +3 -2
  326. package/lib/node/addresses/pda.d.ts +0 -2
  327. package/lib/node/addresses/pda.d.ts.map +1 -1
  328. package/lib/node/addresses/pda.js +1 -14
  329. package/lib/node/adminClient.d.ts +24 -29
  330. package/lib/node/adminClient.d.ts.map +1 -1
  331. package/lib/node/adminClient.js +156 -157
  332. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
  333. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  334. package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
  335. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
  336. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  337. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  338. package/lib/node/bankrun/bankrunConnection.d.ts +8 -5
  339. package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
  340. package/lib/node/bankrun/bankrunConnection.js +92 -32
  341. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  342. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
  343. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  344. package/lib/node/clock/clockSubscriber.d.ts +6 -6
  345. package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
  346. package/lib/node/clock/clockSubscriber.js +4 -3
  347. package/lib/node/config.d.ts +1 -1
  348. package/lib/node/config.d.ts.map +1 -1
  349. package/lib/node/config.js +8 -4
  350. package/lib/node/constants/index.d.ts +1 -2
  351. package/lib/node/constants/index.d.ts.map +1 -1
  352. package/lib/node/constants/index.js +1 -2
  353. package/lib/node/constants/numericConstants.d.ts +1 -2
  354. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  355. package/lib/node/constants/numericConstants.js +7 -5
  356. package/lib/node/constants/spotMarkets.d.ts +0 -1
  357. package/lib/node/constants/spotMarkets.d.ts.map +1 -1
  358. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  359. package/lib/node/constituentMap/constituentMap.js +5 -1
  360. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
  361. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  362. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  363. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
  364. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  365. package/lib/node/core/VelocityCore.d.ts +0 -1
  366. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  367. package/lib/node/core/instructions/deposit.d.ts +0 -1
  368. package/lib/node/core/instructions/deposit.d.ts.map +1 -1
  369. package/lib/node/core/instructions/perpOrders.d.ts +14 -0
  370. package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
  371. package/lib/node/core/instructions/perpOrders.js +14 -0
  372. package/lib/node/core/instructions/withdraw.d.ts +0 -1
  373. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  374. package/lib/node/core/remainingAccounts.d.ts +2 -2
  375. package/lib/node/core/remainingAccounts.d.ts.map +1 -1
  376. package/lib/node/core/remainingAccounts.js +2 -2
  377. package/lib/node/decode/user.d.ts.map +1 -1
  378. package/lib/node/decode/user.js +9 -1
  379. package/lib/node/dlob/DLOB.d.ts +6 -2
  380. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  381. package/lib/node/dlob/DLOB.js +201 -138
  382. package/lib/node/dlob/DLOBNode.d.ts +5 -3
  383. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  384. package/lib/node/dlob/DLOBNode.js +7 -0
  385. package/lib/node/dlob/DLOBSubscriber.d.ts +0 -1
  386. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  387. package/lib/node/dlob/DLOBSubscriber.js +37 -32
  388. package/lib/node/dlob/NodeList.d.ts +0 -1
  389. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  390. package/lib/node/dlob/NodeList.js +8 -7
  391. package/lib/node/dlob/orderBookLevels.d.ts +0 -1
  392. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  393. package/lib/node/dlob/orderBookLevels.js +19 -12
  394. package/lib/node/events/eventList.d.ts +3 -3
  395. package/lib/node/events/eventList.d.ts.map +1 -1
  396. package/lib/node/events/eventList.js +4 -1
  397. package/lib/node/events/eventSubscriber.d.ts +5 -2
  398. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  399. package/lib/node/events/eventSubscriber.js +75 -26
  400. package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
  401. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
  402. package/lib/node/events/eventsServerLogProvider.js +15 -8
  403. package/lib/node/events/fetchLogs.d.ts +1 -1
  404. package/lib/node/events/fetchLogs.d.ts.map +1 -1
  405. package/lib/node/events/fetchLogs.js +4 -2
  406. package/lib/node/events/pollingLogProvider.d.ts +2 -2
  407. package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
  408. package/lib/node/events/pollingLogProvider.js +1 -0
  409. package/lib/node/events/txEventCache.d.ts +3 -3
  410. package/lib/node/events/txEventCache.d.ts.map +1 -1
  411. package/lib/node/events/txEventCache.js +6 -2
  412. package/lib/node/events/types.d.ts +2 -4
  413. package/lib/node/events/types.d.ts.map +1 -1
  414. package/lib/node/events/types.js +0 -2
  415. package/lib/node/events/webSocketLogProvider.d.ts +2 -2
  416. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
  417. package/lib/node/events/webSocketLogProvider.js +5 -2
  418. package/lib/node/factory/bigNum.d.ts +0 -1
  419. package/lib/node/factory/bigNum.d.ts.map +1 -1
  420. package/lib/node/factory/bigNum.js +1 -1
  421. package/lib/node/idl/velocity.d.ts +1243 -1586
  422. package/lib/node/idl/velocity.d.ts.map +1 -1
  423. package/lib/node/idl/velocity.json +1234 -1577
  424. package/lib/node/index.d.ts +0 -2
  425. package/lib/node/index.d.ts.map +1 -1
  426. package/lib/node/index.js +0 -2
  427. package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
  428. package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
  429. package/lib/node/jupiter/jupiterClient.d.ts +1 -2
  430. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
  431. package/lib/node/jupiter/jupiterClient.js +18 -8
  432. package/lib/node/marginCalculation.d.ts +0 -1
  433. package/lib/node/marginCalculation.d.ts.map +1 -1
  434. package/lib/node/marginCalculation.js +1 -0
  435. package/lib/node/marinade/index.d.ts +2 -3
  436. package/lib/node/marinade/index.d.ts.map +1 -1
  437. package/lib/node/marinade/index.js +5 -0
  438. package/lib/node/math/amm.d.ts +31 -14
  439. package/lib/node/math/amm.d.ts.map +1 -1
  440. package/lib/node/math/amm.js +77 -22
  441. package/lib/node/math/auction.d.ts +0 -1
  442. package/lib/node/math/auction.d.ts.map +1 -1
  443. package/lib/node/math/bankruptcy.js +1 -1
  444. package/lib/node/math/conversion.d.ts +0 -1
  445. package/lib/node/math/conversion.d.ts.map +1 -1
  446. package/lib/node/math/funding.d.ts +0 -1
  447. package/lib/node/math/funding.d.ts.map +1 -1
  448. package/lib/node/math/funding.js +6 -6
  449. package/lib/node/math/insurance.d.ts +1 -2
  450. package/lib/node/math/insurance.d.ts.map +1 -1
  451. package/lib/node/math/insurance.js +4 -5
  452. package/lib/node/math/liquidation.d.ts +0 -1
  453. package/lib/node/math/liquidation.d.ts.map +1 -1
  454. package/lib/node/math/margin.d.ts +1 -10
  455. package/lib/node/math/margin.d.ts.map +1 -1
  456. package/lib/node/math/margin.js +3 -62
  457. package/lib/node/math/market.d.ts +4 -13
  458. package/lib/node/math/market.d.ts.map +1 -1
  459. package/lib/node/math/market.js +6 -40
  460. package/lib/node/math/oracles.d.ts +0 -4
  461. package/lib/node/math/oracles.d.ts.map +1 -1
  462. package/lib/node/math/oracles.js +1 -14
  463. package/lib/node/math/orders.d.ts +0 -6
  464. package/lib/node/math/orders.d.ts.map +1 -1
  465. package/lib/node/math/orders.js +2 -74
  466. package/lib/node/math/position.d.ts +1 -6
  467. package/lib/node/math/position.d.ts.map +1 -1
  468. package/lib/node/math/position.js +5 -10
  469. package/lib/node/math/repeg.d.ts +0 -2
  470. package/lib/node/math/repeg.d.ts.map +1 -1
  471. package/lib/node/math/repeg.js +1 -23
  472. package/lib/node/math/spotBalance.d.ts +4 -5
  473. package/lib/node/math/spotBalance.d.ts.map +1 -1
  474. package/lib/node/math/spotBalance.js +6 -6
  475. package/lib/node/math/spotMarket.d.ts +0 -7
  476. package/lib/node/math/spotMarket.d.ts.map +1 -1
  477. package/lib/node/math/spotMarket.js +1 -16
  478. package/lib/node/math/spotPosition.d.ts +4 -5
  479. package/lib/node/math/spotPosition.d.ts.map +1 -1
  480. package/lib/node/math/state.d.ts +0 -3
  481. package/lib/node/math/state.d.ts.map +1 -1
  482. package/lib/node/math/state.js +1 -9
  483. package/lib/node/math/superStake.d.ts +3 -54
  484. package/lib/node/math/superStake.d.ts.map +1 -1
  485. package/lib/node/math/superStake.js +16 -13
  486. package/lib/node/math/trade.d.ts +2 -3
  487. package/lib/node/math/trade.d.ts.map +1 -1
  488. package/lib/node/math/trade.js +6 -6
  489. package/lib/node/math/utils.d.ts +0 -1
  490. package/lib/node/math/utils.d.ts.map +1 -1
  491. package/lib/node/memcmp.d.ts +0 -1
  492. package/lib/node/memcmp.d.ts.map +1 -1
  493. package/lib/node/memcmp.js +1 -10
  494. package/lib/node/oracles/oracleClientCache.d.ts +1 -1
  495. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  496. package/lib/node/oracles/prelaunchOracleClient.js +3 -2
  497. package/lib/node/oracles/pythClient.d.ts +0 -1
  498. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  499. package/lib/node/oracles/pythClient.js +9 -3
  500. package/lib/node/oracles/pythLazerClient.d.ts +0 -1
  501. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  502. package/lib/node/oracles/pythLazerClient.js +3 -2
  503. package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
  504. package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
  505. package/lib/node/oracles/types.d.ts +0 -1
  506. package/lib/node/oracles/types.d.ts.map +1 -1
  507. package/lib/node/oracles/utils.d.ts +4 -1
  508. package/lib/node/oracles/utils.d.ts.map +1 -1
  509. package/lib/node/oracles/utils.js +9 -1
  510. package/lib/node/orderParams.d.ts +0 -1
  511. package/lib/node/orderParams.d.ts.map +1 -1
  512. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
  513. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  514. package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
  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 +1 -1
  518. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  519. package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
  520. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  521. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
  522. package/lib/node/pyth/types.d.ts +0 -1
  523. package/lib/node/pyth/types.d.ts.map +1 -1
  524. package/lib/node/slot/SlotSubscriber.d.ts +1 -1
  525. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
  526. package/lib/node/slot/SlotSubscriber.js +2 -1
  527. package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
  528. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
  529. package/lib/node/slot/SlothashSubscriber.js +11 -4
  530. package/lib/node/swap/UnifiedSwapClient.d.ts +0 -1
  531. package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
  532. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  533. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
  534. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  535. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
  536. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  537. package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
  538. package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
  539. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  540. package/lib/node/swift/swiftOrderSubscriber.js +10 -5
  541. package/lib/node/testClient.js +3 -2
  542. package/lib/node/titan/titanClient.d.ts +0 -1
  543. package/lib/node/titan/titanClient.d.ts.map +1 -1
  544. package/lib/node/tokenFaucet.d.ts +0 -1
  545. package/lib/node/tokenFaucet.d.ts.map +1 -1
  546. package/lib/node/tokenFaucet.js +16 -2
  547. package/lib/node/tx/baseTxSender.d.ts +4 -4
  548. package/lib/node/tx/baseTxSender.d.ts.map +1 -1
  549. package/lib/node/tx/baseTxSender.js +5 -4
  550. package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
  551. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
  552. package/lib/node/tx/fastSingleTxSender.js +9 -5
  553. package/lib/node/tx/reportTransactionError.d.ts +2 -2
  554. package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
  555. package/lib/node/tx/reportTransactionError.js +5 -1
  556. package/lib/node/tx/retryTxSender.d.ts +1 -1
  557. package/lib/node/tx/retryTxSender.d.ts.map +1 -1
  558. package/lib/node/tx/retryTxSender.js +4 -2
  559. package/lib/node/tx/txHandler.d.ts +9 -3
  560. package/lib/node/tx/txHandler.d.ts.map +1 -1
  561. package/lib/node/tx/txHandler.js +54 -40
  562. package/lib/node/tx/txParamProcessor.d.ts +4 -1
  563. package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
  564. package/lib/node/tx/txParamProcessor.js +6 -0
  565. package/lib/node/tx/types.d.ts +1 -1
  566. package/lib/node/tx/types.d.ts.map +1 -1
  567. package/lib/node/tx/whileValidTxSender.d.ts +1 -6
  568. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
  569. package/lib/node/tx/whileValidTxSender.js +35 -13
  570. package/lib/node/types.d.ts +25 -69
  571. package/lib/node/types.d.ts.map +1 -1
  572. package/lib/node/types.js +2 -2
  573. package/lib/node/user.d.ts +21 -8
  574. package/lib/node/user.d.ts.map +1 -1
  575. package/lib/node/user.js +156 -132
  576. package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
  577. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
  578. package/lib/node/userMap/grpcSubscription.d.ts +1 -1
  579. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
  580. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  581. package/lib/node/userMap/referrerMap.js +10 -3
  582. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  583. package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
  584. package/lib/node/userMap/userMap.d.ts +1 -1
  585. package/lib/node/userMap/userMap.d.ts.map +1 -1
  586. package/lib/node/userMap/userMap.js +36 -23
  587. package/lib/node/userMap/userStatsMap.d.ts +1 -1
  588. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  589. package/lib/node/userMap/userStatsMap.js +18 -13
  590. package/lib/node/userStats.d.ts +7 -2
  591. package/lib/node/userStats.d.ts.map +1 -1
  592. package/lib/node/userStats.js +18 -4
  593. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
  594. package/lib/node/util/TransactionConfirmationManager.js +4 -2
  595. package/lib/node/util/chainClock.d.ts +1 -1
  596. package/lib/node/util/chainClock.d.ts.map +1 -1
  597. package/lib/node/util/computeUnits.d.ts +1 -1
  598. package/lib/node/util/computeUnits.d.ts.map +1 -1
  599. package/lib/node/util/computeUnits.js +6 -1
  600. package/lib/node/velocityClient.d.ts +93 -36
  601. package/lib/node/velocityClient.d.ts.map +1 -1
  602. package/lib/node/velocityClient.js +414 -280
  603. package/package.json +15 -8
  604. package/src/accounts/basicUserAccountSubscriber.ts +7 -5
  605. package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
  606. package/src/accounts/bulkAccountLoader.ts +20 -7
  607. package/src/accounts/grpcAccountSubscriber.ts +11 -3
  608. package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
  609. package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
  610. package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
  611. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
  612. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
  613. package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
  614. package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
  615. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
  616. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
  617. package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
  618. package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
  619. package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
  620. package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
  621. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
  622. package/src/accounts/types.ts +6 -4
  623. package/src/accounts/utils.ts +10 -0
  624. package/src/accounts/webSocketAccountSubscriber.ts +23 -10
  625. package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
  626. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
  627. package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
  628. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
  629. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
  630. package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
  631. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
  632. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
  633. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
  634. package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
  635. package/src/addresses/marketAddresses.ts +3 -2
  636. package/src/addresses/pda.ts +0 -25
  637. package/src/adminClient.ts +273 -303
  638. package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
  639. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
  640. package/src/bankrun/bankrunConnection.ts +110 -40
  641. package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
  642. package/src/clock/clockSubscriber.ts +10 -9
  643. package/src/config.ts +8 -3
  644. package/src/constants/index.ts +1 -2
  645. package/src/constants/numericConstants.ts +8 -4
  646. package/src/constituentMap/constituentMap.ts +8 -1
  647. package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
  648. package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
  649. package/src/core/instructions/perpOrders.ts +14 -0
  650. package/src/core/remainingAccounts.ts +4 -4
  651. package/src/decode/user.ts +8 -1
  652. package/src/dlob/DLOB.ts +296 -172
  653. package/src/dlob/DLOBNode.ts +23 -3
  654. package/src/dlob/DLOBSubscriber.ts +51 -34
  655. package/src/dlob/NodeList.ts +8 -7
  656. package/src/dlob/orderBookLevels.ts +45 -25
  657. package/src/events/eventList.ts +4 -1
  658. package/src/events/eventSubscriber.ts +107 -49
  659. package/src/events/eventsServerLogProvider.ts +22 -13
  660. package/src/events/fetchLogs.ts +3 -3
  661. package/src/events/pollingLogProvider.ts +2 -2
  662. package/src/events/txEventCache.ts +8 -2
  663. package/src/events/types.ts +0 -8
  664. package/src/events/webSocketLogProvider.ts +5 -3
  665. package/src/factory/bigNum.ts +2 -2
  666. package/src/idl/velocity.json +1234 -1577
  667. package/src/idl/velocity.ts +1234 -1577
  668. package/src/index.ts +0 -2
  669. package/src/jupiter/jupiterClient.ts +30 -10
  670. package/src/marginCalculation.ts +1 -0
  671. package/src/marinade/index.ts +11 -2
  672. package/src/math/amm.ts +188 -33
  673. package/src/math/bankruptcy.ts +1 -1
  674. package/src/math/funding.ts +7 -6
  675. package/src/math/insurance.ts +6 -8
  676. package/src/math/margin.ts +5 -112
  677. package/src/math/market.ts +6 -96
  678. package/src/math/oracles.ts +0 -17
  679. package/src/math/orders.ts +1 -110
  680. package/src/math/position.ts +4 -16
  681. package/src/math/repeg.ts +0 -29
  682. package/src/math/spotBalance.ts +14 -10
  683. package/src/math/spotMarket.ts +2 -28
  684. package/src/math/spotPosition.ts +4 -4
  685. package/src/math/state.ts +0 -8
  686. package/src/math/superStake.ts +19 -65
  687. package/src/math/trade.ts +2 -6
  688. package/src/memcmp.ts +0 -9
  689. package/src/oracles/prelaunchOracleClient.ts +7 -2
  690. package/src/oracles/pythClient.ts +12 -3
  691. package/src/oracles/pythLazerClient.ts +7 -2
  692. package/src/oracles/utils.ts +15 -0
  693. package/src/orderSubscriber/OrderSubscriber.ts +10 -4
  694. package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
  695. package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
  696. package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
  697. package/src/pyth/types.ts +0 -2
  698. package/src/slot/SlotSubscriber.ts +3 -3
  699. package/src/slot/SlothashSubscriber.ts +17 -6
  700. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
  701. package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
  702. package/src/swift/swiftOrderSubscriber.ts +10 -9
  703. package/src/testClient.ts +2 -2
  704. package/src/tokenFaucet.ts +22 -3
  705. package/src/tx/baseTxSender.ts +10 -10
  706. package/src/tx/fastSingleTxSender.ts +12 -8
  707. package/src/tx/reportTransactionError.ts +12 -7
  708. package/src/tx/retryTxSender.ts +6 -4
  709. package/src/tx/txHandler.ts +88 -43
  710. package/src/tx/txParamProcessor.ts +18 -3
  711. package/src/tx/types.ts +1 -1
  712. package/src/tx/whileValidTxSender.ts +51 -22
  713. package/src/types.ts +39 -75
  714. package/src/user.ts +200 -152
  715. package/src/userMap/WebsocketSubscription.ts +1 -1
  716. package/src/userMap/grpcSubscription.ts +1 -1
  717. package/src/userMap/referrerMap.ts +14 -10
  718. package/src/userMap/revenueShareEscrowMap.ts +8 -3
  719. package/src/userMap/userMap.ts +43 -25
  720. package/src/userMap/userStatsMap.ts +32 -19
  721. package/src/userStats.ts +21 -8
  722. package/src/util/TransactionConfirmationManager.ts +10 -2
  723. package/src/util/chainClock.ts +1 -1
  724. package/src/util/computeUnits.ts +7 -3
  725. package/src/velocityClient.ts +536 -383
  726. package/tests/VelocityCore/remainingAccounts.test.ts +4 -5
  727. package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
  728. package/tests/amm/test.ts +300 -95
  729. package/tests/decode/userAccountBufferStrings.ts +100 -100
  730. package/tests/dlob/helpers.ts +162 -173
  731. package/tests/dlob/test.ts +155 -106
  732. package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
  733. package/tests/user/getMarginCalculation.ts +1 -1
  734. package/tests/user/helpers.ts +3 -4
  735. package/tests/user/marginCalculations.test.ts +2 -2
  736. package/tests/user/test.ts +3 -3
  737. package/tsconfig.browser.json +3 -1
  738. package/tsconfig.json +21 -2
  739. package/.yarn/install-state.gz +0 -0
  740. package/VERSION +0 -1
  741. package/bun.lock +0 -1885
  742. package/lib/browser/constants/insuranceFund.d.ts +0 -5
  743. package/lib/browser/constants/insuranceFund.js +0 -9
  744. package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
  745. package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
  746. package/lib/browser/util/tps.d.ts +0 -2
  747. package/lib/browser/util/tps.js +0 -16
  748. package/lib/node/constants/insuranceFund.d.ts +0 -6
  749. package/lib/node/constants/insuranceFund.d.ts.map +0 -1
  750. package/lib/node/constants/insuranceFund.js +0 -9
  751. package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
  752. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
  753. package/lib/node/tx/forwardOnlyTxSender.js +0 -92
  754. package/lib/node/util/tps.d.ts +0 -3
  755. package/lib/node/util/tps.d.ts.map +0 -1
  756. package/lib/node/util/tps.js +0 -16
  757. package/scripts/updateVersion.js +0 -28
  758. package/src/constants/insuranceFund.ts +0 -8
  759. package/src/tx/forwardOnlyTxSender.ts +0 -145
  760. package/src/util/tps.ts +0 -27
  761. package/tests/decode/phoenix.ts +0 -71
@@ -86,7 +86,11 @@ class AdminClient extends velocityClient_1.VelocityClient {
86
86
  const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
87
87
  const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
88
88
  const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
89
- const tokenProgram = (await this.connection.getAccountInfo(mint)).owner;
89
+ const mintAccountInfo = await this.connection.getAccountInfo(mint);
90
+ if (!mintAccountInfo) {
91
+ throw new Error(`Mint account ${mint.toString()} not found`);
92
+ }
93
+ const tokenProgram = mintAccountInfo.owner;
90
94
  const nameBuffer = (0, userName_1.encodeName)(name);
91
95
  const initializeIx = await this.program.instruction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, nameBuffer, {
92
96
  accounts: {
@@ -196,13 +200,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
196
200
  return txSig;
197
201
  }
198
202
  async getAddMarketToAmmCacheIx(perpMarketIndex) {
203
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
199
204
  return await this.program.instruction.addMarketToAmmCache({
200
205
  accounts: {
201
206
  state: await this.getStatePublicKey(),
202
207
  admin: this.useHotWalletAdmin
203
208
  ? this.wallet.publicKey
204
209
  : this.getStateAccount().coldAdmin,
205
- perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
210
+ perpMarket: perpMarketAccount.pubkey,
206
211
  ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
207
212
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
208
213
  systemProgram: anchor.web3.SystemProgram.programId,
@@ -337,6 +342,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
337
342
  return txSig;
338
343
  }
339
344
  async getUpdateKIx(perpMarketIndex, sqrtK) {
345
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
340
346
  return await this.program.instruction.updateK(sqrtK, {
341
347
  accounts: {
342
348
  state: await this.getStatePublicKey(),
@@ -344,7 +350,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
344
350
  ? this.getStateAccount().coldAdmin
345
351
  : this.wallet.publicKey,
346
352
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
347
- oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
353
+ oracle: perpMarketAccount.oracle,
348
354
  },
349
355
  });
350
356
  }
@@ -373,6 +379,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
373
379
  return txSig;
374
380
  }
375
381
  async getRecenterPerpMarketAmmCrankIx(perpMarketIndex, depth) {
382
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
376
383
  return await this.program.instruction.recenterPerpMarketAmmCrank(depth !== null && depth !== void 0 ? depth : null, {
377
384
  accounts: {
378
385
  admin: this.useHotWalletAdmin
@@ -381,7 +388,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
381
388
  state: await this.getStatePublicKey(),
382
389
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
383
390
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
384
- oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
391
+ oracle: perpMarketAccount.oracle,
385
392
  },
386
393
  });
387
394
  }
@@ -444,7 +451,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
444
451
  return txSig;
445
452
  }
446
453
  async getMoveAmmToPriceIx(perpMarketIndex, targetPrice) {
447
- const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
454
+ const perpMarket = this.getPerpMarketAccountOrThrow(perpMarketIndex);
448
455
  const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
449
456
  );
450
457
  const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
@@ -467,7 +474,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
467
474
  }
468
475
  async getRepegAmmCurveIx(newPeg, perpMarketIndex) {
469
476
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
470
- const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
477
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
471
478
  return await this.program.instruction.repegAmmCurve(newPeg, {
472
479
  accounts: {
473
480
  state: await this.getStatePublicKey(),
@@ -486,7 +493,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
486
493
  return txSig;
487
494
  }
488
495
  async getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex) {
489
- const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
496
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
490
497
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
491
498
  return await this.program.instruction.updatePerpMarketAmmOracleTwap({
492
499
  accounts: {
@@ -506,7 +513,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
506
513
  return txSig;
507
514
  }
508
515
  async getResetPerpMarketAmmOracleTwapIx(perpMarketIndex) {
509
- const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
516
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
510
517
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
511
518
  return await this.program.instruction.resetPerpMarketAmmOracleTwap({
512
519
  accounts: {
@@ -576,7 +583,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
576
583
  return txSig;
577
584
  }
578
585
  async getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault) {
579
- const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
586
+ const spotMarket = this.getSpotMarketAccountOrThrow(spotMarketIndex);
580
587
  const remainingAccounts = [];
581
588
  this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
582
589
  if (this.isTransferHook(spotMarket)) {
@@ -653,17 +660,17 @@ class AdminClient extends velocityClient_1.VelocityClient {
653
660
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
654
661
  return txSig;
655
662
  }
656
- async updatePerpMarketAmmSummaryStats(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl, excludeTotalLiqFee) {
657
- const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl, excludeTotalLiqFee);
663
+ async updatePerpMarketAmmSummaryStats(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl) {
664
+ const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl);
658
665
  const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
659
666
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
660
667
  return txSig;
661
668
  }
662
- async getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl, excludeTotalLiqFee) {
669
+ async getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl) {
670
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
663
671
  return await this.program.instruction.updatePerpMarketAmmSummaryStats({
664
672
  updateAmmSummaryStats: updateAmmSummaryStats !== null && updateAmmSummaryStats !== void 0 ? updateAmmSummaryStats : null,
665
673
  netUnsettledFundingPnl: netUnsettledFundingPnl !== null && netUnsettledFundingPnl !== void 0 ? netUnsettledFundingPnl : null,
666
- excludeTotalLiqFee: excludeTotalLiqFee !== null && excludeTotalLiqFee !== void 0 ? excludeTotalLiqFee : null,
667
674
  }, {
668
675
  accounts: {
669
676
  admin: this.useHotWalletAdmin
@@ -672,7 +679,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
672
679
  state: await this.getStatePublicKey(),
673
680
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
674
681
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
675
- oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
682
+ oracle: perpMarketAccount.oracle,
676
683
  },
677
684
  });
678
685
  }
@@ -970,31 +977,49 @@ class AdminClient extends velocityClient_1.VelocityClient {
970
977
  },
971
978
  });
972
979
  }
973
- async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
974
- const updateWithdrawGuardThresholdIx = await this.getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold);
980
+ async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold, oracle) {
981
+ const updateWithdrawGuardThresholdIx = await this.getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold, oracle);
975
982
  const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
976
983
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
977
984
  return txSig;
978
985
  }
979
- async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold) {
986
+ async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold, oracle) {
987
+ const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
988
+ if (!oracle) {
989
+ const cachedSpotMarket = this.isSubscribed
990
+ ? this.getSpotMarketAccount(spotMarketIndex)
991
+ : undefined;
992
+ if (cachedSpotMarket) {
993
+ oracle = cachedSpotMarket.oracle;
994
+ }
995
+ else {
996
+ const accountInfo = await this.connection.getAccountInfo(spotMarketPublicKey);
997
+ if (!accountInfo) {
998
+ throw new Error(`Spot market account not found: ${spotMarketPublicKey.toString()}`);
999
+ }
1000
+ const spotMarket = this.program.account.spotMarket.coder.accounts.decodeUnchecked('spotMarket', accountInfo.data);
1001
+ oracle = spotMarket.oracle;
1002
+ }
1003
+ }
980
1004
  return await this.program.instruction.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
981
1005
  accounts: {
982
1006
  admin: this.isSubscribed
983
1007
  ? this.getStateAccount().coldAdmin
984
1008
  : this.wallet.publicKey,
985
1009
  state: await this.getStatePublicKey(),
986
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1010
+ spotMarket: spotMarketPublicKey,
1011
+ oracle,
987
1012
  },
988
1013
  });
989
1014
  }
990
- async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
991
- const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(spotMarketIndex, userIfFactor, totalIfFactor);
1015
+ async updateSpotMarketIfFactor(spotMarketIndex, ifFeeFactor, protocolFeeFactor) {
1016
+ const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(spotMarketIndex, ifFeeFactor, protocolFeeFactor);
992
1017
  const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
993
1018
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
994
1019
  return txSig;
995
1020
  }
996
- async getUpdateSpotMarketIfFactorIx(spotMarketIndex, userIfFactor, totalIfFactor) {
997
- return await this.program.instruction.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
1021
+ async getUpdateSpotMarketIfFactorIx(spotMarketIndex, ifFeeFactor, protocolFeeFactor) {
1022
+ return await this.program.instruction.updateSpotMarketIfFactor(spotMarketIndex, ifFeeFactor, protocolFeeFactor, {
998
1023
  accounts: {
999
1024
  admin: this.isSubscribed
1000
1025
  ? this.getStateAccount().coldAdmin
@@ -1096,6 +1121,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1096
1121
  return txSig;
1097
1122
  }
1098
1123
  async getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
1124
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
1099
1125
  return await this.program.instruction.updatePerpMarketOracle(oracle, oracleSource, skipInvaraintCheck, {
1100
1126
  accounts: {
1101
1127
  admin: this.isSubscribed
@@ -1104,7 +1130,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1104
1130
  state: await this.getStatePublicKey(),
1105
1131
  perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
1106
1132
  oracle: oracle,
1107
- oldOracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
1133
+ oldOracle: perpMarketAccount.oracle,
1108
1134
  ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
1109
1135
  },
1110
1136
  });
@@ -1209,6 +1235,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1209
1235
  return txSig;
1210
1236
  }
1211
1237
  async getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
1238
+ const spotMarketAccount = this.getSpotMarketAccountOrThrow(spotMarketIndex);
1212
1239
  return await this.program.instruction.updateSpotMarketOracle(oracle, oracleSource, skipInvaraintCheck, {
1213
1240
  accounts: {
1214
1241
  admin: this.isSubscribed
@@ -1217,7 +1244,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1217
1244
  state: await this.getStatePublicKey(),
1218
1245
  spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1219
1246
  oracle: oracle,
1220
- oldOracle: this.getSpotMarketAccount(spotMarketIndex).oracle,
1247
+ oldOracle: spotMarketAccount.oracle,
1221
1248
  },
1222
1249
  });
1223
1250
  }
@@ -1513,13 +1540,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
1513
1540
  return txSig;
1514
1541
  }
1515
1542
  async getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio) {
1543
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
1516
1544
  return await this.program.instruction.updateMaxSlippageRatio(maxSlippageRatio, {
1517
1545
  accounts: {
1518
1546
  admin: this.isSubscribed
1519
1547
  ? this.getStateAccount().coldAdmin
1520
1548
  : this.wallet.publicKey,
1521
1549
  state: await this.getStatePublicKey(),
1522
- perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
1550
+ perpMarket: perpMarketAccount.pubkey,
1523
1551
  },
1524
1552
  });
1525
1553
  }
@@ -1608,142 +1636,154 @@ class AdminClient extends velocityClient_1.VelocityClient {
1608
1636
  },
1609
1637
  });
1610
1638
  }
1611
- async updateSpotMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
1612
- const updateSpotMarketFeeAdjustmentIx = await this.getUpdateSpotMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
1613
- const tx = await this.buildTransaction(updateSpotMarketFeeAdjustmentIx);
1639
+ async updatePerpMarketFeePoolBufferTarget(perpMarketIndex, feePoolBufferTarget) {
1640
+ const updatePerpMarketFeePoolBufferTargetIx = await this.getUpdatePerpMarketFeePoolBufferTargetIx(perpMarketIndex, feePoolBufferTarget);
1641
+ const tx = await this.buildTransaction(updatePerpMarketFeePoolBufferTargetIx);
1614
1642
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1615
1643
  return txSig;
1616
1644
  }
1617
- async getUpdateSpotMarketFeeAdjustmentIx(spotMarketIndex, feeAdjustment) {
1618
- return await this.program.instruction.updateSpotMarketFeeAdjustment(feeAdjustment, {
1645
+ async getUpdatePerpMarketFeePoolBufferTargetIx(perpMarketIndex, feePoolBufferTarget) {
1646
+ return await this.program.instruction.updatePerpMarketFeePoolBufferTarget(feePoolBufferTarget, {
1619
1647
  accounts: {
1620
1648
  admin: this.isSubscribed
1621
1649
  ? this.getStateAccount().coldAdmin
1622
1650
  : this.wallet.publicKey,
1623
1651
  state: await this.getStatePublicKey(),
1624
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1652
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
1625
1653
  },
1626
1654
  });
1627
1655
  }
1628
- async updatePerpMarketLiquidationFee(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
1629
- const updatePerpMarketLiquidationFeeIx = await this.getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee);
1630
- const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
1656
+ async updateSpotMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
1657
+ const updateSpotMarketFeeAdjustmentIx = await this.getUpdateSpotMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
1658
+ const tx = await this.buildTransaction(updateSpotMarketFeeAdjustmentIx);
1631
1659
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1632
1660
  return txSig;
1633
1661
  }
1634
- async getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
1635
- return await this.program.instruction.updatePerpMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
1662
+ async getUpdateSpotMarketFeeAdjustmentIx(spotMarketIndex, feeAdjustment) {
1663
+ return await this.program.instruction.updateSpotMarketFeeAdjustment(feeAdjustment, {
1636
1664
  accounts: {
1637
1665
  admin: this.isSubscribed
1638
1666
  ? this.getStateAccount().coldAdmin
1639
1667
  : this.wallet.publicKey,
1640
1668
  state: await this.getStatePublicKey(),
1641
- perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
1669
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1642
1670
  },
1643
1671
  });
1644
1672
  }
1645
- async updateSpotMarketLiquidationFee(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
1646
- const updateSpotMarketLiquidationFeeIx = await this.getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee);
1647
- const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
1673
+ async updatePerpMarketLiquidationFee(perpMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
1674
+ const updatePerpMarketLiquidationFeeIx = await this.getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee);
1675
+ const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
1648
1676
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1649
1677
  return txSig;
1650
1678
  }
1651
- async getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
1652
- return await this.program.instruction.updateSpotMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
1679
+ async getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
1680
+ return await this.program.instruction.updatePerpMarketLiquidationFee(liquidatorFee, ifLiquidationFee, protocolLiquidationFee, {
1653
1681
  accounts: {
1654
1682
  admin: this.isSubscribed
1655
1683
  ? this.getStateAccount().coldAdmin
1656
1684
  : this.wallet.publicKey,
1657
1685
  state: await this.getStatePublicKey(),
1658
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1686
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
1659
1687
  },
1660
1688
  });
1661
1689
  }
1662
- async initializeProtocolIfSharesTransferConfig() {
1663
- const initializeProtocolIfSharesTransferConfigIx = await this.getInitializeProtocolIfSharesTransferConfigIx();
1664
- const tx = await this.buildTransaction(initializeProtocolIfSharesTransferConfigIx);
1690
+ async updateSpotMarketLiquidationFee(spotMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
1691
+ const updateSpotMarketLiquidationFeeIx = await this.getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee);
1692
+ const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
1665
1693
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1666
1694
  return txSig;
1667
1695
  }
1668
- async getInitializeProtocolIfSharesTransferConfigIx() {
1669
- return await this.program.instruction.initializeProtocolIfSharesTransferConfig({
1696
+ async getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
1697
+ return await this.program.instruction.updateSpotMarketLiquidationFee(liquidatorFee, ifLiquidationFee, protocolLiquidationFee, {
1670
1698
  accounts: {
1671
1699
  admin: this.isSubscribed
1672
1700
  ? this.getStateAccount().coldAdmin
1673
1701
  : this.wallet.publicKey,
1674
1702
  state: await this.getStatePublicKey(),
1675
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1676
- systemProgram: anchor.web3.SystemProgram.programId,
1677
- protocolIfSharesTransferConfig: (0, pda_1.getProtocolIfSharesTransferConfigPublicKey)(this.program.programId),
1703
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
1678
1704
  },
1679
1705
  });
1680
1706
  }
1681
- async updateProtocolIfSharesTransferConfig(whitelistedSigners, maxTransferPerEpoch) {
1682
- const updateProtocolIfSharesTransferConfigIx = await this.getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners, maxTransferPerEpoch);
1683
- const tx = await this.buildTransaction(updateProtocolIfSharesTransferConfigIx);
1707
+ async updateProtocolFeeRecipient(protocolFeeRecipient, marketType) {
1708
+ const ix = await this.getUpdateProtocolFeeRecipientIx(protocolFeeRecipient, marketType);
1709
+ const tx = await this.buildTransaction(ix);
1684
1710
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1685
1711
  return txSig;
1686
1712
  }
1687
- async getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners, maxTransferPerEpoch) {
1688
- return await this.program.instruction.updateProtocolIfSharesTransferConfig(whitelistedSigners || null, maxTransferPerEpoch, {
1713
+ async getUpdateProtocolFeeRecipientIx(protocolFeeRecipient, marketType) {
1714
+ return await this.program.instruction.updateProtocolFeeRecipient(protocolFeeRecipient, marketType, {
1689
1715
  accounts: {
1690
1716
  admin: this.isSubscribed
1691
1717
  ? this.getStateAccount().coldAdmin
1692
1718
  : this.wallet.publicKey,
1693
1719
  state: await this.getStatePublicKey(),
1694
- protocolIfSharesTransferConfig: (0, pda_1.getProtocolIfSharesTransferConfigPublicKey)(this.program.programId),
1695
1720
  },
1696
1721
  });
1697
1722
  }
1698
- async transferProtocolIfSharesToRevenuePool(outMarketIndex, inMarketIndex, amount) {
1699
- const transferProtocolIfSharesToRevenuePoolIx = await this.getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex, inMarketIndex, amount);
1700
- const tx = await this.buildTransaction(transferProtocolIfSharesToRevenuePoolIx);
1723
+ async withdrawProtocolFeesSpot(marketIndex, amount, txParams) {
1724
+ const ix = await this.getWithdrawProtocolFeesSpotIx(marketIndex, amount);
1725
+ const tx = await this.buildTransaction(ix, txParams);
1701
1726
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1702
1727
  return txSig;
1703
1728
  }
1704
- async getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex, inMarketIndex, amount) {
1705
- const remainingAccounts = await this.getRemainingAccounts({
1706
- userAccounts: [],
1707
- writableSpotMarketIndexes: [outMarketIndex],
1708
- });
1709
- return await this.program.instruction.transferProtocolIfSharesToRevenuePool(outMarketIndex, amount, {
1729
+ async getWithdrawProtocolFeesSpotIx(marketIndex, amount) {
1730
+ const spotMarket = this.getSpotMarketAccountOrThrow(marketIndex);
1731
+ const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
1732
+ const recipient = this.getStateAccount().protocolFeeRecipientSpot;
1733
+ const recipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(spotMarket.mint, recipient, true, tokenProgramId);
1734
+ const remainingAccounts = [];
1735
+ if (this.isTransferHook(spotMarket)) {
1736
+ await this.addExtraAccountMetasToRemainingAccounts(spotMarket.mint, remainingAccounts);
1737
+ }
1738
+ return await this.program.instruction.withdrawProtocolFeesSpot(marketIndex, amount, {
1710
1739
  accounts: {
1711
- authority: this.wallet.publicKey,
1712
1740
  state: await this.getStatePublicKey(),
1713
- insuranceFundVault: await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, outMarketIndex),
1714
- spotMarketVault: await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, outMarketIndex),
1715
- ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, inMarketIndex, outMarketIndex),
1716
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1717
- velocitySigner: this.getStateAccount().signer,
1741
+ payer: this.wallet.publicKey,
1742
+ authority: this.wallet.publicKey,
1743
+ spotMarket: spotMarket.pubkey,
1744
+ spotMarketVault: spotMarket.vault,
1745
+ mint: spotMarket.mint,
1746
+ recipient,
1747
+ recipientTokenAccount,
1748
+ tokenProgram: tokenProgramId,
1749
+ velocitySigner: this.getSignerPublicKey(),
1750
+ systemProgram: web3_js_1.SystemProgram.programId,
1751
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
1718
1752
  },
1719
1753
  remainingAccounts,
1720
1754
  });
1721
1755
  }
1722
- async adminWithdrawFromInsuranceFundVault(marketIndex, amount, recipientTokenAccount, txParams) {
1723
- const ix = await this.getAdminWithdrawFromInsuranceFundVaultIx(marketIndex, amount, recipientTokenAccount);
1756
+ async withdrawProtocolFeesPerp(marketIndex, amount, txParams) {
1757
+ const ix = await this.getWithdrawProtocolFeesPerpIx(marketIndex, amount);
1724
1758
  const tx = await this.buildTransaction(ix, txParams);
1725
1759
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1726
1760
  return txSig;
1727
1761
  }
1728
- async getAdminWithdrawFromInsuranceFundVaultIx(marketIndex, amount, recipientTokenAccount) {
1729
- const spotMarket = this.getSpotMarketAccount(marketIndex);
1730
- const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
1762
+ async getWithdrawProtocolFeesPerpIx(marketIndex, amount) {
1763
+ const perpMarket = this.getPerpMarketAccountOrThrow(marketIndex);
1764
+ const quoteSpotMarket = this.getSpotMarketAccountOrThrow(perpMarket.quoteSpotMarketIndex);
1765
+ const tokenProgramId = this.getTokenProgramForSpotMarket(quoteSpotMarket);
1766
+ const recipient = this.getStateAccount().protocolFeeRecipientPerp;
1767
+ const recipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(quoteSpotMarket.mint, recipient, true, tokenProgramId);
1731
1768
  const remainingAccounts = [];
1732
- this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
1733
- if (this.isTransferHook(spotMarket)) {
1734
- await this.addExtraAccountMetasToRemainingAccounts(spotMarket.mint, remainingAccounts);
1769
+ if (this.isTransferHook(quoteSpotMarket)) {
1770
+ await this.addExtraAccountMetasToRemainingAccounts(quoteSpotMarket.mint, remainingAccounts);
1735
1771
  }
1736
- return await this.program.instruction.adminWithdrawFromInsuranceFundVault(marketIndex, amount, {
1772
+ return await this.program.instruction.withdrawProtocolFeesPerp(marketIndex, amount, {
1737
1773
  accounts: {
1738
1774
  state: await this.getStatePublicKey(),
1739
- authority: this.isSubscribed
1740
- ? this.getStateAccount().coldAdmin
1741
- : this.wallet.publicKey,
1742
- spotMarket: spotMarket.pubkey,
1743
- insuranceFundVault: spotMarket.insuranceFund.vault,
1775
+ payer: this.wallet.publicKey,
1776
+ authority: this.wallet.publicKey,
1777
+ perpMarket: perpMarket.pubkey,
1778
+ quoteSpotMarket: quoteSpotMarket.pubkey,
1779
+ spotMarketVault: quoteSpotMarket.vault,
1780
+ mint: quoteSpotMarket.mint,
1781
+ recipient,
1744
1782
  recipientTokenAccount,
1745
1783
  tokenProgram: tokenProgramId,
1746
1784
  velocitySigner: this.getSignerPublicKey(),
1785
+ systemProgram: web3_js_1.SystemProgram.programId,
1786
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
1747
1787
  },
1748
1788
  remainingAccounts,
1749
1789
  });
@@ -1874,22 +1914,21 @@ class AdminClient extends velocityClient_1.VelocityClient {
1874
1914
  },
1875
1915
  });
1876
1916
  }
1877
- async initializeIfRebalanceConfig(params) {
1878
- const initializeIfRebalanceConfigIx = await this.getInitializeIfRebalanceConfigIx(params);
1879
- const tx = await this.buildTransaction(initializeIfRebalanceConfigIx);
1917
+ async updatePerpMarketFundingBiasSensitivity(perpMarketIndex, fundingBiasSensitivity) {
1918
+ const updatePerpMarketFundingBiasSensitivityIx = await this.getUpdatePerpMarketFundingBiasSensitivityIx(perpMarketIndex, fundingBiasSensitivity);
1919
+ const tx = await this.buildTransaction(updatePerpMarketFundingBiasSensitivityIx);
1880
1920
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1881
1921
  return txSig;
1882
1922
  }
1883
- async getInitializeIfRebalanceConfigIx(params) {
1884
- return await this.program.instruction.initializeIfRebalanceConfig(params, {
1923
+ async getUpdatePerpMarketFundingBiasSensitivityIx(perpMarketIndex, fundingBiasSensitivity) {
1924
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
1925
+ return await this.program.instruction.updatePerpMarketFundingBiasSensitivity(fundingBiasSensitivity, {
1885
1926
  accounts: {
1886
- admin: this.isSubscribed
1887
- ? this.getStateAccount().coldAdmin
1888
- : this.wallet.publicKey,
1927
+ admin: this.useHotWalletAdmin
1928
+ ? this.wallet.publicKey
1929
+ : this.getStateAccount().coldAdmin,
1889
1930
  state: await this.getStatePublicKey(),
1890
- ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, params.inMarketIndex, params.outMarketIndex),
1891
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1892
- systemProgram: anchor.web3.SystemProgram.programId,
1931
+ perpMarket: perpMarketPublicKey,
1893
1932
  },
1894
1933
  });
1895
1934
  }
@@ -1920,7 +1959,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
1920
1959
  }
1921
1960
  async getAdminDepositIx(marketIndex, amount, depositUserAccount, adminTokenAccount) {
1922
1961
  const state = await this.getStatePublicKey();
1923
- const spotMarket = this.getSpotMarketAccount(marketIndex);
1962
+ const spotMarket = this.getSpotMarketAccountOrThrow(marketIndex);
1924
1963
  const remainingAccounts = this.getRemainingAccounts({
1925
1964
  userAccounts: [],
1926
1965
  writableSpotMarketIndexes: [marketIndex],
@@ -2022,51 +2061,6 @@ class AdminClient extends velocityClient_1.VelocityClient {
2022
2061
  },
2023
2062
  });
2024
2063
  }
2025
- async updateDelegateUserGovTokenInsuranceStake(authority, delegate) {
2026
- const updateDelegateUserGovTokenInsuranceStakeIx = await this.getUpdateDelegateUserGovTokenInsuranceStakeIx(authority, delegate);
2027
- const tx = await this.buildTransaction(updateDelegateUserGovTokenInsuranceStakeIx);
2028
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
2029
- return txSig;
2030
- }
2031
- async getUpdateDelegateUserGovTokenInsuranceStakeIx(authority, delegate) {
2032
- const marketIndex = numericConstants_1.GOV_SPOT_MARKET_INDEX;
2033
- const spotMarket = this.getSpotMarketAccount(marketIndex);
2034
- const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, delegate, marketIndex);
2035
- const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
2036
- const ix = this.program.instruction.getUpdateDelegateUserGovTokenInsuranceStakeIx({
2037
- accounts: {
2038
- state: await this.getStatePublicKey(),
2039
- spotMarket: spotMarket.pubkey,
2040
- insuranceFundStake: ifStakeAccountPublicKey,
2041
- userStats: userStatsPublicKey,
2042
- signer: this.wallet.publicKey,
2043
- insuranceFundVault: spotMarket.insuranceFund.vault,
2044
- },
2045
- });
2046
- return ix;
2047
- }
2048
- async depositIntoInsuranceFundStake(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey, txParams) {
2049
- const tx = await this.buildTransaction(await this.getDepositIntoInsuranceFundStakeIx(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey), txParams);
2050
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
2051
- return txSig;
2052
- }
2053
- async getDepositIntoInsuranceFundStakeIx(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey) {
2054
- const spotMarket = this.getSpotMarketAccount(marketIndex);
2055
- return await this.program.instruction.depositIntoInsuranceFundStake(marketIndex, amount, {
2056
- accounts: {
2057
- signer: this.wallet.publicKey,
2058
- state: await this.getStatePublicKey(),
2059
- spotMarket: spotMarket.pubkey,
2060
- insuranceFundStake: insuranceFundStakePublicKey,
2061
- userStats: userStatsPublicKey,
2062
- spotMarketVault: spotMarket.vault,
2063
- insuranceFundVault: spotMarket.insuranceFund.vault,
2064
- userTokenAccount: userTokenAccountPublicKey,
2065
- tokenProgram: this.getTokenProgramForSpotMarket(spotMarket),
2066
- velocitySigner: this.getSignerPublicKey(),
2067
- },
2068
- });
2069
- }
2070
2064
  async updateFeatureBitFlagsSettleLpPool(enable) {
2071
2065
  const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsSettleLpPoolIx(enable);
2072
2066
  const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
@@ -2183,7 +2177,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
2183
2177
  const spotMarketIndex = initializeConstituentParams.spotMarketIndex;
2184
2178
  const constituentTargetBase = (0, pda_1.getConstituentTargetBasePublicKey)(this.program.programId, lpPool);
2185
2179
  const constituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, spotMarketIndex);
2186
- const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
2180
+ const spotMarketAccount = this.getSpotMarketAccountOrThrow(spotMarketIndex);
2187
2181
  return [
2188
2182
  this.program.instruction.initializeConstituent(spotMarketIndex, initializeConstituentParams.decimals, initializeConstituentParams.maxWeightDeviation, initializeConstituentParams.swapFeeMin, initializeConstituentParams.swapFeeMax, initializeConstituentParams.maxBorrowTokenAmount, initializeConstituentParams.oracleStalenessThreshold, initializeConstituentParams.costToTrade, initializeConstituentParams.constituentDerivativeIndex != null
2189
2183
  ? initializeConstituentParams.constituentDerivativeIndex
@@ -2423,8 +2417,8 @@ class AdminClient extends velocityClient_1.VelocityClient {
2423
2417
  userAccountPublicKey,
2424
2418
  });
2425
2419
  }
2426
- const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
2427
- const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
2420
+ const outSpotMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
2421
+ const inSpotMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
2428
2422
  const outTokenProgram = this.getTokenProgramForSpotMarket(outSpotMarket);
2429
2423
  const inTokenProgram = this.getTokenProgramForSpotMarket(inSpotMarket);
2430
2424
  const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
@@ -2472,8 +2466,8 @@ class AdminClient extends velocityClient_1.VelocityClient {
2472
2466
  return { beginSwapIx, endSwapIx };
2473
2467
  }
2474
2468
  async getLpJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, amount, slippageBps, swapMode, onlyDirectRoutes, quote, lpPoolId, }) {
2475
- const outMarket = this.getSpotMarketAccount(outMarketIndex);
2476
- const inMarket = this.getSpotMarketAccount(inMarketIndex);
2469
+ const outMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
2470
+ const inMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
2477
2471
  if (!quote) {
2478
2472
  const fetchedQuote = await jupiterClient.getQuote({
2479
2473
  inputMint: inMarket.mint,
@@ -2534,8 +2528,8 @@ class AdminClient extends velocityClient_1.VelocityClient {
2534
2528
  return { ixs, lookupTables };
2535
2529
  }
2536
2530
  async getDevnetLpSwapIxs(amountIn, amountOut, externalUserAuthority, externalUserInTokenAccount, externalUserOutTokenAccount, inSpotMarketIndex, outSpotMarketIndex) {
2537
- const inSpotMarketAccount = this.getSpotMarketAccount(inSpotMarketIndex);
2538
- const outSpotMarketAccount = this.getSpotMarketAccount(outSpotMarketIndex);
2531
+ const inSpotMarketAccount = this.getSpotMarketAccountOrThrow(inSpotMarketIndex);
2532
+ const outSpotMarketAccount = this.getSpotMarketAccountOrThrow(outSpotMarketIndex);
2539
2533
  const outTokenAccount = await this.getAssociatedTokenAccount(outSpotMarketAccount.marketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(outSpotMarketAccount));
2540
2534
  const inTokenAccount = await this.getAssociatedTokenAccount(inSpotMarketAccount.marketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(inSpotMarketAccount));
2541
2535
  const externalCreateInTokenAccountIx = this.createAssociatedTokenAccountIdempotentInstruction(externalUserInTokenAccount, this.wallet.publicKey, externalUserAuthority, this.getSpotMarketAccount(inSpotMarketIndex).mint);
@@ -2551,6 +2545,8 @@ class AdminClient extends velocityClient_1.VelocityClient {
2551
2545
  return ixs;
2552
2546
  }
2553
2547
  async getAllDevnetLpSwapIxs(lpPoolId, inMarketIndex, outMarketIndex, inAmount, minOutAmount, externalUserAuthority) {
2548
+ const inMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
2549
+ const outMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
2554
2550
  const { beginSwapIx, endSwapIx } = await this.getSwapIx({
2555
2551
  lpPoolId,
2556
2552
  inMarketIndex,
@@ -2559,7 +2555,7 @@ class AdminClient extends velocityClient_1.VelocityClient {
2559
2555
  inTokenAccount: await this.getAssociatedTokenAccount(inMarketIndex, false),
2560
2556
  outTokenAccount: await this.getAssociatedTokenAccount(outMarketIndex, false),
2561
2557
  }, true);
2562
- const devnetLpSwapIxs = await this.getDevnetLpSwapIxs(inAmount, minOutAmount, externalUserAuthority, await this.getAssociatedTokenAccount(inMarketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(this.getSpotMarketAccount(inMarketIndex)), externalUserAuthority), await this.getAssociatedTokenAccount(outMarketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(this.getSpotMarketAccount(outMarketIndex)), externalUserAuthority), inMarketIndex, outMarketIndex);
2558
+ const devnetLpSwapIxs = await this.getDevnetLpSwapIxs(inAmount, minOutAmount, externalUserAuthority, await this.getAssociatedTokenAccount(inMarketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(inMarket), externalUserAuthority), await this.getAssociatedTokenAccount(outMarketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(outMarket), externalUserAuthority), inMarketIndex, outMarketIndex);
2563
2559
  return [
2564
2560
  beginSwapIx,
2565
2561
  ...devnetLpSwapIxs,
@@ -2574,8 +2570,8 @@ class AdminClient extends velocityClient_1.VelocityClient {
2574
2570
  }
2575
2571
  async getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow) {
2576
2572
  const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
2577
- const depositSpotMarket = this.getSpotMarketAccount(depositMarketIndex);
2578
- const withdrawSpotMarket = this.getSpotMarketAccount(borrowMarketIndex);
2573
+ const depositSpotMarket = this.getSpotMarketAccountOrThrow(depositMarketIndex);
2574
+ const withdrawSpotMarket = this.getSpotMarketAccountOrThrow(borrowMarketIndex);
2579
2575
  const depositTokenProgram = this.getTokenProgramForSpotMarket(depositSpotMarket);
2580
2576
  const withdrawTokenProgram = this.getTokenProgramForSpotMarket(withdrawSpotMarket);
2581
2577
  const depositConstituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, depositMarketIndex);
@@ -2638,13 +2634,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
2638
2634
  return txSig;
2639
2635
  }
2640
2636
  async getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar) {
2637
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
2641
2638
  return this.program.instruction.updatePerpMarketLpPoolFeeTransferScalar(lpFeeTransferScalar !== null && lpFeeTransferScalar !== void 0 ? lpFeeTransferScalar : null, lpExchangeFeeExcluscionScalar !== null && lpExchangeFeeExcluscionScalar !== void 0 ? lpExchangeFeeExcluscionScalar : null, {
2642
2639
  accounts: {
2643
2640
  admin: this.useHotWalletAdmin
2644
2641
  ? this.wallet.publicKey
2645
2642
  : this.getStateAccount().coldAdmin,
2646
2643
  state: await this.getStatePublicKey(),
2647
- perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
2644
+ perpMarket: perpMarketAccount.pubkey,
2648
2645
  },
2649
2646
  });
2650
2647
  }
@@ -2655,13 +2652,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
2655
2652
  return txSig;
2656
2653
  }
2657
2654
  async getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex, pausedOperations) {
2655
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
2658
2656
  return this.program.instruction.updatePerpMarketLpPoolPausedOperations(pausedOperations, {
2659
2657
  accounts: {
2660
2658
  admin: this.useHotWalletAdmin
2661
2659
  ? this.wallet.publicKey
2662
2660
  : this.getStateAccount().coldAdmin,
2663
2661
  state: await this.getStatePublicKey(),
2664
- perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
2662
+ perpMarket: perpMarketAccount.pubkey,
2665
2663
  },
2666
2664
  });
2667
2665
  }
@@ -2688,13 +2686,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
2688
2686
  return txSig;
2689
2687
  }
2690
2688
  async getUpdatePerpMarketConfigIx(marketIndex, marketConfig) {
2689
+ const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
2691
2690
  return this.program.instruction.updatePerpMarketConfig(marketConfig, {
2692
2691
  accounts: {
2693
2692
  admin: this.useHotWalletAdmin
2694
2693
  ? this.wallet.publicKey
2695
2694
  : this.getStateAccount().coldAdmin,
2696
2695
  state: await this.getStatePublicKey(),
2697
- perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
2696
+ perpMarket: perpMarketAccount.pubkey,
2698
2697
  },
2699
2698
  });
2700
2699
  }
@@ -2784,13 +2783,13 @@ var HotRole;
2784
2783
  HotRole["LpCache"] = "lpCache";
2785
2784
  HotRole["LpSwap"] = "lpSwap";
2786
2785
  HotRole["LpSettle"] = "lpSettle";
2787
- HotRole["IfRebalance"] = "ifRebalance";
2788
2786
  HotRole["FeatureFlag"] = "featureFlag";
2789
2787
  HotRole["Fuel"] = "fuel";
2790
2788
  HotRole["UserFlag"] = "userFlag";
2791
2789
  HotRole["VaultDeposit"] = "vaultDeposit";
2792
2790
  HotRole["MmOracleCrank"] = "mmOracleCrank";
2793
2791
  HotRole["AmmSpreadAdjust"] = "ammSpreadAdjust";
2792
+ HotRole["FeeWithdraw"] = "feeWithdraw";
2794
2793
  })(HotRole || (exports.HotRole = HotRole = {}));
2795
2794
  /** Anchor encodes Rust enums as `{ <variant>: {} }`. */
2796
2795
  function encodeHotRole(role) {