@velocity-exchange/sdk 0.1.0 → 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 (676) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/bun.lock +23 -1
  3. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
  4. package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
  5. package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  6. package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
  7. package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
  8. package/lib/browser/accounts/bulkAccountLoader.js +12 -1
  9. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
  10. package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
  11. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  12. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
  13. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  14. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  15. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  16. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
  17. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
  18. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
  19. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
  20. package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
  21. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
  22. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  23. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  24. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  25. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  26. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
  27. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  28. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
  29. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  30. package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
  31. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  32. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  33. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
  34. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
  35. package/lib/browser/accounts/types.d.ts +4 -4
  36. package/lib/browser/accounts/utils.d.ts +1 -0
  37. package/lib/browser/accounts/utils.js +8 -1
  38. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
  39. package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
  40. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  41. package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
  42. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  43. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  44. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  45. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
  46. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  47. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  48. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  49. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  50. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  51. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
  52. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  53. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  54. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
  55. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
  56. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
  57. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
  58. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  59. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  60. package/lib/browser/addresses/marketAddresses.js +3 -2
  61. package/lib/browser/addresses/pda.d.ts +0 -2
  62. package/lib/browser/addresses/pda.js +1 -14
  63. package/lib/browser/adminClient.d.ts +24 -28
  64. package/lib/browser/adminClient.js +156 -157
  65. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
  66. package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
  67. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
  68. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  69. package/lib/browser/bankrun/bankrunConnection.d.ts +6 -4
  70. package/lib/browser/bankrun/bankrunConnection.js +69 -31
  71. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  72. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  73. package/lib/browser/clock/clockSubscriber.d.ts +6 -6
  74. package/lib/browser/clock/clockSubscriber.js +4 -3
  75. package/lib/browser/config.d.ts +1 -1
  76. package/lib/browser/config.js +8 -4
  77. package/lib/browser/constants/index.d.ts +1 -2
  78. package/lib/browser/constants/index.js +1 -2
  79. package/lib/browser/constants/numericConstants.d.ts +1 -3
  80. package/lib/browser/constants/numericConstants.js +3 -5
  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/instructions/perpOrders.d.ts +14 -0
  86. package/lib/browser/core/instructions/perpOrders.js +14 -0
  87. package/lib/browser/core/remainingAccounts.d.ts +2 -2
  88. package/lib/browser/core/remainingAccounts.js +2 -2
  89. package/lib/browser/decode/user.js +9 -1
  90. package/lib/browser/dlob/DLOB.d.ts +6 -1
  91. package/lib/browser/dlob/DLOB.js +201 -138
  92. package/lib/browser/dlob/DLOBNode.d.ts +5 -2
  93. package/lib/browser/dlob/DLOBNode.js +7 -0
  94. package/lib/browser/dlob/DLOBSubscriber.js +37 -32
  95. package/lib/browser/dlob/NodeList.js +8 -7
  96. package/lib/browser/dlob/orderBookLevels.js +19 -12
  97. package/lib/browser/events/eventList.js +4 -1
  98. package/lib/browser/events/eventSubscriber.d.ts +5 -2
  99. package/lib/browser/events/eventSubscriber.js +75 -26
  100. package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
  101. package/lib/browser/events/eventsServerLogProvider.js +15 -8
  102. package/lib/browser/events/fetchLogs.d.ts +1 -1
  103. package/lib/browser/events/fetchLogs.js +4 -2
  104. package/lib/browser/events/pollingLogProvider.d.ts +1 -1
  105. package/lib/browser/events/pollingLogProvider.js +1 -0
  106. package/lib/browser/events/txEventCache.js +6 -2
  107. package/lib/browser/events/types.d.ts +2 -4
  108. package/lib/browser/events/types.js +0 -2
  109. package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
  110. package/lib/browser/events/webSocketLogProvider.js +5 -2
  111. package/lib/browser/factory/bigNum.js +1 -1
  112. package/lib/browser/idl/velocity.d.ts +1243 -1586
  113. package/lib/browser/idl/velocity.json +1234 -1577
  114. package/lib/browser/index.d.ts +0 -2
  115. package/lib/browser/index.js +0 -2
  116. package/lib/browser/jupiter/jupiterClient.d.ts +1 -1
  117. package/lib/browser/jupiter/jupiterClient.js +18 -8
  118. package/lib/browser/marginCalculation.js +1 -0
  119. package/lib/browser/math/amm.d.ts +31 -13
  120. package/lib/browser/math/amm.js +77 -22
  121. package/lib/browser/math/bankruptcy.js +1 -1
  122. package/lib/browser/math/funding.js +6 -6
  123. package/lib/browser/math/insurance.d.ts +1 -1
  124. package/lib/browser/math/insurance.js +4 -5
  125. package/lib/browser/math/margin.d.ts +1 -9
  126. package/lib/browser/math/margin.js +3 -62
  127. package/lib/browser/math/market.d.ts +4 -12
  128. package/lib/browser/math/market.js +6 -40
  129. package/lib/browser/math/oracles.d.ts +0 -3
  130. package/lib/browser/math/oracles.js +1 -14
  131. package/lib/browser/math/orders.d.ts +0 -5
  132. package/lib/browser/math/orders.js +2 -74
  133. package/lib/browser/math/position.d.ts +0 -4
  134. package/lib/browser/math/position.js +5 -10
  135. package/lib/browser/math/repeg.d.ts +0 -1
  136. package/lib/browser/math/repeg.js +1 -23
  137. package/lib/browser/math/spotBalance.d.ts +4 -4
  138. package/lib/browser/math/spotBalance.js +6 -6
  139. package/lib/browser/math/spotMarket.d.ts +0 -6
  140. package/lib/browser/math/spotMarket.js +1 -16
  141. package/lib/browser/math/spotPosition.d.ts +4 -4
  142. package/lib/browser/math/state.d.ts +0 -2
  143. package/lib/browser/math/state.js +1 -9
  144. package/lib/browser/math/superStake.d.ts +3 -53
  145. package/lib/browser/math/superStake.js +16 -13
  146. package/lib/browser/math/trade.js +6 -6
  147. package/lib/browser/memcmp.d.ts +0 -1
  148. package/lib/browser/memcmp.js +1 -10
  149. package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
  150. package/lib/browser/oracles/pythClient.js +9 -3
  151. package/lib/browser/oracles/pythLazerClient.js +3 -2
  152. package/lib/browser/oracles/utils.d.ts +4 -0
  153. package/lib/browser/oracles/utils.js +9 -1
  154. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
  155. package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
  156. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  157. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
  158. package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
  159. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  160. package/lib/browser/pyth/types.d.ts +0 -1
  161. package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
  162. package/lib/browser/slot/SlotSubscriber.js +2 -1
  163. package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
  164. package/lib/browser/slot/SlothashSubscriber.js +11 -4
  165. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  166. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  167. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
  168. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
  169. package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
  170. package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
  171. package/lib/browser/testClient.js +3 -2
  172. package/lib/browser/tokenFaucet.js +16 -2
  173. package/lib/browser/tx/baseTxSender.d.ts +4 -4
  174. package/lib/browser/tx/baseTxSender.js +5 -4
  175. package/lib/browser/tx/fastSingleTxSender.d.ts +3 -3
  176. package/lib/browser/tx/fastSingleTxSender.js +9 -5
  177. package/lib/browser/tx/reportTransactionError.d.ts +2 -2
  178. package/lib/browser/tx/reportTransactionError.js +5 -1
  179. package/lib/browser/tx/retryTxSender.d.ts +1 -1
  180. package/lib/browser/tx/retryTxSender.js +4 -2
  181. package/lib/browser/tx/txHandler.d.ts +7 -1
  182. package/lib/browser/tx/txHandler.js +54 -40
  183. package/lib/browser/tx/txParamProcessor.d.ts +4 -1
  184. package/lib/browser/tx/txParamProcessor.js +6 -0
  185. package/lib/browser/tx/types.d.ts +1 -1
  186. package/lib/browser/tx/whileValidTxSender.d.ts +1 -6
  187. package/lib/browser/tx/whileValidTxSender.js +35 -13
  188. package/lib/browser/types.d.ts +27 -70
  189. package/lib/browser/types.js +2 -2
  190. package/lib/browser/user.d.ts +21 -7
  191. package/lib/browser/user.js +156 -132
  192. package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
  193. package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
  194. package/lib/browser/userMap/referrerMap.js +10 -3
  195. package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
  196. package/lib/browser/userMap/userMap.d.ts +1 -1
  197. package/lib/browser/userMap/userMap.js +36 -23
  198. package/lib/browser/userMap/userStatsMap.d.ts +1 -1
  199. package/lib/browser/userMap/userStatsMap.js +18 -13
  200. package/lib/browser/userStats.d.ts +7 -2
  201. package/lib/browser/userStats.js +18 -4
  202. package/lib/browser/util/TransactionConfirmationManager.js +4 -2
  203. package/lib/browser/util/chainClock.d.ts +1 -1
  204. package/lib/browser/util/computeUnits.d.ts +1 -1
  205. package/lib/browser/util/computeUnits.js +6 -1
  206. package/lib/browser/velocityClient.d.ts +92 -34
  207. package/lib/browser/velocityClient.js +414 -280
  208. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
  209. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
  210. package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
  211. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  212. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
  213. package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
  214. package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
  215. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
  216. package/lib/node/accounts/bulkAccountLoader.js +12 -1
  217. package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
  218. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  219. package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
  220. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  221. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  222. package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
  223. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  224. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  225. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  226. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  227. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  228. package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
  229. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  230. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
  231. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
  232. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  233. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
  234. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  235. package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
  236. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  237. package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
  238. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  239. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  240. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  241. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  242. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  243. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  244. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  245. package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
  246. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  247. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  248. package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
  249. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  250. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
  251. package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
  252. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  253. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  254. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  255. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
  256. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  257. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
  258. package/lib/node/accounts/types.d.ts +4 -4
  259. package/lib/node/accounts/types.d.ts.map +1 -1
  260. package/lib/node/accounts/utils.d.ts +1 -0
  261. package/lib/node/accounts/utils.d.ts.map +1 -1
  262. package/lib/node/accounts/utils.js +8 -1
  263. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
  264. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  265. package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
  266. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  267. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  268. package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
  269. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  270. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  271. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  272. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  273. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  274. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
  275. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  276. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  277. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  278. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  279. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  280. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  281. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  282. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  283. package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
  284. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  285. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  286. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  287. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
  288. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  289. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
  290. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
  291. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  292. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
  293. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  294. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  295. package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  296. package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
  297. package/lib/node/addresses/marketAddresses.js +3 -2
  298. package/lib/node/addresses/pda.d.ts +0 -2
  299. package/lib/node/addresses/pda.d.ts.map +1 -1
  300. package/lib/node/addresses/pda.js +1 -14
  301. package/lib/node/adminClient.d.ts +24 -28
  302. package/lib/node/adminClient.d.ts.map +1 -1
  303. package/lib/node/adminClient.js +156 -157
  304. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
  305. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  306. package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
  307. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
  308. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  309. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  310. package/lib/node/bankrun/bankrunConnection.d.ts +6 -4
  311. package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
  312. package/lib/node/bankrun/bankrunConnection.js +69 -31
  313. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  314. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
  315. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  316. package/lib/node/clock/clockSubscriber.d.ts +6 -6
  317. package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
  318. package/lib/node/clock/clockSubscriber.js +4 -3
  319. package/lib/node/config.d.ts +1 -1
  320. package/lib/node/config.d.ts.map +1 -1
  321. package/lib/node/config.js +8 -4
  322. package/lib/node/constants/index.d.ts +1 -2
  323. package/lib/node/constants/index.d.ts.map +1 -1
  324. package/lib/node/constants/index.js +1 -2
  325. package/lib/node/constants/numericConstants.d.ts +1 -3
  326. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  327. package/lib/node/constants/numericConstants.js +3 -5
  328. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  329. package/lib/node/constituentMap/constituentMap.js +5 -1
  330. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
  331. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  332. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  333. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
  334. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  335. package/lib/node/core/instructions/perpOrders.d.ts +14 -0
  336. package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
  337. package/lib/node/core/instructions/perpOrders.js +14 -0
  338. package/lib/node/core/remainingAccounts.d.ts +2 -2
  339. package/lib/node/core/remainingAccounts.d.ts.map +1 -1
  340. package/lib/node/core/remainingAccounts.js +2 -2
  341. package/lib/node/decode/user.d.ts.map +1 -1
  342. package/lib/node/decode/user.js +9 -1
  343. package/lib/node/dlob/DLOB.d.ts +6 -1
  344. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  345. package/lib/node/dlob/DLOB.js +201 -138
  346. package/lib/node/dlob/DLOBNode.d.ts +5 -2
  347. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  348. package/lib/node/dlob/DLOBNode.js +7 -0
  349. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  350. package/lib/node/dlob/DLOBSubscriber.js +37 -32
  351. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  352. package/lib/node/dlob/NodeList.js +8 -7
  353. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  354. package/lib/node/dlob/orderBookLevels.js +19 -12
  355. package/lib/node/events/eventList.d.ts +3 -3
  356. package/lib/node/events/eventList.d.ts.map +1 -1
  357. package/lib/node/events/eventList.js +4 -1
  358. package/lib/node/events/eventSubscriber.d.ts +5 -2
  359. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  360. package/lib/node/events/eventSubscriber.js +75 -26
  361. package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
  362. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
  363. package/lib/node/events/eventsServerLogProvider.js +15 -8
  364. package/lib/node/events/fetchLogs.d.ts +1 -1
  365. package/lib/node/events/fetchLogs.d.ts.map +1 -1
  366. package/lib/node/events/fetchLogs.js +4 -2
  367. package/lib/node/events/pollingLogProvider.d.ts +2 -2
  368. package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
  369. package/lib/node/events/pollingLogProvider.js +1 -0
  370. package/lib/node/events/txEventCache.d.ts +3 -3
  371. package/lib/node/events/txEventCache.d.ts.map +1 -1
  372. package/lib/node/events/txEventCache.js +6 -2
  373. package/lib/node/events/types.d.ts +2 -4
  374. package/lib/node/events/types.d.ts.map +1 -1
  375. package/lib/node/events/types.js +0 -2
  376. package/lib/node/events/webSocketLogProvider.d.ts +2 -2
  377. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
  378. package/lib/node/events/webSocketLogProvider.js +5 -2
  379. package/lib/node/factory/bigNum.js +1 -1
  380. package/lib/node/idl/velocity.d.ts +1243 -1586
  381. package/lib/node/idl/velocity.d.ts.map +1 -1
  382. package/lib/node/idl/velocity.json +1234 -1577
  383. package/lib/node/index.d.ts +0 -2
  384. package/lib/node/index.d.ts.map +1 -1
  385. package/lib/node/index.js +0 -2
  386. package/lib/node/jupiter/jupiterClient.d.ts +1 -1
  387. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
  388. package/lib/node/jupiter/jupiterClient.js +18 -8
  389. package/lib/node/marginCalculation.d.ts.map +1 -1
  390. package/lib/node/marginCalculation.js +1 -0
  391. package/lib/node/math/amm.d.ts +31 -13
  392. package/lib/node/math/amm.d.ts.map +1 -1
  393. package/lib/node/math/amm.js +77 -22
  394. package/lib/node/math/bankruptcy.js +1 -1
  395. package/lib/node/math/funding.d.ts.map +1 -1
  396. package/lib/node/math/funding.js +6 -6
  397. package/lib/node/math/insurance.d.ts +1 -1
  398. package/lib/node/math/insurance.d.ts.map +1 -1
  399. package/lib/node/math/insurance.js +4 -5
  400. package/lib/node/math/margin.d.ts +1 -9
  401. package/lib/node/math/margin.d.ts.map +1 -1
  402. package/lib/node/math/margin.js +3 -62
  403. package/lib/node/math/market.d.ts +4 -12
  404. package/lib/node/math/market.d.ts.map +1 -1
  405. package/lib/node/math/market.js +6 -40
  406. package/lib/node/math/oracles.d.ts +0 -3
  407. package/lib/node/math/oracles.d.ts.map +1 -1
  408. package/lib/node/math/oracles.js +1 -14
  409. package/lib/node/math/orders.d.ts +0 -5
  410. package/lib/node/math/orders.d.ts.map +1 -1
  411. package/lib/node/math/orders.js +2 -74
  412. package/lib/node/math/position.d.ts +1 -5
  413. package/lib/node/math/position.d.ts.map +1 -1
  414. package/lib/node/math/position.js +5 -10
  415. package/lib/node/math/repeg.d.ts +0 -1
  416. package/lib/node/math/repeg.d.ts.map +1 -1
  417. package/lib/node/math/repeg.js +1 -23
  418. package/lib/node/math/spotBalance.d.ts +4 -4
  419. package/lib/node/math/spotBalance.d.ts.map +1 -1
  420. package/lib/node/math/spotBalance.js +6 -6
  421. package/lib/node/math/spotMarket.d.ts +0 -6
  422. package/lib/node/math/spotMarket.d.ts.map +1 -1
  423. package/lib/node/math/spotMarket.js +1 -16
  424. package/lib/node/math/spotPosition.d.ts +4 -4
  425. package/lib/node/math/spotPosition.d.ts.map +1 -1
  426. package/lib/node/math/state.d.ts +0 -2
  427. package/lib/node/math/state.d.ts.map +1 -1
  428. package/lib/node/math/state.js +1 -9
  429. package/lib/node/math/superStake.d.ts +3 -53
  430. package/lib/node/math/superStake.d.ts.map +1 -1
  431. package/lib/node/math/superStake.js +16 -13
  432. package/lib/node/math/trade.d.ts +2 -2
  433. package/lib/node/math/trade.d.ts.map +1 -1
  434. package/lib/node/math/trade.js +6 -6
  435. package/lib/node/memcmp.d.ts +0 -1
  436. package/lib/node/memcmp.d.ts.map +1 -1
  437. package/lib/node/memcmp.js +1 -10
  438. package/lib/node/oracles/oracleClientCache.d.ts +1 -1
  439. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  440. package/lib/node/oracles/prelaunchOracleClient.js +3 -2
  441. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  442. package/lib/node/oracles/pythClient.js +9 -3
  443. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  444. package/lib/node/oracles/pythLazerClient.js +3 -2
  445. package/lib/node/oracles/utils.d.ts +4 -0
  446. package/lib/node/oracles/utils.d.ts.map +1 -1
  447. package/lib/node/oracles/utils.js +9 -1
  448. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
  449. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  450. package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
  451. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  452. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
  453. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -1
  454. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  455. package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
  456. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  457. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
  458. package/lib/node/pyth/types.d.ts +0 -1
  459. package/lib/node/pyth/types.d.ts.map +1 -1
  460. package/lib/node/slot/SlotSubscriber.d.ts +1 -1
  461. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
  462. package/lib/node/slot/SlotSubscriber.js +2 -1
  463. package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
  464. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
  465. package/lib/node/slot/SlothashSubscriber.js +11 -4
  466. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  467. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
  468. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  469. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
  470. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  471. package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
  472. package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
  473. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  474. package/lib/node/swift/swiftOrderSubscriber.js +10 -5
  475. package/lib/node/testClient.js +3 -2
  476. package/lib/node/tokenFaucet.d.ts.map +1 -1
  477. package/lib/node/tokenFaucet.js +16 -2
  478. package/lib/node/tx/baseTxSender.d.ts +4 -4
  479. package/lib/node/tx/baseTxSender.d.ts.map +1 -1
  480. package/lib/node/tx/baseTxSender.js +5 -4
  481. package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
  482. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
  483. package/lib/node/tx/fastSingleTxSender.js +9 -5
  484. package/lib/node/tx/reportTransactionError.d.ts +2 -2
  485. package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
  486. package/lib/node/tx/reportTransactionError.js +5 -1
  487. package/lib/node/tx/retryTxSender.d.ts +1 -1
  488. package/lib/node/tx/retryTxSender.d.ts.map +1 -1
  489. package/lib/node/tx/retryTxSender.js +4 -2
  490. package/lib/node/tx/txHandler.d.ts +9 -3
  491. package/lib/node/tx/txHandler.d.ts.map +1 -1
  492. package/lib/node/tx/txHandler.js +54 -40
  493. package/lib/node/tx/txParamProcessor.d.ts +4 -1
  494. package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
  495. package/lib/node/tx/txParamProcessor.js +6 -0
  496. package/lib/node/tx/types.d.ts +1 -1
  497. package/lib/node/tx/types.d.ts.map +1 -1
  498. package/lib/node/tx/whileValidTxSender.d.ts +1 -6
  499. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
  500. package/lib/node/tx/whileValidTxSender.js +35 -13
  501. package/lib/node/types.d.ts +25 -68
  502. package/lib/node/types.d.ts.map +1 -1
  503. package/lib/node/types.js +2 -2
  504. package/lib/node/user.d.ts +21 -7
  505. package/lib/node/user.d.ts.map +1 -1
  506. package/lib/node/user.js +156 -132
  507. package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
  508. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
  509. package/lib/node/userMap/grpcSubscription.d.ts +1 -1
  510. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
  511. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  512. package/lib/node/userMap/referrerMap.js +10 -3
  513. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  514. package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
  515. package/lib/node/userMap/userMap.d.ts +1 -1
  516. package/lib/node/userMap/userMap.d.ts.map +1 -1
  517. package/lib/node/userMap/userMap.js +36 -23
  518. package/lib/node/userMap/userStatsMap.d.ts +1 -1
  519. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  520. package/lib/node/userMap/userStatsMap.js +18 -13
  521. package/lib/node/userStats.d.ts +7 -2
  522. package/lib/node/userStats.d.ts.map +1 -1
  523. package/lib/node/userStats.js +18 -4
  524. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
  525. package/lib/node/util/TransactionConfirmationManager.js +4 -2
  526. package/lib/node/util/chainClock.d.ts +1 -1
  527. package/lib/node/util/chainClock.d.ts.map +1 -1
  528. package/lib/node/util/computeUnits.d.ts +1 -1
  529. package/lib/node/util/computeUnits.d.ts.map +1 -1
  530. package/lib/node/util/computeUnits.js +6 -1
  531. package/lib/node/velocityClient.d.ts +93 -35
  532. package/lib/node/velocityClient.d.ts.map +1 -1
  533. package/lib/node/velocityClient.js +414 -280
  534. package/package.json +5 -3
  535. package/src/accounts/basicUserAccountSubscriber.ts +7 -5
  536. package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
  537. package/src/accounts/bulkAccountLoader.ts +20 -7
  538. package/src/accounts/grpcAccountSubscriber.ts +11 -3
  539. package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
  540. package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
  541. package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
  542. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
  543. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
  544. package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
  545. package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
  546. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
  547. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
  548. package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
  549. package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
  550. package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
  551. package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
  552. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
  553. package/src/accounts/types.ts +6 -4
  554. package/src/accounts/utils.ts +10 -0
  555. package/src/accounts/webSocketAccountSubscriber.ts +23 -10
  556. package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
  557. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
  558. package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
  559. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
  560. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
  561. package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
  562. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
  563. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
  564. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
  565. package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
  566. package/src/addresses/marketAddresses.ts +3 -2
  567. package/src/addresses/pda.ts +0 -25
  568. package/src/adminClient.ts +273 -303
  569. package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
  570. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
  571. package/src/bankrun/bankrunConnection.ts +83 -39
  572. package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
  573. package/src/clock/clockSubscriber.ts +10 -9
  574. package/src/config.ts +8 -3
  575. package/src/constants/index.ts +1 -2
  576. package/src/constants/numericConstants.ts +3 -3
  577. package/src/constituentMap/constituentMap.ts +8 -1
  578. package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
  579. package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
  580. package/src/core/instructions/perpOrders.ts +14 -0
  581. package/src/core/remainingAccounts.ts +4 -4
  582. package/src/decode/user.ts +8 -1
  583. package/src/dlob/DLOB.ts +296 -172
  584. package/src/dlob/DLOBNode.ts +23 -3
  585. package/src/dlob/DLOBSubscriber.ts +51 -34
  586. package/src/dlob/NodeList.ts +8 -7
  587. package/src/dlob/orderBookLevels.ts +45 -25
  588. package/src/events/eventList.ts +4 -1
  589. package/src/events/eventSubscriber.ts +107 -49
  590. package/src/events/eventsServerLogProvider.ts +22 -13
  591. package/src/events/fetchLogs.ts +3 -3
  592. package/src/events/pollingLogProvider.ts +2 -2
  593. package/src/events/txEventCache.ts +8 -2
  594. package/src/events/types.ts +0 -8
  595. package/src/events/webSocketLogProvider.ts +5 -3
  596. package/src/factory/bigNum.ts +2 -2
  597. package/src/idl/velocity.json +1234 -1577
  598. package/src/idl/velocity.ts +1234 -1577
  599. package/src/index.ts +0 -2
  600. package/src/jupiter/jupiterClient.ts +30 -10
  601. package/src/marginCalculation.ts +1 -0
  602. package/src/math/amm.ts +188 -33
  603. package/src/math/bankruptcy.ts +1 -1
  604. package/src/math/funding.ts +7 -6
  605. package/src/math/insurance.ts +6 -8
  606. package/src/math/margin.ts +5 -112
  607. package/src/math/market.ts +6 -96
  608. package/src/math/oracles.ts +0 -17
  609. package/src/math/orders.ts +1 -110
  610. package/src/math/position.ts +4 -16
  611. package/src/math/repeg.ts +0 -29
  612. package/src/math/spotBalance.ts +14 -10
  613. package/src/math/spotMarket.ts +2 -28
  614. package/src/math/spotPosition.ts +4 -4
  615. package/src/math/state.ts +0 -8
  616. package/src/math/superStake.ts +19 -65
  617. package/src/math/trade.ts +2 -6
  618. package/src/memcmp.ts +0 -9
  619. package/src/oracles/prelaunchOracleClient.ts +7 -2
  620. package/src/oracles/pythClient.ts +12 -3
  621. package/src/oracles/pythLazerClient.ts +7 -2
  622. package/src/oracles/utils.ts +15 -0
  623. package/src/orderSubscriber/OrderSubscriber.ts +10 -4
  624. package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
  625. package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
  626. package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
  627. package/src/pyth/types.ts +0 -2
  628. package/src/slot/SlotSubscriber.ts +3 -3
  629. package/src/slot/SlothashSubscriber.ts +17 -6
  630. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
  631. package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
  632. package/src/swift/swiftOrderSubscriber.ts +10 -9
  633. package/src/testClient.ts +2 -2
  634. package/src/tokenFaucet.ts +22 -3
  635. package/src/tx/baseTxSender.ts +10 -10
  636. package/src/tx/fastSingleTxSender.ts +12 -8
  637. package/src/tx/reportTransactionError.ts +12 -7
  638. package/src/tx/retryTxSender.ts +6 -4
  639. package/src/tx/txHandler.ts +88 -43
  640. package/src/tx/txParamProcessor.ts +18 -3
  641. package/src/tx/types.ts +1 -1
  642. package/src/tx/whileValidTxSender.ts +51 -22
  643. package/src/types.ts +39 -75
  644. package/src/user.ts +200 -152
  645. package/src/userMap/WebsocketSubscription.ts +1 -1
  646. package/src/userMap/grpcSubscription.ts +1 -1
  647. package/src/userMap/referrerMap.ts +13 -9
  648. package/src/userMap/revenueShareEscrowMap.ts +6 -1
  649. package/src/userMap/userMap.ts +43 -25
  650. package/src/userMap/userStatsMap.ts +32 -19
  651. package/src/userStats.ts +21 -8
  652. package/src/util/TransactionConfirmationManager.ts +10 -2
  653. package/src/util/chainClock.ts +1 -1
  654. package/src/util/computeUnits.ts +7 -3
  655. package/src/velocityClient.ts +536 -383
  656. package/tests/amm/test.ts +138 -0
  657. package/tests/dlob/helpers.ts +6 -1
  658. package/tsconfig.json +1 -0
  659. package/lib/browser/constants/insuranceFund.d.ts +0 -5
  660. package/lib/browser/constants/insuranceFund.js +0 -9
  661. package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
  662. package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
  663. package/lib/browser/util/tps.d.ts +0 -2
  664. package/lib/browser/util/tps.js +0 -16
  665. package/lib/node/constants/insuranceFund.d.ts +0 -6
  666. package/lib/node/constants/insuranceFund.d.ts.map +0 -1
  667. package/lib/node/constants/insuranceFund.js +0 -9
  668. package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
  669. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
  670. package/lib/node/tx/forwardOnlyTxSender.js +0 -92
  671. package/lib/node/util/tps.d.ts +0 -3
  672. package/lib/node/util/tps.d.ts.map +0 -1
  673. package/lib/node/util/tps.js +0 -16
  674. package/src/constants/insuranceFund.ts +0 -8
  675. package/src/tx/forwardOnlyTxSender.ts +0 -145
  676. package/src/util/tps.ts +0 -27
@@ -246,9 +246,9 @@ function calculateSpotMarketBorrowCapacity(spotMarketAccount, targetBorrowRate)
246
246
  return { totalCapacity, remainingCapacity };
247
247
  }
248
248
  exports.calculateSpotMarketBorrowCapacity = calculateSpotMarketBorrowCapacity;
249
- function calculateInterestRate(bank, delta = numericConstants_1.ZERO, currentUtilization = null) {
249
+ function calculateInterestRate(bank, delta = numericConstants_1.ZERO, currentUtilization) {
250
250
  // todo: ensure both a delta and current util aren't pass?
251
- const utilization = currentUtilization || calculateUtilization(bank, delta);
251
+ const utilization = currentUtilization !== null && currentUtilization !== void 0 ? currentUtilization : calculateUtilization(bank, delta);
252
252
  const optimalUtil = new anchor_1.BN(bank.optimalUtilization);
253
253
  const optimalRate = new anchor_1.BN(bank.optimalBorrowRate);
254
254
  const maxRate = new anchor_1.BN(bank.maxBorrowRate);
@@ -296,20 +296,20 @@ function calculateInterestRate(bank, delta = numericConstants_1.ZERO, currentUti
296
296
  return anchor_1.BN.max(minRate, rate);
297
297
  }
298
298
  exports.calculateInterestRate = calculateInterestRate;
299
- function calculateDepositRate(bank, delta = numericConstants_1.ZERO, currentUtilization = null) {
299
+ function calculateDepositRate(bank, delta = numericConstants_1.ZERO, currentUtilization) {
300
300
  // positive delta => adding to deposit
301
301
  // negative delta => adding to borrow
302
- const utilization = currentUtilization || calculateUtilization(bank, delta);
302
+ const utilization = currentUtilization !== null && currentUtilization !== void 0 ? currentUtilization : calculateUtilization(bank, delta);
303
303
  const borrowRate = calculateBorrowRate(bank, delta, utilization);
304
304
  const depositRate = borrowRate
305
- .mul(numericConstants_2.PERCENTAGE_PRECISION.sub(new anchor_1.BN(bank.insuranceFund.totalFactor)))
305
+ .mul(numericConstants_2.PERCENTAGE_PRECISION.sub(new anchor_1.BN(bank.insuranceFund.ifFeeFactor + bank.protocolFeeFactor)))
306
306
  .mul(utilization)
307
307
  .div(numericConstants_1.SPOT_MARKET_UTILIZATION_PRECISION)
308
308
  .div(numericConstants_2.PERCENTAGE_PRECISION);
309
309
  return depositRate;
310
310
  }
311
311
  exports.calculateDepositRate = calculateDepositRate;
312
- function calculateBorrowRate(bank, delta = numericConstants_1.ZERO, currentUtilization = null) {
312
+ function calculateBorrowRate(bank, delta = numericConstants_1.ZERO, currentUtilization) {
313
313
  return calculateInterestRate(bank, delta, currentUtilization);
314
314
  }
315
315
  exports.calculateBorrowRate = calculateBorrowRate;
@@ -3,10 +3,4 @@ import { BN } from '../isomorphic/anchor';
3
3
  import { MarginCategory, SpotBalanceType, SpotMarketAccount } from '../types';
4
4
  export declare function castNumberToSpotPrecision(value: number | BN, spotMarket: SpotMarketAccount): BN;
5
5
  export declare function calculateSpotMarketMarginRatio(market: SpotMarketAccount, oraclePrice: BN, marginCategory: MarginCategory, size: BN, balanceType: SpotBalanceType, customMarginRatio?: number): number;
6
- /**
7
- * Returns the maximum remaining deposit that can be made to the spot market. If the maxTokenDeposits on the market is zero then there is no limit and this function will also return zero. (so that needs to be checked)
8
- * @param market
9
- * @returns
10
- */
11
- export declare function calculateMaxRemainingDeposit(market: SpotMarketAccount): BN;
12
6
  //# sourceMappingURL=spotMarket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spotMarket.d.ts","sourceRoot":"","sources":["../../../src/math/spotMarket.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAEN,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,MAAM,UAAU,CAAC;AASlB,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,MAAM,GAAG,EAAE,EAClB,UAAU,EAAE,iBAAiB,GAC3B,EAAE,CAMJ;AAED,wBAAgB,8BAA8B,CAC7C,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,EAAE,EACf,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,EAAE,EACR,WAAW,EAAE,eAAe,EAC5B,iBAAiB,SAAI,GACnB,MAAM,CA0BR;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,iBAAiB,MAerE"}
1
+ {"version":3,"file":"spotMarket.d.ts","sourceRoot":"","sources":["../../../src/math/spotMarket.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAEN,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,MAAM,UAAU,CAAC;AAKlB,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,MAAM,GAAG,EAAE,EAClB,UAAU,EAAE,iBAAiB,GAC3B,EAAE,CAMJ;AAED,wBAAgB,8BAA8B,CAC7C,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,EAAE,EACf,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,EAAE,EACR,WAAW,EAAE,eAAe,EAC5B,iBAAiB,SAAI,GACnB,MAAM,CA0BR"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateMaxRemainingDeposit = exports.calculateSpotMarketMarginRatio = exports.castNumberToSpotPrecision = void 0;
3
+ exports.calculateSpotMarketMarginRatio = exports.castNumberToSpotPrecision = void 0;
4
4
  const anchor_1 = require("../isomorphic/anchor");
5
5
  const types_1 = require("../types");
6
6
  const spotBalance_1 = require("./spotBalance");
@@ -32,18 +32,3 @@ function calculateSpotMarketMarginRatio(market, oraclePrice, marginCategory, siz
32
32
  return marginRatio;
33
33
  }
34
34
  exports.calculateSpotMarketMarginRatio = calculateSpotMarketMarginRatio;
35
- /**
36
- * Returns the maximum remaining deposit that can be made to the spot market. If the maxTokenDeposits on the market is zero then there is no limit and this function will also return zero. (so that needs to be checked)
37
- * @param market
38
- * @returns
39
- */
40
- function calculateMaxRemainingDeposit(market) {
41
- const marketMaxTokenDeposits = market.maxTokenDeposits;
42
- if (marketMaxTokenDeposits.eq(numericConstants_1.ZERO)) {
43
- // If the maxTokenDeposits is set to zero then that means there is no limit. Return the largest number we can to represent infinite available deposit.
44
- return numericConstants_1.ZERO;
45
- }
46
- const totalDepositsTokenAmount = (0, spotBalance_1.getTokenAmount)(market.depositBalance, market, types_1.SpotBalanceType.DEPOSIT);
47
- return marketMaxTokenDeposits.sub(totalDepositsTokenAmount);
48
- }
49
- exports.calculateMaxRemainingDeposit = calculateMaxRemainingDeposit;
@@ -9,12 +9,12 @@ export type OrderFillSimulation = {
9
9
  tokenValue: BN;
10
10
  weight: BN;
11
11
  weightedTokenValue: BN;
12
- freeCollateralContribution: any;
12
+ freeCollateralContribution: BN;
13
13
  };
14
- export declare function getWorstCaseTokenAmounts(spotPosition: SpotPosition, spotMarketAccount: SpotMarketAccount, strictOraclePrice: StrictOraclePrice, marginCategory: MarginCategory, customMarginRatio?: number, includeOpenOrders?: boolean): OrderFillSimulation;
15
- export declare function calculateWeightedTokenValue(tokenAmount: BN, tokenValue: BN, oraclePrice: BN, spotMarket: SpotMarketAccount, marginCategory: MarginCategory, customMarginRatio?: number): {
14
+ export declare function getWorstCaseTokenAmounts(spotPosition: SpotPosition, spotMarketAccount: SpotMarketAccount, strictOraclePrice: StrictOraclePrice, marginCategory: MarginCategory | undefined, customMarginRatio?: number, includeOpenOrders?: boolean): OrderFillSimulation;
15
+ export declare function calculateWeightedTokenValue(tokenAmount: BN, tokenValue: BN, oraclePrice: BN, spotMarket: SpotMarketAccount, marginCategory: MarginCategory | undefined, customMarginRatio?: number): {
16
16
  weight: BN;
17
17
  weightedTokenValue: BN;
18
18
  };
19
- export declare function simulateOrderFill(tokenAmount: BN, tokenValue: BN, openOrders: BN, strictOraclePrice: StrictOraclePrice, spotMarket: SpotMarketAccount, marginCategory: MarginCategory, customMarginRatio?: number): OrderFillSimulation;
19
+ export declare function simulateOrderFill(tokenAmount: BN, tokenValue: BN, openOrders: BN, strictOraclePrice: StrictOraclePrice, spotMarket: SpotMarketAccount, marginCategory: MarginCategory | undefined, customMarginRatio?: number): OrderFillSimulation;
20
20
  //# sourceMappingURL=spotPosition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spotPosition.d.ts","sourceRoot":"","sources":["../../../src/math/spotPosition.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAM3E,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAS1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAEvE;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,EAAE,CAAC;IAChB,UAAU,EAAE,EAAE,CAAC;IACf,MAAM,EA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C;IACf,MAAM,EAAE,EAAE,CAAC;IACX,kBAAkB,EAAE,EAAE,CAAC;IACvB,0BAA0B,EAAE,EAAE,CAAC;CAC/B,CAAC;AAEF,wBAAgB,wBAAwB,CACvC,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,iBAAiB,CAAC,EAAE,MAAM,EAC1B,iBAAiB,GAAE,OAAc,GAC/B,mBAAmB,CAkErB;AAED,wBAAgB,2BAA2B,CAC1C,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,iBAAiB,EAC7B,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,iBAAiB,CAAC,EAAE,MAAM,GACxB;IAAE,MAAM,EAAE,EAAE,CAAC;IAAC,kBAAkB,EAAE,EAAE,CAAA;CAAE,CAwCxC;AAED,wBAAgB,iBAAiB,CAChC,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EACd,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,iBAAiB,EAC7B,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,iBAAiB,CAAC,EAAE,MAAM,GACxB,mBAAmB,CA4BrB"}
@@ -4,6 +4,4 @@ import { StateAccount } from '../types';
4
4
  export declare function calculateInitUserFee(stateAccount: StateAccount): BN;
5
5
  export declare function getMaxNumberOfSubAccounts(stateAccount: StateAccount): BN;
6
6
  export declare function useMedianTriggerPrice(stateAccount: StateAccount): boolean;
7
- export declare function builderCodesEnabled(stateAccount: StateAccount): boolean;
8
- export declare function builderReferralEnabled(stateAccount: StateAccount): boolean;
9
7
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/math/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAM1C,OAAO,EAAmB,YAAY,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,EAAE,CAkBnE;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,EAAE,CAKxE;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAIzE;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAEvE;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAE1E"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/math/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAM1C,OAAO,EAAmB,YAAY,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,EAAE,CAkBnE;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,EAAE,CAKxE;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAIzE"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.builderReferralEnabled = exports.builderCodesEnabled = exports.useMedianTriggerPrice = exports.getMaxNumberOfSubAccounts = exports.calculateInitUserFee = void 0;
3
+ exports.useMedianTriggerPrice = exports.getMaxNumberOfSubAccounts = exports.calculateInitUserFee = void 0;
4
4
  const anchor_1 = require("../isomorphic/anchor");
5
5
  const numericConstants_1 = require("../constants/numericConstants");
6
6
  const types_1 = require("../types");
@@ -34,11 +34,3 @@ function useMedianTriggerPrice(stateAccount) {
34
34
  return ((stateAccount.featureBitFlags & types_1.FeatureBitFlags.MEDIAN_TRIGGER_PRICE) > 0);
35
35
  }
36
36
  exports.useMedianTriggerPrice = useMedianTriggerPrice;
37
- function builderCodesEnabled(stateAccount) {
38
- return (stateAccount.featureBitFlags & types_1.FeatureBitFlags.BUILDER_CODES) > 0;
39
- }
40
- exports.builderCodesEnabled = builderCodesEnabled;
41
- function builderReferralEnabled(stateAccount) {
42
- return (stateAccount.featureBitFlags & types_1.FeatureBitFlags.BUILDER_REFERRAL) > 0;
43
- }
44
- exports.builderReferralEnabled = builderReferralEnabled;
@@ -5,6 +5,7 @@ import { VelocityClient } from '../velocityClient';
5
5
  import { BN } from '../isomorphic/anchor';
6
6
  import { User } from '../user';
7
7
  import { DepositRecord } from '../types';
8
+ import fetch from 'node-fetch';
8
9
  export type BSOL_STATS_API_RESPONSE = {
9
10
  success: boolean;
10
11
  stats?: {
@@ -27,8 +28,8 @@ export type BSOL_EMISSIONS_API_RESPONSE = {
27
28
  lend: number;
28
29
  };
29
30
  };
30
- export declare function fetchBSolMetrics(): Promise<any>;
31
- export declare function fetchBSolVelocityEmissions(): Promise<any>;
31
+ export declare function fetchBSolMetrics(): Promise<fetch.Response>;
32
+ export declare function fetchBSolVelocityEmissions(): Promise<fetch.Response>;
32
33
  export declare function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, velocityClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }: {
33
34
  marketIndex: number;
34
35
  amount: BN;
@@ -107,57 +108,6 @@ export type JITO_SOL_METRICS_ENDPOINT_RESPONSE = {
107
108
  }[];
108
109
  };
109
110
  export declare function fetchJitoSolMetrics(): Promise<JITO_SOL_METRICS_ENDPOINT_RESPONSE>;
110
- export type MSOL_METRICS_ENDPOINT_RESPONSE = {
111
- total_active_balance: number;
112
- available_reserve_balance: number;
113
- emergency_cooling_down: number;
114
- tvl_sol: number;
115
- msol_directed_stake_sol: number;
116
- msol_directed_stake_msol: number;
117
- mnde_total_supply: number;
118
- mnde_circulating_supply: number;
119
- validators_count: number;
120
- stake_accounts: number;
121
- staking_sol_cap: number;
122
- m_sol_price: number;
123
- avg_staking_apy: number;
124
- msol_price_apy_14d: number;
125
- msol_price_apy_30d: number;
126
- msol_price_apy_90d: number;
127
- msol_price_apy_365d: number;
128
- reserve_pda: number;
129
- treasury_m_sol_amount: number;
130
- m_sol_mint_supply: number;
131
- m_sol_supply_state: number;
132
- liq_pool_sol: number;
133
- liq_pool_m_sol: number;
134
- liq_pool_value: number;
135
- liq_pool_token_supply: number;
136
- liq_pool_token_price: number;
137
- liq_pool_target: number;
138
- liq_pool_min_fee: number;
139
- liq_pool_max_fee: number;
140
- liq_pool_current_fee: number;
141
- liq_pool_treasury_cut: number;
142
- liq_pool_cap: number;
143
- total_cooling_down: number;
144
- last_stake_delta_epoch: number;
145
- circulating_ticket_count: number;
146
- circulating_ticket_balance: number;
147
- reward_fee_bp: number;
148
- lido_staking: number;
149
- lido_st_sol_price: number;
150
- lido_stsol_price_apy_14d: number;
151
- lido_stsol_price_apy_30d: number;
152
- lido_stsol_price_apy_90d: number;
153
- lido_stsol_price_apy_365d: number;
154
- stake_delta: number;
155
- bot_balance: number;
156
- treasury_farm_claim_mnde_balance: number;
157
- last_3_epochs_avg_duration_hs: number;
158
- mnde_votes_validators: number;
159
- };
160
- export declare const fetchMSolMetrics: () => Promise<MSOL_METRICS_ENDPOINT_RESPONSE>;
161
111
  export declare function calculateSolEarned({ marketIndex, user, depositRecords, }: {
162
112
  marketIndex: number;
163
113
  user: User;
@@ -1 +1 @@
1
- {"version":3,"file":"superStake.d.ts","sourceRoot":"","sources":["../../../src/math/superStake.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,yBAAyB,EAEzB,SAAS,EACT,sBAAsB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EA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BAAsB,EAAE,CAAC;IAC9B,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;CAC/B,CAAC,CAgBD;AAED,MAAM,MAAM,kCAAkC,GAAG;IAChD,GAAG,EAAE;QAEJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,MAAM,EAAE;QAEP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;CACJ,CAAC;AAkBF,wBAAsB,mBAAmB,gDAyBxC;AAoCD,wBAAsB,kBAAkB,CAAC,EACxC,WAAW,EACX,IAAI,EACJ,cAAc,GACd,EAAE;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,aAAa,EAAE,CAAC;CAChC,GAAG,OAAO,CAAC,EAAE,CAAC,CA6Fd;AAGD,wBAAgB,4CAA4C,CAC3D,gBAAgB,EAAE,MAAM,EACxB,yBAAyB,EAAE,MAAM,EACjC,eAAe,EAAE,MAAM,EACvB,6BAA6B,EAAE,MAAM,EACrC,aAAa,EAAE,MAAM,GACnB,MAAM,CAMR"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calculateEstimatedSuperStakeLiquidationPrice = exports.calculateSolEarned = exports.fetchMSolMetrics = exports.fetchJitoSolMetrics = exports.findBestLstSuperStakeIxs = exports.findBestJitoSolSuperStakeIxs = exports.findBestMSolSuperStakeIxs = exports.findBestSuperStakeIxs = exports.fetchBSolVelocityEmissions = exports.fetchBSolMetrics = void 0;
6
+ exports.calculateEstimatedSuperStakeLiquidationPrice = exports.calculateSolEarned = exports.fetchJitoSolMetrics = exports.findBestLstSuperStakeIxs = exports.findBestJitoSolSuperStakeIxs = exports.findBestMSolSuperStakeIxs = exports.findBestSuperStakeIxs = exports.fetchBSolVelocityEmissions = exports.fetchBSolMetrics = void 0;
7
7
  const web3_js_1 = require("@solana/web3.js");
8
8
  const marinade_1 = require("../marinade");
9
9
  const anchor_1 = require("../isomorphic/anchor");
@@ -45,7 +45,7 @@ async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, veloc
45
45
  else if (marketIndex === 8) {
46
46
  return findBestLstSuperStakeIxs({
47
47
  amount,
48
- lstMint: velocityClient.getSpotMarketAccount(8).mint,
48
+ lstMint: velocityClient.getSpotMarketAccountOrThrow(8).mint,
49
49
  lstMarketIndex: 8,
50
50
  jupiterClient,
51
51
  velocityClient,
@@ -64,8 +64,8 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient
64
64
  const marinadeProgram = (0, marinade_1.getMarinadeFinanceProgram)(velocityClient.provider);
65
65
  price = await (0, marinade_1.getMarinadeMSolPrice)(marinadeProgram);
66
66
  }
67
- const solSpotMarketAccount = velocityClient.getSpotMarketAccount(1);
68
- const mSolSpotMarketAccount = velocityClient.getSpotMarketAccount(2);
67
+ const solSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(1);
68
+ const mSolSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(2);
69
69
  let jupiterPrice;
70
70
  let quote = jupiterQuote;
71
71
  if (!jupiterQuote) {
@@ -77,7 +77,7 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient
77
77
  slippageBps: 1000,
78
78
  onlyDirectRoutes,
79
79
  });
80
- jupiterPrice = +quote.outAmount / +quote.inAmount;
80
+ jupiterPrice = +fetchedQuote.outAmount / +fetchedQuote.inAmount;
81
81
  quote = fetchedQuote;
82
82
  }
83
83
  catch (e) {
@@ -122,7 +122,7 @@ async function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, velocityCli
122
122
  velocityClient,
123
123
  userAccountPublicKey,
124
124
  onlyDirectRoutes,
125
- lstMint: velocityClient.getSpotMarketAccount(6).mint,
125
+ lstMint: velocityClient.getSpotMarketAccountOrThrow(6).mint,
126
126
  lstMarketIndex: 6,
127
127
  jupiterQuote,
128
128
  });
@@ -187,12 +187,6 @@ async function fetchJitoSolMetrics() {
187
187
  return data;
188
188
  }
189
189
  exports.fetchJitoSolMetrics = fetchJitoSolMetrics;
190
- const fetchMSolMetrics = async () => {
191
- const res = await (0, node_fetch_1.default)('https://api2.marinade.finance/metrics_json');
192
- const data = await res.json();
193
- return data;
194
- };
195
- exports.fetchMSolMetrics = fetchMSolMetrics;
196
190
  const getJitoSolHistoricalPriceMap = async (timestamps) => {
197
191
  try {
198
192
  const data = await fetchJitoSolMetrics();
@@ -258,7 +252,10 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
258
252
  await Promise.all(timestamps.map(getMsolPrice));
259
253
  }
260
254
  else if (marketIndex === 6) {
261
- lstRatios = await getJitoSolHistoricalPriceMap(timestamps);
255
+ const jitoSolRatios = await getJitoSolHistoricalPriceMap(timestamps);
256
+ if (jitoSolRatios) {
257
+ lstRatios = jitoSolRatios;
258
+ }
262
259
  }
263
260
  else if (marketIndex === 8) {
264
261
  await getBSolPrice(timestamps);
@@ -277,6 +274,9 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
277
274
  record.marketIndex === 6 ||
278
275
  record.marketIndex === 8) {
279
276
  const lstRatio = lstRatios.get(record.ts.toNumber());
277
+ if (lstRatio === undefined) {
278
+ throw new Error(`Missing LST/SOL ratio for deposit record at timestamp ${record.ts.toNumber()}`);
279
+ }
280
280
  const lstRatioBN = new anchor_1.BN(lstRatio * web3_js_1.LAMPORTS_PER_SOL);
281
281
  const solAmount = record.amount.mul(lstRatioBN).div(numericConstants_1.LAMPORTS_PRECISION);
282
282
  if ((0, types_1.isVariant)(record.direction, 'deposit')) {
@@ -289,6 +289,9 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
289
289
  }
290
290
  const currentLstTokenAmount = await user.getTokenAmount(marketIndex);
291
291
  const currentLstRatio = lstRatios.get(now);
292
+ if (currentLstRatio === undefined) {
293
+ throw new Error(`Missing current LST/SOL ratio for timestamp ${now}`);
294
+ }
292
295
  const currentLstRatioBN = new anchor_1.BN(currentLstRatio * web3_js_1.LAMPORTS_PER_SOL);
293
296
  solEarned = solEarned.add(currentLstTokenAmount.mul(currentLstRatioBN).div(numericConstants_1.LAMPORTS_PRECISION));
294
297
  const currentSOLTokenAmount = await user.getTokenAmount(1);
@@ -27,7 +27,7 @@ export type PriceImpactUnit = 'entryPrice' | 'maxPrice' | 'priceDelta' | 'priceD
27
27
  *
28
28
  * 'newPrice' => the price of the asset after the trade : Precision PRICE_PRECISION
29
29
  */
30
- export declare function calculateTradeSlippage(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN, BN];
30
+ export declare function calculateTradeSlippage(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType | undefined, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN, BN];
31
31
  /**
32
32
  * Calculates acquired amounts for trade executed
33
33
  * @param direction
@@ -39,7 +39,7 @@ export declare function calculateTradeSlippage(direction: PositionDirection, amo
39
39
  * | 'acquiredBase' => positive/negative change in user's base : BN AMM_RESERVE_PRECISION
40
40
  * | 'acquiredQuote' => positive/negative change in user's quote : BN TODO-PRECISION
41
41
  */
42
- export declare function calculateTradeAcquiredAmounts(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN];
42
+ export declare function calculateTradeAcquiredAmounts(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType | undefined, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN];
43
43
  /**
44
44
  * calculateTargetPriceTrade
45
45
  * simple function for finding arbitraging trades
@@ -1 +1 @@
1
- {"version":3,"file":"trade.d.ts","sourceRoot":"","sources":["../../../src/math/trade.ts"],"names":[],"mappings":";AAAA,OAAO,EAEN,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAe1C,OAAO,EAIN,SAAS,EAIT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,MAAM,MAAM,eAAe,GACxB,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,oBAAoB,GACpB,QAAQ,GACR,QAAQ,GACR,kBAAkB,GAClB,qBAAqB,GACrB,yBAAyB,GACzB,0BAA0B,GAC1B,KAAK,CAAC;AAET;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,EAAE,EACV,MAAM,EAAE,iBAAiB,EACzB,cAAc,EAAE,SAAmB,EACnC,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,UAAO,EAChB,UAAU,CAAC,EAAE,EAAE,GACb,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CA2ElB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAC5C,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,EAAE,EACV,MAAM,EAAE,iBAAiB,EACzB,cAAc,EAAE,SAAmB,EACnC,iBA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lippage(direction, amount, market, inputAssetType = 'quo
53
53
  .div(acquiredBaseReserve.abs());
54
54
  let amm;
55
55
  if (useSpread && market.amm.baseSpread > 0) {
56
- const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, market.totalExchangeFee, direction, mmOraclePriceData, latestSlot);
56
+ const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, latestSlot);
57
57
  amm = {
58
58
  baseAssetReserve,
59
59
  quoteAssetReserve,
@@ -102,7 +102,7 @@ function calculateTradeAcquiredAmounts(direction, amount, market, inputAssetType
102
102
  const swapDirection = (0, amm_1.getSwapDirection)(inputAssetType, direction);
103
103
  let amm;
104
104
  if (useSpread && market.amm.baseSpread > 0) {
105
- const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, market.totalExchangeFee, direction, mmOraclePriceData, latestSlot);
105
+ const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, latestSlot);
106
106
  amm = {
107
107
  baseAssetReserve,
108
108
  quoteAssetReserve,
@@ -166,7 +166,7 @@ function calculateTargetPriceTrade(market, targetPrice, pct = MAXPCT, outputAsse
166
166
  let quoteAssetReserveBefore;
167
167
  let peg = market.amm.pegMultiplier;
168
168
  if (useSpread && market.amm.baseSpread > 0) {
169
- const { baseAssetReserve, quoteAssetReserve, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, market.totalExchangeFee, direction, mmOraclePriceData, latestSlot);
169
+ const { baseAssetReserve, quoteAssetReserve, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, latestSlot);
170
170
  baseAssetReserveBefore = baseAssetReserve;
171
171
  quoteAssetReserveBefore = quoteAssetReserve;
172
172
  peg = newPeg;
@@ -239,7 +239,7 @@ function calculateTargetPriceTrade(market, targetPrice, pct = MAXPCT, outputAsse
239
239
  .mul(numericConstants_1.PRICE_PRECISION)
240
240
  .div(baseSize.abs());
241
241
  (0, assert_1.assert)(tp1.sub(tp2).lte(originalDiff), 'Target Price Calculation incorrect');
242
- (0, assert_1.assert)(tp2.lte(tp1) || tp2.sub(tp1).abs() < 100000, 'Target Price Calculation incorrect' +
242
+ (0, assert_1.assert)(tp2.lte(tp1) || tp2.sub(tp1).abs().ltn(100000), 'Target Price Calculation incorrect' +
243
243
  tp2.toString() +
244
244
  '>=' +
245
245
  tp1.toString() +
@@ -280,7 +280,7 @@ function calculateEstimatedPerpEntryPrice(assetType, amount, direction, market,
280
280
  const takerIsLong = (0, types_2.isVariant)(direction, 'long');
281
281
  const limitOrders = dlob[takerIsLong ? 'getRestingLimitAsks' : 'getRestingLimitBids'](market.marketIndex, slot, types_1.MarketType.PERP, mmOraclePriceData);
282
282
  const swapDirection = (0, amm_1.getSwapDirection)(assetType, direction);
283
- const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, market.totalExchangeFee, direction, mmOraclePriceData, new anchor_1.BN(slot));
283
+ const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, new anchor_1.BN(slot));
284
284
  const amm = {
285
285
  baseAssetReserve,
286
286
  quoteAssetReserve,
@@ -302,7 +302,7 @@ function calculateEstimatedPerpEntryPrice(assetType, amount, direction, market,
302
302
  let cumulativeQuoteFilled = numericConstants_1.ZERO;
303
303
  let limitOrder = limitOrders.next().value;
304
304
  if (limitOrder) {
305
- const limitOrderPrice = limitOrder.getPrice(mmOraclePriceData, slot);
305
+ const limitOrderPrice = limitOrder.getPriceOrThrow(mmOraclePriceData, slot);
306
306
  bestPrice = takerIsLong
307
307
  ? anchor_1.BN.min(limitOrderPrice, bestPrice)
308
308
  : anchor_1.BN.max(limitOrderPrice, bestPrice);
@@ -4,7 +4,6 @@ export declare function getNonIdleUserFilter(): MemcmpFilter;
4
4
  export declare function getUserWithOrderFilter(): MemcmpFilter;
5
5
  export declare function getUserWithoutOrderFilter(): MemcmpFilter;
6
6
  export declare function getUserWithAuctionFilter(): MemcmpFilter;
7
- export declare function getUserThatHasBeenLP(): MemcmpFilter;
8
7
  export declare function getUserWithName(name: string): MemcmpFilter;
9
8
  export declare function getUsersWithPoolId(poolId: number): MemcmpFilter;
10
9
  export declare function getUserStatsFilter(): MemcmpFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"memcmp.d.ts","sourceRoot":"","sources":["../../src/memcmp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK1D,wBAAgB,aAAa,IAAI,YAAY,CAO5C;AAED,wBAAgB,oBAAoB,IAAI,YAAY,CAOnD;AAED,wBAAgB,sBAAsB,IAAI,YAAY,CAOrD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CAOxD;AAED,wBAAgB,wBAAwB,IAAI,YAAY,CAOvD;AAED,wBAAgB,oBAAoB,IAAI,YAAY,CAOnD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAO1D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAO/D;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAOjD;AAED,wBAAgB,4BAA4B,IAAI,YAAY,CAO3D;AAED,wBAAgB,sCAAsC,IAAI,YAAY,CAOrE;AAED,wBAAgB,4BAA4B,IAAI,YAAY,CAS3D;AAED,wBAAgB,2BAA2B,IAAI,YAAY,CAO1D;AACD,wBAAgB,2BAA2B,IAAI,YAAY,CAO1D;AAED,wBAAgB,2BAA2B,IAAI,YAAY,CAS1D;AAED,wBAAgB,oBAAoB,IAAI,YAAY,CASnD;AAED,wBAAgB,0BAA0B,CACzC,eAAe,EAAE,SAAS,GACxB,YAAY,CAOd"}
1
+ {"version":3,"file":"memcmp.d.ts","sourceRoot":"","sources":["../../src/memcmp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK1D,wBAAgB,aAAa,IAAI,YAAY,CAO5C;AAED,wBAAgB,oBAAoB,IAAI,YAAY,CAOnD;AAED,wBAAgB,sBAAsB,IAAI,YAAY,CAOrD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CAOxD;AAED,wBAAgB,wBAAwB,IAAI,YAAY,CAOvD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAO1D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAO/D;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAOjD;AAED,wBAAgB,4BAA4B,IAAI,YAAY,CAO3D;AAED,wBAAgB,sCAAsC,IAAI,YAAY,CAOrE;AAED,wBAAgB,4BAA4B,IAAI,YAAY,CAS3D;AAED,wBAAgB,2BAA2B,IAAI,YAAY,CAO1D;AACD,wBAAgB,2BAA2B,IAAI,YAAY,CAO1D;AAED,wBAAgB,2BAA2B,IAAI,YAAY,CAS1D;AAED,wBAAgB,oBAAoB,IAAI,YAAY,CASnD;AAED,wBAAgB,0BAA0B,CACzC,eAAe,EAAE,SAAS,GACxB,YAAY,CAOd"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getConstituentLpPoolFilter = exports.getConstituentFilter = exports.getRevenueShareEscrowFilter = exports.getSpotMarketAccountsFilter = exports.getPerpMarketAccountsFilter = exports.getSignedMsgUserOrdersFilter = exports.getUserStatsIsReferredOrReferrerFilter = exports.getUserStatsIsReferredFilter = exports.getUserStatsFilter = exports.getUsersWithPoolId = exports.getUserWithName = exports.getUserThatHasBeenLP = exports.getUserWithAuctionFilter = exports.getUserWithoutOrderFilter = exports.getUserWithOrderFilter = exports.getNonIdleUserFilter = exports.getUserFilter = void 0;
6
+ exports.getConstituentLpPoolFilter = exports.getConstituentFilter = exports.getRevenueShareEscrowFilter = exports.getSpotMarketAccountsFilter = exports.getPerpMarketAccountsFilter = exports.getSignedMsgUserOrdersFilter = exports.getUserStatsIsReferredOrReferrerFilter = exports.getUserStatsIsReferredFilter = exports.getUserStatsFilter = exports.getUsersWithPoolId = exports.getUserWithName = exports.getUserWithAuctionFilter = exports.getUserWithoutOrderFilter = exports.getUserWithOrderFilter = exports.getNonIdleUserFilter = exports.getUserFilter = void 0;
7
7
  const bs58_1 = __importDefault(require("bs58"));
8
8
  const anchor29_1 = require("./isomorphic/anchor29");
9
9
  const userName_1 = require("./userName");
@@ -52,15 +52,6 @@ function getUserWithAuctionFilter() {
52
52
  };
53
53
  }
54
54
  exports.getUserWithAuctionFilter = getUserWithAuctionFilter;
55
- function getUserThatHasBeenLP() {
56
- return {
57
- memcmp: {
58
- offset: 4267,
59
- bytes: bs58_1.default.encode(Uint8Array.from([99])),
60
- },
61
- };
62
- }
63
- exports.getUserThatHasBeenLP = getUserThatHasBeenLP;
64
55
  function getUserWithName(name) {
65
56
  return {
66
57
  memcmp: {
@@ -5,6 +5,6 @@ import { VelocityProgram } from '../config';
5
5
  export declare class OracleClientCache {
6
6
  cache: Map<string, OracleClient>;
7
7
  constructor();
8
- get(oracleSource: OracleSource, connection: Connection, program: VelocityProgram): OracleClient;
8
+ get(oracleSource: OracleSource, connection: Connection, program: VelocityProgram): OracleClient | undefined;
9
9
  }
10
10
  //# sourceMappingURL=oracleClientCache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prelaunchOracleClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/prelaunchOracleClient.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,qBAAa,qBAAsB,YAAW,YAAY;IACzD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAkB;gBAEd,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe;IAKtD,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IAKpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAgBpE"}
1
+ {"version":3,"file":"prelaunchOracleClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/prelaunchOracleClient.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAI5C,qBAAa,qBAAsB,YAAW,YAAY;IACzD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAkB;gBAEd,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe;IAKtD,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IASpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAgBpE"}
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PrelaunchOracleClient = void 0;
4
+ const utils_1 = require("./utils");
4
5
  class PrelaunchOracleClient {
5
6
  constructor(connection, program) {
6
7
  this.connection = connection;
7
8
  this.program = program;
8
9
  }
9
10
  async getOraclePriceData(pricePublicKey) {
10
- const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
11
- return this.getOraclePriceDataFromBuffer(accountInfo.data);
11
+ const data = await (0, utils_1.getOracleAccountDataOrThrow)(this.connection, pricePublicKey, 'Prelaunch oracle');
12
+ return this.getOraclePriceDataFromBuffer(data);
12
13
  }
13
14
  getOraclePriceDataFromBuffer(buffer) {
14
15
  const prelaunchOracle = this.program.account.prelaunchOracle.coder.accounts.decodeUnchecked('prelaunchOracle', buffer);
@@ -1 +1 @@
1
- {"version":3,"file":"pythClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/pythClient.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAQ1C,qBAAa,UAAW,YAAW,YAAY;IAC9C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAU;gBAG3B,UAAU,EAAE,UAAU,EACtB,QAAQ,KAAM,EACd,UAAU,UAAQ;IAON,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IAKpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAkCpE"}
1
+ {"version":3,"file":"pythClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/pythClient.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAS1C,qBAAa,UAAW,YAAW,YAAY;IAC9C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAU;gBAG3B,UAAU,EAAE,UAAU,EACtB,QAAQ,KAAM,EACd,UAAU,UAAQ;IAON,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IASpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAsCpE"}
@@ -4,6 +4,7 @@ exports.PythClient = void 0;
4
4
  const client_1 = require("@pythnetwork/client");
5
5
  const anchor_1 = require("../isomorphic/anchor");
6
6
  const numericConstants_1 = require("../constants/numericConstants");
7
+ const utils_1 = require("./utils");
7
8
  class PythClient {
8
9
  constructor(connection, multiple = numericConstants_1.ONE, stableCoin = false) {
9
10
  this.connection = connection;
@@ -11,12 +12,17 @@ class PythClient {
11
12
  this.stableCoin = stableCoin;
12
13
  }
13
14
  async getOraclePriceData(pricePublicKey) {
14
- const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
15
- return this.getOraclePriceDataFromBuffer(accountInfo.data);
15
+ const data = await (0, utils_1.getOracleAccountDataOrThrow)(this.connection, pricePublicKey, 'Pyth oracle');
16
+ return this.getOraclePriceDataFromBuffer(data);
16
17
  }
17
18
  getOraclePriceDataFromBuffer(buffer) {
19
+ var _a;
18
20
  const priceData = (0, client_1.parsePriceData)(buffer);
19
- const confidence = convertPythPrice(priceData.confidence, priceData.exponent, this.multiple);
21
+ // `confidence` is absent on uninitialized/invalid price accounts. Base passed it
22
+ // straight into convertPythPrice, where `undefined * 10**exponent` is `NaN` and
23
+ // `new BN(NaN)` coerces to 0 — so base already yielded a zero-confidence price.
24
+ // `?? 0` makes that explicit and type-checks, preserving the same result.
25
+ const confidence = convertPythPrice((_a = priceData.confidence) !== null && _a !== void 0 ? _a : 0, priceData.exponent, this.multiple);
20
26
  const minPublishers = Math.min(priceData.numComponentPrices, 3);
21
27
  let price = convertPythPrice(priceData.aggregate.price, priceData.exponent, this.multiple);
22
28
  if (this.stableCoin) {
@@ -1 +1 @@
1
- {"version":3,"file":"pythLazerClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/pythLazerClient.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAW,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAkB,EAAE,EAAW,MAAM,sBAAsB,CAAC;AAYnE,qBAAa,eAAgB,YAAW,YAAY;IACnD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,OAAO,CAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;gBAGxD,UAAU,EAAE,UAAU,EACtB,QAAQ,KAAM,EACd,UAAU,UAAQ;IAqBN,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IAKpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAkCpE"}
1
+ {"version":3,"file":"pythLazerClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/pythLazerClient.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAW,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAkB,EAAE,EAAW,MAAM,sBAAsB,CAAC;AAanE,qBAAa,eAAgB,YAAW,YAAY;IACnD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,OAAO,CAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;gBAGxD,UAAU,EAAE,UAAU,EACtB,QAAQ,KAAM,EACd,UAAU,UAAQ;IAqBN,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IASpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAkCpE"}
@@ -9,6 +9,7 @@ const anchor_1 = require("../isomorphic/anchor");
9
9
  const numericConstants_1 = require("../constants/numericConstants");
10
10
  const wallet_1 = require("../wallet");
11
11
  const velocity_json_1 = __importDefault(require("../idl/velocity.json"));
12
+ const utils_1 = require("./utils");
12
13
  class PythLazerClient {
13
14
  constructor(connection, multiple = numericConstants_1.ONE, stableCoin = false) {
14
15
  this.connection = connection;
@@ -23,8 +24,8 @@ class PythLazerClient {
23
24
  this.decodeFunc = this.program.account.pythLazerOracle.coder.accounts.decodeUnchecked.bind(this.program.account.pythLazerOracle.coder.accounts);
24
25
  }
25
26
  async getOraclePriceData(pricePublicKey) {
26
- const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
27
- return this.getOraclePriceDataFromBuffer(accountInfo.data);
27
+ const data = await (0, utils_1.getOracleAccountDataOrThrow)(this.connection, pricePublicKey, 'Pyth lazer oracle');
28
+ return this.getOraclePriceDataFromBuffer(data);
28
29
  }
29
30
  getOraclePriceDataFromBuffer(buffer) {
30
31
  const priceData = this.decodeFunc('pythLazerOracle', buffer);
@@ -1,5 +1,9 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  /// <reference types="bn.js" />
4
+ import { Connection, PublicKey } from '@solana/web3.js';
2
5
  import { BN } from '../isomorphic/anchor';
3
6
  import { OraclePriceData } from './types';
7
+ export declare function getOracleAccountDataOrThrow(connection: Connection, pricePublicKey: PublicKey, oracleName: string): Promise<Buffer>;
4
8
  export declare function getOracleConfidenceFromMMOracleData(mmOraclePrice: BN, oraclePriceData: OraclePriceData): BN;
5
9
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/oracles/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,mCAAmC,CAClD,aAAa,EAAE,EAAE,EACjB,eAAe,EAAE,eAAe,GAC9B,EAAE,CAGJ"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/oracles/utils.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAsB,2BAA2B,CAChD,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,SAAS,EACzB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAgB,mCAAmC,CAClD,aAAa,EAAE,EAAE,EACjB,eAAe,EAAE,eAAe,GAC9B,EAAE,CAGJ"}
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOracleConfidenceFromMMOracleData = void 0;
3
+ exports.getOracleConfidenceFromMMOracleData = exports.getOracleAccountDataOrThrow = void 0;
4
+ async function getOracleAccountDataOrThrow(connection, pricePublicKey, oracleName) {
5
+ const accountInfo = await connection.getAccountInfo(pricePublicKey);
6
+ if (!accountInfo) {
7
+ throw new Error(`${oracleName} account not found: ${pricePublicKey.toBase58()}`);
8
+ }
9
+ return accountInfo.data;
10
+ }
11
+ exports.getOracleAccountDataOrThrow = getOracleAccountDataOrThrow;
4
12
  function getOracleConfidenceFromMMOracleData(mmOraclePrice, oraclePriceData) {
5
13
  const mmOracleDiffPremium = mmOraclePrice.sub(oraclePriceData.price).abs();
6
14
  return oraclePriceData.confidence.add(mmOracleDiffPremium);
@@ -22,7 +22,7 @@ export declare class OrderSubscriber {
22
22
  commitment: Commitment;
23
23
  eventEmitter: StrictEventEmitter<EventEmitter, OrderSubscriberEvents>;
24
24
  fetchPromise?: Promise<void>;
25
- fetchPromiseResolver: () => void;
25
+ private fetchPromiseResolver;
26
26
  mostRecentSlot: number;
27
27
  decodeFn: (name: string, data: Buffer) => UserAccount;
28
28
  decodeData?: boolean;