@velocity-exchange/sdk 0.3.0 → 0.4.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 (1046) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +18 -0
  3. package/lib/browser/accounts/basicUserAccountSubscriber.js +18 -0
  4. package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
  5. package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +18 -0
  6. package/lib/browser/accounts/bulkAccountLoader.d.ts +52 -0
  7. package/lib/browser/accounts/bulkAccountLoader.js +51 -0
  8. package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +9 -2
  9. package/lib/browser/accounts/bulkUserStatsSubscription.js +9 -2
  10. package/lib/browser/accounts/bulkUserSubscription.d.ts +8 -2
  11. package/lib/browser/accounts/bulkUserSubscription.js +8 -2
  12. package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
  13. package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +37 -0
  14. package/lib/browser/accounts/fetch.d.ts +59 -2
  15. package/lib/browser/accounts/fetch.js +57 -2
  16. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +30 -0
  17. package/lib/browser/accounts/grpcAccountSubscriber.js +30 -0
  18. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
  19. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
  20. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
  21. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +118 -37
  22. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
  23. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +40 -12
  24. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
  25. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +33 -0
  26. package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +15 -0
  27. package/lib/browser/accounts/grpcUserAccountSubscriber.js +15 -0
  28. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
  29. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +15 -0
  30. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
  31. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
  32. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
  33. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
  34. package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +34 -0
  35. package/lib/browser/accounts/laserProgramAccountSubscriber.js +34 -0
  36. package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
  37. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +19 -0
  38. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
  39. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
  40. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
  41. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
  42. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
  43. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +21 -2
  44. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
  45. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +22 -0
  46. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +32 -0
  47. package/lib/browser/accounts/pollingUserAccountSubscriber.js +32 -0
  48. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
  49. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +22 -0
  50. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
  51. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
  52. package/lib/browser/accounts/testBulkAccountLoader.d.ts +8 -0
  53. package/lib/browser/accounts/testBulkAccountLoader.js +8 -0
  54. package/lib/browser/accounts/types.d.ts +149 -0
  55. package/lib/browser/accounts/types.js +13 -0
  56. package/lib/browser/accounts/utils.d.ts +18 -0
  57. package/lib/browser/accounts/utils.js +32 -16
  58. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +41 -0
  59. package/lib/browser/accounts/webSocketAccountSubscriber.js +41 -0
  60. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
  61. package/lib/browser/accounts/webSocketAccountSubscriberV2.js +31 -23
  62. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
  63. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
  64. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
  65. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +36 -0
  66. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
  67. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
  68. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
  69. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
  70. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
  71. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +26 -0
  72. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
  73. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
  74. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
  75. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
  76. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
  77. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
  78. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
  79. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +33 -0
  80. package/lib/browser/addresses/marketAddresses.d.ts +10 -0
  81. package/lib/browser/addresses/marketAddresses.js +10 -0
  82. package/lib/browser/addresses/pda.d.ts +214 -2
  83. package/lib/browser/addresses/pda.js +217 -5
  84. package/lib/browser/adminClient.d.ts +2136 -4
  85. package/lib/browser/adminClient.js +2150 -4
  86. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +15 -0
  87. package/lib/browser/auctionSubscriber/auctionSubscriber.js +15 -0
  88. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
  89. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
  90. package/lib/browser/auctionSubscriber/index.d.ts +6 -0
  91. package/lib/browser/auctionSubscriber/index.js +6 -0
  92. package/lib/browser/auctionSubscriber/types.d.ts +7 -0
  93. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
  94. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +33 -0
  95. package/lib/browser/blockhashSubscriber/index.d.ts +5 -0
  96. package/lib/browser/blockhashSubscriber/index.js +5 -0
  97. package/lib/browser/blockhashSubscriber/types.d.ts +5 -0
  98. package/lib/browser/clock/clockSubscriber.d.ts +24 -0
  99. package/lib/browser/clock/clockSubscriber.js +22 -0
  100. package/lib/browser/config.d.ts +58 -4
  101. package/lib/browser/config.js +88 -21
  102. package/lib/browser/constants/numericConstants.d.ts +67 -0
  103. package/lib/browser/constants/numericConstants.js +68 -1
  104. package/lib/browser/constants/perpMarkets.d.ts +10 -0
  105. package/lib/browser/constants/perpMarkets.js +40 -908
  106. package/lib/browser/constants/spotMarkets.d.ts +13 -0
  107. package/lib/browser/constants/spotMarkets.js +16 -742
  108. package/lib/browser/constants/txConstants.d.ts +1 -0
  109. package/lib/browser/constants/txConstants.js +1 -0
  110. package/lib/browser/core/VelocityCore.d.ts +285 -8
  111. package/lib/browser/core/VelocityCore.js +281 -8
  112. package/lib/browser/core/instructions/deposit.d.ts +22 -0
  113. package/lib/browser/core/instructions/deposit.js +22 -0
  114. package/lib/browser/core/instructions/fill.d.ts +17 -0
  115. package/lib/browser/core/instructions/fill.js +17 -0
  116. package/lib/browser/core/instructions/funding.d.ts +12 -0
  117. package/lib/browser/core/instructions/funding.js +12 -0
  118. package/lib/browser/core/instructions/liquidation.d.ts +18 -0
  119. package/lib/browser/core/instructions/liquidation.js +18 -0
  120. package/lib/browser/core/instructions/orders.d.ts +28 -0
  121. package/lib/browser/core/instructions/orders.js +28 -0
  122. package/lib/browser/core/instructions/perpOrders.d.ts +106 -0
  123. package/lib/browser/core/instructions/perpOrders.js +106 -0
  124. package/lib/browser/core/instructions/settlement.d.ts +14 -0
  125. package/lib/browser/core/instructions/settlement.js +14 -0
  126. package/lib/browser/core/instructions/trigger.d.ts +15 -0
  127. package/lib/browser/core/instructions/trigger.js +15 -0
  128. package/lib/browser/core/instructions/withdraw.d.ts +21 -0
  129. package/lib/browser/core/instructions/withdraw.js +21 -0
  130. package/lib/browser/core/remainingAccounts.d.ts +47 -3
  131. package/lib/browser/core/remainingAccounts.js +20 -0
  132. package/lib/browser/core/signedMsg.d.ts +38 -0
  133. package/lib/browser/core/signedMsg.js +33 -0
  134. package/lib/browser/decode/customCoder.d.ts +39 -3
  135. package/lib/browser/decode/customCoder.js +45 -3
  136. package/lib/browser/decode/user.d.ts +22 -0
  137. package/lib/browser/decode/user.js +22 -0
  138. package/lib/browser/dlob/DLOB.d.ts +502 -53
  139. package/lib/browser/dlob/DLOB.js +540 -98
  140. package/lib/browser/dlob/DLOBNode.d.ts +86 -4
  141. package/lib/browser/dlob/DLOBNode.js +37 -4
  142. package/lib/browser/dlob/DLOBSubscriber.d.ts +39 -12
  143. package/lib/browser/dlob/DLOBSubscriber.js +42 -12
  144. package/lib/browser/dlob/NodeList.d.ts +69 -0
  145. package/lib/browser/dlob/NodeList.js +66 -0
  146. package/lib/browser/dlob/orderBookLevels.d.ts +106 -13
  147. package/lib/browser/dlob/orderBookLevels.js +84 -14
  148. package/lib/browser/dlob/types.d.ts +15 -0
  149. package/lib/browser/events/eventList.d.ts +14 -0
  150. package/lib/browser/events/eventList.js +14 -0
  151. package/lib/browser/events/eventSubscriber.d.ts +87 -10
  152. package/lib/browser/events/eventSubscriber.js +93 -8
  153. package/lib/browser/events/eventsServerLogProvider.d.ts +22 -0
  154. package/lib/browser/events/eventsServerLogProvider.js +27 -0
  155. package/lib/browser/events/fetchLogs.d.ts +31 -0
  156. package/lib/browser/events/fetchLogs.js +46 -1
  157. package/lib/browser/events/parse.d.ts +23 -0
  158. package/lib/browser/events/parse.js +23 -0
  159. package/lib/browser/events/pollingLogProvider.d.ts +24 -0
  160. package/lib/browser/events/pollingLogProvider.js +24 -0
  161. package/lib/browser/events/sort.d.ts +11 -0
  162. package/lib/browser/events/sort.js +12 -0
  163. package/lib/browser/events/txEventCache.d.ts +13 -3
  164. package/lib/browser/events/txEventCache.js +19 -7
  165. package/lib/browser/events/types.d.ts +118 -2
  166. package/lib/browser/events/types.js +11 -0
  167. package/lib/browser/events/webSocketLogProvider.d.ts +23 -0
  168. package/lib/browser/events/webSocketLogProvider.js +28 -0
  169. package/lib/browser/factory/oracleClient.js +2 -2
  170. package/lib/browser/idl/velocity.d.ts +4 -4
  171. package/lib/browser/idl/velocity.json +4 -4
  172. package/lib/browser/keypair.d.ts +8 -0
  173. package/lib/browser/keypair.js +8 -0
  174. package/lib/browser/marginCalculation.d.ts +134 -2
  175. package/lib/browser/marginCalculation.js +121 -0
  176. package/lib/browser/math/amm.d.ts +348 -29
  177. package/lib/browser/math/amm.js +310 -32
  178. package/lib/browser/math/auction.d.ts +95 -19
  179. package/lib/browser/math/auction.js +118 -28
  180. package/lib/browser/math/bankruptcy.d.ts +46 -0
  181. package/lib/browser/math/bankruptcy.js +89 -1
  182. package/lib/browser/math/builder.d.ts +64 -8
  183. package/lib/browser/math/builder.js +71 -9
  184. package/lib/browser/math/conversion.d.ts +21 -0
  185. package/lib/browser/math/conversion.js +21 -0
  186. package/lib/browser/math/exchangeStatus.d.ts +91 -0
  187. package/lib/browser/math/exchangeStatus.js +106 -3
  188. package/lib/browser/math/funding.d.ts +57 -20
  189. package/lib/browser/math/funding.js +63 -23
  190. package/lib/browser/math/insurance.d.ts +62 -0
  191. package/lib/browser/math/insurance.js +62 -0
  192. package/lib/browser/math/liquidation.d.ts +127 -11
  193. package/lib/browser/math/liquidation.js +182 -19
  194. package/lib/browser/math/margin.d.ts +79 -13
  195. package/lib/browser/math/margin.js +80 -14
  196. package/lib/browser/math/market.d.ts +135 -15
  197. package/lib/browser/math/market.js +145 -17
  198. package/lib/browser/math/oracles.d.ts +113 -0
  199. package/lib/browser/math/oracles.js +118 -1
  200. package/lib/browser/math/orders.d.ts +115 -10
  201. package/lib/browser/math/orders.js +130 -19
  202. package/lib/browser/math/position.d.ts +80 -33
  203. package/lib/browser/math/position.js +80 -33
  204. package/lib/browser/math/repeg.d.ts +48 -10
  205. package/lib/browser/math/repeg.js +48 -10
  206. package/lib/browser/math/spotBalance.d.ts +200 -5
  207. package/lib/browser/math/spotBalance.js +239 -10
  208. package/lib/browser/math/spotMarket.d.ts +36 -3
  209. package/lib/browser/math/spotMarket.js +36 -3
  210. package/lib/browser/math/spotPosition.d.ts +72 -0
  211. package/lib/browser/math/spotPosition.js +62 -0
  212. package/lib/browser/math/state.d.ts +31 -0
  213. package/lib/browser/math/state.js +31 -0
  214. package/lib/browser/math/superStake.d.ts +126 -2
  215. package/lib/browser/math/superStake.js +123 -3
  216. package/lib/browser/math/tiers.d.ts +29 -0
  217. package/lib/browser/math/tiers.js +29 -0
  218. package/lib/browser/math/trade.d.ts +102 -51
  219. package/lib/browser/math/trade.js +101 -55
  220. package/lib/browser/math/utils.d.ts +71 -9
  221. package/lib/browser/math/utils.js +71 -9
  222. package/lib/browser/memcmp.d.ts +94 -0
  223. package/lib/browser/memcmp.js +103 -2
  224. package/lib/browser/oracles/oracleClientCache.d.ts +16 -0
  225. package/lib/browser/oracles/oracleClientCache.js +16 -0
  226. package/lib/browser/oracles/oracleId.d.ts +31 -0
  227. package/lib/browser/oracles/oracleId.js +39 -8
  228. package/lib/browser/oracles/prelaunchOracleClient.d.ts +20 -0
  229. package/lib/browser/oracles/prelaunchOracleClient.js +20 -0
  230. package/lib/browser/oracles/pythClient.d.ts +31 -0
  231. package/lib/browser/oracles/pythClient.js +32 -1
  232. package/lib/browser/oracles/pythLazerClient.d.ts +34 -0
  233. package/lib/browser/oracles/pythLazerClient.js +35 -1
  234. package/lib/browser/oracles/quoteAssetOracleClient.d.ts +18 -0
  235. package/lib/browser/oracles/quoteAssetOracleClient.js +18 -0
  236. package/lib/browser/oracles/strictOraclePrice.d.ts +21 -0
  237. package/lib/browser/oracles/strictOraclePrice.js +21 -0
  238. package/lib/browser/oracles/types.d.ts +45 -0
  239. package/lib/browser/oracles/utils.d.ts +20 -0
  240. package/lib/browser/oracles/utils.js +20 -0
  241. package/lib/browser/orderParams.d.ts +42 -4
  242. package/lib/browser/orderParams.js +42 -4
  243. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +56 -0
  244. package/lib/browser/orderSubscriber/OrderSubscriber.js +56 -0
  245. package/lib/browser/orderSubscriber/PollingSubscription.d.ts +11 -0
  246. package/lib/browser/orderSubscriber/PollingSubscription.js +11 -0
  247. package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +18 -0
  248. package/lib/browser/orderSubscriber/WebsocketSubscription.js +18 -0
  249. package/lib/browser/orderSubscriber/grpcSubscription.d.ts +16 -0
  250. package/lib/browser/orderSubscriber/grpcSubscription.js +16 -0
  251. package/lib/browser/orderSubscriber/types.d.ts +9 -0
  252. package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
  253. package/lib/browser/priorityFee/averageOverSlotsStrategy.js +1 -0
  254. package/lib/browser/priorityFee/averageStrategy.d.ts +1 -0
  255. package/lib/browser/priorityFee/averageStrategy.js +1 -0
  256. package/lib/browser/priorityFee/ewmaStrategy.d.ts +10 -0
  257. package/lib/browser/priorityFee/ewmaStrategy.js +10 -0
  258. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
  259. package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +9 -2
  260. package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
  261. package/lib/browser/priorityFee/maxOverSlotsStrategy.js +1 -0
  262. package/lib/browser/priorityFee/maxStrategy.d.ts +1 -0
  263. package/lib/browser/priorityFee/maxStrategy.js +1 -0
  264. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +39 -0
  265. package/lib/browser/priorityFee/priorityFeeSubscriber.js +39 -0
  266. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
  267. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +21 -2
  268. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
  269. package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +10 -0
  270. package/lib/browser/priorityFee/types.d.ts +32 -0
  271. package/lib/browser/priorityFee/types.js +5 -0
  272. package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
  273. package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +8 -0
  274. package/lib/browser/slot/SlotSubscriber.d.ts +18 -0
  275. package/lib/browser/slot/SlotSubscriber.js +16 -0
  276. package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
  277. package/lib/browser/slot/SlothashSubscriber.js +25 -1
  278. package/lib/browser/tx/baseTxSender.d.ts +163 -0
  279. package/lib/browser/tx/baseTxSender.js +174 -6
  280. package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
  281. package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
  282. package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
  283. package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
  284. package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
  285. package/lib/browser/tx/fastSingleTxSender.d.ts +47 -0
  286. package/lib/browser/tx/fastSingleTxSender.js +48 -1
  287. package/lib/browser/tx/forwardOnlyTxSender.d.ts +48 -0
  288. package/lib/browser/tx/forwardOnlyTxSender.js +48 -0
  289. package/lib/browser/tx/reportTransactionError.d.ts +18 -6
  290. package/lib/browser/tx/reportTransactionError.js +18 -6
  291. package/lib/browser/tx/retryTxSender.d.ts +40 -0
  292. package/lib/browser/tx/retryTxSender.js +39 -0
  293. package/lib/browser/tx/txHandler.d.ts +146 -35
  294. package/lib/browser/tx/txHandler.js +132 -32
  295. package/lib/browser/tx/txParamProcessor.d.ts +47 -0
  296. package/lib/browser/tx/txParamProcessor.js +47 -0
  297. package/lib/browser/tx/types.d.ts +46 -0
  298. package/lib/browser/tx/types.js +5 -0
  299. package/lib/browser/tx/utils.d.ts +26 -0
  300. package/lib/browser/tx/utils.js +26 -0
  301. package/lib/browser/tx/whileValidTxSender.d.ts +82 -0
  302. package/lib/browser/tx/whileValidTxSender.js +81 -0
  303. package/lib/browser/types.d.ts +781 -13
  304. package/lib/browser/types.js +126 -9
  305. package/lib/browser/user.d.ts +645 -84
  306. package/lib/browser/user.js +779 -96
  307. package/lib/browser/userMap/PollingSubscription.d.ts +10 -0
  308. package/lib/browser/userMap/PollingSubscription.js +14 -2
  309. package/lib/browser/userMap/WebsocketSubscription.d.ts +9 -0
  310. package/lib/browser/userMap/WebsocketSubscription.js +9 -0
  311. package/lib/browser/userMap/grpcSubscription.d.ts +8 -0
  312. package/lib/browser/userMap/grpcSubscription.js +8 -0
  313. package/lib/browser/userMap/referrerMap.d.ts +72 -2
  314. package/lib/browser/userMap/referrerMap.js +84 -2
  315. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +37 -10
  316. package/lib/browser/userMap/revenueShareEscrowMap.js +38 -11
  317. package/lib/browser/userMap/userMap.d.ts +81 -3
  318. package/lib/browser/userMap/userMap.js +81 -4
  319. package/lib/browser/userMap/userMapConfig.d.ts +23 -0
  320. package/lib/browser/userMap/userStatsMap.d.ts +22 -0
  321. package/lib/browser/userMap/userStatsMap.js +22 -0
  322. package/lib/browser/userName.d.ts +16 -0
  323. package/lib/browser/userName.js +16 -0
  324. package/lib/browser/userStats.d.ts +28 -1
  325. package/lib/browser/userStats.js +28 -1
  326. package/lib/browser/util/TransactionConfirmationManager.d.ts +33 -0
  327. package/lib/browser/util/TransactionConfirmationManager.js +33 -0
  328. package/lib/browser/util/chainClock.d.ts +24 -0
  329. package/lib/browser/util/chainClock.js +20 -0
  330. package/lib/browser/util/computeUnits.d.ts +32 -0
  331. package/lib/browser/util/computeUnits.js +32 -0
  332. package/lib/browser/util/digest.d.ts +17 -0
  333. package/lib/browser/util/digest.js +17 -0
  334. package/lib/browser/util/ed25519Utils.d.ts +12 -2
  335. package/lib/browser/util/ed25519Utils.js +12 -2
  336. package/lib/browser/util/promiseTimeout.d.ts +9 -0
  337. package/lib/browser/util/promiseTimeout.js +9 -0
  338. package/lib/browser/velocityClient.d.ts +3322 -215
  339. package/lib/browser/velocityClient.js +3412 -245
  340. package/lib/browser/wallet.d.ts +37 -0
  341. package/lib/browser/wallet.js +37 -0
  342. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +18 -0
  343. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
  344. package/lib/node/accounts/basicUserAccountSubscriber.js +18 -0
  345. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
  346. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
  347. package/lib/node/accounts/basicUserStatsAccountSubscriber.js +18 -0
  348. package/lib/node/accounts/bulkAccountLoader.d.ts +52 -0
  349. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
  350. package/lib/node/accounts/bulkAccountLoader.js +51 -0
  351. package/lib/node/accounts/bulkUserStatsSubscription.d.ts +9 -2
  352. package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -1
  353. package/lib/node/accounts/bulkUserStatsSubscription.js +9 -2
  354. package/lib/node/accounts/bulkUserSubscription.d.ts +8 -2
  355. package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -1
  356. package/lib/node/accounts/bulkUserSubscription.js +8 -2
  357. package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
  358. package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -1
  359. package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +37 -0
  360. package/lib/node/accounts/fetch.d.ts +59 -2
  361. package/lib/node/accounts/fetch.d.ts.map +1 -1
  362. package/lib/node/accounts/fetch.js +57 -2
  363. package/lib/node/accounts/grpcAccountSubscriber.d.ts +30 -0
  364. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  365. package/lib/node/accounts/grpcAccountSubscriber.js +30 -0
  366. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
  367. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  368. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
  369. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
  370. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  371. package/lib/node/accounts/grpcMultiAccountSubscriber.js +118 -37
  372. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
  373. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  374. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +40 -12
  375. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
  376. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  377. package/lib/node/accounts/grpcProgramAccountSubscriber.js +33 -0
  378. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +15 -0
  379. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
  380. package/lib/node/accounts/grpcUserAccountSubscriber.js +15 -0
  381. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
  382. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
  383. package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +15 -0
  384. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
  385. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  386. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
  387. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
  388. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  389. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
  390. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +34 -0
  391. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  392. package/lib/node/accounts/laserProgramAccountSubscriber.js +34 -0
  393. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
  394. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  395. package/lib/node/accounts/oneShotUserAccountSubscriber.js +19 -0
  396. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
  397. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  398. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
  399. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
  400. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  401. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
  402. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
  403. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  404. package/lib/node/accounts/pollingOracleAccountSubscriber.js +21 -2
  405. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
  406. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  407. package/lib/node/accounts/pollingTokenAccountSubscriber.js +22 -0
  408. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +32 -0
  409. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
  410. package/lib/node/accounts/pollingUserAccountSubscriber.js +32 -0
  411. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
  412. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  413. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +22 -0
  414. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
  415. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  416. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
  417. package/lib/node/accounts/testBulkAccountLoader.d.ts +8 -0
  418. package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
  419. package/lib/node/accounts/testBulkAccountLoader.js +8 -0
  420. package/lib/node/accounts/types.d.ts +149 -0
  421. package/lib/node/accounts/types.d.ts.map +1 -1
  422. package/lib/node/accounts/types.js +13 -0
  423. package/lib/node/accounts/utils.d.ts +18 -0
  424. package/lib/node/accounts/utils.d.ts.map +1 -1
  425. package/lib/node/accounts/utils.js +32 -16
  426. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +41 -0
  427. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  428. package/lib/node/accounts/webSocketAccountSubscriber.js +41 -0
  429. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
  430. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  431. package/lib/node/accounts/webSocketAccountSubscriberV2.js +31 -23
  432. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
  433. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  434. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
  435. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
  436. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  437. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +36 -0
  438. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
  439. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  440. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
  441. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
  442. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  443. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
  444. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
  445. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  446. package/lib/node/accounts/webSocketUserAccountSubscriber.js +26 -0
  447. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
  448. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  449. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
  450. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
  451. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  452. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
  453. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
  454. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  455. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
  456. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
  457. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  458. package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +33 -0
  459. package/lib/node/addresses/marketAddresses.d.ts +10 -0
  460. package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
  461. package/lib/node/addresses/marketAddresses.js +10 -0
  462. package/lib/node/addresses/pda.d.ts +214 -2
  463. package/lib/node/addresses/pda.d.ts.map +1 -1
  464. package/lib/node/addresses/pda.js +217 -5
  465. package/lib/node/adminClient.d.ts +2136 -4
  466. package/lib/node/adminClient.d.ts.map +1 -1
  467. package/lib/node/adminClient.js +2150 -4
  468. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
  469. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  470. package/lib/node/auctionSubscriber/auctionSubscriber.js +15 -0
  471. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
  472. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  473. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
  474. package/lib/node/auctionSubscriber/index.d.ts +6 -0
  475. package/lib/node/auctionSubscriber/index.d.ts.map +1 -1
  476. package/lib/node/auctionSubscriber/index.js +6 -0
  477. package/lib/node/auctionSubscriber/types.d.ts +7 -0
  478. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  479. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
  480. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
  481. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +33 -0
  482. package/lib/node/blockhashSubscriber/index.d.ts +5 -0
  483. package/lib/node/blockhashSubscriber/index.d.ts.map +1 -1
  484. package/lib/node/blockhashSubscriber/index.js +5 -0
  485. package/lib/node/blockhashSubscriber/types.d.ts +5 -0
  486. package/lib/node/blockhashSubscriber/types.d.ts.map +1 -1
  487. package/lib/node/clock/clockSubscriber.d.ts +24 -0
  488. package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
  489. package/lib/node/clock/clockSubscriber.js +22 -0
  490. package/lib/node/config.d.ts +58 -4
  491. package/lib/node/config.d.ts.map +1 -1
  492. package/lib/node/config.js +88 -21
  493. package/lib/node/constants/numericConstants.d.ts +67 -0
  494. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  495. package/lib/node/constants/numericConstants.js +68 -1
  496. package/lib/node/constants/perpMarkets.d.ts +10 -0
  497. package/lib/node/constants/perpMarkets.d.ts.map +1 -1
  498. package/lib/node/constants/perpMarkets.js +40 -908
  499. package/lib/node/constants/spotMarkets.d.ts +13 -0
  500. package/lib/node/constants/spotMarkets.d.ts.map +1 -1
  501. package/lib/node/constants/spotMarkets.js +16 -742
  502. package/lib/node/constants/txConstants.d.ts +1 -0
  503. package/lib/node/constants/txConstants.d.ts.map +1 -1
  504. package/lib/node/constants/txConstants.js +1 -0
  505. package/lib/node/core/VelocityCore.d.ts +285 -8
  506. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  507. package/lib/node/core/VelocityCore.js +281 -8
  508. package/lib/node/core/instructions/deposit.d.ts +22 -0
  509. package/lib/node/core/instructions/deposit.d.ts.map +1 -1
  510. package/lib/node/core/instructions/deposit.js +22 -0
  511. package/lib/node/core/instructions/fill.d.ts +17 -0
  512. package/lib/node/core/instructions/fill.d.ts.map +1 -1
  513. package/lib/node/core/instructions/fill.js +17 -0
  514. package/lib/node/core/instructions/funding.d.ts +12 -0
  515. package/lib/node/core/instructions/funding.d.ts.map +1 -1
  516. package/lib/node/core/instructions/funding.js +12 -0
  517. package/lib/node/core/instructions/liquidation.d.ts +18 -0
  518. package/lib/node/core/instructions/liquidation.d.ts.map +1 -1
  519. package/lib/node/core/instructions/liquidation.js +18 -0
  520. package/lib/node/core/instructions/orders.d.ts +28 -0
  521. package/lib/node/core/instructions/orders.d.ts.map +1 -1
  522. package/lib/node/core/instructions/orders.js +28 -0
  523. package/lib/node/core/instructions/perpOrders.d.ts +106 -0
  524. package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
  525. package/lib/node/core/instructions/perpOrders.js +106 -0
  526. package/lib/node/core/instructions/settlement.d.ts +14 -0
  527. package/lib/node/core/instructions/settlement.d.ts.map +1 -1
  528. package/lib/node/core/instructions/settlement.js +14 -0
  529. package/lib/node/core/instructions/trigger.d.ts +15 -0
  530. package/lib/node/core/instructions/trigger.d.ts.map +1 -1
  531. package/lib/node/core/instructions/trigger.js +15 -0
  532. package/lib/node/core/instructions/withdraw.d.ts +21 -0
  533. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  534. package/lib/node/core/instructions/withdraw.js +21 -0
  535. package/lib/node/core/remainingAccounts.d.ts +47 -3
  536. package/lib/node/core/remainingAccounts.d.ts.map +1 -1
  537. package/lib/node/core/remainingAccounts.js +20 -0
  538. package/lib/node/core/signedMsg.d.ts +38 -0
  539. package/lib/node/core/signedMsg.d.ts.map +1 -1
  540. package/lib/node/core/signedMsg.js +33 -0
  541. package/lib/node/decode/customCoder.d.ts +39 -3
  542. package/lib/node/decode/customCoder.d.ts.map +1 -1
  543. package/lib/node/decode/customCoder.js +45 -3
  544. package/lib/node/decode/user.d.ts +22 -0
  545. package/lib/node/decode/user.d.ts.map +1 -1
  546. package/lib/node/decode/user.js +22 -0
  547. package/lib/node/dlob/DLOB.d.ts +502 -53
  548. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  549. package/lib/node/dlob/DLOB.js +540 -98
  550. package/lib/node/dlob/DLOBNode.d.ts +86 -4
  551. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  552. package/lib/node/dlob/DLOBNode.js +37 -4
  553. package/lib/node/dlob/DLOBSubscriber.d.ts +39 -12
  554. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  555. package/lib/node/dlob/DLOBSubscriber.js +42 -12
  556. package/lib/node/dlob/NodeList.d.ts +69 -0
  557. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  558. package/lib/node/dlob/NodeList.js +66 -0
  559. package/lib/node/dlob/orderBookLevels.d.ts +106 -13
  560. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  561. package/lib/node/dlob/orderBookLevels.js +84 -14
  562. package/lib/node/dlob/types.d.ts +15 -0
  563. package/lib/node/dlob/types.d.ts.map +1 -1
  564. package/lib/node/events/eventList.d.ts +14 -0
  565. package/lib/node/events/eventList.d.ts.map +1 -1
  566. package/lib/node/events/eventList.js +14 -0
  567. package/lib/node/events/eventSubscriber.d.ts +87 -10
  568. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  569. package/lib/node/events/eventSubscriber.js +93 -8
  570. package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
  571. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
  572. package/lib/node/events/eventsServerLogProvider.js +27 -0
  573. package/lib/node/events/fetchLogs.d.ts +31 -0
  574. package/lib/node/events/fetchLogs.d.ts.map +1 -1
  575. package/lib/node/events/fetchLogs.js +46 -1
  576. package/lib/node/events/parse.d.ts +23 -0
  577. package/lib/node/events/parse.d.ts.map +1 -1
  578. package/lib/node/events/parse.js +23 -0
  579. package/lib/node/events/pollingLogProvider.d.ts +24 -0
  580. package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
  581. package/lib/node/events/pollingLogProvider.js +24 -0
  582. package/lib/node/events/sort.d.ts +11 -0
  583. package/lib/node/events/sort.d.ts.map +1 -1
  584. package/lib/node/events/sort.js +12 -0
  585. package/lib/node/events/txEventCache.d.ts +13 -3
  586. package/lib/node/events/txEventCache.d.ts.map +1 -1
  587. package/lib/node/events/txEventCache.js +19 -7
  588. package/lib/node/events/types.d.ts +118 -2
  589. package/lib/node/events/types.d.ts.map +1 -1
  590. package/lib/node/events/types.js +11 -0
  591. package/lib/node/events/webSocketLogProvider.d.ts +23 -0
  592. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
  593. package/lib/node/events/webSocketLogProvider.js +28 -0
  594. package/lib/node/factory/oracleClient.js +2 -2
  595. package/lib/node/idl/velocity.d.ts +4 -4
  596. package/lib/node/idl/velocity.d.ts.map +1 -1
  597. package/lib/node/idl/velocity.json +4 -4
  598. package/lib/node/keypair.d.ts +8 -0
  599. package/lib/node/keypair.d.ts.map +1 -1
  600. package/lib/node/keypair.js +8 -0
  601. package/lib/node/marginCalculation.d.ts +134 -2
  602. package/lib/node/marginCalculation.d.ts.map +1 -1
  603. package/lib/node/marginCalculation.js +121 -0
  604. package/lib/node/math/amm.d.ts +348 -29
  605. package/lib/node/math/amm.d.ts.map +1 -1
  606. package/lib/node/math/amm.js +310 -32
  607. package/lib/node/math/auction.d.ts +95 -19
  608. package/lib/node/math/auction.d.ts.map +1 -1
  609. package/lib/node/math/auction.js +118 -28
  610. package/lib/node/math/bankruptcy.d.ts +46 -0
  611. package/lib/node/math/bankruptcy.d.ts.map +1 -1
  612. package/lib/node/math/bankruptcy.js +89 -1
  613. package/lib/node/math/builder.d.ts +64 -8
  614. package/lib/node/math/builder.d.ts.map +1 -1
  615. package/lib/node/math/builder.js +71 -9
  616. package/lib/node/math/conversion.d.ts +21 -0
  617. package/lib/node/math/conversion.d.ts.map +1 -1
  618. package/lib/node/math/conversion.js +21 -0
  619. package/lib/node/math/exchangeStatus.d.ts +91 -0
  620. package/lib/node/math/exchangeStatus.d.ts.map +1 -1
  621. package/lib/node/math/exchangeStatus.js +106 -3
  622. package/lib/node/math/funding.d.ts +57 -20
  623. package/lib/node/math/funding.d.ts.map +1 -1
  624. package/lib/node/math/funding.js +63 -23
  625. package/lib/node/math/insurance.d.ts +62 -0
  626. package/lib/node/math/insurance.d.ts.map +1 -1
  627. package/lib/node/math/insurance.js +62 -0
  628. package/lib/node/math/liquidation.d.ts +127 -11
  629. package/lib/node/math/liquidation.d.ts.map +1 -1
  630. package/lib/node/math/liquidation.js +182 -19
  631. package/lib/node/math/margin.d.ts +79 -13
  632. package/lib/node/math/margin.d.ts.map +1 -1
  633. package/lib/node/math/margin.js +80 -14
  634. package/lib/node/math/market.d.ts +135 -15
  635. package/lib/node/math/market.d.ts.map +1 -1
  636. package/lib/node/math/market.js +145 -17
  637. package/lib/node/math/oracles.d.ts +113 -0
  638. package/lib/node/math/oracles.d.ts.map +1 -1
  639. package/lib/node/math/oracles.js +118 -1
  640. package/lib/node/math/orders.d.ts +115 -10
  641. package/lib/node/math/orders.d.ts.map +1 -1
  642. package/lib/node/math/orders.js +130 -19
  643. package/lib/node/math/position.d.ts +80 -33
  644. package/lib/node/math/position.d.ts.map +1 -1
  645. package/lib/node/math/position.js +80 -33
  646. package/lib/node/math/repeg.d.ts +48 -10
  647. package/lib/node/math/repeg.d.ts.map +1 -1
  648. package/lib/node/math/repeg.js +48 -10
  649. package/lib/node/math/spotBalance.d.ts +200 -5
  650. package/lib/node/math/spotBalance.d.ts.map +1 -1
  651. package/lib/node/math/spotBalance.js +239 -10
  652. package/lib/node/math/spotMarket.d.ts +36 -3
  653. package/lib/node/math/spotMarket.d.ts.map +1 -1
  654. package/lib/node/math/spotMarket.js +36 -3
  655. package/lib/node/math/spotPosition.d.ts +72 -0
  656. package/lib/node/math/spotPosition.d.ts.map +1 -1
  657. package/lib/node/math/spotPosition.js +62 -0
  658. package/lib/node/math/state.d.ts +31 -0
  659. package/lib/node/math/state.d.ts.map +1 -1
  660. package/lib/node/math/state.js +31 -0
  661. package/lib/node/math/superStake.d.ts +126 -2
  662. package/lib/node/math/superStake.d.ts.map +1 -1
  663. package/lib/node/math/superStake.js +123 -3
  664. package/lib/node/math/tiers.d.ts +29 -0
  665. package/lib/node/math/tiers.d.ts.map +1 -1
  666. package/lib/node/math/tiers.js +29 -0
  667. package/lib/node/math/trade.d.ts +102 -51
  668. package/lib/node/math/trade.d.ts.map +1 -1
  669. package/lib/node/math/trade.js +101 -55
  670. package/lib/node/math/utils.d.ts +71 -9
  671. package/lib/node/math/utils.d.ts.map +1 -1
  672. package/lib/node/math/utils.js +71 -9
  673. package/lib/node/memcmp.d.ts +94 -0
  674. package/lib/node/memcmp.d.ts.map +1 -1
  675. package/lib/node/memcmp.js +103 -2
  676. package/lib/node/oracles/oracleClientCache.d.ts +16 -0
  677. package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
  678. package/lib/node/oracles/oracleClientCache.js +16 -0
  679. package/lib/node/oracles/oracleId.d.ts +31 -0
  680. package/lib/node/oracles/oracleId.d.ts.map +1 -1
  681. package/lib/node/oracles/oracleId.js +39 -8
  682. package/lib/node/oracles/prelaunchOracleClient.d.ts +20 -0
  683. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  684. package/lib/node/oracles/prelaunchOracleClient.js +20 -0
  685. package/lib/node/oracles/pythClient.d.ts +31 -0
  686. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  687. package/lib/node/oracles/pythClient.js +32 -1
  688. package/lib/node/oracles/pythLazerClient.d.ts +34 -0
  689. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  690. package/lib/node/oracles/pythLazerClient.js +35 -1
  691. package/lib/node/oracles/quoteAssetOracleClient.d.ts +18 -0
  692. package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -1
  693. package/lib/node/oracles/quoteAssetOracleClient.js +18 -0
  694. package/lib/node/oracles/strictOraclePrice.d.ts +21 -0
  695. package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
  696. package/lib/node/oracles/strictOraclePrice.js +21 -0
  697. package/lib/node/oracles/types.d.ts +45 -0
  698. package/lib/node/oracles/types.d.ts.map +1 -1
  699. package/lib/node/oracles/utils.d.ts +20 -0
  700. package/lib/node/oracles/utils.d.ts.map +1 -1
  701. package/lib/node/oracles/utils.js +20 -0
  702. package/lib/node/orderParams.d.ts +42 -4
  703. package/lib/node/orderParams.d.ts.map +1 -1
  704. package/lib/node/orderParams.js +42 -4
  705. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +56 -0
  706. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  707. package/lib/node/orderSubscriber/OrderSubscriber.js +56 -0
  708. package/lib/node/orderSubscriber/PollingSubscription.d.ts +11 -0
  709. package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -1
  710. package/lib/node/orderSubscriber/PollingSubscription.js +11 -0
  711. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +18 -0
  712. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -1
  713. package/lib/node/orderSubscriber/WebsocketSubscription.js +18 -0
  714. package/lib/node/orderSubscriber/grpcSubscription.d.ts +16 -0
  715. package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
  716. package/lib/node/orderSubscriber/grpcSubscription.js +16 -0
  717. package/lib/node/orderSubscriber/types.d.ts +9 -0
  718. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  719. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
  720. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -1
  721. package/lib/node/priorityFee/averageOverSlotsStrategy.js +1 -0
  722. package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
  723. package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -1
  724. package/lib/node/priorityFee/averageStrategy.js +1 -0
  725. package/lib/node/priorityFee/ewmaStrategy.d.ts +10 -0
  726. package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -1
  727. package/lib/node/priorityFee/ewmaStrategy.js +10 -0
  728. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
  729. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
  730. package/lib/node/priorityFee/heliusPriorityFeeMethod.js +9 -2
  731. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
  732. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -1
  733. package/lib/node/priorityFee/maxOverSlotsStrategy.js +1 -0
  734. package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
  735. package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -1
  736. package/lib/node/priorityFee/maxStrategy.js +1 -0
  737. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +39 -0
  738. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  739. package/lib/node/priorityFee/priorityFeeSubscriber.js +39 -0
  740. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
  741. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  742. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +21 -2
  743. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
  744. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
  745. package/lib/node/priorityFee/solanaPriorityFeeMethod.js +10 -0
  746. package/lib/node/priorityFee/types.d.ts +32 -0
  747. package/lib/node/priorityFee/types.d.ts.map +1 -1
  748. package/lib/node/priorityFee/types.js +5 -0
  749. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
  750. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
  751. package/lib/node/priorityFee/velocityPriorityFeeMethod.js +8 -0
  752. package/lib/node/slot/SlotSubscriber.d.ts +18 -0
  753. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
  754. package/lib/node/slot/SlotSubscriber.js +16 -0
  755. package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
  756. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
  757. package/lib/node/slot/SlothashSubscriber.js +25 -1
  758. package/lib/node/tx/baseTxSender.d.ts +163 -0
  759. package/lib/node/tx/baseTxSender.d.ts.map +1 -1
  760. package/lib/node/tx/baseTxSender.js +174 -6
  761. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
  762. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -1
  763. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
  764. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
  765. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -1
  766. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
  767. package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
  768. package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -1
  769. package/lib/node/tx/fastSingleTxSender.d.ts +47 -0
  770. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
  771. package/lib/node/tx/fastSingleTxSender.js +48 -1
  772. package/lib/node/tx/forwardOnlyTxSender.d.ts +48 -0
  773. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -1
  774. package/lib/node/tx/forwardOnlyTxSender.js +48 -0
  775. package/lib/node/tx/reportTransactionError.d.ts +18 -6
  776. package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
  777. package/lib/node/tx/reportTransactionError.js +18 -6
  778. package/lib/node/tx/retryTxSender.d.ts +40 -0
  779. package/lib/node/tx/retryTxSender.d.ts.map +1 -1
  780. package/lib/node/tx/retryTxSender.js +39 -0
  781. package/lib/node/tx/txHandler.d.ts +146 -35
  782. package/lib/node/tx/txHandler.d.ts.map +1 -1
  783. package/lib/node/tx/txHandler.js +132 -32
  784. package/lib/node/tx/txParamProcessor.d.ts +47 -0
  785. package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
  786. package/lib/node/tx/txParamProcessor.js +47 -0
  787. package/lib/node/tx/types.d.ts +46 -0
  788. package/lib/node/tx/types.d.ts.map +1 -1
  789. package/lib/node/tx/types.js +5 -0
  790. package/lib/node/tx/utils.d.ts +26 -0
  791. package/lib/node/tx/utils.d.ts.map +1 -1
  792. package/lib/node/tx/utils.js +26 -0
  793. package/lib/node/tx/whileValidTxSender.d.ts +82 -0
  794. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
  795. package/lib/node/tx/whileValidTxSender.js +81 -0
  796. package/lib/node/types.d.ts +781 -13
  797. package/lib/node/types.d.ts.map +1 -1
  798. package/lib/node/types.js +126 -9
  799. package/lib/node/user.d.ts +645 -84
  800. package/lib/node/user.d.ts.map +1 -1
  801. package/lib/node/user.js +779 -96
  802. package/lib/node/userMap/PollingSubscription.d.ts +10 -0
  803. package/lib/node/userMap/PollingSubscription.d.ts.map +1 -1
  804. package/lib/node/userMap/PollingSubscription.js +14 -2
  805. package/lib/node/userMap/WebsocketSubscription.d.ts +9 -0
  806. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
  807. package/lib/node/userMap/WebsocketSubscription.js +9 -0
  808. package/lib/node/userMap/grpcSubscription.d.ts +8 -0
  809. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
  810. package/lib/node/userMap/grpcSubscription.js +8 -0
  811. package/lib/node/userMap/referrerMap.d.ts +72 -2
  812. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  813. package/lib/node/userMap/referrerMap.js +84 -2
  814. package/lib/node/userMap/revenueShareEscrowMap.d.ts +37 -10
  815. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  816. package/lib/node/userMap/revenueShareEscrowMap.js +38 -11
  817. package/lib/node/userMap/userMap.d.ts +81 -3
  818. package/lib/node/userMap/userMap.d.ts.map +1 -1
  819. package/lib/node/userMap/userMap.js +81 -4
  820. package/lib/node/userMap/userMapConfig.d.ts +23 -0
  821. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  822. package/lib/node/userMap/userStatsMap.d.ts +22 -0
  823. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  824. package/lib/node/userMap/userStatsMap.js +22 -0
  825. package/lib/node/userName.d.ts +16 -0
  826. package/lib/node/userName.d.ts.map +1 -1
  827. package/lib/node/userName.js +16 -0
  828. package/lib/node/userStats.d.ts +28 -1
  829. package/lib/node/userStats.d.ts.map +1 -1
  830. package/lib/node/userStats.js +28 -1
  831. package/lib/node/util/TransactionConfirmationManager.d.ts +33 -0
  832. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
  833. package/lib/node/util/TransactionConfirmationManager.js +33 -0
  834. package/lib/node/util/chainClock.d.ts +24 -0
  835. package/lib/node/util/chainClock.d.ts.map +1 -1
  836. package/lib/node/util/chainClock.js +20 -0
  837. package/lib/node/util/computeUnits.d.ts +32 -0
  838. package/lib/node/util/computeUnits.d.ts.map +1 -1
  839. package/lib/node/util/computeUnits.js +32 -0
  840. package/lib/node/util/digest.d.ts +17 -0
  841. package/lib/node/util/digest.d.ts.map +1 -1
  842. package/lib/node/util/digest.js +17 -0
  843. package/lib/node/util/ed25519Utils.d.ts +12 -2
  844. package/lib/node/util/ed25519Utils.d.ts.map +1 -1
  845. package/lib/node/util/ed25519Utils.js +12 -2
  846. package/lib/node/util/promiseTimeout.d.ts +9 -0
  847. package/lib/node/util/promiseTimeout.d.ts.map +1 -1
  848. package/lib/node/util/promiseTimeout.js +9 -0
  849. package/lib/node/velocityClient.d.ts +3322 -215
  850. package/lib/node/velocityClient.d.ts.map +1 -1
  851. package/lib/node/velocityClient.js +3412 -245
  852. package/lib/node/wallet.d.ts +37 -0
  853. package/lib/node/wallet.d.ts.map +1 -1
  854. package/lib/node/wallet.js +37 -0
  855. package/package.json +2 -1
  856. package/src/accounts/basicUserAccountSubscriber.ts +18 -0
  857. package/src/accounts/basicUserStatsAccountSubscriber.ts +18 -0
  858. package/src/accounts/bulkAccountLoader.ts +52 -0
  859. package/src/accounts/bulkUserStatsSubscription.ts +9 -2
  860. package/src/accounts/bulkUserSubscription.ts +8 -2
  861. package/src/accounts/customizedCadenceBulkAccountLoader.ts +37 -0
  862. package/src/accounts/fetch.ts +59 -2
  863. package/src/accounts/grpcAccountSubscriber.ts +30 -0
  864. package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +16 -0
  865. package/src/accounts/grpcMultiAccountSubscriber.ts +121 -38
  866. package/src/accounts/grpcMultiUserAccountSubscriber.ts +49 -11
  867. package/src/accounts/grpcProgramAccountSubscriber.ts +33 -0
  868. package/src/accounts/grpcUserAccountSubscriber.ts +15 -0
  869. package/src/accounts/grpcUserStatsAccountSubscriber.ts +15 -0
  870. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +41 -0
  871. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +160 -1
  872. package/src/accounts/laserProgramAccountSubscriber.ts +34 -0
  873. package/src/accounts/oneShotUserAccountSubscriber.ts +19 -0
  874. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +19 -0
  875. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +31 -0
  876. package/src/accounts/pollingOracleAccountSubscriber.ts +21 -2
  877. package/src/accounts/pollingTokenAccountSubscriber.ts +22 -0
  878. package/src/accounts/pollingUserAccountSubscriber.ts +32 -0
  879. package/src/accounts/pollingUserStatsAccountSubscriber.ts +22 -0
  880. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +84 -1
  881. package/src/accounts/testBulkAccountLoader.ts +8 -0
  882. package/src/accounts/types.ts +149 -0
  883. package/src/accounts/utils.ts +42 -24
  884. package/src/accounts/webSocketAccountSubscriber.ts +41 -0
  885. package/src/accounts/webSocketAccountSubscriberV2.ts +31 -23
  886. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +27 -0
  887. package/src/accounts/webSocketProgramAccountSubscriber.ts +36 -0
  888. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +26 -0
  889. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +21 -0
  890. package/src/accounts/webSocketUserAccountSubscriber.ts +26 -0
  891. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +20 -0
  892. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +127 -2
  893. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +110 -0
  894. package/src/accounts/websocketProgramUserAccountSubscriber.ts +33 -0
  895. package/src/addresses/marketAddresses.ts +10 -0
  896. package/src/addresses/pda.ts +228 -12
  897. package/src/adminClient.ts +2156 -4
  898. package/src/auctionSubscriber/auctionSubscriber.ts +15 -0
  899. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +19 -0
  900. package/src/auctionSubscriber/index.ts +6 -0
  901. package/src/auctionSubscriber/types.ts +7 -0
  902. package/src/blockhashSubscriber/BlockhashSubscriber.ts +33 -0
  903. package/src/blockhashSubscriber/index.ts +5 -0
  904. package/src/blockhashSubscriber/types.ts +5 -4
  905. package/src/clock/clockSubscriber.ts +24 -0
  906. package/src/config.ts +109 -22
  907. package/src/constants/numericConstants.ts +70 -0
  908. package/src/constants/perpMarkets.ts +45 -960
  909. package/src/constants/spotMarkets.ts +23 -793
  910. package/src/constants/txConstants.ts +1 -0
  911. package/src/core/VelocityCore.ts +286 -8
  912. package/src/core/instructions/deposit.ts +22 -0
  913. package/src/core/instructions/fill.ts +17 -0
  914. package/src/core/instructions/funding.ts +12 -0
  915. package/src/core/instructions/liquidation.ts +18 -0
  916. package/src/core/instructions/orders.ts +28 -0
  917. package/src/core/instructions/perpOrders.ts +106 -0
  918. package/src/core/instructions/settlement.ts +14 -0
  919. package/src/core/instructions/trigger.ts +15 -0
  920. package/src/core/instructions/withdraw.ts +21 -0
  921. package/src/core/remainingAccounts.ts +47 -3
  922. package/src/core/signedMsg.ts +38 -0
  923. package/src/decode/customCoder.ts +46 -3
  924. package/src/decode/user.ts +22 -0
  925. package/src/dlob/DLOB.ts +668 -97
  926. package/src/dlob/DLOBNode.ts +98 -6
  927. package/src/dlob/DLOBSubscriber.ts +49 -12
  928. package/src/dlob/NodeList.ts +69 -0
  929. package/src/dlob/orderBookLevels.ts +108 -14
  930. package/src/dlob/types.ts +15 -0
  931. package/src/events/eventList.ts +14 -0
  932. package/src/events/eventSubscriber.ts +100 -19
  933. package/src/events/eventsServerLogProvider.ts +28 -0
  934. package/src/events/fetchLogs.ts +52 -2
  935. package/src/events/parse.ts +23 -0
  936. package/src/events/pollingLogProvider.ts +24 -0
  937. package/src/events/sort.ts +12 -0
  938. package/src/events/txEventCache.ts +19 -7
  939. package/src/events/types.ts +131 -11
  940. package/src/events/webSocketLogProvider.ts +29 -0
  941. package/src/factory/oracleClient.ts +2 -2
  942. package/src/idl/velocity.json +4 -4
  943. package/src/idl/velocity.ts +4 -4
  944. package/src/keypair.ts +8 -0
  945. package/src/marginCalculation.ts +153 -2
  946. package/src/math/amm.ts +371 -36
  947. package/src/math/auction.ts +139 -30
  948. package/src/math/bankruptcy.ts +104 -1
  949. package/src/math/builder.ts +74 -8
  950. package/src/math/conversion.ts +21 -0
  951. package/src/math/exchangeStatus.ts +117 -2
  952. package/src/math/funding.ts +63 -23
  953. package/src/math/insurance.ts +62 -0
  954. package/src/math/liquidation.ts +227 -17
  955. package/src/math/margin.ts +80 -14
  956. package/src/math/market.ts +148 -17
  957. package/src/math/oracles.ts +124 -0
  958. package/src/math/orders.ts +141 -19
  959. package/src/math/position.ts +80 -33
  960. package/src/math/repeg.ts +48 -10
  961. package/src/math/spotBalance.ts +252 -12
  962. package/src/math/spotMarket.ts +36 -3
  963. package/src/math/spotPosition.ts +72 -0
  964. package/src/math/state.ts +31 -0
  965. package/src/math/superStake.ts +126 -3
  966. package/src/math/tiers.ts +29 -0
  967. package/src/math/trade.ts +125 -55
  968. package/src/math/utils.ts +71 -9
  969. package/src/memcmp.ts +104 -2
  970. package/src/oracles/oracleClientCache.ts +16 -0
  971. package/src/oracles/oracleId.ts +39 -6
  972. package/src/oracles/prelaunchOracleClient.ts +20 -0
  973. package/src/oracles/pythClient.ts +32 -1
  974. package/src/oracles/pythLazerClient.ts +35 -1
  975. package/src/oracles/quoteAssetOracleClient.ts +18 -0
  976. package/src/oracles/strictOraclePrice.ts +21 -0
  977. package/src/oracles/types.ts +45 -0
  978. package/src/oracles/utils.ts +20 -0
  979. package/src/orderParams.ts +42 -4
  980. package/src/orderSubscriber/OrderSubscriber.ts +56 -0
  981. package/src/orderSubscriber/PollingSubscription.ts +11 -0
  982. package/src/orderSubscriber/WebsocketSubscription.ts +18 -0
  983. package/src/orderSubscriber/grpcSubscription.ts +16 -0
  984. package/src/orderSubscriber/types.ts +9 -0
  985. package/src/priorityFee/averageOverSlotsStrategy.ts +1 -0
  986. package/src/priorityFee/averageStrategy.ts +1 -0
  987. package/src/priorityFee/ewmaStrategy.ts +10 -0
  988. package/src/priorityFee/heliusPriorityFeeMethod.ts +13 -2
  989. package/src/priorityFee/maxOverSlotsStrategy.ts +1 -0
  990. package/src/priorityFee/maxStrategy.ts +1 -0
  991. package/src/priorityFee/priorityFeeSubscriber.ts +39 -0
  992. package/src/priorityFee/priorityFeeSubscriberMap.ts +21 -2
  993. package/src/priorityFee/solanaPriorityFeeMethod.ts +12 -0
  994. package/src/priorityFee/types.ts +33 -15
  995. package/src/priorityFee/velocityPriorityFeeMethod.ts +11 -0
  996. package/src/slot/SlotSubscriber.ts +18 -0
  997. package/src/slot/SlothashSubscriber.ts +27 -1
  998. package/src/tx/baseTxSender.ts +185 -5
  999. package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +12 -0
  1000. package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +15 -0
  1001. package/src/tx/blockhashFetcher/types.ts +4 -0
  1002. package/src/tx/fastSingleTxSender.ts +58 -4
  1003. package/src/tx/forwardOnlyTxSender.ts +48 -0
  1004. package/src/tx/reportTransactionError.ts +18 -6
  1005. package/src/tx/retryTxSender.ts +40 -0
  1006. package/src/tx/txHandler.ts +146 -35
  1007. package/src/tx/txParamProcessor.ts +47 -0
  1008. package/src/tx/types.ts +46 -0
  1009. package/src/tx/utils.ts +26 -0
  1010. package/src/tx/whileValidTxSender.ts +82 -0
  1011. package/src/types.ts +777 -24
  1012. package/src/user.ts +869 -110
  1013. package/src/userMap/PollingSubscription.ts +16 -2
  1014. package/src/userMap/WebsocketSubscription.ts +9 -0
  1015. package/src/userMap/grpcSubscription.ts +8 -0
  1016. package/src/userMap/referrerMap.ts +92 -3
  1017. package/src/userMap/revenueShareEscrowMap.ts +38 -11
  1018. package/src/userMap/userMap.ts +82 -4
  1019. package/src/userMap/userMapConfig.ts +23 -10
  1020. package/src/userMap/userStatsMap.ts +22 -0
  1021. package/src/userName.ts +16 -0
  1022. package/src/userStats.ts +28 -1
  1023. package/src/util/TransactionConfirmationManager.ts +33 -0
  1024. package/src/util/chainClock.ts +24 -0
  1025. package/src/util/computeUnits.ts +32 -0
  1026. package/src/util/digest.ts +17 -0
  1027. package/src/util/ed25519Utils.ts +12 -2
  1028. package/src/util/promiseTimeout.ts +9 -0
  1029. package/src/velocityClient.ts +3439 -249
  1030. package/src/wallet.ts +37 -0
  1031. package/tests/VelocityCore/builder_escrow.test.ts +121 -0
  1032. package/tests/amm/test.ts +102 -0
  1033. package/tests/builder/builderFee.test.ts +42 -0
  1034. package/tests/dlob/tickSizeStandardization.ts +545 -0
  1035. package/tests/exchangeStatus/test.ts +45 -0
  1036. package/tests/liquidation/test.ts +125 -0
  1037. package/tests/oracles/mmOracleGate.test.ts +379 -0
  1038. package/tests/oracles/pythPegSnap.test.ts +76 -0
  1039. package/tests/sdkParity/enumParity.test.ts +84 -0
  1040. package/tests/sdkParity/marginCategoryFill.test.ts +143 -0
  1041. package/tests/sdkParity/memcmpOffsets.test.ts +139 -0
  1042. package/tests/spot/test.ts +55 -0
  1043. package/tests/user/bankruptcy.ts +165 -0
  1044. package/tests/user/feeAndWithdrawLimits.ts +284 -0
  1045. package/tests/user/getMarginCalculation.ts +226 -1
  1046. package/tests/user/test.ts +8 -4
@@ -13,9 +13,17 @@
13
13
  */
14
14
  import { Keypair, PublicKey, Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
15
15
  import { BN } from './isomorphic/anchor';
16
+ /** Utility type that maps every key of `A` to the same-shaped record with all values replaced by type `B`. */
16
17
  export type MappedRecord<A extends Record<string, unknown>, B> = {
17
18
  [K in keyof A]: B;
18
19
  };
20
+ /**
21
+ * Bitmask mirror of `State.exchangeStatus`. Each non-zero member pauses one class of
22
+ * instructions protocol-wide; multiple bits may be set simultaneously (e.g. deposits and
23
+ * withdrawals paused together). `PAUSED` (255) is the "pause everything" value, not a flag
24
+ * combinable with the others. Only `coldAdmin`/`warmAdmin` may clear bits; `pauseAdmin` may
25
+ * only set them (see `StateAccount.pauseAdmin`).
26
+ */
19
27
  export declare enum ExchangeStatus {
20
28
  ACTIVE = 0,
21
29
  DEPOSIT_PAUSED = 1,
@@ -28,16 +36,34 @@ export declare enum ExchangeStatus {
28
36
  AMM_IMMEDIATE_FILL_PAUSED = 128,
29
37
  PAUSED = 255
30
38
  }
39
+ /**
40
+ * Mirror of the Rust `SolvencyStatus` bitflag (`StateAccount.solvencyStatus`). Gates internal
41
+ * solvency-repair flows (bankruptcy / pnl-deficit resolution) independently of
42
+ * `ExchangeStatus.WITHDRAW_PAUSED`, so withdrawals can be halted while repair keeps running, or
43
+ * repair can be frozen on its own (e.g. when an oracle is suspect) without touching withdrawals.
44
+ * `ACTIVE` (0) means repair is allowed.
45
+ */
31
46
  export declare enum SolvencyStatus {
32
47
  ACTIVE = 0,
33
48
  SOLVENCY_REPAIR_PAUSED = 1
34
49
  }
50
+ /** Bitmask mirror of `StateAccount.featureBitFlags`, gating protocol-wide optional features. */
35
51
  export declare enum FeatureBitFlags {
36
52
  MM_ORACLE_UPDATE = 1,
37
53
  MEDIAN_TRIGGER_PRICE = 2,
38
- BUILDER_CODES = 4,
39
- BUILDER_REFERRAL = 8
54
+ BUILDER_CODES = 4
40
55
  }
56
+ /**
57
+ * Mirrors the Rust `MarketStatus` enum on `PerpMarketAccount.status` / `SpotMarketAccount.status`.
58
+ * Controls which operations a market allows: `INITIALIZED` (warm-up, fills paused), `ACTIVE` (all
59
+ * operations allowed), `REDUCE_ONLY` (fills may only shrink a liability), `SETTLEMENT` (market has
60
+ * a determined settlement price; positions must be settled), `DELISTED` (no participants remain).
61
+ * Velocity's on-chain discriminants (`Initialized`=0, `Active`=1, `ReduceOnly`=2, `Settlement`=3,
62
+ * `Delisted`=4) are **shifted down from upstream Drift's** (`ReduceOnly`=6, `Settlement`=7,
63
+ * `Delisted`=8) after the deprecated `FundingPaused`/`AmmPaused`/`FillPaused`/`WithdrawPaused`
64
+ * variants were removed — any decoder built against the old Drift discriminants will silently
65
+ * misread these states.
66
+ */
41
67
  export declare class MarketStatus {
42
68
  static readonly INITIALIZED: {
43
69
  initialized: {};
@@ -55,6 +81,7 @@ export declare class MarketStatus {
55
81
  delisted: {};
56
82
  };
57
83
  }
84
+ /** Bitmask mirror of `PerpMarketAccount.pausedOperations`; each bit disables one perp-market operation. */
58
85
  export declare enum PerpOperation {
59
86
  UPDATE_FUNDING = 1,
60
87
  AMM_FILL = 2,
@@ -62,8 +89,10 @@ export declare enum PerpOperation {
62
89
  SETTLE_PNL = 8,
63
90
  SETTLE_PNL_WITH_POSITION = 16,
64
91
  LIQUIDATION = 32,
65
- SETTLE_REV_POOL = 64
92
+ AMM_IMMEDIATE_FILL = 64,
93
+ SETTLE_REV_POOL = 128
66
94
  }
95
+ /** Bitmask mirror of `SpotMarketAccount.pausedOperations`; each bit disables one spot-market operation. */
67
96
  export declare enum SpotOperation {
68
97
  UPDATE_CUMULATIVE_INTEREST = 1,
69
98
  FILL = 2,
@@ -71,42 +100,65 @@ export declare enum SpotOperation {
71
100
  WITHDRAW = 8,
72
101
  LIQUIDATION = 16
73
102
  }
103
+ /** Bitmask mirror of `SpotMarketAccount.ifPausedOperations`; each bit disables one insurance-fund-stake operation. */
74
104
  export declare enum InsuranceFundOperation {
75
105
  INIT = 1,
76
106
  ADD = 2,
77
107
  REQUEST_REMOVE = 4,
78
108
  REMOVE = 8
79
109
  }
110
+ /**
111
+ * Bitmask mirror of `UserAccount.status`. Multiple bits can be set at once (e.g. a bankrupt user
112
+ * is also `BEING_LIQUIDATED`). `0` (unset) means active/normal. Bit `16` (was `PROTECTED_MAKER`)
113
+ * is reserved and no longer assigned.
114
+ */
80
115
  export declare enum UserStatus {
81
116
  BEING_LIQUIDATED = 1,
82
117
  BANKRUPT = 2,
83
118
  REDUCE_ONLY = 4,
84
119
  ADVANCED_LP = 8
85
120
  }
121
+ /** Bitmask mirror of `UserAccount.specialUserStatus`. `VAMM_HEDGER` marks the account used by the protocol's own vAMM-hedging bot. */
86
122
  export declare enum SpecialUserStatus {
87
123
  VAMM_HEDGER = 1
88
124
  }
125
+ /** Bitmask mirror of `UserStatsAccount.pausedOperations`; each bit disables one per-user-stats update path. */
89
126
  export declare enum UserStatsPausedOperation {
90
127
  UPDATE_BID_ASK_TWAP = 1,
91
128
  AMM_ATOMIC_FILL = 2,
92
129
  AMM_ATOMIC_RISK_INCREASING_FILL = 4
93
130
  }
131
+ /** Bitmask mirror of `PerpMarketAccount.marketConfig`. `DISABLE_FORMULAIC_K_UPDATE` turns off the AMM's automatic `k` (liquidity depth) adjustments for that market. */
94
132
  export declare enum MarketConfigFlag {
95
133
  DISABLE_FORMULAIC_K_UPDATE = 1
96
134
  }
135
+ /** Margin-mode enum-class. Currently only `DEFAULT` (cross margin) exists; isolated margin is expressed per-position via `PositionFlag.IsolatedPosition`, not a distinct margin mode. */
97
136
  export declare class MarginMode {
98
137
  static readonly DEFAULT: {
99
138
  default: {};
100
139
  };
101
140
  }
141
+ /**
142
+ * Mirrors the on-chain `ContractType` on `PerpMarketAccount.contractType`. Only `PERPETUAL` is
143
+ * live; `DEPRECATED_FUTURE` and `DEPRECATED_PREDICTION` are inert stubs kept for IDL/discriminant
144
+ * compatibility and are never assigned to a market.
145
+ */
102
146
  export declare class ContractType {
103
147
  static readonly PERPETUAL: {
104
148
  perpetual: {};
105
149
  };
106
- static readonly FUTURE: {
107
- future: {};
150
+ static readonly DEPRECATED_FUTURE: {
151
+ deprecatedFuture: {};
152
+ };
153
+ static readonly DEPRECATED_PREDICTION: {
154
+ deprecatedPrediction: {};
108
155
  };
109
156
  }
157
+ /**
158
+ * A perp market's speculativeness tier (`PerpMarketAccount.contractTier`). Determines how much of
159
+ * the insurance fund the market may draw on during bankruptcy and the order markets are
160
+ * liquidated in — `ISOLATED` markets receive no shared insurance coverage; `A` is safest.
161
+ */
110
162
  export declare class ContractTier {
111
163
  static readonly A: {
112
164
  a: {};
@@ -127,6 +179,12 @@ export declare class ContractTier {
127
179
  isolated: {};
128
180
  };
129
181
  }
182
+ /**
183
+ * A spot market's collateral-safety tier (`SpotMarketAccount.assetTier`). Determines whether a
184
+ * deposit can be used as cross-margin collateral alongside other assets: `COLLATERAL` may back
185
+ * any borrow, `PROTECTED`/`CROSS` have restrictions on being borrowed against, `ISOLATED` deposits
186
+ * can't be combined with other borrows, and `UNLISTED` deposits count for nothing.
187
+ */
130
188
  export declare class AssetTier {
131
189
  static readonly COLLATERAL: {
132
190
  collateral: {};
@@ -144,10 +202,12 @@ export declare class AssetTier {
144
202
  unlisted: {};
145
203
  };
146
204
  }
205
+ /** Bitmask mirror of `SpotMarketAccount.tokenProgramFlag`, recording which SPL token-program features the market's mint uses. */
147
206
  export declare enum TokenProgramFlag {
148
207
  Token2022 = 1,
149
208
  TransferHook = 2
150
209
  }
210
+ /** Direction of an LP-pool constituent swap (add liquidity vs remove liquidity). */
151
211
  export declare class SwapDirection {
152
212
  static readonly ADD: {
153
213
  add: {};
@@ -156,6 +216,7 @@ export declare class SwapDirection {
156
216
  remove: {};
157
217
  };
158
218
  }
219
+ /** Whether a `SpotPosition`/`PoolBalance`'s scaled balance represents a deposit (positive token claim) or a borrow (liability). */
159
220
  export declare class SpotBalanceType {
160
221
  static readonly DEPOSIT: {
161
222
  deposit: {};
@@ -164,6 +225,7 @@ export declare class SpotBalanceType {
164
225
  borrow: {};
165
226
  };
166
227
  }
228
+ /** Long (bid) or short (ask) side of a perp/spot order or position. */
167
229
  export declare class PositionDirection {
168
230
  static readonly LONG: {
169
231
  long: {};
@@ -172,6 +234,7 @@ export declare class PositionDirection {
172
234
  short: {};
173
235
  };
174
236
  }
237
+ /** Direction of a `DepositRecord` / `LPBorrowLendDepositRecord` event: funds entering or leaving the protocol. */
175
238
  export declare class DepositDirection {
176
239
  static readonly DEPOSIT: {
177
240
  deposit: {};
@@ -180,6 +243,13 @@ export declare class DepositDirection {
180
243
  withdraw: {};
181
244
  };
182
245
  }
246
+ /**
247
+ * Mirrors the on-chain `OracleSource` enum, identifying which oracle provider/decoder to use for
248
+ * a market's `oracle` account. The `1K`/`1M` suffixes scale the raw feed price by 1e3/1e6 (used
249
+ * for low-priced assets like BONK). `DEPRECATED_SWITCHBOARD`/`DEPRECATED_SWITCHBOARD_ON_DEMAND`
250
+ * are inert stubs — using them returns `InvalidOracle`. `Prelaunch` reads from a `PrelaunchOracle`
251
+ * account instead of an external feed.
252
+ */
183
253
  export declare class OracleSource {
184
254
  static readonly PYTH: {
185
255
  pyth: {};
@@ -199,8 +269,8 @@ export declare class OracleSource {
199
269
  static readonly PYTH_1M_PULL: {
200
270
  pyth1MPull: {};
201
271
  };
202
- static readonly SWITCHBOARD: {
203
- switchboard: {};
272
+ static readonly DEPRECATED_SWITCHBOARD: {
273
+ deprecatedSwitchboard: {};
204
274
  };
205
275
  static readonly QUOTE_ASSET: {
206
276
  quoteAsset: {};
@@ -214,8 +284,8 @@ export declare class OracleSource {
214
284
  static readonly Prelaunch: {
215
285
  prelaunch: {};
216
286
  };
217
- static readonly SWITCHBOARD_ON_DEMAND: {
218
- switchboardOnDemand: {};
287
+ static readonly DEPRECATED_SWITCHBOARD_ON_DEMAND: {
288
+ deprecatedSwitchboardOnDemand: {};
219
289
  };
220
290
  static readonly PYTH_LAZER: {
221
291
  pythLazer: {};
@@ -230,6 +300,13 @@ export declare class OracleSource {
230
300
  pythLazerStableCoin: {};
231
301
  };
232
302
  }
303
+ /**
304
+ * Stable SDK-internal numeric encoding of `OracleSource`, used only for oracle-id string
305
+ * round-tripping (`getOracleSourceNum` ↔ `getOracleSourceFromNum` in `oracles/oracleId.ts`).
306
+ * NOTE: these numbers are **not** the on-chain Borsh discriminants and are **not** in the
307
+ * on-chain enum's declaration order — do not use them for raw memcmp filters against chain
308
+ * data. They only need to be self-consistent within the SDK.
309
+ */
233
310
  export declare class OracleSourceNum {
234
311
  static readonly PYTH = 0;
235
312
  static readonly PYTH_1K = 1;
@@ -237,17 +314,18 @@ export declare class OracleSourceNum {
237
314
  static readonly PYTH_PULL = 3;
238
315
  static readonly PYTH_1K_PULL = 4;
239
316
  static readonly PYTH_1M_PULL = 5;
240
- static readonly SWITCHBOARD = 6;
317
+ static readonly DEPRECATED_SWITCHBOARD = 6;
241
318
  static readonly QUOTE_ASSET = 7;
242
319
  static readonly PYTH_STABLE_COIN = 8;
243
320
  static readonly PYTH_STABLE_COIN_PULL = 9;
244
321
  static readonly PRELAUNCH = 10;
245
- static readonly SWITCHBOARD_ON_DEMAND = 11;
322
+ static readonly DEPRECATED_SWITCHBOARD_ON_DEMAND = 11;
246
323
  static readonly PYTH_LAZER = 12;
247
324
  static readonly PYTH_LAZER_1K = 13;
248
325
  static readonly PYTH_LAZER_1M = 14;
249
326
  static readonly PYTH_LAZER_STABLE_COIN = 15;
250
327
  }
328
+ /** The order's price-determination mechanism: `LIMIT`/`TRIGGER_LIMIT` use `Order.price`, `MARKET`/`TRIGGER_MARKET` fill at the best available price (subject to any auction), and `ORACLE` prices relative to the oracle via `Order.oraclePriceOffset`. `TRIGGER_*` variants only become active once `Order.triggerPrice` is crossed. */
251
329
  export declare class OrderType {
252
330
  static readonly LIMIT: {
253
331
  limit: {};
@@ -265,7 +343,9 @@ export declare class OrderType {
265
343
  oracle: {};
266
344
  };
267
345
  }
346
+ /** String-literal twin of `MarketType`, used where a plain `'perp' | 'spot'` string (not the `{variant: {}}` shape) is more convenient, e.g. UI/query params. */
268
347
  export declare type MarketTypeStr = 'perp' | 'spot';
348
+ /** Whether an order/position/market is on the spot or perp side of the protocol. */
269
349
  export declare class MarketType {
270
350
  static readonly SPOT: {
271
351
  spot: {};
@@ -274,6 +354,7 @@ export declare class MarketType {
274
354
  perp: {};
275
355
  };
276
356
  }
357
+ /** Lifecycle state of an `Order`: `INIT` (unused slot), `OPEN` (live, may still be filled), `FILLED` (fully filled), `CANCELED`. */
277
358
  export declare class OrderStatus {
278
359
  static readonly INIT: {
279
360
  init: {};
@@ -288,12 +369,27 @@ export declare class OrderStatus {
288
369
  canceled: {};
289
370
  };
290
371
  }
372
+ /**
373
+ * Bitmask mirror of `Order.bitFlags` / `OrderParams.bitFlags`.
374
+ * - `SignedMessage`: order originated from a signed off-chain message (swift/signed-msg flow).
375
+ * - `OracleTriggerMarket`: a `TriggerMarket` order whose trigger condition is evaluated against
376
+ * the oracle price rather than the last mark/fill price.
377
+ * - `SafeTriggerOrder`: exempts the order from the AMM's low-risk-fill slot-delay gate — it may
378
+ * be immediately filled by the AMM once triggered, or when the order itself is a liquidation.
379
+ * - `NewTriggerReduceOnly`: for a reduce-only order that has triggered, suppresses updating the
380
+ * user's `openBids`/`openAsks` counters (avoids double-counting margin already reserved).
381
+ * - `HasBuilder`: the order carries a `builderIdx`/`builderFeeTenthBps` builder-code fee split.
382
+ * - `IsIsolatedPosition`: the order trades against/opens an isolated-margin position rather than cross margin.
383
+ */
291
384
  export declare class OrderBitFlag {
292
385
  static readonly SignedMessage = 1;
293
386
  static readonly OracleTriggerMarket = 2;
294
387
  static readonly SafeTriggerOrder = 4;
295
388
  static readonly NewTriggerReduceOnly = 8;
389
+ static readonly HasBuilder = 16;
390
+ static readonly IsIsolatedPosition = 32;
296
391
  }
392
+ /** The kind of action an `OrderActionRecord` event describes. */
297
393
  export declare class OrderAction {
298
394
  static readonly PLACE: {
299
395
  place: {};
@@ -311,6 +407,7 @@ export declare class OrderAction {
311
407
  trigger: {};
312
408
  };
313
409
  }
410
+ /** Why an `OrderActionRecord` event happened — the specific reason a fill/cancel/expire/trigger occurred (e.g. which fulfillment method filled the order, or why it was rejected/canceled). */
314
411
  export declare class OrderActionExplanation {
315
412
  static readonly NONE: {
316
413
  none: {};
@@ -364,6 +461,7 @@ export declare class OrderActionExplanation {
364
461
  transferPerpPosition: {};
365
462
  };
366
463
  }
464
+ /** Trigger-order condition on `Order.triggerCondition`. `ABOVE`/`BELOW` are the pending (not-yet-triggered) states; `TRIGGERED_ABOVE`/`TRIGGERED_BELOW` record that the condition has already fired, so the order is now live for filling. */
367
465
  export declare class OrderTriggerCondition {
368
466
  static readonly ABOVE: {
369
467
  above: {};
@@ -378,6 +476,7 @@ export declare class OrderTriggerCondition {
378
476
  triggeredBelow: {};
379
477
  };
380
478
  }
479
+ /** Why a `DepositRecord` event happened: a direct transfer, a borrow being drawn, a borrow being repaid, or a protocol reward credit. */
381
480
  export declare class DepositExplanation {
382
481
  static readonly NONE: {
383
482
  none: {};
@@ -395,6 +494,7 @@ export declare class DepositExplanation {
395
494
  reward: {};
396
495
  };
397
496
  }
497
+ /** Why a `SettlePnlRecord` event happened: a normal settle, or settlement of an expired-market position at the market's `expiryPrice`. */
398
498
  export declare class SettlePnlExplanation {
399
499
  static readonly NONE: {
400
500
  none: {};
@@ -403,6 +503,7 @@ export declare class SettlePnlExplanation {
403
503
  expiredPosition: {};
404
504
  };
405
505
  }
506
+ /** The insurance-fund-stake action an `InsuranceFundStakeRecord` event describes. */
406
507
  export declare class StakeAction {
407
508
  static readonly STAKE: {
408
509
  stake: {};
@@ -423,6 +524,7 @@ export declare class StakeAction {
423
524
  stakeTransfer: {};
424
525
  };
425
526
  }
527
+ /** Fill/settle-PnL strictness passed to settle-PnL instructions: `TRY_SETTLE` settles as much as is safe and never fails outright, `MUST_SETTLE` requires the full requested settlement to succeed or the instruction reverts. */
426
528
  export declare class SettlePnlMode {
427
529
  static readonly TRY_SETTLE: {
428
530
  trySettle: {};
@@ -431,15 +533,21 @@ export declare class SettlePnlMode {
431
533
  mustSettle: {};
432
534
  };
433
535
  }
536
+ /** Returns true if the Anchor enum-class instance `object` (shape `{ [variant]: {} }`) is the given variant key. */
434
537
  export declare function isVariant(object: unknown, type: string): boolean;
538
+ /** Returns true if the Anchor enum-class instance `object` matches any of the given variant keys. */
435
539
  export declare function isOneOfVariant(object: unknown, types: string[]): boolean;
540
+ /** Returns the sole variant key of an Anchor enum-class instance (shape `{ [variant]: {} }`), e.g. `"long"` for `PositionDirection.LONG`. */
436
541
  export declare function getVariant(object: unknown): string;
542
+ /** Aggressor side of a trade for candle/trade-history purposes. `None` is used when a fill has no clear taker side (e.g. some liquidations). */
437
543
  export declare enum TradeSide {
438
544
  None = 0,
439
545
  Buy = 1,
440
546
  Sell = 2
441
547
  }
548
+ /** Candle bucket size in minutes (`'1'`…`'240'`), or `'D'`/`'W'`/`'M'` for day/week/month candles. */
442
549
  export type CandleResolution = '1' | '5' | '15' | '60' | '240' | 'D' | 'W' | 'M';
550
+ /** Emitted when a new `UserAccount` sub-account is created. */
443
551
  export type NewUserRecord = {
444
552
  ts: BN;
445
553
  userAuthority: PublicKey;
@@ -448,6 +556,7 @@ export type NewUserRecord = {
448
556
  name: number[];
449
557
  referrer: PublicKey;
450
558
  };
559
+ /** Emitted on every deposit, withdraw, or internal transfer that moves tokens into/out of a spot market. */
451
560
  export type DepositRecord = {
452
561
  ts: BN;
453
562
  userAuthority: PublicKey;
@@ -457,64 +566,104 @@ export type DepositRecord = {
457
566
  withdraw?: any;
458
567
  };
459
568
  marketIndex: number;
569
+ /** amount moved, in the spot market's token-mint precision (`SpotMarketConfig.precision`) */
460
570
  amount: BN;
571
+ /** PRICE_PRECISION (1e6) */
461
572
  oraclePrice: BN;
573
+ /** market's total deposit balance after this action, SPOT_BALANCE_PRECISION (1e9) scaled balance */
462
574
  marketDepositBalance: BN;
575
+ /** market's total borrow balance after this action, SPOT_BALANCE_PRECISION (1e9) scaled balance */
463
576
  marketWithdrawBalance: BN;
577
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
464
578
  marketCumulativeDepositInterest: BN;
579
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
465
580
  marketCumulativeBorrowInterest: BN;
581
+ /** user's lifetime deposits after this action, QUOTE_PRECISION (1e6) */
466
582
  totalDepositsAfter: BN;
583
+ /** user's lifetime withdraws after this action, QUOTE_PRECISION (1e6) */
467
584
  totalWithdrawsAfter: BN;
468
585
  depositRecordId: BN;
469
586
  explanation: DepositExplanation;
587
+ /** set when this was a `transferDeposit`: the counterparty user account */
470
588
  transferUser?: PublicKey;
589
+ /** the signer that authorized the action, when different from the user's own authority (e.g. a delegate or keeper) */
471
590
  signer?: PublicKey;
591
+ /** the user's token amount (deposit/borrow value) after this action, spot market token-mint precision */
472
592
  userTokenAmountAfter: BN;
473
593
  };
594
+ /** Emitted whenever a spot market's cumulative deposit/borrow interest is updated. */
474
595
  export type SpotInterestRecord = {
475
596
  ts: BN;
476
597
  marketIndex: number;
598
+ /** SPOT_BALANCE_PRECISION (1e9) */
477
599
  depositBalance: BN;
600
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
478
601
  cumulativeDepositInterest: BN;
602
+ /** SPOT_BALANCE_PRECISION (1e9) */
479
603
  borrowBalance: BN;
604
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
480
605
  cumulativeBorrowInterest: BN;
606
+ /** SPOT_UTILIZATION_PRECISION (1e6) */
481
607
  optimalUtilization: number;
608
+ /** SPOT_RATE_PRECISION (1e6) */
482
609
  optimalBorrowRate: number;
610
+ /** SPOT_RATE_PRECISION (1e6) */
483
611
  maxBorrowRate: number;
484
612
  };
613
+ /** Emitted when a perp market's AMM curve is adjusted (repeg or `k` update). */
485
614
  export type AmmCurveChanged = {
486
615
  ts: BN;
487
616
  marketIndex: number;
617
+ /** PEG_PRECISION (1e6) */
488
618
  pegMultiplierBefore: BN;
619
+ /** AMM_RESERVE_PRECISION (1e9) */
489
620
  baseAssetReserveBefore: BN;
621
+ /** AMM_RESERVE_PRECISION (1e9) */
490
622
  quoteAssetReserveBefore: BN;
623
+ /** AMM_RESERVE_PRECISION (1e9) */
491
624
  sqrtKBefore: BN;
625
+ /** PEG_PRECISION (1e6) */
492
626
  pegMultiplierAfter: BN;
627
+ /** AMM_RESERVE_PRECISION (1e9) */
493
628
  baseAssetReserveAfter: BN;
629
+ /** AMM_RESERVE_PRECISION (1e9) */
494
630
  quoteAssetReserveAfter: BN;
631
+ /** AMM_RESERVE_PRECISION (1e9) */
495
632
  sqrtKAfter: BN;
633
+ /** signed cost of the curve adjustment, QUOTE_PRECISION (1e6) */
496
634
  adjustmentCost: BN;
635
+ /** QUOTE_PRECISION (1e6) */
497
636
  totalFeeMinusDistributionsAfter: BN;
637
+ /** PRICE_PRECISION (1e6) */
498
638
  oraclePrice: BN;
499
639
  };
640
+ /** Emitted on insurance-fund vault operations (init/add/request-remove/remove) for a spot market's IF, keyed by the perp market that triggered it when settling a deficit. */
500
641
  export declare type InsuranceFundRecord = {
501
642
  ts: BN;
502
643
  spotMarketIndex: number;
503
644
  perpMarketIndex: number;
645
+ /** IF_FACTOR_PRECISION (1e6) share of this action attributed to the user */
504
646
  userIfFactor: number;
647
+ /** IF_FACTOR_PRECISION (1e6) total IF factor at the time of the action */
505
648
  totalIfFactor: number;
649
+ /** spot market vault token balance before the action, spot market token-mint precision */
506
650
  vaultAmountBefore: BN;
651
+ /** insurance-fund vault token balance before the action, spot market token-mint precision */
507
652
  insuranceVaultAmountBefore: BN;
508
653
  totalIfSharesBefore: BN;
509
654
  totalIfSharesAfter: BN;
655
+ /** amount moved, spot market token-mint precision */
510
656
  amount: BN;
511
657
  };
658
+ /** Emitted on every `InsuranceFundStake` account mutation (stake, unstake request/cancel, unstake, transfer). */
512
659
  export declare type InsuranceFundStakeRecord = {
513
660
  ts: BN;
514
661
  userAuthority: PublicKey;
515
662
  action: StakeAction;
663
+ /** amount staked/unstaked, spot market token-mint precision */
516
664
  amount: BN;
517
665
  marketIndex: number;
666
+ /** insurance-fund vault token balance before the action, spot market token-mint precision */
518
667
  insuranceVaultAmountBefore: BN;
519
668
  ifSharesBefore: BN;
520
669
  userIfSharesBefore: BN;
@@ -523,39 +672,59 @@ export declare type InsuranceFundStakeRecord = {
523
672
  userIfSharesAfter: BN;
524
673
  totalIfSharesAfter: BN;
525
674
  };
675
+ /** Emitted every time a perp market's funding rate is updated. */
526
676
  export type FundingRateRecord = {
527
677
  ts: BN;
528
678
  recordId: BN;
529
679
  marketIndex: number;
680
+ /** unit is quote per base, FUNDING_RATE_PRECISION (1e9) */
530
681
  fundingRate: BN;
682
+ /** FUNDING_RATE_PRECISION (1e9) */
531
683
  fundingRateLong: BN;
684
+ /** FUNDING_RATE_PRECISION (1e9) */
532
685
  fundingRateShort: BN;
686
+ /** FUNDING_RATE_PRECISION (1e9) */
533
687
  cumulativeFundingRateLong: BN;
688
+ /** FUNDING_RATE_PRECISION (1e9) */
534
689
  cumulativeFundingRateShort: BN;
690
+ /** PRICE_PRECISION (1e6) */
535
691
  oraclePriceTwap: BN;
692
+ /** PRICE_PRECISION (1e6) */
536
693
  markPriceTwap: BN;
694
+ /** BASE_PRECISION (1e9) */
537
695
  baseAssetAmountWithAmm: BN;
538
696
  };
697
+ /** Emitted whenever a user's perp position settles a funding payment. */
539
698
  export type FundingPaymentRecord = {
540
699
  ts: BN;
541
700
  userAuthority: PublicKey;
542
701
  user: PublicKey;
543
702
  marketIndex: number;
703
+ /** signed, positive = user received funding; QUOTE_PRECISION (1e6) */
544
704
  fundingPayment: BN;
705
+ /** the position size the payment was calculated against, BASE_PRECISION (1e9) */
545
706
  baseAssetAmount: BN;
707
+ /** the user's cumulative funding rate prior to this payment, FUNDING_RATE_PRECISION (1e9) */
546
708
  userLastCumulativeFunding: BN;
709
+ /** FUNDING_RATE_PRECISION (1e9) */
547
710
  ammCumulativeFundingLong: BN;
711
+ /** FUNDING_RATE_PRECISION (1e9) */
548
712
  ammCumulativeFundingShort: BN;
549
713
  };
714
+ /** Emitted for every liquidation action. Exactly one of `liquidatePerp`/`liquidateSpot`/`liquidateBorrowForPerpPnl`/`liquidatePerpPnlForDeposit`/`perpBankruptcy`/`spotBankruptcy` is populated, selected by `liquidationType`; the others are left as zeroed defaults. */
550
715
  export type LiquidationRecord = {
551
716
  ts: BN;
552
717
  user: PublicKey;
553
718
  liquidator: PublicKey;
554
719
  liquidationType: LiquidationType;
720
+ /** QUOTE_PRECISION (1e6) */
555
721
  marginRequirement: BN;
722
+ /** signed, QUOTE_PRECISION (1e6) */
556
723
  totalCollateral: BN;
724
+ /** cumulative margin freed by this liquidation so far, QUOTE_PRECISION (1e6) */
557
725
  marginFreed: BN;
558
726
  liquidationId: number;
727
+ /** true if the user was bankrupt (their loss exceeded their collateral) as of this action */
559
728
  bankrupt: boolean;
560
729
  canceledOrderIds: number[];
561
730
  liquidatePerp: LiquidatePerpRecord;
@@ -564,8 +733,10 @@ export type LiquidationRecord = {
564
733
  liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
565
734
  perpBankruptcy: PerpBankruptcyRecord;
566
735
  spotBankruptcy: SpotBankruptcyRecord;
736
+ /** bitmask, see `LiquidationBitFlag` */
567
737
  bitFlags: number;
568
738
  };
739
+ /** Which liquidation path a `LiquidationRecord` describes; selects which of the record's sub-record fields is populated. */
569
740
  export declare class LiquidationType {
570
741
  static readonly LIQUIDATE_PERP: {
571
742
  liquidatePerp: {};
@@ -586,86 +757,131 @@ export declare class LiquidationType {
586
757
  liquidateSpot: {};
587
758
  };
588
759
  }
760
+ /** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_PERP`: a perp position was force-closed. */
589
761
  export type LiquidatePerpRecord = {
590
762
  marketIndex: number;
763
+ /** PRICE_PRECISION (1e6) */
591
764
  oraclePrice: BN;
765
+ /** signed size transferred to the liquidator, BASE_PRECISION (1e9) */
592
766
  baseAssetAmount: BN;
767
+ /** QUOTE_PRECISION (1e6) */
593
768
  quoteAssetAmount: BN;
594
769
  userOrderId: number;
595
770
  liquidatorOrderId: number;
596
771
  fillRecordId: BN;
772
+ /** paid to the liquidator, LIQUIDATOR_FEE_PRECISION (1e6)-denominated rate applied to `quoteAssetAmount`; QUOTE_PRECISION (1e6) amount */
597
773
  liquidatorFee: BN;
774
+ /** cut routed to the insurance fund, QUOTE_PRECISION (1e6) */
598
775
  ifFee: BN;
776
+ /** cut routed to the protocol fee pool, QUOTE_PRECISION (1e6) */
599
777
  protocolFee: BN;
600
778
  };
779
+ /** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_SPOT`: a spot borrow was liquidated against a spot asset deposit. */
601
780
  export type LiquidateSpotRecord = {
602
781
  assetMarketIndex: number;
782
+ /** PRICE_PRECISION (1e6) */
603
783
  assetPrice: BN;
784
+ /** asset market token-mint precision */
604
785
  assetTransfer: BN;
605
786
  liabilityMarketIndex: number;
787
+ /** PRICE_PRECISION (1e6) */
606
788
  liabilityPrice: BN;
789
+ /** liability market token-mint precision */
607
790
  liabilityTransfer: BN;
791
+ /** liability market token-mint precision */
608
792
  ifFee: BN;
793
+ /** liability market token-mint precision */
609
794
  protocolFee: BN;
610
795
  };
796
+ /** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_BORROW_FOR_PERP_PNL`: a user's negative perp PnL was covered by seizing one of their spot borrows/deposits. */
611
797
  export type LiquidateBorrowForPerpPnlRecord = {
612
798
  perpMarketIndex: number;
799
+ /** PRICE_PRECISION (1e6) */
613
800
  marketOraclePrice: BN;
801
+ /** QUOTE_PRECISION (1e6) */
614
802
  pnlTransfer: BN;
615
803
  liabilityMarketIndex: number;
804
+ /** PRICE_PRECISION (1e6) */
616
805
  liabilityPrice: BN;
806
+ /** liability market token-mint precision */
617
807
  liabilityTransfer: BN;
618
808
  };
809
+ /** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_PERP_PNL_FOR_DEPOSIT`: a user's positive perp PnL was seized to cover a deficit, paid out from one of their spot deposits. */
619
810
  export type LiquidatePerpPnlForDepositRecord = {
620
811
  perpMarketIndex: number;
812
+ /** PRICE_PRECISION (1e6) */
621
813
  marketOraclePrice: BN;
814
+ /** QUOTE_PRECISION (1e6) */
622
815
  pnlTransfer: BN;
623
816
  assetMarketIndex: number;
817
+ /** PRICE_PRECISION (1e6) */
624
818
  assetPrice: BN;
819
+ /** asset market token-mint precision */
625
820
  assetTransfer: BN;
626
821
  };
822
+ /** Populated on `LiquidationRecord` when `liquidationType` is `PERP_BANKRUPTCY`: a user's unpaid perp loss was resolved via insurance-fund payout and/or socialized loss (`clawbackUser`/`clawbackUserPayment` set only when a clawback source exists). */
627
823
  export type PerpBankruptcyRecord = {
628
824
  marketIndex: number;
825
+ /** the bankrupt (unresolved negative) pnl, signed, QUOTE_PRECISION (1e6) */
629
826
  pnl: BN;
827
+ /** amount paid from the insurance fund, QUOTE_PRECISION (1e6) */
630
828
  ifPayment: BN;
631
829
  clawbackUser: PublicKey | null;
830
+ /** QUOTE_PRECISION (1e6), set only when `clawbackUser` is set */
632
831
  clawbackUserPayment: BN | null;
832
+ /** FUNDING_RATE_PRECISION (1e9) */
633
833
  cumulativeFundingRateDelta: BN;
634
834
  };
835
+ /** Populated on `LiquidationRecord` when `liquidationType` is `SPOT_BANKRUPTCY`: a user's unpaid spot borrow was resolved via insurance-fund payout and socialized loss. */
635
836
  export type SpotBankruptcyRecord = {
636
837
  marketIndex: number;
838
+ /** spot market token-mint precision */
637
839
  borrowAmount: BN;
840
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
638
841
  cumulativeDepositInterestDelta: BN;
842
+ /** amount paid from the insurance fund, spot market token-mint precision */
639
843
  ifPayment: BN;
640
844
  };
845
+ /** Bitmask mirror of `LiquidationRecord.bitFlags`. `IsolatedPosition` marks that the liquidation acted on an isolated-margin position rather than the user's cross-margin account. */
641
846
  export declare class LiquidationBitFlag {
642
847
  static readonly IsolatedPosition = 1;
643
848
  }
849
+ /** Emitted every time a user's perp PnL is settled against the market's pnl pool. */
644
850
  export type SettlePnlRecord = {
645
851
  ts: BN;
646
852
  user: PublicKey;
647
853
  marketIndex: number;
854
+ /** signed amount settled, QUOTE_PRECISION (1e6) */
648
855
  pnl: BN;
856
+ /** the position size at settlement time, BASE_PRECISION (1e9) */
649
857
  baseAssetAmount: BN;
858
+ /** `PerpPosition.quoteAssetAmount` after settlement, QUOTE_PRECISION (1e6) */
650
859
  quoteAssetAmountAfter: BN;
860
+ /** `PerpPosition.quoteEntryAmount` at settlement time, QUOTE_PRECISION (1e6) */
651
861
  quoteEntryAmount: BN;
862
+ /** the price pnl was settled at, PRICE_PRECISION (1e6) */
652
863
  settlePrice: BN;
653
864
  explanation: SettlePnlExplanation;
654
865
  };
866
+ /** Emitted when a signed off-chain (swift) order message is matched/recorded on-chain, so indexers can associate the signed message with its resulting order. */
655
867
  export type SignedMsgOrderRecord = {
656
868
  ts: BN;
657
869
  user: PublicKey;
870
+ /** hash of the signed message, used to dedupe/look up the original signed order */
658
871
  hash: string;
659
872
  matchingOrderParams: OrderParams;
873
+ /** slot after which the signed message is no longer eligible to be placed */
660
874
  signedMsgOrderMaxSlot: BN;
661
875
  signedMsgOrderUuid: Uint8Array;
662
876
  userOrderId: number;
663
877
  };
878
+ /** Emitted whenever an `Order` slot is written (placed, updated on fill, canceled, expired, triggered) — a full snapshot of the order's post-action state. */
664
879
  export type OrderRecord = {
665
880
  ts: BN;
666
881
  user: PublicKey;
667
882
  order: Order;
668
883
  };
884
+ /** Emitted for every order lifecycle action (place/fill/cancel/expire/trigger). Taker/maker fields are `null` when not applicable to the action (e.g. AMM fills have no `maker`). */
669
885
  export type OrderActionRecord = {
670
886
  ts: BN;
671
887
  action: OrderAction;
@@ -673,109 +889,170 @@ export type OrderActionRecord = {
673
889
  marketIndex: number;
674
890
  marketType: MarketType;
675
891
  filler: PublicKey | null;
892
+ /** paid to the filler/keeper, QUOTE_PRECISION (1e6) */
676
893
  fillerReward: BN | null;
677
894
  fillRecordId: BN | null;
895
+ /** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
678
896
  baseAssetAmountFilled: BN | null;
897
+ /** QUOTE_PRECISION (1e6) */
679
898
  quoteAssetAmountFilled: BN | null;
899
+ /** QUOTE_PRECISION (1e6) */
680
900
  takerFee: BN | null;
901
+ /** rebate paid to the maker (can be negative if the maker pays a fee), QUOTE_PRECISION (1e6) */
681
902
  makerFee: BN | null;
903
+ /** BPS_PRECISION-style share of the taker fee credited to the referrer */
682
904
  referrerReward: number | null;
905
+ /** taker's price improvement vs. their limit/oracle price, QUOTE_PRECISION (1e6) */
683
906
  quoteAssetAmountSurplus: BN | null;
907
+ /** fee charged by the spot fulfillment method (e.g. an external DEX), spot market token-mint precision */
684
908
  spotFulfillmentMethodFee: BN | null;
685
909
  taker: PublicKey | null;
686
910
  takerOrderId: number | null;
687
911
  takerOrderDirection: PositionDirection | null;
912
+ /** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
688
913
  takerOrderBaseAssetAmount: BN | null;
914
+ /** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
689
915
  takerOrderCumulativeBaseAssetAmountFilled: BN | null;
916
+ /** QUOTE_PRECISION (1e6) */
690
917
  takerOrderCumulativeQuoteAssetAmountFilled: BN | null;
691
918
  maker: PublicKey | null;
692
919
  makerOrderId: number | null;
693
920
  makerOrderDirection: PositionDirection | null;
921
+ /** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
694
922
  makerOrderBaseAssetAmount: BN | null;
923
+ /** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
695
924
  makerOrderCumulativeBaseAssetAmountFilled: BN | null;
925
+ /** QUOTE_PRECISION (1e6) */
696
926
  makerOrderCumulativeQuoteAssetAmountFilled: BN | null;
927
+ /** PRICE_PRECISION (1e6) */
697
928
  oraclePrice: BN;
929
+ /** bitmask, currently records isolated-margin/builder-fee flags mirrored from `OrderBitFlag` */
698
930
  bitFlags: number;
931
+ /** taker's `PerpPosition.quoteEntryAmount` immediately before this fill, QUOTE_PRECISION (1e6) */
699
932
  takerExistingQuoteEntryAmount: BN | null;
933
+ /** taker's `PerpPosition.baseAssetAmount` immediately before this fill, BASE_PRECISION (1e9) */
700
934
  takerExistingBaseAssetAmount: BN | null;
935
+ /** maker's `PerpPosition.quoteEntryAmount` immediately before this fill, QUOTE_PRECISION (1e6) */
701
936
  makerExistingQuoteEntryAmount: BN | null;
937
+ /** maker's `PerpPosition.baseAssetAmount` immediately before this fill, BASE_PRECISION (1e9) */
702
938
  makerExistingBaseAssetAmount: BN | null;
939
+ /** PRICE_PRECISION (1e6), set only for trigger-order fills */
703
940
  triggerPrice: BN | null;
941
+ /** index into the taker's `RevenueShareEscrow.approvedBuilders`, set only when the taker order had `OrderBitFlag.HasBuilder` */
704
942
  builderIdx: number | null;
943
+ /** builder fee charged on this fill, QUOTE_PRECISION (1e6) */
705
944
  builderFee: BN | null;
706
945
  };
946
+ /** Emitted on every constant-product spot swap (`beginSwap`/`endSwap`) between two spot markets. */
707
947
  export type SwapRecord = {
708
948
  ts: BN;
709
949
  user: PublicKey;
950
+ /** out market token-mint precision */
710
951
  amountOut: BN;
952
+ /** in market token-mint precision */
711
953
  amountIn: BN;
712
954
  outMarketIndex: number;
713
955
  inMarketIndex: number;
956
+ /** PRICE_PRECISION (1e6) */
714
957
  outOraclePrice: BN;
958
+ /** PRICE_PRECISION (1e6) */
715
959
  inOraclePrice: BN;
960
+ /** total fee charged on the swap, out market token-mint precision */
716
961
  fee: BN;
717
962
  };
963
+ /** Emitted when a spot market's vault balance is reconciled against `SpotMarketAccount.depositBalance`/`borrowBalance` (drift/donation detection). */
718
964
  export type SpotMarketVaultDepositRecord = {
719
965
  ts: BN;
720
966
  marketIndex: number;
967
+ /** SPOT_BALANCE_PRECISION (1e9) */
721
968
  depositBalance: BN;
969
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
722
970
  cumulativeDepositInterestBefore: BN;
971
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
723
972
  cumulativeDepositInterestAfter: BN;
973
+ /** spot market token-mint precision */
724
974
  depositTokenAmountBefore: BN;
975
+ /** spot market token-mint precision */
725
976
  amount: BN;
726
977
  };
978
+ /** Emitted when a `UserAccount` sub-account is deleted. */
727
979
  export type DeleteUserRecord = {
728
980
  ts: BN;
729
981
  userAuthority: PublicKey;
730
982
  user: PublicKey;
731
983
  subAccountId: number;
984
+ /** set when a keeper (not the user/delegate) deleted an idle account */
732
985
  keeper: PublicKey | null;
733
986
  };
987
+ /** Emitted on every constituent-to-constituent swap inside an LP pool (`LPPoolAccount`). */
734
988
  export type LPSwapRecord = {
735
989
  ts: BN;
736
990
  slot: BN;
737
991
  authority: PublicKey;
992
+ /** out constituent's spot market token-mint precision */
738
993
  outAmount: BN;
994
+ /** in constituent's spot market token-mint precision */
739
995
  inAmount: BN;
996
+ /** out constituent's spot market token-mint precision */
740
997
  outFee: BN;
998
+ /** in constituent's spot market token-mint precision */
741
999
  inFee: BN;
742
1000
  outSpotMarketIndex: number;
743
1001
  inSpotMarketIndex: number;
744
1002
  outConstituentIndex: number;
745
1003
  inConstituentIndex: number;
1004
+ /** PRICE_PRECISION (1e6) */
746
1005
  outOraclePrice: BN;
1006
+ /** PRICE_PRECISION (1e6) */
747
1007
  inOraclePrice: BN;
1008
+ /** LP pool AUM at the time of the swap, QUOTE_PRECISION (1e6) */
748
1009
  lastAum: BN;
749
1010
  lastAumSlot: BN;
1011
+ /** PERCENTAGE_PRECISION (1e6) */
750
1012
  inMarketCurrentWeight: BN;
1013
+ /** PERCENTAGE_PRECISION (1e6) */
751
1014
  outMarketCurrentWeight: BN;
1015
+ /** PERCENTAGE_PRECISION (1e6) */
752
1016
  inMarketTargetWeight: BN;
1017
+ /** PERCENTAGE_PRECISION (1e6) */
753
1018
  outMarketTargetWeight: BN;
754
1019
  inSwapId: BN;
755
1020
  outSwapId: BN;
756
1021
  lpPool: PublicKey;
757
1022
  };
1023
+ /** Emitted when LP tokens are minted (deposit) or redeemed (withdraw) against an LP pool. */
758
1024
  export type LPMintRedeemRecord = {
759
1025
  ts: BN;
760
1026
  slot: BN;
761
1027
  authority: PublicKey;
1028
+ /** encodes mint vs. redeem (and any sub-variant); compare against the program's `MintRedeemDescription` discriminant */
762
1029
  description: number;
1030
+ /** constituent spot market token-mint precision */
763
1031
  amount: BN;
1032
+ /** constituent spot market token-mint precision */
764
1033
  fee: BN;
765
1034
  spotMarketIndex: number;
766
1035
  constituentIndex: number;
1036
+ /** PRICE_PRECISION (1e6) */
767
1037
  oraclePrice: BN;
768
1038
  mint: PublicKey;
1039
+ /** LP token precision (quote-mint precision, QUOTE_PRECISION 1e6) */
769
1040
  lpAmount: BN;
1041
+ /** LP token precision */
770
1042
  lpFee: BN;
1043
+ /** LP token price, PRICE_PRECISION (1e6) */
771
1044
  lpPrice: BN;
772
1045
  mintRedeemId: BN;
1046
+ /** LP pool AUM at the time of the action, QUOTE_PRECISION (1e6) */
773
1047
  lastAum: BN;
774
1048
  lastAumSlot: BN;
1049
+ /** PERCENTAGE_PRECISION (1e6) */
775
1050
  inMarketCurrentWeight: BN;
1051
+ /** PERCENTAGE_PRECISION (1e6) */
776
1052
  inMarketTargetWeight: BN;
777
1053
  lpPool: PublicKey;
778
1054
  };
1055
+ /** Emitted when a perp market settles PnL/fees with its hedging LP pool. */
779
1056
  export type LPSettleRecord = {
780
1057
  recordId: BN;
781
1058
  lastTs: BN;
@@ -783,25 +1060,53 @@ export type LPSettleRecord = {
783
1060
  ts: BN;
784
1061
  slot: BN;
785
1062
  perpMarketIndex: number;
1063
+ /** signed amount transferred to/from the LP pool, QUOTE_PRECISION (1e6) */
786
1064
  settleToLpAmount: BN;
1065
+ /** signed, QUOTE_PRECISION (1e6) */
787
1066
  perpAmmPnlDelta: BN;
1067
+ /** signed, QUOTE_PRECISION (1e6) */
788
1068
  perpAmmExFeeDelta: BN;
1069
+ /** LP pool AUM after this settle, QUOTE_PRECISION (1e6) */
789
1070
  lpAum: BN;
1071
+ /** LP token price after this settle, PRICE_PRECISION (1e6) */
790
1072
  lpPrice: BN;
791
1073
  lpPool: PublicKey;
792
1074
  };
1075
+ /** Emitted when an LP pool constituent's borrow/lend deposit into (or withdrawal from) the underlying spot market changes. */
793
1076
  export type LPBorrowLendDepositRecord = {
794
1077
  ts: BN;
795
1078
  slot: BN;
796
1079
  spotMarketIndex: number;
797
1080
  constituentIndex: number;
798
1081
  direction: DepositDirection;
1082
+ /** constituent spot market token-mint precision */
799
1083
  tokenBalance: BN;
1084
+ /** constituent spot market token-mint precision */
800
1085
  lastTokenBalance: BN;
1086
+ /** interest accrued since the last update, constituent spot market token-mint precision */
801
1087
  interestAccruedTokenAmount: BN;
1088
+ /** constituent spot market token-mint precision */
802
1089
  amountDepositWithdraw: BN;
803
1090
  lpPool: PublicKey;
804
1091
  };
1092
+ /**
1093
+ * The protocol's single global config account (one per deployment). Decoded mirror of the Rust
1094
+ * `State` zero-copy account.
1095
+ *
1096
+ * **Admin tiers** — three levels of authority, from slowest/most-trusted to fastest/least-trusted:
1097
+ * - `coldAdmin`: root authority, set once at `initialize`. Only key that can rotate `warmAdmin`
1098
+ * and `pauseAdmin`. Expected to sit behind a (small) timelocked multisig.
1099
+ * - `warmAdmin`: operational authority that can rotate the eleven `hot*` bot keys below.
1100
+ * `PublicKey.default()` means unset, in which case only `coldAdmin` can act.
1101
+ * - `pauseAdmin`: emergency-pause authority with no on-chain timelock — may only *add* pause bits
1102
+ * to `exchangeStatus` (never clear them); `coldAdmin`/`warmAdmin` retain full pause+unpause power.
1103
+ * `PublicKey.default()` means unassigned (only cold/warm can pause).
1104
+ *
1105
+ * **Hot role keys** (`hot*`): purpose-specific bot keys for high-frequency keeper actions (AMM
1106
+ * cranking, LP cache/swap/settle, feature-flag toggles, fuel, user-flag updates, vault deposits,
1107
+ * mm-oracle cranking, AMM spread adjustment, protocol-fee withdrawal). `PublicKey.default()` means
1108
+ * the role is unassigned and only `warmAdmin`/`coldAdmin` may call handlers gated on that role.
1109
+ */
805
1110
  export type StateAccount = {
806
1111
  coldAdmin: PublicKey;
807
1112
  warmAdmin: PublicKey;
@@ -816,9 +1121,13 @@ export type StateAccount = {
816
1121
  hotVaultDeposit: PublicKey;
817
1122
  hotMmOracleCrank: PublicKey;
818
1123
  hotAmmSpreadAdjust: PublicKey;
1124
+ /** hot key authorized to trigger protocol-fee withdrawals to `protocolFeeRecipientPerp`/`protocolFeeRecipientSpot` */
819
1125
  hotFeeWithdraw: PublicKey;
1126
+ /** treasury PERP protocol fees are withdrawn to (settable only by `coldAdmin`); `PublicKey.default()` makes perp fee withdrawals inert */
820
1127
  protocolFeeRecipientPerp: PublicKey;
1128
+ /** treasury SPOT protocol fees are withdrawn to (settable only by `coldAdmin`); `PublicKey.default()` makes spot fee withdrawals inert */
821
1129
  protocolFeeRecipientSpot: PublicKey;
1130
+ /** bitmask, see `ExchangeStatus` */
822
1131
  exchangeStatus: number;
823
1132
  whitelistMint: PublicKey;
824
1133
  discountMint: PublicKey;
@@ -827,113 +1136,187 @@ export type StateAccount = {
827
1136
  numberOfSubAccounts: BN;
828
1137
  numberOfMarkets: number;
829
1138
  numberOfSpotMarkets: number;
1139
+ /** slots */
830
1140
  minPerpAuctionDuration: number;
1141
+ /** seconds */
831
1142
  defaultMarketOrderTimeInForce: number;
1143
+ /** slots */
832
1144
  defaultSpotAuctionDuration: number;
1145
+ /** MARGIN_PRECISION (1e4); extra maintenance-margin buffer required before a liquidation may proceed */
833
1146
  liquidationMarginBufferRatio: number;
1147
+ /** seconds a market stays in `SETTLEMENT` status before positions must be settled */
834
1148
  settlementDuration: number;
835
1149
  maxNumberOfSubAccounts: number;
836
1150
  signer: PublicKey;
837
1151
  signerNonce: number;
838
1152
  srmVault: PublicKey;
1153
+ /** default `FeeStructure` applied to new perp markets */
839
1154
  perpFeeStructure: FeeStructure;
1155
+ /** default `FeeStructure` applied to new spot markets */
840
1156
  spotFeeStructure: FeeStructure;
1157
+ /** LIQUIDATION_PCT_PRECISION (1e4); fraction of a position liquidated per partial-liquidation pass */
841
1158
  initialPctToLiquidate: number;
1159
+ /** seconds a liquidation is spread over */
842
1160
  liquidationDuration: number;
1161
+ /** max SOL fee `getInitUserFee` may charge to create a new sub-account, in value/100 SOL (e.g. 100 = 1 SOL); ramps from 0 to this max as account-space utilization rises from 80% to 100% of `maxNumberOfSubAccounts` */
843
1162
  maxInitializeUserFee: number;
1163
+ /** bitmask, see `FeatureBitFlags` */
844
1164
  featureBitFlags: number;
1165
+ /** bitmask of LP-pool-specific feature flags */
845
1166
  lpPoolFeatureBitFlags: number;
1167
+ /** bitmask, see `SolvencyStatus` */
846
1168
  solvencyStatus: number;
847
1169
  };
1170
+ /** Decoded mirror of the on-chain `PerpMarket` zero-copy account. */
848
1171
  export type PerpMarketAccount = {
849
1172
  status: MarketStatus;
850
1173
  contractType: ContractType;
851
1174
  contractTier: ContractTier;
1175
+ /** unix timestamp the market will expire; only set if the market is reduce-only */
852
1176
  expiryTs: BN;
1177
+ /** PRICE_PRECISION (1e6); the price positions settle at, only set once the market is expired */
853
1178
  expiryPrice: BN;
854
1179
  marketIndex: number;
855
1180
  pubkey: PublicKey;
856
1181
  name: number[];
1182
+ /** the market's constant-product vAMM state */
857
1183
  amm: AMM;
1184
+ /** market-wide stats shared across all makers (mark/oracle TWAPs, volume, mm-oracle snapshot) */
858
1185
  marketStats: MarketStats;
859
1186
  numberOfUsersWithBase: number;
860
1187
  numberOfUsers: number;
1188
+ /** MARGIN_PRECISION (1e4); collateral fraction required to open a position, e.g. 1000 = 10% = 10x max leverage */
861
1189
  marginRatioInitial: number;
1190
+ /** MARGIN_PRECISION (1e4); collateral fraction below which a position is liquidated */
862
1191
  marginRatioMaintenance: number;
863
1192
  nextFillRecordId: BN;
864
1193
  nextFundingRateRecordId: BN;
1194
+ /** the market's pnl pool: increases when users settle negative pnl, decreases when users settle positive pnl; SPOT_BALANCE_PRECISION (1e9) scaled balance in the quote spot market */
865
1195
  pnlPool: PoolBalance;
1196
+ /** protocol-owned quote-denominated fee claim, withdrawn to `StateAccount.protocolFeeRecipientPerp`; SPOT_BALANCE_PRECISION (1e9) scaled balance */
866
1197
  protocolFeePool: PoolBalance;
1198
+ /** consolidated fee-split accounting: lifetime analytics counters plus pending protocol/IF/AMM carveouts */
867
1199
  feeLedger: FeeLedger;
1200
+ /** LIQUIDATOR_FEE_PRECISION (1e6); fee paid to the liquidator for taking over the position */
868
1201
  liquidatorFee: number;
1202
+ /** LIQUIDATOR_FEE_PRECISION (1e6); cut of a liquidation routed to the insurance fund */
869
1203
  ifLiquidationFee: number;
1204
+ /** LIQUIDATOR_FEE_PRECISION (1e6); protocol's cut of a liquidation, taken from the liquidatee */
870
1205
  protocolLiquidationFee: number;
1206
+ /** QUOTE_PRECISION (1e6); pnl-pool retention buffer the fee-sweep leaves untouched above `max(net_user_pnl, 0)` */
871
1207
  feePoolBufferTarget: BN;
1208
+ /** MARGIN_PRECISION (1e4); scales margin ratio up for large positions */
872
1209
  imfFactor: number;
1210
+ /** MARGIN_PRECISION (1e4); discounts positive-unrealized-pnl asset weight for large positions */
873
1211
  unrealizedPnlImfFactor: number;
1212
+ /** QUOTE_PRECISION (1e6); pnl imbalance (long pnl − short pnl) above which positive-pnl asset weight starts being discounted */
874
1213
  unrealizedPnlMaxImbalance: BN;
1214
+ /** SPOT_WEIGHT_PRECISION (1e4); initial-margin asset weight applied to a user's unrealized positive pnl */
875
1215
  unrealizedPnlInitialAssetWeight: number;
1216
+ /** SPOT_WEIGHT_PRECISION (1e4); maintenance-margin asset weight applied to a user's unrealized positive pnl */
876
1217
  unrealizedPnlMaintenanceAssetWeight: number;
1218
+ /** the market's claim on the insurance fund */
877
1219
  insuranceClaim: {
1220
+ /** QUOTE_PRECISION (1e6), signed: positive if funds left the market, negative if pulled in */
878
1221
  revenueWithdrawSinceLastSettle: BN;
1222
+ /** QUOTE_PRECISION (1e6); cap on revenue withdrawable per settle period */
879
1223
  maxRevenueWithdrawPerPeriod: BN;
880
1224
  lastRevenueWithdrawTs: BN;
1225
+ /** QUOTE_PRECISION (1e6); insurance already used to resolve bankruptcy/pnl deficits */
881
1226
  quoteSettledInsurance: BN;
1227
+ /** QUOTE_PRECISION (1e6); max insurance this market may draw to resolve bankruptcy/pnl deficits */
882
1228
  quoteMaxInsurance: BN;
883
1229
  };
884
1230
  quoteSpotMarketIndex: number;
1231
+ /** -100 to 100; percentage adjustment applied to the base fee rate (e.g. -50 halves a 5bps fee to 2.5bps) */
885
1232
  feeAdjustment: number;
1233
+ /** bitmask, see `PerpOperation` */
886
1234
  pausedOperations: number;
1235
+ /** PRICE_PRECISION (1e6); price of the most recent fill */
887
1236
  lastFillPrice: BN;
888
1237
  poolId: number;
1238
+ /** this market's relationship to its hedging LP pool; admin-set, never mutated per fill */
889
1239
  hedgeConfig: {
1240
+ /** the `LPPoolAccount.lpPoolId` this market hedges into */
890
1241
  poolId: number;
1242
+ /** hedging enabled for this market when non-zero */
891
1243
  status: number;
1244
+ /** bitmask of paused `ConstituentLpOperation`s */
892
1245
  pausedOperations: number;
1246
+ /** scalar excluding a share of exchange fees from hedge routing */
893
1247
  exchangeFeeExclusionScalar: number;
1248
+ /** scalar for the share of fees transferred to the hedge pool */
894
1249
  feeTransferScalar: number;
895
1250
  };
1251
+ /** bitmask, see `MarketConfigFlag` */
896
1252
  marketConfig: number;
897
1253
  oracle: PublicKey;
898
1254
  oracleSource: OracleSource;
1255
+ /** override for the per-fill slot delay required from the oracle; -1 = use the state default */
899
1256
  oracleSlotDelayOverride: number;
1257
+ /** override for `StateAccount.minPerpAuctionDuration`; 0 = no override, -1 = disable speed bump, 1-100 = literal speed bump slots */
900
1258
  oracleLowRiskSlotDelayOverride: number;
1259
+ /** always non-negative; total long open interest across all users, BASE_PRECISION (1e9) */
901
1260
  baseAssetAmountLong: BN;
1261
+ /** always non-positive; total short open interest across all users, BASE_PRECISION (1e9) */
902
1262
  baseAssetAmountShort: BN;
1263
+ /** sum of all users' `PerpPosition.quoteAssetAmount` in this market, QUOTE_PRECISION (1e6) */
903
1264
  quoteAssetAmount: BN;
1265
+ /** QUOTE_PRECISION (1e6) */
904
1266
  quoteEntryAmountLong: BN;
1267
+ /** QUOTE_PRECISION (1e6) */
905
1268
  quoteEntryAmountShort: BN;
1269
+ /** QUOTE_PRECISION (1e6) */
906
1270
  quoteBreakEvenAmountLong: BN;
1271
+ /** QUOTE_PRECISION (1e6) */
907
1272
  quoteBreakEvenAmountShort: BN;
1273
+ /** QUOTE_PRECISION (1e6); accumulated socialized loss paid by users in this market since inception */
908
1274
  totalSocialLoss: BN;
1275
+ /** BASE_PRECISION (1e9); max allowed open interest — trades that would breach this are blocked */
909
1276
  maxOpenInterest: BN;
1277
+ /** FUNDING_RATE_PRECISION (1e9) */
910
1278
  cumulativeFundingRateLong: BN;
1279
+ /** FUNDING_RATE_PRECISION (1e9) */
911
1280
  cumulativeFundingRateShort: BN;
1281
+ /** unit is quote per base, FUNDING_RATE_PRECISION (1e9) */
912
1282
  lastFundingRate: BN;
1283
+ /** FUNDING_RATE_PRECISION (1e9) */
913
1284
  lastFundingRateLong: BN;
1285
+ /** FUNDING_RATE_PRECISION (1e9) */
914
1286
  lastFundingRateShort: BN;
915
1287
  lastFundingRateTs: BN;
1288
+ /** unsettled funding pnl across the whole market */
916
1289
  netUnsettledFundingPnl: BN;
1290
+ /** BPS_PRECISION (1e4); dead-zone threshold for the funding premium — mark/oracle spreads within this band add no funding premium */
917
1291
  fundingClampThreshold: number;
1292
+ /** PERCENTAGE_PRECISION (1e6); slope of the funding premium ramp above the dead zone (1.0x = pass shrunk spread through unchanged) */
918
1293
  fundingRampSlope: number;
1294
+ /** orders must be a multiple of this, BASE_PRECISION (1e9) */
919
1295
  orderStepSize: BN;
1296
+ /** orders must be a multiple of this, PRICE_PRECISION (1e6) */
920
1297
  orderTickSize: BN;
921
1298
  };
1299
+ /** Oracle price/TWAP snapshot shared by `PerpMarketAccount.marketStats` and `SpotMarketAccount`. All price fields are PRICE_PRECISION (1e6). */
922
1300
  export type HistoricalOracleData = {
923
1301
  lastOraclePrice: BN;
1302
+ /** number of slots since the last oracle update */
924
1303
  lastOracleDelay: BN;
925
1304
  lastOracleConf: BN;
926
1305
  lastOraclePriceTwap: BN;
927
1306
  lastOraclePriceTwap5Min: BN;
1307
+ /** unix timestamp of the last TWAP snapshot */
928
1308
  lastOraclePriceTwapTs: BN;
929
1309
  };
1310
+ /** Rolling index-price stats for a spot market (bid/ask/TWAP of the underlying index, e.g. a basket or peg reference). All price fields are PRICE_PRECISION (1e6). */
930
1311
  export type HistoricalIndexData = {
931
1312
  lastIndexBidPrice: BN;
932
1313
  lastIndexAskPrice: BN;
933
1314
  lastIndexPriceTwap: BN;
934
1315
  lastIndexPriceTwap5Min: BN;
1316
+ /** unix timestamp of the last TWAP snapshot */
935
1317
  lastIndexPriceTwapTs: BN;
936
1318
  };
1319
+ /** Decoded mirror of the on-chain `SpotMarket` zero-copy account. */
937
1320
  export type SpotMarketAccount = {
938
1321
  status: MarketStatus;
939
1322
  assetTier: AssetTier;
@@ -941,225 +1324,382 @@ export type SpotMarketAccount = {
941
1324
  marketIndex: number;
942
1325
  pubkey: PublicKey;
943
1326
  mint: PublicKey;
1327
+ /** the market's token vault; balance should be >= `depositBalance` token amount − `borrowBalance` token amount */
944
1328
  vault: PublicKey;
945
1329
  oracle: PublicKey;
946
1330
  oracleSource: OracleSource;
947
1331
  historicalOracleData: HistoricalOracleData;
948
1332
  historicalIndexData: HistoricalIndexData;
1333
+ /** covers bankruptcies for borrows of this market's token and perps settling in this market's token */
949
1334
  insuranceFund: {
950
1335
  vault: PublicKey;
951
1336
  totalShares: BN;
952
1337
  userShares: BN;
1338
+ /** exponent used to rebase `totalShares`/`userShares` */
953
1339
  sharesBase: BN;
1340
+ /** seconds a stake must wait after an unstake request before it can be withdrawn */
954
1341
  unstakingPeriod: BN;
955
1342
  lastRevenueSettleTs: BN;
1343
+ /** seconds; how often `revenuePool` may settle into the IF vault */
956
1344
  revenueSettlePeriod: BN;
1345
+ /** IF_FACTOR_PRECISION (1e6); fraction of spot deposit-interest gains carved out to the (100% staker-owned) insurance fund */
957
1346
  ifFeeFactor: number;
958
1347
  };
1348
+ /** revenue this market's token has collected (e.g. for SOL-PERP, settled funds flow into the USDC revenue pool); SPOT_BALANCE_PRECISION (1e9) scaled balance */
959
1349
  revenuePool: PoolBalance;
1350
+ /** protocol-owned fee claim in this market's token, withdrawn to `StateAccount.protocolFeeRecipientSpot`; SPOT_BALANCE_PRECISION (1e9) scaled balance */
960
1351
  protocolFeePool: PoolBalance;
1352
+ /** LIQUIDATOR_FEE_PRECISION (1e6); cut of a liquidation routed to the insurance fund */
961
1353
  ifLiquidationFee: number;
1354
+ /** LIQUIDATOR_FEE_PRECISION (1e6); protocol's cut of a spot liquidation, taken from the liquidatee */
962
1355
  protocolLiquidationFee: number;
1356
+ /** IF_FACTOR_PRECISION (1e6); protocol's carveout of lending deposit-interest gains */
963
1357
  protocolFeeFactor: number;
1358
+ /** token mint decimals; token-mint precision throughout this account is 10^decimals */
964
1359
  decimals: number;
1360
+ /** SPOT_UTILIZATION_PRECISION (1e6) */
965
1361
  optimalUtilization: number;
1362
+ /** SPOT_RATE_PRECISION (1e6); borrow rate when the market is at `optimalUtilization` */
966
1363
  optimalBorrowRate: number;
1364
+ /** SPOT_RATE_PRECISION (1e6); borrow rate at 100% utilization */
967
1365
  maxBorrowRate: number;
1366
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
968
1367
  cumulativeDepositInterest: BN;
1368
+ /** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
969
1369
  cumulativeBorrowInterest: BN;
1370
+ /** token mint precision; accumulated socialized loss from borrows, in this market's own token */
970
1371
  totalSocialLoss: BN;
1372
+ /** QUOTE_PRECISION (1e6); accumulated socialized loss from borrows, converted to quote */
971
1373
  totalQuoteSocialLoss: BN;
1374
+ /** SPOT_BALANCE_PRECISION (1e9) scaled balance; multiply by `cumulativeDepositInterest` for the token amount */
972
1375
  depositBalance: BN;
1376
+ /** SPOT_BALANCE_PRECISION (1e9) scaled balance; multiply by `cumulativeBorrowInterest` for the token amount */
973
1377
  borrowBalance: BN;
1378
+ /** token mint precision; 0 = no limit */
974
1379
  maxTokenDeposits: BN;
975
1380
  lastInterestTs: BN;
976
1381
  lastTwapTs: BN;
1382
+ /** unix timestamp the market is set to expire; only set if reduce-only */
977
1383
  expiryTs: BN;
1384
+ /** SPOT_WEIGHT_PRECISION (1e4); e.g. 8000 (.8) means $100 of deposits contributes $80 to initial collateral */
978
1385
  initialAssetWeight: number;
1386
+ /** SPOT_WEIGHT_PRECISION (1e4); e.g. 9000 (.9) means $100 of deposits contributes $90 to maintenance collateral */
979
1387
  maintenanceAssetWeight: number;
1388
+ /** SPOT_WEIGHT_PRECISION (1e4); e.g. 9000 (.9) means $100 of borrows contributes $90 to the initial margin requirement */
980
1389
  initialLiabilityWeight: number;
1390
+ /** SPOT_WEIGHT_PRECISION (1e4); e.g. 8000 (.8) means $100 of borrows contributes $80 to the maintenance margin requirement */
981
1391
  maintenanceLiabilityWeight: number;
1392
+ /** LIQUIDATOR_FEE_PRECISION (1e6); fee paid to the liquidator for taking over the borrow/deposit */
982
1393
  liquidatorFee: number;
1394
+ /** MARGIN_PRECISION (1e4); scales liability weight up / asset weight down for large positions */
983
1395
  imfFactor: number;
1396
+ /** QUOTE_PRECISION (1e6); deposit level at which `initialAssetWeight` begins scaling down; 0 = disabled */
984
1397
  scaleInitialAssetWeightStart: BN;
1398
+ /** token mint precision; below this vault balance, no withdraw limits/guards apply */
985
1399
  withdrawGuardThreshold: BN;
1400
+ /** token mint precision; 24h rolling average of deposit token amount */
986
1401
  depositTokenTwap: BN;
1402
+ /** token mint precision; 24h rolling average of borrow token amount */
987
1403
  borrowTokenTwap: BN;
1404
+ /** SPOT_UTILIZATION_PRECISION (1e6); 24h rolling average utilization (borrow / total) */
988
1405
  utilizationTwap: BN;
989
1406
  nextDepositRecordId: BN;
1407
+ /** orders must be a multiple of this, token mint precision */
990
1408
  orderStepSize: BN;
1409
+ /** orders must be a multiple of this, PRICE_PRECISION (1e6) */
991
1410
  orderTickSize: BN;
1411
+ /** token mint precision */
992
1412
  minOrderSize: BN;
1413
+ /** token mint precision; 0 = no limit */
993
1414
  maxPositionSize: BN;
994
1415
  nextFillRecordId: BN;
1416
+ /** fees collected from swaps between this market and the quote market, settled to the quote market's revenue pool; SPOT_BALANCE_PRECISION (1e9) scaled balance */
995
1417
  spotFeePool: PoolBalance;
1418
+ /** QUOTE_PRECISION (1e6) */
996
1419
  totalSpotFee: BN;
1420
+ /** token mint precision; total fees received from swaps */
997
1421
  totalSwapFee: BN;
1422
+ /** token mint precision; amount loaned out in `beginSwap`, for the in-flight flash-loan invariant check */
998
1423
  flashLoanAmount: BN;
1424
+ /** token mint precision; user's token balance snapshotted at `beginSwap`, used to compute how much left the system by `endSwap` */
999
1425
  flashLoanInitialTokenAmount: BN;
1000
1426
  ordersEnabled: boolean;
1427
+ /** bitmask, see `SpotOperation` */
1001
1428
  pausedOperations: number;
1429
+ /** bitmask, see `InsuranceFundOperation` */
1002
1430
  ifPausedOperations: number;
1431
+ /** X/10000; fraction of `maxTokenDeposits` that may be borrowed in total; 0 disables the cap */
1003
1432
  maxTokenBorrowsFraction: number;
1433
+ /** X/200; floor borrow rate regardless of utilization */
1004
1434
  minBorrowRate: number;
1435
+ /** bitmask, see `TokenProgramFlag` */
1005
1436
  tokenProgramFlag: number;
1006
1437
  poolId: number;
1438
+ /** -100 to 100; percentage adjustment applied to the base fee rate */
1007
1439
  feeAdjustment: number;
1008
1440
  };
1441
+ /** A scaled token balance inside a market's internal pools (pnl pool, protocol fee pool, revenue pool, spot fee pool, AMM fee pool). Multiply `scaledBalance` (SPOT_BALANCE_PRECISION, 1e9) by the referenced spot market's `cumulativeDepositInterest`/`cumulativeBorrowInterest` to get the token amount. */
1009
1442
  export type PoolBalance = {
1010
1443
  scaledBalance: BN;
1444
+ /** the spot market this balance's token amount is denominated in */
1011
1445
  marketIndex: number;
1012
1446
  };
1447
+ /**
1448
+ * Consolidated per-market fee ledger: lifetime analytics counters plus the pending
1449
+ * (not-yet-materialized) protocol/IF/AMM carveouts and the AMM's backstop-of-last-resort
1450
+ * clawback cap. All fields are QUOTE_PRECISION (1e6). Pure counters — the actual token claims
1451
+ * live in `PerpMarketAccount.protocolFeePool` / `pnlPool` / `AMM.feePool`.
1452
+ */
1013
1453
  export type FeeLedger = {
1454
+ /** lifetime gross taker fees collected (analytics only, post referee-discount, pre carve-outs) */
1014
1455
  totalExchangeFee: BN;
1456
+ /** lifetime liquidation fees charged to liquidatees (IF + protocol cuts; analytics only) */
1015
1457
  totalLiquidationFee: BN;
1458
+ /** protocol carveouts accrued but not yet materialized into `protocolFeePool` */
1016
1459
  pendingProtocolFee: BN;
1460
+ /** insurance-fund carveouts accrued but not yet materialized into the quote market's revenue pool; also the first bankruptcy tranche */
1017
1461
  pendingIfFee: BN;
1462
+ /** cumulative fee provision granted to the AMM as its backstop-of-last-resort tranche; drawable (and decremented) only in bankruptcy */
1018
1463
  ammProtocolFeesReceived: BN;
1464
+ /** AMM fee provision accrued at fill but not yet tokenized into `AMM.feePool` by the sweep; always `<= ammProtocolFeesReceived` */
1019
1465
  pendingAmmProvision: BN;
1020
1466
  };
1467
+ /** Decoded mirror of the on-chain constant-product `AMM` struct embedded in `PerpMarketAccount.amm`. */
1021
1468
  export type AMM = {
1469
+ /** partition of fees moved from pnl settlements; SPOT_BALANCE_PRECISION (1e9) scaled balance */
1022
1470
  feePool: PoolBalance;
1471
+ /** `x` reserve of the constant-product formula (x*y=k), AMM_RESERVE_PRECISION (1e9) */
1023
1472
  baseAssetReserve: BN;
1473
+ /** `y` reserve of the constant-product formula (x*y=k), AMM_RESERVE_PRECISION (1e9) */
1024
1474
  quoteAssetReserve: BN;
1475
+ /** PERCENTAGE_PRECISION (1e6); how tightly the min/max reserves bracket the current reserves (lowers slippage without adding liquidity) */
1025
1476
  concentrationCoef: BN;
1477
+ /** AMM_RESERVE_PRECISION (1e9); reserve floor below which the AMM is unavailable */
1026
1478
  minBaseAssetReserve: BN;
1479
+ /** AMM_RESERVE_PRECISION (1e9); reserve ceiling above which the AMM is unavailable */
1027
1480
  maxBaseAssetReserve: BN;
1481
+ /** `sqrt(k)`, AMM_RESERVE_PRECISION (1e9); cached to avoid precision loss recomputing it */
1028
1482
  sqrtK: BN;
1483
+ /** normalizes quote reserves for lowest slippage when the market is balanced; PEG_PRECISION (1e6) */
1029
1484
  pegMultiplier: BN;
1485
+ /** `y` reserve when the market is balanced, AMM_RESERVE_PRECISION (1e9) */
1030
1486
  terminalQuoteAssetReserve: BN;
1487
+ /** net position (longs − shorts) with the AMM as counterparty, BASE_PRECISION (1e9) */
1031
1488
  baseAssetAmountWithAmm: BN;
1489
+ /** the AMM's own fee-derived income (provision + spread surplus), QUOTE_PRECISION (1e6) — the market's gross fees are `feeLedger.totalExchangeFee` */
1032
1490
  totalFee: BN;
1491
+ /** spread-capture component of `totalFee` (trading profit, not a paid fee), QUOTE_PRECISION (1e6) */
1033
1492
  totalMmFee: BN;
1493
+ /** the AMM's equity ledger (retained earnings): fee income + funding/PnL + credits − curve costs − bankruptcy clawbacks; AMM money only, QUOTE_PRECISION (1e6) */
1034
1494
  totalFeeMinusDistributions: BN;
1495
+ /** @deprecated frozen pre-isolation analytics counter; nothing writes this anymore. QUOTE_PRECISION (1e6) */
1035
1496
  totalFeeWithdrawn: BN;
1497
+ /** cached spread-adjusted ask (long-take) reserve, AMM_RESERVE_PRECISION (1e9) */
1036
1498
  askBaseAssetReserve: BN;
1499
+ /** AMM_RESERVE_PRECISION (1e9) */
1037
1500
  askQuoteAssetReserve: BN;
1501
+ /** cached spread-adjusted bid (short-take) reserve, AMM_RESERVE_PRECISION (1e9) */
1038
1502
  bidBaseAssetReserve: BN;
1503
+ /** AMM_RESERVE_PRECISION (1e9) */
1039
1504
  bidQuoteAssetReserve: BN;
1040
1505
  lastUpdateSlot: BN;
1506
+ /** change in `totalFeeMinusDistributions` since the last funding update, QUOTE_PRECISION (1e6) */
1041
1507
  netRevenueSinceLastFunding: BN;
1508
+ /** the AMM's last-seen cumulative long funding rate (mirrors `PerpPosition.lastCumulativeFundingRate`), FUNDING_RATE_PRECISION (1e9) */
1042
1509
  lastCumulativeFundingRateLong: BN;
1510
+ /** FUNDING_RATE_PRECISION (1e9) */
1043
1511
  lastCumulativeFundingRateShort: BN;
1512
+ /** signed, BID_ASK_SPREAD_PRECISION (1e6); cached oracle-vs-reserve price spread feeding `calculate_spread` */
1044
1513
  lastOracleReservePriceSpreadPct: BN;
1045
1514
  lastSpreadUpdateSlot: BN;
1515
+ /** BID_ASK_SPREAD_PRECISION (1e6); minimum spread the AMM can quote */
1046
1516
  baseSpread: number;
1517
+ /** BID_ASK_SPREAD_PRECISION (1e6); maximum spread the AMM can quote */
1047
1518
  maxSpread: number;
1519
+ /** BID_ASK_SPREAD_PRECISION (1e6); cached spread applied to the ask (long-take) side */
1048
1520
  longSpread: number;
1521
+ /** BID_ASK_SPREAD_PRECISION (1e6); cached spread applied to the bid (short-take) side */
1049
1522
  shortSpread: number;
1523
+ /** signed, PRICE_PRECISION (1e6); cached reference-price offset applied to both sides' quotes */
1050
1524
  referencePriceOffset: number;
1525
+ /** fraction of total available liquidity a single AMM fill may consume */
1051
1526
  maxFillReserveFraction: number;
1527
+ /** maximum slippage ratio a single AMM fill may push */
1052
1528
  maxSlippageRatio: number;
1529
+ /** 0-100; intensity of the AMM's formulaic `k` updates */
1053
1530
  curveUpdateIntensity: number;
1531
+ /** 0 = no AMM JIT participation, (0,100] = intensity of protocol-owned-AMM JIT participation */
1054
1532
  ammJitIntensity: number;
1533
+ /** signed, -100 = 0x scale, 100 = 2x scale, applied to the computed spread */
1055
1534
  ammSpreadAdjustment: number;
1535
+ /** signed, -100 = 0x scale, 100 = 2x scale, applied to the inventory-skew component of the spread */
1056
1536
  ammInventorySpreadAdjustment: number;
1057
1537
  referencePriceOffsetDeadbandPct: number;
1538
+ /** stored in hundredths (value/100); how much the paying side's spread widens while the AMM pays funding on its inventory — 50 => 1.5x, 100 => 2x, 0 disables the bias */
1058
1539
  fundingBiasSensitivity: number;
1059
1540
  };
1541
+ /** Market-wide stats shared across all makers (vAMM, DLOB resting orders, JIT participants), updated on every fill regardless of which maker filled. */
1060
1542
  export type MarketStats = {
1543
+ /** average (bid+ask)/2 price over `fundingPeriod`, PRICE_PRECISION (1e6) */
1061
1544
  lastMarkPriceTwap: BN;
1545
+ /** average (bid+ask)/2 price over 5 minutes, PRICE_PRECISION (1e6) */
1062
1546
  lastMarkPriceTwap5Min: BN;
1063
1547
  lastMarkPriceTwapTs: BN;
1548
+ /** PRICE_PRECISION (1e6) */
1064
1549
  lastBidPriceTwap: BN;
1550
+ /** PRICE_PRECISION (1e6) */
1065
1551
  lastAskPriceTwap: BN;
1552
+ /** standard deviation of fill (mark) prices, PRICE_PRECISION (1e6) */
1066
1553
  markStd: BN;
1554
+ /** standard deviation of the oracle price at each update, PRICE_PRECISION (1e6) */
1067
1555
  oracleStd: BN;
1556
+ /** PERCENTAGE_PRECISION (1e6); size of the oracle confidence interval as a fraction of price */
1068
1557
  lastOracleConfPct: BN;
1558
+ /** QUOTE_PRECISION (1e6); estimated total volume traded in the market */
1069
1559
  volume24H: BN;
1070
1560
  longIntensityVolume: BN;
1071
1561
  shortIntensityVolume: BN;
1072
1562
  lastTradeTs: BN;
1563
+ /** unit is quote per base, QUOTE_PRECISION (1e6); estimate of the last 24h average funding rate */
1073
1564
  last24HAvgFundingRate: BN;
1565
+ /** seconds; periodicity of funding rate updates */
1074
1566
  fundingPeriod: BN;
1567
+ /** BASE_PRECISION (1e9); minimum order size, mirrored here from `PerpMarketAccount` config so the AMM can read it without touching the market's other fields */
1075
1568
  minOrderSize: BN;
1569
+ /** market-maker oracle price snapshot set by the native `updateMmOracle` handler */
1076
1570
  mmOraclePrice: BN;
1077
1571
  mmOracleSlot: BN;
1572
+ /** monotonically increasing; guards against out-of-order mm-oracle updates */
1078
1573
  mmOracleSequenceId: BN;
1574
+ /** canonical sanitised/clamped oracle price after normalisation */
1079
1575
  lastOracleNormalisedPrice: BN;
1576
+ /** PRICE_PRECISION (1e6); reference-price offset from the previous `_update_amm` call, used to smooth the sign-flip transition when the freshly computed offset changes direction */
1080
1577
  lastReferencePriceOffset: number;
1081
1578
  lastOracleValid: boolean;
1579
+ /** unit is quote per base, QUOTE_PRECISION (1e6); oracle TWAP snapshot used by the funding-rate computation */
1082
1580
  lastFundingOracleTwap: BN;
1083
1581
  historicalOracleData: HistoricalOracleData;
1084
1582
  };
1583
+ /** A user's position in one perp market. Decoded mirror of the on-chain `PerpPosition`. */
1085
1584
  export type PerpPosition = {
1585
+ /** signed size of the position, BASE_PRECISION (1e9) */
1086
1586
  baseAssetAmount: BN;
1587
+ /** the market's last cumulative funding rate this position has settled against, FUNDING_RATE_PRECISION (1e9) */
1087
1588
  lastCumulativeFundingRate: BN;
1088
1589
  marketIndex: number;
1590
+ /** used to calculate pnl; updated on open/close/settle, includes fees/funding, QUOTE_PRECISION (1e6) */
1089
1591
  quoteAssetAmount: BN;
1592
+ /** quote the position was entered with (base * avg entry price), excludes fees/funding, QUOTE_PRECISION (1e6) */
1090
1593
  quoteEntryAmount: BN;
1594
+ /** quote needed to exit at breakeven, includes fees/funding, QUOTE_PRECISION (1e6) */
1091
1595
  quoteBreakEvenAmount: BN;
1092
1596
  openOrders: number;
1597
+ /** size of non-reduce-only bids resting/triggering against this position, BASE_PRECISION (1e9) */
1093
1598
  openBids: BN;
1599
+ /** size of non-reduce-only asks resting/triggering against this position, BASE_PRECISION (1e9) */
1094
1600
  openAsks: BN;
1601
+ /** cumulative pnl settled in this market since the position was opened, QUOTE_PRECISION (1e6) */
1095
1602
  settledPnl: BN;
1096
1603
  /** TODO: remove this field - it doesn't exist on chain */
1097
1604
  remainderBaseAssetAmount: number;
1605
+ /** MARGIN_PRECISION (1e4); custom max margin ratio for this position, 0 = use the market default */
1098
1606
  maxMarginRatio: number;
1607
+ /** bitmask, see `PositionFlag` */
1099
1608
  positionFlag: number;
1609
+ /** SPOT_BALANCE_PRECISION (1e9) scaled balance backing this position when it is isolated-margin (`PositionFlag.IsolatedPosition` set) */
1100
1610
  isolatedPositionScaledBalance: BN;
1101
1611
  };
1612
+ /** Decoded mirror of the on-chain `UserStats` account: authority-level (cross-sub-account) rolling volume, fee, and referral stats. */
1102
1613
  export type UserStatsAccount = {
1103
1614
  numberOfSubAccounts: number;
1615
+ /** can exceed `numberOfSubAccounts` if sub-accounts were deleted */
1104
1616
  numberOfSubAccountsCreated: number;
1617
+ /** rolling 30-day maker volume, QUOTE_PRECISION (1e6) */
1105
1618
  makerVolume30D: BN;
1619
+ /** rolling 30-day taker volume, QUOTE_PRECISION (1e6) */
1106
1620
  takerVolume30D: BN;
1621
+ /** rolling 30-day filler (keeper) volume, QUOTE_PRECISION (1e6) */
1107
1622
  fillerVolume30D: BN;
1108
1623
  lastMakerVolume30DTs: BN;
1109
1624
  lastTakerVolume30DTs: BN;
1110
1625
  lastFillerVolume30DTs: BN;
1111
1626
  fees: {
1627
+ /** total taker fees paid, QUOTE_PRECISION (1e6) */
1112
1628
  totalFeePaid: BN;
1629
+ /** total maker rebate received, QUOTE_PRECISION (1e6) */
1113
1630
  totalFeeRebate: BN;
1631
+ /** total discount from holding the discount token, QUOTE_PRECISION (1e6) */
1114
1632
  totalTokenDiscount: BN;
1633
+ /** total discount from being a referred user, QUOTE_PRECISION (1e6) */
1115
1634
  totalRefereeDiscount: BN;
1116
1635
  };
1117
1636
  referrer: PublicKey;
1637
+ /** bitmask, see `ReferrerStatus` */
1118
1638
  referrerStatus: number;
1119
1639
  disableUpdatePerpBidAskTwap: number;
1640
+ /** bitmask, see `UserStatsPausedOperation` */
1120
1641
  pausedOperations: number;
1121
1642
  authority: PublicKey;
1122
1643
  ifStakedQuoteAssetAmount: BN;
1123
1644
  delegatePermissions: number;
1124
1645
  };
1646
+ /** Decoded mirror of the on-chain `User` (sub-account) zero-copy account. */
1125
1647
  export type UserAccount = {
1126
1648
  authority: PublicKey;
1649
+ /** address that can control the account on the authority's behalf; limited power, cannot withdraw */
1127
1650
  delegate: PublicKey;
1128
1651
  name: number[];
1129
1652
  subAccountId: number;
1130
1653
  spotPositions: SpotPosition[];
1131
1654
  perpPositions: PerpPosition[];
1132
1655
  orders: Order[];
1656
+ /** bitmask, see `UserStatus` */
1133
1657
  status: number;
1134
1658
  nextLiquidationId: number;
1135
1659
  nextOrderId: number;
1660
+ /** MARGIN_PRECISION (1e4); custom max initial margin ratio for the whole account, 0 = use market defaults */
1136
1661
  maxMarginRatio: number;
1662
+ /** fees (taker fee, maker rebate, referrer reward, filler reward) and pnl for perps, QUOTE_PRECISION (1e6) */
1137
1663
  settledPerpPnl: BN;
1664
+ /** QUOTE_PRECISION (1e6) */
1138
1665
  totalDeposits: BN;
1666
+ /** QUOTE_PRECISION (1e6) */
1139
1667
  totalWithdraws: BN;
1668
+ /** QUOTE_PRECISION (1e6) */
1140
1669
  totalSocialLoss: BN;
1670
+ /** cumulative funding paid/received across perps, QUOTE_PRECISION (1e6) */
1141
1671
  cumulativePerpFunding: BN;
1672
+ /** fees (taker fee, maker rebate, filler reward) for spot, QUOTE_PRECISION (1e6) */
1142
1673
  cumulativeSpotFees: BN;
1674
+ /** QUOTE_PRECISION (1e6); margin freed so far during an in-progress liquidation (spreads the liquidation over time); 0 when not being liquidated */
1143
1675
  liquidationMarginFreed: BN;
1144
1676
  lastActiveSlot: BN;
1145
1677
  isMarginTradingEnabled: boolean;
1678
+ /** true if the account hasn't interacted with the protocol in ~1 week and has no orders/positions/borrows; off-chain keepers may ignore idle accounts */
1146
1679
  idle: boolean;
1147
1680
  openOrders: number;
1148
1681
  hasOpenOrder: boolean;
1149
1682
  openAuctions: number;
1150
1683
  hasOpenAuction: boolean;
1151
1684
  poolId: number;
1685
+ /** bitmask, see `SpecialUserStatus` */
1152
1686
  specialUserStatus: number;
1153
1687
  };
1688
+ /** A user's balance in one spot market. Decoded mirror of the on-chain `SpotPosition`. */
1154
1689
  export type SpotPosition = {
1155
1690
  marketIndex: number;
1156
1691
  balanceType: SpotBalanceType;
1692
+ /** SPOT_BALANCE_PRECISION (1e9) scaled balance; multiply by the spot market's cumulative deposit/borrow interest for the token amount */
1157
1693
  scaledBalance: BN;
1158
1694
  openOrders: number;
1695
+ /** size of non-reduce-only bids resting/triggering, token mint precision */
1159
1696
  openBids: BN;
1697
+ /** size of non-reduce-only asks resting/triggering, token mint precision */
1160
1698
  openAsks: BN;
1699
+ /** cumulative deposits/borrows into this market, token mint precision */
1161
1700
  cumulativeDeposits: BN;
1162
1701
  };
1702
+ /** Decoded mirror of an on-chain `Order` slot inside `UserAccount.orders`. */
1163
1703
  export type Order = {
1164
1704
  status: OrderStatus;
1165
1705
  orderType: OrderType;
@@ -1168,48 +1708,73 @@ export type Order = {
1168
1708
  orderId: number;
1169
1709
  userOrderId: number;
1170
1710
  marketIndex: number;
1711
+ /** the limit price; can be 0 for market orders. For orders with an auction, unused until the auction completes. PRICE_PRECISION (1e6) */
1171
1712
  price: BN;
1713
+ /** perp: BASE_PRECISION (1e9); spot: token mint precision */
1172
1714
  baseAssetAmount: BN;
1715
+ /** perp: BASE_PRECISION (1e9); spot: token mint precision */
1173
1716
  baseAssetAmountFilled: BN;
1717
+ /** QUOTE_PRECISION (1e6) */
1174
1718
  quoteAssetAmountFilled: BN;
1175
1719
  direction: PositionDirection;
1176
1720
  reduceOnly: boolean;
1721
+ /** price at which the order becomes active; only relevant for trigger orders, PRICE_PRECISION (1e6) */
1177
1722
  triggerPrice: BN;
1178
1723
  triggerCondition: OrderTriggerCondition;
1724
+ /** the user's position direction when this order was placed */
1179
1725
  existingPositionDirection: PositionDirection;
1180
1726
  postOnly: boolean;
1727
+ /** must be canceled the same slot it's placed if not fully filled */
1181
1728
  immediateOrCancel: boolean;
1729
+ /** if set, the limit price is `oraclePrice + oraclePriceOffset`; PRICE_PRECISION (1e6), signed */
1182
1730
  oraclePriceOffset: BN;
1731
+ /** slots the auction lasts; only relevant for market/oracle orders */
1183
1732
  auctionDuration: number;
1733
+ /** PRICE_PRECISION (1e6), signed; only relevant for market/oracle orders */
1184
1734
  auctionStartPrice: BN;
1735
+ /** PRICE_PRECISION (1e6), signed; only relevant for market/oracle orders */
1185
1736
  auctionEndPrice: BN;
1737
+ /** unix timestamp after which the order expires */
1186
1738
  maxTs: BN;
1739
+ /** bitmask, see `OrderBitFlag` */
1187
1740
  bitFlags: number;
1741
+ /** low 8 bits of the slot the order was posted on-chain (not the order's `slot` field for signed-msg orders) */
1188
1742
  postedSlotTail: number;
1189
1743
  };
1744
+ /** Instruction-parameter shape for placing an order (perp or spot). Optional fields default to `null`/unset on-chain unless noted. */
1190
1745
  export type OrderParams = {
1191
1746
  orderType: OrderType;
1192
1747
  marketType: MarketType;
1193
1748
  userOrderId: number;
1194
1749
  direction: PositionDirection;
1750
+ /** perp: BASE_PRECISION (1e9); spot: token mint precision */
1195
1751
  baseAssetAmount: BN;
1752
+ /** limit price, PRICE_PRECISION (1e6); 0 for market orders */
1196
1753
  price: BN;
1197
1754
  marketIndex: number;
1198
1755
  reduceOnly: boolean;
1199
1756
  postOnly: PostOnlyParams;
1757
+ /** bitmask, see `OrderParamsBitFlag` (distinct from the on-chain `Order.bitFlags` set of flags) */
1200
1758
  bitFlags: number;
1759
+ /** PRICE_PRECISION (1e6); only used for trigger orders */
1201
1760
  triggerPrice: BN | null;
1202
1761
  triggerCondition: OrderTriggerCondition;
1762
+ /** signed offset from the oracle price, PRICE_PRECISION (1e6); when set, the order's effective limit price tracks the oracle */
1203
1763
  oraclePriceOffset: BN | null;
1764
+ /** slots; only used for market/oracle orders */
1204
1765
  auctionDuration: number | null;
1766
+ /** unix timestamp after which the order expires */
1205
1767
  maxTs: BN | null;
1768
+ /** PRICE_PRECISION (1e6) or oracle-offset units depending on the order, signed; only used for market/oracle orders */
1206
1769
  auctionStartPrice: BN | null;
1770
+ /** PRICE_PRECISION (1e6) or oracle-offset units depending on the order, signed; only used for market/oracle orders */
1207
1771
  auctionEndPrice: BN | null;
1208
1772
  /** index into the placing user's RevenueShareEscrow.approved_builders list (non-swift builder codes) */
1209
1773
  builderIdx?: number | null;
1210
1774
  /** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
1211
1775
  builderFeeTenthBps?: number | null;
1212
1776
  };
1777
+ /** Whether/how an order must avoid taking liquidity. `MUST_POST_ONLY` reverts the transaction if the order would cross; `TRY_POST_ONLY` silently drops the order instead of reverting; `SLIDE` adjusts the price to make it post-only. */
1213
1778
  export declare class PostOnlyParams {
1214
1779
  static readonly NONE: {
1215
1780
  none: {};
@@ -1264,45 +1829,58 @@ export type ScaleOrderParams = {
1264
1829
  /** Maximum timestamp for orders to be valid */
1265
1830
  maxTs: BN | null;
1266
1831
  };
1832
+ /** Bitmask mirror of `OrderParams.bitFlags` (the instruction-parameter flag set; distinct from the on-chain `Order.bitFlags` set of `OrderBitFlag`). */
1267
1833
  export declare class OrderParamsBitFlag {
1268
1834
  static readonly ImmediateOrCancel = 1;
1269
1835
  }
1836
+ /** Bitmask mirror of `PerpPosition.positionFlag`. Multiple bits can be set (e.g. an isolated position mid-liquidation has both `IsolatedPosition` and `BeingLiquidated`). */
1270
1837
  export declare class PositionFlag {
1271
1838
  static readonly IsolatedPosition = 1;
1272
1839
  static readonly BeingLiquidated = 2;
1273
1840
  static readonly Bankruptcy = 4;
1274
1841
  }
1842
+ /** The subset of `OrderParams` an SDK caller must always supply; everything else can be defaulted. */
1275
1843
  export type NecessaryOrderParams = {
1276
1844
  orderType: OrderType;
1277
1845
  marketIndex: number;
1278
1846
  baseAssetAmount: BN;
1279
1847
  direction: PositionDirection;
1280
1848
  };
1849
+ /** `OrderParams` with every field optional except `NecessaryOrderParams`; SDK order-placement helpers fill in the rest from `DefaultOrderParams`. */
1281
1850
  export type OptionalOrderParams = {
1282
1851
  [Property in keyof OrderParams]?: OrderParams[Property];
1283
1852
  } & NecessaryOrderParams;
1853
+ /** Fields to change on an existing order via `modifyOrder`. Only the fields present (non-`undefined`) are changed on-chain; the rest of the order is left as-is. `null` explicitly clears an optional on-chain field (e.g. `triggerPrice: null` removes the trigger). */
1284
1854
  export type ModifyOrderParams = {
1285
1855
  [Property in keyof OrderParams]?: OrderParams[Property] | null;
1286
1856
  } & {
1287
1857
  policy?: ModifyOrderPolicy | null;
1288
1858
  };
1859
+ /** Bitmask passed as `ModifyOrderParams.policy` (combine with `|`). `MustModify`: fail the instruction instead of silently no-op'ing if the target order id can't be found. `ExcludePreviousFill`: when a new `baseAssetAmount` is given, treat it as the new *remaining* size — the already-filled amount is subtracted off it (rather than replacing the order's total size outright). */
1289
1860
  export declare enum ModifyOrderPolicy {
1290
1861
  MustModify = 1,
1291
1862
  ExcludePreviousFill = 2
1292
1863
  }
1864
+ /** Base `OrderParams` (a market perp long of size 0) that SDK order-building helpers spread their caller-supplied `OptionalOrderParams` over. */
1293
1865
  export declare const DefaultOrderParams: OrderParams;
1866
+ /** The payload signed off-chain by a user (non-delegated) for a swift/signed-msg order, optionally bundling bracket TP/SL orders and an isolated-margin deposit. */
1294
1867
  export type SignedMsgOrderParamsMessage = {
1295
1868
  signedMsgOrderParams: OrderParams;
1296
1869
  subAccountId: number;
1870
+ /** slot the message was signed at; combined with `signedMsgOrderMaxSlot`-style checks to bound message validity */
1297
1871
  slot: BN;
1298
1872
  uuid: Uint8Array;
1299
1873
  takeProfitOrderParams: SignedMsgTriggerOrderParams | null;
1300
1874
  stopLossOrderParams: SignedMsgTriggerOrderParams | null;
1875
+ /** MARGIN_PRECISION (1e4); custom max margin ratio applied to the resulting position, if any */
1301
1876
  maxMarginRatio?: number | null;
1302
1877
  builderIdx?: number | null;
1878
+ /** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
1303
1879
  builderFeeTenthBps?: number | null;
1880
+ /** if set, deposits this amount (spot market token-mint precision) into a new isolated-margin position when placing the order */
1304
1881
  isolatedPositionDeposit?: BN | null;
1305
1882
  };
1883
+ /** Same as `SignedMsgOrderParamsMessage`, but signed by a delegate on the taker's behalf; carries `takerPubkey` explicitly since the signer isn't the taker's own authority. */
1306
1884
  export type SignedMsgOrderParamsDelegateMessage = {
1307
1885
  signedMsgOrderParams: OrderParams;
1308
1886
  slot: BN;
@@ -1315,49 +1893,68 @@ export type SignedMsgOrderParamsDelegateMessage = {
1315
1893
  builderFeeTenthBps?: number | null;
1316
1894
  isolatedPositionDeposit?: BN | null;
1317
1895
  };
1896
+ /** A bracket take-profit/stop-loss order attached to a signed-msg order message. */
1318
1897
  export type SignedMsgTriggerOrderParams = {
1898
+ /** PRICE_PRECISION (1e6) */
1319
1899
  triggerPrice: BN;
1900
+ /** perp: BASE_PRECISION (1e9); spot: token mint precision */
1320
1901
  baseAssetAmount: BN;
1321
1902
  };
1903
+ /** Identifies a resting maker order/account to pass into a fill instruction's remaining accounts. `order` may be omitted when the whole account (not one specific order) is being matched against, e.g. AMM-JIT. */
1322
1904
  export type MakerInfo = {
1323
1905
  maker: PublicKey;
1324
1906
  makerStats: PublicKey;
1325
1907
  makerUserAccount: UserAccount;
1326
1908
  order?: Order;
1327
1909
  };
1910
+ /** Identifies the taker order/account being filled, for fill instructions. */
1328
1911
  export type TakerInfo = {
1329
1912
  taker: PublicKey;
1330
1913
  takerStats: PublicKey;
1331
1914
  takerUserAccount: UserAccount;
1332
1915
  order: Order;
1333
1916
  };
1917
+ /** Referrer accounts to pass into an instruction so the referrer's reward can be credited. */
1334
1918
  export type ReferrerInfo = {
1335
1919
  referrer: PublicKey;
1336
1920
  referrerStats: PublicKey;
1337
1921
  };
1922
+ /** Bitmask mirror of `UserStatsAccount.referrerStatus`. */
1338
1923
  export declare enum ReferrerStatus {
1339
1924
  IsReferrer = 1,
1340
1925
  IsReferred = 2,
1341
1926
  /** set when the user's RevenueShareEscrow was initialized with a referrer */
1342
1927
  BuilderReferral = 4
1343
1928
  }
1929
+ /** Which fill outcome counts as "success" for a `placeAndTake*` instruction's on-chain success check. */
1344
1930
  export declare enum PlaceAndTakeOrderSuccessCondition {
1345
1931
  PartialFill = 1,
1346
1932
  FullFill = 2
1347
1933
  }
1348
1934
  type ExactType<T> = Pick<T, keyof T>;
1935
+ /** Compute-budget overrides accepted by SDK transaction-building helpers. Omit either field to let the SDK compute/skip it. */
1349
1936
  export type BaseTxParams = ExactType<{
1937
+ /** explicit compute-unit limit to request; if omitted, may be derived via simulation (see `ProcessingTxParams`) */
1350
1938
  computeUnits?: number;
1939
+ /** micro-lamports per compute unit for the priority fee */
1351
1940
  computeUnitsPrice?: number;
1352
1941
  }>;
1942
+ /** Controls how the SDK derives compute-unit limit/price when not explicitly given in `BaseTxParams`. */
1353
1943
  export type ProcessingTxParams = {
1944
+ /** simulate the transaction to determine the compute-unit limit instead of using a static estimate */
1354
1945
  useSimulatedComputeUnits?: boolean;
1946
+ /** multiplier applied to the simulated/estimated compute-unit count to leave headroom, e.g. 1.2 = +20% */
1355
1947
  computeUnitsBufferMultiplier?: number;
1948
+ /** also use the simulated compute-unit count (rather than the static estimate) as the basis for `getCUPriceFromComputeUnits` */
1356
1949
  useSimulatedComputeUnitsForCUPriceCalculation?: boolean;
1950
+ /** custom function mapping a compute-unit count to a compute-unit price (micro-lamports); overrides `computeUnitsPrice` */
1357
1951
  getCUPriceFromComputeUnits?: (computeUnits: number) => number;
1952
+ /** floor applied to the computed/simulated compute-unit count before requesting a limit */
1358
1953
  lowerBoundCu?: number;
1359
1954
  };
1955
+ /** Combined compute-budget + compute-unit-derivation options accepted by SDK transaction-building helpers. */
1360
1956
  export type TxParams = BaseTxParams & ProcessingTxParams;
1957
+ /** For `beginSwap`/`endSwap`, whether the reduce-only constraint applies to the `In` (source) or `Out` (destination) side of the swap. */
1361
1958
  export declare class SwapReduceOnly {
1362
1959
  static readonly In: {
1363
1960
  in: {};
@@ -1366,6 +1963,7 @@ export declare class SwapReduceOnly {
1366
1963
  out: {};
1367
1964
  };
1368
1965
  }
1966
+ /** Minimal wallet adapter the SDK requires for legacy (non-versioned) transaction signing. */
1369
1967
  export interface IWallet {
1370
1968
  signTransaction(tx: Transaction): Promise<Transaction>;
1371
1969
  signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
@@ -1373,49 +1971,72 @@ export interface IWallet {
1373
1971
  payer?: Keypair;
1374
1972
  supportedTransactionVersions?: ReadonlySet<TransactionVersion> | null | undefined;
1375
1973
  }
1974
+ /** Wallet adapter capable of signing versioned transactions (v0 message format). */
1376
1975
  export interface IVersionedWallet {
1377
1976
  signVersionedTransaction(tx: VersionedTransaction): Promise<VersionedTransaction>;
1378
1977
  signAllVersionedTransactions(txs: VersionedTransaction[]): Promise<VersionedTransaction[]>;
1379
1978
  publicKey: PublicKey;
1380
1979
  payer?: Keypair;
1381
1980
  }
1981
+ /** `IWallet` extended with arbitrary-message signing (used for signed-msg/swift order flows). */
1382
1982
  export interface IWalletV2 extends IWallet {
1383
1983
  signMessage(message: Uint8Array): Promise<Uint8Array>;
1384
1984
  }
1985
+ /** The fee schedule applied to fills in a market category (perp or spot); decoded from `StateAccount.perpFeeStructure`/`spotFeeStructure`. */
1385
1986
  export type FeeStructure = {
1987
+ /** volume-based fee tiers, evaluated by the taker's 30-day volume; tier 0 is the base/default tier */
1386
1988
  feeTiers: FeeTier[];
1387
1989
  fillerRewardStructure: OrderFillerRewardStructure;
1990
+ /** flat portion of the filler (keeper) reward, QUOTE_PRECISION (1e6) */
1388
1991
  flatFillerFee: BN;
1992
+ /** FEE_PERCENTAGE_DENOMINATOR (100)-denominated share of the trade-fee remainder provisioned to the AMM as its backstop-of-last-resort tranche; `ammFeeNumerator + ifFeeNumerator` must be <= 100, the protocol keeps the residual */
1389
1993
  ammFeeNumerator: number;
1994
+ /** FEE_PERCENTAGE_DENOMINATOR (100)-denominated share of the trade-fee remainder routed to the insurance fund */
1390
1995
  ifFeeNumerator: number;
1391
1996
  };
1997
+ /** One volume tier of a `FeeStructure`. All `*Numerator`/`*Denominator` pairs form a fraction (e.g. `feeNumerator / feeDenominator`). */
1392
1998
  export type FeeTier = {
1999
+ /** taker fee rate */
1393
2000
  feeNumerator: number;
1394
2001
  feeDenominator: number;
2002
+ /** rebate paid to the resting maker */
1395
2003
  makerRebateNumerator: number;
1396
2004
  makerRebateDenominator: number;
2005
+ /** share of the taker fee credited to the taker's referrer */
1397
2006
  referrerRewardNumerator: number;
1398
2007
  referrerRewardDenominator: number;
2008
+ /** discount applied to the taker's own fee when they were referred */
1399
2009
  refereeFeeNumerator: number;
1400
2010
  refereeFeeDenominator: number;
1401
2011
  };
2012
+ /** The reward paid to the keeper (filler) that submits a fill transaction. */
1402
2013
  export type OrderFillerRewardStructure = {
2014
+ /** share of the fill's fee/size paid as a variable reward */
1403
2015
  rewardNumerator: number;
1404
2016
  rewardDenominator: number;
2017
+ /** QUOTE_PRECISION (1e6); floor below which the time-based reward component doesn't apply */
1405
2018
  timeBasedRewardLowerBound: BN;
1406
2019
  };
2020
+ /** Protocol-wide oracle safety thresholds (`StateAccount.oracleGuardRails`), gating how far an oracle price may diverge from mark and how stale/uncertain it may be before it's rejected for a given action. */
1407
2021
  export type OracleGuardRails = {
1408
2022
  priceDivergence: {
2023
+ /** PERCENTAGE_PRECISION (1e6); max allowed |mark − oracle| / oracle before divergence checks reject the price */
1409
2024
  markOraclePercentDivergence: BN;
2025
+ /** PERCENTAGE_PRECISION (1e6); max allowed divergence between the oracle's live price and its 5-minute TWAP */
1410
2026
  oracleTwap5MinPercentDivergence: BN;
1411
2027
  };
1412
2028
  validity: {
2029
+ /** slots; oracle updates older than this are stale for AMM-facing actions */
1413
2030
  slotsBeforeStaleForAmm: BN;
2031
+ /** slots; oracle updates older than this are stale for margin/liquidation actions */
1414
2032
  slotsBeforeStaleForMargin: BN;
2033
+ /** PERCENTAGE_PRECISION (1e6)-scaled fraction of price; oracle confidence intervals wider than this are rejected */
1415
2034
  confidenceIntervalMaxSize: BN;
2035
+ /** oracle price moves within one update exceeding this multiple of the recent range are rejected as "too volatile" */
1416
2036
  tooVolatileRatio: BN;
1417
2037
  };
1418
2038
  };
2039
+ /** Result of the oracle validity check (`is_oracle_valid_for_action` and friends). Only `Valid` (7) permits using the price; every other variant identifies the specific failure so callers can gate accordingly (stale-for-margin still permits AMM-only actions, etc.). */
1419
2040
  export declare enum OracleValidity {
1420
2041
  NonPositive = 0,
1421
2042
  TooVolatile = 1,
@@ -1426,19 +2047,27 @@ export declare enum OracleValidity {
1426
2047
  isStaleForAmmImmediate = 6,
1427
2048
  Valid = 7
1428
2049
  }
2050
+ /** Decoded mirror of a `PrelaunchOracle` account — an admin-fed synthetic price feed used before a market has a real external oracle (`OracleSource.Prelaunch`). */
1429
2051
  export type PrelaunchOracle = {
2052
+ /** PRICE_PRECISION (1e6) */
1430
2053
  price: BN;
2054
+ /** PRICE_PRECISION (1e6); ceiling the admin-set price is clamped to */
1431
2055
  maxPrice: BN;
2056
+ /** PRICE_PRECISION (1e6) */
1432
2057
  confidence: BN;
1433
2058
  ammLastUpdateSlot: BN;
1434
2059
  lastUpdateSlot: BN;
1435
2060
  perpMarketIndex: number;
1436
2061
  };
2062
+ /** Admin instruction params for updating a `PrelaunchOracle`; `null` fields leave the current on-chain value unchanged. */
1437
2063
  export type PrelaunchOracleParams = {
1438
2064
  perpMarketIndex: number;
2065
+ /** PRICE_PRECISION (1e6) */
1439
2066
  price: BN | null;
2067
+ /** PRICE_PRECISION (1e6) */
1440
2068
  maxPrice: BN | null;
1441
2069
  };
2070
+ /** Decoded mirror of a Pyth Lazer oracle account. `price`/`conf` are in the feed's native `exponent` (a power-of-ten scale factor, typically negative), not a fixed SDK precision — divide by `10^-exponent` to get the human-readable price. */
1442
2071
  export type PythLazerOracle = {
1443
2072
  price: BN;
1444
2073
  publishTime: BN;
@@ -1446,28 +2075,43 @@ export type PythLazerOracle = {
1446
2075
  exponent: number;
1447
2076
  conf: BN;
1448
2077
  };
2078
+ /** Admin instruction params for correcting a perp market's cached AMM summary stats; `null` fields leave the current on-chain value unchanged. */
1449
2079
  export type UpdatePerpMarketSummaryStatsParams = {
2080
+ /** QUOTE_PRECISION (1e6) */
1450
2081
  netUnsettledFundingPnl: BN | null;
1451
2082
  updateAmmSummaryStats: boolean | null;
1452
2083
  };
1453
- export type MarginCategory = 'Initial' | 'Maintenance';
2084
+ /**
2085
+ * Which margin requirement a calculation is being performed for, mirroring the program's
2086
+ * `MarginRequirementType`: `'Initial'` (opening/maintaining leverage headroom), `'Maintenance'`
2087
+ * (liquidation), or `'Fill'` (fill-time check — weights/ratios are the integer-averaged midpoint
2088
+ * of initial and maintenance).
2089
+ */
2090
+ export type MarginCategory = 'Initial' | 'Maintenance' | 'Fill';
2091
+ /** Decoded mirror of the on-chain `InsuranceFundStake` account: one user's stake in one spot market's insurance fund. */
1454
2092
  export type InsuranceFundStake = {
2093
+ /** signed, spot market token-mint precision; tracks the staker's cost basis for pnl reporting */
1455
2094
  costBasis: BN;
1456
2095
  marketIndex: number;
1457
2096
  authority: PublicKey;
2097
+ /** the staker's share count; multiply by the IF's share price to get token value */
1458
2098
  ifShares: BN;
2099
+ /** exponent used to rebase `ifShares` in step with `InsuranceFund.sharesBase` */
1459
2100
  ifBase: BN;
1460
2101
  lastValidTs: BN;
1461
2102
  lastWithdrawRequestShares: BN;
2103
+ /** spot market token-mint precision value of `lastWithdrawRequestShares` at request time */
1462
2104
  lastWithdrawRequestValue: BN;
1463
2105
  lastWithdrawRequestTs: BN;
1464
2106
  };
2107
+ /** Decoded mirror of a `ReferrerName` account, mapping a human-readable referrer name to its user/authority. */
1465
2108
  export type ReferrerNameAccount = {
1466
2109
  name: number[];
1467
2110
  user: PublicKey;
1468
2111
  authority: PublicKey;
1469
2112
  userStats: PublicKey;
1470
2113
  };
2114
+ /** SDK-computed convenience summary of a perp market's order-size/margin/insurance limits, derived from `PerpMarketAccount` (not decoded directly from a single on-chain field). */
1471
2115
  export type PerpMarketExtendedInfo = {
1472
2116
  marketIndex: number;
1473
2117
  /**
@@ -1489,29 +2133,38 @@ export type PerpMarketExtendedInfo = {
1489
2133
  pnlPoolValue: BN;
1490
2134
  contractTier: ContractTier;
1491
2135
  };
2136
+ /** SDK-computed breakdown of a user's margin-health calculation, grouped by contribution type; each group is a list of the individual `HealthComponent`s that summed into the account's total collateral/margin requirement. */
1492
2137
  export type HealthComponents = {
1493
2138
  deposits: HealthComponent[];
1494
2139
  borrows: HealthComponent[];
1495
2140
  perpPositions: HealthComponent[];
1496
2141
  perpPnl: HealthComponent[];
1497
2142
  };
2143
+ /** One market's contribution to a `HealthComponents` group. */
1498
2144
  export type HealthComponent = {
1499
2145
  marketIndex: number;
2146
+ /** perp: signed BASE_PRECISION (1e9) position size; spot: signed token-mint-precision balance */
1500
2147
  size: BN;
2148
+ /** unweighted USD value, QUOTE_PRECISION (1e6) */
1501
2149
  value: BN;
2150
+ /** the asset/liability weight applied, SPOT_WEIGHT_PRECISION or MARGIN_PRECISION (1e4) depending on component type */
1502
2151
  weight: BN;
2152
+ /** `value` after applying `weight`, QUOTE_PRECISION (1e6); this is what's actually summed into total collateral/margin requirement */
1503
2153
  weightedValue: BN;
1504
2154
  };
2155
+ /** Event map for `VelocityClient`'s internal metrics emitter. */
1505
2156
  export interface VelocityClientMetricsEvents {
1506
2157
  txSigned: SignedTxData[];
1507
2158
  preTxSigned: void;
1508
2159
  }
2160
+ /** A transaction the SDK has signed, returned by transaction-sending helpers before/instead of submission. */
1509
2161
  export type SignedTxData = {
1510
2162
  txSig: string;
1511
2163
  signedTx: Transaction | VersionedTransaction;
1512
2164
  lastValidBlockHeight?: number;
1513
2165
  blockHash: string;
1514
2166
  };
2167
+ /** Proof of a signed-msg (swift) taker order, submitted to the program to fill it. */
1515
2168
  export interface SignedMsgOrderParams {
1516
2169
  /**
1517
2170
  * The encoded order params that were signed (borsh encoded then hexified).
@@ -1522,229 +2175,342 @@ export interface SignedMsgOrderParams {
1522
2175
  */
1523
2176
  signature: Buffer;
1524
2177
  }
2178
+ /** One slot of a `SignedMsgUserOrdersAccount`, recording a signed-msg order's validity window and dedupe key so a replayed/expired signed message can be rejected without an extra RPC round-trip. */
1525
2179
  export type SignedMsgOrderId = {
2180
+ /** slot after which this signed message is no longer eligible to be placed */
1526
2181
  maxSlot: BN;
1527
2182
  uuid: Uint8Array;
1528
2183
  orderId: number;
1529
2184
  };
2185
+ /** Per-authority account tracking recently-seen signed-msg order UUIDs, used to detect replay/duplicate submission of the same signed message. */
1530
2186
  export type SignedMsgUserOrdersAccount = {
1531
2187
  authorityPubkey: PublicKey;
1532
2188
  signedMsgOrderData: SignedMsgOrderId[];
1533
2189
  };
2190
+ /** Account listing the delegate keys authorized to submit signed-msg orders over the swift websocket on a user's behalf. */
1534
2191
  export type SignedMsgWsDelegatesAccount = {
1535
2192
  delegates: PublicKey[];
1536
2193
  };
2194
+ /** Decoded mirror of the on-chain `RevenueShare` account: one per builder/referrer, accumulating their lifetime rewards. */
1537
2195
  export type RevenueShareAccount = {
2196
+ /** the builder or referrer that owns this account */
1538
2197
  authority: PublicKey;
2198
+ /** QUOTE_PRECISION (1e6) */
1539
2199
  totalReferrerRewards: BN;
2200
+ /** QUOTE_PRECISION (1e6) */
1540
2201
  totalBuilderRewards: BN;
1541
2202
  padding: number[];
1542
2203
  };
2204
+ /** Decoded mirror of the on-chain `RevenueShareEscrow` account: one per trading user, holding their referrer link, approved builder codes, and in-flight per-order fee accruals awaiting settlement. Required in remaining accounts when filling an order with a builder code or a referred taker (see `TakerInfo`/fill-instruction docs). */
1543
2205
  export type RevenueShareEscrowAccount = {
2206
+ /** the user that owns this escrow */
1544
2207
  authority: PublicKey;
1545
2208
  referrer: PublicKey;
1546
2209
  reservedFixed: number[];
2210
+ /** ring-buffer of in-flight order fee accruals, settled into the builder's/referrer's `RevenueShareAccount` on settle-PnL */
1547
2211
  orders: RevenueShareOrder[];
2212
+ /** builders this user has approved to charge a fee, indexed by `builderIdx` on `OrderParams`/`RevenueShareOrder` */
1548
2213
  approvedBuilders: BuilderInfo[];
1549
2214
  };
2215
+ /** One in-flight order's accrued builder/referral fee inside a `RevenueShareEscrowAccount`. */
1550
2216
  export type RevenueShareOrder = {
2217
+ /** QUOTE_PRECISION (1e6); accrued so far for this slot — may include fees from other orders that reused the same slot, not exclusively `orderId` */
1551
2218
  feesAccrued: BN;
2219
+ /** the currently-active order's id in this slot; only meaningful while the slot is open */
1552
2220
  orderId: number;
2221
+ /** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
1553
2222
  feeTenthBps: number;
1554
2223
  marketIndex: number;
2224
+ /** only meaningful while the slot is open */
1555
2225
  subAccountId: number;
2226
+ /** index into `RevenueShareEscrowAccount.approvedBuilders` this order's fee settles to; ignored for a referral-only slot */
1556
2227
  builderIdx: number;
2228
+ /** bitflags describing slot state (init/open/completed) and whether it holds referral rewards rather than a builder fee */
1557
2229
  bitFlags: number;
1558
2230
  userOrderIndex: number;
1559
2231
  marketType: MarketType;
1560
2232
  padding: number[];
1561
2233
  };
2234
+ /** One builder a user has approved to charge a fee on their orders, inside `RevenueShareEscrowAccount.approvedBuilders`. */
1562
2235
  export type BuilderInfo = {
2236
+ /** the builder's authority */
1563
2237
  authority: PublicKey;
2238
+ /** ceiling on the fee (tenths of a bps) this builder may charge; `0` means the approval has been revoked */
1564
2239
  maxFeeTenthBps: number;
1565
2240
  padding: number[];
1566
2241
  };
2242
+ /** Emitted when a perp market's fee-ledger pendings are swept into their durable homes (protocol fee pool, quote market revenue pool, AMM fee pool). */
1567
2243
  export type PerpMarketFeeSweepRecord = {
1568
2244
  ts: BN;
1569
2245
  marketIndex: number;
2246
+ /** pending insurance cut moved to the quote spot market's revenue pool, QUOTE_PRECISION (1e6) */
1570
2247
  ifSwept: BN;
2248
+ /** pending protocol cut moved to the market's protocol fee pool, QUOTE_PRECISION (1e6) */
1571
2249
  protocolSwept: BN;
2250
+ /** AMM fee provision (booked at fill) tokenized into `AMM.feePool`, QUOTE_PRECISION (1e6) */
1572
2251
  ammProvisionTokenized: BN;
1573
2252
  };
2253
+ /** Emitted when `coldAdmin` withdraws accumulated protocol fees to the configured recipient. */
1574
2254
  export type ProtocolFeeWithdrawRecord = {
1575
2255
  ts: BN;
2256
+ /** perp market index for a perp-fee withdrawal, else the spot market index */
1576
2257
  marketIndex: number;
2258
+ /** true if this withdrawal drained a perp market's `protocolFeePool` (sourced from the quote spot vault); false for a spot market withdrawal */
1577
2259
  isPerp: boolean;
2260
+ /** the spot market the tokens were drawn from */
1578
2261
  spotMarketIndex: number;
2262
+ /** spot market token-mint precision */
1579
2263
  amount: BN;
1580
2264
  recipientTokenAccount: PublicKey;
1581
2265
  };
2266
+ /** Emitted when a builder's/referrer's accrued `RevenueShareOrder` fees are settled into their `RevenueShareAccount`. */
1582
2267
  export type RevenueShareSettleRecord = {
1583
2268
  ts: BN;
2269
+ /** set when this settle paid a builder fee */
1584
2270
  builder: PublicKey | null;
2271
+ /** set when this settle paid a referral reward */
1585
2272
  referrer: PublicKey | null;
2273
+ /** QUOTE_PRECISION (1e6) */
1586
2274
  feeSettled: BN;
1587
2275
  marketIndex: number;
1588
2276
  marketType: MarketType;
2277
+ /** the builder's `RevenueShareAccount.totalReferrerRewards` after this settle, QUOTE_PRECISION (1e6) */
1589
2278
  builderTotalReferrerRewards: BN;
2279
+ /** the builder's `RevenueShareAccount.totalBuilderRewards` after this settle, QUOTE_PRECISION (1e6) */
1590
2280
  builderTotalBuilderRewards: BN;
1591
2281
  builderSubAccountId: number;
1592
2282
  };
2283
+ /** Admin instruction params to add one constituent's weight in a perp market's AMM constituent mapping (used to route hedge flow). */
1593
2284
  export type AddAmmConstituentMappingDatum = {
1594
2285
  constituentIndex: number;
1595
2286
  perpMarketIndex: number;
2287
+ /** PERCENTAGE_PRECISION (1e6) */
1596
2288
  weight: BN;
1597
2289
  };
2290
+ /** One entry of an `AmmConstituentMapping`, weighting how much of a perp market's hedge flow routes to a given LP-pool constituent. */
1598
2291
  export type AmmConstituentDatum = AddAmmConstituentMappingDatum & {
1599
2292
  lastSlot: BN;
1600
2293
  };
2294
+ /** Decoded mirror of the `AmmConstituentMapping` account: which LP-pool constituents each perp market hedges into, and by how much. */
1601
2295
  export type AmmConstituentMapping = {
1602
2296
  lpPool: PublicKey;
1603
2297
  bump: number;
1604
2298
  weights: AmmConstituentDatum[];
1605
2299
  };
2300
+ /** One perp market's target-hedge-position entry inside a `ConstituentTargetBaseAccount`. */
1606
2301
  export type TargetDatum = {
2302
+ /** bps; estimated cost to trade into/out of the target position */
1607
2303
  costToTradeBps: number;
1608
2304
  lastOracleSlot: BN;
1609
2305
  lastPositionSlot: BN;
2306
+ /** BASE_PRECISION (1e9); the target hedge position size */
1610
2307
  targetBase: BN;
1611
2308
  };
2309
+ /** Decoded mirror of the `ConstituentTargetBase` account: the LP pool's per-perp-market target hedge positions. */
1612
2310
  export type ConstituentTargetBaseAccount = {
1613
2311
  lpPool: PublicKey;
1614
2312
  bump: number;
1615
2313
  targets: TargetDatum[];
1616
2314
  };
2315
+ /** Decoded mirror of the `ConstituentCorrelations` account: pairwise correlation coefficients between an LP pool's constituents, used in swap-fee pricing. */
1617
2316
  export type ConstituentCorrelations = {
1618
2317
  lpPool: PublicKey;
1619
2318
  bump: number;
2319
+ /** PERCENTAGE_PRECISION (1e6), signed; flattened row-major correlation matrix */
1620
2320
  correlations: BN[];
1621
2321
  };
2322
+ /** Decoded mirror of the on-chain `LPPool` account: a hedging vault that mints/redeems LP tokens against a basket of spot-market constituents and hedges perp-market exposure. */
1622
2323
  export type LPPoolAccount = {
1623
2324
  lpPoolId: number;
1624
2325
  pubkey: PublicKey;
2326
+ /** the LP token mint */
1625
2327
  mint: PublicKey;
1626
2328
  whitelistMint: PublicKey;
1627
2329
  constituentTargetBase: PublicKey;
1628
2330
  constituentCorrelations: PublicKey;
2331
+ /** QUOTE_PRECISION (1e6); mint requests that would push AUM above this are rejected */
1629
2332
  maxAum: BN;
2333
+ /** QUOTE_PRECISION (1e6); AUM of the vault in USD, updated lazily */
1630
2334
  lastAum: BN;
2335
+ /** QUOTE_PRECISION (1e6) */
1631
2336
  cumulativeQuoteSentToPerpMarkets: BN;
2337
+ /** QUOTE_PRECISION (1e6) */
1632
2338
  cumulativeQuoteReceivedFromPerpMarkets: BN;
2339
+ /** signed, QUOTE_PRECISION (1e6); total fees paid for minting and redeeming LP tokens */
1633
2340
  totalMintRedeemFeesPaid: BN;
1634
2341
  lastAumSlot: BN;
2342
+ /** token-mint precision cap on a single settle's quote transfer */
1635
2343
  maxSettleQuoteAmount: BN;
1636
2344
  mintRedeemId: BN;
1637
2345
  settleId: BN;
2346
+ /** PERCENTAGE_PRECISION (1e6); floor fee charged on mint/redeem */
1638
2347
  minMintFee: BN;
2348
+ /** LP token precision; the LP mint's total supply */
1639
2349
  tokenSupply: BN;
2350
+ /** PERCENTAGE_PRECISION (1e6); pool-wide volatility parameter feeding swap-fee/target pricing */
1640
2351
  volatility: BN;
1641
2352
  constituents: number;
1642
- quoteConstituentIndex: number;
2353
+ quoteConsituentIndex: number;
1643
2354
  bump: number;
2355
+ /** no precision — a raw constant used in swap-fee execution-cost pricing */
1644
2356
  gammaExecution: number;
2357
+ /** no precision — a raw constant used in swap-fee pricing */
1645
2358
  xi: number;
2359
+ /** bps of fee per 10 slots of oracle-target delay */
1646
2360
  targetOracleDelayFeeBpsPer10Slots: number;
2361
+ /** bps of fee per 10 slots of position-target delay */
1647
2362
  targetPositionDelayFeeBpsPer10Slots: number;
1648
2363
  };
2364
+ /** A constituent's spot-market balance inside an LP pool (parallel to `PoolBalance` but tracking cumulative deposits too). */
1649
2365
  export type ConstituentSpotBalance = {
2366
+ /** SPOT_BALANCE_PRECISION (1e9) scaled balance */
1650
2367
  scaledBalance: BN;
2368
+ /** token mint precision */
1651
2369
  cumulativeDeposits: BN;
1652
2370
  marketIndex: number;
1653
2371
  balanceType: SpotBalanceType;
1654
2372
  };
2373
+ /** Admin instruction params for `initializeConstituent`, configuring a new LP-pool spot-market constituent. */
1655
2374
  export type InitializeConstituentParams = {
1656
2375
  spotMarketIndex: number;
1657
2376
  decimals: number;
2377
+ /** PERCENTAGE_PRECISION (1e6); max allowed deviation from target weight before rebalance pressure kicks in */
1658
2378
  maxWeightDeviation: BN;
2379
+ /** PERCENTAGE_PRECISION (1e6) */
1659
2380
  swapFeeMin: BN;
2381
+ /** PERCENTAGE_PRECISION (1e6) */
1660
2382
  swapFeeMax: BN;
2383
+ /** token mint precision; borrow cap for this constituent */
1661
2384
  maxBorrowTokenAmount: BN;
2385
+ /** slots; oracle updates older than this are treated as stale for this constituent */
1662
2386
  oracleStalenessThreshold: BN;
2387
+ /** bps; estimated cost to trade this constituent */
1663
2388
  costToTrade: number;
2389
+ /** PERCENTAGE_PRECISION (1e6); weight applied when this constituent derives its price from another constituent */
1664
2390
  derivativeWeight: BN;
1665
2391
  constituentDerivativeIndex?: number;
2392
+ /** PERCENTAGE_PRECISION (1e6); max allowed depeg from the derivative reference before the constituent is treated as broken */
1666
2393
  constituentDerivativeDepegThreshold?: BN;
2394
+ /** PERCENTAGE_PRECISION (1e6), signed; this constituent's correlation with every other constituent */
1667
2395
  constituentCorrelations: BN[];
2396
+ /** PERCENTAGE_PRECISION (1e6) */
1668
2397
  volatility: BN;
1669
2398
  gammaExecution?: number;
1670
2399
  gammaInventory?: number;
1671
2400
  xi?: number;
1672
2401
  };
2402
+ /** Lifecycle status of an LP-pool `ConstituentAccount`. */
1673
2403
  export declare enum ConstituentStatus {
1674
2404
  ACTIVE = 0,
2405
+ /** may only shrink toward its target weight, not grow */
1675
2406
  REDUCE_ONLY = 1,
1676
2407
  DECOMMISSIONED = 2
1677
2408
  }
2409
+ /** Bitmask mirror of `ConstituentAccount.pausedOperations`, gating which LP-pool operations a constituent allows. */
1678
2410
  export declare enum ConstituentLpOperation {
1679
2411
  Swap = 1,
1680
2412
  Deposit = 2,
1681
2413
  Withdraw = 4
1682
2414
  }
2415
+ /** Decoded mirror of the on-chain `Constituent` account: one spot-market asset inside an LP pool's basket. */
1683
2416
  export type ConstituentAccount = {
1684
2417
  pubkey: PublicKey;
1685
2418
  mint: PublicKey;
1686
2419
  lpPool: PublicKey;
1687
2420
  vault: PublicKey;
2421
+ /** signed, positive = fees received, negative = fees paid; PERCENTAGE_PRECISION-derived token units */
1688
2422
  totalSwapFees: BN;
1689
2423
  spotBalance: ConstituentSpotBalance;
2424
+ /** token mint precision */
1690
2425
  lastSpotBalanceTokenAmount: BN;
2426
+ /** token mint precision */
1691
2427
  cumulativeSpotInterestAccruedTokenAmount: BN;
2428
+ /** PERCENTAGE_PRECISION (1e6); max allowed deviation from target weight */
1692
2429
  maxWeightDeviation: BN;
2430
+ /** PERCENTAGE_PRECISION (1e6); min fee charged on swaps to/from this constituent */
1693
2431
  swapFeeMin: BN;
2432
+ /** PERCENTAGE_PRECISION (1e6); max fee charged on swaps to/from this constituent */
1694
2433
  swapFeeMax: BN;
2434
+ /** token mint precision */
1695
2435
  maxBorrowTokenAmount: BN;
2436
+ /** token mint precision; the vault's actual token account balance */
1696
2437
  vaultTokenBalance: BN;
1697
2438
  lastOraclePrice: BN;
1698
2439
  lastOracleSlot: BN;
2440
+ /** slots; delay allowed for a valid AUM calculation before this constituent's price is considered stale */
1699
2441
  oracleStalenessThreshold: BN;
2442
+ /** token mint precision; user's token balance snapshotted at `beginSwap`-style flash accounting */
1700
2443
  flashLoanInitialTokenAmount: BN;
1701
2444
  nextSwapId: BN;
2445
+ /** PERCENTAGE_PRECISION (1e6); share of derivative weight routed to this constituent specifically; 0 if this constituent has no derivative weight */
1702
2446
  derivativeWeight: BN;
2447
+ /** PERCENTAGE_PRECISION (1e6); 1 = 1% */
1703
2448
  volatility: BN;
2449
+ /** PERCENTAGE_PRECISION (1e6); max allowed depeg from the parent constituent before this derivative is treated as broken */
1704
2450
  constituentDerivativeDepegThreshold: BN;
2451
+ /** the parent constituent's index if this is a derivative (e.g. dSOL -> SOL); -1 if this constituent is itself a parent */
1705
2452
  constituentDerivativeIndex: number;
1706
2453
  spotMarketIndex: number;
1707
2454
  constituentIndex: number;
1708
2455
  decimals: number;
1709
2456
  bump: number;
1710
2457
  vaultBump: number;
2458
+ /** no precision — raw constant used in swap-fee inventory-skew pricing */
1711
2459
  gammaInventory: number;
2460
+ /** no precision — raw constant used in swap-fee execution-cost pricing */
1712
2461
  gammaExecution: number;
2462
+ /** no precision — raw constant used in swap-fee pricing */
1713
2463
  xi: number;
2464
+ /** see `ConstituentStatus` */
1714
2465
  status: number;
2466
+ /** bitmask, see `ConstituentLpOperation` */
1715
2467
  pausedOperations: number;
1716
2468
  };
2469
+ /** One perp market's cached AMM/settlement snapshot inside an `AmmCache`, refreshed by the keeper crank so LP-pool settlement doesn't need to reload the full `PerpMarketAccount`. */
1717
2470
  export type CacheInfo = {
1718
2471
  oracle: PublicKey;
1719
2472
  lastFeePoolTokenAmount: BN;
2473
+ /** signed */
1720
2474
  lastNetPnlPoolTokenAmount: BN;
1721
2475
  lastExchangeFees: BN;
1722
2476
  lastSettleAmmExFees: BN;
2477
+ /** signed */
1723
2478
  lastSettleAmmPnl: BN;
2479
+ /** BASE_PRECISION (1e9), signed; the AMM's net position at last cache update */
1724
2480
  position: BN;
1725
2481
  slot: BN;
1726
2482
  lastSettleAmount: BN;
1727
2483
  lastSettleSlot: BN;
1728
2484
  lastSettleTs: BN;
2485
+ /** signed; quote owed from the LP pool to this market (or vice versa if negative) */
1729
2486
  quoteOwedFromLpPool: BN;
2487
+ /** signed; cap on the AMM's hedgeable inventory */
1730
2488
  ammInventoryLimit: BN;
2489
+ /** PRICE_PRECISION (1e6), signed */
1731
2490
  oraclePrice: BN;
1732
2491
  oracleSlot: BN;
2492
+ /** numeric `OracleSourceNum` discriminant */
1733
2493
  oracleSource: number;
2494
+ /** `OracleValidity` discriminant at last cache update */
1734
2495
  oracleValidity: number;
1735
2496
  lpStatusForPerpMarket: number;
1736
2497
  ammPositionScalar: number;
1737
2498
  marketIndex: number;
1738
2499
  };
2500
+ /** Decoded mirror of the on-chain `AmmCache` account: one `CacheInfo` per perp market, indexed by `marketIndex`. */
1739
2501
  export type AmmCache = {
1740
2502
  bump: number;
1741
2503
  cache: CacheInfo[];
1742
2504
  };
2505
+ /** SDK-computed result of checking whether a user account can currently be liquidated. */
1743
2506
  export type AccountLiquidatableStatus = {
1744
2507
  canBeLiquidated: boolean;
2508
+ /** QUOTE_PRECISION (1e6); the maintenance margin requirement compared against */
1745
2509
  marginRequirement: BN;
2510
+ /** signed, QUOTE_PRECISION (1e6) */
1746
2511
  totalCollateral: BN;
1747
2512
  };
2513
+ /** Direction of an admin `transferFeeAndPnlPool` action, moving funds between a perp market's protocol fee pool and its pnl pool. */
1748
2514
  export declare class TransferFeeAndPnlPoolDirection {
1749
2515
  static readonly FEE_TO_PNL_POOL: {
1750
2516
  feeToPnlPool: {};
@@ -1753,12 +2519,14 @@ export declare class TransferFeeAndPnlPoolDirection {
1753
2519
  pnlToFeePool: {};
1754
2520
  };
1755
2521
  }
2522
+ /** Emitted when an admin transfers funds between a perp market's fee pool and pnl pool (`transferFeeAndPnlPool`). The two market indices may refer to the same or different perp markets. */
1756
2523
  export type TransferFeeAndPnlPoolRecord = {
1757
2524
  ts: BN;
1758
2525
  slot: BN;
1759
2526
  perpMarketIndexWithFeePool: number;
1760
2527
  perpMarketIndexWithPnlPool: number;
1761
2528
  direction: TransferFeeAndPnlPoolDirection;
2529
+ /** QUOTE_PRECISION (1e6) */
1762
2530
  amount: BN;
1763
2531
  };
1764
2532
  export {};