@velocity-exchange/sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (676) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/bun.lock +23 -1
  3. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
  4. package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
  5. package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  6. package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
  7. package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
  8. package/lib/browser/accounts/bulkAccountLoader.js +12 -1
  9. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
  10. package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
  11. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  12. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
  13. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  14. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  15. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  16. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
  17. package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
  18. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
  19. package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
  20. package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
  21. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
  22. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  23. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  24. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  25. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  26. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
  27. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  28. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
  29. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  30. package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
  31. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  32. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  33. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
  34. package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
  35. package/lib/browser/accounts/types.d.ts +4 -4
  36. package/lib/browser/accounts/utils.d.ts +1 -0
  37. package/lib/browser/accounts/utils.js +8 -1
  38. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
  39. package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
  40. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  41. package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
  42. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  43. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  44. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  45. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
  46. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  47. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  48. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  49. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  50. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  51. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
  52. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  53. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  54. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
  55. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
  56. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
  57. package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
  58. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  59. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  60. package/lib/browser/addresses/marketAddresses.js +3 -2
  61. package/lib/browser/addresses/pda.d.ts +0 -2
  62. package/lib/browser/addresses/pda.js +1 -14
  63. package/lib/browser/adminClient.d.ts +24 -28
  64. package/lib/browser/adminClient.js +156 -157
  65. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
  66. package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
  67. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
  68. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  69. package/lib/browser/bankrun/bankrunConnection.d.ts +6 -4
  70. package/lib/browser/bankrun/bankrunConnection.js +69 -31
  71. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  72. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  73. package/lib/browser/clock/clockSubscriber.d.ts +6 -6
  74. package/lib/browser/clock/clockSubscriber.js +4 -3
  75. package/lib/browser/config.d.ts +1 -1
  76. package/lib/browser/config.js +8 -4
  77. package/lib/browser/constants/index.d.ts +1 -2
  78. package/lib/browser/constants/index.js +1 -2
  79. package/lib/browser/constants/numericConstants.d.ts +1 -3
  80. package/lib/browser/constants/numericConstants.js +3 -5
  81. package/lib/browser/constituentMap/constituentMap.js +5 -1
  82. package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  83. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  84. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  85. package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
  86. package/lib/browser/core/instructions/perpOrders.js +14 -0
  87. package/lib/browser/core/remainingAccounts.d.ts +2 -2
  88. package/lib/browser/core/remainingAccounts.js +2 -2
  89. package/lib/browser/decode/user.js +9 -1
  90. package/lib/browser/dlob/DLOB.d.ts +6 -1
  91. package/lib/browser/dlob/DLOB.js +201 -138
  92. package/lib/browser/dlob/DLOBNode.d.ts +5 -2
  93. package/lib/browser/dlob/DLOBNode.js +7 -0
  94. package/lib/browser/dlob/DLOBSubscriber.js +37 -32
  95. package/lib/browser/dlob/NodeList.js +8 -7
  96. package/lib/browser/dlob/orderBookLevels.js +19 -12
  97. package/lib/browser/events/eventList.js +4 -1
  98. package/lib/browser/events/eventSubscriber.d.ts +5 -2
  99. package/lib/browser/events/eventSubscriber.js +75 -26
  100. package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
  101. package/lib/browser/events/eventsServerLogProvider.js +15 -8
  102. package/lib/browser/events/fetchLogs.d.ts +1 -1
  103. package/lib/browser/events/fetchLogs.js +4 -2
  104. package/lib/browser/events/pollingLogProvider.d.ts +1 -1
  105. package/lib/browser/events/pollingLogProvider.js +1 -0
  106. package/lib/browser/events/txEventCache.js +6 -2
  107. package/lib/browser/events/types.d.ts +2 -4
  108. package/lib/browser/events/types.js +0 -2
  109. package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
  110. package/lib/browser/events/webSocketLogProvider.js +5 -2
  111. package/lib/browser/factory/bigNum.js +1 -1
  112. package/lib/browser/idl/velocity.d.ts +1243 -1586
  113. package/lib/browser/idl/velocity.json +1234 -1577
  114. package/lib/browser/index.d.ts +0 -2
  115. package/lib/browser/index.js +0 -2
  116. package/lib/browser/jupiter/jupiterClient.d.ts +1 -1
  117. package/lib/browser/jupiter/jupiterClient.js +18 -8
  118. package/lib/browser/marginCalculation.js +1 -0
  119. package/lib/browser/math/amm.d.ts +31 -13
  120. package/lib/browser/math/amm.js +77 -22
  121. package/lib/browser/math/bankruptcy.js +1 -1
  122. package/lib/browser/math/funding.js +6 -6
  123. package/lib/browser/math/insurance.d.ts +1 -1
  124. package/lib/browser/math/insurance.js +4 -5
  125. package/lib/browser/math/margin.d.ts +1 -9
  126. package/lib/browser/math/margin.js +3 -62
  127. package/lib/browser/math/market.d.ts +4 -12
  128. package/lib/browser/math/market.js +6 -40
  129. package/lib/browser/math/oracles.d.ts +0 -3
  130. package/lib/browser/math/oracles.js +1 -14
  131. package/lib/browser/math/orders.d.ts +0 -5
  132. package/lib/browser/math/orders.js +2 -74
  133. package/lib/browser/math/position.d.ts +0 -4
  134. package/lib/browser/math/position.js +5 -10
  135. package/lib/browser/math/repeg.d.ts +0 -1
  136. package/lib/browser/math/repeg.js +1 -23
  137. package/lib/browser/math/spotBalance.d.ts +4 -4
  138. package/lib/browser/math/spotBalance.js +6 -6
  139. package/lib/browser/math/spotMarket.d.ts +0 -6
  140. package/lib/browser/math/spotMarket.js +1 -16
  141. package/lib/browser/math/spotPosition.d.ts +4 -4
  142. package/lib/browser/math/state.d.ts +0 -2
  143. package/lib/browser/math/state.js +1 -9
  144. package/lib/browser/math/superStake.d.ts +3 -53
  145. package/lib/browser/math/superStake.js +16 -13
  146. package/lib/browser/math/trade.js +6 -6
  147. package/lib/browser/memcmp.d.ts +0 -1
  148. package/lib/browser/memcmp.js +1 -10
  149. package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
  150. package/lib/browser/oracles/pythClient.js +9 -3
  151. package/lib/browser/oracles/pythLazerClient.js +3 -2
  152. package/lib/browser/oracles/utils.d.ts +4 -0
  153. package/lib/browser/oracles/utils.js +9 -1
  154. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
  155. package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
  156. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  157. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
  158. package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
  159. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  160. package/lib/browser/pyth/types.d.ts +0 -1
  161. package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
  162. package/lib/browser/slot/SlotSubscriber.js +2 -1
  163. package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
  164. package/lib/browser/slot/SlothashSubscriber.js +11 -4
  165. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  166. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  167. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
  168. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
  169. package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
  170. package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
  171. package/lib/browser/testClient.js +3 -2
  172. package/lib/browser/tokenFaucet.js +16 -2
  173. package/lib/browser/tx/baseTxSender.d.ts +4 -4
  174. package/lib/browser/tx/baseTxSender.js +5 -4
  175. package/lib/browser/tx/fastSingleTxSender.d.ts +3 -3
  176. package/lib/browser/tx/fastSingleTxSender.js +9 -5
  177. package/lib/browser/tx/reportTransactionError.d.ts +2 -2
  178. package/lib/browser/tx/reportTransactionError.js +5 -1
  179. package/lib/browser/tx/retryTxSender.d.ts +1 -1
  180. package/lib/browser/tx/retryTxSender.js +4 -2
  181. package/lib/browser/tx/txHandler.d.ts +7 -1
  182. package/lib/browser/tx/txHandler.js +54 -40
  183. package/lib/browser/tx/txParamProcessor.d.ts +4 -1
  184. package/lib/browser/tx/txParamProcessor.js +6 -0
  185. package/lib/browser/tx/types.d.ts +1 -1
  186. package/lib/browser/tx/whileValidTxSender.d.ts +1 -6
  187. package/lib/browser/tx/whileValidTxSender.js +35 -13
  188. package/lib/browser/types.d.ts +27 -70
  189. package/lib/browser/types.js +2 -2
  190. package/lib/browser/user.d.ts +21 -7
  191. package/lib/browser/user.js +156 -132
  192. package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
  193. package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
  194. package/lib/browser/userMap/referrerMap.js +10 -3
  195. package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
  196. package/lib/browser/userMap/userMap.d.ts +1 -1
  197. package/lib/browser/userMap/userMap.js +36 -23
  198. package/lib/browser/userMap/userStatsMap.d.ts +1 -1
  199. package/lib/browser/userMap/userStatsMap.js +18 -13
  200. package/lib/browser/userStats.d.ts +7 -2
  201. package/lib/browser/userStats.js +18 -4
  202. package/lib/browser/util/TransactionConfirmationManager.js +4 -2
  203. package/lib/browser/util/chainClock.d.ts +1 -1
  204. package/lib/browser/util/computeUnits.d.ts +1 -1
  205. package/lib/browser/util/computeUnits.js +6 -1
  206. package/lib/browser/velocityClient.d.ts +92 -34
  207. package/lib/browser/velocityClient.js +414 -280
  208. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
  209. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
  210. package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
  211. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
  212. package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
  213. package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
  214. package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
  215. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
  216. package/lib/node/accounts/bulkAccountLoader.js +12 -1
  217. package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
  218. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  219. package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
  220. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
  221. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  222. package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
  223. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
  224. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  225. package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
  226. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
  227. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  228. package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
  229. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
  230. package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
  231. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
  232. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  233. package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
  234. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  235. package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
  236. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  237. package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
  238. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  239. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
  240. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  241. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  242. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
  243. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
  244. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  245. package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
  246. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
  247. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  248. package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
  249. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
  250. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
  251. package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
  252. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
  253. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  254. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
  255. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
  256. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
  257. package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
  258. package/lib/node/accounts/types.d.ts +4 -4
  259. package/lib/node/accounts/types.d.ts.map +1 -1
  260. package/lib/node/accounts/utils.d.ts +1 -0
  261. package/lib/node/accounts/utils.d.ts.map +1 -1
  262. package/lib/node/accounts/utils.js +8 -1
  263. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
  264. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  265. package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
  266. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
  267. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  268. package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
  269. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
  270. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  271. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
  272. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
  273. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  274. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
  275. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
  276. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  277. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
  278. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
  279. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  280. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
  281. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
  282. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  283. package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
  284. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
  285. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  286. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
  287. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
  288. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
  289. package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
  290. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
  291. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
  292. package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
  293. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
  294. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  295. package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
  296. package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
  297. package/lib/node/addresses/marketAddresses.js +3 -2
  298. package/lib/node/addresses/pda.d.ts +0 -2
  299. package/lib/node/addresses/pda.d.ts.map +1 -1
  300. package/lib/node/addresses/pda.js +1 -14
  301. package/lib/node/adminClient.d.ts +24 -28
  302. package/lib/node/adminClient.d.ts.map +1 -1
  303. package/lib/node/adminClient.js +156 -157
  304. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
  305. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  306. package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
  307. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
  308. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  309. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  310. package/lib/node/bankrun/bankrunConnection.d.ts +6 -4
  311. package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
  312. package/lib/node/bankrun/bankrunConnection.js +69 -31
  313. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
  314. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
  315. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
  316. package/lib/node/clock/clockSubscriber.d.ts +6 -6
  317. package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
  318. package/lib/node/clock/clockSubscriber.js +4 -3
  319. package/lib/node/config.d.ts +1 -1
  320. package/lib/node/config.d.ts.map +1 -1
  321. package/lib/node/config.js +8 -4
  322. package/lib/node/constants/index.d.ts +1 -2
  323. package/lib/node/constants/index.d.ts.map +1 -1
  324. package/lib/node/constants/index.js +1 -2
  325. package/lib/node/constants/numericConstants.d.ts +1 -3
  326. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  327. package/lib/node/constants/numericConstants.js +3 -5
  328. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  329. package/lib/node/constituentMap/constituentMap.js +5 -1
  330. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
  331. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
  332. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
  333. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
  334. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
  335. package/lib/node/core/instructions/perpOrders.d.ts +14 -0
  336. package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
  337. package/lib/node/core/instructions/perpOrders.js +14 -0
  338. package/lib/node/core/remainingAccounts.d.ts +2 -2
  339. package/lib/node/core/remainingAccounts.d.ts.map +1 -1
  340. package/lib/node/core/remainingAccounts.js +2 -2
  341. package/lib/node/decode/user.d.ts.map +1 -1
  342. package/lib/node/decode/user.js +9 -1
  343. package/lib/node/dlob/DLOB.d.ts +6 -1
  344. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  345. package/lib/node/dlob/DLOB.js +201 -138
  346. package/lib/node/dlob/DLOBNode.d.ts +5 -2
  347. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  348. package/lib/node/dlob/DLOBNode.js +7 -0
  349. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  350. package/lib/node/dlob/DLOBSubscriber.js +37 -32
  351. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  352. package/lib/node/dlob/NodeList.js +8 -7
  353. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  354. package/lib/node/dlob/orderBookLevels.js +19 -12
  355. package/lib/node/events/eventList.d.ts +3 -3
  356. package/lib/node/events/eventList.d.ts.map +1 -1
  357. package/lib/node/events/eventList.js +4 -1
  358. package/lib/node/events/eventSubscriber.d.ts +5 -2
  359. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  360. package/lib/node/events/eventSubscriber.js +75 -26
  361. package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
  362. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
  363. package/lib/node/events/eventsServerLogProvider.js +15 -8
  364. package/lib/node/events/fetchLogs.d.ts +1 -1
  365. package/lib/node/events/fetchLogs.d.ts.map +1 -1
  366. package/lib/node/events/fetchLogs.js +4 -2
  367. package/lib/node/events/pollingLogProvider.d.ts +2 -2
  368. package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
  369. package/lib/node/events/pollingLogProvider.js +1 -0
  370. package/lib/node/events/txEventCache.d.ts +3 -3
  371. package/lib/node/events/txEventCache.d.ts.map +1 -1
  372. package/lib/node/events/txEventCache.js +6 -2
  373. package/lib/node/events/types.d.ts +2 -4
  374. package/lib/node/events/types.d.ts.map +1 -1
  375. package/lib/node/events/types.js +0 -2
  376. package/lib/node/events/webSocketLogProvider.d.ts +2 -2
  377. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
  378. package/lib/node/events/webSocketLogProvider.js +5 -2
  379. package/lib/node/factory/bigNum.js +1 -1
  380. package/lib/node/idl/velocity.d.ts +1243 -1586
  381. package/lib/node/idl/velocity.d.ts.map +1 -1
  382. package/lib/node/idl/velocity.json +1234 -1577
  383. package/lib/node/index.d.ts +0 -2
  384. package/lib/node/index.d.ts.map +1 -1
  385. package/lib/node/index.js +0 -2
  386. package/lib/node/jupiter/jupiterClient.d.ts +1 -1
  387. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
  388. package/lib/node/jupiter/jupiterClient.js +18 -8
  389. package/lib/node/marginCalculation.d.ts.map +1 -1
  390. package/lib/node/marginCalculation.js +1 -0
  391. package/lib/node/math/amm.d.ts +31 -13
  392. package/lib/node/math/amm.d.ts.map +1 -1
  393. package/lib/node/math/amm.js +77 -22
  394. package/lib/node/math/bankruptcy.js +1 -1
  395. package/lib/node/math/funding.d.ts.map +1 -1
  396. package/lib/node/math/funding.js +6 -6
  397. package/lib/node/math/insurance.d.ts +1 -1
  398. package/lib/node/math/insurance.d.ts.map +1 -1
  399. package/lib/node/math/insurance.js +4 -5
  400. package/lib/node/math/margin.d.ts +1 -9
  401. package/lib/node/math/margin.d.ts.map +1 -1
  402. package/lib/node/math/margin.js +3 -62
  403. package/lib/node/math/market.d.ts +4 -12
  404. package/lib/node/math/market.d.ts.map +1 -1
  405. package/lib/node/math/market.js +6 -40
  406. package/lib/node/math/oracles.d.ts +0 -3
  407. package/lib/node/math/oracles.d.ts.map +1 -1
  408. package/lib/node/math/oracles.js +1 -14
  409. package/lib/node/math/orders.d.ts +0 -5
  410. package/lib/node/math/orders.d.ts.map +1 -1
  411. package/lib/node/math/orders.js +2 -74
  412. package/lib/node/math/position.d.ts +1 -5
  413. package/lib/node/math/position.d.ts.map +1 -1
  414. package/lib/node/math/position.js +5 -10
  415. package/lib/node/math/repeg.d.ts +0 -1
  416. package/lib/node/math/repeg.d.ts.map +1 -1
  417. package/lib/node/math/repeg.js +1 -23
  418. package/lib/node/math/spotBalance.d.ts +4 -4
  419. package/lib/node/math/spotBalance.d.ts.map +1 -1
  420. package/lib/node/math/spotBalance.js +6 -6
  421. package/lib/node/math/spotMarket.d.ts +0 -6
  422. package/lib/node/math/spotMarket.d.ts.map +1 -1
  423. package/lib/node/math/spotMarket.js +1 -16
  424. package/lib/node/math/spotPosition.d.ts +4 -4
  425. package/lib/node/math/spotPosition.d.ts.map +1 -1
  426. package/lib/node/math/state.d.ts +0 -2
  427. package/lib/node/math/state.d.ts.map +1 -1
  428. package/lib/node/math/state.js +1 -9
  429. package/lib/node/math/superStake.d.ts +3 -53
  430. package/lib/node/math/superStake.d.ts.map +1 -1
  431. package/lib/node/math/superStake.js +16 -13
  432. package/lib/node/math/trade.d.ts +2 -2
  433. package/lib/node/math/trade.d.ts.map +1 -1
  434. package/lib/node/math/trade.js +6 -6
  435. package/lib/node/memcmp.d.ts +0 -1
  436. package/lib/node/memcmp.d.ts.map +1 -1
  437. package/lib/node/memcmp.js +1 -10
  438. package/lib/node/oracles/oracleClientCache.d.ts +1 -1
  439. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  440. package/lib/node/oracles/prelaunchOracleClient.js +3 -2
  441. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  442. package/lib/node/oracles/pythClient.js +9 -3
  443. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  444. package/lib/node/oracles/pythLazerClient.js +3 -2
  445. package/lib/node/oracles/utils.d.ts +4 -0
  446. package/lib/node/oracles/utils.d.ts.map +1 -1
  447. package/lib/node/oracles/utils.js +9 -1
  448. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
  449. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  450. package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
  451. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
  452. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
  453. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -1
  454. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  455. package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
  456. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
  457. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
  458. package/lib/node/pyth/types.d.ts +0 -1
  459. package/lib/node/pyth/types.d.ts.map +1 -1
  460. package/lib/node/slot/SlotSubscriber.d.ts +1 -1
  461. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
  462. package/lib/node/slot/SlotSubscriber.js +2 -1
  463. package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
  464. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
  465. package/lib/node/slot/SlothashSubscriber.js +11 -4
  466. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
  467. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
  468. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
  469. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
  470. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  471. package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
  472. package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
  473. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  474. package/lib/node/swift/swiftOrderSubscriber.js +10 -5
  475. package/lib/node/testClient.js +3 -2
  476. package/lib/node/tokenFaucet.d.ts.map +1 -1
  477. package/lib/node/tokenFaucet.js +16 -2
  478. package/lib/node/tx/baseTxSender.d.ts +4 -4
  479. package/lib/node/tx/baseTxSender.d.ts.map +1 -1
  480. package/lib/node/tx/baseTxSender.js +5 -4
  481. package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
  482. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
  483. package/lib/node/tx/fastSingleTxSender.js +9 -5
  484. package/lib/node/tx/reportTransactionError.d.ts +2 -2
  485. package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
  486. package/lib/node/tx/reportTransactionError.js +5 -1
  487. package/lib/node/tx/retryTxSender.d.ts +1 -1
  488. package/lib/node/tx/retryTxSender.d.ts.map +1 -1
  489. package/lib/node/tx/retryTxSender.js +4 -2
  490. package/lib/node/tx/txHandler.d.ts +9 -3
  491. package/lib/node/tx/txHandler.d.ts.map +1 -1
  492. package/lib/node/tx/txHandler.js +54 -40
  493. package/lib/node/tx/txParamProcessor.d.ts +4 -1
  494. package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
  495. package/lib/node/tx/txParamProcessor.js +6 -0
  496. package/lib/node/tx/types.d.ts +1 -1
  497. package/lib/node/tx/types.d.ts.map +1 -1
  498. package/lib/node/tx/whileValidTxSender.d.ts +1 -6
  499. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
  500. package/lib/node/tx/whileValidTxSender.js +35 -13
  501. package/lib/node/types.d.ts +25 -68
  502. package/lib/node/types.d.ts.map +1 -1
  503. package/lib/node/types.js +2 -2
  504. package/lib/node/user.d.ts +21 -7
  505. package/lib/node/user.d.ts.map +1 -1
  506. package/lib/node/user.js +156 -132
  507. package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
  508. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
  509. package/lib/node/userMap/grpcSubscription.d.ts +1 -1
  510. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
  511. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  512. package/lib/node/userMap/referrerMap.js +10 -3
  513. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  514. package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
  515. package/lib/node/userMap/userMap.d.ts +1 -1
  516. package/lib/node/userMap/userMap.d.ts.map +1 -1
  517. package/lib/node/userMap/userMap.js +36 -23
  518. package/lib/node/userMap/userStatsMap.d.ts +1 -1
  519. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  520. package/lib/node/userMap/userStatsMap.js +18 -13
  521. package/lib/node/userStats.d.ts +7 -2
  522. package/lib/node/userStats.d.ts.map +1 -1
  523. package/lib/node/userStats.js +18 -4
  524. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
  525. package/lib/node/util/TransactionConfirmationManager.js +4 -2
  526. package/lib/node/util/chainClock.d.ts +1 -1
  527. package/lib/node/util/chainClock.d.ts.map +1 -1
  528. package/lib/node/util/computeUnits.d.ts +1 -1
  529. package/lib/node/util/computeUnits.d.ts.map +1 -1
  530. package/lib/node/util/computeUnits.js +6 -1
  531. package/lib/node/velocityClient.d.ts +93 -35
  532. package/lib/node/velocityClient.d.ts.map +1 -1
  533. package/lib/node/velocityClient.js +414 -280
  534. package/package.json +5 -3
  535. package/src/accounts/basicUserAccountSubscriber.ts +7 -5
  536. package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
  537. package/src/accounts/bulkAccountLoader.ts +20 -7
  538. package/src/accounts/grpcAccountSubscriber.ts +11 -3
  539. package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
  540. package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
  541. package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
  542. package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
  543. package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
  544. package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
  545. package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
  546. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
  547. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
  548. package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
  549. package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
  550. package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
  551. package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
  552. package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
  553. package/src/accounts/types.ts +6 -4
  554. package/src/accounts/utils.ts +10 -0
  555. package/src/accounts/webSocketAccountSubscriber.ts +23 -10
  556. package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
  557. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
  558. package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
  559. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
  560. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
  561. package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
  562. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
  563. package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
  564. package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
  565. package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
  566. package/src/addresses/marketAddresses.ts +3 -2
  567. package/src/addresses/pda.ts +0 -25
  568. package/src/adminClient.ts +273 -303
  569. package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
  570. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
  571. package/src/bankrun/bankrunConnection.ts +83 -39
  572. package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
  573. package/src/clock/clockSubscriber.ts +10 -9
  574. package/src/config.ts +8 -3
  575. package/src/constants/index.ts +1 -2
  576. package/src/constants/numericConstants.ts +3 -3
  577. package/src/constituentMap/constituentMap.ts +8 -1
  578. package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
  579. package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
  580. package/src/core/instructions/perpOrders.ts +14 -0
  581. package/src/core/remainingAccounts.ts +4 -4
  582. package/src/decode/user.ts +8 -1
  583. package/src/dlob/DLOB.ts +296 -172
  584. package/src/dlob/DLOBNode.ts +23 -3
  585. package/src/dlob/DLOBSubscriber.ts +51 -34
  586. package/src/dlob/NodeList.ts +8 -7
  587. package/src/dlob/orderBookLevels.ts +45 -25
  588. package/src/events/eventList.ts +4 -1
  589. package/src/events/eventSubscriber.ts +107 -49
  590. package/src/events/eventsServerLogProvider.ts +22 -13
  591. package/src/events/fetchLogs.ts +3 -3
  592. package/src/events/pollingLogProvider.ts +2 -2
  593. package/src/events/txEventCache.ts +8 -2
  594. package/src/events/types.ts +0 -8
  595. package/src/events/webSocketLogProvider.ts +5 -3
  596. package/src/factory/bigNum.ts +2 -2
  597. package/src/idl/velocity.json +1234 -1577
  598. package/src/idl/velocity.ts +1234 -1577
  599. package/src/index.ts +0 -2
  600. package/src/jupiter/jupiterClient.ts +30 -10
  601. package/src/marginCalculation.ts +1 -0
  602. package/src/math/amm.ts +188 -33
  603. package/src/math/bankruptcy.ts +1 -1
  604. package/src/math/funding.ts +7 -6
  605. package/src/math/insurance.ts +6 -8
  606. package/src/math/margin.ts +5 -112
  607. package/src/math/market.ts +6 -96
  608. package/src/math/oracles.ts +0 -17
  609. package/src/math/orders.ts +1 -110
  610. package/src/math/position.ts +4 -16
  611. package/src/math/repeg.ts +0 -29
  612. package/src/math/spotBalance.ts +14 -10
  613. package/src/math/spotMarket.ts +2 -28
  614. package/src/math/spotPosition.ts +4 -4
  615. package/src/math/state.ts +0 -8
  616. package/src/math/superStake.ts +19 -65
  617. package/src/math/trade.ts +2 -6
  618. package/src/memcmp.ts +0 -9
  619. package/src/oracles/prelaunchOracleClient.ts +7 -2
  620. package/src/oracles/pythClient.ts +12 -3
  621. package/src/oracles/pythLazerClient.ts +7 -2
  622. package/src/oracles/utils.ts +15 -0
  623. package/src/orderSubscriber/OrderSubscriber.ts +10 -4
  624. package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
  625. package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
  626. package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
  627. package/src/pyth/types.ts +0 -2
  628. package/src/slot/SlotSubscriber.ts +3 -3
  629. package/src/slot/SlothashSubscriber.ts +17 -6
  630. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
  631. package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
  632. package/src/swift/swiftOrderSubscriber.ts +10 -9
  633. package/src/testClient.ts +2 -2
  634. package/src/tokenFaucet.ts +22 -3
  635. package/src/tx/baseTxSender.ts +10 -10
  636. package/src/tx/fastSingleTxSender.ts +12 -8
  637. package/src/tx/reportTransactionError.ts +12 -7
  638. package/src/tx/retryTxSender.ts +6 -4
  639. package/src/tx/txHandler.ts +88 -43
  640. package/src/tx/txParamProcessor.ts +18 -3
  641. package/src/tx/types.ts +1 -1
  642. package/src/tx/whileValidTxSender.ts +51 -22
  643. package/src/types.ts +39 -75
  644. package/src/user.ts +200 -152
  645. package/src/userMap/WebsocketSubscription.ts +1 -1
  646. package/src/userMap/grpcSubscription.ts +1 -1
  647. package/src/userMap/referrerMap.ts +13 -9
  648. package/src/userMap/revenueShareEscrowMap.ts +6 -1
  649. package/src/userMap/userMap.ts +43 -25
  650. package/src/userMap/userStatsMap.ts +32 -19
  651. package/src/userStats.ts +21 -8
  652. package/src/util/TransactionConfirmationManager.ts +10 -2
  653. package/src/util/chainClock.ts +1 -1
  654. package/src/util/computeUnits.ts +7 -3
  655. package/src/velocityClient.ts +536 -383
  656. package/tests/amm/test.ts +138 -0
  657. package/tests/dlob/helpers.ts +6 -1
  658. package/tsconfig.json +1 -0
  659. package/lib/browser/constants/insuranceFund.d.ts +0 -5
  660. package/lib/browser/constants/insuranceFund.js +0 -9
  661. package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
  662. package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
  663. package/lib/browser/util/tps.d.ts +0 -2
  664. package/lib/browser/util/tps.js +0 -16
  665. package/lib/node/constants/insuranceFund.d.ts +0 -6
  666. package/lib/node/constants/insuranceFund.d.ts.map +0 -1
  667. package/lib/node/constants/insuranceFund.js +0 -9
  668. package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
  669. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
  670. package/lib/node/tx/forwardOnlyTxSender.js +0 -92
  671. package/lib/node/util/tps.d.ts +0 -3
  672. package/lib/node/util/tps.d.ts.map +0 -1
  673. package/lib/node/util/tps.js +0 -16
  674. package/src/constants/insuranceFund.ts +0 -8
  675. package/src/tx/forwardOnlyTxSender.ts +0 -145
  676. package/src/util/tps.ts +0 -27
@@ -443,250 +443,6 @@
443
443
  }
444
444
  ]
445
445
  },
446
- {
447
- "name": "admin_withdraw_from_insurance_fund_vault",
448
- "discriminator": [
449
- 228,
450
- 208,
451
- 191,
452
- 246,
453
- 169,
454
- 58,
455
- 189,
456
- 213
457
- ],
458
- "accounts": [
459
- {
460
- "name": "state"
461
- },
462
- {
463
- "name": "authority",
464
- "writable": true,
465
- "signer": true
466
- },
467
- {
468
- "name": "spot_market",
469
- "writable": true,
470
- "pda": {
471
- "seeds": [
472
- {
473
- "kind": "const",
474
- "value": [
475
- 115,
476
- 112,
477
- 111,
478
- 116,
479
- 95,
480
- 109,
481
- 97,
482
- 114,
483
- 107,
484
- 101,
485
- 116
486
- ]
487
- },
488
- {
489
- "kind": "arg",
490
- "path": "market_index"
491
- }
492
- ]
493
- }
494
- },
495
- {
496
- "name": "insurance_fund_vault",
497
- "writable": true,
498
- "pda": {
499
- "seeds": [
500
- {
501
- "kind": "const",
502
- "value": [
503
- 105,
504
- 110,
505
- 115,
506
- 117,
507
- 114,
508
- 97,
509
- 110,
510
- 99,
511
- 101,
512
- 95,
513
- 102,
514
- 117,
515
- 110,
516
- 100,
517
- 95,
518
- 118,
519
- 97,
520
- 117,
521
- 108,
522
- 116
523
- ]
524
- },
525
- {
526
- "kind": "arg",
527
- "path": "market_index"
528
- }
529
- ]
530
- }
531
- },
532
- {
533
- "name": "recipient_token_account",
534
- "writable": true
535
- },
536
- {
537
- "name": "token_program"
538
- },
539
- {
540
- "name": "velocity_signer"
541
- }
542
- ],
543
- "args": [
544
- {
545
- "name": "market_index",
546
- "type": "u16"
547
- },
548
- {
549
- "name": "amount",
550
- "type": "u64"
551
- }
552
- ]
553
- },
554
- {
555
- "name": "begin_insurance_fund_swap",
556
- "discriminator": [
557
- 176,
558
- 69,
559
- 143,
560
- 205,
561
- 32,
562
- 132,
563
- 163,
564
- 0
565
- ],
566
- "accounts": [
567
- {
568
- "name": "state"
569
- },
570
- {
571
- "name": "authority",
572
- "writable": true,
573
- "signer": true
574
- },
575
- {
576
- "name": "out_insurance_fund_vault",
577
- "writable": true,
578
- "pda": {
579
- "seeds": [
580
- {
581
- "kind": "const",
582
- "value": [
583
- 105,
584
- 110,
585
- 115,
586
- 117,
587
- 114,
588
- 97,
589
- 110,
590
- 99,
591
- 101,
592
- 95,
593
- 102,
594
- 117,
595
- 110,
596
- 100,
597
- 95,
598
- 118,
599
- 97,
600
- 117,
601
- 108,
602
- 116
603
- ]
604
- },
605
- {
606
- "kind": "arg",
607
- "path": "out_market_index"
608
- }
609
- ]
610
- }
611
- },
612
- {
613
- "name": "in_insurance_fund_vault",
614
- "writable": true,
615
- "pda": {
616
- "seeds": [
617
- {
618
- "kind": "const",
619
- "value": [
620
- 105,
621
- 110,
622
- 115,
623
- 117,
624
- 114,
625
- 97,
626
- 110,
627
- 99,
628
- 101,
629
- 95,
630
- 102,
631
- 117,
632
- 110,
633
- 100,
634
- 95,
635
- 118,
636
- 97,
637
- 117,
638
- 108,
639
- 116
640
- ]
641
- },
642
- {
643
- "kind": "arg",
644
- "path": "in_market_index"
645
- }
646
- ]
647
- }
648
- },
649
- {
650
- "name": "out_token_account",
651
- "writable": true
652
- },
653
- {
654
- "name": "in_token_account",
655
- "writable": true
656
- },
657
- {
658
- "name": "if_rebalance_config",
659
- "writable": true
660
- },
661
- {
662
- "name": "token_program"
663
- },
664
- {
665
- "name": "velocity_signer"
666
- },
667
- {
668
- "name": "instructions",
669
- "docs": [
670
- "Instructions Sysvar for instruction introspection"
671
- ],
672
- "address": "Sysvar1nstructions1111111111111111111111111"
673
- }
674
- ],
675
- "args": [
676
- {
677
- "name": "in_market_index",
678
- "type": "u16"
679
- },
680
- {
681
- "name": "out_market_index",
682
- "type": "u16"
683
- },
684
- {
685
- "name": "amount_in",
686
- "type": "u64"
687
- }
688
- ]
689
- },
690
446
  {
691
447
  "name": "begin_lp_swap",
692
448
  "discriminator": [
@@ -1786,203 +1542,16 @@
1786
1542
  ]
1787
1543
  },
1788
1544
  {
1789
- "name": "deposit_into_insurance_fund_stake",
1545
+ "name": "deposit_into_isolated_perp_position",
1790
1546
  "discriminator": [
1791
- 4,
1792
- 22,
1793
- 226,
1794
- 201,
1795
- 124,
1796
- 44,
1797
- 82,
1798
- 230
1799
- ],
1800
- "accounts": [
1801
- {
1802
- "name": "signer",
1803
- "signer": true
1804
- },
1805
- {
1806
- "name": "state",
1807
- "writable": true
1808
- },
1809
- {
1810
- "name": "spot_market",
1811
- "writable": true,
1812
- "pda": {
1813
- "seeds": [
1814
- {
1815
- "kind": "const",
1816
- "value": [
1817
- 115,
1818
- 112,
1819
- 111,
1820
- 116,
1821
- 95,
1822
- 109,
1823
- 97,
1824
- 114,
1825
- 107,
1826
- 101,
1827
- 116
1828
- ]
1829
- },
1830
- {
1831
- "kind": "arg",
1832
- "path": "market_index"
1833
- }
1834
- ]
1835
- }
1836
- },
1837
- {
1838
- "name": "insurance_fund_stake",
1839
- "writable": true,
1840
- "pda": {
1841
- "seeds": [
1842
- {
1843
- "kind": "const",
1844
- "value": [
1845
- 105,
1846
- 110,
1847
- 115,
1848
- 117,
1849
- 114,
1850
- 97,
1851
- 110,
1852
- 99,
1853
- 101,
1854
- 95,
1855
- 102,
1856
- 117,
1857
- 110,
1858
- 100,
1859
- 95,
1860
- 115,
1861
- 116,
1862
- 97,
1863
- 107,
1864
- 101
1865
- ]
1866
- },
1867
- {
1868
- "kind": "account",
1869
- "path": "user_stats"
1870
- },
1871
- {
1872
- "kind": "arg",
1873
- "path": "market_index"
1874
- }
1875
- ]
1876
- }
1877
- },
1878
- {
1879
- "name": "user_stats",
1880
- "writable": true
1881
- },
1882
- {
1883
- "name": "spot_market_vault",
1884
- "writable": true,
1885
- "pda": {
1886
- "seeds": [
1887
- {
1888
- "kind": "const",
1889
- "value": [
1890
- 115,
1891
- 112,
1892
- 111,
1893
- 116,
1894
- 95,
1895
- 109,
1896
- 97,
1897
- 114,
1898
- 107,
1899
- 101,
1900
- 116,
1901
- 95,
1902
- 118,
1903
- 97,
1904
- 117,
1905
- 108,
1906
- 116
1907
- ]
1908
- },
1909
- {
1910
- "kind": "arg",
1911
- "path": "market_index"
1912
- }
1913
- ]
1914
- }
1915
- },
1916
- {
1917
- "name": "insurance_fund_vault",
1918
- "writable": true,
1919
- "pda": {
1920
- "seeds": [
1921
- {
1922
- "kind": "const",
1923
- "value": [
1924
- 105,
1925
- 110,
1926
- 115,
1927
- 117,
1928
- 114,
1929
- 97,
1930
- 110,
1931
- 99,
1932
- 101,
1933
- 95,
1934
- 102,
1935
- 117,
1936
- 110,
1937
- 100,
1938
- 95,
1939
- 118,
1940
- 97,
1941
- 117,
1942
- 108,
1943
- 116
1944
- ]
1945
- },
1946
- {
1947
- "kind": "arg",
1948
- "path": "market_index"
1949
- }
1950
- ]
1951
- }
1952
- },
1953
- {
1954
- "name": "user_token_account",
1955
- "writable": true
1956
- },
1957
- {
1958
- "name": "token_program"
1959
- },
1960
- {
1961
- "name": "velocity_signer"
1962
- }
1963
- ],
1964
- "args": [
1965
- {
1966
- "name": "market_index",
1967
- "type": "u16"
1968
- },
1969
- {
1970
- "name": "amount",
1971
- "type": "u64"
1972
- }
1973
- ]
1974
- },
1975
- {
1976
- "name": "deposit_into_isolated_perp_position",
1977
- "discriminator": [
1978
- 101,
1979
- 48,
1980
- 255,
1981
- 153,
1982
- 127,
1983
- 121,
1984
- 170,
1985
- 26
1547
+ 101,
1548
+ 48,
1549
+ 255,
1550
+ 153,
1551
+ 127,
1552
+ 121,
1553
+ 170,
1554
+ 26
1986
1555
  ],
1987
1556
  "accounts": [
1988
1557
  {
@@ -2340,185 +1909,53 @@
2340
1909
  ]
2341
1910
  },
2342
1911
  {
2343
- "name": "end_insurance_fund_swap",
1912
+ "name": "end_lp_swap",
2344
1913
  "discriminator": [
2345
- 206,
2346
- 230,
2347
- 98,
2348
- 8,
2349
- 249,
2350
- 158,
2351
- 169,
2352
- 167
1914
+ 99,
1915
+ 125,
1916
+ 214,
1917
+ 165,
1918
+ 129,
1919
+ 175,
1920
+ 253,
1921
+ 135
2353
1922
  ],
2354
1923
  "accounts": [
2355
1924
  {
2356
1925
  "name": "state"
2357
1926
  },
2358
1927
  {
2359
- "name": "authority",
1928
+ "name": "admin",
2360
1929
  "writable": true,
2361
1930
  "signer": true
2362
1931
  },
2363
1932
  {
2364
- "name": "out_insurance_fund_vault",
2365
- "writable": true,
2366
- "pda": {
2367
- "seeds": [
2368
- {
2369
- "kind": "const",
2370
- "value": [
2371
- 105,
2372
- 110,
2373
- 115,
2374
- 117,
2375
- 114,
2376
- 97,
2377
- 110,
2378
- 99,
2379
- 101,
2380
- 95,
2381
- 102,
2382
- 117,
2383
- 110,
2384
- 100,
2385
- 95,
2386
- 118,
2387
- 97,
2388
- 117,
2389
- 108,
2390
- 116
2391
- ]
2392
- },
2393
- {
2394
- "kind": "arg",
2395
- "path": "out_market_index"
2396
- }
2397
- ]
2398
- }
2399
- },
2400
- {
2401
- "name": "in_insurance_fund_vault",
2402
- "writable": true,
2403
- "pda": {
2404
- "seeds": [
2405
- {
2406
- "kind": "const",
2407
- "value": [
2408
- 105,
2409
- 110,
2410
- 115,
2411
- 117,
2412
- 114,
2413
- 97,
2414
- 110,
2415
- 99,
2416
- 101,
2417
- 95,
2418
- 102,
2419
- 117,
2420
- 110,
2421
- 100,
2422
- 95,
2423
- 118,
2424
- 97,
2425
- 117,
2426
- 108,
2427
- 116
2428
- ]
2429
- },
2430
- {
2431
- "kind": "arg",
2432
- "path": "in_market_index"
2433
- }
2434
- ]
2435
- }
2436
- },
2437
- {
2438
- "name": "out_token_account",
2439
- "writable": true
2440
- },
2441
- {
2442
- "name": "in_token_account",
2443
- "writable": true
2444
- },
2445
- {
2446
- "name": "if_rebalance_config",
2447
- "writable": true
2448
- },
2449
- {
2450
- "name": "token_program"
2451
- },
2452
- {
2453
- "name": "velocity_signer"
2454
- },
2455
- {
2456
- "name": "instructions",
2457
- "docs": [
2458
- "Instructions Sysvar for instruction introspection"
2459
- ],
2460
- "address": "Sysvar1nstructions1111111111111111111111111"
2461
- }
2462
- ],
2463
- "args": [
2464
- {
2465
- "name": "in_market_index",
2466
- "type": "u16"
2467
- },
2468
- {
2469
- "name": "out_market_index",
2470
- "type": "u16"
2471
- }
2472
- ]
2473
- },
2474
- {
2475
- "name": "end_lp_swap",
2476
- "discriminator": [
2477
- 99,
2478
- 125,
2479
- 214,
2480
- 165,
2481
- 129,
2482
- 175,
2483
- 253,
2484
- 135
2485
- ],
2486
- "accounts": [
2487
- {
2488
- "name": "state"
2489
- },
2490
- {
2491
- "name": "admin",
2492
- "writable": true,
2493
- "signer": true
2494
- },
2495
- {
2496
- "name": "signer_out_token_account",
2497
- "docs": [
2498
- "Signer token accounts"
2499
- ],
2500
- "writable": true
2501
- },
2502
- {
2503
- "name": "signer_in_token_account",
2504
- "writable": true
2505
- },
2506
- {
2507
- "name": "constituent_out_token_account",
2508
- "docs": [
2509
- "Constituent token accounts"
2510
- ],
2511
- "writable": true
2512
- },
2513
- {
2514
- "name": "constituent_in_token_account",
2515
- "writable": true
2516
- },
2517
- {
2518
- "name": "out_constituent",
2519
- "docs": [
2520
- "Constituents"
2521
- ],
1933
+ "name": "signer_out_token_account",
1934
+ "docs": [
1935
+ "Signer token accounts"
1936
+ ],
1937
+ "writable": true
1938
+ },
1939
+ {
1940
+ "name": "signer_in_token_account",
1941
+ "writable": true
1942
+ },
1943
+ {
1944
+ "name": "constituent_out_token_account",
1945
+ "docs": [
1946
+ "Constituent token accounts"
1947
+ ],
1948
+ "writable": true
1949
+ },
1950
+ {
1951
+ "name": "constituent_in_token_account",
1952
+ "writable": true
1953
+ },
1954
+ {
1955
+ "name": "out_constituent",
1956
+ "docs": [
1957
+ "Constituents"
1958
+ ],
2522
1959
  "writable": true,
2523
1960
  "pda": {
2524
1961
  "seeds": [
@@ -3349,87 +2786,6 @@
3349
2786
  }
3350
2787
  ]
3351
2788
  },
3352
- {
3353
- "name": "initialize_if_rebalance_config",
3354
- "discriminator": [
3355
- 8,
3356
- 85,
3357
- 184,
3358
- 167,
3359
- 176,
3360
- 61,
3361
- 173,
3362
- 226
3363
- ],
3364
- "accounts": [
3365
- {
3366
- "name": "admin",
3367
- "writable": true,
3368
- "signer": true
3369
- },
3370
- {
3371
- "name": "if_rebalance_config",
3372
- "writable": true,
3373
- "pda": {
3374
- "seeds": [
3375
- {
3376
- "kind": "const",
3377
- "value": [
3378
- 105,
3379
- 102,
3380
- 95,
3381
- 114,
3382
- 101,
3383
- 98,
3384
- 97,
3385
- 108,
3386
- 97,
3387
- 110,
3388
- 99,
3389
- 101,
3390
- 95,
3391
- 99,
3392
- 111,
3393
- 110,
3394
- 102,
3395
- 105,
3396
- 103
3397
- ]
3398
- },
3399
- {
3400
- "kind": "arg",
3401
- "path": "params.in_market_index"
3402
- },
3403
- {
3404
- "kind": "arg",
3405
- "path": "params.out_market_index"
3406
- }
3407
- ]
3408
- }
3409
- },
3410
- {
3411
- "name": "state"
3412
- },
3413
- {
3414
- "name": "rent",
3415
- "address": "SysvarRent111111111111111111111111111111111"
3416
- },
3417
- {
3418
- "name": "system_program",
3419
- "address": "11111111111111111111111111111111"
3420
- }
3421
- ],
3422
- "args": [
3423
- {
3424
- "name": "params",
3425
- "type": {
3426
- "defined": {
3427
- "name": "IfRebalanceConfigParams"
3428
- }
3429
- }
3430
- }
3431
- ]
3432
- },
3433
2789
  {
3434
2790
  "name": "initialize_insurance_fund_stake",
3435
2791
  "discriminator": [
@@ -8123,75 +7479,164 @@
8123
7479
  ]
8124
7480
  },
8125
7481
  {
8126
- "name": "transfer_deposit",
7482
+ "name": "sweep_perp_market_fees",
8127
7483
  "discriminator": [
8128
- 20,
8129
- 20,
7484
+ 194,
8130
7485
  147,
8131
- 223,
8132
- 41,
8133
- 63,
8134
- 204,
8135
- 111
7486
+ 181,
7487
+ 230,
7488
+ 193,
7489
+ 155,
7490
+ 241,
7491
+ 225
8136
7492
  ],
8137
7493
  "accounts": [
8138
- {
8139
- "name": "from_user",
8140
- "writable": true
8141
- },
8142
- {
8143
- "name": "to_user",
8144
- "writable": true
8145
- },
8146
- {
8147
- "name": "user_stats",
8148
- "writable": true
8149
- },
8150
- {
8151
- "name": "authority",
8152
- "signer": true,
8153
- "relations": [
8154
- "from_user",
8155
- "to_user",
8156
- "user_stats"
8157
- ]
8158
- },
8159
7494
  {
8160
7495
  "name": "state"
8161
7496
  },
8162
7497
  {
8163
- "name": "spot_market_vault",
7498
+ "name": "perp_market",
7499
+ "writable": true,
8164
7500
  "pda": {
8165
7501
  "seeds": [
8166
7502
  {
8167
7503
  "kind": "const",
8168
7504
  "value": [
8169
- 115,
8170
7505
  112,
8171
- 111,
8172
- 116,
7506
+ 101,
7507
+ 114,
7508
+ 112,
8173
7509
  95,
8174
7510
  109,
8175
7511
  97,
8176
7512
  114,
8177
7513
  107,
8178
7514
  101,
8179
- 116,
8180
- 95,
8181
- 118,
8182
- 97,
8183
- 117,
8184
- 108,
8185
7515
  116
8186
7516
  ]
8187
7517
  },
8188
7518
  {
8189
7519
  "kind": "arg",
8190
- "path": "market_index"
7520
+ "path": "perp_market_index"
8191
7521
  }
8192
7522
  ]
8193
7523
  }
8194
- }
7524
+ },
7525
+ {
7526
+ "name": "spot_market",
7527
+ "docs": [
7528
+ "The perp market's quote spot market (enforced by the PDA derivation)"
7529
+ ],
7530
+ "writable": true,
7531
+ "pda": {
7532
+ "seeds": [
7533
+ {
7534
+ "kind": "const",
7535
+ "value": [
7536
+ 115,
7537
+ 112,
7538
+ 111,
7539
+ 116,
7540
+ 95,
7541
+ 109,
7542
+ 97,
7543
+ 114,
7544
+ 107,
7545
+ 101,
7546
+ 116
7547
+ ]
7548
+ },
7549
+ {
7550
+ "kind": "account",
7551
+ "path": "perp_market"
7552
+ }
7553
+ ]
7554
+ }
7555
+ },
7556
+ {
7557
+ "name": "oracle",
7558
+ "relations": [
7559
+ "perp_market"
7560
+ ]
7561
+ }
7562
+ ],
7563
+ "args": [
7564
+ {
7565
+ "name": "perp_market_index",
7566
+ "type": "u16"
7567
+ }
7568
+ ]
7569
+ },
7570
+ {
7571
+ "name": "transfer_deposit",
7572
+ "discriminator": [
7573
+ 20,
7574
+ 20,
7575
+ 147,
7576
+ 223,
7577
+ 41,
7578
+ 63,
7579
+ 204,
7580
+ 111
7581
+ ],
7582
+ "accounts": [
7583
+ {
7584
+ "name": "from_user",
7585
+ "writable": true
7586
+ },
7587
+ {
7588
+ "name": "to_user",
7589
+ "writable": true
7590
+ },
7591
+ {
7592
+ "name": "user_stats",
7593
+ "writable": true
7594
+ },
7595
+ {
7596
+ "name": "authority",
7597
+ "signer": true,
7598
+ "relations": [
7599
+ "from_user",
7600
+ "to_user",
7601
+ "user_stats"
7602
+ ]
7603
+ },
7604
+ {
7605
+ "name": "state"
7606
+ },
7607
+ {
7608
+ "name": "spot_market_vault",
7609
+ "pda": {
7610
+ "seeds": [
7611
+ {
7612
+ "kind": "const",
7613
+ "value": [
7614
+ 115,
7615
+ 112,
7616
+ 111,
7617
+ 116,
7618
+ 95,
7619
+ 109,
7620
+ 97,
7621
+ 114,
7622
+ 107,
7623
+ 101,
7624
+ 116,
7625
+ 95,
7626
+ 118,
7627
+ 97,
7628
+ 117,
7629
+ 108,
7630
+ 116
7631
+ ]
7632
+ },
7633
+ {
7634
+ "kind": "arg",
7635
+ "path": "market_index"
7636
+ }
7637
+ ]
7638
+ }
7639
+ }
8195
7640
  ],
8196
7641
  "args": [
8197
7642
  {
@@ -8727,120 +8172,6 @@
8727
8172
  }
8728
8173
  ]
8729
8174
  },
8730
- {
8731
- "name": "transfer_protocol_if_shares_to_revenue_pool",
8732
- "discriminator": [
8733
- 236,
8734
- 136,
8735
- 147,
8736
- 153,
8737
- 146,
8738
- 205,
8739
- 104,
8740
- 29
8741
- ],
8742
- "accounts": [
8743
- {
8744
- "name": "state"
8745
- },
8746
- {
8747
- "name": "authority",
8748
- "writable": true,
8749
- "signer": true
8750
- },
8751
- {
8752
- "name": "insurance_fund_vault",
8753
- "writable": true,
8754
- "pda": {
8755
- "seeds": [
8756
- {
8757
- "kind": "const",
8758
- "value": [
8759
- 105,
8760
- 110,
8761
- 115,
8762
- 117,
8763
- 114,
8764
- 97,
8765
- 110,
8766
- 99,
8767
- 101,
8768
- 95,
8769
- 102,
8770
- 117,
8771
- 110,
8772
- 100,
8773
- 95,
8774
- 118,
8775
- 97,
8776
- 117,
8777
- 108,
8778
- 116
8779
- ]
8780
- },
8781
- {
8782
- "kind": "arg",
8783
- "path": "market_index"
8784
- }
8785
- ]
8786
- }
8787
- },
8788
- {
8789
- "name": "spot_market_vault",
8790
- "writable": true,
8791
- "pda": {
8792
- "seeds": [
8793
- {
8794
- "kind": "const",
8795
- "value": [
8796
- 115,
8797
- 112,
8798
- 111,
8799
- 116,
8800
- 95,
8801
- 109,
8802
- 97,
8803
- 114,
8804
- 107,
8805
- 101,
8806
- 116,
8807
- 95,
8808
- 118,
8809
- 97,
8810
- 117,
8811
- 108,
8812
- 116
8813
- ]
8814
- },
8815
- {
8816
- "kind": "arg",
8817
- "path": "market_index"
8818
- }
8819
- ]
8820
- }
8821
- },
8822
- {
8823
- "name": "if_rebalance_config",
8824
- "writable": true
8825
- },
8826
- {
8827
- "name": "token_program"
8828
- },
8829
- {
8830
- "name": "velocity_signer"
8831
- }
8832
- ],
8833
- "args": [
8834
- {
8835
- "name": "market_index",
8836
- "type": "u16"
8837
- },
8838
- {
8839
- "name": "amount",
8840
- "type": "u64"
8841
- }
8842
- ]
8843
- },
8844
8175
  {
8845
8176
  "name": "trigger_order",
8846
8177
  "discriminator": [
@@ -9359,117 +8690,16 @@
9359
8690
  ]
9360
8691
  },
9361
8692
  {
9362
- "name": "update_delegate_user_gov_token_insurance_stake",
8693
+ "name": "update_discount_mint",
9363
8694
  "discriminator": [
9364
- 241,
9365
- 29,
9366
- 215,
9367
- 228,
9368
- 142,
9369
- 116,
9370
- 22,
9371
- 160
9372
- ],
9373
- "accounts": [
9374
- {
9375
- "name": "spot_market",
9376
- "writable": true,
9377
- "pda": {
9378
- "seeds": [
9379
- {
9380
- "kind": "const",
9381
- "value": [
9382
- 115,
9383
- 112,
9384
- 111,
9385
- 116,
9386
- 95,
9387
- 109,
9388
- 97,
9389
- 114,
9390
- 107,
9391
- 101,
9392
- 116
9393
- ]
9394
- },
9395
- {
9396
- "kind": "const",
9397
- "value": [
9398
- 15,
9399
- 0
9400
- ]
9401
- }
9402
- ]
9403
- }
9404
- },
9405
- {
9406
- "name": "insurance_fund_stake"
9407
- },
9408
- {
9409
- "name": "user_stats",
9410
- "writable": true
9411
- },
9412
- {
9413
- "name": "admin",
9414
- "signer": true
9415
- },
9416
- {
9417
- "name": "insurance_fund_vault",
9418
- "writable": true,
9419
- "pda": {
9420
- "seeds": [
9421
- {
9422
- "kind": "const",
9423
- "value": [
9424
- 105,
9425
- 110,
9426
- 115,
9427
- 117,
9428
- 114,
9429
- 97,
9430
- 110,
9431
- 99,
9432
- 101,
9433
- 95,
9434
- 102,
9435
- 117,
9436
- 110,
9437
- 100,
9438
- 95,
9439
- 118,
9440
- 97,
9441
- 117,
9442
- 108,
9443
- 116
9444
- ]
9445
- },
9446
- {
9447
- "kind": "const",
9448
- "value": [
9449
- 15,
9450
- 0
9451
- ]
9452
- }
9453
- ]
9454
- }
9455
- },
9456
- {
9457
- "name": "state"
9458
- }
9459
- ],
9460
- "args": []
9461
- },
9462
- {
9463
- "name": "update_discount_mint",
9464
- "discriminator": [
9465
- 32,
9466
- 252,
9467
- 122,
9468
- 211,
9469
- 66,
9470
- 31,
9471
- 47,
9472
- 241
8695
+ 32,
8696
+ 252,
8697
+ 122,
8698
+ 211,
8699
+ 66,
8700
+ 31,
8701
+ 47,
8702
+ 241
9473
8703
  ],
9474
8704
  "accounts": [
9475
8705
  {
@@ -9759,43 +8989,6 @@
9759
8989
  }
9760
8990
  ]
9761
8991
  },
9762
- {
9763
- "name": "update_if_rebalance_config",
9764
- "discriminator": [
9765
- 142,
9766
- 245,
9767
- 249,
9768
- 66,
9769
- 249,
9770
- 181,
9771
- 22,
9772
- 83
9773
- ],
9774
- "accounts": [
9775
- {
9776
- "name": "admin",
9777
- "writable": true,
9778
- "signer": true
9779
- },
9780
- {
9781
- "name": "if_rebalance_config",
9782
- "writable": true
9783
- },
9784
- {
9785
- "name": "state"
9786
- }
9787
- ],
9788
- "args": [
9789
- {
9790
- "name": "params",
9791
- "type": {
9792
- "defined": {
9793
- "name": "IfRebalanceConfigParams"
9794
- }
9795
- }
9796
- }
9797
- ]
9798
- },
9799
8992
  {
9800
8993
  "name": "update_initial_amm_cache_info",
9801
8994
  "discriminator": [
@@ -10632,6 +9825,70 @@
10632
9825
  }
10633
9826
  ]
10634
9827
  },
9828
+ {
9829
+ "name": "update_perp_market_fee_pool_buffer_target",
9830
+ "discriminator": [
9831
+ 125,
9832
+ 234,
9833
+ 40,
9834
+ 44,
9835
+ 91,
9836
+ 26,
9837
+ 231,
9838
+ 177
9839
+ ],
9840
+ "accounts": [
9841
+ {
9842
+ "name": "admin",
9843
+ "signer": true
9844
+ },
9845
+ {
9846
+ "name": "state"
9847
+ },
9848
+ {
9849
+ "name": "perp_market",
9850
+ "writable": true
9851
+ }
9852
+ ],
9853
+ "args": [
9854
+ {
9855
+ "name": "fee_pool_buffer_target",
9856
+ "type": "u64"
9857
+ }
9858
+ ]
9859
+ },
9860
+ {
9861
+ "name": "update_perp_market_funding_bias_sensitivity",
9862
+ "discriminator": [
9863
+ 143,
9864
+ 62,
9865
+ 234,
9866
+ 145,
9867
+ 184,
9868
+ 237,
9869
+ 110,
9870
+ 116
9871
+ ],
9872
+ "accounts": [
9873
+ {
9874
+ "name": "admin",
9875
+ "signer": true
9876
+ },
9877
+ {
9878
+ "name": "state"
9879
+ },
9880
+ {
9881
+ "name": "perp_market",
9882
+ "writable": true
9883
+ }
9884
+ ],
9885
+ "args": [
9886
+ {
9887
+ "name": "funding_bias_sensitivity",
9888
+ "type": "u8"
9889
+ }
9890
+ ]
9891
+ },
10635
9892
  {
10636
9893
  "name": "update_perp_market_funding_period",
10637
9894
  "discriminator": [
@@ -10733,6 +9990,10 @@
10733
9990
  {
10734
9991
  "name": "if_liquidation_fee",
10735
9992
  "type": "u32"
9993
+ },
9994
+ {
9995
+ "name": "protocol_liquidation_fee",
9996
+ "type": "u32"
10736
9997
  }
10737
9998
  ]
10738
9999
  },
@@ -11721,6 +10982,48 @@
11721
10982
  }
11722
10983
  ]
11723
10984
  },
10985
+ {
10986
+ "name": "update_protocol_fee_recipient",
10987
+ "docs": [
10988
+ "Cold-only: set the treasury protocol fees may be withdrawn to.",
10989
+ "Perp (quote) and spot (per-market token) recipients are configured",
10990
+ "independently via `market_type`."
10991
+ ],
10992
+ "discriminator": [
10993
+ 213,
10994
+ 60,
10995
+ 21,
10996
+ 106,
10997
+ 42,
10998
+ 67,
10999
+ 60,
11000
+ 162
11001
+ ],
11002
+ "accounts": [
11003
+ {
11004
+ "name": "state",
11005
+ "writable": true
11006
+ },
11007
+ {
11008
+ "name": "admin",
11009
+ "signer": true
11010
+ }
11011
+ ],
11012
+ "args": [
11013
+ {
11014
+ "name": "protocol_fee_recipient",
11015
+ "type": "pubkey"
11016
+ },
11017
+ {
11018
+ "name": "market_type",
11019
+ "type": {
11020
+ "defined": {
11021
+ "name": "MarketType"
11022
+ }
11023
+ }
11024
+ }
11025
+ ]
11026
+ },
11724
11027
  {
11725
11028
  "name": "update_special_user_status",
11726
11029
  "discriminator": [
@@ -12051,11 +11354,11 @@
12051
11354
  "type": "u16"
12052
11355
  },
12053
11356
  {
12054
- "name": "user_if_factor",
11357
+ "name": "if_fee_factor",
12055
11358
  "type": "u32"
12056
11359
  },
12057
11360
  {
12058
- "name": "total_if_factor",
11361
+ "name": "protocol_fee_factor",
12059
11362
  "type": "u32"
12060
11363
  }
12061
11364
  ]
@@ -12125,6 +11428,10 @@
12125
11428
  {
12126
11429
  "name": "if_liquidation_fee",
12127
11430
  "type": "u32"
11431
+ },
11432
+ {
11433
+ "name": "protocol_liquidation_fee",
11434
+ "type": "u32"
12128
11435
  }
12129
11436
  ]
12130
11437
  },
@@ -12842,118 +12149,16 @@
12842
12149
  ]
12843
12150
  },
12844
12151
  {
12845
- "name": "update_user_gov_token_insurance_stake",
12152
+ "name": "update_user_idle",
12846
12153
  "discriminator": [
12847
- 143,
12848
- 99,
12849
- 235,
12850
- 187,
12154
+ 253,
12155
+ 133,
12156
+ 67,
12157
+ 22,
12158
+ 103,
12159
+ 161,
12851
12160
  20,
12852
- 159,
12853
- 184,
12854
- 84
12855
- ],
12856
- "accounts": [
12857
- {
12858
- "name": "state"
12859
- },
12860
- {
12861
- "name": "spot_market",
12862
- "writable": true,
12863
- "pda": {
12864
- "seeds": [
12865
- {
12866
- "kind": "const",
12867
- "value": [
12868
- 115,
12869
- 112,
12870
- 111,
12871
- 116,
12872
- 95,
12873
- 109,
12874
- 97,
12875
- 114,
12876
- 107,
12877
- 101,
12878
- 116
12879
- ]
12880
- },
12881
- {
12882
- "kind": "const",
12883
- "value": [
12884
- 15,
12885
- 0
12886
- ]
12887
- }
12888
- ]
12889
- }
12890
- },
12891
- {
12892
- "name": "insurance_fund_stake",
12893
- "writable": true
12894
- },
12895
- {
12896
- "name": "user_stats",
12897
- "writable": true
12898
- },
12899
- {
12900
- "name": "signer",
12901
- "signer": true
12902
- },
12903
- {
12904
- "name": "insurance_fund_vault",
12905
- "writable": true,
12906
- "pda": {
12907
- "seeds": [
12908
- {
12909
- "kind": "const",
12910
- "value": [
12911
- 105,
12912
- 110,
12913
- 115,
12914
- 117,
12915
- 114,
12916
- 97,
12917
- 110,
12918
- 99,
12919
- 101,
12920
- 95,
12921
- 102,
12922
- 117,
12923
- 110,
12924
- 100,
12925
- 95,
12926
- 118,
12927
- 97,
12928
- 117,
12929
- 108,
12930
- 116
12931
- ]
12932
- },
12933
- {
12934
- "kind": "const",
12935
- "value": [
12936
- 15,
12937
- 0
12938
- ]
12939
- }
12940
- ]
12941
- }
12942
- }
12943
- ],
12944
- "args": []
12945
- },
12946
- {
12947
- "name": "update_user_idle",
12948
- "discriminator": [
12949
- 253,
12950
- 133,
12951
- 67,
12952
- 22,
12953
- 103,
12954
- 161,
12955
- 20,
12956
- 100
12161
+ 100
12957
12162
  ],
12958
12163
  "accounts": [
12959
12164
  {
@@ -13413,6 +12618,12 @@
13413
12618
  {
13414
12619
  "name": "spot_market",
13415
12620
  "writable": true
12621
+ },
12622
+ {
12623
+ "name": "oracle",
12624
+ "relations": [
12625
+ "spot_market"
12626
+ ]
13416
12627
  }
13417
12628
  ],
13418
12629
  "args": [
@@ -13912,32 +13123,426 @@
13912
13123
  "name": "velocity_signer"
13913
13124
  },
13914
13125
  {
13915
- "name": "constituent",
13916
- "writable": true
13126
+ "name": "constituent",
13127
+ "writable": true
13128
+ },
13129
+ {
13130
+ "name": "constituent_token_account",
13131
+ "writable": true
13132
+ },
13133
+ {
13134
+ "name": "spot_market",
13135
+ "writable": true
13136
+ },
13137
+ {
13138
+ "name": "spot_market_vault",
13139
+ "writable": true
13140
+ },
13141
+ {
13142
+ "name": "token_program"
13143
+ },
13144
+ {
13145
+ "name": "mint"
13146
+ },
13147
+ {
13148
+ "name": "oracle"
13149
+ }
13150
+ ],
13151
+ "args": [
13152
+ {
13153
+ "name": "amount",
13154
+ "type": "u64"
13155
+ }
13156
+ ]
13157
+ },
13158
+ {
13159
+ "name": "withdraw_protocol_fees_perp",
13160
+ "docs": [
13161
+ "Withdraw a perp market's accrued protocol fees (from the quote spot vault)",
13162
+ "to `protocol_fee_recipient_perp` (auth: `FeeWithdraw` hot key)."
13163
+ ],
13164
+ "discriminator": [
13165
+ 227,
13166
+ 99,
13167
+ 23,
13168
+ 227,
13169
+ 168,
13170
+ 217,
13171
+ 136,
13172
+ 181
13173
+ ],
13174
+ "accounts": [
13175
+ {
13176
+ "name": "state"
13177
+ },
13178
+ {
13179
+ "name": "payer",
13180
+ "writable": true,
13181
+ "signer": true
13182
+ },
13183
+ {
13184
+ "name": "authority",
13185
+ "signer": true
13186
+ },
13187
+ {
13188
+ "name": "perp_market",
13189
+ "writable": true,
13190
+ "pda": {
13191
+ "seeds": [
13192
+ {
13193
+ "kind": "const",
13194
+ "value": [
13195
+ 112,
13196
+ 101,
13197
+ 114,
13198
+ 112,
13199
+ 95,
13200
+ 109,
13201
+ 97,
13202
+ 114,
13203
+ 107,
13204
+ 101,
13205
+ 116
13206
+ ]
13207
+ },
13208
+ {
13209
+ "kind": "arg",
13210
+ "path": "market_index"
13211
+ }
13212
+ ]
13213
+ }
13214
+ },
13215
+ {
13216
+ "name": "quote_spot_market",
13217
+ "writable": true,
13218
+ "pda": {
13219
+ "seeds": [
13220
+ {
13221
+ "kind": "const",
13222
+ "value": [
13223
+ 115,
13224
+ 112,
13225
+ 111,
13226
+ 116,
13227
+ 95,
13228
+ 109,
13229
+ 97,
13230
+ 114,
13231
+ 107,
13232
+ 101,
13233
+ 116
13234
+ ]
13235
+ },
13236
+ {
13237
+ "kind": "account",
13238
+ "path": "perp_market"
13239
+ }
13240
+ ]
13241
+ }
13242
+ },
13243
+ {
13244
+ "name": "spot_market_vault",
13245
+ "writable": true,
13246
+ "pda": {
13247
+ "seeds": [
13248
+ {
13249
+ "kind": "const",
13250
+ "value": [
13251
+ 115,
13252
+ 112,
13253
+ 111,
13254
+ 116,
13255
+ 95,
13256
+ 109,
13257
+ 97,
13258
+ 114,
13259
+ 107,
13260
+ 101,
13261
+ 116,
13262
+ 95,
13263
+ 118,
13264
+ 97,
13265
+ 117,
13266
+ 108,
13267
+ 116
13268
+ ]
13269
+ },
13270
+ {
13271
+ "kind": "account",
13272
+ "path": "perp_market"
13273
+ }
13274
+ ]
13275
+ }
13276
+ },
13277
+ {
13278
+ "name": "mint",
13279
+ "relations": [
13280
+ "spot_market_vault"
13281
+ ]
13282
+ },
13283
+ {
13284
+ "name": "recipient"
13285
+ },
13286
+ {
13287
+ "name": "recipient_token_account",
13288
+ "writable": true,
13289
+ "pda": {
13290
+ "seeds": [
13291
+ {
13292
+ "kind": "account",
13293
+ "path": "recipient"
13294
+ },
13295
+ {
13296
+ "kind": "account",
13297
+ "path": "token_program"
13298
+ },
13299
+ {
13300
+ "kind": "account",
13301
+ "path": "mint"
13302
+ }
13303
+ ],
13304
+ "program": {
13305
+ "kind": "const",
13306
+ "value": [
13307
+ 140,
13308
+ 151,
13309
+ 37,
13310
+ 143,
13311
+ 78,
13312
+ 36,
13313
+ 137,
13314
+ 241,
13315
+ 187,
13316
+ 61,
13317
+ 16,
13318
+ 41,
13319
+ 20,
13320
+ 142,
13321
+ 13,
13322
+ 131,
13323
+ 11,
13324
+ 90,
13325
+ 19,
13326
+ 153,
13327
+ 218,
13328
+ 255,
13329
+ 16,
13330
+ 132,
13331
+ 4,
13332
+ 142,
13333
+ 123,
13334
+ 216,
13335
+ 219,
13336
+ 233,
13337
+ 248,
13338
+ 89
13339
+ ]
13340
+ }
13341
+ }
13342
+ },
13343
+ {
13344
+ "name": "token_program"
13345
+ },
13346
+ {
13347
+ "name": "velocity_signer"
13348
+ },
13349
+ {
13350
+ "name": "system_program",
13351
+ "address": "11111111111111111111111111111111"
13352
+ },
13353
+ {
13354
+ "name": "associated_token_program",
13355
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
13356
+ }
13357
+ ],
13358
+ "args": [
13359
+ {
13360
+ "name": "market_index",
13361
+ "type": "u16"
13362
+ },
13363
+ {
13364
+ "name": "amount",
13365
+ "type": "u64"
13366
+ }
13367
+ ]
13368
+ },
13369
+ {
13370
+ "name": "withdraw_protocol_fees_spot",
13371
+ "docs": [
13372
+ "Withdraw a spot market's accrued protocol fees to `protocol_fee_recipient_spot`",
13373
+ "(auth: `FeeWithdraw` hot key)."
13374
+ ],
13375
+ "discriminator": [
13376
+ 177,
13377
+ 216,
13378
+ 30,
13379
+ 239,
13380
+ 253,
13381
+ 177,
13382
+ 123,
13383
+ 155
13384
+ ],
13385
+ "accounts": [
13386
+ {
13387
+ "name": "state"
13388
+ },
13389
+ {
13390
+ "name": "payer",
13391
+ "writable": true,
13392
+ "signer": true
13393
+ },
13394
+ {
13395
+ "name": "authority",
13396
+ "signer": true
13397
+ },
13398
+ {
13399
+ "name": "spot_market",
13400
+ "writable": true,
13401
+ "pda": {
13402
+ "seeds": [
13403
+ {
13404
+ "kind": "const",
13405
+ "value": [
13406
+ 115,
13407
+ 112,
13408
+ 111,
13409
+ 116,
13410
+ 95,
13411
+ 109,
13412
+ 97,
13413
+ 114,
13414
+ 107,
13415
+ 101,
13416
+ 116
13417
+ ]
13418
+ },
13419
+ {
13420
+ "kind": "arg",
13421
+ "path": "market_index"
13422
+ }
13423
+ ]
13424
+ }
13425
+ },
13426
+ {
13427
+ "name": "spot_market_vault",
13428
+ "writable": true,
13429
+ "pda": {
13430
+ "seeds": [
13431
+ {
13432
+ "kind": "const",
13433
+ "value": [
13434
+ 115,
13435
+ 112,
13436
+ 111,
13437
+ 116,
13438
+ 95,
13439
+ 109,
13440
+ 97,
13441
+ 114,
13442
+ 107,
13443
+ 101,
13444
+ 116,
13445
+ 95,
13446
+ 118,
13447
+ 97,
13448
+ 117,
13449
+ 108,
13450
+ 116
13451
+ ]
13452
+ },
13453
+ {
13454
+ "kind": "arg",
13455
+ "path": "market_index"
13456
+ }
13457
+ ]
13458
+ }
13459
+ },
13460
+ {
13461
+ "name": "mint",
13462
+ "relations": [
13463
+ "spot_market_vault"
13464
+ ]
13917
13465
  },
13918
13466
  {
13919
- "name": "constituent_token_account",
13920
- "writable": true
13467
+ "name": "recipient"
13921
13468
  },
13922
13469
  {
13923
- "name": "spot_market",
13924
- "writable": true
13470
+ "name": "recipient_token_account",
13471
+ "writable": true,
13472
+ "pda": {
13473
+ "seeds": [
13474
+ {
13475
+ "kind": "account",
13476
+ "path": "recipient"
13477
+ },
13478
+ {
13479
+ "kind": "account",
13480
+ "path": "token_program"
13481
+ },
13482
+ {
13483
+ "kind": "account",
13484
+ "path": "mint"
13485
+ }
13486
+ ],
13487
+ "program": {
13488
+ "kind": "const",
13489
+ "value": [
13490
+ 140,
13491
+ 151,
13492
+ 37,
13493
+ 143,
13494
+ 78,
13495
+ 36,
13496
+ 137,
13497
+ 241,
13498
+ 187,
13499
+ 61,
13500
+ 16,
13501
+ 41,
13502
+ 20,
13503
+ 142,
13504
+ 13,
13505
+ 131,
13506
+ 11,
13507
+ 90,
13508
+ 19,
13509
+ 153,
13510
+ 218,
13511
+ 255,
13512
+ 16,
13513
+ 132,
13514
+ 4,
13515
+ 142,
13516
+ 123,
13517
+ 216,
13518
+ 219,
13519
+ 233,
13520
+ 248,
13521
+ 89
13522
+ ]
13523
+ }
13524
+ }
13925
13525
  },
13926
13526
  {
13927
- "name": "spot_market_vault",
13928
- "writable": true
13527
+ "name": "token_program"
13929
13528
  },
13930
13529
  {
13931
- "name": "token_program"
13530
+ "name": "velocity_signer"
13932
13531
  },
13933
13532
  {
13934
- "name": "mint"
13533
+ "name": "system_program",
13534
+ "address": "11111111111111111111111111111111"
13935
13535
  },
13936
13536
  {
13937
- "name": "oracle"
13537
+ "name": "associated_token_program",
13538
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
13938
13539
  }
13939
13540
  ],
13940
13541
  "args": [
13542
+ {
13543
+ "name": "market_index",
13544
+ "type": "u16"
13545
+ },
13941
13546
  {
13942
13547
  "name": "amount",
13943
13548
  "type": "u64"
@@ -14038,19 +13643,6 @@
14038
13643
  99
14039
13644
  ]
14040
13645
  },
14041
- {
14042
- "name": "IfRebalanceConfig",
14043
- "discriminator": [
14044
- 214,
14045
- 84,
14046
- 40,
14047
- 251,
14048
- 107,
14049
- 144,
14050
- 173,
14051
- 239
14052
- ]
14053
- },
14054
13646
  {
14055
13647
  "name": "InsuranceFundStake",
14056
13648
  "discriminator": [
@@ -14235,19 +13827,6 @@
14235
13827
  }
14236
13828
  ],
14237
13829
  "events": [
14238
- {
14239
- "name": "AdminWithdrawFromInsuranceFundRecord",
14240
- "discriminator": [
14241
- 230,
14242
- 236,
14243
- 10,
14244
- 0,
14245
- 196,
14246
- 41,
14247
- 147,
14248
- 45
14249
- ]
14250
- },
14251
13830
  {
14252
13831
  "name": "AmmCurveChanged",
14253
13832
  "discriminator": [
@@ -14339,19 +13918,6 @@
14339
13918
  114
14340
13919
  ]
14341
13920
  },
14342
- {
14343
- "name": "InsuranceFundSwapRecord",
14344
- "discriminator": [
14345
- 85,
14346
- 190,
14347
- 99,
14348
- 203,
14349
- 237,
14350
- 33,
14351
- 227,
14352
- 100
14353
- ]
14354
- },
14355
13921
  {
14356
13922
  "name": "LPBorrowLendDepositRecord",
14357
13923
  "discriminator": [
@@ -14456,6 +14022,32 @@
14456
14022
  90
14457
14023
  ]
14458
14024
  },
14025
+ {
14026
+ "name": "PerpMarketFeeSweepRecord",
14027
+ "discriminator": [
14028
+ 55,
14029
+ 107,
14030
+ 227,
14031
+ 104,
14032
+ 179,
14033
+ 8,
14034
+ 121,
14035
+ 33
14036
+ ]
14037
+ },
14038
+ {
14039
+ "name": "ProtocolFeeWithdrawRecord",
14040
+ "discriminator": [
14041
+ 249,
14042
+ 158,
14043
+ 52,
14044
+ 81,
14045
+ 30,
14046
+ 11,
14047
+ 45,
14048
+ 149
14049
+ ]
14050
+ },
14459
14051
  {
14460
14052
  "name": "RevenueShareSettleRecord",
14461
14053
  "discriminator": [
@@ -14547,19 +14139,6 @@
14547
14139
  12
14548
14140
  ]
14549
14141
  },
14550
- {
14551
- "name": "TransferProtocolIfSharesToRevenuePoolRecord",
14552
- "discriminator": [
14553
- 209,
14554
- 118,
14555
- 142,
14556
- 167,
14557
- 130,
14558
- 46,
14559
- 164,
14560
- 151
14561
- ]
14562
- },
14563
14142
  {
14564
14143
  "name": "_SignedMsgOrderParamsExport",
14565
14144
  "discriminator": [
@@ -16334,6 +15913,21 @@
16334
15913
  "code": 6351,
16335
15914
  "name": "InvalidAdminTier",
16336
15915
  "msg": "Signer is not authorized for this admin tier"
15916
+ },
15917
+ {
15918
+ "code": 6352,
15919
+ "name": "WithdrawGuardThresholdNotionalTooLarge",
15920
+ "msg": "Withdraw guard threshold notional exceeds max"
15921
+ },
15922
+ {
15923
+ "code": 6353,
15924
+ "name": "InvalidProtocolFeeRecipient",
15925
+ "msg": "Recipient must be the configured protocol fee recipient"
15926
+ },
15927
+ {
15928
+ "code": 6354,
15929
+ "name": "InsufficientProtocolFees",
15930
+ "msg": "Insufficient protocol fees available to withdraw"
16337
15931
  }
16338
15932
  ],
16339
15933
  "types": [
@@ -16433,7 +16027,11 @@
16433
16027
  {
16434
16028
  "name": "total_fee",
16435
16029
  "docs": [
16436
- "total fees collected by this perp market",
16030
+ "Lifetime fee-derived income booked to the AMM ITSELF (analytics):",
16031
+ "its fee provision (the `amm_fee` cut of trade-fee remainders) plus",
16032
+ "spread surplus. NOT the market's gross fees — those live in",
16033
+ "`PerpMarket.fee_ledger.total_exchange_fee`. Adjusted in lockstep with",
16034
+ "`total_fee_minus_distributions` by admin summary-stats corrections.",
16437
16035
  "precision: QUOTE_PRECISION"
16438
16036
  ],
16439
16037
  "type": "i128"
@@ -16441,7 +16039,9 @@
16441
16039
  {
16442
16040
  "name": "total_mm_fee",
16443
16041
  "docs": [
16444
- "total fees collected by the vAMM's bid/ask spread",
16042
+ "Spread-capture component of `total_fee` (analytics): the gap between",
16043
+ "the curve price and the execution price on AMM fills. Trading profit,",
16044
+ "not a fee anyone explicitly pays.",
16445
16045
  "precision: QUOTE_PRECISION"
16446
16046
  ],
16447
16047
  "type": "i128"
@@ -16449,7 +16049,14 @@
16449
16049
  {
16450
16050
  "name": "total_fee_minus_distributions",
16451
16051
  "docs": [
16452
- "total fees minus any recognized upnl and pool withdraws",
16052
+ "The AMM's equity ledger (retained earnings) broader than the name",
16053
+ "suggests: fee income (`apply_fill_fees`) + funding and other P&L",
16054
+ "(`record_amm_pnl`) + external credits (`record_credit`), minus",
16055
+ "curve-adjustment costs (`apply_cost`) and bankruptcy clawbacks.",
16056
+ "Contains ONLY the AMM's own money (protocol/IF carveouts never enter",
16057
+ "it). Drives `is_underwater`, the drawdown breaker, and curve-cost",
16058
+ "budgets; reconciled against pool balances by",
16059
+ "`calculate_perp_market_amm_summary_stats`.",
16453
16060
  "precision: QUOTE_PRECISION"
16454
16061
  ],
16455
16062
  "type": "i128"
@@ -16457,7 +16064,9 @@
16457
16064
  {
16458
16065
  "name": "total_fee_withdrawn",
16459
16066
  "docs": [
16460
- "sum of all fees from fee pool withdrawn to revenue pool",
16067
+ "@deprecated frozen analytics counter from the pre-isolation design",
16068
+ "(sum of fees withdrawn from the fee pool to the revenue pool). The",
16069
+ "sweep no longer touches the AMM's pools, so nothing writes this.",
16461
16070
  "precision: QUOTE_PRECISION"
16462
16071
  ],
16463
16072
  "type": "u128"
@@ -16635,12 +16244,25 @@
16635
16244
  "name": "reference_price_offset_deadband_pct",
16636
16245
  "type": "u8"
16637
16246
  },
16247
+ {
16248
+ "name": "funding_bias_sensitivity",
16249
+ "docs": [
16250
+ "s in the funding bias β(f) = 1 + s * ρ(f): how much the paying-side",
16251
+ "spread widens while the vAMM pays funding on its inventory.",
16252
+ "",
16253
+ "s is stored in hundredths (s = value / 100), so at full ramp (ρ = 1)",
16254
+ "the multiplier is 1 + value/100: 50 => 1.5x, 100 => 2x, u8 caps s at",
16255
+ "2.55. Same convention as `amm_spread_adjustment` (100 = double).",
16256
+ "0 disables the bias."
16257
+ ],
16258
+ "type": "u8"
16259
+ },
16638
16260
  {
16639
16261
  "name": "padding_post_amm",
16640
16262
  "type": {
16641
16263
  "array": [
16642
16264
  "u8",
16643
- 3
16265
+ 2
16644
16266
  ]
16645
16267
  }
16646
16268
  }
@@ -16667,50 +16289,6 @@
16667
16289
  ]
16668
16290
  }
16669
16291
  },
16670
- {
16671
- "name": "AdminWithdrawFromInsuranceFundRecord",
16672
- "type": {
16673
- "kind": "struct",
16674
- "fields": [
16675
- {
16676
- "name": "ts",
16677
- "type": "i64"
16678
- },
16679
- {
16680
- "name": "market_index",
16681
- "type": "u16"
16682
- },
16683
- {
16684
- "name": "admin",
16685
- "type": "pubkey"
16686
- },
16687
- {
16688
- "name": "amount",
16689
- "type": "u64"
16690
- },
16691
- {
16692
- "name": "shares_burned",
16693
- "type": "u128"
16694
- },
16695
- {
16696
- "name": "insurance_fund_vault_amount_before",
16697
- "type": "u64"
16698
- },
16699
- {
16700
- "name": "protocol_shares_before",
16701
- "type": "u128"
16702
- },
16703
- {
16704
- "name": "protocol_shares_after",
16705
- "type": "u128"
16706
- },
16707
- {
16708
- "name": "recipient_token_account",
16709
- "type": "pubkey"
16710
- }
16711
- ]
16712
- }
16713
- },
16714
16292
  {
16715
16293
  "name": "AmmCache",
16716
16294
  "type": {
@@ -17640,52 +17218,126 @@
17640
17218
  "type": "u128"
17641
17219
  },
17642
17220
  {
17643
- "name": "market_cumulative_borrow_interest",
17221
+ "name": "market_cumulative_borrow_interest",
17222
+ "docs": [
17223
+ "precision: SPOT_CUMULATIVE_INTEREST_PRECISION"
17224
+ ],
17225
+ "type": "u128"
17226
+ },
17227
+ {
17228
+ "name": "total_deposits_after",
17229
+ "docs": [
17230
+ "precision: QUOTE_PRECISION"
17231
+ ],
17232
+ "type": "u64"
17233
+ },
17234
+ {
17235
+ "name": "total_withdraws_after",
17236
+ "docs": [
17237
+ "precision: QUOTE_PRECISION"
17238
+ ],
17239
+ "type": "u64"
17240
+ },
17241
+ {
17242
+ "name": "explanation",
17243
+ "type": {
17244
+ "defined": {
17245
+ "name": "DepositExplanation"
17246
+ }
17247
+ }
17248
+ },
17249
+ {
17250
+ "name": "transfer_user",
17251
+ "type": {
17252
+ "option": "pubkey"
17253
+ }
17254
+ },
17255
+ {
17256
+ "name": "signer",
17257
+ "type": {
17258
+ "option": "pubkey"
17259
+ }
17260
+ },
17261
+ {
17262
+ "name": "user_token_amount_after",
17263
+ "docs": [
17264
+ "precision: token mint precision"
17265
+ ],
17266
+ "type": "i128"
17267
+ }
17268
+ ]
17269
+ }
17270
+ },
17271
+ {
17272
+ "name": "FeeLedger",
17273
+ "docs": [
17274
+ "All of a perp market's fee-split accounting in one ledger.",
17275
+ "Pure counters — token claims live in the pools",
17276
+ "(`protocol_fee_pool`, the quote `revenue_pool`, `AMM.fee_pool`).",
17277
+ "Convention: gross-fee counters record what the taker actually paid",
17278
+ "(post referee discount, pre carve-outs) on BOTH the AMM and DLOB-match",
17279
+ "paths."
17280
+ ],
17281
+ "serialization": "bytemuckunsafe",
17282
+ "repr": {
17283
+ "kind": "c"
17284
+ },
17285
+ "type": {
17286
+ "kind": "struct",
17287
+ "fields": [
17288
+ {
17289
+ "name": "total_exchange_fee",
17290
+ "docs": [
17291
+ "lifetime gross taker fees collected (analytics; not a routing driver)",
17292
+ "precision: QUOTE_PRECISION"
17293
+ ],
17294
+ "type": "u128"
17295
+ },
17296
+ {
17297
+ "name": "total_liquidation_fee",
17298
+ "docs": [
17299
+ "lifetime liquidation fees charged to liquidatees (IF + protocol cuts;",
17300
+ "pure analytics — routing happens via the pending counters).",
17301
+ "precision: QUOTE_PRECISION"
17302
+ ],
17303
+ "type": "u128"
17304
+ },
17305
+ {
17306
+ "name": "pending_protocol_fee",
17644
17307
  "docs": [
17645
- "precision: SPOT_CUMULATIVE_INTEREST_PRECISION"
17308
+ "protocol (residual) carveouts accrued but not yet materialized into",
17309
+ "`protocol_fee_pool`. precision: QUOTE_PRECISION"
17646
17310
  ],
17647
17311
  "type": "u128"
17648
17312
  },
17649
17313
  {
17650
- "name": "total_deposits_after",
17314
+ "name": "pending_if_fee",
17651
17315
  "docs": [
17316
+ "insurance-fund carveouts accrued but not yet materialized into the",
17317
+ "quote `revenue_pool`; also the first bankruptcy tranche.",
17652
17318
  "precision: QUOTE_PRECISION"
17653
17319
  ],
17654
- "type": "u64"
17320
+ "type": "u128"
17655
17321
  },
17656
17322
  {
17657
- "name": "total_withdraws_after",
17323
+ "name": "amm_protocol_fees_received",
17658
17324
  "docs": [
17659
- "precision: QUOTE_PRECISION"
17325
+ "cumulative fee provision granted to the AMM via `amm_fee_numerator` —",
17326
+ "its backstop-of-last-resort tranche, drawable (and decremented) only in",
17327
+ "bankruptcy. The AMM's own spread/trading capital beyond this provision",
17328
+ "is never tapped. precision: QUOTE_PRECISION"
17660
17329
  ],
17661
- "type": "u64"
17662
- },
17663
- {
17664
- "name": "explanation",
17665
- "type": {
17666
- "defined": {
17667
- "name": "DepositExplanation"
17668
- }
17669
- }
17670
- },
17671
- {
17672
- "name": "transfer_user",
17673
- "type": {
17674
- "option": "pubkey"
17675
- }
17676
- },
17677
- {
17678
- "name": "signer",
17679
- "type": {
17680
- "option": "pubkey"
17681
- }
17330
+ "type": "u128"
17682
17331
  },
17683
17332
  {
17684
- "name": "user_token_amount_after",
17333
+ "name": "pending_amm_provision",
17685
17334
  "docs": [
17686
- "precision: token mint precision"
17335
+ "AMM fee provision accrued at fill (already booked into the AMM's",
17336
+ "`total_fee_minus_distributions`) but not yet tokenized into",
17337
+ "`amm.fee_pool` by the sweep. Invariant: `<= amm_protocol_fees_received`.",
17338
+ "precision: QUOTE_PRECISION"
17687
17339
  ],
17688
- "type": "i128"
17340
+ "type": "u128"
17689
17341
  }
17690
17342
  ]
17691
17343
  }
@@ -17724,13 +17376,26 @@
17724
17376
  "type": "u64"
17725
17377
  },
17726
17378
  {
17727
- "name": "padding",
17379
+ "name": "amm_fee_numerator",
17728
17380
  "docs": [
17729
- "Reserved padding. Kept so `size_of::<FeeStructure>()` stays a multiple of 16",
17730
- "(OrderFillerRewardStructure's u128 forces 16-byte alignment on host x86_64);",
17731
- "removing it would diverge host vs. SBF layout."
17381
+ "Share of the trade-fee *remainder* (taker fee after maker rebate, referral,",
17382
+ "referee discount, and filler reward are taken off the top) provisioned to",
17383
+ "the AMM as liquidity (its backstop-of-last-resort tranche, tracked in",
17384
+ "`PerpMarket.fee_ledger.amm_protocol_fees_received`). precision:",
17385
+ "FEE_PERCENTAGE_DENOMINATOR. `amm_fee_numerator + if_fee_numerator` must",
17386
+ "be <= FEE_PERCENTAGE_DENOMINATOR; the protocol receives the residual",
17387
+ "(`remainder − amm − if`) into its withdrawable `protocol_fee_pool`.",
17388
+ "(Was the reserved `padding: u64`, repartitioned into two u32s —",
17389
+ "size/alignment unchanged.)"
17732
17390
  ],
17733
- "type": "u64"
17391
+ "type": "u32"
17392
+ },
17393
+ {
17394
+ "name": "if_fee_numerator",
17395
+ "docs": [
17396
+ "Share of the trade-fee remainder routed to the insurance fund (`revenue_pool`)."
17397
+ ],
17398
+ "type": "u32"
17734
17399
  }
17735
17400
  ]
17736
17401
  }
@@ -18090,9 +17755,6 @@
18090
17755
  {
18091
17756
  "name": "LpSettle"
18092
17757
  },
18093
- {
18094
- "name": "IfRebalance"
18095
- },
18096
17758
  {
18097
17759
  "name": "FeatureFlag"
18098
17760
  },
@@ -18110,160 +17772,9 @@
18110
17772
  },
18111
17773
  {
18112
17774
  "name": "AmmSpreadAdjust"
18113
- }
18114
- ]
18115
- }
18116
- },
18117
- {
18118
- "name": "IfRebalanceConfig",
18119
- "serialization": "bytemuckunsafe",
18120
- "repr": {
18121
- "kind": "c"
18122
- },
18123
- "type": {
18124
- "kind": "struct",
18125
- "fields": [
18126
- {
18127
- "name": "pubkey",
18128
- "type": "pubkey"
18129
- },
18130
- {
18131
- "name": "total_in_amount",
18132
- "docs": [
18133
- "total amount to be sold"
18134
- ],
18135
- "type": "u64"
18136
- },
18137
- {
18138
- "name": "current_in_amount",
18139
- "docs": [
18140
- "amount already sold"
18141
- ],
18142
- "type": "u64"
18143
- },
18144
- {
18145
- "name": "current_out_amount",
18146
- "docs": [
18147
- "amount already bought"
18148
- ],
18149
- "type": "u64"
18150
- },
18151
- {
18152
- "name": "current_out_amount_transferred",
18153
- "docs": [
18154
- "amount already transferred to revenue pool"
18155
- ],
18156
- "type": "u64"
18157
- },
18158
- {
18159
- "name": "current_in_amount_since_last_transfer",
18160
- "docs": [
18161
- "amount already bought in epoch"
18162
- ],
18163
- "type": "u64"
18164
- },
18165
- {
18166
- "name": "epoch_start_ts",
18167
- "docs": [
18168
- "start time of epoch"
18169
- ],
18170
- "type": "i64"
18171
- },
18172
- {
18173
- "name": "epoch_in_amount",
18174
- "docs": [
18175
- "amount already bought in epoch"
18176
- ],
18177
- "type": "u64"
18178
- },
18179
- {
18180
- "name": "epoch_max_in_amount",
18181
- "docs": [
18182
- "max amount to swap in epoch"
18183
- ],
18184
- "type": "u64"
18185
- },
18186
- {
18187
- "name": "epoch_duration",
18188
- "docs": [
18189
- "duration of epoch"
18190
- ],
18191
- "type": "i64"
18192
- },
18193
- {
18194
- "name": "out_market_index",
18195
- "docs": [
18196
- "market index to sell"
18197
- ],
18198
- "type": "u16"
18199
- },
18200
- {
18201
- "name": "in_market_index",
18202
- "docs": [
18203
- "market index to buy"
18204
- ],
18205
- "type": "u16"
18206
- },
18207
- {
18208
- "name": "max_slippage_bps",
18209
- "type": "u16"
18210
- },
18211
- {
18212
- "name": "swap_mode",
18213
- "type": "u8"
18214
- },
18215
- {
18216
- "name": "status",
18217
- "type": "u8"
18218
- },
18219
- {
18220
- "name": "padding2",
18221
- "type": {
18222
- "array": [
18223
- "u8",
18224
- 32
18225
- ]
18226
- }
18227
- }
18228
- ]
18229
- }
18230
- },
18231
- {
18232
- "name": "IfRebalanceConfigParams",
18233
- "type": {
18234
- "kind": "struct",
18235
- "fields": [
18236
- {
18237
- "name": "total_in_amount",
18238
- "type": "u64"
18239
- },
18240
- {
18241
- "name": "epoch_max_in_amount",
18242
- "type": "u64"
18243
- },
18244
- {
18245
- "name": "epoch_duration",
18246
- "type": "i64"
18247
- },
18248
- {
18249
- "name": "out_market_index",
18250
- "type": "u16"
18251
- },
18252
- {
18253
- "name": "in_market_index",
18254
- "type": "u16"
18255
- },
18256
- {
18257
- "name": "max_slippage_bps",
18258
- "type": "u16"
18259
- },
18260
- {
18261
- "name": "swap_mode",
18262
- "type": "u8"
18263
17775
  },
18264
17776
  {
18265
- "name": "status",
18266
- "type": "u8"
17777
+ "name": "FeeWithdraw"
18267
17778
  }
18268
17779
  ]
18269
17780
  }
@@ -18356,15 +17867,33 @@
18356
17867
  },
18357
17868
  {
18358
17869
  "name": "revenue_settle_period",
17870
+ "docs": [
17871
+ "How often `revenue_pool` may settle into the IF vault (seconds)."
17872
+ ],
18359
17873
  "type": "i64"
18360
17874
  },
18361
17875
  {
18362
- "name": "total_factor",
17876
+ "name": "if_fee_factor",
17877
+ "docs": [
17878
+ "Fraction of spot deposit-interest gains carved out to the insurance fund",
17879
+ "(staker-owned). precision: IF_FACTOR_PRECISION. (Was `total_factor`; the",
17880
+ "protocol-vs-staker split was removed — the IF is now 100% staker-owned,",
17881
+ "so this is purely the staker IF carveout.)"
17882
+ ],
18363
17883
  "type": "u32"
18364
17884
  },
18365
17885
  {
18366
- "name": "user_factor",
18367
- "type": "u32"
17886
+ "name": "_padding_if",
17887
+ "docs": [
17888
+ "Was `user_factor` (the old protocol/staker split knob). The IF is now",
17889
+ "100% staker-owned, so the split is gone; slot kept as padding."
17890
+ ],
17891
+ "type": {
17892
+ "array": [
17893
+ "u8",
17894
+ 4
17895
+ ]
17896
+ }
18368
17897
  }
18369
17898
  ]
18370
17899
  }
@@ -18533,112 +18062,24 @@
18533
18062
  "type": "u128"
18534
18063
  },
18535
18064
  {
18536
- "name": "user_if_shares_before",
18537
- "type": "u128"
18538
- },
18539
- {
18540
- "name": "total_if_shares_before",
18541
- "type": "u128"
18542
- },
18543
- {
18544
- "name": "if_shares_after",
18545
- "type": "u128"
18546
- },
18547
- {
18548
- "name": "user_if_shares_after",
18549
- "type": "u128"
18550
- },
18551
- {
18552
- "name": "total_if_shares_after",
18553
- "type": "u128"
18554
- }
18555
- ]
18556
- }
18557
- },
18558
- {
18559
- "name": "InsuranceFundSwapRecord",
18560
- "type": {
18561
- "kind": "struct",
18562
- "fields": [
18563
- {
18564
- "name": "rebalance_config",
18565
- "type": "pubkey"
18566
- },
18567
- {
18568
- "name": "in_if_total_shares_before",
18569
- "type": "u128"
18570
- },
18571
- {
18572
- "name": "out_if_total_shares_before",
18573
- "type": "u128"
18574
- },
18575
- {
18576
- "name": "in_if_user_shares_before",
18577
- "type": "u128"
18578
- },
18579
- {
18580
- "name": "out_if_user_shares_before",
18581
- "type": "u128"
18582
- },
18583
- {
18584
- "name": "in_if_total_shares_after",
18585
- "type": "u128"
18586
- },
18587
- {
18588
- "name": "out_if_total_shares_after",
18589
- "type": "u128"
18590
- },
18591
- {
18592
- "name": "in_if_user_shares_after",
18593
- "type": "u128"
18594
- },
18595
- {
18596
- "name": "out_if_user_shares_after",
18597
- "type": "u128"
18598
- },
18599
- {
18600
- "name": "ts",
18601
- "type": "i64"
18602
- },
18603
- {
18604
- "name": "in_amount",
18605
- "type": "u64"
18606
- },
18607
- {
18608
- "name": "out_amount",
18609
- "type": "u64"
18610
- },
18611
- {
18612
- "name": "out_oracle_price",
18613
- "type": "u64"
18614
- },
18615
- {
18616
- "name": "out_oracle_price_twap",
18617
- "type": "i64"
18618
- },
18619
- {
18620
- "name": "in_vault_amount_before",
18621
- "type": "u64"
18622
- },
18623
- {
18624
- "name": "out_vault_amount_before",
18625
- "type": "u64"
18065
+ "name": "user_if_shares_before",
18066
+ "type": "u128"
18626
18067
  },
18627
18068
  {
18628
- "name": "in_fund_vault_amount_after",
18629
- "type": "u64"
18069
+ "name": "total_if_shares_before",
18070
+ "type": "u128"
18630
18071
  },
18631
18072
  {
18632
- "name": "out_fund_vault_amount_after",
18633
- "type": "u64"
18073
+ "name": "if_shares_after",
18074
+ "type": "u128"
18634
18075
  },
18635
18076
  {
18636
- "name": "in_market_index",
18637
- "type": "u16"
18077
+ "name": "user_if_shares_after",
18078
+ "type": "u128"
18638
18079
  },
18639
18080
  {
18640
- "name": "out_market_index",
18641
- "type": "u16"
18081
+ "name": "total_if_shares_after",
18082
+ "type": "u128"
18642
18083
  }
18643
18084
  ]
18644
18085
  }
@@ -19256,6 +18697,14 @@
19256
18697
  "precision: QUOTE_PRECISION"
19257
18698
  ],
19258
18699
  "type": "u64"
18700
+ },
18701
+ {
18702
+ "name": "protocol_fee",
18703
+ "docs": [
18704
+ "protocol's cut, routed to the perp market's `protocol_fee_pool`",
18705
+ "precision: QUOTE_PRECISION"
18706
+ ],
18707
+ "type": "u64"
19259
18708
  }
19260
18709
  ]
19261
18710
  }
@@ -19298,6 +18747,14 @@
19298
18747
  "precision: token mint precision"
19299
18748
  ],
19300
18749
  "type": "u64"
18750
+ },
18751
+ {
18752
+ "name": "protocol_fee",
18753
+ "docs": [
18754
+ "protocol's cut, routed to the liability market's `protocol_fee_pool`",
18755
+ "precision: token mint precision"
18756
+ ],
18757
+ "type": "u64"
19301
18758
  }
19302
18759
  ]
19303
18760
  }
@@ -19674,15 +19131,26 @@
19674
19131
  {
19675
19132
  "name": "padding",
19676
19133
  "docs": [
19677
- "Padding so historical_oracle_data is 8-aligned."
19134
+ "Padding so last_funding_oracle_twap is 8-aligned."
19678
19135
  ],
19679
19136
  "type": {
19680
19137
  "array": [
19681
19138
  "u8",
19682
- 11
19139
+ 3
19683
19140
  ]
19684
19141
  }
19685
19142
  },
19143
+ {
19144
+ "name": "last_funding_oracle_twap",
19145
+ "docs": [
19146
+ "Oracle TWAP captured at last funding update, the normalizer",
19147
+ "`last_24h_avg_funding_rate` accrued against. Read by the AMM's",
19148
+ "funding bias spread and `get_last_funding_basis`. Migrated from",
19149
+ "`PerpMarket` so the AMM reads only from `MarketStats`.",
19150
+ "precision: PRICE_PRECISION"
19151
+ ],
19152
+ "type": "i64"
19153
+ },
19686
19154
  {
19687
19155
  "name": "historical_oracle_data",
19688
19156
  "docs": [
@@ -21028,20 +20496,17 @@
21028
20496
  "type": "i128"
21029
20497
  },
21030
20498
  {
21031
- "name": "total_exchange_fee",
21032
- "docs": [
21033
- "total fees collected by exchange fee schedule",
21034
- "precision: QUOTE_PRECISION"
21035
- ],
21036
- "type": "u128"
21037
- },
21038
- {
21039
- "name": "total_liquidation_fee",
20499
+ "name": "fee_ledger",
21040
20500
  "docs": [
21041
- "all fees collected by market for liquidations",
21042
- "precision: QUOTE_PRECISION"
20501
+ "The market's fee ledger: every fee-split counter in one place (gross",
20502
+ "analytics, pending protocol/IF carveouts, and the AMM's backstop",
20503
+ "tranche). Mutate through its accessor methods, not raw field writes."
21043
20504
  ],
21044
- "type": "u128"
20505
+ "type": {
20506
+ "defined": {
20507
+ "name": "FeeLedger"
20508
+ }
20509
+ }
21045
20510
  },
21046
20511
  {
21047
20512
  "name": "oracle",
@@ -21062,6 +20527,67 @@
21062
20527
  }
21063
20528
  }
21064
20529
  },
20530
+ {
20531
+ "name": "protocol_fee_pool",
20532
+ "docs": [
20533
+ "Protocol fees collected on this perp market, quote/USDC-denominated — a",
20534
+ "protocol-owned Deposit-type claim against the quote spot market vault",
20535
+ "(like `pnl_pool`; counted in the quote market's `deposit_balance`).",
20536
+ "Owned by the protocol, not users, and never part of the insurance",
20537
+ "backstop. `market_index` is set to `quote_spot_market_index`. Withdrawn",
20538
+ "directly to `State.protocol_fee_recipient_perp`."
20539
+ ],
20540
+ "type": {
20541
+ "defined": {
20542
+ "name": "PoolBalance"
20543
+ }
20544
+ }
20545
+ },
20546
+ {
20547
+ "name": "protocol_liquidation_fee",
20548
+ "docs": [
20549
+ "Protocol's cut of a perp liquidation, taken from the liquidatee.",
20550
+ "precision: LIQUIDATOR_FEE_PRECISION"
20551
+ ],
20552
+ "type": "u32"
20553
+ },
20554
+ {
20555
+ "name": "_padding_buffer",
20556
+ "type": {
20557
+ "array": [
20558
+ "u8",
20559
+ 4
20560
+ ]
20561
+ }
20562
+ },
20563
+ {
20564
+ "name": "fee_pool_buffer_target",
20565
+ "docs": [
20566
+ "The pnl-pool retention buffer the streaming sweep's IF and",
20567
+ "AMM-provision drains leave untouched: `sweep_market_fees` drains",
20568
+ "those pendings only from what the pnl pool holds above",
20569
+ "`max(net_user_pnl, 0) + fee_pool_buffer_target`. The protocol drain",
20570
+ "is EXEMPT — it reserves only `max(net_user_pnl, 0)` and runs first;",
20571
+ "it sweeps every settle, so each drain stays small, and its pending is",
20572
+ "no bankruptcy tranche so retaining it buys nothing.",
20573
+ "",
20574
+ "Why a buffer on top of the user-claims reservation: `net_user_pnl`",
20575
+ "is a mark-to-market snapshot, so a pool swept to the exact mark is",
20576
+ "short on the next adverse oracle tick — and the sweep is a one-way",
20577
+ "valve, so the slack can't be cheaply recalled (IF value returns only",
20578
+ "through capped gated paths, the AMM provision only via bankruptcy",
20579
+ "clawback). The buffer throttles those outflows per sweep; pool tokens",
20580
+ "are fungible (pendings are counters, not segregated tokens), so",
20581
+ "whichever cut lingers keeps settling winners in the meantime. This",
20582
+ "delays materialization, it does not divert anyone's cut. Side",
20583
+ "benefits: an unswept IF cut gives THIS market uncapped market-local",
20584
+ "bankruptcy coverage (tranche 1) instead of capped shared-vault",
20585
+ "coverage, and the buffer damps the IF settle ratchet (value settled",
20586
+ "into the IF accrues to stakers permanently).",
20587
+ "precision: QUOTE_PRECISION"
20588
+ ],
20589
+ "type": "u64"
20590
+ },
21065
20591
  {
21066
20592
  "name": "name",
21067
20593
  "docs": [
@@ -21124,11 +20650,17 @@
21124
20650
  "type": "i64"
21125
20651
  },
21126
20652
  {
21127
- "name": "last_funding_oracle_twap",
20653
+ "name": "_padding_funding_twap",
21128
20654
  "docs": [
21129
- "oracle TWAP captured at last funding update"
20655
+ "Explicit padding where `last_funding_oracle_twap` used to live",
20656
+ "(moved to `MarketStats`); keeps every later field at its old offset."
21130
20657
  ],
21131
- "type": "i64"
20658
+ "type": {
20659
+ "array": [
20660
+ "u8",
20661
+ 8
20662
+ ]
20663
+ }
21132
20664
  },
21133
20665
  {
21134
20666
  "name": "order_step_size",
@@ -21407,13 +20939,14 @@
21407
20939
  "docs": [
21408
20940
  "Trailing padding so `market_stats` lands at the offset Rust naturally",
21409
20941
  "computes via `repr(C)` alignment and the `(SIZE - 8) % 16 == 0`",
21410
- "invariant holds. Bumped to 36 bytes (was 28) when `next_curve_record_id`",
21411
- "was removed."
20942
+ "invariant holds. (32 bytes moved into `fee_ledger` as",
20943
+ "`amm_protocol_fees_received` and then `pending_amm_provision` joined",
20944
+ "it, keeping `market_stats` fixed.)"
21412
20945
  ],
21413
20946
  "type": {
21414
20947
  "array": [
21415
20948
  "u8",
21416
- 36
20949
+ 4
21417
20950
  ]
21418
20951
  }
21419
20952
  },
@@ -21478,6 +21011,50 @@
21478
21011
  ]
21479
21012
  }
21480
21013
  },
21014
+ {
21015
+ "name": "PerpMarketFeeSweepRecord",
21016
+ "docs": [
21017
+ "Emitted by the streaming fee sweep (`sweep_market_fees`) when it",
21018
+ "materializes pending fee carveouts out of a perp market's pnl pool."
21019
+ ],
21020
+ "type": {
21021
+ "kind": "struct",
21022
+ "fields": [
21023
+ {
21024
+ "name": "ts",
21025
+ "docs": [
21026
+ "unix_timestamp of action"
21027
+ ],
21028
+ "type": "i64"
21029
+ },
21030
+ {
21031
+ "name": "market_index",
21032
+ "type": "u16"
21033
+ },
21034
+ {
21035
+ "name": "if_swept",
21036
+ "docs": [
21037
+ "pending insurance cut moved to the quote spot market's revenue_pool"
21038
+ ],
21039
+ "type": "u64"
21040
+ },
21041
+ {
21042
+ "name": "protocol_swept",
21043
+ "docs": [
21044
+ "pending protocol cut moved to the market's protocol_fee_pool"
21045
+ ],
21046
+ "type": "u64"
21047
+ },
21048
+ {
21049
+ "name": "amm_provision_tokenized",
21050
+ "docs": [
21051
+ "AMM fee provision tokenized into amm.fee_pool (booked at fill)"
21052
+ ],
21053
+ "type": "u64"
21054
+ }
21055
+ ]
21056
+ }
21057
+ },
21481
21058
  {
21482
21059
  "name": "PerpPosition",
21483
21060
  "serialization": "bytemuckunsafe",
@@ -21755,6 +21332,51 @@
21755
21332
  ]
21756
21333
  }
21757
21334
  },
21335
+ {
21336
+ "name": "ProtocolFeeWithdrawRecord",
21337
+ "type": {
21338
+ "kind": "struct",
21339
+ "fields": [
21340
+ {
21341
+ "name": "ts",
21342
+ "docs": [
21343
+ "unix_timestamp of action"
21344
+ ],
21345
+ "type": "i64"
21346
+ },
21347
+ {
21348
+ "name": "market_index",
21349
+ "docs": [
21350
+ "perp market index for a perp-fee withdrawal, else the spot market index"
21351
+ ],
21352
+ "type": "u16"
21353
+ },
21354
+ {
21355
+ "name": "is_perp",
21356
+ "docs": [
21357
+ "true if this withdrawal drained a perp market's protocol_fee_pool",
21358
+ "(sourced from the quote spot vault), false for a spot market withdrawal"
21359
+ ],
21360
+ "type": "bool"
21361
+ },
21362
+ {
21363
+ "name": "spot_market_index",
21364
+ "docs": [
21365
+ "the spot market the tokens were drawn from"
21366
+ ],
21367
+ "type": "u16"
21368
+ },
21369
+ {
21370
+ "name": "amount",
21371
+ "type": "u64"
21372
+ },
21373
+ {
21374
+ "name": "recipient_token_account",
21375
+ "type": "pubkey"
21376
+ }
21377
+ ]
21378
+ }
21379
+ },
21758
21380
  {
21759
21381
  "name": "PythLazerOracle",
21760
21382
  "serialization": "bytemuckunsafe",
@@ -23135,12 +22757,58 @@
23135
22757
  "name": "pool_id",
23136
22758
  "type": "u8"
23137
22759
  },
22760
+ {
22761
+ "name": "_padding_align_pfp",
22762
+ "docs": [
22763
+ "Aligns `protocol_fee_pool`'s leading u128 to a 16-byte struct offset so",
22764
+ "host (x86_64, align 16) and SBF (align 8) layouts agree. Do not reorder."
22765
+ ],
22766
+ "type": {
22767
+ "array": [
22768
+ "u8",
22769
+ 8
22770
+ ]
22771
+ }
22772
+ },
22773
+ {
22774
+ "name": "protocol_fee_pool",
22775
+ "docs": [
22776
+ "Protocol fees collected in this market's token (lending protocol carveout",
22777
+ "+ spot-liquidation protocol fee). A protocol-owned Deposit-type claim",
22778
+ "inside the spot vault (counted in `deposit_balance`, like `revenue_pool`)",
22779
+ "— owned by the protocol, not users, and never part of the insurance",
22780
+ "backstop. Withdrawn directly to `State.protocol_fee_recipient_spot`; the",
22781
+ "withdrawal decrements this claim and re-validates the vault still covers",
22782
+ "all remaining claims, so it can never tap user deposits."
22783
+ ],
22784
+ "type": {
22785
+ "defined": {
22786
+ "name": "PoolBalance"
22787
+ }
22788
+ }
22789
+ },
22790
+ {
22791
+ "name": "protocol_liquidation_fee",
22792
+ "docs": [
22793
+ "Protocol's cut of a spot liquidation, taken from the liquidatee.",
22794
+ "precision: LIQUIDATOR_FEE_PRECISION"
22795
+ ],
22796
+ "type": "u32"
22797
+ },
22798
+ {
22799
+ "name": "protocol_fee_factor",
22800
+ "docs": [
22801
+ "Protocol's carveout of lending deposit-interest gains, routed to",
22802
+ "`protocol_fee_pool`. precision: IF_FACTOR_PRECISION"
22803
+ ],
22804
+ "type": "u32"
22805
+ },
23138
22806
  {
23139
22807
  "name": "padding",
23140
22808
  "type": {
23141
22809
  "array": [
23142
22810
  "u8",
23143
- 56
22811
+ 8
23144
22812
  ]
23145
22813
  }
23146
22814
  }
@@ -23320,7 +22988,7 @@
23320
22988
  {
23321
22989
  "name": "warm_admin",
23322
22990
  "docs": [
23323
- "Operational authority (e.g. multisig+timelock). Can rotate the 11 hot keys",
22991
+ "Operational authority (e.g. multisig+timelock). Can rotate the 10 hot keys",
23324
22992
  "below. `Pubkey::default()` means unset — only `cold_admin` can act in that case."
23325
22993
  ],
23326
22994
  "type": "pubkey"
@@ -23355,10 +23023,6 @@
23355
23023
  "name": "hot_lp_settle",
23356
23024
  "type": "pubkey"
23357
23025
  },
23358
- {
23359
- "name": "hot_if_rebalance",
23360
- "type": "pubkey"
23361
- },
23362
23026
  {
23363
23027
  "name": "hot_feature_flag",
23364
23028
  "type": "pubkey"
@@ -23491,6 +23155,35 @@
23491
23155
  "name": "lp_pool_feature_bit_flags",
23492
23156
  "type": "u8"
23493
23157
  },
23158
+ {
23159
+ "name": "protocol_fee_recipient_perp",
23160
+ "docs": [
23161
+ "Treasury that PERP protocol fees (quote-denominated) may be withdrawn",
23162
+ "to. Settable only by `cold_admin`. `withdraw_protocol_fees_perp` pays",
23163
+ "this key's associated token account (recipient-locked).",
23164
+ "`Pubkey::default()` (unset) makes perp withdrawals inert."
23165
+ ],
23166
+ "type": "pubkey"
23167
+ },
23168
+ {
23169
+ "name": "protocol_fee_recipient_spot",
23170
+ "docs": [
23171
+ "Treasury that SPOT protocol fees (each market's own token: lending",
23172
+ "carveouts + spot-liquidation cuts) may be withdrawn to. Settable only",
23173
+ "by `cold_admin`. `withdraw_protocol_fees_spot` pays this key's",
23174
+ "associated token account for the market's mint (recipient-locked).",
23175
+ "`Pubkey::default()` (unset) makes spot withdrawals inert."
23176
+ ],
23177
+ "type": "pubkey"
23178
+ },
23179
+ {
23180
+ "name": "hot_fee_withdraw",
23181
+ "docs": [
23182
+ "Hot key authorized for the `FeeWithdraw` role (triggers protocol-fee",
23183
+ "withdrawals to the configured recipients)."
23184
+ ],
23185
+ "type": "pubkey"
23186
+ },
23494
23187
  {
23495
23188
  "name": "padding",
23496
23189
  "type": {
@@ -23660,42 +23353,6 @@
23660
23353
  ]
23661
23354
  }
23662
23355
  },
23663
- {
23664
- "name": "TransferProtocolIfSharesToRevenuePoolRecord",
23665
- "type": {
23666
- "kind": "struct",
23667
- "fields": [
23668
- {
23669
- "name": "ts",
23670
- "type": "i64"
23671
- },
23672
- {
23673
- "name": "market_index",
23674
- "type": "u16"
23675
- },
23676
- {
23677
- "name": "amount",
23678
- "type": "u64"
23679
- },
23680
- {
23681
- "name": "shares",
23682
- "type": "u128"
23683
- },
23684
- {
23685
- "name": "if_vault_amount_before",
23686
- "type": "u64"
23687
- },
23688
- {
23689
- "name": "protocol_shares_before",
23690
- "type": "u128"
23691
- },
23692
- {
23693
- "name": "transfer_amount",
23694
- "type": "u64"
23695
- }
23696
- ]
23697
- }
23698
- },
23699
23356
  {
23700
23357
  "name": "UpdatePerpMarketSummaryStatsParams",
23701
23358
  "type": {
@@ -23712,12 +23369,6 @@
23712
23369
  "type": {
23713
23370
  "option": "bool"
23714
23371
  }
23715
- },
23716
- {
23717
- "name": "exclude_total_liq_fee",
23718
- "type": {
23719
- "option": "bool"
23720
- }
23721
23372
  }
23722
23373
  ]
23723
23374
  }
@@ -24133,11 +23784,17 @@
24133
23784
  "type": "u8"
24134
23785
  },
24135
23786
  {
24136
- "name": "if_staked_gov_token_amount",
23787
+ "name": "padding1",
24137
23788
  "docs": [
24138
- "The amount of tokens staked in the governance spot markets if"
23789
+ "9 bytes: 1 byte of former repr(C) alignment padding + the removed",
23790
+ "8-byte `if_staked_gov_token_amount` field (gov-token stake fee discount)"
24139
23791
  ],
24140
- "type": "u64"
23792
+ "type": {
23793
+ "array": [
23794
+ "u8",
23795
+ 9
23796
+ ]
23797
+ }
24141
23798
  },
24142
23799
  {
24143
23800
  "name": "delegate_permissions",