@velocity-exchange/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1046) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +18 -0
  3. package/lib/browser/accounts/basicUserAccountSubscriber.js +18 -0
  4. package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
  5. package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +18 -0
  6. package/lib/browser/accounts/bulkAccountLoader.d.ts +52 -0
  7. package/lib/browser/accounts/bulkAccountLoader.js +51 -0
  8. package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +9 -2
  9. package/lib/browser/accounts/bulkUserStatsSubscription.js +9 -2
  10. package/lib/browser/accounts/bulkUserSubscription.d.ts +8 -2
  11. package/lib/browser/accounts/bulkUserSubscription.js +8 -2
  12. package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
  13. package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +37 -0
  14. package/lib/browser/accounts/fetch.d.ts +59 -2
  15. package/lib/browser/accounts/fetch.js +57 -2
  16. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +30 -0
  17. package/lib/browser/accounts/grpcAccountSubscriber.js +30 -0
  18. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
  19. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
  20. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
  21. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +118 -37
  22. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
  23. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +40 -12
  24. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
  25. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +33 -0
  26. package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +15 -0
  27. package/lib/browser/accounts/grpcUserAccountSubscriber.js +15 -0
  28. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
  29. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +15 -0
  30. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
  31. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
  32. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
  33. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
  34. package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +34 -0
  35. package/lib/browser/accounts/laserProgramAccountSubscriber.js +34 -0
  36. package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
  37. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +19 -0
  38. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
  39. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
  40. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
  41. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
  42. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
  43. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +21 -2
  44. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
  45. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +22 -0
  46. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +32 -0
  47. package/lib/browser/accounts/pollingUserAccountSubscriber.js +32 -0
  48. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
  49. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +22 -0
  50. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
  51. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
  52. package/lib/browser/accounts/testBulkAccountLoader.d.ts +8 -0
  53. package/lib/browser/accounts/testBulkAccountLoader.js +8 -0
  54. package/lib/browser/accounts/types.d.ts +149 -0
  55. package/lib/browser/accounts/types.js +13 -0
  56. package/lib/browser/accounts/utils.d.ts +18 -0
  57. package/lib/browser/accounts/utils.js +32 -16
  58. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +41 -0
  59. package/lib/browser/accounts/webSocketAccountSubscriber.js +41 -0
  60. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
  61. package/lib/browser/accounts/webSocketAccountSubscriberV2.js +31 -23
  62. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
  63. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
  64. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
  65. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +36 -0
  66. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
  67. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
  68. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
  69. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
  70. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
  71. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +26 -0
  72. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
  73. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
  74. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
  75. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
  76. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
  77. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
  78. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
  79. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +33 -0
  80. package/lib/browser/addresses/marketAddresses.d.ts +10 -0
  81. package/lib/browser/addresses/marketAddresses.js +10 -0
  82. package/lib/browser/addresses/pda.d.ts +214 -2
  83. package/lib/browser/addresses/pda.js +217 -5
  84. package/lib/browser/adminClient.d.ts +2136 -4
  85. package/lib/browser/adminClient.js +2150 -4
  86. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +15 -0
  87. package/lib/browser/auctionSubscriber/auctionSubscriber.js +15 -0
  88. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
  89. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
  90. package/lib/browser/auctionSubscriber/index.d.ts +6 -0
  91. package/lib/browser/auctionSubscriber/index.js +6 -0
  92. package/lib/browser/auctionSubscriber/types.d.ts +7 -0
  93. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
  94. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +33 -0
  95. package/lib/browser/blockhashSubscriber/index.d.ts +5 -0
  96. package/lib/browser/blockhashSubscriber/index.js +5 -0
  97. package/lib/browser/blockhashSubscriber/types.d.ts +5 -0
  98. package/lib/browser/clock/clockSubscriber.d.ts +24 -0
  99. package/lib/browser/clock/clockSubscriber.js +22 -0
  100. package/lib/browser/config.d.ts +58 -4
  101. package/lib/browser/config.js +88 -21
  102. package/lib/browser/constants/numericConstants.d.ts +67 -0
  103. package/lib/browser/constants/numericConstants.js +68 -1
  104. package/lib/browser/constants/perpMarkets.d.ts +10 -0
  105. package/lib/browser/constants/perpMarkets.js +40 -908
  106. package/lib/browser/constants/spotMarkets.d.ts +13 -0
  107. package/lib/browser/constants/spotMarkets.js +16 -742
  108. package/lib/browser/constants/txConstants.d.ts +1 -0
  109. package/lib/browser/constants/txConstants.js +1 -0
  110. package/lib/browser/core/VelocityCore.d.ts +285 -8
  111. package/lib/browser/core/VelocityCore.js +281 -8
  112. package/lib/browser/core/instructions/deposit.d.ts +22 -0
  113. package/lib/browser/core/instructions/deposit.js +22 -0
  114. package/lib/browser/core/instructions/fill.d.ts +17 -0
  115. package/lib/browser/core/instructions/fill.js +17 -0
  116. package/lib/browser/core/instructions/funding.d.ts +12 -0
  117. package/lib/browser/core/instructions/funding.js +12 -0
  118. package/lib/browser/core/instructions/liquidation.d.ts +18 -0
  119. package/lib/browser/core/instructions/liquidation.js +18 -0
  120. package/lib/browser/core/instructions/orders.d.ts +28 -0
  121. package/lib/browser/core/instructions/orders.js +28 -0
  122. package/lib/browser/core/instructions/perpOrders.d.ts +106 -0
  123. package/lib/browser/core/instructions/perpOrders.js +106 -0
  124. package/lib/browser/core/instructions/settlement.d.ts +14 -0
  125. package/lib/browser/core/instructions/settlement.js +14 -0
  126. package/lib/browser/core/instructions/trigger.d.ts +15 -0
  127. package/lib/browser/core/instructions/trigger.js +15 -0
  128. package/lib/browser/core/instructions/withdraw.d.ts +21 -0
  129. package/lib/browser/core/instructions/withdraw.js +21 -0
  130. package/lib/browser/core/remainingAccounts.d.ts +47 -3
  131. package/lib/browser/core/remainingAccounts.js +20 -0
  132. package/lib/browser/core/signedMsg.d.ts +38 -0
  133. package/lib/browser/core/signedMsg.js +33 -0
  134. package/lib/browser/decode/customCoder.d.ts +39 -3
  135. package/lib/browser/decode/customCoder.js +45 -3
  136. package/lib/browser/decode/user.d.ts +22 -0
  137. package/lib/browser/decode/user.js +22 -0
  138. package/lib/browser/dlob/DLOB.d.ts +502 -53
  139. package/lib/browser/dlob/DLOB.js +540 -98
  140. package/lib/browser/dlob/DLOBNode.d.ts +86 -4
  141. package/lib/browser/dlob/DLOBNode.js +37 -4
  142. package/lib/browser/dlob/DLOBSubscriber.d.ts +39 -12
  143. package/lib/browser/dlob/DLOBSubscriber.js +42 -12
  144. package/lib/browser/dlob/NodeList.d.ts +69 -0
  145. package/lib/browser/dlob/NodeList.js +66 -0
  146. package/lib/browser/dlob/orderBookLevels.d.ts +106 -13
  147. package/lib/browser/dlob/orderBookLevels.js +84 -14
  148. package/lib/browser/dlob/types.d.ts +15 -0
  149. package/lib/browser/events/eventList.d.ts +14 -0
  150. package/lib/browser/events/eventList.js +14 -0
  151. package/lib/browser/events/eventSubscriber.d.ts +87 -10
  152. package/lib/browser/events/eventSubscriber.js +93 -8
  153. package/lib/browser/events/eventsServerLogProvider.d.ts +22 -0
  154. package/lib/browser/events/eventsServerLogProvider.js +27 -0
  155. package/lib/browser/events/fetchLogs.d.ts +31 -0
  156. package/lib/browser/events/fetchLogs.js +46 -1
  157. package/lib/browser/events/parse.d.ts +23 -0
  158. package/lib/browser/events/parse.js +23 -0
  159. package/lib/browser/events/pollingLogProvider.d.ts +24 -0
  160. package/lib/browser/events/pollingLogProvider.js +24 -0
  161. package/lib/browser/events/sort.d.ts +11 -0
  162. package/lib/browser/events/sort.js +12 -0
  163. package/lib/browser/events/txEventCache.d.ts +13 -3
  164. package/lib/browser/events/txEventCache.js +19 -7
  165. package/lib/browser/events/types.d.ts +118 -2
  166. package/lib/browser/events/types.js +11 -0
  167. package/lib/browser/events/webSocketLogProvider.d.ts +23 -0
  168. package/lib/browser/events/webSocketLogProvider.js +28 -0
  169. package/lib/browser/factory/oracleClient.js +2 -2
  170. package/lib/browser/idl/velocity.d.ts +4 -4
  171. package/lib/browser/idl/velocity.json +4 -4
  172. package/lib/browser/keypair.d.ts +8 -0
  173. package/lib/browser/keypair.js +8 -0
  174. package/lib/browser/marginCalculation.d.ts +134 -2
  175. package/lib/browser/marginCalculation.js +121 -0
  176. package/lib/browser/math/amm.d.ts +348 -29
  177. package/lib/browser/math/amm.js +310 -32
  178. package/lib/browser/math/auction.d.ts +95 -19
  179. package/lib/browser/math/auction.js +118 -28
  180. package/lib/browser/math/bankruptcy.d.ts +46 -0
  181. package/lib/browser/math/bankruptcy.js +89 -1
  182. package/lib/browser/math/builder.d.ts +64 -8
  183. package/lib/browser/math/builder.js +71 -9
  184. package/lib/browser/math/conversion.d.ts +21 -0
  185. package/lib/browser/math/conversion.js +21 -0
  186. package/lib/browser/math/exchangeStatus.d.ts +91 -0
  187. package/lib/browser/math/exchangeStatus.js +106 -3
  188. package/lib/browser/math/funding.d.ts +57 -20
  189. package/lib/browser/math/funding.js +63 -23
  190. package/lib/browser/math/insurance.d.ts +62 -0
  191. package/lib/browser/math/insurance.js +62 -0
  192. package/lib/browser/math/liquidation.d.ts +127 -11
  193. package/lib/browser/math/liquidation.js +182 -19
  194. package/lib/browser/math/margin.d.ts +79 -13
  195. package/lib/browser/math/margin.js +80 -14
  196. package/lib/browser/math/market.d.ts +135 -15
  197. package/lib/browser/math/market.js +145 -17
  198. package/lib/browser/math/oracles.d.ts +113 -0
  199. package/lib/browser/math/oracles.js +118 -1
  200. package/lib/browser/math/orders.d.ts +115 -10
  201. package/lib/browser/math/orders.js +130 -19
  202. package/lib/browser/math/position.d.ts +80 -33
  203. package/lib/browser/math/position.js +80 -33
  204. package/lib/browser/math/repeg.d.ts +48 -10
  205. package/lib/browser/math/repeg.js +48 -10
  206. package/lib/browser/math/spotBalance.d.ts +200 -5
  207. package/lib/browser/math/spotBalance.js +239 -10
  208. package/lib/browser/math/spotMarket.d.ts +36 -3
  209. package/lib/browser/math/spotMarket.js +36 -3
  210. package/lib/browser/math/spotPosition.d.ts +72 -0
  211. package/lib/browser/math/spotPosition.js +62 -0
  212. package/lib/browser/math/state.d.ts +31 -0
  213. package/lib/browser/math/state.js +31 -0
  214. package/lib/browser/math/superStake.d.ts +126 -2
  215. package/lib/browser/math/superStake.js +123 -3
  216. package/lib/browser/math/tiers.d.ts +29 -0
  217. package/lib/browser/math/tiers.js +29 -0
  218. package/lib/browser/math/trade.d.ts +102 -51
  219. package/lib/browser/math/trade.js +101 -55
  220. package/lib/browser/math/utils.d.ts +71 -9
  221. package/lib/browser/math/utils.js +71 -9
  222. package/lib/browser/memcmp.d.ts +94 -0
  223. package/lib/browser/memcmp.js +103 -2
  224. package/lib/browser/oracles/oracleClientCache.d.ts +16 -0
  225. package/lib/browser/oracles/oracleClientCache.js +16 -0
  226. package/lib/browser/oracles/oracleId.d.ts +31 -0
  227. package/lib/browser/oracles/oracleId.js +39 -8
  228. package/lib/browser/oracles/prelaunchOracleClient.d.ts +20 -0
  229. package/lib/browser/oracles/prelaunchOracleClient.js +20 -0
  230. package/lib/browser/oracles/pythClient.d.ts +31 -0
  231. package/lib/browser/oracles/pythClient.js +32 -1
  232. package/lib/browser/oracles/pythLazerClient.d.ts +34 -0
  233. package/lib/browser/oracles/pythLazerClient.js +35 -1
  234. package/lib/browser/oracles/quoteAssetOracleClient.d.ts +18 -0
  235. package/lib/browser/oracles/quoteAssetOracleClient.js +18 -0
  236. package/lib/browser/oracles/strictOraclePrice.d.ts +21 -0
  237. package/lib/browser/oracles/strictOraclePrice.js +21 -0
  238. package/lib/browser/oracles/types.d.ts +45 -0
  239. package/lib/browser/oracles/utils.d.ts +20 -0
  240. package/lib/browser/oracles/utils.js +20 -0
  241. package/lib/browser/orderParams.d.ts +42 -4
  242. package/lib/browser/orderParams.js +42 -4
  243. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +56 -0
  244. package/lib/browser/orderSubscriber/OrderSubscriber.js +56 -0
  245. package/lib/browser/orderSubscriber/PollingSubscription.d.ts +11 -0
  246. package/lib/browser/orderSubscriber/PollingSubscription.js +11 -0
  247. package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +18 -0
  248. package/lib/browser/orderSubscriber/WebsocketSubscription.js +18 -0
  249. package/lib/browser/orderSubscriber/grpcSubscription.d.ts +16 -0
  250. package/lib/browser/orderSubscriber/grpcSubscription.js +16 -0
  251. package/lib/browser/orderSubscriber/types.d.ts +9 -0
  252. package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
  253. package/lib/browser/priorityFee/averageOverSlotsStrategy.js +1 -0
  254. package/lib/browser/priorityFee/averageStrategy.d.ts +1 -0
  255. package/lib/browser/priorityFee/averageStrategy.js +1 -0
  256. package/lib/browser/priorityFee/ewmaStrategy.d.ts +10 -0
  257. package/lib/browser/priorityFee/ewmaStrategy.js +10 -0
  258. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
  259. package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +9 -2
  260. package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
  261. package/lib/browser/priorityFee/maxOverSlotsStrategy.js +1 -0
  262. package/lib/browser/priorityFee/maxStrategy.d.ts +1 -0
  263. package/lib/browser/priorityFee/maxStrategy.js +1 -0
  264. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +39 -0
  265. package/lib/browser/priorityFee/priorityFeeSubscriber.js +39 -0
  266. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
  267. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +21 -2
  268. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
  269. package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +10 -0
  270. package/lib/browser/priorityFee/types.d.ts +32 -0
  271. package/lib/browser/priorityFee/types.js +5 -0
  272. package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
  273. package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +8 -0
  274. package/lib/browser/slot/SlotSubscriber.d.ts +18 -0
  275. package/lib/browser/slot/SlotSubscriber.js +16 -0
  276. package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
  277. package/lib/browser/slot/SlothashSubscriber.js +25 -1
  278. package/lib/browser/tx/baseTxSender.d.ts +163 -0
  279. package/lib/browser/tx/baseTxSender.js +174 -6
  280. package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
  281. package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
  282. package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
  283. package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
  284. package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
  285. package/lib/browser/tx/fastSingleTxSender.d.ts +47 -0
  286. package/lib/browser/tx/fastSingleTxSender.js +48 -1
  287. package/lib/browser/tx/forwardOnlyTxSender.d.ts +48 -0
  288. package/lib/browser/tx/forwardOnlyTxSender.js +48 -0
  289. package/lib/browser/tx/reportTransactionError.d.ts +18 -6
  290. package/lib/browser/tx/reportTransactionError.js +18 -6
  291. package/lib/browser/tx/retryTxSender.d.ts +40 -0
  292. package/lib/browser/tx/retryTxSender.js +39 -0
  293. package/lib/browser/tx/txHandler.d.ts +146 -35
  294. package/lib/browser/tx/txHandler.js +132 -32
  295. package/lib/browser/tx/txParamProcessor.d.ts +47 -0
  296. package/lib/browser/tx/txParamProcessor.js +47 -0
  297. package/lib/browser/tx/types.d.ts +46 -0
  298. package/lib/browser/tx/types.js +5 -0
  299. package/lib/browser/tx/utils.d.ts +26 -0
  300. package/lib/browser/tx/utils.js +26 -0
  301. package/lib/browser/tx/whileValidTxSender.d.ts +82 -0
  302. package/lib/browser/tx/whileValidTxSender.js +81 -0
  303. package/lib/browser/types.d.ts +781 -13
  304. package/lib/browser/types.js +126 -9
  305. package/lib/browser/user.d.ts +645 -84
  306. package/lib/browser/user.js +779 -96
  307. package/lib/browser/userMap/PollingSubscription.d.ts +10 -0
  308. package/lib/browser/userMap/PollingSubscription.js +14 -2
  309. package/lib/browser/userMap/WebsocketSubscription.d.ts +9 -0
  310. package/lib/browser/userMap/WebsocketSubscription.js +9 -0
  311. package/lib/browser/userMap/grpcSubscription.d.ts +8 -0
  312. package/lib/browser/userMap/grpcSubscription.js +8 -0
  313. package/lib/browser/userMap/referrerMap.d.ts +72 -2
  314. package/lib/browser/userMap/referrerMap.js +84 -2
  315. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +37 -10
  316. package/lib/browser/userMap/revenueShareEscrowMap.js +38 -11
  317. package/lib/browser/userMap/userMap.d.ts +81 -3
  318. package/lib/browser/userMap/userMap.js +81 -4
  319. package/lib/browser/userMap/userMapConfig.d.ts +23 -0
  320. package/lib/browser/userMap/userStatsMap.d.ts +22 -0
  321. package/lib/browser/userMap/userStatsMap.js +22 -0
  322. package/lib/browser/userName.d.ts +16 -0
  323. package/lib/browser/userName.js +16 -0
  324. package/lib/browser/userStats.d.ts +28 -1
  325. package/lib/browser/userStats.js +28 -1
  326. package/lib/browser/util/TransactionConfirmationManager.d.ts +33 -0
  327. package/lib/browser/util/TransactionConfirmationManager.js +33 -0
  328. package/lib/browser/util/chainClock.d.ts +24 -0
  329. package/lib/browser/util/chainClock.js +20 -0
  330. package/lib/browser/util/computeUnits.d.ts +32 -0
  331. package/lib/browser/util/computeUnits.js +32 -0
  332. package/lib/browser/util/digest.d.ts +17 -0
  333. package/lib/browser/util/digest.js +17 -0
  334. package/lib/browser/util/ed25519Utils.d.ts +12 -2
  335. package/lib/browser/util/ed25519Utils.js +12 -2
  336. package/lib/browser/util/promiseTimeout.d.ts +9 -0
  337. package/lib/browser/util/promiseTimeout.js +9 -0
  338. package/lib/browser/velocityClient.d.ts +3322 -215
  339. package/lib/browser/velocityClient.js +3412 -245
  340. package/lib/browser/wallet.d.ts +37 -0
  341. package/lib/browser/wallet.js +37 -0
  342. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +18 -0
  343. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
  344. package/lib/node/accounts/basicUserAccountSubscriber.js +18 -0
  345. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
  346. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
  347. package/lib/node/accounts/basicUserStatsAccountSubscriber.js +18 -0
  348. package/lib/node/accounts/bulkAccountLoader.d.ts +52 -0
  349. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
  350. package/lib/node/accounts/bulkAccountLoader.js +51 -0
  351. package/lib/node/accounts/bulkUserStatsSubscription.d.ts +9 -2
  352. package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -1
  353. package/lib/node/accounts/bulkUserStatsSubscription.js +9 -2
  354. package/lib/node/accounts/bulkUserSubscription.d.ts +8 -2
  355. package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -1
  356. package/lib/node/accounts/bulkUserSubscription.js +8 -2
  357. package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
  358. package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -1
  359. package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +37 -0
  360. package/lib/node/accounts/fetch.d.ts +59 -2
  361. package/lib/node/accounts/fetch.d.ts.map +1 -1
  362. package/lib/node/accounts/fetch.js +57 -2
  363. package/lib/node/accounts/grpcAccountSubscriber.d.ts +30 -0
  364. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  365. package/lib/node/accounts/grpcAccountSubscriber.js +30 -0
  366. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
  367. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  368. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
  369. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
  370. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  371. package/lib/node/accounts/grpcMultiAccountSubscriber.js +118 -37
  372. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
  373. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  374. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +40 -12
  375. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
  376. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  377. package/lib/node/accounts/grpcProgramAccountSubscriber.js +33 -0
  378. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +15 -0
  379. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
  380. package/lib/node/accounts/grpcUserAccountSubscriber.js +15 -0
  381. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
  382. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
  383. package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +15 -0
  384. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
  385. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  386. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
  387. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
  388. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  389. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
  390. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +34 -0
  391. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  392. package/lib/node/accounts/laserProgramAccountSubscriber.js +34 -0
  393. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
  394. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  395. package/lib/node/accounts/oneShotUserAccountSubscriber.js +19 -0
  396. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
  397. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  398. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
  399. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
  400. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  401. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
  402. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
  403. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  404. package/lib/node/accounts/pollingOracleAccountSubscriber.js +21 -2
  405. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
  406. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  407. package/lib/node/accounts/pollingTokenAccountSubscriber.js +22 -0
  408. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +32 -0
  409. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
  410. package/lib/node/accounts/pollingUserAccountSubscriber.js +32 -0
  411. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
  412. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  413. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +22 -0
  414. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
  415. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  416. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
  417. package/lib/node/accounts/testBulkAccountLoader.d.ts +8 -0
  418. package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
  419. package/lib/node/accounts/testBulkAccountLoader.js +8 -0
  420. package/lib/node/accounts/types.d.ts +149 -0
  421. package/lib/node/accounts/types.d.ts.map +1 -1
  422. package/lib/node/accounts/types.js +13 -0
  423. package/lib/node/accounts/utils.d.ts +18 -0
  424. package/lib/node/accounts/utils.d.ts.map +1 -1
  425. package/lib/node/accounts/utils.js +32 -16
  426. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +41 -0
  427. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  428. package/lib/node/accounts/webSocketAccountSubscriber.js +41 -0
  429. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
  430. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  431. package/lib/node/accounts/webSocketAccountSubscriberV2.js +31 -23
  432. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
  433. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  434. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
  435. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
  436. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  437. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +36 -0
  438. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
  439. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  440. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
  441. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
  442. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  443. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
  444. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
  445. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  446. package/lib/node/accounts/webSocketUserAccountSubscriber.js +26 -0
  447. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
  448. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  449. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
  450. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
  451. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  452. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
  453. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
  454. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  455. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
  456. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
  457. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  458. package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +33 -0
  459. package/lib/node/addresses/marketAddresses.d.ts +10 -0
  460. package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
  461. package/lib/node/addresses/marketAddresses.js +10 -0
  462. package/lib/node/addresses/pda.d.ts +214 -2
  463. package/lib/node/addresses/pda.d.ts.map +1 -1
  464. package/lib/node/addresses/pda.js +217 -5
  465. package/lib/node/adminClient.d.ts +2136 -4
  466. package/lib/node/adminClient.d.ts.map +1 -1
  467. package/lib/node/adminClient.js +2150 -4
  468. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
  469. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  470. package/lib/node/auctionSubscriber/auctionSubscriber.js +15 -0
  471. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
  472. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  473. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
  474. package/lib/node/auctionSubscriber/index.d.ts +6 -0
  475. package/lib/node/auctionSubscriber/index.d.ts.map +1 -1
  476. package/lib/node/auctionSubscriber/index.js +6 -0
  477. package/lib/node/auctionSubscriber/types.d.ts +7 -0
  478. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  479. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
  480. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
  481. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +33 -0
  482. package/lib/node/blockhashSubscriber/index.d.ts +5 -0
  483. package/lib/node/blockhashSubscriber/index.d.ts.map +1 -1
  484. package/lib/node/blockhashSubscriber/index.js +5 -0
  485. package/lib/node/blockhashSubscriber/types.d.ts +5 -0
  486. package/lib/node/blockhashSubscriber/types.d.ts.map +1 -1
  487. package/lib/node/clock/clockSubscriber.d.ts +24 -0
  488. package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
  489. package/lib/node/clock/clockSubscriber.js +22 -0
  490. package/lib/node/config.d.ts +58 -4
  491. package/lib/node/config.d.ts.map +1 -1
  492. package/lib/node/config.js +88 -21
  493. package/lib/node/constants/numericConstants.d.ts +67 -0
  494. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  495. package/lib/node/constants/numericConstants.js +68 -1
  496. package/lib/node/constants/perpMarkets.d.ts +10 -0
  497. package/lib/node/constants/perpMarkets.d.ts.map +1 -1
  498. package/lib/node/constants/perpMarkets.js +40 -908
  499. package/lib/node/constants/spotMarkets.d.ts +13 -0
  500. package/lib/node/constants/spotMarkets.d.ts.map +1 -1
  501. package/lib/node/constants/spotMarkets.js +16 -742
  502. package/lib/node/constants/txConstants.d.ts +1 -0
  503. package/lib/node/constants/txConstants.d.ts.map +1 -1
  504. package/lib/node/constants/txConstants.js +1 -0
  505. package/lib/node/core/VelocityCore.d.ts +285 -8
  506. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  507. package/lib/node/core/VelocityCore.js +281 -8
  508. package/lib/node/core/instructions/deposit.d.ts +22 -0
  509. package/lib/node/core/instructions/deposit.d.ts.map +1 -1
  510. package/lib/node/core/instructions/deposit.js +22 -0
  511. package/lib/node/core/instructions/fill.d.ts +17 -0
  512. package/lib/node/core/instructions/fill.d.ts.map +1 -1
  513. package/lib/node/core/instructions/fill.js +17 -0
  514. package/lib/node/core/instructions/funding.d.ts +12 -0
  515. package/lib/node/core/instructions/funding.d.ts.map +1 -1
  516. package/lib/node/core/instructions/funding.js +12 -0
  517. package/lib/node/core/instructions/liquidation.d.ts +18 -0
  518. package/lib/node/core/instructions/liquidation.d.ts.map +1 -1
  519. package/lib/node/core/instructions/liquidation.js +18 -0
  520. package/lib/node/core/instructions/orders.d.ts +28 -0
  521. package/lib/node/core/instructions/orders.d.ts.map +1 -1
  522. package/lib/node/core/instructions/orders.js +28 -0
  523. package/lib/node/core/instructions/perpOrders.d.ts +106 -0
  524. package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
  525. package/lib/node/core/instructions/perpOrders.js +106 -0
  526. package/lib/node/core/instructions/settlement.d.ts +14 -0
  527. package/lib/node/core/instructions/settlement.d.ts.map +1 -1
  528. package/lib/node/core/instructions/settlement.js +14 -0
  529. package/lib/node/core/instructions/trigger.d.ts +15 -0
  530. package/lib/node/core/instructions/trigger.d.ts.map +1 -1
  531. package/lib/node/core/instructions/trigger.js +15 -0
  532. package/lib/node/core/instructions/withdraw.d.ts +21 -0
  533. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  534. package/lib/node/core/instructions/withdraw.js +21 -0
  535. package/lib/node/core/remainingAccounts.d.ts +47 -3
  536. package/lib/node/core/remainingAccounts.d.ts.map +1 -1
  537. package/lib/node/core/remainingAccounts.js +20 -0
  538. package/lib/node/core/signedMsg.d.ts +38 -0
  539. package/lib/node/core/signedMsg.d.ts.map +1 -1
  540. package/lib/node/core/signedMsg.js +33 -0
  541. package/lib/node/decode/customCoder.d.ts +39 -3
  542. package/lib/node/decode/customCoder.d.ts.map +1 -1
  543. package/lib/node/decode/customCoder.js +45 -3
  544. package/lib/node/decode/user.d.ts +22 -0
  545. package/lib/node/decode/user.d.ts.map +1 -1
  546. package/lib/node/decode/user.js +22 -0
  547. package/lib/node/dlob/DLOB.d.ts +502 -53
  548. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  549. package/lib/node/dlob/DLOB.js +540 -98
  550. package/lib/node/dlob/DLOBNode.d.ts +86 -4
  551. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  552. package/lib/node/dlob/DLOBNode.js +37 -4
  553. package/lib/node/dlob/DLOBSubscriber.d.ts +39 -12
  554. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  555. package/lib/node/dlob/DLOBSubscriber.js +42 -12
  556. package/lib/node/dlob/NodeList.d.ts +69 -0
  557. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  558. package/lib/node/dlob/NodeList.js +66 -0
  559. package/lib/node/dlob/orderBookLevels.d.ts +106 -13
  560. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  561. package/lib/node/dlob/orderBookLevels.js +84 -14
  562. package/lib/node/dlob/types.d.ts +15 -0
  563. package/lib/node/dlob/types.d.ts.map +1 -1
  564. package/lib/node/events/eventList.d.ts +14 -0
  565. package/lib/node/events/eventList.d.ts.map +1 -1
  566. package/lib/node/events/eventList.js +14 -0
  567. package/lib/node/events/eventSubscriber.d.ts +87 -10
  568. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  569. package/lib/node/events/eventSubscriber.js +93 -8
  570. package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
  571. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
  572. package/lib/node/events/eventsServerLogProvider.js +27 -0
  573. package/lib/node/events/fetchLogs.d.ts +31 -0
  574. package/lib/node/events/fetchLogs.d.ts.map +1 -1
  575. package/lib/node/events/fetchLogs.js +46 -1
  576. package/lib/node/events/parse.d.ts +23 -0
  577. package/lib/node/events/parse.d.ts.map +1 -1
  578. package/lib/node/events/parse.js +23 -0
  579. package/lib/node/events/pollingLogProvider.d.ts +24 -0
  580. package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
  581. package/lib/node/events/pollingLogProvider.js +24 -0
  582. package/lib/node/events/sort.d.ts +11 -0
  583. package/lib/node/events/sort.d.ts.map +1 -1
  584. package/lib/node/events/sort.js +12 -0
  585. package/lib/node/events/txEventCache.d.ts +13 -3
  586. package/lib/node/events/txEventCache.d.ts.map +1 -1
  587. package/lib/node/events/txEventCache.js +19 -7
  588. package/lib/node/events/types.d.ts +118 -2
  589. package/lib/node/events/types.d.ts.map +1 -1
  590. package/lib/node/events/types.js +11 -0
  591. package/lib/node/events/webSocketLogProvider.d.ts +23 -0
  592. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
  593. package/lib/node/events/webSocketLogProvider.js +28 -0
  594. package/lib/node/factory/oracleClient.js +2 -2
  595. package/lib/node/idl/velocity.d.ts +4 -4
  596. package/lib/node/idl/velocity.d.ts.map +1 -1
  597. package/lib/node/idl/velocity.json +4 -4
  598. package/lib/node/keypair.d.ts +8 -0
  599. package/lib/node/keypair.d.ts.map +1 -1
  600. package/lib/node/keypair.js +8 -0
  601. package/lib/node/marginCalculation.d.ts +134 -2
  602. package/lib/node/marginCalculation.d.ts.map +1 -1
  603. package/lib/node/marginCalculation.js +121 -0
  604. package/lib/node/math/amm.d.ts +348 -29
  605. package/lib/node/math/amm.d.ts.map +1 -1
  606. package/lib/node/math/amm.js +310 -32
  607. package/lib/node/math/auction.d.ts +95 -19
  608. package/lib/node/math/auction.d.ts.map +1 -1
  609. package/lib/node/math/auction.js +118 -28
  610. package/lib/node/math/bankruptcy.d.ts +46 -0
  611. package/lib/node/math/bankruptcy.d.ts.map +1 -1
  612. package/lib/node/math/bankruptcy.js +89 -1
  613. package/lib/node/math/builder.d.ts +64 -8
  614. package/lib/node/math/builder.d.ts.map +1 -1
  615. package/lib/node/math/builder.js +71 -9
  616. package/lib/node/math/conversion.d.ts +21 -0
  617. package/lib/node/math/conversion.d.ts.map +1 -1
  618. package/lib/node/math/conversion.js +21 -0
  619. package/lib/node/math/exchangeStatus.d.ts +91 -0
  620. package/lib/node/math/exchangeStatus.d.ts.map +1 -1
  621. package/lib/node/math/exchangeStatus.js +106 -3
  622. package/lib/node/math/funding.d.ts +57 -20
  623. package/lib/node/math/funding.d.ts.map +1 -1
  624. package/lib/node/math/funding.js +63 -23
  625. package/lib/node/math/insurance.d.ts +62 -0
  626. package/lib/node/math/insurance.d.ts.map +1 -1
  627. package/lib/node/math/insurance.js +62 -0
  628. package/lib/node/math/liquidation.d.ts +127 -11
  629. package/lib/node/math/liquidation.d.ts.map +1 -1
  630. package/lib/node/math/liquidation.js +182 -19
  631. package/lib/node/math/margin.d.ts +79 -13
  632. package/lib/node/math/margin.d.ts.map +1 -1
  633. package/lib/node/math/margin.js +80 -14
  634. package/lib/node/math/market.d.ts +135 -15
  635. package/lib/node/math/market.d.ts.map +1 -1
  636. package/lib/node/math/market.js +145 -17
  637. package/lib/node/math/oracles.d.ts +113 -0
  638. package/lib/node/math/oracles.d.ts.map +1 -1
  639. package/lib/node/math/oracles.js +118 -1
  640. package/lib/node/math/orders.d.ts +115 -10
  641. package/lib/node/math/orders.d.ts.map +1 -1
  642. package/lib/node/math/orders.js +130 -19
  643. package/lib/node/math/position.d.ts +80 -33
  644. package/lib/node/math/position.d.ts.map +1 -1
  645. package/lib/node/math/position.js +80 -33
  646. package/lib/node/math/repeg.d.ts +48 -10
  647. package/lib/node/math/repeg.d.ts.map +1 -1
  648. package/lib/node/math/repeg.js +48 -10
  649. package/lib/node/math/spotBalance.d.ts +200 -5
  650. package/lib/node/math/spotBalance.d.ts.map +1 -1
  651. package/lib/node/math/spotBalance.js +239 -10
  652. package/lib/node/math/spotMarket.d.ts +36 -3
  653. package/lib/node/math/spotMarket.d.ts.map +1 -1
  654. package/lib/node/math/spotMarket.js +36 -3
  655. package/lib/node/math/spotPosition.d.ts +72 -0
  656. package/lib/node/math/spotPosition.d.ts.map +1 -1
  657. package/lib/node/math/spotPosition.js +62 -0
  658. package/lib/node/math/state.d.ts +31 -0
  659. package/lib/node/math/state.d.ts.map +1 -1
  660. package/lib/node/math/state.js +31 -0
  661. package/lib/node/math/superStake.d.ts +126 -2
  662. package/lib/node/math/superStake.d.ts.map +1 -1
  663. package/lib/node/math/superStake.js +123 -3
  664. package/lib/node/math/tiers.d.ts +29 -0
  665. package/lib/node/math/tiers.d.ts.map +1 -1
  666. package/lib/node/math/tiers.js +29 -0
  667. package/lib/node/math/trade.d.ts +102 -51
  668. package/lib/node/math/trade.d.ts.map +1 -1
  669. package/lib/node/math/trade.js +101 -55
  670. package/lib/node/math/utils.d.ts +71 -9
  671. package/lib/node/math/utils.d.ts.map +1 -1
  672. package/lib/node/math/utils.js +71 -9
  673. package/lib/node/memcmp.d.ts +94 -0
  674. package/lib/node/memcmp.d.ts.map +1 -1
  675. package/lib/node/memcmp.js +103 -2
  676. package/lib/node/oracles/oracleClientCache.d.ts +16 -0
  677. package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
  678. package/lib/node/oracles/oracleClientCache.js +16 -0
  679. package/lib/node/oracles/oracleId.d.ts +31 -0
  680. package/lib/node/oracles/oracleId.d.ts.map +1 -1
  681. package/lib/node/oracles/oracleId.js +39 -8
  682. package/lib/node/oracles/prelaunchOracleClient.d.ts +20 -0
  683. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  684. package/lib/node/oracles/prelaunchOracleClient.js +20 -0
  685. package/lib/node/oracles/pythClient.d.ts +31 -0
  686. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  687. package/lib/node/oracles/pythClient.js +32 -1
  688. package/lib/node/oracles/pythLazerClient.d.ts +34 -0
  689. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  690. package/lib/node/oracles/pythLazerClient.js +35 -1
  691. package/lib/node/oracles/quoteAssetOracleClient.d.ts +18 -0
  692. package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -1
  693. package/lib/node/oracles/quoteAssetOracleClient.js +18 -0
  694. package/lib/node/oracles/strictOraclePrice.d.ts +21 -0
  695. package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
  696. package/lib/node/oracles/strictOraclePrice.js +21 -0
  697. package/lib/node/oracles/types.d.ts +45 -0
  698. package/lib/node/oracles/types.d.ts.map +1 -1
  699. package/lib/node/oracles/utils.d.ts +20 -0
  700. package/lib/node/oracles/utils.d.ts.map +1 -1
  701. package/lib/node/oracles/utils.js +20 -0
  702. package/lib/node/orderParams.d.ts +42 -4
  703. package/lib/node/orderParams.d.ts.map +1 -1
  704. package/lib/node/orderParams.js +42 -4
  705. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +56 -0
  706. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  707. package/lib/node/orderSubscriber/OrderSubscriber.js +56 -0
  708. package/lib/node/orderSubscriber/PollingSubscription.d.ts +11 -0
  709. package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -1
  710. package/lib/node/orderSubscriber/PollingSubscription.js +11 -0
  711. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +18 -0
  712. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -1
  713. package/lib/node/orderSubscriber/WebsocketSubscription.js +18 -0
  714. package/lib/node/orderSubscriber/grpcSubscription.d.ts +16 -0
  715. package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
  716. package/lib/node/orderSubscriber/grpcSubscription.js +16 -0
  717. package/lib/node/orderSubscriber/types.d.ts +9 -0
  718. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  719. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
  720. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -1
  721. package/lib/node/priorityFee/averageOverSlotsStrategy.js +1 -0
  722. package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
  723. package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -1
  724. package/lib/node/priorityFee/averageStrategy.js +1 -0
  725. package/lib/node/priorityFee/ewmaStrategy.d.ts +10 -0
  726. package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -1
  727. package/lib/node/priorityFee/ewmaStrategy.js +10 -0
  728. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
  729. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
  730. package/lib/node/priorityFee/heliusPriorityFeeMethod.js +9 -2
  731. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
  732. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -1
  733. package/lib/node/priorityFee/maxOverSlotsStrategy.js +1 -0
  734. package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
  735. package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -1
  736. package/lib/node/priorityFee/maxStrategy.js +1 -0
  737. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +39 -0
  738. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  739. package/lib/node/priorityFee/priorityFeeSubscriber.js +39 -0
  740. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
  741. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  742. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +21 -2
  743. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
  744. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
  745. package/lib/node/priorityFee/solanaPriorityFeeMethod.js +10 -0
  746. package/lib/node/priorityFee/types.d.ts +32 -0
  747. package/lib/node/priorityFee/types.d.ts.map +1 -1
  748. package/lib/node/priorityFee/types.js +5 -0
  749. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
  750. package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
  751. package/lib/node/priorityFee/velocityPriorityFeeMethod.js +8 -0
  752. package/lib/node/slot/SlotSubscriber.d.ts +18 -0
  753. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
  754. package/lib/node/slot/SlotSubscriber.js +16 -0
  755. package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
  756. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
  757. package/lib/node/slot/SlothashSubscriber.js +25 -1
  758. package/lib/node/tx/baseTxSender.d.ts +163 -0
  759. package/lib/node/tx/baseTxSender.d.ts.map +1 -1
  760. package/lib/node/tx/baseTxSender.js +174 -6
  761. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
  762. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -1
  763. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
  764. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
  765. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -1
  766. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
  767. package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
  768. package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -1
  769. package/lib/node/tx/fastSingleTxSender.d.ts +47 -0
  770. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
  771. package/lib/node/tx/fastSingleTxSender.js +48 -1
  772. package/lib/node/tx/forwardOnlyTxSender.d.ts +48 -0
  773. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -1
  774. package/lib/node/tx/forwardOnlyTxSender.js +48 -0
  775. package/lib/node/tx/reportTransactionError.d.ts +18 -6
  776. package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
  777. package/lib/node/tx/reportTransactionError.js +18 -6
  778. package/lib/node/tx/retryTxSender.d.ts +40 -0
  779. package/lib/node/tx/retryTxSender.d.ts.map +1 -1
  780. package/lib/node/tx/retryTxSender.js +39 -0
  781. package/lib/node/tx/txHandler.d.ts +146 -35
  782. package/lib/node/tx/txHandler.d.ts.map +1 -1
  783. package/lib/node/tx/txHandler.js +132 -32
  784. package/lib/node/tx/txParamProcessor.d.ts +47 -0
  785. package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
  786. package/lib/node/tx/txParamProcessor.js +47 -0
  787. package/lib/node/tx/types.d.ts +46 -0
  788. package/lib/node/tx/types.d.ts.map +1 -1
  789. package/lib/node/tx/types.js +5 -0
  790. package/lib/node/tx/utils.d.ts +26 -0
  791. package/lib/node/tx/utils.d.ts.map +1 -1
  792. package/lib/node/tx/utils.js +26 -0
  793. package/lib/node/tx/whileValidTxSender.d.ts +82 -0
  794. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
  795. package/lib/node/tx/whileValidTxSender.js +81 -0
  796. package/lib/node/types.d.ts +781 -13
  797. package/lib/node/types.d.ts.map +1 -1
  798. package/lib/node/types.js +126 -9
  799. package/lib/node/user.d.ts +645 -84
  800. package/lib/node/user.d.ts.map +1 -1
  801. package/lib/node/user.js +779 -96
  802. package/lib/node/userMap/PollingSubscription.d.ts +10 -0
  803. package/lib/node/userMap/PollingSubscription.d.ts.map +1 -1
  804. package/lib/node/userMap/PollingSubscription.js +14 -2
  805. package/lib/node/userMap/WebsocketSubscription.d.ts +9 -0
  806. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
  807. package/lib/node/userMap/WebsocketSubscription.js +9 -0
  808. package/lib/node/userMap/grpcSubscription.d.ts +8 -0
  809. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
  810. package/lib/node/userMap/grpcSubscription.js +8 -0
  811. package/lib/node/userMap/referrerMap.d.ts +72 -2
  812. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  813. package/lib/node/userMap/referrerMap.js +84 -2
  814. package/lib/node/userMap/revenueShareEscrowMap.d.ts +37 -10
  815. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  816. package/lib/node/userMap/revenueShareEscrowMap.js +38 -11
  817. package/lib/node/userMap/userMap.d.ts +81 -3
  818. package/lib/node/userMap/userMap.d.ts.map +1 -1
  819. package/lib/node/userMap/userMap.js +81 -4
  820. package/lib/node/userMap/userMapConfig.d.ts +23 -0
  821. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  822. package/lib/node/userMap/userStatsMap.d.ts +22 -0
  823. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  824. package/lib/node/userMap/userStatsMap.js +22 -0
  825. package/lib/node/userName.d.ts +16 -0
  826. package/lib/node/userName.d.ts.map +1 -1
  827. package/lib/node/userName.js +16 -0
  828. package/lib/node/userStats.d.ts +28 -1
  829. package/lib/node/userStats.d.ts.map +1 -1
  830. package/lib/node/userStats.js +28 -1
  831. package/lib/node/util/TransactionConfirmationManager.d.ts +33 -0
  832. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
  833. package/lib/node/util/TransactionConfirmationManager.js +33 -0
  834. package/lib/node/util/chainClock.d.ts +24 -0
  835. package/lib/node/util/chainClock.d.ts.map +1 -1
  836. package/lib/node/util/chainClock.js +20 -0
  837. package/lib/node/util/computeUnits.d.ts +32 -0
  838. package/lib/node/util/computeUnits.d.ts.map +1 -1
  839. package/lib/node/util/computeUnits.js +32 -0
  840. package/lib/node/util/digest.d.ts +17 -0
  841. package/lib/node/util/digest.d.ts.map +1 -1
  842. package/lib/node/util/digest.js +17 -0
  843. package/lib/node/util/ed25519Utils.d.ts +12 -2
  844. package/lib/node/util/ed25519Utils.d.ts.map +1 -1
  845. package/lib/node/util/ed25519Utils.js +12 -2
  846. package/lib/node/util/promiseTimeout.d.ts +9 -0
  847. package/lib/node/util/promiseTimeout.d.ts.map +1 -1
  848. package/lib/node/util/promiseTimeout.js +9 -0
  849. package/lib/node/velocityClient.d.ts +3322 -215
  850. package/lib/node/velocityClient.d.ts.map +1 -1
  851. package/lib/node/velocityClient.js +3412 -245
  852. package/lib/node/wallet.d.ts +37 -0
  853. package/lib/node/wallet.d.ts.map +1 -1
  854. package/lib/node/wallet.js +37 -0
  855. package/package.json +2 -1
  856. package/src/accounts/basicUserAccountSubscriber.ts +18 -0
  857. package/src/accounts/basicUserStatsAccountSubscriber.ts +18 -0
  858. package/src/accounts/bulkAccountLoader.ts +52 -0
  859. package/src/accounts/bulkUserStatsSubscription.ts +9 -2
  860. package/src/accounts/bulkUserSubscription.ts +8 -2
  861. package/src/accounts/customizedCadenceBulkAccountLoader.ts +37 -0
  862. package/src/accounts/fetch.ts +59 -2
  863. package/src/accounts/grpcAccountSubscriber.ts +30 -0
  864. package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +16 -0
  865. package/src/accounts/grpcMultiAccountSubscriber.ts +121 -38
  866. package/src/accounts/grpcMultiUserAccountSubscriber.ts +49 -11
  867. package/src/accounts/grpcProgramAccountSubscriber.ts +33 -0
  868. package/src/accounts/grpcUserAccountSubscriber.ts +15 -0
  869. package/src/accounts/grpcUserStatsAccountSubscriber.ts +15 -0
  870. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +41 -0
  871. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +160 -1
  872. package/src/accounts/laserProgramAccountSubscriber.ts +34 -0
  873. package/src/accounts/oneShotUserAccountSubscriber.ts +19 -0
  874. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +19 -0
  875. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +31 -0
  876. package/src/accounts/pollingOracleAccountSubscriber.ts +21 -2
  877. package/src/accounts/pollingTokenAccountSubscriber.ts +22 -0
  878. package/src/accounts/pollingUserAccountSubscriber.ts +32 -0
  879. package/src/accounts/pollingUserStatsAccountSubscriber.ts +22 -0
  880. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +84 -1
  881. package/src/accounts/testBulkAccountLoader.ts +8 -0
  882. package/src/accounts/types.ts +149 -0
  883. package/src/accounts/utils.ts +42 -24
  884. package/src/accounts/webSocketAccountSubscriber.ts +41 -0
  885. package/src/accounts/webSocketAccountSubscriberV2.ts +31 -23
  886. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +27 -0
  887. package/src/accounts/webSocketProgramAccountSubscriber.ts +36 -0
  888. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +26 -0
  889. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +21 -0
  890. package/src/accounts/webSocketUserAccountSubscriber.ts +26 -0
  891. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +20 -0
  892. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +127 -2
  893. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +110 -0
  894. package/src/accounts/websocketProgramUserAccountSubscriber.ts +33 -0
  895. package/src/addresses/marketAddresses.ts +10 -0
  896. package/src/addresses/pda.ts +228 -12
  897. package/src/adminClient.ts +2156 -4
  898. package/src/auctionSubscriber/auctionSubscriber.ts +15 -0
  899. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +19 -0
  900. package/src/auctionSubscriber/index.ts +6 -0
  901. package/src/auctionSubscriber/types.ts +7 -0
  902. package/src/blockhashSubscriber/BlockhashSubscriber.ts +33 -0
  903. package/src/blockhashSubscriber/index.ts +5 -0
  904. package/src/blockhashSubscriber/types.ts +5 -4
  905. package/src/clock/clockSubscriber.ts +24 -0
  906. package/src/config.ts +109 -22
  907. package/src/constants/numericConstants.ts +70 -0
  908. package/src/constants/perpMarkets.ts +45 -960
  909. package/src/constants/spotMarkets.ts +23 -793
  910. package/src/constants/txConstants.ts +1 -0
  911. package/src/core/VelocityCore.ts +286 -8
  912. package/src/core/instructions/deposit.ts +22 -0
  913. package/src/core/instructions/fill.ts +17 -0
  914. package/src/core/instructions/funding.ts +12 -0
  915. package/src/core/instructions/liquidation.ts +18 -0
  916. package/src/core/instructions/orders.ts +28 -0
  917. package/src/core/instructions/perpOrders.ts +106 -0
  918. package/src/core/instructions/settlement.ts +14 -0
  919. package/src/core/instructions/trigger.ts +15 -0
  920. package/src/core/instructions/withdraw.ts +21 -0
  921. package/src/core/remainingAccounts.ts +47 -3
  922. package/src/core/signedMsg.ts +38 -0
  923. package/src/decode/customCoder.ts +46 -3
  924. package/src/decode/user.ts +22 -0
  925. package/src/dlob/DLOB.ts +668 -97
  926. package/src/dlob/DLOBNode.ts +98 -6
  927. package/src/dlob/DLOBSubscriber.ts +49 -12
  928. package/src/dlob/NodeList.ts +69 -0
  929. package/src/dlob/orderBookLevels.ts +108 -14
  930. package/src/dlob/types.ts +15 -0
  931. package/src/events/eventList.ts +14 -0
  932. package/src/events/eventSubscriber.ts +100 -19
  933. package/src/events/eventsServerLogProvider.ts +28 -0
  934. package/src/events/fetchLogs.ts +52 -2
  935. package/src/events/parse.ts +23 -0
  936. package/src/events/pollingLogProvider.ts +24 -0
  937. package/src/events/sort.ts +12 -0
  938. package/src/events/txEventCache.ts +19 -7
  939. package/src/events/types.ts +131 -11
  940. package/src/events/webSocketLogProvider.ts +29 -0
  941. package/src/factory/oracleClient.ts +2 -2
  942. package/src/idl/velocity.json +4 -4
  943. package/src/idl/velocity.ts +4 -4
  944. package/src/keypair.ts +8 -0
  945. package/src/marginCalculation.ts +153 -2
  946. package/src/math/amm.ts +371 -36
  947. package/src/math/auction.ts +139 -30
  948. package/src/math/bankruptcy.ts +104 -1
  949. package/src/math/builder.ts +74 -8
  950. package/src/math/conversion.ts +21 -0
  951. package/src/math/exchangeStatus.ts +117 -2
  952. package/src/math/funding.ts +63 -23
  953. package/src/math/insurance.ts +62 -0
  954. package/src/math/liquidation.ts +227 -17
  955. package/src/math/margin.ts +80 -14
  956. package/src/math/market.ts +148 -17
  957. package/src/math/oracles.ts +124 -0
  958. package/src/math/orders.ts +141 -19
  959. package/src/math/position.ts +80 -33
  960. package/src/math/repeg.ts +48 -10
  961. package/src/math/spotBalance.ts +252 -12
  962. package/src/math/spotMarket.ts +36 -3
  963. package/src/math/spotPosition.ts +72 -0
  964. package/src/math/state.ts +31 -0
  965. package/src/math/superStake.ts +126 -3
  966. package/src/math/tiers.ts +29 -0
  967. package/src/math/trade.ts +125 -55
  968. package/src/math/utils.ts +71 -9
  969. package/src/memcmp.ts +104 -2
  970. package/src/oracles/oracleClientCache.ts +16 -0
  971. package/src/oracles/oracleId.ts +39 -6
  972. package/src/oracles/prelaunchOracleClient.ts +20 -0
  973. package/src/oracles/pythClient.ts +32 -1
  974. package/src/oracles/pythLazerClient.ts +35 -1
  975. package/src/oracles/quoteAssetOracleClient.ts +18 -0
  976. package/src/oracles/strictOraclePrice.ts +21 -0
  977. package/src/oracles/types.ts +45 -0
  978. package/src/oracles/utils.ts +20 -0
  979. package/src/orderParams.ts +42 -4
  980. package/src/orderSubscriber/OrderSubscriber.ts +56 -0
  981. package/src/orderSubscriber/PollingSubscription.ts +11 -0
  982. package/src/orderSubscriber/WebsocketSubscription.ts +18 -0
  983. package/src/orderSubscriber/grpcSubscription.ts +16 -0
  984. package/src/orderSubscriber/types.ts +9 -0
  985. package/src/priorityFee/averageOverSlotsStrategy.ts +1 -0
  986. package/src/priorityFee/averageStrategy.ts +1 -0
  987. package/src/priorityFee/ewmaStrategy.ts +10 -0
  988. package/src/priorityFee/heliusPriorityFeeMethod.ts +13 -2
  989. package/src/priorityFee/maxOverSlotsStrategy.ts +1 -0
  990. package/src/priorityFee/maxStrategy.ts +1 -0
  991. package/src/priorityFee/priorityFeeSubscriber.ts +39 -0
  992. package/src/priorityFee/priorityFeeSubscriberMap.ts +21 -2
  993. package/src/priorityFee/solanaPriorityFeeMethod.ts +12 -0
  994. package/src/priorityFee/types.ts +33 -15
  995. package/src/priorityFee/velocityPriorityFeeMethod.ts +11 -0
  996. package/src/slot/SlotSubscriber.ts +18 -0
  997. package/src/slot/SlothashSubscriber.ts +27 -1
  998. package/src/tx/baseTxSender.ts +185 -5
  999. package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +12 -0
  1000. package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +15 -0
  1001. package/src/tx/blockhashFetcher/types.ts +4 -0
  1002. package/src/tx/fastSingleTxSender.ts +58 -4
  1003. package/src/tx/forwardOnlyTxSender.ts +48 -0
  1004. package/src/tx/reportTransactionError.ts +18 -6
  1005. package/src/tx/retryTxSender.ts +40 -0
  1006. package/src/tx/txHandler.ts +146 -35
  1007. package/src/tx/txParamProcessor.ts +47 -0
  1008. package/src/tx/types.ts +46 -0
  1009. package/src/tx/utils.ts +26 -0
  1010. package/src/tx/whileValidTxSender.ts +82 -0
  1011. package/src/types.ts +777 -24
  1012. package/src/user.ts +869 -110
  1013. package/src/userMap/PollingSubscription.ts +16 -2
  1014. package/src/userMap/WebsocketSubscription.ts +9 -0
  1015. package/src/userMap/grpcSubscription.ts +8 -0
  1016. package/src/userMap/referrerMap.ts +92 -3
  1017. package/src/userMap/revenueShareEscrowMap.ts +38 -11
  1018. package/src/userMap/userMap.ts +82 -4
  1019. package/src/userMap/userMapConfig.ts +23 -10
  1020. package/src/userMap/userStatsMap.ts +22 -0
  1021. package/src/userName.ts +16 -0
  1022. package/src/userStats.ts +28 -1
  1023. package/src/util/TransactionConfirmationManager.ts +33 -0
  1024. package/src/util/chainClock.ts +24 -0
  1025. package/src/util/computeUnits.ts +32 -0
  1026. package/src/util/digest.ts +17 -0
  1027. package/src/util/ed25519Utils.ts +12 -2
  1028. package/src/util/promiseTimeout.ts +9 -0
  1029. package/src/velocityClient.ts +3439 -249
  1030. package/src/wallet.ts +37 -0
  1031. package/tests/VelocityCore/builder_escrow.test.ts +121 -0
  1032. package/tests/amm/test.ts +102 -0
  1033. package/tests/builder/builderFee.test.ts +42 -0
  1034. package/tests/dlob/tickSizeStandardization.ts +545 -0
  1035. package/tests/exchangeStatus/test.ts +45 -0
  1036. package/tests/liquidation/test.ts +125 -0
  1037. package/tests/oracles/mmOracleGate.test.ts +379 -0
  1038. package/tests/oracles/pythPegSnap.test.ts +76 -0
  1039. package/tests/sdkParity/enumParity.test.ts +84 -0
  1040. package/tests/sdkParity/marginCategoryFill.test.ts +143 -0
  1041. package/tests/sdkParity/memcmpOffsets.test.ts +139 -0
  1042. package/tests/spot/test.ts +55 -0
  1043. package/tests/user/bankruptcy.ts +165 -0
  1044. package/tests/user/feeAndWithdrawLimits.ts +284 -0
  1045. package/tests/user/getMarginCalculation.ts +226 -1
  1046. package/tests/user/test.ts +8 -4
@@ -1,10 +1,17 @@
1
1
  /**
2
2
  * AdminClient — governance and protocol administration instruction builders.
3
- * Extends {@link VelocityClient}; all trading/keeper methods are also available.
3
+ * Extends `VelocityClient`; all trading/keeper methods are also available.
4
4
  *
5
5
  * Covers: perp/spot market initialization and updates, oracle guard rail config,
6
6
  * fee structure updates, insurance fund operations, vault management, IF rebalancing,
7
- * pause/unpause exchange, and all ~126 admin instruction handlers in `instructions/admin.rs`.
7
+ * pause/unpause exchange, and all admin instruction handlers in `instructions/admin.rs`.
8
+ *
9
+ * Most methods require a specific admin tier, enforced on-chain by `state.cold_admin` /
10
+ * `state.warm_admin` / per-role `state.hot_*` keys (see `programs/velocity/src/auth.rs`).
11
+ * Tiers are additive — cold ⊇ warm ⊇ hot(role) — so the cold admin can always call a
12
+ * warm- or hot-gated instruction. Each method's doc below states the minimum tier
13
+ * required by the on-chain constraint; passing a lower-tier wallet fails the transaction
14
+ * with `Unauthorized`, not client-side.
8
15
  */
9
16
  import { AddressLookupTableAccount, Keypair, PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
10
17
  import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, SolvencyStatus, MarketStatus, ContractTier, AssetTier, TxParams, AddAmmConstituentMappingDatum, SwapReduceOnly, InitializeConstituentParams, ConstituentStatus, LPPoolAccount, TransferFeeAndPnlPoolDirection, MarketType } from './types';
@@ -13,25 +20,206 @@ import { VelocityClient } from './velocityClient';
13
20
  import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
14
21
  import { SwapMode } from './swap/UnifiedSwapClient';
15
22
  export declare class AdminClient extends VelocityClient {
23
+ /**
24
+ * Creates the protocol's singleton `State` account (one-time setup). Fails client-side
25
+ * if `State` already exists. On a real mainnet build the on-chain `Initialize` accounts
26
+ * struct additionally locks the signer to `ids::state_init_authority` so the one-time
27
+ * init cannot be front-run; on devnet/localnet or the `anchor-test` build any signer may
28
+ * call it. Seeds `cold_admin` and `warm_admin` to the calling wallet and `pause_admin` to
29
+ * the default (unassigned) pubkey — rotate them afterward via `updateAdmin` /
30
+ * `updateWarmAdmin` / `updatePauseAdmin`.
31
+ * @param usdcMint - Mint of the protocol's quote asset (must have 6 decimals; becomes
32
+ * `state.quoteAssetMint`).
33
+ * @param _adminControlsPrices - Unused; retained for call-site compatibility.
34
+ * @returns Tuple containing the transaction signature.
35
+ */
16
36
  initialize(usdcMint: PublicKey, _adminControlsPrices: boolean): Promise<[TransactionSignature]>;
37
+ /**
38
+ * Initializes a new spot market: creates the `SpotMarket` PDA plus its token vault and
39
+ * insurance-fund vault, and appends it at `state.numberOfSpotMarkets` (or `marketIndex`
40
+ * if explicitly supplied — the on-chain handler asserts it matches the next sequential
41
+ * index). Requires warm admin (`check_warm`); if `activeStatus` is `true` the on-chain
42
+ * handler additionally requires the **cold** admin specifically (a market cannot be
43
+ * launched active by a warm-only signer). For `oracleSource: QuoteAsset` (used only for
44
+ * the index-0 quote market), `oracle` must be `PublicKey.default`.
45
+ * @param mint - Spot market's token mint. Must have >= 5 decimals (exactly 6 for the
46
+ * quote/index-0 market).
47
+ * @param optimalUtilization - Utilization at the borrow-rate kink, SPOT_UTILIZATION_PRECISION (1e6, 100% = 1e6).
48
+ * @param optimalRate - Borrow rate at `optimalUtilization`, SPOT_RATE_PRECISION (1e6, 100% APR = 1e6).
49
+ * @param maxRate - Borrow rate at 100% utilization, SPOT_RATE_PRECISION (1e6).
50
+ * @param oracle - Oracle account for this market's price feed (`PublicKey.default` for `OracleSource.QuoteAsset`).
51
+ * @param oracleSource - Oracle provider/format for `oracle`.
52
+ * @param initialAssetWeight - Initial (deposit) asset weight, SPOT_WEIGHT_PRECISION (1e4, 100% = 1e4).
53
+ * @param maintenanceAssetWeight - Maintenance asset weight, SPOT_WEIGHT_PRECISION (1e4).
54
+ * @param initialLiabilityWeight - Initial (borrow) liability weight, SPOT_WEIGHT_PRECISION (1e4).
55
+ * @param maintenanceLiabilityWeight - Maintenance liability weight, SPOT_WEIGHT_PRECISION (1e4).
56
+ * @param imfFactor - Increases weight penalty as position size grows, SPOT_IMF_PRECISION (1e6). Default 0.
57
+ * @param liquidatorFee - Fee paid to liquidators, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
58
+ * @param ifLiquidationFee - Portion of the liquidation fee routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
59
+ * @param activeStatus - If `true`, market is `Active` immediately; otherwise `Initialized` (trading disabled until a later status update). Requires cold admin when `true`. Default `true`.
60
+ * @param assetTier - Collateral tier gating cross-margin usability. Default `AssetTier.COLLATERAL`.
61
+ * @param scaleInitialAssetWeightStart - Deposit-token-amount threshold, QUOTE_PRECISION (1e6) equivalent notional, above which `initialAssetWeight` scales down. Default 0 (disabled).
62
+ * @param withdrawGuardThreshold - Token-amount threshold, market's native decimals, above which large single withdraws/borrows are blocked. Default 0.
63
+ * @param orderTickSize - Minimum price increment for spot orders, PRICE_PRECISION (1e6). Default 1.
64
+ * @param orderStepSize - Minimum base size increment for spot orders, market's native decimals. Also seeds `minOrderSize`. Default 1.
65
+ * @param ifTotalFactor - Insurance fund fee share of the total spot fee, IF_FACTOR_PRECISION (1e6). Default 0.
66
+ * @param name - Market display name, UTF-8 encoded and padded/truncated to 32 bytes. Default `DEFAULT_MARKET_NAME`.
67
+ * @param marketIndex - Explicit spot market index; defaults to `state.numberOfSpotMarkets` (the next free slot) when omitted.
68
+ * @returns Transaction signature.
69
+ */
17
70
  initializeSpotMarket(mint: PublicKey, optimalUtilization: number, optimalRate: number, maxRate: number, oracle: PublicKey, oracleSource: OracleSource, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number, liquidatorFee?: number, ifLiquidationFee?: number, activeStatus?: boolean, assetTier?: {
18
71
  collateral: {};
19
72
  }, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string, marketIndex?: number): Promise<TransactionSignature>;
73
+ /**
74
+ * Builds the `initializeSpotMarket` instruction without sending it. See `initializeSpotMarket`
75
+ * for parameter units and the cold-admin-if-`activeStatus` rule. Looks up `mint`'s owning
76
+ * token program on-chain (throws if the mint account doesn't exist) and resolves the admin
77
+ * signer to `wallet.publicKey` when `useHotWalletAdmin` is set, otherwise to `state.coldAdmin`
78
+ * (or the wallet if not yet subscribed).
79
+ * @returns The unsigned `initializeSpotMarket` instruction.
80
+ */
20
81
  getInitializeSpotMarketIx(mint: PublicKey, optimalUtilization: number, optimalRate: number, maxRate: number, oracle: PublicKey, oracleSource: OracleSource, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number, liquidatorFee?: number, ifLiquidationFee?: number, activeStatus?: boolean, assetTier?: {
21
82
  collateral: {};
22
83
  }, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string, marketIndex?: number): Promise<TransactionInstruction>;
84
+ /**
85
+ * Closes a mis-initialized spot market and refunds rent to the admin. Requires warm admin
86
+ * (`check_warm`). On-chain the handler only allows deleting the **most recently created**
87
+ * market (`marketIndex == state.numberOfSpotMarkets - 1`), still in `Initialized` status
88
+ * (never activated), with zero deposit and borrow balances and empty vaults — otherwise it
89
+ * throws `InvalidMarketAccountforDeletion`.
90
+ * @param marketIndex - Index of the spot market to delete; must be the last-created, unactivated, empty market.
91
+ * @returns Transaction signature.
92
+ */
23
93
  deleteInitializedSpotMarket(marketIndex: number): Promise<TransactionSignature>;
94
+ /**
95
+ * Builds the `deleteInitializedSpotMarket` instruction without sending it. See
96
+ * `deleteInitializedSpotMarket` for the on-chain preconditions.
97
+ * @param marketIndex - Index of the spot market to delete.
98
+ * @returns The unsigned `deleteInitializedSpotMarket` instruction.
99
+ */
24
100
  getDeleteInitializedSpotMarketIx(marketIndex: number): Promise<TransactionInstruction>;
101
+ /**
102
+ * Initializes a new perp market's `PerpMarket` PDA and seeds its AMM. Requires warm admin
103
+ * (`check_warm`); if `activeStatus` is `true` the on-chain handler additionally requires
104
+ * the **cold** admin (a market cannot launch active under a warm-only signer). The handler
105
+ * asserts `marketIndex === state.numberOfMarkets` (must be the next sequential index) and
106
+ * that `baseAssetReserve === quoteAssetReserve` (the initial mark price is exactly
107
+ * `pegMultiplier`). Does not add the market to the AMM cache — call `addMarketToAmmCache`
108
+ * separately (typically before the market can be traded/cranked).
109
+ * @param marketIndex - New market's index; must equal `state.numberOfMarkets`.
110
+ * @param priceOracle - Oracle account backing this market's price feed.
111
+ * @param baseAssetReserve - Initial AMM base reserve, BASE_PRECISION (1e9). Must equal `quoteAssetReserve`.
112
+ * @param quoteAssetReserve - Initial AMM quote reserve, BASE_PRECISION (1e9, AMM-internal units, not quote-asset dollars). Must equal `baseAssetReserve`.
113
+ * @param periodicity - Funding period, seconds (`market.marketStats.fundingPeriod`), as a BN.
114
+ * @param pegMultiplier - AMM peg, PEG_PRECISION (1e6). With equal reserves this fixes the initial mark price to `pegMultiplier`. Default `PEG_PRECISION` (price = 1.0).
115
+ * @param oracleSource - Oracle provider/format for `priceOracle`. Default `OracleSource.PYTH_LAZER`.
116
+ * @param contractTier - Risk/collateral tier for the contract. Default `ContractTier.SPECULATIVE`.
117
+ * @param marginRatioInitial - Initial margin ratio, MARGIN_PRECISION (1e4, e.g. 2000 = 20% = 5x max leverage). Default 2000.
118
+ * @param marginRatioMaintenance - Maintenance margin ratio, MARGIN_PRECISION (1e4). Default 500 (5%).
119
+ * @param liquidatorFee - Fee paid to liquidators, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
120
+ * @param ifLiquidatorFee - Portion of the liquidation fee routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Default 10000 (1%).
121
+ * @param imfFactor - Increases the effective margin requirement as position size grows, PERCENTAGE_PRECISION-scaled (1e6). Default 0.
122
+ * @param activeStatus - If `true`, market is `Active` immediately; otherwise `Initialized`. Requires cold admin when `true`. Default `true`.
123
+ * @param baseSpread - Base bid/ask spread around the AMM reserve price, BID_ASK_SPREAD_PRECISION (1e6). Default 0.
124
+ * @param maxSpread - Maximum allowed total spread, BID_ASK_SPREAD_PRECISION (1e6). Default 142500 (14.25%).
125
+ * @param maxOpenInterest - Cap on base-asset open interest, BASE_PRECISION (1e9). Default 0 (unlimited — treated as no cap by downstream checks).
126
+ * @param maxRevenueWithdrawPerPeriod - Cap on revenue-pool withdrawals per settlement period, QUOTE_PRECISION (1e6). Default 0.
127
+ * @param quoteMaxInsurance - Lifetime cap on insurance draws for this market, QUOTE_PRECISION (1e6). Default 0.
128
+ * @param orderStepSize - Minimum base-size increment for orders, BASE_PRECISION (1e9). Default `BASE_PRECISION / 10000`.
129
+ * @param orderTickSize - Minimum price increment for orders, PRICE_PRECISION (1e6). Default `PRICE_PRECISION / 100000`.
130
+ * @param minOrderSize - Minimum base order size, BASE_PRECISION (1e9). Default `BASE_PRECISION / 10000`.
131
+ * @param concentrationCoefScale - Unitless divisor controlling AMM liquidity concentration around the peg (`concentrationCoef = CONCENTRATION_PRECISION + (MAX_CONCENTRATION_COEFFICIENT - CONCENTRATION_PRECISION) / scale`; must be > 0). Default `ONE` (widest allowed concentration). Larger scale narrows the depth band.
132
+ * @param curveUpdateIntensity - 0-100 knob controlling how aggressively the AMM curve/peg re-centers on repegs. Default 0 (disabled).
133
+ * @param ammJitIntensity - 0-100 knob controlling how aggressively the AMM just-in-time-fills maker orders. Default 0 (disabled).
134
+ * @param name - Market display name, UTF-8 encoded and padded/truncated to 32 bytes. Default `DEFAULT_MARKET_NAME`.
135
+ * @param lpPoolId - LP pool this market's hedge exposure is routed to; 0 means unassigned. Default 0.
136
+ * @param fundingClampThreshold - Dead-zone half-width before funding ramps up, basis points (BPS_PRECISION, 1e4). 0 falls back on-chain to 5 bps. Default 0.
137
+ * @param fundingRampSlope - Slope applied to the price spread beyond the dead zone, PERCENTAGE_PRECISION (1e6, 1e6 = 1.0x). 0 falls back on-chain to 1e6 (1.0x). Default 0.
138
+ * @returns Transaction signature.
139
+ */
25
140
  initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, fundingClampThreshold?: number, fundingRampSlope?: number): Promise<TransactionSignature>;
141
+ /**
142
+ * Builds the `initializePerpMarket` instruction without sending it. See `initializePerpMarket`
143
+ * for parameter units and the cold-admin-if-`activeStatus` rule.
144
+ * @returns Single-element array containing the unsigned `initializePerpMarket` instruction.
145
+ */
26
146
  getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number, fundingClampThreshold?: number, fundingRampSlope?: number): Promise<TransactionInstruction[]>;
147
+ /**
148
+ * Creates the protocol-wide singleton `AmmCache` PDA (one-time setup, empty until
149
+ * `addMarketToAmmCache` is called per market). Requires warm admin (`check_warm`).
150
+ * @returns Transaction signature.
151
+ */
27
152
  initializeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
153
+ /**
154
+ * Builds the `initializeAmmCache` instruction without sending it. See `initializeAmmCache`.
155
+ * @returns The unsigned `initializeAmmCache` instruction.
156
+ */
28
157
  getInitializeAmmCacheIx(): Promise<TransactionInstruction>;
158
+ /**
159
+ * Appends a perp market's entry to the `AmmCache` (reallocating it larger by one slot).
160
+ * Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if the market index
161
+ * is already present in the cache. A market must be added here before keeper cranks that
162
+ * rely on the AMM cache (e.g. LP-pool settlement) can process it.
163
+ * @param perpMarketIndex - Index of the perp market to add.
164
+ * @returns Transaction signature.
165
+ */
29
166
  addMarketToAmmCache(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
167
+ /**
168
+ * Builds the `addMarketToAmmCache` instruction without sending it. See `addMarketToAmmCache`.
169
+ * @param perpMarketIndex - Index of the perp market to add. Throws if the market is not
170
+ * already tracked by the local account subscriber.
171
+ * @returns The unsigned `addMarketToAmmCache` instruction.
172
+ */
30
173
  getAddMarketToAmmCacheIx(perpMarketIndex: number): Promise<TransactionInstruction>;
174
+ /**
175
+ * Closes the `AmmCache` PDA, refunding rent to the admin. Requires warm admin
176
+ * (`check_warm`). Removes tracking for every market at once — there is no per-market
177
+ * inverse of `addMarketToAmmCache`.
178
+ * @returns Transaction signature.
179
+ */
31
180
  deleteAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
181
+ /**
182
+ * Builds the `deleteAmmCache` instruction without sending it. See `deleteAmmCache`.
183
+ * @returns The unsigned `deleteAmmCache` instruction.
184
+ */
32
185
  getDeleteAmmCacheIx(): Promise<TransactionInstruction>;
186
+ /**
187
+ * Refreshes the `AmmCache` entries for the given perp markets from their current on-chain
188
+ * state and oracle price (market stats, MM-oracle price/validity). Requires the `LpCache`
189
+ * hot key (or warm/cold). `perpMarketIndexes` are passed as readable perp markets in
190
+ * `remainingAccounts` (each market's oracle account must be resolvable via the local
191
+ * account subscriber); the quote spot market (index 0) is always included as readable.
192
+ * @param perpMarketIndexes - Perp market indexes to refresh in the cache.
193
+ * @returns Transaction signature.
194
+ */
33
195
  updateInitialAmmCacheInfo(perpMarketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
196
+ /**
197
+ * Builds the `updateInitialAmmCacheInfo` instruction without sending it. See
198
+ * `updateInitialAmmCacheInfo`.
199
+ * @param perpMarketIndexes - Perp market indexes to refresh in the cache.
200
+ * @returns The unsigned `updateInitialAmmCacheInfo` instruction.
201
+ */
34
202
  getUpdateInitialAmmCacheInfoIx(perpMarketIndexes: number[]): Promise<TransactionInstruction>;
203
+ /**
204
+ * Force-overwrites one market's `AmmCache` entry fields (admin escape hatch, e.g. to
205
+ * recover from a bad cache after an incident). Requires the `LpCache` hot key (or
206
+ * warm/cold). Only fields present in `params` are changed; omitted fields keep their
207
+ * current cached value. No-op (does not throw) if `perpMarketIndex` has no cache entry yet.
208
+ *
209
+ * Caution: despite its name, `params.lastSettleTs` is **not** forwarded to the
210
+ * instruction — `getOverrideAmmCacheInfoIx` expects `lastSettleSlot` and this wrapper
211
+ * passes `params` straight through, so any `lastSettleTs` value is silently dropped and
212
+ * the cache's `lastSettleSlot` is left unchanged. Call `getOverrideAmmCacheInfoIx` directly
213
+ * with `lastSettleSlot` if that field needs to be overridden.
214
+ * @param perpMarketIndex - Perp market whose cache entry to override.
215
+ * @param params.quoteOwedFromLpPool - Quote owed from the LP pool to this market's hedge, QUOTE_PRECISION (1e6), signed.
216
+ * @param params.lastSettleTs - Not applied by this method; see caution above.
217
+ * @param params.lastFeePoolTokenAmount - Cached fee-pool token balance, quote spot market's native decimals.
218
+ * @param params.lastNetPnlPoolTokenAmount - Cached net PnL-pool token balance, quote spot market's native decimals, signed.
219
+ * @param params.ammPositionScalar - Unitless 0-100 scalar applied to the AMM's hedge position sizing.
220
+ * @param params.ammInventoryLimit - Inventory limit for the AMM's hedge position, BASE_PRECISION (1e9), signed.
221
+ * @returns Transaction signature.
222
+ */
35
223
  overrideAmmCacheInfo(perpMarketIndex: number, params: {
36
224
  quoteOwedFromLpPool?: BN;
37
225
  lastSettleTs?: BN;
@@ -40,6 +228,12 @@ export declare class AdminClient extends VelocityClient {
40
228
  ammPositionScalar?: number;
41
229
  ammInventoryLimit?: BN;
42
230
  }, txParams?: TxParams): Promise<TransactionSignature>;
231
+ /**
232
+ * Builds the `overrideAmmCacheInfo` instruction without sending it. Unlike `overrideAmmCacheInfo`,
233
+ * this overload's `params` correctly uses `lastSettleSlot` (not `lastSettleTs`) and does
234
+ * forward it. See `overrideAmmCacheInfo` for field units.
235
+ * @returns The unsigned `overrideAmmCacheInfo` instruction.
236
+ */
43
237
  getOverrideAmmCacheInfoIx(perpMarketIndex: number, params: {
44
238
  quoteOwedFromLpPool?: BN;
45
239
  lastSettleSlot?: BN;
@@ -48,218 +242,1820 @@ export declare class AdminClient extends VelocityClient {
48
242
  ammPositionScalar?: number;
49
243
  ammInventoryLimit?: BN;
50
244
  }): Promise<TransactionInstruction>;
245
+ /**
246
+ * Intended to reallocate the `AmmCache` to `state.numberOfMarkets` entries and reset it
247
+ * (`ResetAmmCache` accounts struct is gated on the `LpCache` hot key, or warm/cold, per
248
+ * `programs/velocity/src/instructions/admin.rs`). **Currently non-functional**: no
249
+ * `reset_amm_cache` handler is wired into the program's instruction dispatch, so this
250
+ * instruction does not exist in the IDL — `getResetAmmCacheIx` casts to `any` to bypass
251
+ * the missing type, but calling it throws at runtime (`program.instruction.resetAmmCache`
252
+ * is `undefined`). Use `deleteAmmCache` + `initializeAmmCache` + `addMarketToAmmCache` per
253
+ * market to achieve the same effect until this is wired up on-chain.
254
+ * @returns Transaction signature (in practice: throws before a transaction is built).
255
+ */
51
256
  resetAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
257
+ /**
258
+ * Builds the (currently non-existent) `resetAmmCache` instruction. See `resetAmmCache` —
259
+ * this throws because the program does not expose a `resetAmmCache` instruction.
260
+ * @returns Never resolves successfully; throws when the missing instruction is invoked.
261
+ */
52
262
  getResetAmmCacheIx(): Promise<TransactionInstruction>;
263
+ /**
264
+ * Closes a mis-initialized perp market and refunds rent to the admin. Requires warm admin
265
+ * (`check_warm`). On-chain the handler only allows deleting the **most recently created**
266
+ * market (`marketIndex == state.numberOfMarkets - 1`), still in `Initialized` status
267
+ * (never activated), with zero users — otherwise it throws `InvalidMarketAccountforDeletion`.
268
+ * @param marketIndex - Index of the perp market to delete; must be the last-created, unactivated, userless market.
269
+ * @returns Transaction signature.
270
+ */
53
271
  deleteInitializedPerpMarket(marketIndex: number): Promise<TransactionSignature>;
272
+ /**
273
+ * Builds the `deleteInitializedPerpMarket` instruction without sending it. See
274
+ * `deleteInitializedPerpMarket` for the on-chain preconditions.
275
+ * @param marketIndex - Index of the perp market to delete.
276
+ * @returns The unsigned `deleteInitializedPerpMarket` instruction.
277
+ */
54
278
  getDeleteInitializedPerpMarketIx(marketIndex: number): Promise<TransactionInstruction>;
279
+ /**
280
+ * Directly overwrites the AMM's base/quote reserves and `sqrtK` for a perp market — an
281
+ * admin escape hatch to force the AMM mark price (`quoteAssetReserve / baseAssetReserve *
282
+ * pegMultiplier`) without going through a repeg. Requires warm admin (`check_warm`).
283
+ * Re-derives min/max base reserve bounds from the new `sqrtK` and re-validates the market
284
+ * (`validate_perp_market`) before committing, so an inconsistent reserve/peg combination
285
+ * fails the transaction.
286
+ * @param perpMarketIndex - Perp market to move.
287
+ * @param baseAssetReserve - New AMM base reserve, BASE_PRECISION (1e9).
288
+ * @param quoteAssetReserve - New AMM quote reserve, BASE_PRECISION (1e9, AMM-internal units).
289
+ * @param sqrtK - New invariant `sqrt(baseAssetReserve * quoteAssetReserve)`, BASE_PRECISION (1e9). Defaults to the exact square root of `baseAssetReserve * quoteAssetReserve` when omitted.
290
+ * @returns Transaction signature.
291
+ */
55
292
  moveAmmPrice(perpMarketIndex: number, baseAssetReserve: BN, quoteAssetReserve: BN, sqrtK?: BN): Promise<TransactionSignature>;
293
+ /**
294
+ * Builds the `moveAmmPrice` instruction without sending it. See `moveAmmPrice` for units
295
+ * and the `sqrtK` default.
296
+ * @returns The unsigned `moveAmmPrice` instruction.
297
+ */
56
298
  getMoveAmmPriceIx(perpMarketIndex: number, baseAssetReserve: BN, quoteAssetReserve: BN, sqrtK?: BN): Promise<TransactionInstruction>;
299
+ /**
300
+ * Rescales a perp market's AMM invariant (`sqrtK`) while holding the mark price
301
+ * approximately constant, widening or tightening depth around the current peg. Requires
302
+ * warm admin (`check_warm`). On-chain, increasing `sqrtK` must cost the AMM's fee reserve
303
+ * a non-negative amount (charged against `totalFeeMinusDistributions`, capped at that
304
+ * balance) and decreasing it must yield a non-positive cost; the resulting price move must
305
+ * stay within `MAX_UPDATE_K_PRICE_CHANGE` and `sqrtK` may not increase past `MAX_SQRT_K` —
306
+ * violating any of these throws `InvalidUpdateK`.
307
+ * @param perpMarketIndex - Perp market to rescale.
308
+ * @param sqrtK - New invariant, BASE_PRECISION (1e9).
309
+ * @returns Transaction signature.
310
+ */
57
311
  updateK(perpMarketIndex: number, sqrtK: BN): Promise<TransactionSignature>;
312
+ /**
313
+ * Builds the `updateK` instruction without sending it. See `updateK` for units and the
314
+ * on-chain cost/price-change constraints.
315
+ * @returns The unsigned `updateK` instruction.
316
+ */
58
317
  getUpdateKIx(perpMarketIndex: number, sqrtK: BN): Promise<TransactionInstruction>;
318
+ /**
319
+ * Re-centers a perp market's AMM around a new peg and invariant while keeping the AMM's
320
+ * net position unchanged (`amm.recenter`) — the admin-driven counterpart of an automatic
321
+ * repeg, typically used to realign the AMM to the oracle after a large price move.
322
+ * Requires warm admin (`check_warm`). Re-derives min/max base reserve bounds and
323
+ * re-validates the market before committing.
324
+ * @param perpMarketIndex - Perp market to recenter.
325
+ * @param pegMultiplier - New AMM peg, PEG_PRECISION (1e6).
326
+ * @param sqrtK - New invariant, BASE_PRECISION (1e9).
327
+ * @returns Transaction signature.
328
+ */
59
329
  recenterPerpMarketAmm(perpMarketIndex: number, pegMultiplier: BN, sqrtK: BN): Promise<TransactionSignature>;
330
+ /**
331
+ * Builds the `recenterPerpMarketAmm` instruction without sending it. See
332
+ * `recenterPerpMarketAmm` for units.
333
+ * @returns The unsigned `recenterPerpMarketAmm` instruction.
334
+ */
60
335
  getRecenterPerpMarketAmmIx(perpMarketIndex: number, pegMultiplier: BN, sqrtK: BN): Promise<TransactionInstruction>;
336
+ /**
337
+ * Keeper-cranked variant of `recenterPerpMarketAmm`: derives the target peg/invariant from
338
+ * the current oracle price (and an optional target depth) instead of taking them as
339
+ * explicit params. Requires the `AmmCrank` hot key (or warm/cold).
340
+ * @param perpMarketIndex - Perp market to recenter.
341
+ * @param depth - Optional target liquidity depth to recenter around, BASE_PRECISION (1e9). Omit to use the market's existing depth.
342
+ * @returns Transaction signature.
343
+ */
61
344
  recenterPerpMarketAmmCrank(perpMarketIndex: number, depth?: BN): Promise<TransactionSignature>;
345
+ /**
346
+ * Builds the `recenterPerpMarketAmmCrank` instruction without sending it. See
347
+ * `recenterPerpMarketAmmCrank`.
348
+ * @returns The unsigned `recenterPerpMarketAmmCrank` instruction.
349
+ */
62
350
  getRecenterPerpMarketAmmCrankIx(perpMarketIndex: number, depth?: BN): Promise<TransactionInstruction>;
351
+ /**
352
+ * Updates a perp market's AMM concentration coefficient, changing how tightly liquidity
353
+ * is concentrated around the peg (calls the on-chain `updatePerpMarketConcentrationCoef`
354
+ * instruction). Requires warm admin (`check_warm`).
355
+ * @param perpMarketIndex - Perp market to update.
356
+ * @param concentrationScale - Unitless divisor, must be > 0 (`concentrationCoef = CONCENTRATION_PRECISION + (MAX_CONCENTRATION_COEFFICIENT - CONCENTRATION_PRECISION) / concentrationScale`). Larger scale narrows the depth band; `1` yields the widest allowed concentration.
357
+ * @returns Transaction signature.
358
+ */
63
359
  updatePerpMarketConcentrationScale(perpMarketIndex: number, concentrationScale: BN): Promise<TransactionSignature>;
360
+ /**
361
+ * Builds the `updatePerpMarketConcentrationCoef` instruction without sending it. See
362
+ * `updatePerpMarketConcentrationScale`.
363
+ * @returns The unsigned `updatePerpMarketConcentrationCoef` instruction.
364
+ */
64
365
  getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex: number, concentrationScale: BN): Promise<TransactionInstruction>;
366
+ /**
367
+ * Sets which LP pool a perp market's hedge exposure (`hedgeConfig.poolId`) is routed to.
368
+ * Requires warm admin (`check_warm`).
369
+ * @param perpMarketIndex - Perp market to update.
370
+ * @param lpPoolId - Target LP pool id; 0 means unassigned.
371
+ * @returns Transaction signature.
372
+ */
65
373
  updatePerpMarketLpPoolId(perpMarketIndex: number, lpPoolId: number): Promise<string>;
374
+ /**
375
+ * Builds the `updatePerpMarketLpPoolId` instruction without sending it. See
376
+ * `updatePerpMarketLpPoolId`.
377
+ * @returns The unsigned `updatePerpMarketLpPoolId` instruction.
378
+ */
66
379
  getUpdatePerpMarketLpPoolIdIx(perpMarketIndex: number, lpPoolId: number): Promise<TransactionInstruction>;
380
+ /**
381
+ * Sets a perp market's LP-pool hedge status (`hedgeConfig.status`) and immediately
382
+ * refreshes its `AmmCache` entry from the new market state. Requires warm admin
383
+ * (`check_warm`).
384
+ * @param perpMarketIndex - Perp market to update.
385
+ * @param lpStatus - New hedge status bitmask/value for `hedgeConfig.status`.
386
+ * @returns Transaction signature.
387
+ */
67
388
  updatePerpMarketLpPoolStatus(perpMarketIndex: number, lpStatus: number): Promise<string>;
389
+ /**
390
+ * Builds the `updatePerpMarketLpPoolStatus` instruction without sending it. See
391
+ * `updatePerpMarketLpPoolStatus`.
392
+ * @returns The unsigned `updatePerpMarketLpPoolStatus` instruction.
393
+ */
68
394
  getUpdatePerpMarketLpPoolStatusIx(perpMarketIndex: number, lpStatus: number): Promise<TransactionInstruction>;
395
+ /**
396
+ * Convenience wrapper around `moveAmmPrice`: computes, from the locally cached
397
+ * `PerpMarket` account, the base/quote reserves that move the AMM's mark price to
398
+ * `targetPrice` (holding `sqrtK` fixed at its current value) and sends that instruction.
399
+ * Requires warm admin (`check_warm`, same as `moveAmmPrice`). Throws if the market isn't
400
+ * tracked by the local account subscriber.
401
+ * @param perpMarketIndex - Perp market to move.
402
+ * @param targetPrice - Desired AMM mark price, PRICE_PRECISION (1e6).
403
+ * @returns Transaction signature.
404
+ */
69
405
  moveAmmToPrice(perpMarketIndex: number, targetPrice: BN): Promise<TransactionSignature>;
406
+ /**
407
+ * Builds the underlying `moveAmmPrice` instruction that moves the AMM to `targetPrice`.
408
+ * See `moveAmmToPrice`.
409
+ * @returns The unsigned `moveAmmPrice` instruction.
410
+ */
70
411
  getMoveAmmToPriceIx(perpMarketIndex: number, targetPrice: BN): Promise<TransactionInstruction>;
412
+ /**
413
+ * Repegs a perp market's AMM toward `newPeg`, adjusting reserves to keep the invariant
414
+ * (`sqrtK`) fixed while moving the mark price. Requires warm admin (`check_warm`). The
415
+ * on-chain `repeg` routine validates the oracle (per `state.oracleGuardRails`) and charges
416
+ * the reserve/fee-pool the resulting `adjustment_cost`; emits `AmmCurveChanged`.
417
+ * @param newPeg - Candidate new AMM peg, PEG_PRECISION (1e6).
418
+ * @param perpMarketIndex - Perp market to repeg.
419
+ * @returns Transaction signature.
420
+ */
71
421
  repegAmmCurve(newPeg: BN, perpMarketIndex: number): Promise<TransactionSignature>;
422
+ /**
423
+ * Builds the `repegAmmCurve` instruction without sending it. See `repegAmmCurve`. Throws
424
+ * if `perpMarketIndex` isn't tracked by the local account subscriber (needed to resolve
425
+ * the market's oracle account).
426
+ * @returns The unsigned `repegAmmCurve` instruction.
427
+ */
72
428
  getRepegAmmCurveIx(newPeg: BN, perpMarketIndex: number): Promise<TransactionInstruction>;
429
+ /**
430
+ * Nudges a perp market's cached oracle TWAP (`marketStats.historicalOracleData.lastOraclePriceTwap`,
431
+ * PRICE_PRECISION 1e6) toward the freshly-sampled oracle TWAP, but only accepts the move
432
+ * if it narrows the mark/oracle TWAP gap or flips its sign (otherwise clamps the cached
433
+ * TWAP to the mark TWAP). Requires warm admin (`check_warm`); throws `PriceBandsBreached`
434
+ * on-chain if the new gap would be strictly larger with the same sign, and `InvalidOracle`
435
+ * if the oracle can't be read.
436
+ * @param perpMarketIndex - Perp market to update.
437
+ * @returns Transaction signature.
438
+ */
73
439
  updatePerpMarketAmmOracleTwap(perpMarketIndex: number): Promise<TransactionSignature>;
440
+ /**
441
+ * Builds the `updatePerpMarketAmmOracleTwap` instruction without sending it. See
442
+ * `updatePerpMarketAmmOracleTwap`.
443
+ * @returns The unsigned `updatePerpMarketAmmOracleTwap` instruction.
444
+ */
74
445
  getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex: number): Promise<TransactionInstruction>;
446
+ /**
447
+ * Admin failsafe that force-resets a perp market's cached oracle TWAP to the current mark
448
+ * TWAP (unconditionally, unlike `updatePerpMarketAmmOracleTwap`'s gap-narrowing check).
449
+ * Requires warm admin (`check_warm`). Use when the oracle TWAP has drifted badly (e.g.
450
+ * after an oracle outage) and funding needs to be re-anchored immediately.
451
+ * @param perpMarketIndex - Perp market to reset.
452
+ * @returns Transaction signature.
453
+ */
75
454
  resetPerpMarketAmmOracleTwap(perpMarketIndex: number): Promise<TransactionSignature>;
455
+ /**
456
+ * Builds the `resetPerpMarketAmmOracleTwap` instruction without sending it. See
457
+ * `resetPerpMarketAmmOracleTwap`.
458
+ * @returns The unsigned `resetPerpMarketAmmOracleTwap` instruction.
459
+ */
76
460
  getResetPerpMarketAmmOracleTwapIx(perpMarketIndex: number): Promise<TransactionInstruction>;
461
+ /**
462
+ * Tops up a perp market's AMM fee pool: transfers `amount` from `sourceVault` (a token
463
+ * account the caller controls) into the quote spot market's vault via CPI, and credits
464
+ * the same amount to `perpMarket.amm.totalFeeMinusDistributions` / `amm.feePool`. Requires
465
+ * the `VaultDeposit` hot key (or warm/cold).
466
+ * @param perpMarketIndex - Perp market whose fee pool to credit.
467
+ * @param amount - Amount to deposit, quote spot market's native decimals (QUOTE_PRECISION, 1e6, for the standard USDC quote market).
468
+ * @param sourceVault - Token account to transfer `amount` from; `admin` must be its authority.
469
+ * @returns Transaction signature.
470
+ */
77
471
  depositIntoPerpMarketFeePool(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
472
+ /**
473
+ * Builds the `depositIntoPerpMarketFeePool` instruction without sending it. See
474
+ * `depositIntoPerpMarketFeePool`.
475
+ * @returns The unsigned `depositIntoPerpMarketFeePool` instruction.
476
+ */
78
477
  getDepositIntoPerpMarketFeePoolIx(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionInstruction>;
478
+ /**
479
+ * Credits `amount` to a perp market's PnL pool balance as pure internal accounting — it
480
+ * does **not** move any tokens. On-chain the handler only validates that the quote spot
481
+ * market's actual vault balance still covers the resulting internal balances
482
+ * (`validate_spot_market_vault_amount`); it does not itself deposit the backing tokens, so
483
+ * call this only after (or together with) a real deposit that gets the tokens into the
484
+ * vault. Requires warm admin (`check_warm`).
485
+ * @param perpMarketIndex - Perp market whose PnL pool to credit.
486
+ * @param amount - Amount to credit, quote spot market's native decimals (QUOTE_PRECISION, 1e6, for the standard USDC quote market).
487
+ * @returns Transaction signature.
488
+ */
79
489
  updatePerpMarketPnlPool(perpMarketIndex: number, amount: BN): Promise<TransactionSignature>;
490
+ /**
491
+ * Builds the `updatePerpMarketPnlPool` instruction without sending it. See
492
+ * `updatePerpMarketPnlPool` — no tokens are moved by this instruction.
493
+ * @returns The unsigned `updatePerpMarketPnlPool` instruction.
494
+ */
80
495
  getUpdatePerpMarketPnlPoolIx(perpMarketIndex: number, amount: BN): Promise<TransactionInstruction>;
496
+ /**
497
+ * Deposits `amount` from `sourceVault` (a token account the caller controls) directly into
498
+ * a spot market's vault via CPI and credits the market's deposit balance accordingly.
499
+ * Requires the `VaultDeposit` hot key (or warm/cold). Throws on-chain if the spot market
500
+ * has deposits paused (`SpotOperation::Deposit`).
501
+ * @param spotMarketIndex - Spot market whose vault to deposit into.
502
+ * @param amount - Amount to deposit, the spot market's native token decimals.
503
+ * @param sourceVault - Token account to transfer `amount` from; `admin` must be its authority.
504
+ * @returns Transaction signature.
505
+ */
81
506
  depositIntoSpotMarketVault(spotMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
507
+ /**
508
+ * Builds the `depositIntoSpotMarketVault` instruction without sending it. See
509
+ * `depositIntoSpotMarketVault`. Automatically appends transfer-hook extra account metas
510
+ * when the mint requires them.
511
+ * @returns The unsigned `depositIntoSpotMarketVault` instruction.
512
+ */
82
513
  getDepositIntoSpotMarketVaultIx(spotMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionInstruction>;
514
+ /**
515
+ * Rotates the root (`state.coldAdmin`) authority — the top of the cold ⊇ warm ⊇
516
+ * hot(role) tier hierarchy. Cold-only: the `ColdAdminUpdateState` context requires
517
+ * the current signer to equal `state.coldAdmin`. This is the one-time-per-rotation
518
+ * root key change; `warmAdmin` and `pauseAdmin` are rotated separately via
519
+ * `updateWarmAdmin`/`updatePauseAdmin` (also cold-only).
520
+ * @param admin - New cold admin pubkey.
521
+ * @returns Transaction signature.
522
+ */
83
523
  updateAdmin(admin: PublicKey): Promise<TransactionSignature>;
524
+ /**
525
+ * Builds the `updateAdmin` instruction without sending it. See `updateAdmin`.
526
+ * @returns The unsigned `updateAdmin` instruction.
527
+ */
84
528
  getUpdateAdminIx(admin: PublicKey): Promise<TransactionInstruction>;
529
+ /**
530
+ * Sets how aggressively a perp market's AMM curve auto-adjusts. Requires the market's
531
+ * `HotAdminUpdatePerpMarket` gate — the `check_warm` constraint on that context currently
532
+ * accepts cold or warm admin only (no dedicated hot role is wired to it). On-chain, values
533
+ * `0..=100` control repeg/formulaic-k intensity and `101..=200` additionally enable
534
+ * reference-price-offset intensity; values above 200 throw `DefaultError`.
535
+ * @param perpMarketIndex - Perp market to update.
536
+ * @param curveUpdateIntensity - 0-200 intensity knob (see above for the two sub-ranges).
537
+ * @returns Transaction signature.
538
+ */
85
539
  updatePerpMarketCurveUpdateIntensity(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionSignature>;
540
+ /**
541
+ * Builds the `updatePerpMarketCurveUpdateIntensity` instruction without sending it. See
542
+ * `updatePerpMarketCurveUpdateIntensity`.
543
+ * @returns The unsigned `updatePerpMarketCurveUpdateIntensity` instruction.
544
+ */
86
545
  getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionInstruction>;
546
+ /**
547
+ * Sets the dead-band, as a percent of price, within which the AMM's reference-price offset
548
+ * (used to bias the AMM's quoted price away from the raw oracle/mark price) is suppressed.
549
+ * Gated the same as `updatePerpMarketCurveUpdateIntensity` (warm admin via
550
+ * `HotAdminUpdatePerpMarket`'s `check_warm` constraint). Throws `DefaultError` on-chain if
551
+ * `referencePriceOffsetDeadbandPct > 100`.
552
+ * @param perpMarketIndex - Perp market to update.
553
+ * @param referencePriceOffsetDeadbandPct - 0-100 percent dead-band.
554
+ * @returns Transaction signature.
555
+ */
87
556
  updatePerpMarketReferencePriceOffsetDeadbandPct(perpMarketIndex: number, referencePriceOffsetDeadbandPct: number): Promise<TransactionSignature>;
557
+ /**
558
+ * Builds the `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction without sending
559
+ * it. See `updatePerpMarketReferencePriceOffsetDeadbandPct`.
560
+ * @returns The unsigned `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction.
561
+ */
88
562
  getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(perpMarketIndex: number, referencePriceOffsetDeadbandPct: number): Promise<TransactionInstruction>;
563
+ /**
564
+ * **Currently non-functional**: the program does not expose an
565
+ * `update_perp_market_target_base_asset_amount_per_lp` instruction (no such handler is
566
+ * wired into `lib.rs`, and it's absent from the generated IDL). `getUpdatePerpMarketTargetBaseAssetAmountPerLpIx`
567
+ * casts `this.program.instruction` to `any` to bypass the missing type, but the call
568
+ * throws at runtime. `targetBaseAssetAmountPerLp` exists only as a legacy field in
569
+ * `test_utils/legacy_snapshot.rs`, not on the live `PerpMarket`/`AMM` struct.
570
+ * @param perpMarketIndex - Perp market that would be updated.
571
+ * @param targetBaseAssetAmountPerLP - Intended target base-asset-amount-per-LP value.
572
+ * @returns Transaction signature (in practice: throws before a transaction is built).
573
+ */
89
574
  updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionSignature>;
575
+ /**
576
+ * Admin recalibration of a perp market's AMM fee-accounting summary stats. Requires the
577
+ * `AmmCrank` hot key (or warm/cold). If `netUnsettledFundingPnl` is provided it directly
578
+ * overwrites `perpMarket.netUnsettledFundingPnl`. If `updateAmmSummaryStats` is `true`,
579
+ * recomputes `amm.totalFeeMinusDistributions` from current market/spot-market/oracle state
580
+ * and applies the resulting delta to `amm.totalFee` and `amm.totalMmFee`; omitted or
581
+ * `false` leaves fee accounting untouched. Re-validates the market before committing.
582
+ * @param perpMarketIndex - Perp market to recalibrate.
583
+ * @param updateAmmSummaryStats - If `true`, recompute and correct AMM fee-accounting totals. Default: unset (no correction).
584
+ * @param netUnsettledFundingPnl - Overwrite for `perpMarket.netUnsettledFundingPnl`, QUOTE_PRECISION (1e6), signed. Default: unset (unchanged).
585
+ * @returns Transaction signature.
586
+ */
90
587
  updatePerpMarketAmmSummaryStats(perpMarketIndex: number, updateAmmSummaryStats?: boolean, netUnsettledFundingPnl?: BN): Promise<TransactionSignature>;
588
+ /**
589
+ * Builds the `updatePerpMarketAmmSummaryStats` instruction without sending it. See
590
+ * `updatePerpMarketAmmSummaryStats`. Throws if `perpMarketIndex` isn't tracked by the
591
+ * local account subscriber (needed to resolve the market's oracle account).
592
+ * @returns The unsigned `updatePerpMarketAmmSummaryStats` instruction.
593
+ */
91
594
  getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex: number, updateAmmSummaryStats?: boolean, netUnsettledFundingPnl?: BN): Promise<TransactionInstruction>;
595
+ /**
596
+ * Builds the (currently non-existent) `updatePerpMarketTargetBaseAssetAmountPerLp`
597
+ * instruction. See `updatePerpMarketTargetBaseAssetAmountPerLp` — this throws because the
598
+ * program does not expose that instruction.
599
+ * @returns Never resolves successfully; throws when the missing instruction is invoked.
600
+ */
92
601
  getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionInstruction>;
602
+ /**
603
+ * Sets a perp market's initial and maintenance margin ratios (max leverage and
604
+ * liquidation threshold). Requires warm admin (`check_warm`). On-chain, validates the pair
605
+ * is internally consistent and compatible with the market's current `liquidatorFee`
606
+ * (`amm.validate_compatible_with_margin_ratio`) before committing.
607
+ * @param perpMarketIndex - Perp market to update.
608
+ * @param marginRatioInitial - Initial margin ratio, MARGIN_PRECISION (1e4, e.g. 2000 = 20% = 5x max leverage). Must be >= `marginRatioMaintenance`.
609
+ * @param marginRatioMaintenance - Maintenance margin ratio, MARGIN_PRECISION (1e4).
610
+ * @returns Transaction signature.
611
+ */
93
612
  updatePerpMarketMarginRatio(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionSignature>;
613
+ /**
614
+ * Builds the `updatePerpMarketMarginRatio` instruction without sending it. See
615
+ * `updatePerpMarketMarginRatio`.
616
+ * @returns The unsigned `updatePerpMarketMarginRatio` instruction.
617
+ */
94
618
  getUpdatePerpMarketMarginRatioIx(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionInstruction>;
619
+ /**
620
+ * Sets a perp market's funding dead-zone: the band around the oracle TWAP within which no
621
+ * funding premium accrues, and the ramp applied to the premium beyond that band. Requires
622
+ * warm admin (`check_warm`). Unlike `initializePerpMarket` (where `0` silently falls back
623
+ * to defaults), the update handler validates its inputs directly and throws `DefaultError`
624
+ * if `fundingClampThreshold >= BPS_PRECISION` (i.e. must be < 100%) or if
625
+ * `fundingRampSlope === 0` (a zero slope would flatten every premium past the band to the
626
+ * funding-rate offset).
627
+ * @param perpMarketIndex - Perp market to update.
628
+ * @param fundingClampThreshold - Dead-zone half-width, basis points (BPS_PRECISION, 1e4). Must be < 10000.
629
+ * @param fundingRampSlope - Slope applied beyond the dead zone, PERCENTAGE_PRECISION (1e6, 1e6 = 1.0x). Must be > 0.
630
+ * @returns Transaction signature.
631
+ */
95
632
  updatePerpMarketFundingDeadZone(perpMarketIndex: number, fundingClampThreshold: number, fundingRampSlope: number): Promise<TransactionSignature>;
633
+ /**
634
+ * Builds the `updatePerpMarketFundingDeadZone` instruction without sending it. See
635
+ * `updatePerpMarketFundingDeadZone` for units and validation.
636
+ * @returns The unsigned `updatePerpMarketFundingDeadZone` instruction.
637
+ */
96
638
  getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex: number, fundingClampThreshold: number, fundingRampSlope: number): Promise<TransactionInstruction>;
639
+ /**
640
+ * Sets a perp market's IMF factors, which increase the effective margin requirement (and
641
+ * shrink unrealized-PnL asset weight) as position size grows. Requires warm admin
642
+ * (`check_warm`). Throws `DefaultError` on-chain if either value exceeds `SPOT_IMF_PRECISION` (1e6).
643
+ * @param perpMarketIndex - Perp market to update.
644
+ * @param imfFactor - Position-size margin penalty factor, SPOT_IMF_PRECISION (1e6). Must be <= 1e6.
645
+ * @param unrealizedPnlImfFactor - Position-size penalty factor applied to unrealized-PnL asset weight, SPOT_IMF_PRECISION (1e6). Must be <= 1e6.
646
+ * @returns Transaction signature.
647
+ */
97
648
  updatePerpMarketImfFactor(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionSignature>;
649
+ /**
650
+ * Builds the `updatePerpMarketImfFactor` instruction without sending it. See
651
+ * `updatePerpMarketImfFactor`.
652
+ * @returns The unsigned `updatePerpMarketImfFactor` instruction.
653
+ */
98
654
  getUpdatePerpMarketImfFactorIx(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionInstruction>;
655
+ /**
656
+ * Sets a perp market's base bid/ask spread around the AMM reserve price. Requires warm
657
+ * admin (`check_warm`). The AMM's cached `longSpread`/`shortSpread` are refreshed from
658
+ * this value on the next quote/fill rather than immediately.
659
+ * @param perpMarketIndex - Perp market to update.
660
+ * @param baseSpread - New base spread, BID_ASK_SPREAD_PRECISION (1e6).
661
+ * @returns Transaction signature.
662
+ */
99
663
  updatePerpMarketBaseSpread(perpMarketIndex: number, baseSpread: number): Promise<TransactionSignature>;
664
+ /**
665
+ * Builds the `updatePerpMarketBaseSpread` instruction without sending it. See
666
+ * `updatePerpMarketBaseSpread`.
667
+ * @returns The unsigned `updatePerpMarketBaseSpread` instruction.
668
+ */
100
669
  getUpdatePerpMarketBaseSpreadIx(perpMarketIndex: number, baseSpread: number): Promise<TransactionInstruction>;
670
+ /**
671
+ * Sets how aggressively the AMM just-in-time-fills incoming taker orders against its own
672
+ * inventory before routing to the DLOB. Gated the same as `updatePerpMarketCurveUpdateIntensity`
673
+ * (warm admin via `HotAdminUpdatePerpMarket`'s `check_warm` constraint). Throws
674
+ * `DefaultError` on-chain if outside `0..=100`.
675
+ * @param perpMarketIndex - Perp market to update.
676
+ * @param ammJitIntensity - 0-100 intensity; 0 disables AMM JIT fills.
677
+ * @returns Transaction signature.
678
+ */
101
679
  updateAmmJitIntensity(perpMarketIndex: number, ammJitIntensity: number): Promise<TransactionSignature>;
680
+ /**
681
+ * Builds the `updateAmmJitIntensity` instruction without sending it. See
682
+ * `updateAmmJitIntensity`.
683
+ * @returns The unsigned `updateAmmJitIntensity` instruction.
684
+ */
102
685
  getUpdateAmmJitIntensityIx(perpMarketIndex: number, ammJitIntensity: number): Promise<TransactionInstruction>;
686
+ /**
687
+ * Sets a perp market's display name. Requires warm admin (`check_warm`).
688
+ * @param perpMarketIndex - Perp market to rename.
689
+ * @param name - New display name, UTF-8 encoded and padded/truncated to 32 bytes.
690
+ * @returns Transaction signature.
691
+ */
103
692
  updatePerpMarketName(perpMarketIndex: number, name: string): Promise<TransactionSignature>;
693
+ /**
694
+ * Builds the `updatePerpMarketName` instruction without sending it. See `updatePerpMarketName`.
695
+ * @returns The unsigned `updatePerpMarketName` instruction.
696
+ */
104
697
  getUpdatePerpMarketNameIx(perpMarketIndex: number, name: string): Promise<TransactionInstruction>;
698
+ /**
699
+ * Sets a spot market's display name. Requires warm admin (`check_warm`).
700
+ * @param spotMarketIndex - Spot market to rename.
701
+ * @param name - New display name, UTF-8 encoded and padded/truncated to 32 bytes.
702
+ * @returns Transaction signature.
703
+ */
105
704
  updateSpotMarketName(spotMarketIndex: number, name: string): Promise<TransactionSignature>;
705
+ /**
706
+ * Builds the `updateSpotMarketName` instruction without sending it. See `updateSpotMarketName`.
707
+ * @returns The unsigned `updateSpotMarketName` instruction.
708
+ */
106
709
  getUpdateSpotMarketNameIx(spotMarketIndex: number, name: string): Promise<TransactionInstruction>;
710
+ /**
711
+ * Sets which pool a spot market belongs to (used to segment markets, e.g. for LP-pool
712
+ * constituent grouping). Requires warm admin (`check_warm`).
713
+ * @param spotMarketIndex - Spot market to update.
714
+ * @param poolId - Target pool id.
715
+ * @returns Transaction signature.
716
+ */
107
717
  updateSpotMarketPoolId(spotMarketIndex: number, poolId: number): Promise<TransactionSignature>;
718
+ /**
719
+ * Builds the `updateSpotMarketPoolId` instruction without sending it. See `updateSpotMarketPoolId`.
720
+ * @returns The unsigned `updateSpotMarketPoolId` instruction.
721
+ */
108
722
  getUpdateSpotMarketPoolIdIx(spotMarketIndex: number, poolId: number): Promise<TransactionInstruction>;
723
+ /**
724
+ * Sets a perp market's maximum allowed total bid/ask spread. Gated the same as
725
+ * `updatePerpMarketCurveUpdateIntensity` (warm admin via `HotAdminUpdatePerpMarket`'s
726
+ * `check_warm` constraint). Throws `DefaultError` on-chain if `maxSpread` is below the
727
+ * market's current `baseSpread` or exceeds `marginRatioInitial * 100`.
728
+ * @param perpMarketIndex - Perp market to update.
729
+ * @param maxSpread - New max spread, BID_ASK_SPREAD_PRECISION (1e6). Must be >= `baseSpread` and <= `marginRatioInitial * 100`.
730
+ * @returns Transaction signature.
731
+ */
109
732
  updatePerpMarketMaxSpread(perpMarketIndex: number, maxSpread: number): Promise<TransactionSignature>;
733
+ /**
734
+ * Builds the `updatePerpMarketMaxSpread` instruction without sending it. See
735
+ * `updatePerpMarketMaxSpread` for units and validation.
736
+ * @returns The unsigned `updatePerpMarketMaxSpread` instruction.
737
+ */
110
738
  getUpdatePerpMarketMaxSpreadIx(perpMarketIndex: number, maxSpread: number): Promise<TransactionInstruction>;
739
+ /**
740
+ * Replaces the protocol-wide perp `FeeStructure` (fee tiers, filler reward, AMM/IF
741
+ * fee split) wholesale. Requires warm admin (`check_warm`). On-chain,
742
+ * `validate_fee_structure` rejects a structure whose `amm_fee_numerator +
743
+ * if_fee_numerator` (both FEE_PERCENTAGE_DENOMINATOR-scaled) exceeds 100% of the
744
+ * trade-fee remainder, among other tier sanity checks.
745
+ * @param feeStructure - Full replacement fee structure (not a partial patch).
746
+ * @returns Transaction signature.
747
+ */
111
748
  updatePerpFeeStructure(feeStructure: FeeStructure): Promise<TransactionSignature>;
749
+ /**
750
+ * Builds the `updatePerpFeeStructure` instruction without sending it. See
751
+ * `updatePerpFeeStructure`.
752
+ * @returns The unsigned `updatePerpFeeStructure` instruction.
753
+ */
112
754
  getUpdatePerpFeeStructureIx(feeStructure: FeeStructure): Promise<TransactionInstruction>;
755
+ /**
756
+ * Replaces the protocol-wide spot `FeeStructure` wholesale. Requires warm admin
757
+ * (`check_warm`); see `updatePerpFeeStructure` for validation.
758
+ * @param feeStructure - Full replacement fee structure (not a partial patch).
759
+ * @returns Transaction signature.
760
+ */
113
761
  updateSpotFeeStructure(feeStructure: FeeStructure): Promise<TransactionSignature>;
762
+ /**
763
+ * Builds the `updateSpotFeeStructure` instruction without sending it. See
764
+ * `updateSpotFeeStructure`.
765
+ * @returns The unsigned `updateSpotFeeStructure` instruction.
766
+ */
114
767
  getUpdateSpotFeeStructureIx(feeStructure: FeeStructure): Promise<TransactionInstruction>;
768
+ /**
769
+ * Sets the fraction of a liquidatable position that may be closed immediately
770
+ * (before the `updateLiquidationDuration` ramp phases in the rest). Requires warm
771
+ * admin (`check_warm`). On-chain the liquidatable fraction ramps linearly from this
772
+ * floor up to 100% over `liquidationDuration` slots since the user's last active
773
+ * slot (see `calculate_max_pct_to_liquidate`); shortages under 50 QUOTE_PRECISION
774
+ * always liquidate in full regardless of this setting.
775
+ * @param initialPctToLiquidate - Initial liquidatable fraction, LIQUIDATION_PCT_PRECISION (1e4, e.g. 2500 = 25%).
776
+ * @returns Transaction signature.
777
+ */
115
778
  updateInitialPctToLiquidate(initialPctToLiquidate: number): Promise<TransactionSignature>;
779
+ /**
780
+ * Builds the `updateInitialPctToLiquidate` instruction without sending it. See
781
+ * `updateInitialPctToLiquidate`.
782
+ * @returns The unsigned `updateInitialPctToLiquidate` instruction.
783
+ */
116
784
  getUpdateInitialPctToLiquidateIx(initialPctToLiquidate: number): Promise<TransactionInstruction>;
785
+ /**
786
+ * Sets how many slots it takes for a liquidation's max-closeable fraction to ramp
787
+ * from `initialPctToLiquidate` up to 100% (see `updateInitialPctToLiquidate`).
788
+ * Requires warm admin (`check_warm`).
789
+ * @param liquidationDuration - Ramp duration, slots (comment in `calculate_max_pct_to_liquidate` notes ~150 slots ≈ 1 minute at 400ms/slot).
790
+ * @returns Transaction signature.
791
+ */
117
792
  updateLiquidationDuration(liquidationDuration: number): Promise<TransactionSignature>;
793
+ /**
794
+ * Builds the `updateLiquidationDuration` instruction without sending it. See
795
+ * `updateLiquidationDuration`.
796
+ * @returns The unsigned `updateLiquidationDuration` instruction.
797
+ */
118
798
  getUpdateLiquidationDurationIx(liquidationDuration: number): Promise<TransactionInstruction>;
799
+ /**
800
+ * Sets the extra maintenance-margin buffer applied when deciding whether a user is
801
+ * liquidatable, on top of the market's own maintenance margin ratio — a safety
802
+ * margin so liquidation triggers before a user is fully underwater. Requires warm
803
+ * admin (`check_warm`).
804
+ * @param updateLiquidationMarginBufferRatio - Extra margin buffer, MARGIN_PRECISION (1e4).
805
+ * @returns Transaction signature.
806
+ */
119
807
  updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio: number): Promise<TransactionSignature>;
808
+ /**
809
+ * Builds the `updateLiquidationMarginBufferRatio` instruction without sending it.
810
+ * See `updateLiquidationMarginBufferRatio`.
811
+ * @returns The unsigned `updateLiquidationMarginBufferRatio` instruction.
812
+ */
120
813
  getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio: number): Promise<TransactionInstruction>;
814
+ /**
815
+ * Replaces the protocol-wide `OracleGuardRails` (validity/confidence/divergence
816
+ * thresholds used to gate oracle-price-driven actions across every market).
817
+ * Requires warm admin (`check_warm`).
818
+ * @param oracleGuardRails - Full replacement guard-rail config (not a partial patch).
819
+ * @returns Transaction signature.
820
+ */
121
821
  updateOracleGuardRails(oracleGuardRails: OracleGuardRails): Promise<TransactionSignature>;
822
+ /**
823
+ * Builds the `updateOracleGuardRails` instruction without sending it. See
824
+ * `updateOracleGuardRails`.
825
+ * @returns The unsigned `updateOracleGuardRails` instruction.
826
+ */
122
827
  getUpdateOracleGuardRailsIx(oracleGuardRails: OracleGuardRails): Promise<TransactionInstruction>;
828
+ /**
829
+ * Sets the buffer (past a perp market's `expiry_ts`) that must elapse before user
830
+ * positions in a `Settlement`-status market can be settled at the expiry price.
831
+ * Requires warm admin (`check_warm`).
832
+ * @param settlementDuration - Post-expiry settlement buffer, seconds.
833
+ * @returns Transaction signature.
834
+ */
123
835
  updateStateSettlementDuration(settlementDuration: number): Promise<TransactionSignature>;
836
+ /**
837
+ * Builds the `updateStateSettlementDuration` instruction without sending it. See
838
+ * `updateStateSettlementDuration`.
839
+ * @returns The unsigned `updateStateSettlementDuration` instruction.
840
+ */
124
841
  getUpdateStateSettlementDurationIx(settlementDuration: number): Promise<TransactionInstruction>;
842
+ /**
843
+ * Sets the protocol-wide cap on sub-accounts per authority
844
+ * (`state.maxNumberOfSubAccounts`) and, via `get_init_user_fee`, the denominator
845
+ * against which `state.numberOfSubAccounts` utilization phases in the
846
+ * `initializeUser` anti-spam fee (see `updateStateMaxInitializeUserFee`). Requires
847
+ * warm admin (`check_warm`).
848
+ * @param maxNumberOfSubAccounts - New protocol-wide sub-account cap.
849
+ * @returns Transaction signature.
850
+ */
125
851
  updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts: number): Promise<TransactionSignature>;
852
+ /**
853
+ * Builds the `updateStateMaxNumberOfSubAccounts` instruction without sending it.
854
+ * See `updateStateMaxNumberOfSubAccounts`.
855
+ * @returns The unsigned `updateStateMaxNumberOfSubAccounts` instruction.
856
+ */
126
857
  getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts: number): Promise<TransactionInstruction>;
858
+ /**
859
+ * Sets the cap on the anti-spam fee `initializeUser` may charge as
860
+ * `state.numberOfSubAccounts` approaches `state.maxNumberOfSubAccounts`. On-chain
861
+ * (`State::get_init_user_fee`) the fee is 0 below ~80% utilization and then scales
862
+ * up to this cap by the time the cap is reached; `0` disables the fee entirely.
863
+ * Requires warm admin (`check_warm`).
864
+ * @param maxInitializeUserFee - Fee cap, hundredths of a SOL (e.g. `100` = 1 SOL, `1` = 0.01 SOL).
865
+ * @returns Transaction signature.
866
+ */
127
867
  updateStateMaxInitializeUserFee(maxInitializeUserFee: number): Promise<TransactionSignature>;
868
+ /**
869
+ * Builds the `updateStateMaxInitializeUserFee` instruction without sending it. See
870
+ * `updateStateMaxInitializeUserFee`.
871
+ * @returns The unsigned `updateStateMaxInitializeUserFee` instruction.
872
+ */
128
873
  getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee: number): Promise<TransactionInstruction>;
874
+ /**
875
+ * Sets a spot market's withdraw guard threshold — the token-amount cap above which a
876
+ * single withdraw/borrow is blocked. Requires warm admin (`check_warm`, on the
877
+ * `AdminUpdateSpotMarketWithdrawGuardThreshold` context). On-chain the notional is priced
878
+ * with the max of the live oracle price and the 5-minute oracle TWAP (`StrictOraclePrice`),
879
+ * so a momentarily-manipulated-down oracle can't let an oversized threshold through;
880
+ * `validate_withdraw_guard_threshold` then re-derives the implied cap and rejects an
881
+ * inconsistent value.
882
+ * @param spotMarketIndex - Spot market to update.
883
+ * @param withdrawGuardThreshold - New threshold, the market's native token decimals.
884
+ * @param oracle - Must equal `spotMarket.oracle` — the account struct's `has_one = oracle`
885
+ * constraint (`ErrorCode::InvalidOracle`) enforces this on-chain, so it is not a way to
886
+ * point at a different price feed. When omitted, this is resolved automatically from the
887
+ * local account cache (or, if not subscribed, by fetching and decoding the `SpotMarket`
888
+ * account directly) — pass it explicitly only to avoid that extra lookup.
889
+ * @returns Transaction signature.
890
+ */
129
891
  updateWithdrawGuardThreshold(spotMarketIndex: number, withdrawGuardThreshold: BN, oracle?: PublicKey): Promise<TransactionSignature>;
892
+ /**
893
+ * Builds the `updateWithdrawGuardThreshold` instruction without sending it. See
894
+ * `updateWithdrawGuardThreshold` — in particular, the `oracle` param must equal
895
+ * `spotMarket.oracle` (enforced by the `has_one` constraint) and is auto-resolved when
896
+ * omitted. Throws if the spot market account can't be found when not subscribed.
897
+ * @returns The unsigned `updateWithdrawGuardThreshold` instruction.
898
+ */
130
899
  getUpdateWithdrawGuardThresholdIx(spotMarketIndex: number, withdrawGuardThreshold: BN, oracle?: PublicKey): Promise<TransactionInstruction>;
900
+ /**
901
+ * Sets a spot market's lending-gain carveouts: the share of deposit interest routed to the
902
+ * insurance fund (`ifFeeFactor`) and to the withdrawable protocol fee pool
903
+ * (`protocolFeeFactor`); lenders keep the remainder. Requires warm admin (`check_warm`).
904
+ * Throws `DefaultError` on-chain if the two factors don't sum to strictly less than 100%
905
+ * (a full 100% carveout would zero out lender interest and freeze the entire accrual path,
906
+ * including the IF/protocol credits themselves).
907
+ * @param spotMarketIndex - Spot market to update; must match the market account passed.
908
+ * @param ifFeeFactor - Insurance-fund carveout, IF_FACTOR_PRECISION (1e6).
909
+ * @param protocolFeeFactor - Protocol-fee-pool carveout, IF_FACTOR_PRECISION (1e6). `ifFeeFactor + protocolFeeFactor` must be < 1e6.
910
+ * @returns Transaction signature.
911
+ */
131
912
  updateSpotMarketIfFactor(spotMarketIndex: number, ifFeeFactor: number, protocolFeeFactor: number): Promise<TransactionSignature>;
913
+ /**
914
+ * Builds the `updateSpotMarketIfFactor` instruction without sending it. See
915
+ * `updateSpotMarketIfFactor` for units and validation.
916
+ * @returns The unsigned `updateSpotMarketIfFactor` instruction.
917
+ */
132
918
  getUpdateSpotMarketIfFactorIx(spotMarketIndex: number, ifFeeFactor: number, protocolFeeFactor: number): Promise<TransactionInstruction>;
919
+ /**
920
+ * Sets how often a spot market's revenue pool may be settled to the insurance fund.
921
+ * Requires warm admin (`check_warm`).
922
+ * @param spotMarketIndex - Spot market to update.
923
+ * @param revenueSettlePeriod - Minimum interval between revenue settlements, seconds.
924
+ * @returns Transaction signature.
925
+ */
133
926
  updateSpotMarketRevenueSettlePeriod(spotMarketIndex: number, revenueSettlePeriod: BN): Promise<TransactionSignature>;
927
+ /**
928
+ * Builds the `updateSpotMarketRevenueSettlePeriod` instruction without sending it. See
929
+ * `updateSpotMarketRevenueSettlePeriod`.
930
+ * @returns The unsigned `updateSpotMarketRevenueSettlePeriod` instruction.
931
+ */
134
932
  getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex: number, revenueSettlePeriod: BN): Promise<TransactionInstruction>;
933
+ /**
934
+ * Sets a spot market's maximum total deposit balance. Requires warm admin (`check_warm`).
935
+ * @param spotMarketIndex - Spot market to update.
936
+ * @param maxTokenDeposits - New deposit cap, the market's native token decimals. `0` disables the cap.
937
+ * @returns Transaction signature.
938
+ */
135
939
  updateSpotMarketMaxTokenDeposits(spotMarketIndex: number, maxTokenDeposits: BN): Promise<TransactionSignature>;
940
+ /**
941
+ * Builds the `updateSpotMarketMaxTokenDeposits` instruction without sending it. See
942
+ * `updateSpotMarketMaxTokenDeposits`.
943
+ * @returns The unsigned `updateSpotMarketMaxTokenDeposits` instruction.
944
+ */
136
945
  getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex: number, maxTokenDeposits: BN): Promise<TransactionInstruction>;
946
+ /**
947
+ * Caps a spot market's total borrows as a fraction of its `maxTokenDeposits`, rather than
948
+ * an absolute token amount. Requires warm admin (`check_warm`). On-chain, the effective cap
949
+ * is `maxTokenDeposits * maxTokenBorrowsFraction / 10000`; the handler throws
950
+ * `InvalidSpotMarketInitialization` if current borrows already exceed the new cap.
951
+ * @param spotMarketIndex - Spot market to update.
952
+ * @param maxTokenBorrowsFraction - Fraction of `maxTokenDeposits` borrowable, in hundredths of a percent (10000 = 100%).
953
+ * @returns Transaction signature.
954
+ */
137
955
  updateSpotMarketMaxTokenBorrows(spotMarketIndex: number, maxTokenBorrowsFraction: number): Promise<TransactionSignature>;
956
+ /**
957
+ * Builds the `updateSpotMarketMaxTokenBorrows` instruction without sending it. See
958
+ * `updateSpotMarketMaxTokenBorrows`.
959
+ * @returns The unsigned `updateSpotMarketMaxTokenBorrows` instruction.
960
+ */
138
961
  getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex: number, maxTokenBorrowsFraction: number): Promise<TransactionInstruction>;
962
+ /**
963
+ * Sets the deposit-notional threshold above which a spot market's `initialAssetWeight`
964
+ * scales down (see `initializeSpotMarket`'s `scaleInitialAssetWeightStart`). Requires warm
965
+ * admin (`check_warm`). `0` disables scaling.
966
+ * @param spotMarketIndex - Spot market to update.
967
+ * @param scaleInitialAssetWeightStart - Deposit-notional threshold, QUOTE_PRECISION (1e6). `0` disables scaling.
968
+ * @returns Transaction signature.
969
+ */
139
970
  updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex: number, scaleInitialAssetWeightStart: BN): Promise<TransactionSignature>;
971
+ /**
972
+ * Builds the `updateSpotMarketScaleInitialAssetWeightStart` instruction without sending it.
973
+ * See `updateSpotMarketScaleInitialAssetWeightStart`.
974
+ * @returns The unsigned `updateSpotMarketScaleInitialAssetWeightStart` instruction.
975
+ */
140
976
  getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex: number, scaleInitialAssetWeightStart: BN): Promise<TransactionInstruction>;
977
+ /**
978
+ * Sets how long an insurance-fund staker's unstake request must sit in escrow before it can
979
+ * be completed for a given spot market. Requires warm admin (`check_warm`).
980
+ * @param spotMarketIndex - Spot market whose insurance fund to update.
981
+ * @param insuranceWithdrawEscrowPeriod - Unstaking escrow duration, seconds.
982
+ * @returns Transaction signature.
983
+ */
141
984
  updateInsuranceFundUnstakingPeriod(spotMarketIndex: number, insuranceWithdrawEscrowPeriod: BN): Promise<TransactionSignature>;
985
+ /**
986
+ * Builds the `updateInsuranceFundUnstakingPeriod` instruction without sending it. See
987
+ * `updateInsuranceFundUnstakingPeriod`.
988
+ * @returns The unsigned `updateInsuranceFundUnstakingPeriod` instruction.
989
+ */
142
990
  getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex: number, insuranceWithdrawEscrowPeriod: BN): Promise<TransactionInstruction>;
991
+ /**
992
+ * Swaps a perp market's oracle account/source. Requires **cold** admin
993
+ * (`AdminUpdatePerpMarketOracle`'s `check_cold` constraint) — a lesser admin swapping the
994
+ * oracle could re-price margin/liquidation math and any `AmmCache`-derived value at will.
995
+ * On-chain the handler reads both the new and current (`oldOracle`) oracle prices and,
996
+ * unless `skipInvaraintCheck` is `true`, throws `DefaultError` if the new price is
997
+ * non-positive or diverges more than 10% from the old one. If the market is present in the
998
+ * `AmmCache`, its cached fields are refreshed from the new oracle in the same instruction.
999
+ * @param perpMarketIndex - Perp market to update.
1000
+ * @param oracle - New oracle account.
1001
+ * @param oracleSource - Oracle provider/format for `oracle`.
1002
+ * @param skipInvaraintCheck - If `true`, skips the on-chain non-positive/10%-divergence sanity check against the current oracle price. Default `false`.
1003
+ * @returns Transaction signature.
1004
+ */
143
1005
  updatePerpMarketOracle(perpMarketIndex: number, oracle: PublicKey, oracleSource: OracleSource, skipInvaraintCheck?: boolean): Promise<TransactionSignature>;
1006
+ /**
1007
+ * Builds the `updatePerpMarketOracle` instruction without sending it. See
1008
+ * `updatePerpMarketOracle`. Resolves `oldOracle` from the locally-cached perp market account
1009
+ * (throws if `perpMarketIndex` isn't tracked by the account subscriber) and passes the
1010
+ * program's singleton `AmmCache` PDA.
1011
+ * @returns The unsigned `updatePerpMarketOracle` instruction.
1012
+ */
144
1013
  getUpdatePerpMarketOracleIx(perpMarketIndex: number, oracle: PublicKey, oracleSource: OracleSource, skipInvaraintCheck?: boolean): Promise<TransactionInstruction>;
1014
+ /**
1015
+ * Sets a perp market's minimum base-size increment and minimum price increment for orders.
1016
+ * Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless both are > 0
1017
+ * and `stepSize <= 2_000_000_000` (kept below `i32::MAX` for the LP's remainder-base-asset
1018
+ * accounting).
1019
+ * @param perpMarketIndex - Perp market to update.
1020
+ * @param stepSize - Minimum base-size increment, BASE_PRECISION (1e9).
1021
+ * @param tickSize - Minimum price increment, PRICE_PRECISION (1e6).
1022
+ * @returns Transaction signature.
1023
+ */
145
1024
  updatePerpMarketStepSizeAndTickSize(perpMarketIndex: number, stepSize: BN, tickSize: BN): Promise<TransactionSignature>;
1025
+ /**
1026
+ * Builds the `updatePerpMarketStepSizeAndTickSize` instruction without sending it. See
1027
+ * `updatePerpMarketStepSizeAndTickSize`.
1028
+ * @returns The unsigned `updatePerpMarketStepSizeAndTickSize` instruction.
1029
+ */
146
1030
  getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex: number, stepSize: BN, tickSize: BN): Promise<TransactionInstruction>;
1031
+ /**
1032
+ * Sets a perp market's minimum order base size (`market.marketStats.minOrderSize`). Requires
1033
+ * warm admin (`check_warm`). On-chain, throws `DefaultError` unless `orderSize > 0`.
1034
+ * @param perpMarketIndex - Perp market to update.
1035
+ * @param orderSize - Minimum base order size, BASE_PRECISION (1e9).
1036
+ * @returns Transaction signature.
1037
+ */
147
1038
  updatePerpMarketMinOrderSize(perpMarketIndex: number, orderSize: BN): Promise<TransactionSignature>;
1039
+ /**
1040
+ * Builds the `updatePerpMarketMinOrderSize` instruction without sending it. See
1041
+ * `updatePerpMarketMinOrderSize`.
1042
+ * @returns The unsigned `updatePerpMarketMinOrderSize` instruction.
1043
+ */
148
1044
  getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex: number, orderSize: BN): Promise<TransactionInstruction>;
1045
+ /**
1046
+ * Sets a spot market's minimum base-size increment and minimum price increment for orders.
1047
+ * Requires warm admin (`check_warm`). On-chain, the quote/index-0 market (`marketIndex ===
1048
+ * 0`) is exempt from the `> 0` check other spot markets must satisfy.
1049
+ * @param spotMarketIndex - Spot market to update.
1050
+ * @param stepSize - Minimum base-size increment, market's native token decimals.
1051
+ * @param tickSize - Minimum price increment, PRICE_PRECISION (1e6).
1052
+ * @returns Transaction signature.
1053
+ */
149
1054
  updateSpotMarketStepSizeAndTickSize(spotMarketIndex: number, stepSize: BN, tickSize: BN): Promise<TransactionSignature>;
1055
+ /**
1056
+ * Builds the `updateSpotMarketStepSizeAndTickSize` instruction without sending it. See
1057
+ * `updateSpotMarketStepSizeAndTickSize`.
1058
+ * @returns The unsigned `updateSpotMarketStepSizeAndTickSize` instruction.
1059
+ */
150
1060
  getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex: number, stepSize: BN, tickSize: BN): Promise<TransactionInstruction>;
1061
+ /**
1062
+ * Sets a spot market's minimum order base size. Requires warm admin (`check_warm`). On-chain,
1063
+ * the quote/index-0 market is exempt from the `> 0` check other spot markets must satisfy.
1064
+ * @param spotMarketIndex - Spot market to update.
1065
+ * @param orderSize - Minimum base order size, market's native token decimals.
1066
+ * @returns Transaction signature.
1067
+ */
151
1068
  updateSpotMarketMinOrderSize(spotMarketIndex: number, orderSize: BN): Promise<TransactionSignature>;
1069
+ /**
1070
+ * Builds the `updateSpotMarketMinOrderSize` instruction without sending it. See
1071
+ * `updateSpotMarketMinOrderSize`.
1072
+ * @returns The unsigned `updateSpotMarketMinOrderSize` instruction.
1073
+ */
152
1074
  getUpdateSpotMarketMinOrderSizeIx(spotMarketIndex: number, orderSize: BN): Promise<TransactionInstruction>;
1075
+ /**
1076
+ * Schedules a perp market for expiry: sets `expiryTs` and immediately flips the market to
1077
+ * `MarketStatus.ReduceOnly` (existing positions can only be reduced from this point).
1078
+ * Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if `expiryTs` is not
1079
+ * strictly after the current on-chain clock timestamp. This does not settle or delist the
1080
+ * market — see `settleExpiredMarketPoolsToRevenuePool` for the later teardown step.
1081
+ * @param perpMarketIndex - Perp market to schedule for expiry.
1082
+ * @param expiryTs - Unix timestamp (seconds) after which the market is expired; must be in the future.
1083
+ * @returns Transaction signature.
1084
+ */
153
1085
  updatePerpMarketExpiry(perpMarketIndex: number, expiryTs: BN): Promise<TransactionSignature>;
1086
+ /**
1087
+ * Builds the `updatePerpMarketExpiry` instruction without sending it. See
1088
+ * `updatePerpMarketExpiry`.
1089
+ * @returns The unsigned `updatePerpMarketExpiry` instruction.
1090
+ */
154
1091
  getUpdatePerpMarketExpiryIx(perpMarketIndex: number, expiryTs: BN): Promise<TransactionInstruction>;
1092
+ /**
1093
+ * Swaps a spot market's oracle account/source. Requires **cold** admin
1094
+ * (`AdminUpdateSpotMarketOracle`'s `check_cold` constraint) — a lesser admin swapping the
1095
+ * oracle could re-price the withdraw guard threshold notional cap and all margin math at
1096
+ * will. On-chain the handler reads both the new and current (`oldOracle`) oracle prices and,
1097
+ * unless `skipInvaraintCheck` is `true`, throws `DefaultError` if the new price is
1098
+ * non-positive or diverges more than 10% from the old one.
1099
+ * @param spotMarketIndex - Spot market to update.
1100
+ * @param oracle - New oracle account.
1101
+ * @param oracleSource - Oracle provider/format for `oracle`.
1102
+ * @param skipInvaraintCheck - If `true`, skips the on-chain non-positive/10%-divergence sanity check against the current oracle price. Default `false`.
1103
+ * @returns Transaction signature.
1104
+ */
155
1105
  updateSpotMarketOracle(spotMarketIndex: number, oracle: PublicKey, oracleSource: OracleSource, skipInvaraintCheck?: boolean): Promise<TransactionSignature>;
1106
+ /**
1107
+ * Builds the `updateSpotMarketOracle` instruction without sending it. See
1108
+ * `updateSpotMarketOracle`. Resolves `oldOracle` from the locally-cached spot market account
1109
+ * (throws if `spotMarketIndex` isn't tracked by the account subscriber).
1110
+ * @returns The unsigned `updateSpotMarketOracle` instruction.
1111
+ */
156
1112
  getUpdateSpotMarketOracleIx(spotMarketIndex: number, oracle: PublicKey, oracleSource: OracleSource, skipInvaraintCheck?: boolean): Promise<TransactionInstruction>;
1113
+ /**
1114
+ * Enables or disables limit-order placement/fills on a spot market (`spotMarket.ordersEnabled`).
1115
+ * Requires warm admin (`check_warm`).
1116
+ * @param spotMarketIndex - Spot market to update.
1117
+ * @param ordersEnabled - Whether spot orders are enabled for this market.
1118
+ * @returns Transaction signature.
1119
+ */
157
1120
  updateSpotMarketOrdersEnabled(spotMarketIndex: number, ordersEnabled: boolean): Promise<TransactionSignature>;
1121
+ /**
1122
+ * Builds the `updateSpotMarketOrdersEnabled` instruction without sending it. See
1123
+ * `updateSpotMarketOrdersEnabled`.
1124
+ * @returns The unsigned `updateSpotMarketOrdersEnabled` instruction.
1125
+ */
158
1126
  getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex: number, ordersEnabled: boolean): Promise<TransactionInstruction>;
1127
+ /**
1128
+ * Sets a spot market's insurance-fund operation pause bitmask (`InsuranceFundOperation`:
1129
+ * `Init` 0b0001, `Add` 0b0010, `RequestRemove` 0b0100, `Remove` 0b1000). Gated by
1130
+ * `PauseAdminUpdateSpotMarket` — callable by cold, warm, or the dedicated `pause_admin`; a
1131
+ * caller authorized only via `pause_admin` (not warm/cold) may only *add* pause bits, never
1132
+ * clear existing ones (`require_pause_only_added`).
1133
+ * @param spotMarketIndex - Spot market to update.
1134
+ * @param pausedOperations - New `InsuranceFundOperation` bitmask.
1135
+ * @returns Transaction signature.
1136
+ */
159
1137
  updateSpotMarketIfPausedOperations(spotMarketIndex: number, pausedOperations: number): Promise<TransactionSignature>;
1138
+ /**
1139
+ * Builds the `updateSpotMarketIfPausedOperations` instruction without sending it. See
1140
+ * `updateSpotMarketIfPausedOperations`.
1141
+ * @returns The unsigned `updateSpotMarketIfPausedOperations` instruction.
1142
+ */
160
1143
  getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex: number, pausedOperations: number): Promise<TransactionInstruction>;
1144
+ /**
1145
+ * Schedules a spot market for expiry: sets `expiryTs` and immediately flips the market to
1146
+ * `MarketStatus.ReduceOnly`. Requires warm admin (`check_warm`). Throws `DefaultError`
1147
+ * on-chain if `expiryTs` is not strictly after the current on-chain clock timestamp.
1148
+ * @param spotMarketIndex - Spot market to schedule for expiry.
1149
+ * @param expiryTs - Unix timestamp (seconds) after which the market is expired; must be in the future.
1150
+ * @returns Transaction signature.
1151
+ */
161
1152
  updateSpotMarketExpiry(spotMarketIndex: number, expiryTs: BN): Promise<TransactionSignature>;
1153
+ /**
1154
+ * Builds the `updateSpotMarketExpiry` instruction without sending it. See
1155
+ * `updateSpotMarketExpiry`.
1156
+ * @returns The unsigned `updateSpotMarketExpiry` instruction.
1157
+ */
162
1158
  getUpdateSpotMarketExpiryIx(spotMarketIndex: number, expiryTs: BN): Promise<TransactionInstruction>;
1159
+ /**
1160
+ * @deprecated The `update_whitelist_mint` instruction handler exists in the Rust
1161
+ * program (`handle_update_whitelist_mint`) but its `#[program]` entry point is
1162
+ * currently commented out in `lib.rs`, so it is absent from the deployed program
1163
+ * and from the generated IDL. Calling this (or `getUpdateWhitelistMintIx`) throws
1164
+ * at runtime — `this.program.instruction` has no `updateWhitelistMint` member —
1165
+ * regardless of the `as any` cast used to bypass the TS type check. Do not call
1166
+ * until the on-chain entry point is re-enabled.
1167
+ * @param whitelistMint - Intended new `state.whitelistMint` (unused while dead).
1168
+ * @returns Transaction signature (never reached).
1169
+ */
163
1170
  updateWhitelistMint(whitelistMint?: PublicKey): Promise<TransactionSignature>;
1171
+ /**
1172
+ * @deprecated See `updateWhitelistMint` — the underlying `update_whitelist_mint`
1173
+ * instruction is not wired up on-chain and is missing from the IDL; this throws
1174
+ * at runtime.
1175
+ * @returns Never resolves successfully.
1176
+ */
164
1177
  getUpdateWhitelistMintIx(whitelistMint?: PublicKey): Promise<TransactionInstruction>;
1178
+ /**
1179
+ * Sets `state.discountMint` — a token that grants trade-fee discounts to holders
1180
+ * (checked against the `FeeTier` discount rules at fill time). Requires warm admin
1181
+ * (`check_warm`).
1182
+ * @param discountMint - New discount-token mint.
1183
+ * @returns Transaction signature.
1184
+ */
165
1185
  updateDiscountMint(discountMint: PublicKey): Promise<TransactionSignature>;
1186
+ /**
1187
+ * Builds the `updateDiscountMint` instruction without sending it. See
1188
+ * `updateDiscountMint`.
1189
+ * @returns The unsigned `updateDiscountMint` instruction.
1190
+ */
166
1191
  getUpdateDiscountMintIx(discountMint: PublicKey): Promise<TransactionInstruction>;
1192
+ /**
1193
+ * Sets a spot market's deposit/borrow margin weights and IMF factor. Requires warm admin
1194
+ * (`check_warm`). On-chain, `validate_margin_weights` enforces the standard invariants
1195
+ * (asset weights <= SPOT_WEIGHT_PRECISION, liability weights >= SPOT_WEIGHT_PRECISION,
1196
+ * initial at least as conservative as maintenance, and consistency with `imfFactor`).
1197
+ * @param spotMarketIndex - Spot market to update.
1198
+ * @param initialAssetWeight - Initial (deposit) asset weight, SPOT_WEIGHT_PRECISION (1e4).
1199
+ * @param maintenanceAssetWeight - Maintenance asset weight, SPOT_WEIGHT_PRECISION (1e4).
1200
+ * @param initialLiabilityWeight - Initial (borrow) liability weight, SPOT_WEIGHT_PRECISION (1e4).
1201
+ * @param maintenanceLiabilityWeight - Maintenance liability weight, SPOT_WEIGHT_PRECISION (1e4).
1202
+ * @param imfFactor - Increases weight penalty as position size grows, SPOT_IMF_PRECISION (1e6). Default 0.
1203
+ * @returns Transaction signature.
1204
+ */
167
1205
  updateSpotMarketMarginWeights(spotMarketIndex: number, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number): Promise<TransactionSignature>;
1206
+ /**
1207
+ * Builds the `updateSpotMarketMarginWeights` instruction without sending it. See
1208
+ * `updateSpotMarketMarginWeights`.
1209
+ * @returns The unsigned `updateSpotMarketMarginWeights` instruction.
1210
+ */
168
1211
  getUpdateSpotMarketMarginWeightsIx(spotMarketIndex: number, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number): Promise<TransactionInstruction>;
1212
+ /**
1213
+ * Sets a spot market's interest-rate curve: the utilization/rate kink plus the max rate at
1214
+ * 100% utilization. Requires warm admin (`check_warm`). On-chain, `validate_borrow_rate`
1215
+ * checks the curve is well-formed (kink within bounds, rates monotonically increasing,
1216
+ * `min_borrow_rate` at or below `optimal_borrow_rate`).
1217
+ * @param spotMarketIndex - Spot market to update.
1218
+ * @param optimalUtilization - Utilization at the borrow-rate kink, SPOT_UTILIZATION_PRECISION (1e6, 100% = 1e6).
1219
+ * @param optimalBorrowRate - Borrow rate at `optimalUtilization`, SPOT_RATE_PRECISION (1e6, 100% APR = 1e6).
1220
+ * @param optimalMaxRate - Borrow rate at 100% utilization, SPOT_RATE_PRECISION (1e6).
1221
+ * @param minBorrowRate - Floor borrow rate at 0% utilization, in units of 0.5% (i.e. `SPOT_RATE_PRECISION / 200` per unit); omit to leave `spotMarket.minBorrowRate` unchanged.
1222
+ * @returns Transaction signature.
1223
+ */
169
1224
  updateSpotMarketBorrowRate(spotMarketIndex: number, optimalUtilization: number, optimalBorrowRate: number, optimalMaxRate: number, minBorrowRate?: number | undefined): Promise<TransactionSignature>;
1225
+ /**
1226
+ * Builds the `updateSpotMarketBorrowRate` instruction without sending it. See
1227
+ * `updateSpotMarketBorrowRate`.
1228
+ * @returns The unsigned `updateSpotMarketBorrowRate` instruction.
1229
+ */
170
1230
  getUpdateSpotMarketBorrowRateIx(spotMarketIndex: number, optimalUtilization: number, optimalBorrowRate: number, optimalMaxRate: number, minBorrowRate?: number | undefined): Promise<TransactionInstruction>;
1231
+ /**
1232
+ * Sets a spot market's `AssetTier` (collateral-usability gate for cross-margin). Requires
1233
+ * warm admin (`check_warm`). On-chain, if `spotMarket.initialAssetWeight > 0` (the market is
1234
+ * currently usable as collateral), the new tier must be `AssetTier.COLLATERAL` or
1235
+ * `AssetTier.PROTECTED` — otherwise it throws `DefaultError`; zero the initial asset weight
1236
+ * first to move a market to a lesser tier.
1237
+ * @param spotMarketIndex - Spot market to update.
1238
+ * @param assetTier - New asset tier.
1239
+ * @returns Transaction signature.
1240
+ */
171
1241
  updateSpotMarketAssetTier(spotMarketIndex: number, assetTier: AssetTier): Promise<TransactionSignature>;
1242
+ /**
1243
+ * Builds the `updateSpotMarketAssetTier` instruction without sending it. See
1244
+ * `updateSpotMarketAssetTier`.
1245
+ * @returns The unsigned `updateSpotMarketAssetTier` instruction.
1246
+ */
172
1247
  getUpdateSpotMarketAssetTierIx(spotMarketIndex: number, assetTier: AssetTier): Promise<TransactionInstruction>;
1248
+ /**
1249
+ * Sets a spot market's `MarketStatus` directly. Requires warm admin (`check_warm`). Unlike
1250
+ * `updatePerpMarketStatus`, the spot handler applies no restriction on the target status —
1251
+ * `Delisted`/`Settlement` can be set here directly (there is no separate spot
1252
+ * settlement-teardown instruction).
1253
+ * @param spotMarketIndex - Spot market to update.
1254
+ * @param marketStatus - New market status.
1255
+ * @returns Transaction signature.
1256
+ */
173
1257
  updateSpotMarketStatus(spotMarketIndex: number, marketStatus: MarketStatus): Promise<TransactionSignature>;
1258
+ /**
1259
+ * Builds the `updateSpotMarketStatus` instruction without sending it. See
1260
+ * `updateSpotMarketStatus`.
1261
+ * @returns The unsigned `updateSpotMarketStatus` instruction.
1262
+ */
174
1263
  getUpdateSpotMarketStatusIx(spotMarketIndex: number, marketStatus: MarketStatus): Promise<TransactionInstruction>;
1264
+ /**
1265
+ * Sets a spot market's operation pause bitmask (`SpotOperation`: `UpdateCumulativeInterest`
1266
+ * 0b00001, `Fill` 0b00010, `Deposit` 0b00100, `Withdraw` 0b01000, `Liquidation` 0b10000).
1267
+ * Gated by `PauseAdminUpdateSpotMarket` — callable by cold, warm, or the dedicated
1268
+ * `pause_admin`; a caller authorized only via `pause_admin` may only *add* pause bits, never
1269
+ * clear existing ones (`require_pause_only_added`).
1270
+ * @param spotMarketIndex - Spot market to update.
1271
+ * @param pausedOperations - New `SpotOperation` bitmask.
1272
+ * @returns Transaction signature.
1273
+ */
175
1274
  updateSpotMarketPausedOperations(spotMarketIndex: number, pausedOperations: number): Promise<TransactionSignature>;
1275
+ /**
1276
+ * Builds the `updateSpotMarketPausedOperations` instruction without sending it. See
1277
+ * `updateSpotMarketPausedOperations`.
1278
+ * @returns The unsigned `updateSpotMarketPausedOperations` instruction.
1279
+ */
176
1280
  getUpdateSpotMarketPausedOperationsIx(spotMarketIndex: number, pausedOperations: number): Promise<TransactionInstruction>;
1281
+ /**
1282
+ * Sets a perp market's `MarketStatus` directly. Requires warm admin (`check_warm`). On-chain,
1283
+ * throws `DefaultError` if the target status is `Delisted` or `Settlement` — those are only
1284
+ * reached through the market-expiry lifecycle (`updatePerpMarketExpiry` -> `ReduceOnly`,
1285
+ * then the keeper's `settleExpiredMarket` -> `Settlement`, then
1286
+ * `settleExpiredMarketPoolsToRevenuePool` -> `Delisted`), never set directly here.
1287
+ * @param perpMarketIndex - Perp market to update.
1288
+ * @param marketStatus - New market status; must not be `Delisted` or `Settlement`.
1289
+ * @returns Transaction signature.
1290
+ */
177
1291
  updatePerpMarketStatus(perpMarketIndex: number, marketStatus: MarketStatus): Promise<TransactionSignature>;
1292
+ /**
1293
+ * Builds the `updatePerpMarketStatus` instruction without sending it. See
1294
+ * `updatePerpMarketStatus`.
1295
+ * @returns The unsigned `updatePerpMarketStatus` instruction.
1296
+ */
178
1297
  getUpdatePerpMarketStatusIx(perpMarketIndex: number, marketStatus: MarketStatus): Promise<TransactionInstruction>;
1298
+ /**
1299
+ * Sets a perp market's operation pause bitmask (`PerpOperation`: `UpdateFunding` 0b00000001,
1300
+ * `AmmFill` 0b00000010, `Fill` 0b00000100, `SettlePnl` 0b00001000, `SettlePnlWithPosition`
1301
+ * 0b00010000, `Liquidation` 0b00100000, `AmmImmediateFill` 0b01000000, `SettleRevPool`
1302
+ * 0b10000000). Gated by `PauseAdminUpdatePerpMarket` — callable by cold, warm, or the
1303
+ * dedicated `pause_admin`. Authority matrix on-chain: **cold** may set any value; **warm**
1304
+ * may only flip the `UpdateFunding` / `SettleRevPool` bits, all others must be preserved
1305
+ * (throws `DefaultError` otherwise); **pause_admin** may set any bit but only *add* pause
1306
+ * bits, never clear them (`require_pause_only_added`).
1307
+ * @param perpMarketIndex - Perp market to update.
1308
+ * @param pausedOperations - New `PerpOperation` bitmask.
1309
+ * @returns Transaction signature.
1310
+ */
179
1311
  updatePerpMarketPausedOperations(perpMarketIndex: number, pausedOperations: number): Promise<TransactionSignature>;
1312
+ /**
1313
+ * Builds the `updatePerpMarketPausedOperations` instruction without sending it. See
1314
+ * `updatePerpMarketPausedOperations`.
1315
+ * @returns The unsigned `updatePerpMarketPausedOperations` instruction.
1316
+ */
180
1317
  getUpdatePerpMarketPausedOperationsIx(perpMarketIndex: number, pausedOperations: number): Promise<TransactionInstruction>;
1318
+ /**
1319
+ * Sets a perp market's `ContractTier` (risk/collateral classification). Requires warm admin
1320
+ * (`check_warm`).
1321
+ * @param perpMarketIndex - Perp market to update.
1322
+ * @param contractTier - New contract tier.
1323
+ * @returns Transaction signature.
1324
+ */
181
1325
  updatePerpMarketContractTier(perpMarketIndex: number, contractTier: ContractTier): Promise<TransactionSignature>;
1326
+ /**
1327
+ * Builds the `updatePerpMarketContractTier` instruction without sending it. See
1328
+ * `updatePerpMarketContractTier`.
1329
+ * @returns The unsigned `updatePerpMarketContractTier` instruction.
1330
+ */
182
1331
  getUpdatePerpMarketContractTierIx(perpMarketIndex: number, contractTier: ContractTier): Promise<TransactionInstruction>;
1332
+ /**
1333
+ * Sets `state.exchangeStatus`, the protocol-wide pause bitmask (`ExchangeStatus`).
1334
+ * Reachable by cold, warm, or `pauseAdmin` (`PauseAdminUpdateState`'s
1335
+ * `check_pause`), but the handler enforces `require_pause_only_added`: a caller
1336
+ * authorised only via `pauseAdmin` (not warm/cold) may add pause bits but never
1337
+ * clear one — cold/warm can set any value, including unpausing. The `admin`
1338
+ * account below defaults to `coldAdmin`; a pause-admin-only caller must override it
1339
+ * with their own pubkey.
1340
+ * @param exchangeStatus - New pause bitmask, `ExchangeStatus` (bit values; `PAUSED` = 255 pauses everything).
1341
+ * @returns Transaction signature.
1342
+ */
183
1343
  updateExchangeStatus(exchangeStatus: ExchangeStatus): Promise<TransactionSignature>;
1344
+ /**
1345
+ * Builds the `updateExchangeStatus` instruction without sending it. See
1346
+ * `updateExchangeStatus`.
1347
+ * @returns The unsigned `updateExchangeStatus` instruction.
1348
+ */
184
1349
  getUpdateExchangeStatusIx(exchangeStatus: ExchangeStatus): Promise<TransactionInstruction>;
1350
+ /**
1351
+ * Sets `state.solvencyStatus` (`SolvencyStatus`), gating internal solvency-repair
1352
+ * flows (bankruptcy / pnl-deficit resolution) independently of
1353
+ * `ExchangeStatus.WITHDRAW_PAUSED`. Cold-only — unlike `updateExchangeStatus`, the
1354
+ * `ColdAdminUpdateState` context accepts only `state.coldAdmin`; there is no
1355
+ * pause-admin or warm-admin path and no bit-add-only restriction.
1356
+ * @param solvencyStatus - New bitmask, `SolvencyStatus` (currently one bit: `SOLVENCY_REPAIR_PAUSED`).
1357
+ * @returns Transaction signature.
1358
+ */
185
1359
  updateSolvencyStatus(solvencyStatus: SolvencyStatus): Promise<TransactionSignature>;
1360
+ /**
1361
+ * Builds the `updateSolvencyStatus` instruction without sending it. See
1362
+ * `updateSolvencyStatus`.
1363
+ * @returns The unsigned `updateSolvencyStatus` instruction.
1364
+ */
186
1365
  getUpdateSolvencyStatusIx(solvencyStatus: SolvencyStatus): Promise<TransactionInstruction>;
1366
+ /**
1367
+ * Sets the protocol-wide default minimum perp-order auction duration
1368
+ * (`state.minPerpAuctionDuration`) — orders placed without an explicit longer
1369
+ * auction fall back to this floor. Requires warm admin (`check_warm`).
1370
+ * @param minDuration - Minimum auction duration, slots.
1371
+ * @returns Transaction signature.
1372
+ */
187
1373
  updatePerpAuctionDuration(minDuration: BN | number): Promise<TransactionSignature>;
1374
+ /**
1375
+ * Builds the `updatePerpAuctionDuration` instruction without sending it. See
1376
+ * `updatePerpAuctionDuration`.
1377
+ * @returns The unsigned `updatePerpAuctionDuration` instruction.
1378
+ */
188
1379
  getUpdatePerpAuctionDurationIx(minDuration: BN | number): Promise<TransactionInstruction>;
1380
+ /**
1381
+ * Sets the protocol-wide default spot-order auction duration
1382
+ * (`state.defaultSpotAuctionDuration`). Requires warm admin (`check_warm`).
1383
+ * @param defaultAuctionDuration - Default auction duration, slots.
1384
+ * @returns Transaction signature.
1385
+ */
189
1386
  updateSpotAuctionDuration(defaultAuctionDuration: number): Promise<TransactionSignature>;
1387
+ /**
1388
+ * Builds the `updateSpotAuctionDuration` instruction without sending it. See
1389
+ * `updateSpotAuctionDuration`.
1390
+ * @returns The unsigned `updateSpotAuctionDuration` instruction.
1391
+ */
190
1392
  getUpdateSpotAuctionDurationIx(defaultAuctionDuration: number): Promise<TransactionInstruction>;
1393
+ /**
1394
+ * Sets the fraction of a perp market's AMM base reserve a single fill may consume
1395
+ * (`amm.maxFillReserveFraction`; a single fill is capped at
1396
+ * `baseAssetReserve / maxFillReserveFraction`, further bounded by half the AMM's
1397
+ * per-side available liquidity). Requires warm admin (`check_warm`). Throws `DefaultError`
1398
+ * on-chain if `maxBaseAssetAmountRatio` is 0. Smaller values allow larger single fills.
1399
+ * @param perpMarketIndex - Perp market to update.
1400
+ * @param maxBaseAssetAmountRatio - Divisor applied to `baseAssetReserve` to cap a single fill's size; must be > 0.
1401
+ * @returns Transaction signature.
1402
+ */
191
1403
  updatePerpMarketMaxFillReserveFraction(perpMarketIndex: number, maxBaseAssetAmountRatio: number): Promise<TransactionSignature>;
1404
+ /**
1405
+ * Builds the `updatePerpMarketMaxFillReserveFraction` instruction without sending it. See
1406
+ * `updatePerpMarketMaxFillReserveFraction`.
1407
+ * @returns The unsigned `updatePerpMarketMaxFillReserveFraction` instruction.
1408
+ */
192
1409
  getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex: number, maxBaseAssetAmountRatio: number): Promise<TransactionInstruction>;
1410
+ /**
1411
+ * **Currently broken and a dead config knob even if fixed.** Intended to set a perp market's
1412
+ * `amm.maxSlippageRatio` (on-chain default 50, i.e. ~2% per the seed comment in
1413
+ * `initializePerpMarket`'s default config) — but `getUpdateMaxSlippageRatioIx` calls
1414
+ * `this.program.instruction.updateMaxSlippageRatio` (cast to `any` to bypass the missing
1415
+ * type); the actual on-chain/IDL instruction is named `updatePerpMarketMaxSlippageRatio`, so
1416
+ * this throws at runtime (`... is not a function`). Separately, even the correctly-named
1417
+ * instruction's target field, `amm.maxSlippageRatio`, is not read by any fill/slippage-check
1418
+ * path in the program — it is write-only. Requires warm admin (`check_warm`) on the
1419
+ * `update_perp_market_max_slippage_ratio` handler.
1420
+ * @param perpMarketIndex - Perp market that would be updated.
1421
+ * @param maxSlippageRatio - Intended `amm.maxSlippageRatio` value, unitless (would validate `> 0`).
1422
+ * @returns Transaction signature (in practice: throws before a transaction is built).
1423
+ */
193
1424
  updateMaxSlippageRatio(perpMarketIndex: number, maxSlippageRatio: number): Promise<TransactionSignature>;
1425
+ /**
1426
+ * Builds the (currently broken) `updateMaxSlippageRatio` instruction. See
1427
+ * `updateMaxSlippageRatio` — this throws because the program has no `updateMaxSlippageRatio`
1428
+ * instruction (the real name is `updatePerpMarketMaxSlippageRatio`). Throws if
1429
+ * `perpMarketIndex` isn't tracked by the local account subscriber, before it even reaches
1430
+ * the bad instruction-name call.
1431
+ * @returns Never resolves successfully; throws when the missing instruction is invoked.
1432
+ */
194
1433
  getUpdateMaxSlippageRatioIx(perpMarketIndex: number, maxSlippageRatio: number): Promise<TransactionInstruction>;
1434
+ /**
1435
+ * Sets the asset weights applied to a user's unrealized (unsettled) perp PnL when it counts
1436
+ * toward free collateral. Requires warm admin (`check_warm`). On-chain, both weights must be
1437
+ * <= SPOT_WEIGHT_PRECISION and `unrealizedInitialAssetWeight <= unrealizedMaintenanceAssetWeight`,
1438
+ * or the handler throws `DefaultError`.
1439
+ * @param perpMarketIndex - Perp market to update.
1440
+ * @param unrealizedInitialAssetWeight - Initial-margin weight on unrealized PnL, SPOT_WEIGHT_PRECISION (1e4).
1441
+ * @param unrealizedMaintenanceAssetWeight - Maintenance-margin weight on unrealized PnL, SPOT_WEIGHT_PRECISION (1e4). Must be >= the initial weight.
1442
+ * @returns Transaction signature.
1443
+ */
195
1444
  updatePerpMarketUnrealizedAssetWeight(perpMarketIndex: number, unrealizedInitialAssetWeight: number, unrealizedMaintenanceAssetWeight: number): Promise<TransactionSignature>;
1445
+ /**
1446
+ * Builds the `updatePerpMarketUnrealizedAssetWeight` instruction without sending it. See
1447
+ * `updatePerpMarketUnrealizedAssetWeight`.
1448
+ * @returns The unsigned `updatePerpMarketUnrealizedAssetWeight` instruction.
1449
+ */
196
1450
  getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex: number, unrealizedInitialAssetWeight: number, unrealizedMaintenanceAssetWeight: number): Promise<TransactionInstruction>;
1451
+ /**
1452
+ * Sets a perp market's insurance/revenue-pool caps. Requires warm admin (`check_warm`).
1453
+ * On-chain, all three are bounded by the tier-specific `INSURANCE_{A,B,C,SPECULATIVE}_MAX`
1454
+ * constant for the market's current `contractTier` (`maxRevenueWithdrawPerPeriod` may
1455
+ * alternatively be as large as `FEE_POOL_TO_REVENUE_POOL_THRESHOLD` if that's bigger than
1456
+ * the tier max), and `quoteMaxInsurance` must be >= the market's already-settled insurance
1457
+ * claim — violating either throws `DefaultError`.
1458
+ * @param perpMarketIndex - Perp market to update.
1459
+ * @param unrealizedMaxImbalance - Cap on unrealized-PnL imbalance eligible for insurance backing, QUOTE_PRECISION (1e6).
1460
+ * @param maxRevenueWithdrawPerPeriod - Cap on revenue-pool withdrawals per settlement period, QUOTE_PRECISION (1e6).
1461
+ * @param quoteMaxInsurance - Lifetime cap on insurance draws for this market, QUOTE_PRECISION (1e6). Must be >= the market's already-settled insurance claim.
1462
+ * @returns Transaction signature.
1463
+ */
197
1464
  updatePerpMarketMaxImbalances(perpMarketIndex: number, unrealizedMaxImbalance: BN, maxRevenueWithdrawPerPeriod: BN, quoteMaxInsurance: BN): Promise<TransactionSignature>;
1465
+ /**
1466
+ * Builds the `updatePerpMarketMaxImbalances` instruction without sending it. See
1467
+ * `updatePerpMarketMaxImbalances`.
1468
+ * @returns The unsigned `updatePerpMarketMaxImbalances` instruction.
1469
+ */
198
1470
  getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex: number, unrealizedMaxImbalance: BN, maxRevenueWithdrawPerPeriod: BN, quoteMaxInsurance: BN): Promise<TransactionInstruction>;
1471
+ /**
1472
+ * Sets a perp market's open-interest cap. Requires warm admin (`check_warm`). Throws
1473
+ * `DefaultError` on-chain unless `maxOpenInterest` is an exact multiple of the market's
1474
+ * `orderStepSize`.
1475
+ * @param perpMarketIndex - Perp market to update.
1476
+ * @param maxOpenInterest - Cap on base-asset open interest, BASE_PRECISION (1e9). Must be a multiple of `orderStepSize`.
1477
+ * @returns Transaction signature.
1478
+ */
199
1479
  updatePerpMarketMaxOpenInterest(perpMarketIndex: number, maxOpenInterest: BN): Promise<TransactionSignature>;
1480
+ /**
1481
+ * Builds the `updatePerpMarketMaxOpenInterest` instruction without sending it. See
1482
+ * `updatePerpMarketMaxOpenInterest`.
1483
+ * @returns The unsigned `updatePerpMarketMaxOpenInterest` instruction.
1484
+ */
200
1485
  getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex: number, maxOpenInterest: BN): Promise<TransactionInstruction>;
1486
+ /**
1487
+ * Directly overwrites a perp market's user-count counters (`numberOfUsers` /
1488
+ * `numberOfUsersWithBase`), used to correct drift from the incrementally-maintained
1489
+ * counters. Requires warm admin (`check_warm`). Either counter can be omitted to leave it
1490
+ * unchanged. On-chain, throws `DefaultError` if the resulting `numberOfUsers <
1491
+ * numberOfUsersWithBase`.
1492
+ * @param perpMarketIndex - Perp market to update.
1493
+ * @param numberOfUsers - New total open-position-or-order user count. Omit to leave unchanged.
1494
+ * @param numberOfUsersWithBase - New count of users with a nonzero base position. Omit to leave unchanged. Must not exceed `numberOfUsers`.
1495
+ * @returns Transaction signature.
1496
+ */
201
1497
  updatePerpMarketNumberOfUser(perpMarketIndex: number, numberOfUsers?: number, numberOfUsersWithBase?: number): Promise<TransactionSignature>;
1498
+ /**
1499
+ * Builds the `updatePerpMarketNumberOfUsers` instruction without sending it. See
1500
+ * `updatePerpMarketNumberOfUser`.
1501
+ * @returns The unsigned `updatePerpMarketNumberOfUsers` instruction.
1502
+ */
202
1503
  getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex: number, numberOfUsers?: number, numberOfUsersWithBase?: number): Promise<TransactionInstruction>;
1504
+ /**
1505
+ * Scales a perp market's taker fee and maker rebate up or down by a percentage of the base
1506
+ * fee tier. Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if
1507
+ * `abs(feeAdjustment) > FEE_ADJUSTMENT_MAX` (100).
1508
+ * @param perpMarketIndex - Perp market to update.
1509
+ * @param feeAdjustment - Percent adjustment applied to the base taker fee / maker rebate, -100..100 (negative reduces, positive increases; 0 = no adjustment).
1510
+ * @returns Transaction signature.
1511
+ */
203
1512
  updatePerpMarketFeeAdjustment(perpMarketIndex: number, feeAdjustment: number): Promise<TransactionSignature>;
1513
+ /**
1514
+ * Builds the `updatePerpMarketFeeAdjustment` instruction without sending it. See
1515
+ * `updatePerpMarketFeeAdjustment`.
1516
+ * @returns The unsigned `updatePerpMarketFeeAdjustment` instruction.
1517
+ */
204
1518
  getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex: number, feeAdjustment: number): Promise<TransactionInstruction>;
1519
+ /**
1520
+ * Sets the retention buffer the streaming fee sweep leaves in a perp market's pnl pool on top
1521
+ * of `max(netUserPnl, 0)` before the IF/AMM-provision drains take their cut (the protocol
1522
+ * drain is exempt and always runs). Requires warm admin (`check_warm`). See
1523
+ * `perp_market.fee_pool_buffer_target`'s doc comment for why the buffer exists (a swept pool
1524
+ * is short on the next adverse oracle tick, and sweeps are a one-way valve).
1525
+ * @param perpMarketIndex - Perp market to update.
1526
+ * @param feePoolBufferTarget - Pnl-pool retention buffer, QUOTE_PRECISION (1e6).
1527
+ * @returns Transaction signature.
1528
+ */
205
1529
  updatePerpMarketFeePoolBufferTarget(perpMarketIndex: number, feePoolBufferTarget: BN): Promise<TransactionSignature>;
1530
+ /**
1531
+ * Builds the `updatePerpMarketFeePoolBufferTarget` instruction without sending it. See
1532
+ * `updatePerpMarketFeePoolBufferTarget`.
1533
+ * @returns The unsigned `updatePerpMarketFeePoolBufferTarget` instruction.
1534
+ */
206
1535
  getUpdatePerpMarketFeePoolBufferTargetIx(perpMarketIndex: number, feePoolBufferTarget: BN): Promise<TransactionInstruction>;
1536
+ /**
1537
+ * Scales a spot market's taker fee and maker rebate up or down by a percentage of the base
1538
+ * fee tier. Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if
1539
+ * `abs(feeAdjustment) > FEE_ADJUSTMENT_MAX` (100). Note: the first parameter is a **spot**
1540
+ * market index despite being named `perpMarketIndex` here.
1541
+ * @param perpMarketIndex - Spot market index to update (misnamed; not a perp market index).
1542
+ * @param feeAdjustment - Percent adjustment applied to the base taker fee / maker rebate, -100..100 (negative reduces, positive increases; 0 = no adjustment).
1543
+ * @returns Transaction signature.
1544
+ */
207
1545
  updateSpotMarketFeeAdjustment(perpMarketIndex: number, feeAdjustment: number): Promise<TransactionSignature>;
1546
+ /**
1547
+ * Builds the `updateSpotMarketFeeAdjustment` instruction without sending it. See
1548
+ * `updateSpotMarketFeeAdjustment`.
1549
+ * @returns The unsigned `updateSpotMarketFeeAdjustment` instruction.
1550
+ */
208
1551
  getUpdateSpotMarketFeeAdjustmentIx(spotMarketIndex: number, feeAdjustment: number): Promise<TransactionInstruction>;
1552
+ /**
1553
+ * Sets the three-way split of a perp market's liquidation fee: the cut paid to the
1554
+ * liquidator, the cut routed to the insurance fund, and the cut kept by the protocol.
1555
+ * Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless
1556
+ * `liquidatorFee + ifLiquidationFee + protocolLiquidationFee < LIQUIDATION_FEE_PRECISION`,
1557
+ * `ifLiquidationFee < LIQUIDATION_FEE_PRECISION`, and `protocolLiquidationFee <=
1558
+ * LIQUIDATION_FEE_PRECISION / 10` (10%); also re-validates `liquidatorFee` against the
1559
+ * market's current margin ratios (`amm.validate_compatible_with_liquidation_fee`).
1560
+ * @param perpMarketIndex - Perp market to update.
1561
+ * @param liquidatorFee - Fee paid to the liquidator, LIQUIDATION_FEE_PRECISION (1e6).
1562
+ * @param ifLiquidationFee - Portion routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6).
1563
+ * @param protocolLiquidationFee - Portion kept by the protocol, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision. Default 0.
1564
+ * @returns Transaction signature.
1565
+ */
209
1566
  updatePerpMarketLiquidationFee(perpMarketIndex: number, liquidatorFee: number, ifLiquidationFee: number, protocolLiquidationFee?: number): Promise<TransactionSignature>;
1567
+ /**
1568
+ * Builds the `updatePerpMarketLiquidationFee` instruction without sending it. See
1569
+ * `updatePerpMarketLiquidationFee`.
1570
+ * @returns The unsigned `updatePerpMarketLiquidationFee` instruction.
1571
+ */
210
1572
  getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex: number, liquidatorFee: number, ifLiquidationFee: number, protocolLiquidationFee?: number): Promise<TransactionInstruction>;
1573
+ /**
1574
+ * Sets the three-way split of a spot market's liquidation fee: the cut paid to the
1575
+ * liquidator, the cut routed to the insurance fund, and the cut kept by the protocol.
1576
+ * Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless
1577
+ * `liquidatorFee + ifLiquidationFee + protocolLiquidationFee < LIQUIDATION_FEE_PRECISION`,
1578
+ * and both `ifLiquidationFee` and `protocolLiquidationFee` are each
1579
+ * <= `LIQUIDATION_FEE_PRECISION / 10` (10%).
1580
+ * @param spotMarketIndex - Spot market to update.
1581
+ * @param liquidatorFee - Fee paid to the liquidator, LIQUIDATION_FEE_PRECISION (1e6).
1582
+ * @param ifLiquidationFee - Portion routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision.
1583
+ * @param protocolLiquidationFee - Portion kept by the protocol, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision. Default 0.
1584
+ * @returns Transaction signature.
1585
+ */
211
1586
  updateSpotMarketLiquidationFee(spotMarketIndex: number, liquidatorFee: number, ifLiquidationFee: number, protocolLiquidationFee?: number): Promise<TransactionSignature>;
1587
+ /**
1588
+ * Builds the `updateSpotMarketLiquidationFee` instruction without sending it. See
1589
+ * `updateSpotMarketLiquidationFee`.
1590
+ * @returns The unsigned `updateSpotMarketLiquidationFee` instruction.
1591
+ */
212
1592
  getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex: number, liquidatorFee: number, ifLiquidationFee: number, protocolLiquidationFee?: number): Promise<TransactionInstruction>;
1593
+ /**
1594
+ * Cold-only. Sets the treasury pubkey that `withdrawProtocolFeesPerp` /
1595
+ * `withdrawProtocolFeesSpot` pay out to. Perp (quote-denominated) and spot
1596
+ * (per-market-token) recipients are independent — `marketType` selects which one
1597
+ * this call updates. Withdrawals for a market type are inert (the fee-withdraw ix
1598
+ * always fails) until its recipient is set to a non-default pubkey.
1599
+ * @param protocolFeeRecipient - New recipient wallet; its ATA (per mint) receives future withdrawals.
1600
+ * @param marketType - Which recipient slot to update, `MarketType.PERP` or `MarketType.SPOT`.
1601
+ * @returns Transaction signature.
1602
+ */
213
1603
  updateProtocolFeeRecipient(protocolFeeRecipient: PublicKey, marketType: MarketType): Promise<TransactionSignature>;
1604
+ /**
1605
+ * Builds the `updateProtocolFeeRecipient` instruction without sending it. See
1606
+ * `updateProtocolFeeRecipient`.
1607
+ * @returns The unsigned `updateProtocolFeeRecipient` instruction.
1608
+ */
214
1609
  getUpdateProtocolFeeRecipientIx(protocolFeeRecipient: PublicKey, marketType: MarketType): Promise<TransactionInstruction>;
1610
+ /**
1611
+ * Withdraws a spot market's accrued protocol fees (lending-interest + spot-liquidation
1612
+ * carveouts, tracked in `spotMarket.protocolFeePool`) from its vault to
1613
+ * `state.protocolFeeRecipientSpot`'s ATA. Requires `HotRole.FeeWithdraw` (cold, warm,
1614
+ * or the configured fee-withdraw hot key) — `this.wallet` must hold that role, since
1615
+ * `getWithdrawProtocolFeesSpotIx` signs as `this.wallet.publicKey` for both `payer`
1616
+ * and `authority`. The recipient ATA is created (`init_if_needed`) if missing. The
1617
+ * withdrawn amount is capped at whatever is actually available, and the vault must
1618
+ * still fully cover depositor backing afterward or the instruction fails.
1619
+ * @param marketIndex - Spot market to withdraw protocol fees from.
1620
+ * @param amount - Requested amount, the market's native token decimals (clamped down to the available balance on-chain).
1621
+ * @param txParams - Optional transaction-building overrides.
1622
+ * @returns Transaction signature.
1623
+ */
215
1624
  withdrawProtocolFeesSpot(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
1625
+ /**
1626
+ * Builds the `withdrawProtocolFeesSpot` instruction without sending it. Also wires
1627
+ * up transfer-hook remaining accounts if the market's mint requires them. See
1628
+ * `withdrawProtocolFeesSpot`.
1629
+ * @returns The unsigned `withdrawProtocolFeesSpot` instruction.
1630
+ */
216
1631
  getWithdrawProtocolFeesSpotIx(marketIndex: number, amount: BN): Promise<TransactionInstruction>;
1632
+ /**
1633
+ * Withdraws a perp market's accrued protocol fees (quote-denominated, tracked in
1634
+ * `perpMarket.protocolFeePool`) from the quote spot market's vault to
1635
+ * `state.protocolFeeRecipientPerp`'s ATA. Requires `HotRole.FeeWithdraw` — see
1636
+ * `withdrawProtocolFeesSpot` for the same signer/ATA/clamping/vault-invariant
1637
+ * behavior (this mirrors it against the perp market's quote-denominated pool
1638
+ * instead of a spot market's own token).
1639
+ * @param marketIndex - Perp market to withdraw protocol fees from.
1640
+ * @param amount - Requested amount, QUOTE_PRECISION (1e6) (clamped down to the available balance on-chain).
1641
+ * @param txParams - Optional transaction-building overrides.
1642
+ * @returns Transaction signature.
1643
+ */
217
1644
  withdrawProtocolFeesPerp(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
1645
+ /**
1646
+ * Builds the `withdrawProtocolFeesPerp` instruction without sending it. Also wires
1647
+ * up transfer-hook remaining accounts if the quote market's mint requires them. See
1648
+ * `withdrawProtocolFeesPerp`.
1649
+ * @returns The unsigned `withdrawProtocolFeesPerp` instruction.
1650
+ */
218
1651
  getWithdrawProtocolFeesPerpIx(marketIndex: number, amount: BN): Promise<TransactionInstruction>;
1652
+ /**
1653
+ * Creates a market-local synthetic "oracle" account (`PrelaunchOracle`) for a perp market
1654
+ * that has no real price feed yet (e.g. a pre-launch/pre-listing market), seeded with an
1655
+ * admin-supplied price. Requires warm admin (`check_warm`). Set the market's `oracle` to
1656
+ * this account's address (via `updatePerpMarketOracle`, with a matching `OracleSource`) to
1657
+ * use it. `PrelaunchOracle::validate` runs at the end of the handler and throws
1658
+ * `InvalidOracle` if `price` or `maxPrice` end up `0` (both are zero-initialized and only
1659
+ * set when the corresponding argument is provided) or if `price > maxPrice` — in practice
1660
+ * both must be supplied and satisfy `price <= maxPrice`.
1661
+ * @param perpMarketIndex - Perp market this oracle backs; fixes the PDA seed.
1662
+ * @param price - Initial synthetic price, PRICE_PRECISION (1e6). Must be nonzero and <= `maxPrice`.
1663
+ * @param maxPrice - Ceiling the price is allowed to move to, PRICE_PRECISION (1e6). Must be nonzero and >= `price`.
1664
+ * @returns Transaction signature.
1665
+ */
219
1666
  initializePrelaunchOracle(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionSignature>;
1667
+ /**
1668
+ * Builds the `initializePrelaunchOracle` instruction without sending it. See
1669
+ * `initializePrelaunchOracle`.
1670
+ * @returns The unsigned `initializePrelaunchOracle` instruction.
1671
+ */
220
1672
  getInitializePrelaunchOracleIx(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionInstruction>;
1673
+ /**
1674
+ * Updates a perp market's `PrelaunchOracle` price and/or ceiling. Requires warm admin
1675
+ * (`check_warm`). If `price` is provided, this **also directly overwrites the perp market's
1676
+ * mark-price TWAPs** (`lastMarkPriceTwap`, `lastMarkPriceTwap5min`, and clamps
1677
+ * `lastBidPriceTwap`/`lastAskPriceTwap` toward the new price) and their timestamp — a much
1678
+ * broader side effect than the field name suggests. `PrelaunchOracle::validate` re-runs at
1679
+ * the end and throws `InvalidOracle` if the resulting `price`/`maxPrice` are `0` or
1680
+ * `price > maxPrice`. Either argument omitted leaves that field (and, for `price`, the TWAPs)
1681
+ * unchanged.
1682
+ * @param perpMarketIndex - Perp market whose prelaunch oracle to update.
1683
+ * @param price - New synthetic price, PRICE_PRECISION (1e6). Also overwrites the market's mark-price TWAPs when provided. Omit to leave unchanged.
1684
+ * @param maxPrice - New price ceiling, PRICE_PRECISION (1e6). Omit to leave unchanged.
1685
+ * @returns Transaction signature.
1686
+ */
221
1687
  updatePrelaunchOracleParams(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionSignature>;
1688
+ /**
1689
+ * Builds the `updatePrelaunchOracleParams` instruction without sending it. See
1690
+ * `updatePrelaunchOracleParams`.
1691
+ * @returns The unsigned `updatePrelaunchOracleParams` instruction.
1692
+ */
222
1693
  getUpdatePrelaunchOracleParamsIx(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionInstruction>;
1694
+ /**
1695
+ * Closes a perp market's `PrelaunchOracle` account and refunds rent to the admin. Requires
1696
+ * warm admin (`check_warm`). On-chain, throws `DefaultError` if the oracle is still the
1697
+ * market's active `oracle` — repoint the market to a different oracle first (via
1698
+ * `updatePerpMarketOracle`).
1699
+ *
1700
+ * **Currently broken**: `getDeletePrelaunchOracleIx` builds a `PrelaunchOracleParams`-shaped
1701
+ * object (`{ perpMarketIndex, price, maxPrice }`) as the instruction argument, but the
1702
+ * on-chain `deletePrelaunchOracle` instruction (and its IDL) takes a single `u16`
1703
+ * `perpMarketIndex` scalar, not that object — this throws when the Borsh encoder tries to
1704
+ * serialize an object where a `u16` is expected.
1705
+ * @param perpMarketIndex - Perp market whose prelaunch oracle to delete; must not be the market's current oracle.
1706
+ * @returns Transaction signature (in practice: throws before a transaction is built).
1707
+ */
223
1708
  deletePrelaunchOracle(perpMarketIndex: number): Promise<TransactionSignature>;
1709
+ /**
1710
+ * Builds the (currently broken) `deletePrelaunchOracle` instruction. See
1711
+ * `deletePrelaunchOracle` — throws because the argument shape doesn't match the IDL's `u16`.
1712
+ * `price`/`maxPrice` are accepted but unused; the underlying call never reads them.
1713
+ * @returns Never resolves successfully; throws when the malformed instruction args are encoded.
1714
+ */
224
1715
  getDeletePrelaunchOracleIx(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionInstruction>;
1716
+ /**
1717
+ * Overrides how many slots of oracle delay a perp market tolerates before its "low-risk"
1718
+ * oracle-staleness check (`OracleValidity`'s `is_stale_for_amm_low_risk`, consumed by margin
1719
+ * calculations, order fills, AMM repeg/refresh, and the AMM cache) trips. Gated on
1720
+ * `HotAdminUpdatePerpMarket`, whose account constraint is actually `check_warm` — this
1721
+ * requires **warm** admin (or cold), not a dedicated hot key, despite the struct's name.
1722
+ * `0` (the default) means no override — the market falls back to the global
1723
+ * `state.oracleGuardRails.validity.slotsBeforeStaleForAmm`; a nonzero value is clamped to
1724
+ * `>= 0` and used as the slot threshold directly.
1725
+ * @param perpMarketIndex - Perp market to update.
1726
+ * @param oracleLowRiskSlotDelayOverride - Slots of oracle delay tolerated for low-risk AMM actions before staleness trips. `0` = use the global default; negative values are treated as `0`.
1727
+ * @returns Transaction signature.
1728
+ */
225
1729
  updatePerpMarketOracleLowRiskSlotDelayOverride(perpMarketIndex: number, oracleLowRiskSlotDelayOverride: number): Promise<TransactionSignature>;
1730
+ /**
1731
+ * Builds the `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction without sending it.
1732
+ * See `updatePerpMarketOracleLowRiskSlotDelayOverride`.
1733
+ * @returns The unsigned `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction.
1734
+ */
226
1735
  getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(perpMarketIndex: number, oracleLowRiskSlotDelayOverride: number): Promise<TransactionInstruction>;
1736
+ /**
1737
+ * Overrides how many slots of oracle delay a perp market tolerates before its "immediate"
1738
+ * per-fill staleness check trips (used for AMM-immediate fills; the on-chain field is
1739
+ * `perpMarket.oracleSlotDelayOverride`, default `-1`). Gated on `HotAdminUpdatePerpMarket`,
1740
+ * whose account constraint is actually `check_warm` — this requires **warm** admin (or
1741
+ * cold), not a dedicated hot key. `0` means the market is always treated as stale for
1742
+ * immediate AMM actions; any other value is clamped to `>= 0` and used as the slot threshold
1743
+ * (delay > threshold is stale).
1744
+ * @param perpMarketIndex - Perp market to update.
1745
+ * @param oracleSlotDelay - Slots of oracle delay tolerated before the immediate-fill staleness check trips. `0` = always stale; negative input is clamped to `0` on-chain.
1746
+ * @returns Transaction signature.
1747
+ */
227
1748
  updatePerpMarketOracleSlotDelayOverride(perpMarketIndex: number, oracleSlotDelay: number): Promise<TransactionSignature>;
1749
+ /**
1750
+ * Builds the `updatePerpMarketOracleSlotDelayOverride` instruction without sending it. See
1751
+ * `updatePerpMarketOracleSlotDelayOverride`.
1752
+ * @returns The unsigned `updatePerpMarketOracleSlotDelayOverride` instruction.
1753
+ */
228
1754
  getUpdatePerpMarketOracleSlotDelayOverrideIx(perpMarketIndex: number, oracleSlotDelay: number): Promise<TransactionInstruction>;
1755
+ /**
1756
+ * Sets a perp market's manual spread-widening scalars. Gated on `HotAdminUpdatePerpMarket`,
1757
+ * whose account constraint is actually `check_warm` — this requires **warm** admin (or
1758
+ * cold), not a dedicated hot key. **`referencePriceOffset` is accepted for wire/IDL
1759
+ * compatibility but ignored on-chain** — `amm.referencePriceOffset` is a per-crank output
1760
+ * recomputed from inventory and market stats by
1761
+ * `crate::vlp::amm::math::spread::update_amm_quote_state`, not an admin-settable value; pass
1762
+ * any value.
1763
+ * @param perpMarketIndex - Perp market to update.
1764
+ * @param ammSpreadAdjustment - Signed scalar on the AMM's base spread, same convention as `fee_adjustment` (-100 = spread scaled to 0, 100 = spread doubled, 0 = no adjustment).
1765
+ * @param ammInventorySpreadAdjustment - Signed scalar on the inventory-skew component of the spread, same -100..100 convention.
1766
+ * @param referencePriceOffset - Ignored on-chain; retained only for instruction-argument compatibility.
1767
+ * @returns Transaction signature.
1768
+ */
229
1769
  updatePerpMarketAmmSpreadAdjustment(perpMarketIndex: number, ammSpreadAdjustment: number, ammInventorySpreadAdjustment: number, referencePriceOffset: number): Promise<TransactionSignature>;
1770
+ /**
1771
+ * Builds the `updatePerpMarketAmmSpreadAdjustment` instruction without sending it. See
1772
+ * `updatePerpMarketAmmSpreadAdjustment`.
1773
+ * @returns The unsigned `updatePerpMarketAmmSpreadAdjustment` instruction.
1774
+ */
230
1775
  getUpdatePerpMarketAmmSpreadAdjustmentIx(perpMarketIndex: number, ammSpreadAdjustment: number, ammInventorySpreadAdjustment: number, referencePriceOffset: number): Promise<TransactionInstruction>;
1776
+ /**
1777
+ * Sets how much a perp market's paying-side spread widens while the vAMM's inventory is
1778
+ * paying funding: `amm.fundingBiasSensitivity = s` gives multiplier `β(f) = 1 + s/100 * ρ(f)`
1779
+ * (at full ramp, `ρ = 1`: 50 -> 1.5x, 100 -> 2x). Gated on `HotAdminUpdatePerpMarket`, whose
1780
+ * account constraint is actually `check_warm` — this requires **warm** admin (or cold), not
1781
+ * a dedicated hot key.
1782
+ * @param perpMarketIndex - Perp market to update.
1783
+ * @param fundingBiasSensitivity - Sensitivity `s`, in hundredths (value/100 is the multiplier slope); `0` disables the bias. `u8` range caps `s` at 2.55.
1784
+ * @returns Transaction signature.
1785
+ */
231
1786
  updatePerpMarketFundingBiasSensitivity(perpMarketIndex: number, fundingBiasSensitivity: number): Promise<TransactionSignature>;
1787
+ /**
1788
+ * Builds the `updatePerpMarketFundingBiasSensitivity` instruction without sending it. See
1789
+ * `updatePerpMarketFundingBiasSensitivity`.
1790
+ * @returns The unsigned `updatePerpMarketFundingBiasSensitivity` instruction.
1791
+ */
232
1792
  getUpdatePerpMarketFundingBiasSensitivityIx(perpMarketIndex: number, fundingBiasSensitivity: number): Promise<TransactionInstruction>;
1793
+ /**
1794
+ * Creates the zero'd `PythLazerOracle` PDA for a Pyth Lazer feed id (one-time setup
1795
+ * before that feed can be pushed to via `updatePythLazerOracle`/keeper cranks).
1796
+ * Requires warm admin (`check_warm`, `InitPythLazerOracle` context). Idempotent per
1797
+ * `feedId` — a second call for the same id fails (`init` on an existing PDA).
1798
+ * @param feedId - Pyth Lazer feed id; seeds the `PythLazerOracle` PDA (`getPythLazerOraclePublicKey`).
1799
+ * @returns Transaction signature.
1800
+ */
233
1801
  initializePythLazerOracle(feedId: number): Promise<TransactionSignature>;
1802
+ /**
1803
+ * Builds the `initializePythLazerOracle` instruction without sending it. See
1804
+ * `initializePythLazerOracle`.
1805
+ * @returns The unsigned `initializePythLazerOracle` instruction.
1806
+ */
234
1807
  getInitializePythLazerOracleIx(feedId: number): Promise<TransactionInstruction>;
1808
+ /**
1809
+ * Deposits tokens from an admin-controlled token account directly into a user's
1810
+ * spot balance, recorded as a `DepositExplanation.Reward` deposit (e.g. crediting a
1811
+ * promotional/reward balance without the user signing). Requires
1812
+ * `HotRole.VaultDeposit` (cold, warm, or the configured vault-deposit hot key) —
1813
+ * `this.wallet` signs as `admin` and must hold that role.
1814
+ * @param marketIndex - Spot market to deposit into.
1815
+ * @param amount - Deposit amount, the market's native token decimals.
1816
+ * @param depositUserAccount - User account (`User` PDA pubkey) to credit.
1817
+ * @param adminTokenAccount - Source token account (must belong to `this.wallet`). Defaults to `this.wallet`'s associated token account for the market's mint.
1818
+ * @returns Transaction signature.
1819
+ */
235
1820
  adminDeposit(marketIndex: number, amount: BN, depositUserAccount: PublicKey, adminTokenAccount?: PublicKey): Promise<TransactionSignature>;
1821
+ /**
1822
+ * Builds the `adminDeposit` instruction without sending it. Also wires up the
1823
+ * mint and transfer-hook remaining accounts the deposit needs. See `adminDeposit`.
1824
+ * @returns The unsigned `adminDeposit` instruction.
1825
+ */
236
1826
  getAdminDepositIx(marketIndex: number, amount: BN, depositUserAccount: PublicKey, adminTokenAccount?: PublicKey): Promise<TransactionInstruction>;
1827
+ /**
1828
+ * Resets a perp market's push-oracle ("MM oracle") state — `marketStats.mmOraclePrice`,
1829
+ * `mmOracleSequenceId`, and `mmOracleSlot` — all to `0`. Requires warm admin (the
1830
+ * `HotAdminUpdatePerpMarket` context's `check_warm` constraint — despite the name,
1831
+ * no dedicated hot role is wired to it; see `updatePerpMarketCurveUpdateIntensity`
1832
+ * for the same gate). Use to force the next `updateMmOracleNative` push to be
1833
+ * treated as a fresh bootstrap (its step-size cap is skipped when the previous
1834
+ * price is `0`).
1835
+ * @param marketIndex - Perp market whose MM oracle fields to zero.
1836
+ * @returns Transaction signature.
1837
+ */
237
1838
  zeroMMOracleFields(marketIndex: number): Promise<TransactionSignature>;
1839
+ /**
1840
+ * Builds the `zeroMMOracleFields` instruction without sending it. See
1841
+ * `zeroMMOracleFields`.
1842
+ * @returns The unsigned `zeroMmOracleFields` instruction.
1843
+ */
238
1844
  getZeroMMOracleFieldsIx(marketIndex: number): Promise<TransactionInstruction>;
1845
+ /**
1846
+ * Toggles the `FeatureBitFlags.MM_ORACLE_UPDATE` bit on `state.featureBitFlags`,
1847
+ * which gates the native (non-Anchor) `updateMmOracleNative` push-oracle
1848
+ * dispatch — the on-chain handler asserts this bit before accepting a push.
1849
+ * Requires `HotRole.FeatureFlag` (`HotAdminUpdateState`'s `check_hot`) to disable,
1850
+ * but **enabling requires `state.coldAdmin` specifically** — the handler rejects
1851
+ * `enable: true` from any other signer, even one otherwise authorised for the
1852
+ * `FeatureFlag` role, so a compromised feature-flag hot key can only trip this
1853
+ * kill switch, never clear it.
1854
+ * @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
1855
+ * @returns Transaction signature.
1856
+ */
239
1857
  updateFeatureBitFlagsMMOracle(enable: boolean): Promise<TransactionSignature>;
1858
+ /**
1859
+ * Builds the `updateFeatureBitFlagsMMOracle` instruction without sending it. See
1860
+ * `updateFeatureBitFlagsMMOracle`.
1861
+ * @returns The unsigned `updateFeatureBitFlagsMmOracle` instruction.
1862
+ */
240
1863
  getUpdateFeatureBitFlagsMMOracleIx(enable: boolean): Promise<TransactionInstruction>;
1864
+ /**
1865
+ * Toggles the `FeatureBitFlags.BUILDER_CODES` bit on `state.featureBitFlags`
1866
+ * (gates builder-code fee-attribution instructions protocol-wide). Same
1867
+ * kill-switch gating as `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may
1868
+ * disable, only `coldAdmin` may enable.
1869
+ * @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
1870
+ * @returns Transaction signature.
1871
+ */
241
1872
  updateFeatureBitFlagsBuilderCodes(enable: boolean): Promise<TransactionSignature>;
1873
+ /**
1874
+ * Builds the `updateFeatureBitFlagsBuilderCodes` instruction without sending it.
1875
+ * See `updateFeatureBitFlagsBuilderCodes`.
1876
+ * @returns The unsigned `updateFeatureBitFlagsBuilderCodes` instruction.
1877
+ */
242
1878
  getUpdateFeatureBitFlagsBuilderCodesIx(enable: boolean): Promise<TransactionInstruction>;
1879
+ /**
1880
+ * @deprecated There is no `BuilderReferral` bit in the on-chain `FeatureBitFlags`
1881
+ * enum (only `MmOracleUpdate`, `MedianTriggerPrice`, `BuilderCodes` exist) and no
1882
+ * `update_feature_bit_flags_builder_referral` instruction is defined in the
1883
+ * program or present in the IDL. Calling this (or
1884
+ * `getUpdateFeatureBitFlagsBuilderReferralIx`) throws at runtime — hence the
1885
+ * `as any` cast on `this.program.instruction` used to bypass the TS type check.
1886
+ * Do not call until (and unless) a matching on-chain instruction ships.
1887
+ * @param enable - Intended flag state (unused while dead).
1888
+ * @returns Transaction signature (never reached).
1889
+ */
243
1890
  updateFeatureBitFlagsBuilderReferral(enable: boolean): Promise<TransactionSignature>;
1891
+ /**
1892
+ * @deprecated See `updateFeatureBitFlagsBuilderReferral` — no matching instruction
1893
+ * exists on-chain or in the IDL; this throws at runtime.
1894
+ * @returns Never resolves successfully.
1895
+ */
244
1896
  getUpdateFeatureBitFlagsBuilderReferralIx(enable: boolean): Promise<TransactionInstruction>;
1897
+ /**
1898
+ * Toggles the `FeatureBitFlags.MEDIAN_TRIGGER_PRICE` bit on
1899
+ * `state.featureBitFlags` (gates using a median of price sources for trigger-order
1900
+ * evaluation). Same kill-switch gating as `updateFeatureBitFlagsMMOracle`:
1901
+ * `HotRole.FeatureFlag` may disable, only `coldAdmin` may enable.
1902
+ * @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
1903
+ * @returns Transaction signature.
1904
+ */
245
1905
  updateFeatureBitFlagsMedianTriggerPrice(enable: boolean): Promise<TransactionSignature>;
1906
+ /**
1907
+ * Builds the `updateFeatureBitFlagsMedianTriggerPrice` instruction without sending
1908
+ * it. See `updateFeatureBitFlagsMedianTriggerPrice`.
1909
+ * @returns The unsigned `updateFeatureBitFlagsMedianTriggerPrice` instruction.
1910
+ */
246
1911
  getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable: boolean): Promise<TransactionInstruction>;
1912
+ /**
1913
+ * Toggles the `LpPoolFeatureBitFlags.SettleLpPool`-equivalent bit on
1914
+ * `state.lpPoolFeatureBitFlags` (gates `settlePerpToLpPool`/LP-pool settlement
1915
+ * protocol-wide). Same kill-switch gating as `updateFeatureBitFlagsMMOracle`:
1916
+ * `HotRole.FeatureFlag` may disable, only `coldAdmin` may enable.
1917
+ * @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
1918
+ * @returns Transaction signature.
1919
+ */
247
1920
  updateFeatureBitFlagsSettleLpPool(enable: boolean): Promise<TransactionSignature>;
1921
+ /**
1922
+ * Builds the `updateFeatureBitFlagsSettleLpPool` instruction without sending it.
1923
+ * See `updateFeatureBitFlagsSettleLpPool`.
1924
+ * @returns The unsigned `updateFeatureBitFlagsSettleLpPool` instruction.
1925
+ */
248
1926
  getUpdateFeatureBitFlagsSettleLpPoolIx(enable: boolean): Promise<TransactionInstruction>;
1927
+ /**
1928
+ * Toggles the LP-pool swap-enabled bit on `state.lpPoolFeatureBitFlags` (gates
1929
+ * `lpPoolSwap`/begin-end swap flows protocol-wide). Same kill-switch gating as
1930
+ * `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may disable, only
1931
+ * `coldAdmin` may enable.
1932
+ * @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
1933
+ * @returns Transaction signature.
1934
+ */
249
1935
  updateFeatureBitFlagsSwapLpPool(enable: boolean): Promise<TransactionSignature>;
1936
+ /**
1937
+ * Builds the `updateFeatureBitFlagsSwapLpPool` instruction without sending it. See
1938
+ * `updateFeatureBitFlagsSwapLpPool`.
1939
+ * @returns The unsigned `updateFeatureBitFlagsSwapLpPool` instruction.
1940
+ */
250
1941
  getUpdateFeatureBitFlagsSwapLpPoolIx(enable: boolean): Promise<TransactionInstruction>;
1942
+ /**
1943
+ * Toggles the LP-pool mint/redeem-enabled bit on `state.lpPoolFeatureBitFlags`
1944
+ * (gates `lpPoolAddLiquidity`/`lpPoolRemoveLiquidity` protocol-wide). Same
1945
+ * kill-switch gating as `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may
1946
+ * disable, only `coldAdmin` may enable.
1947
+ * @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
1948
+ * @returns Transaction signature.
1949
+ */
251
1950
  updateFeatureBitFlagsMintRedeemLpPool(enable: boolean): Promise<TransactionSignature>;
1951
+ /**
1952
+ * Builds the `updateFeatureBitFlagsMintRedeemLpPool` instruction without sending
1953
+ * it. See `updateFeatureBitFlagsMintRedeemLpPool`.
1954
+ * @returns The unsigned `updateFeatureBitFlagsMintRedeemLpPool` instruction.
1955
+ */
252
1956
  getUpdateFeatureBitFlagsMintRedeemLpPoolIx(enable: boolean): Promise<TransactionInstruction>;
1957
+ /**
1958
+ * Sets a user's `UserStats.pausedOperations` bitmask. Reachable by cold, warm,
1959
+ * `HotRole.UserFlag`, or `pauseAdmin` (`PauseAdminUpdateUserStats`'s constraint
1960
+ * ORs `check_pause` with `check_hot(.., UserFlag)`). A caller authorised only via
1961
+ * `pauseAdmin` (i.e. not cold/warm/`UserFlag`) may add pause bits but never clear
1962
+ * one; cold/warm/`UserFlag` may set any value. The `admin` account below defaults
1963
+ * to `coldAdmin`; other roles must override it with their own pubkey.
1964
+ * @param authority - Wallet authority whose `UserStats` PDA to update (derives the PDA).
1965
+ * @param pausedOperations - New pause bitmask for the user's stats account.
1966
+ * @returns Transaction signature.
1967
+ */
253
1968
  adminUpdateUserStatsPausedOperations(authority: PublicKey, pausedOperations: number): Promise<TransactionSignature>;
1969
+ /**
1970
+ * Builds the `adminUpdateUserStatsPausedOperations` instruction without sending
1971
+ * it. See `adminUpdateUserStatsPausedOperations`.
1972
+ * @returns The unsigned `adminUpdateUserStatsPausedOperations` instruction.
1973
+ */
254
1974
  getAdminUpdateUserStatsPausedOperationsIx(authority: PublicKey, pausedOperations: number): Promise<TransactionInstruction>;
1975
+ /**
1976
+ * Creates a new LP pool: mints its 6-decimal LP-token mint (fresh `mint` keypair,
1977
+ * mint authority set to the `lpPool` PDA), then initializes the `LPPool` account
1978
+ * plus its (initially empty) `AmmConstituentMapping`, `ConstituentTargetBase`, and
1979
+ * `ConstituentCorrelations` side accounts. Requires warm admin (`check_warm`).
1980
+ * Constituents (backing spot-market assets) are added afterward via
1981
+ * `initializeConstituent`.
1982
+ * @param lpPoolId - New pool's id byte; seeds the `LPPool` PDA (`getLpPoolPublicKey`).
1983
+ * @param minMintFee - Minimum fee floor charged on mint, signed, PERCENTAGE_PRECISION (1e6).
1984
+ * @param maxAum - AUM cap above which minting new LP tokens is rejected, QUOTE_PRECISION (1e6).
1985
+ * @param maxSettleQuoteAmountPerMarket - Per-perp-market cap on quote settled into/out of the pool per settlement, QUOTE_PRECISION (1e6).
1986
+ * @param mint - Fresh keypair for the pool's LP-token mint; funded and initialized by this call, and must co-sign.
1987
+ * @param whitelistMint - Optional token that gates who may mint/redeem this pool's LP token (see `updateLpPoolParams`). Defaults to `PublicKey.default` (no gating).
1988
+ * @returns Transaction signature.
1989
+ */
255
1990
  initializeLpPool(lpPoolId: number, minMintFee: BN, maxAum: BN, maxSettleQuoteAmountPerMarket: BN, mint: Keypair, whitelistMint?: PublicKey): Promise<TransactionSignature>;
1991
+ /**
1992
+ * Builds the `createAccount` + `initializeMint2` + `initializeLpPool` instructions
1993
+ * without sending them. See `initializeLpPool`.
1994
+ * @returns The unsigned instructions (mint account creation, mint init, pool init) in order; `mint` must also sign the transaction.
1995
+ */
256
1996
  getInitializeLpPoolIx(lpPoolId: number, minMintFee: BN, maxAum: BN, maxSettleQuoteAmountPerMarket: BN, mint: Keypair, whitelistMint?: PublicKey): Promise<TransactionInstruction[]>;
1997
+ /**
1998
+ * Adds a new constituent (backing spot-market asset) to an existing LP pool:
1999
+ * creates its `Constituent` PDA + token vault, appends a slot to
2000
+ * `ConstituentTargetBase`, and records its correlation row in
2001
+ * `ConstituentCorrelations`. Requires warm admin (`check_warm`). On-chain,
2002
+ * `newConstituentCorrelations`'s length must equal the pool's current constituent
2003
+ * count *before* this call (one correlation entry per existing constituent); the
2004
+ * new constituent's `constituentIndex` is assigned as the next sequential index.
2005
+ * @param lpPoolId - Target LP pool's id byte.
2006
+ * @param initializeConstituentParams - Constituent configuration; see `InitializeConstituentParams` for per-field precision.
2007
+ * @returns Transaction signature.
2008
+ */
257
2009
  initializeConstituent(lpPoolId: number, initializeConstituentParams: InitializeConstituentParams): Promise<TransactionSignature>;
2010
+ /**
2011
+ * Builds the `initializeConstituent` instruction without sending it. See
2012
+ * `initializeConstituent`.
2013
+ * @returns The unsigned `initializeConstituent` instruction, as a single-element array.
2014
+ */
258
2015
  getInitializeConstituentIx(lpPoolId: number, initializeConstituentParams: InitializeConstituentParams): Promise<TransactionInstruction[]>;
2016
+ /**
2017
+ * Sets an LP-pool constituent's lifecycle `status` (`ConstituentStatus`: `ACTIVE`,
2018
+ * `REDUCE_ONLY`, or `DECOMMISSIONED`). Requires warm admin (`check_warm`).
2019
+ * `REDUCE_ONLY` restricts flows to only shrink the constituent toward its target
2020
+ * weight; `DECOMMISSIONED` marks it as having no remaining participants.
2021
+ * @param constituent - Constituent PDA to update.
2022
+ * @param constituentStatus - New status.
2023
+ * @returns Transaction signature.
2024
+ */
259
2025
  updateConstituentStatus(constituent: PublicKey, constituentStatus: ConstituentStatus): Promise<TransactionSignature>;
2026
+ /**
2027
+ * Builds the `updateConstituentStatus` instruction without sending it. See
2028
+ * `updateConstituentStatus`.
2029
+ * @returns The unsigned `updateConstituentStatus` instruction.
2030
+ */
260
2031
  getUpdateConstituentStatusIx(constituent: PublicKey, constituentStatus: ConstituentStatus): Promise<TransactionInstruction>;
2032
+ /**
2033
+ * Sets an LP-pool constituent's `pausedOperations` bitmask (`ConstituentLpOperation`:
2034
+ * `Swap`/`Deposit`/`Withdraw`). Requires warm admin (`check_warm`) — despite the
2035
+ * `useHotWalletAdmin` flag name used for the default `admin` account below, no
2036
+ * dedicated hot role exists for this ix; the signer must be cold or warm.
2037
+ * @param constituent - Constituent PDA to update.
2038
+ * @param pausedOperations - New pause bitmask, `ConstituentLpOperation` bit values.
2039
+ * @returns Transaction signature.
2040
+ */
261
2041
  updateConstituentPausedOperations(constituent: PublicKey, pausedOperations: number): Promise<TransactionSignature>;
2042
+ /**
2043
+ * Builds the `updateConstituentPausedOperations` instruction without sending it.
2044
+ * See `updateConstituentPausedOperations`.
2045
+ * @returns The unsigned `updateConstituentPausedOperations` instruction.
2046
+ */
262
2047
  getUpdateConstituentPausedOperationsIx(constituent: PublicKey, pausedOperations: number): Promise<TransactionInstruction>;
2048
+ /**
2049
+ * Patches an LP-pool constituent's tunable params — each field is optional and
2050
+ * only the ones provided overwrite the on-chain value (see `ConstituentAccount`
2051
+ * for per-field precision, which matches these params 1:1). Requires warm admin
2052
+ * (`check_warm`); the underlying ix builder resolves `admin` as `this.wallet`
2053
+ * directly (no cold/warm fallback), so `this.wallet` must itself hold that role.
2054
+ * @param lpPoolId - Constituent's parent LP pool id byte.
2055
+ * @param constituentPublicKey - Constituent PDA to patch.
2056
+ * @param updateConstituentParams - Partial param patch; unset fields are left unchanged. `costToTradeBps` is bps and lives on the pool's `ConstituentTargetBase`, not the `Constituent` account itself.
2057
+ * @returns Transaction signature.
2058
+ */
263
2059
  updateConstituentParams(lpPoolId: number, constituentPublicKey: PublicKey, updateConstituentParams: {
264
2060
  maxWeightDeviation?: BN;
265
2061
  swapFeeMin?: BN;
@@ -274,6 +2070,15 @@ export declare class AdminClient extends VelocityClient {
274
2070
  gammaInventory?: number;
275
2071
  xi?: number;
276
2072
  }): Promise<TransactionSignature>;
2073
+ /**
2074
+ * Builds the `updateConstituentParams` instruction without sending it. Note this
2075
+ * method's parameter type omits `costToTradeBps` even though the public
2076
+ * `updateConstituentParams` wrapper's type includes it and forwards it through
2077
+ * unchanged at runtime — call via `updateConstituentParams` (or add the field
2078
+ * manually) if you need to set it while calling this builder directly. See
2079
+ * `updateConstituentParams`.
2080
+ * @returns The unsigned `updateConstituentParams` instruction, as a single-element array.
2081
+ */
277
2082
  getUpdateConstituentParamsIx(lpPoolId: number, constituentPublicKey: PublicKey, updateConstituentParams: {
278
2083
  maxWeightDeviation?: BN;
279
2084
  swapFeeMin?: BN;
@@ -287,6 +2092,15 @@ export declare class AdminClient extends VelocityClient {
287
2092
  gammaInventory?: number;
288
2093
  xi?: number;
289
2094
  }): Promise<TransactionInstruction[]>;
2095
+ /**
2096
+ * Patches an LP pool's tunable params — each field is optional and only the ones
2097
+ * provided overwrite the on-chain value. Requires warm admin (`check_warm`). If
2098
+ * `maxAum` is provided, on-chain validation rejects lowering it below the pool's
2099
+ * current `maxAum` (the cap may only be raised via this ix).
2100
+ * @param lpPoolId - Target LP pool's id byte.
2101
+ * @param updateLpPoolParams - Partial param patch; unset fields are left unchanged. `maxSettleQuoteAmount` and `maxAum` are QUOTE_PRECISION (1e6); `volatility` is PERCENTAGE_PRECISION (1e6); `whitelistMint` gates who may mint/redeem the pool's LP token.
2102
+ * @returns Transaction signature.
2103
+ */
290
2104
  updateLpPoolParams(lpPoolId: number, updateLpPoolParams: {
291
2105
  maxSettleQuoteAmount?: BN;
292
2106
  volatility?: BN;
@@ -295,6 +2109,11 @@ export declare class AdminClient extends VelocityClient {
295
2109
  whitelistMint?: PublicKey;
296
2110
  maxAum?: BN;
297
2111
  }): Promise<TransactionSignature>;
2112
+ /**
2113
+ * Builds the `updateLpPoolParams` instruction without sending it. See
2114
+ * `updateLpPoolParams`.
2115
+ * @returns The unsigned `updateLpPoolParams` instruction, as a single-element array.
2116
+ */
298
2117
  getUpdateLpPoolParamsIx(lpPoolId: number, updateLpPoolParams: {
299
2118
  maxSettleQuoteAmount?: BN;
300
2119
  volatility?: BN;
@@ -303,13 +2122,75 @@ export declare class AdminClient extends VelocityClient {
303
2122
  whitelistMint?: PublicKey;
304
2123
  maxAum?: BN;
305
2124
  }): Promise<TransactionInstruction[]>;
2125
+ /**
2126
+ * Adds new (perp market, constituent) weight entries to an LP pool's
2127
+ * `AmmConstituentMapping` — routing that fraction of the perp market's hedge flow
2128
+ * into the given constituent. Requires warm admin (`check_warm`). On-chain,
2129
+ * inserting a `(perpMarketIndex, constituentIndex)` pair that already exists fails
2130
+ * (`InvalidAmmConstituentMappingArgument`) — use `updateAmmConstituentMappingData`
2131
+ * to change an existing entry's weight instead.
2132
+ * @param lpPoolId - Target LP pool's id byte.
2133
+ * @param addAmmConstituentMappingData - New entries to add; see `AddAmmConstituentMappingDatum` (`weight` is PERCENTAGE_PRECISION, 1e6).
2134
+ * @returns Transaction signature.
2135
+ */
306
2136
  addAmmConstituentMappingData(lpPoolId: number, addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]): Promise<TransactionSignature>;
2137
+ /**
2138
+ * Builds the `addAmmConstituentMappingData` instruction without sending it (the
2139
+ * `as any` cast works around a generated-type mismatch, not a missing on-chain
2140
+ * instruction — `add_amm_constituent_mapping_data` is present in the IDL). See
2141
+ * `addAmmConstituentMappingData`.
2142
+ * @returns The unsigned `addAmmConstituentMappingData` instruction, as a single-element array.
2143
+ */
307
2144
  getAddAmmConstituentMappingDataIx(lpPoolId: number, addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]): Promise<TransactionInstruction[]>;
2145
+ /**
2146
+ * Updates the weight (and refreshes `lastSlot`) of existing entries in an LP
2147
+ * pool's `AmmConstituentMapping`. Requires warm admin (`check_warm`). On-chain,
2148
+ * every `(perpMarketIndex, constituentIndex)` pair must already exist — an unknown
2149
+ * pair fails with `InvalidAmmConstituentMappingArgument` (use
2150
+ * `addAmmConstituentMappingData` to create new entries).
2151
+ * @param lpPoolId - Target LP pool's id byte.
2152
+ * @param addAmmConstituentMappingData - Entries to update in place; see `AddAmmConstituentMappingDatum` (`weight` is PERCENTAGE_PRECISION, 1e6).
2153
+ * @returns Transaction signature.
2154
+ */
308
2155
  updateAmmConstituentMappingData(lpPoolId: number, addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]): Promise<TransactionSignature>;
2156
+ /**
2157
+ * Builds the `updateAmmConstituentMappingData` instruction without sending it. See
2158
+ * `updateAmmConstituentMappingData`.
2159
+ * @returns The unsigned `updateAmmConstituentMappingData` instruction, as a single-element array.
2160
+ */
309
2161
  getUpdateAmmConstituentMappingDataIx(lpPoolId: number, addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]): Promise<TransactionInstruction[]>;
2162
+ /**
2163
+ * Removes a single `(perpMarketIndex, constituentIndex)` entry from an LP pool's
2164
+ * `AmmConstituentMapping`. Requires warm admin (`check_warm`). Fails
2165
+ * (`InvalidAmmConstituentMappingArgument`) if no matching entry exists.
2166
+ * @param lpPoolId - Target LP pool's id byte.
2167
+ * @param perpMarketIndex - Perp market side of the entry to remove.
2168
+ * @param constituentIndex - Constituent side of the entry to remove.
2169
+ * @returns Transaction signature.
2170
+ */
310
2171
  removeAmmConstituentMappingData(lpPoolId: number, perpMarketIndex: number, constituentIndex: number): Promise<TransactionSignature>;
2172
+ /**
2173
+ * Builds the `removeAmmConstituentMappingData` instruction without sending it. See
2174
+ * `removeAmmConstituentMappingData`.
2175
+ * @returns The unsigned `removeAmmConstituentMappingData` instruction, as a single-element array.
2176
+ */
311
2177
  getRemoveAmmConstituentMappingDataIx(lpPoolId: number, perpMarketIndex: number, constituentIndex: number): Promise<TransactionInstruction[]>;
2178
+ /**
2179
+ * Sets the correlation between two constituents in an LP pool's
2180
+ * `ConstituentCorrelations` matrix (symmetric — updates both `(index1, index2)`
2181
+ * and `(index2, index1)`). Requires warm admin (`check_warm`).
2182
+ * @param lpPoolId - Target LP pool's id byte.
2183
+ * @param index1 - First constituent's index.
2184
+ * @param index2 - Second constituent's index.
2185
+ * @param correlation - New correlation, PERCENTAGE_PRECISION (1e6), signed.
2186
+ * @returns Transaction signature.
2187
+ */
312
2188
  updateConstituentCorrelationData(lpPoolId: number, index1: number, index2: number, correlation: BN): Promise<TransactionSignature>;
2189
+ /**
2190
+ * Builds the `updateConstituentCorrelationData` instruction without sending it.
2191
+ * See `updateConstituentCorrelationData`.
2192
+ * @returns The unsigned `updateConstituentCorrelationData` instruction, as a single-element array.
2193
+ */
313
2194
  getUpdateConstituentCorrelationDataIx(lpPoolId: number, index1: number, index2: number, correlation: BN): Promise<TransactionInstruction[]>;
314
2195
  /**
315
2196
  * Get the velocity begin_swap and end_swap instructions
@@ -337,6 +2218,24 @@ export declare class AdminClient extends VelocityClient {
337
2218
  beginSwapIx: TransactionInstruction;
338
2219
  endSwapIx: TransactionInstruction;
339
2220
  }>;
2221
+ /**
2222
+ * Builds a flash-loan-style LP-pool swap that routes the actual trade through
2223
+ * Jupiter: wraps a Jupiter swap quote/instruction set between the same
2224
+ * `beginLpSwap`/`endLpSwap` instruction pair `getSwapIx` uses, so the LP pool's
2225
+ * constituent vaults temporarily fund the swap and are repaid by the end of the
2226
+ * transaction (`endLpSwap` fails if the constituents aren't made whole). Fetches
2227
+ * a quote from `jupiterClient` if one isn't passed in.
2228
+ * @param jupiterClient - Jupiter client used to fetch the quote/swap transaction and lookup tables.
2229
+ * @param outMarketIndex - Spot market of the token being bought.
2230
+ * @param inMarketIndex - Spot market of the token being sold.
2231
+ * @param amount - Swap amount, in-market's native decimals (interpreted as exact-in or exact-out per `swapMode`).
2232
+ * @param slippageBps - Optional slippage tolerance passed to Jupiter, basis points.
2233
+ * @param swapMode - Optional `'ExactIn'` / `'ExactOut'`; also inferred from `quote.swapMode` if a quote is supplied.
2234
+ * @param onlyDirectRoutes - Optional, restricts the Jupiter quote to single-hop routes.
2235
+ * @param quote - Optional pre-fetched Jupiter quote; skips the internal fetch if provided.
2236
+ * @param lpPoolId - LP pool id byte the swap routes through.
2237
+ * @returns The unsigned instruction sequence (begin-swap, Jupiter swap instructions, end-swap) and any address lookup tables the Jupiter instructions require.
2238
+ */
340
2239
  getLpJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, amount, slippageBps, swapMode, onlyDirectRoutes, quote, lpPoolId, }: {
341
2240
  jupiterClient: JupiterClient;
342
2241
  outMarketIndex: number;
@@ -353,38 +2252,271 @@ export declare class AdminClient extends VelocityClient {
353
2252
  ixs: TransactionInstruction[];
354
2253
  lookupTables: AddressLookupTableAccount[];
355
2254
  }>;
2255
+ /**
2256
+ * Devnet/test-only helper: builds a plain SPL-token transfer pair simulating an
2257
+ * external counterparty swapping against `this.wallet`'s own token accounts (not
2258
+ * an atomic on-chain program instruction, and not gated by any admin tier — it's
2259
+ * ordinary token transfers assembled for local test flows, typically alongside
2260
+ * `getSwapIx`'s begin/end pair as in `getAllDevnetLpSwapIxs`). Also idempotently
2261
+ * creates the external user's in/out ATAs.
2262
+ * @param amountIn - Amount `this.wallet` sends of the in-market token, that market's native decimals.
2263
+ * @param amountOut - Amount `this.wallet` receives of the out-market token, that market's native decimals.
2264
+ * @param externalUserAuthority - The simulated counterparty's wallet authority.
2265
+ * @param externalUserInTokenAccount - Counterparty's ATA that receives the in-market token.
2266
+ * @param externalUserOutTokenAccount - Counterparty's ATA that sends the out-market token.
2267
+ * @param inSpotMarketIndex - Spot market of the token `this.wallet` sends.
2268
+ * @param outSpotMarketIndex - Spot market of the token `this.wallet` receives.
2269
+ * @returns Unsigned instructions: create both ATAs, then the two transfers.
2270
+ */
356
2271
  getDevnetLpSwapIxs(amountIn: BN, amountOut: BN, externalUserAuthority: PublicKey, externalUserInTokenAccount: PublicKey, externalUserOutTokenAccount: PublicKey, inSpotMarketIndex: number, outSpotMarketIndex: number): Promise<TransactionInstruction[]>;
2272
+ /**
2273
+ * Devnet/test-only helper: wraps `getSwapIx`'s begin/end LP-pool swap pair around
2274
+ * `getDevnetLpSwapIxs`'s simulated-counterparty transfers, producing the full
2275
+ * instruction sequence for an end-to-end devnet LP-pool swap test.
2276
+ * @param lpPoolId - LP pool id byte the swap routes through.
2277
+ * @param inMarketIndex - Spot market of the token going in.
2278
+ * @param outMarketIndex - Spot market of the token coming out.
2279
+ * @param inAmount - Amount going in, in-market's native decimals.
2280
+ * @param minOutAmount - Minimum acceptable amount out, out-market's native decimals (also used as the simulated counterparty's exact transfer amount).
2281
+ * @param externalUserAuthority - The simulated counterparty's wallet authority.
2282
+ * @returns Unsigned instructions: begin-swap, the simulated transfer pair, end-swap, in order.
2283
+ */
357
2284
  getAllDevnetLpSwapIxs(lpPoolId: number, inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, externalUserAuthority: PublicKey): Promise<TransactionInstruction[]>;
2285
+ /**
2286
+ * Atomically moves an LP-pool constituent's idle tokens into a spot market's
2287
+ * lending vault (earning yield) and borrows another constituent's tokens back out
2288
+ * of a (possibly different) spot market's vault, in one transaction. Requires
2289
+ * `HotRole.LpSwap` on both legs (`DepositProgramVault`/`WithdrawProgramVault`
2290
+ * contexts) — `this.wallet` signs as `admin` directly and must hold that role.
2291
+ * Each leg re-validates the constituent's borrow/token-amount invariants
2292
+ * on-chain; the withdraw leg additionally caps the transfer at
2293
+ * `constituent.maxBorrowTokenAmount` (+5% buffer).
2294
+ * @param lpPoolId - LP pool whose constituents to move tokens for.
2295
+ * @param depositMarketIndex - Spot market (and matching constituent) to deposit into.
2296
+ * @param borrowMarketIndex - Spot market (and matching constituent) to borrow/withdraw from.
2297
+ * @param amountToDeposit - Deposit amount, the deposit market's native decimals.
2298
+ * @param amountToBorrow - Withdraw amount, the borrow market's native decimals.
2299
+ * @returns Transaction signature.
2300
+ */
358
2301
  depositWithdrawToProgramVault(lpPoolId: number, depositMarketIndex: number, borrowMarketIndex: number, amountToDeposit: BN, amountToBorrow: BN): Promise<TransactionSignature>;
2302
+ /**
2303
+ * Builds the `depositToProgramVault` and `withdrawFromProgramVault` instructions
2304
+ * without sending them. See `depositWithdrawToProgramVault`; also the building
2305
+ * block for `getDepositToProgramVaultIx`/`getWithdrawFromProgramVaultIx`
2306
+ * (each of which calls this with the unused leg's amount set to `0`).
2307
+ * @returns The unsigned `{ depositIx, withdrawIx }` pair.
2308
+ */
359
2309
  getDepositWithdrawToProgramVaultIxs(lpPoolId: number, depositMarketIndex: number, borrowMarketIndex: number, amountToDeposit: BN, amountToBorrow: BN): Promise<{
360
2310
  depositIx: TransactionInstruction;
361
2311
  withdrawIx: TransactionInstruction;
362
2312
  }>;
2313
+ /**
2314
+ * Deposits an LP-pool constituent's idle tokens into its spot market's lending
2315
+ * vault, on its own (single-leg version of `depositWithdrawToProgramVault`).
2316
+ * Requires `HotRole.LpSwap`; `this.wallet` must hold that role.
2317
+ * @param lpPoolId - LP pool whose constituent to deposit from.
2318
+ * @param depositMarketIndex - Spot market (and matching constituent) to deposit into.
2319
+ * @param amountToDeposit - Deposit amount, the market's native decimals.
2320
+ * @returns Transaction signature.
2321
+ */
363
2322
  depositToProgramVault(lpPoolId: number, depositMarketIndex: number, amountToDeposit: BN): Promise<TransactionSignature>;
2323
+ /**
2324
+ * Borrows tokens from a spot market's lending vault back into an LP-pool
2325
+ * constituent, on its own (single-leg version of `depositWithdrawToProgramVault`).
2326
+ * Requires `HotRole.LpSwap`; `this.wallet` must hold that role. On-chain, capped
2327
+ * at `constituent.maxBorrowTokenAmount` (+5% buffer).
2328
+ * @param lpPoolId - LP pool whose constituent to borrow into.
2329
+ * @param borrowMarketIndex - Spot market (and matching constituent) to borrow from.
2330
+ * @param amountToWithdraw - Withdraw amount, the market's native decimals.
2331
+ * @returns Transaction signature.
2332
+ */
364
2333
  withdrawFromProgramVault(lpPoolId: number, borrowMarketIndex: number, amountToWithdraw: BN): Promise<TransactionSignature>;
2334
+ /**
2335
+ * Builds the `depositToProgramVault` instruction without sending it, via
2336
+ * `getDepositWithdrawToProgramVaultIxs` with a `0` withdraw amount (the
2337
+ * accompanying zero-amount withdraw instruction is discarded, not sent). See
2338
+ * `depositToProgramVault`.
2339
+ * @returns The unsigned `depositToProgramVault` instruction.
2340
+ */
365
2341
  getDepositToProgramVaultIx(lpPoolId: number, depositMarketIndex: number, amountToDeposit: BN): Promise<TransactionInstruction>;
2342
+ /**
2343
+ * Builds the `withdrawFromProgramVault` instruction without sending it, via
2344
+ * `getDepositWithdrawToProgramVaultIxs` with a `0` deposit amount (the
2345
+ * accompanying zero-amount deposit instruction is discarded, not sent). See
2346
+ * `withdrawFromProgramVault`.
2347
+ * @returns The unsigned `withdrawFromProgramVault` instruction.
2348
+ */
366
2349
  getWithdrawFromProgramVaultIx(lpPoolId: number, borrowMarketIndex: number, amountToWithdraw: BN): Promise<TransactionInstruction>;
2350
+ /**
2351
+ * Patches a perp market's `hedgeConfig` fee-routing scalars that control how much
2352
+ * of the AMM's fee growth is swept to its LP pool (see `sweepPerpMarketFees`).
2353
+ * Requires warm admin (the `HotAdminUpdatePerpMarketDlp` context's `check_warm`
2354
+ * constraint). Both params are optional; only the ones provided are updated.
2355
+ * @param marketIndex - Perp market to update.
2356
+ * @param lpFeeTransferScalar - `hedgeConfig.feeTransferScalar`, percent 0-100 (divided by 100 on-chain) of AMM fee-pool growth routed to the LP pool.
2357
+ * @param lpExchangeFeeExcluscionScalar - `hedgeConfig.exchangeFeeExclusionScalar`, percent 0-100 of the period's exchange-fee growth excluded from that sweep.
2358
+ * @returns Transaction signature.
2359
+ */
367
2360
  updatePerpMarketLpPoolFeeTransferScalar(marketIndex: number, lpFeeTransferScalar?: number, lpExchangeFeeExcluscionScalar?: number): Promise<string>;
2361
+ /**
2362
+ * Builds the `updatePerpMarketLpPoolFeeTransferScalar` instruction without
2363
+ * sending it. See `updatePerpMarketLpPoolFeeTransferScalar`.
2364
+ * @returns The unsigned `updatePerpMarketLpPoolFeeTransferScalar` instruction.
2365
+ */
368
2366
  getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex: number, lpFeeTransferScalar?: number, lpExchangeFeeExcluscionScalar?: number): Promise<TransactionInstruction>;
2367
+ /**
2368
+ * Sets a perp market's `hedgeConfig.pausedOperations` bitmask
2369
+ * (`ConstituentLpOperation`: `Swap`/`Deposit`/`Withdraw`), pausing that market's
2370
+ * side of LP-pool hedge flow. Reachable by cold, warm, or `pauseAdmin`
2371
+ * (`PauseAdminUpdatePerpMarket`'s `check_pause`), with the same bit-add-only
2372
+ * restriction for a pause-admin-only caller as `updateExchangeStatus`. The
2373
+ * `admin` account below defaults to `coldAdmin`; other roles must override it.
2374
+ * @param marketIndex - Perp market to update.
2375
+ * @param pausedOperations - New pause bitmask, `ConstituentLpOperation` bit values.
2376
+ * @returns Transaction signature.
2377
+ */
369
2378
  updatePerpMarketLpPoolPausedOperations(marketIndex: number, pausedOperations: number): Promise<string>;
2379
+ /**
2380
+ * Builds the `updatePerpMarketLpPoolPausedOperations` instruction without
2381
+ * sending it. See `updatePerpMarketLpPoolPausedOperations`.
2382
+ * @returns The unsigned `updatePerpMarketLpPoolPausedOperations` instruction.
2383
+ */
370
2384
  getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex: number, pausedOperations: number): Promise<TransactionInstruction>;
2385
+ /**
2386
+ * Mints `1000` units of an LP pool's `whitelistMint` to `authority`'s associated
2387
+ * token account, creating the ATA if needed. This is a plain SPL-token mint, not
2388
+ * a velocity program instruction — no `HotRole`/tier gate applies; instead the
2389
+ * token program itself requires `this.wallet` to be the mint's authority (set
2390
+ * whenever the whitelist mint was created — typically the same admin that called
2391
+ * `initializeLpPool`/`updateLpPoolParams` to configure it). Holding units of the
2392
+ * whitelist mint is what gates `authority`'s ability to mint/redeem this pool's LP
2393
+ * token, if `lpPool.whitelistMint` is set to a non-default pubkey.
2394
+ * @param lpPool - LP pool whose `whitelistMint` to mint from.
2395
+ * @param authority - Wallet to receive the whitelist tokens.
2396
+ * @returns Transaction signature.
2397
+ */
371
2398
  mintLpWhitelistToken(lpPool: LPPoolAccount, authority: PublicKey): Promise<TransactionSignature>;
2399
+ /**
2400
+ * Builds the ATA-creation and `mintTo` instructions without sending them. See
2401
+ * `mintLpWhitelistToken`.
2402
+ * @returns The unsigned instructions: idempotent ATA creation, then mint-to, in order.
2403
+ */
372
2404
  getMintLpWhitelistTokenIx(lpPool: LPPoolAccount, authority: PublicKey): Promise<TransactionInstruction[]>;
2405
+ /**
2406
+ * Sets a perp market's `marketConfig` bitmask (currently one bit:
2407
+ * `MarketConfigFlag.DisableFormulaicKUpdate`, which turns off the AMM's automatic
2408
+ * k-adjustment for the market). Requires warm admin (the `HotAdminUpdatePerpMarket`
2409
+ * context's `check_warm` constraint), but **setting any bit (a non-zero value)
2410
+ * requires `state.coldAdmin` specifically** — a warm-only signer may only pass `0`
2411
+ * (clear all bits). Unknown bits are rejected (`InvalidPerpMarketConfig`).
2412
+ * @param marketIndex - Perp market to update.
2413
+ * @param marketConfig - New bitmask; non-zero values require cold admin.
2414
+ * @returns Transaction signature.
2415
+ */
373
2416
  updatePerpMarketConfig(marketIndex: number, marketConfig: number): Promise<string>;
2417
+ /**
2418
+ * Builds the `updatePerpMarketConfig` instruction without sending it. See
2419
+ * `updatePerpMarketConfig`.
2420
+ * @returns The unsigned `updatePerpMarketConfig` instruction.
2421
+ */
374
2422
  getUpdatePerpMarketConfigIx(marketIndex: number, marketConfig: number): Promise<TransactionInstruction>;
2423
+ /**
2424
+ * Moves quote value between one perp market's protocol fee pool and another (or
2425
+ * the same) perp market's pnl pool — a pure internal ledger transfer against the
2426
+ * shared quote spot market's scaled balances, no tokens actually move. Requires
2427
+ * warm admin (`check_warm`). On-chain, the transfer is capped at the source
2428
+ * pool's available token amount. For a same-market move the AMM's
2429
+ * `totalFeeMinusDistributions` ledger is left untouched (equity-neutral within
2430
+ * one market's perimeter); for a cross-market move, the fee-pool market's ledger
2431
+ * is adjusted to reflect quote leaving/entering its perimeter (reconciled later
2432
+ * by the summary-stats recompute ix).
2433
+ * @param perpMarketIndexWithFeePool - Perp market whose fee pool is the transfer source/destination.
2434
+ * @param perpMarketIndexWithPnlPool - Perp market whose pnl pool is the transfer destination/source.
2435
+ * @param amount - Amount to move, QUOTE_PRECISION (1e6) (clamped down to the source pool's available balance on-chain).
2436
+ * @param direction - `TransferFeeAndPnlPoolDirection.FEE_TO_PNL_POOL` or `.PNL_TO_FEE_POOL`.
2437
+ * @returns Transaction signature.
2438
+ */
375
2439
  transferFeeAndPnlPool(perpMarketIndexWithFeePool: number, perpMarketIndexWithPnlPool: number, amount: BN, direction: TransferFeeAndPnlPoolDirection): Promise<TransactionSignature>;
2440
+ /**
2441
+ * Builds the `transferFeeAndPnlPool` instruction without sending it. See
2442
+ * `transferFeeAndPnlPool`.
2443
+ * @returns The unsigned `transferFeeAndPnlPool` instruction.
2444
+ */
376
2445
  getTransferFeeAndPnlPoolIx(perpMarketIndexWithFeePool: number, perpMarketIndexWithPnlPool: number, amount: BN, direction: TransferFeeAndPnlPoolDirection): Promise<TransactionInstruction>;
2446
+ /**
2447
+ * Sets a `User` account's `specialUserStatus` bitmask (`SpecialUserStatus`;
2448
+ * currently one bit, `VAMM_HEDGER`, marking the account the protocol's own
2449
+ * vAMM-hedging bot trades from). Requires `HotRole.UserFlag` (cold, warm, or the
2450
+ * configured user-flag hot key), but **setting any bit (a non-zero value)
2451
+ * requires `state.coldAdmin` specifically** — a `UserFlag`-hot-only signer may
2452
+ * only pass `0` (clear all bits). Unknown bits are rejected (`DefaultError`).
2453
+ * @param userAccountPublicKey - `User` PDA to update.
2454
+ * @param status - New bitmask; non-zero values require cold admin.
2455
+ * @param txParams - Optional transaction-building overrides.
2456
+ * @returns Transaction signature.
2457
+ */
377
2458
  updateSpecialUserStatus(userAccountPublicKey: PublicKey, status: number, txParams?: TxParams): Promise<TransactionSignature>;
2459
+ /**
2460
+ * Builds the `updateSpecialUserStatus` instruction without sending it. See
2461
+ * `updateSpecialUserStatus`.
2462
+ * @returns The unsigned `updateSpecialUserStatus` instruction.
2463
+ */
378
2464
  getUpdateSpecialUserStatusIx(userAccountPublicKey: PublicKey, status: number): Promise<TransactionInstruction>;
2465
+ /**
2466
+ * Rotates `state.warmAdmin`, the operational (multisig+timelock) tier that can
2467
+ * rotate every hot-role key (`updateHotAdmin`). Cold-only: the `UpdateWarmAdmin`
2468
+ * context requires `state.coldAdmin == admin.key()`.
2469
+ * @param newWarmAdmin - New warm admin pubkey. `PublicKey.default()` unsets the role — only `coldAdmin` can then act where warm was accepted.
2470
+ * @returns Transaction signature.
2471
+ */
379
2472
  updateWarmAdmin(newWarmAdmin: PublicKey): Promise<TransactionSignature>;
2473
+ /**
2474
+ * Builds the `updateWarmAdmin` instruction without sending it. See
2475
+ * `updateWarmAdmin`.
2476
+ * @returns The unsigned `updateWarmAdmin` instruction.
2477
+ */
380
2478
  getUpdateWarmAdminIx(newWarmAdmin: PublicKey): Promise<TransactionInstruction>;
2479
+ /**
2480
+ * Rotates `state.pauseAdmin`, the no-timelock emergency-pause key authorised (in
2481
+ * addition to cold/warm) for handlers that flip pause bitmasks
2482
+ * (`updateExchangeStatus`, per-market/per-user paused-operations updates) —
2483
+ * restricted at the handler level to *adding* pause bits, never clearing them.
2484
+ * Cold-only: the `UpdatePauseAdmin` context requires `state.coldAdmin ==
2485
+ * admin.key()`.
2486
+ * @param newPauseAdmin - New pause admin pubkey. `PublicKey.default()` unsets the role — only cold/warm can then pause.
2487
+ * @returns Transaction signature.
2488
+ */
2489
+ updatePauseAdmin(newPauseAdmin: PublicKey): Promise<TransactionSignature>;
2490
+ /**
2491
+ * Builds the `updatePauseAdmin` instruction without sending it. See
2492
+ * `updatePauseAdmin`.
2493
+ * @returns The unsigned `updatePauseAdmin` instruction.
2494
+ */
2495
+ getUpdatePauseAdminIx(newPauseAdmin: PublicKey): Promise<TransactionInstruction>;
2496
+ /**
2497
+ * Rotates one purpose-specific hot-role key on `state` (e.g. `hotFeeWithdraw`,
2498
+ * `hotVaultDeposit`). Warm-or-cold: the `UpdateHotAdmin` context requires
2499
+ * `state.isWarm(admin.key())`. Compromise of one hot key only exposes the
2500
+ * instructions gated on that specific `HotRole` — rotating it here fully revokes
2501
+ * the old key for that role.
2502
+ * @param role - Which hot role's key to rotate.
2503
+ * @param newPubkey - New key for that role. `PublicKey.default()` unsets it — only warm/cold can then call handlers gated on that role.
2504
+ * @returns Transaction signature.
2505
+ */
381
2506
  updateHotAdmin(role: HotRole, newPubkey: PublicKey): Promise<TransactionSignature>;
2507
+ /**
2508
+ * Builds the `updateHotAdmin` instruction without sending it. See
2509
+ * `updateHotAdmin`.
2510
+ * @returns The unsigned `updateHotAdmin` instruction.
2511
+ */
382
2512
  getUpdateHotAdminIx(role: HotRole, newPubkey: PublicKey): Promise<TransactionInstruction>;
383
2513
  }
384
2514
  /**
385
2515
  * Hot-admin role identifier. Each role is a separate purpose-specific signer key
386
- * stored on the `AdminAuthorityConfig` PDA. Compromise of one role's key only
387
- * enables that role's instructions.
2516
+ * stored directly on the `State` account (one `hot*` pubkey field per role, e.g.
2517
+ * `state.hotFeeWithdraw` for `FeeWithdraw`) — there is no separate
2518
+ * "AdminAuthorityConfig" account. Compromise of one role's key only enables that
2519
+ * role's instructions (see `updateHotAdmin` to rotate one).
388
2520
  */
389
2521
  export declare enum HotRole {
390
2522
  AmmCrank = "ammCrank",