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