@drift-labs/sdk 2.163.0-beta.0 → 2.163.0-beta.11

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 (500) hide show
  1. package/.prettierignore +1 -0
  2. package/.yarn/install-state.gz +0 -0
  3. package/README.md +2 -2
  4. package/VERSION +1 -1
  5. package/bun.lock +47 -79
  6. package/lib/browser/accounts/fetch.d.ts +6 -6
  7. package/lib/browser/accounts/fetch.js +4 -4
  8. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -2
  9. package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
  10. package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
  11. package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
  12. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
  13. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
  14. package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
  15. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
  16. package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +2 -2
  17. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
  18. package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +2 -2
  19. package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
  20. package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
  21. package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
  22. package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +2 -2
  23. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
  24. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
  25. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
  26. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
  27. package/lib/browser/accounts/pollingUserAccountSubscriber.js +2 -2
  28. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
  29. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +1 -1
  30. package/lib/browser/accounts/testBulkAccountLoader.js +3 -5
  31. package/lib/browser/accounts/types.d.ts +11 -14
  32. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +3 -3
  33. package/lib/browser/accounts/webSocketAccountSubscriber.js +1 -2
  34. package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
  35. package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
  36. package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
  37. package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
  38. package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
  39. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
  40. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
  41. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
  42. package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
  43. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
  44. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
  45. package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
  46. package/lib/browser/addresses/pda.d.ts +6 -2
  47. package/lib/browser/addresses/pda.js +7 -12
  48. package/lib/browser/adminClient.d.ts +13 -9
  49. package/lib/browser/adminClient.js +47 -72
  50. package/lib/browser/auctionSubscriber/auctionSubscriber.js +1 -1
  51. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
  52. package/lib/browser/config.d.ts +7 -3
  53. package/lib/browser/config.js +9 -7
  54. package/lib/browser/constants/index.d.ts +5 -0
  55. package/lib/browser/constants/index.js +5 -0
  56. package/lib/browser/constants/numericConstants.d.ts +1 -1
  57. package/lib/browser/constants/numericConstants.js +3 -3
  58. package/lib/browser/constants/perpMarkets.js +3 -412
  59. package/lib/browser/constants/spotMarkets.js +7 -91
  60. package/lib/browser/constituentMap/constituentMap.js +2 -2
  61. package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
  62. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
  63. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
  64. package/lib/browser/decode/customCoder.d.ts +7 -9
  65. package/lib/browser/decode/customCoder.js +17 -28
  66. package/lib/browser/decode/user.js +11 -25
  67. package/lib/browser/dlob/DLOB.d.ts +12 -0
  68. package/lib/browser/dlob/DLOB.js +12 -0
  69. package/lib/browser/dlob/orderBookLevels.js +1 -1
  70. package/lib/browser/driftClient.d.ts +34 -59
  71. package/lib/browser/driftClient.js +105 -562
  72. package/lib/browser/driftClientConfig.d.ts +7 -0
  73. package/lib/browser/events/eventSubscriber.d.ts +8 -0
  74. package/lib/browser/events/eventSubscriber.js +5 -2
  75. package/lib/browser/events/parse.d.ts +1 -1
  76. package/lib/browser/factory/oracleClient.d.ts +2 -2
  77. package/lib/browser/factory/oracleClient.js +9 -21
  78. package/lib/browser/idl/drift.d.ts +21463 -0
  79. package/lib/browser/idl/drift.js +2 -0
  80. package/lib/browser/idl/drift.json +20973 -15333
  81. package/lib/browser/idl/pyth.d.ts +97 -0
  82. package/lib/browser/idl/pyth.js +2 -0
  83. package/lib/browser/idl/token_faucet.d.ts +197 -0
  84. package/lib/browser/idl/token_faucet.js +2 -0
  85. package/lib/browser/idl/token_faucet.json +148 -61
  86. package/lib/browser/index.d.ts +13 -6
  87. package/lib/browser/index.js +12 -5
  88. package/lib/browser/marinade/index.d.ts +1 -1
  89. package/lib/browser/marinade/index.js +2 -2
  90. package/lib/browser/math/amm.d.ts +4 -5
  91. package/lib/browser/math/amm.js +8 -35
  92. package/lib/browser/math/funding.js +6 -1
  93. package/lib/browser/math/margin.d.ts +3 -4
  94. package/lib/browser/math/margin.js +16 -47
  95. package/lib/browser/math/market.d.ts +2 -2
  96. package/lib/browser/math/market.js +10 -42
  97. package/lib/browser/math/oracles.js +14 -19
  98. package/lib/browser/math/position.js +1 -1
  99. package/lib/browser/math/trade.js +4 -4
  100. package/lib/browser/memcmp.js +8 -8
  101. package/lib/browser/openbook/openbookV2Subscriber.d.ts +1 -1
  102. package/lib/browser/openbook/openbookV2Subscriber.js +3 -3
  103. package/lib/browser/oracles/oracleClientCache.d.ts +2 -2
  104. package/lib/browser/oracles/prelaunchOracleClient.d.ts +2 -2
  105. package/lib/browser/oracles/prelaunchOracleClient.js +1 -1
  106. package/lib/browser/oracles/pythLazerClient.js +3 -5
  107. package/lib/browser/oracles/types.d.ts +6 -0
  108. package/lib/browser/orderParams.d.ts +0 -1
  109. package/lib/browser/orderParams.js +1 -5
  110. package/lib/browser/orderSubscriber/OrderSubscriber.js +3 -4
  111. package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
  112. package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
  113. package/lib/browser/orderSubscriber/index.d.ts +5 -0
  114. package/lib/browser/orderSubscriber/index.js +5 -0
  115. package/lib/browser/priorityFee/index.d.ts +5 -0
  116. package/lib/browser/priorityFee/index.js +5 -0
  117. package/lib/browser/pyth/index.d.ts +2 -2
  118. package/lib/browser/pyth/types.d.ts +1 -1
  119. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
  120. package/lib/browser/swift/index.d.ts +7 -0
  121. package/lib/browser/swift/index.js +7 -0
  122. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +4 -3
  123. package/lib/browser/tokenFaucet.d.ts +2 -2
  124. package/lib/browser/tokenFaucet.js +4 -4
  125. package/lib/browser/tx/txHandler.d.ts +12 -0
  126. package/lib/browser/tx/txHandler.js +12 -0
  127. package/lib/browser/types.d.ts +23 -31
  128. package/lib/browser/types.js +11 -12
  129. package/lib/browser/user.d.ts +27 -18
  130. package/lib/browser/user.js +64 -100
  131. package/lib/browser/userMap/WebsocketSubscription.js +1 -1
  132. package/lib/browser/userMap/grpcSubscription.js +1 -1
  133. package/lib/browser/userMap/revenueShareEscrowMap.js +4 -4
  134. package/lib/browser/userMap/userMap.js +4 -5
  135. package/lib/browser/userMap/userStatsMap.js +2 -3
  136. package/lib/browser/userStats.d.ts +5 -0
  137. package/lib/node/accounts/fetch.d.ts +6 -6
  138. package/lib/node/accounts/fetch.d.ts.map +1 -1
  139. package/lib/node/accounts/fetch.js +4 -4
  140. package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -2
  141. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  142. package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
  143. package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts.map +1 -1
  144. package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
  145. package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts.map +1 -1
  146. package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
  147. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
  148. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  149. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
  150. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  151. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
  152. package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
  153. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
  154. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  155. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +2 -2
  156. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
  157. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
  158. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
  159. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +2 -2
  160. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  161. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
  162. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
  163. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
  164. package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
  165. package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
  166. package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts.map +1 -1
  167. package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +2 -2
  168. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
  169. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  170. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
  171. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
  172. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
  173. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
  174. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
  175. package/lib/node/accounts/pollingUserAccountSubscriber.js +2 -2
  176. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
  177. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
  178. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +1 -1
  179. package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
  180. package/lib/node/accounts/testBulkAccountLoader.js +3 -5
  181. package/lib/node/accounts/types.d.ts +11 -14
  182. package/lib/node/accounts/types.d.ts.map +1 -1
  183. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +3 -3
  184. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  185. package/lib/node/accounts/webSocketAccountSubscriber.js +1 -2
  186. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
  187. package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
  188. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
  189. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
  190. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
  191. package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
  192. package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts.map +1 -1
  193. package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
  194. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
  195. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
  196. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
  197. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  198. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
  199. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
  200. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
  201. package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
  202. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
  203. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
  204. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
  205. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
  206. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
  207. package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
  208. package/lib/node/addresses/pda.d.ts +6 -2
  209. package/lib/node/addresses/pda.d.ts.map +1 -1
  210. package/lib/node/addresses/pda.js +7 -12
  211. package/lib/node/adminClient.d.ts +13 -9
  212. package/lib/node/adminClient.d.ts.map +1 -1
  213. package/lib/node/adminClient.js +47 -72
  214. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  215. package/lib/node/auctionSubscriber/auctionSubscriber.js +1 -1
  216. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  217. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
  218. package/lib/node/config.d.ts +7 -3
  219. package/lib/node/config.d.ts.map +1 -1
  220. package/lib/node/config.js +9 -7
  221. package/lib/node/constants/index.d.ts +5 -0
  222. package/lib/node/constants/index.d.ts.map +1 -1
  223. package/lib/node/constants/index.js +5 -0
  224. package/lib/node/constants/numericConstants.d.ts +1 -1
  225. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  226. package/lib/node/constants/numericConstants.js +3 -3
  227. package/lib/node/constants/perpMarkets.d.ts.map +1 -1
  228. package/lib/node/constants/perpMarkets.js +3 -412
  229. package/lib/node/constants/spotMarkets.d.ts.map +1 -1
  230. package/lib/node/constants/spotMarkets.js +7 -91
  231. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  232. package/lib/node/constituentMap/constituentMap.js +2 -2
  233. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
  234. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
  235. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
  236. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
  237. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
  238. package/lib/node/decode/customCoder.d.ts +7 -9
  239. package/lib/node/decode/customCoder.d.ts.map +1 -1
  240. package/lib/node/decode/customCoder.js +17 -28
  241. package/lib/node/decode/user.d.ts.map +1 -1
  242. package/lib/node/decode/user.js +11 -25
  243. package/lib/node/dlob/DLOB.d.ts +12 -0
  244. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  245. package/lib/node/dlob/DLOB.js +12 -0
  246. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  247. package/lib/node/dlob/orderBookLevels.js +1 -1
  248. package/lib/node/driftClient.d.ts +34 -59
  249. package/lib/node/driftClient.d.ts.map +1 -1
  250. package/lib/node/driftClient.js +105 -562
  251. package/lib/node/driftClientConfig.d.ts +7 -0
  252. package/lib/node/driftClientConfig.d.ts.map +1 -1
  253. package/lib/node/events/eventSubscriber.d.ts +8 -0
  254. package/lib/node/events/eventSubscriber.d.ts.map +1 -1
  255. package/lib/node/events/eventSubscriber.js +5 -2
  256. package/lib/node/events/parse.d.ts +1 -1
  257. package/lib/node/events/parse.d.ts.map +1 -1
  258. package/lib/node/factory/oracleClient.d.ts +2 -2
  259. package/lib/node/factory/oracleClient.d.ts.map +1 -1
  260. package/lib/node/factory/oracleClient.js +9 -21
  261. package/lib/node/idl/drift.d.ts +21464 -0
  262. package/lib/node/idl/drift.d.ts.map +1 -0
  263. package/lib/node/idl/drift.js +2 -0
  264. package/lib/node/idl/drift.json +20973 -15333
  265. package/lib/node/idl/pyth.d.ts +98 -0
  266. package/lib/node/idl/pyth.d.ts.map +1 -0
  267. package/lib/node/idl/pyth.js +2 -0
  268. package/lib/node/idl/token_faucet.d.ts +198 -0
  269. package/lib/node/idl/token_faucet.d.ts.map +1 -0
  270. package/lib/node/idl/token_faucet.js +2 -0
  271. package/lib/node/idl/token_faucet.json +148 -61
  272. package/lib/node/index.d.ts +13 -6
  273. package/lib/node/index.d.ts.map +1 -1
  274. package/lib/node/index.js +12 -5
  275. package/lib/node/marinade/index.d.ts +1 -1
  276. package/lib/node/marinade/index.d.ts.map +1 -1
  277. package/lib/node/marinade/index.js +2 -2
  278. package/lib/node/math/amm.d.ts +4 -5
  279. package/lib/node/math/amm.d.ts.map +1 -1
  280. package/lib/node/math/amm.js +8 -35
  281. package/lib/node/math/funding.d.ts.map +1 -1
  282. package/lib/node/math/funding.js +6 -1
  283. package/lib/node/math/margin.d.ts +3 -4
  284. package/lib/node/math/margin.d.ts.map +1 -1
  285. package/lib/node/math/margin.js +16 -47
  286. package/lib/node/math/market.d.ts +2 -2
  287. package/lib/node/math/market.d.ts.map +1 -1
  288. package/lib/node/math/market.js +10 -42
  289. package/lib/node/math/oracles.d.ts.map +1 -1
  290. package/lib/node/math/oracles.js +14 -19
  291. package/lib/node/math/position.d.ts.map +1 -1
  292. package/lib/node/math/position.js +1 -1
  293. package/lib/node/math/trade.d.ts.map +1 -1
  294. package/lib/node/math/trade.js +4 -4
  295. package/lib/node/memcmp.js +8 -8
  296. package/lib/node/openbook/openbookV2Subscriber.d.ts +1 -1
  297. package/lib/node/openbook/openbookV2Subscriber.d.ts.map +1 -1
  298. package/lib/node/openbook/openbookV2Subscriber.js +3 -3
  299. package/lib/node/oracles/oracleClientCache.d.ts +2 -2
  300. package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
  301. package/lib/node/oracles/prelaunchOracleClient.d.ts +2 -2
  302. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
  303. package/lib/node/oracles/prelaunchOracleClient.js +1 -1
  304. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  305. package/lib/node/oracles/pythLazerClient.js +3 -5
  306. package/lib/node/oracles/types.d.ts +6 -0
  307. package/lib/node/oracles/types.d.ts.map +1 -1
  308. package/lib/node/orderParams.d.ts +0 -1
  309. package/lib/node/orderParams.d.ts.map +1 -1
  310. package/lib/node/orderParams.js +1 -5
  311. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  312. package/lib/node/orderSubscriber/OrderSubscriber.js +3 -4
  313. package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
  314. package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
  315. package/lib/node/orderSubscriber/index.d.ts +5 -0
  316. package/lib/node/orderSubscriber/index.d.ts.map +1 -1
  317. package/lib/node/orderSubscriber/index.js +5 -0
  318. package/lib/node/priorityFee/index.d.ts +5 -0
  319. package/lib/node/priorityFee/index.d.ts.map +1 -1
  320. package/lib/node/priorityFee/index.js +5 -0
  321. package/lib/node/pyth/index.d.ts +2 -2
  322. package/lib/node/pyth/index.d.ts.map +1 -1
  323. package/lib/node/pyth/types.d.ts +1 -1
  324. package/lib/node/pyth/types.d.ts.map +1 -1
  325. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
  326. package/lib/node/swift/index.d.ts +7 -0
  327. package/lib/node/swift/index.d.ts.map +1 -1
  328. package/lib/node/swift/index.js +7 -0
  329. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  330. package/lib/node/swift/signedMsgUserAccountSubscriber.js +4 -3
  331. package/lib/node/tokenFaucet.d.ts +2 -2
  332. package/lib/node/tokenFaucet.d.ts.map +1 -1
  333. package/lib/node/tokenFaucet.js +4 -4
  334. package/lib/node/tx/txHandler.d.ts +12 -0
  335. package/lib/node/tx/txHandler.d.ts.map +1 -1
  336. package/lib/node/tx/txHandler.js +12 -0
  337. package/lib/node/types.d.ts +23 -31
  338. package/lib/node/types.d.ts.map +1 -1
  339. package/lib/node/types.js +11 -12
  340. package/lib/node/user.d.ts +27 -18
  341. package/lib/node/user.d.ts.map +1 -1
  342. package/lib/node/user.js +64 -100
  343. package/lib/node/userMap/WebsocketSubscription.js +1 -1
  344. package/lib/node/userMap/grpcSubscription.js +1 -1
  345. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  346. package/lib/node/userMap/revenueShareEscrowMap.js +4 -4
  347. package/lib/node/userMap/userMap.d.ts.map +1 -1
  348. package/lib/node/userMap/userMap.js +4 -5
  349. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  350. package/lib/node/userMap/userStatsMap.js +2 -3
  351. package/lib/node/userStats.d.ts +5 -0
  352. package/lib/node/userStats.d.ts.map +1 -1
  353. package/package.json +5 -7
  354. package/src/accounts/fetch.ts +18 -17
  355. package/src/accounts/grpcAccountSubscriber.ts +3 -3
  356. package/src/accounts/grpcDriftClientAccountSubscriber.ts +2 -3
  357. package/src/accounts/grpcDriftClientAccountSubscriberV2.ts +5 -6
  358. package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +2 -2
  359. package/src/accounts/grpcMultiAccountSubscriber.ts +4 -4
  360. package/src/accounts/grpcMultiUserAccountSubscriber.ts +4 -4
  361. package/src/accounts/grpcProgramAccountSubscriber.ts +3 -3
  362. package/src/accounts/grpcUserAccountSubscriber.ts +2 -2
  363. package/src/accounts/grpcUserStatsAccountSubscriber.ts +2 -2
  364. package/src/accounts/laserProgramAccountSubscriber.ts +3 -3
  365. package/src/accounts/oneShotUserAccountSubscriber.ts +6 -7
  366. package/src/accounts/oneShotUserStatsAccountSubscriber.ts +10 -9
  367. package/src/accounts/pollingDriftClientAccountSubscriber.ts +12 -11
  368. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -10
  369. package/src/accounts/pollingOracleAccountSubscriber.ts +2 -2
  370. package/src/accounts/pollingTokenAccountSubscriber.ts +2 -2
  371. package/src/accounts/pollingUserAccountSubscriber.ts +2 -2
  372. package/src/accounts/pollingUserStatsAccountSubscriber.ts +14 -14
  373. package/src/accounts/testBulkAccountLoader.ts +3 -5
  374. package/src/accounts/types.ts +10 -25
  375. package/src/accounts/webSocketAccountSubscriber.ts +5 -5
  376. package/src/accounts/webSocketAccountSubscriberV2.ts +4 -3
  377. package/src/accounts/webSocketDriftClientAccountSubscriber.ts +9 -10
  378. package/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +13 -10
  379. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +3 -3
  380. package/src/accounts/webSocketProgramAccountSubscriber.ts +4 -3
  381. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +4 -3
  382. package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +4 -3
  383. package/src/accounts/webSocketUserAccountSubscriber.ts +3 -3
  384. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +3 -3
  385. package/src/accounts/websocketProgramUserAccountSubscriber.ts +4 -4
  386. package/src/addresses/pda.ts +6 -22
  387. package/src/adminClient.ts +183 -239
  388. package/src/auctionSubscriber/auctionSubscriber.ts +5 -3
  389. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +5 -3
  390. package/src/config.ts +24 -16
  391. package/src/constants/index.ts +5 -0
  392. package/src/constants/numericConstants.ts +2 -3
  393. package/src/constants/perpMarkets.ts +3 -445
  394. package/src/constants/spotMarkets.ts +7 -102
  395. package/src/constituentMap/constituentMap.ts +5 -6
  396. package/src/constituentMap/pollingConstituentAccountSubscriber.ts +3 -3
  397. package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +6 -6
  398. package/src/decode/customCoder.ts +26 -35
  399. package/src/decode/user.ts +11 -25
  400. package/src/dlob/DLOB.ts +12 -0
  401. package/src/dlob/orderBookLevels.ts +0 -1
  402. package/src/driftClient.ts +286 -1092
  403. package/src/driftClientConfig.ts +7 -0
  404. package/src/events/eventSubscriber.ts +14 -2
  405. package/src/events/parse.ts +2 -2
  406. package/src/factory/oracleClient.ts +17 -28
  407. package/src/idl/drift.json +20973 -15333
  408. package/src/idl/drift.ts +21463 -0
  409. package/src/idl/pyth.ts +97 -0
  410. package/src/idl/token_faucet.json +148 -61
  411. package/src/idl/token_faucet.ts +197 -0
  412. package/src/index.ts +13 -12
  413. package/src/margin/README.md +0 -1
  414. package/src/marinade/index.ts +2 -2
  415. package/src/math/amm.ts +2 -48
  416. package/src/math/funding.ts +8 -3
  417. package/src/math/margin.ts +12 -67
  418. package/src/math/market.ts +15 -69
  419. package/src/math/oracles.ts +14 -30
  420. package/src/math/position.ts +0 -1
  421. package/src/math/trade.ts +0 -4
  422. package/src/memcmp.ts +1 -1
  423. package/src/openbook/openbookV2Subscriber.ts +1 -1
  424. package/src/oracles/oracleClientCache.ts +2 -2
  425. package/src/oracles/prelaunchOracleClient.ts +9 -8
  426. package/src/oracles/pythLazerClient.ts +10 -12
  427. package/src/oracles/types.ts +6 -0
  428. package/src/orderParams.ts +0 -5
  429. package/src/orderSubscriber/OrderSubscriber.ts +7 -6
  430. package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
  431. package/src/orderSubscriber/grpcSubscription.ts +2 -2
  432. package/src/orderSubscriber/index.ts +5 -0
  433. package/src/priorityFee/index.ts +5 -0
  434. package/src/pyth/index.ts +4 -4
  435. package/src/pyth/types.ts +1 -1
  436. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +1 -1
  437. package/src/swift/index.ts +7 -0
  438. package/src/swift/signedMsgUserAccountSubscriber.ts +7 -4
  439. package/src/tokenFaucet.ts +8 -4
  440. package/src/tx/txHandler.ts +12 -0
  441. package/src/types.ts +21 -20
  442. package/src/user.ts +66 -144
  443. package/src/userMap/WebsocketSubscription.ts +1 -1
  444. package/src/userMap/grpcSubscription.ts +1 -1
  445. package/src/userMap/revenueShareEscrowMap.ts +24 -20
  446. package/src/userMap/userMap.ts +8 -7
  447. package/src/userMap/userStatsMap.ts +6 -5
  448. package/src/userStats.ts +5 -0
  449. package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +5 -4
  450. package/tests/amm/test.ts +45 -64
  451. package/tests/ci/verifyConstants.ts +23 -26
  452. package/tests/decode/test.ts +2 -4
  453. package/tests/dlob/helpers.ts +8 -15
  454. package/tests/user/helpers.ts +1 -2
  455. package/tests/user/marginCalculations.test.ts +2 -3
  456. package/tests/user/test.ts +18 -15
  457. package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -29
  458. package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
  459. package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -23
  460. package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
  461. package/lib/browser/idl/pyth_solana_receiver.json +0 -628
  462. package/lib/browser/idl/switchboard.json +0 -8354
  463. package/lib/browser/idl/switchboard_on_demand_30.json +0 -5849
  464. package/lib/browser/oracles/pythPullClient.d.ts +0 -19
  465. package/lib/browser/oracles/pythPullClient.js +0 -65
  466. package/lib/browser/oracles/switchboardClient.d.ts +0 -12
  467. package/lib/browser/oracles/switchboardClient.js +0 -40
  468. package/lib/browser/oracles/switchboardOnDemandClient.d.ts +0 -12
  469. package/lib/browser/oracles/switchboardOnDemandClient.js +0 -33
  470. package/lib/browser/util/pythOracleUtils.d.ts +0 -2
  471. package/lib/browser/util/pythOracleUtils.js +0 -15
  472. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -30
  473. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
  474. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
  475. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -24
  476. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
  477. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
  478. package/lib/node/idl/pyth_solana_receiver.json +0 -628
  479. package/lib/node/idl/switchboard.json +0 -8354
  480. package/lib/node/idl/switchboard_on_demand_30.json +0 -5849
  481. package/lib/node/oracles/pythPullClient.d.ts +0 -20
  482. package/lib/node/oracles/pythPullClient.d.ts.map +0 -1
  483. package/lib/node/oracles/pythPullClient.js +0 -65
  484. package/lib/node/oracles/switchboardClient.d.ts +0 -13
  485. package/lib/node/oracles/switchboardClient.d.ts.map +0 -1
  486. package/lib/node/oracles/switchboardClient.js +0 -40
  487. package/lib/node/oracles/switchboardOnDemandClient.d.ts +0 -13
  488. package/lib/node/oracles/switchboardOnDemandClient.d.ts.map +0 -1
  489. package/lib/node/oracles/switchboardOnDemandClient.js +0 -33
  490. package/lib/node/util/pythOracleUtils.d.ts +0 -3
  491. package/lib/node/util/pythOracleUtils.d.ts.map +0 -1
  492. package/lib/node/util/pythOracleUtils.js +0 -15
  493. package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +0 -189
  494. package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +0 -131
  495. package/src/idl/switchboard.json +0 -8354
  496. package/src/idl/switchboard_on_demand_30.json +0 -5849
  497. package/src/oracles/pythPullClient.ts +0 -112
  498. package/src/oracles/switchboardClient.ts +0 -77
  499. package/src/oracles/switchboardOnDemandClient.ts +0 -64
  500. package/src/util/pythOracleUtils.ts +0 -11
@@ -1,12 +1,19 @@
1
+ /**
2
+ * DriftClient — main SDK entry point for all trading and keeper operations.
3
+ *
4
+ * Responsibilities:
5
+ * - Builds and sends all on-chain instructions (place/cancel/fill orders, deposits, withdrawals,
6
+ * settle PnL, update funding rate, liquidations).
7
+ * - Manages the program account subscription lifecycle (markets, oracles, user accounts).
8
+ * - Provides oracle price reads, market config lookups, and PDA derivation helpers.
9
+ *
10
+ * Admin operations (market init, fee updates, oracle config) live in {@link AdminClient} (adminClient.ts).
11
+ * Read-only user account queries (margin, positions, PnL) live in {@link User} (user.ts).
12
+ *
13
+ * Instruction → on-chain handler mapping: see ARCHITECTURE.md § SDK↔Instruction Mapping.
14
+ */
1
15
  import * as anchor from '@coral-xyz/anchor';
2
- import {
3
- AnchorProvider,
4
- BN,
5
- Idl,
6
- Program,
7
- ProgramAccount,
8
- } from '@coral-xyz/anchor';
9
- import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
16
+ import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
10
17
  import bs58 from 'bs58';
11
18
  import {
12
19
  ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -26,7 +33,6 @@ import {
26
33
  } from '@solana/spl-token';
27
34
  import {
28
35
  DriftClientMetricsEvents,
29
- HighLeverageModeConfig,
30
36
  isVariant,
31
37
  IWallet,
32
38
  MakerInfo,
@@ -72,6 +78,10 @@ import {
72
78
  } from './types';
73
79
  import driftIDL from './idl/drift.json';
74
80
 
81
+ /** Client-side guardrail; mirrors on-chain `ErrorCode::SpotDlobTradingDisabled`. */
82
+ const SPOT_DLOB_TRADING_DISABLED_MSG =
83
+ 'Spot DLOB trading is disabled; spot balances, deposits, and swaps remain available.';
84
+
75
85
  import {
76
86
  AccountMeta,
77
87
  AddressLookupTableAccount,
@@ -99,14 +109,12 @@ import {
99
109
  getDriftSignerPublicKey,
100
110
  getDriftStateAccountPublicKey,
101
111
  getFuelOverflowAccountPublicKey,
102
- getHighLeverageModeConfigPublicKey,
103
112
  getInsuranceFundStakeAccountPublicKey,
104
113
  getOpenbookV2FulfillmentConfigPublicKey,
105
114
  getPerpMarketPublicKey,
106
115
  getPhoenixFulfillmentConfigPublicKey,
107
116
  getProtectedMakerModeConfigPublicKey,
108
117
  getPythLazerOraclePublicKey,
109
- getPythPullOraclePublicKey,
110
118
  getReferrerNamePublicKeySync,
111
119
  getSerumFulfillmentConfigPublicKey,
112
120
  getSerumSignerPublicKey,
@@ -164,12 +172,12 @@ import { User } from './user';
164
172
  import { UserSubscriptionConfig } from './userConfig';
165
173
  import {
166
174
  configs,
167
- DRIFT_ORACLE_RECEIVER_ID,
168
175
  DEFAULT_CONFIRMATION_OPTS,
169
- DRIFT_PROGRAM_ID,
170
176
  DriftEnv,
177
+ DriftProgram,
171
178
  PYTH_LAZER_STORAGE_ACCOUNT_KEY,
172
179
  } from './config';
180
+ import { Drift } from './idl/drift';
173
181
  import { WRAPPED_SOL_MINT } from './constants/spotMarkets';
174
182
  import { UserStats } from './userStats';
175
183
  import { isSpotPositionAvailable } from './math/spotPosition';
@@ -181,28 +189,19 @@ import { SwapMode, UnifiedQuoteResponse } from './swap/UnifiedSwapClient';
181
189
  import { getNonIdleUserFilter } from './memcmp';
182
190
  import { UserStatsSubscriptionConfig } from './userStatsConfig';
183
191
  import { getMarinadeDepositIx, getMarinadeFinanceProgram } from './marinade';
184
- import { getOrderParams, isUpdateHighLeverageMode } from './orderParams';
192
+ import { getOrderParams } from './orderParams';
185
193
  import { numberToSafeBN } from './math/utils';
186
194
  import { TransactionParamProcessor } from './tx/txParamProcessor';
187
- import {
188
- isOracleTooDivergent,
189
- isOracleValid,
190
- trimVaaSignatures,
191
- } from './math/oracles';
195
+ import { isOracleTooDivergent, isOracleValid } from './math/oracles';
192
196
  import { TxHandler } from './tx/txHandler';
193
- import { parseAccumulatorUpdateData } from '@pythnetwork/price-service-sdk';
194
- import { getFeedIdUint8Array, trimFeedId } from './util/pythOracleUtils';
195
197
  import { createMinimalEd25519VerifyIx } from './util/ed25519Utils';
196
198
  import {
197
199
  createNativeInstructionDiscriminatorBuffer,
198
200
  isVersionedTransaction,
199
201
  MAX_TX_BYTE_SIZE,
200
202
  } from './tx/utils';
201
- import pythSolanaReceiverIdl from './idl/pyth_solana_receiver.json';
202
- import { asV0Tx, PullFeed, AnchorUtils } from '@switchboard-xyz/on-demand';
203
203
  import { grpcDriftClientAccountSubscriber } from './accounts/grpcDriftClientAccountSubscriber';
204
204
  import nacl from 'tweetnacl';
205
- import { Slothash } from './slot/SlothashSubscriber';
206
205
  import { getOracleId } from './oracles/oracleId';
207
206
  import { SignedMsgOrderParams } from './types';
208
207
  import { TakerInfo } from './types';
@@ -218,15 +217,6 @@ import {
218
217
  } from './math/builder';
219
218
  import { TitanClient, SwapMode as TitanSwapMode } from './titan/titanClient';
220
219
  import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
221
- import {
222
- DEFAULT_RECEIVER_PROGRAM_ID,
223
- WORMHOLE_CORE_BRIDGE_SOLANA_IDL,
224
- DEFAULT_WORMHOLE_PROGRAM_ID,
225
- getGuardianSetPda,
226
- WormholeCoreBridgeSolana,
227
- PythSolanaReceiver,
228
- } from './pyth';
229
-
230
220
  /**
231
221
  * Union type for swap clients (Titan and Jupiter) - Legacy type
232
222
  * @deprecated Use UnifiedSwapClient class instead
@@ -249,7 +239,7 @@ type RemainingAccountParams = {
249
239
  export class DriftClient {
250
240
  connection: Connection;
251
241
  wallet: IWallet;
252
- public program: Program;
242
+ public program: DriftProgram;
253
243
  provider: AnchorProvider;
254
244
  env: DriftEnv;
255
245
  opts?: ConfirmOptions;
@@ -290,12 +280,6 @@ export class DriftClient {
290
280
 
291
281
  txHandler: TxHandler;
292
282
 
293
- receiverProgram?: Program<PythSolanaReceiver>;
294
- wormholeProgram?: Program<WormholeCoreBridgeSolana>;
295
- sbOnDemandProgramdId: PublicKey;
296
- sbOnDemandProgram?: Program30<Idl30>;
297
- sbProgramFeedConfigs?: Map<string, any>;
298
-
299
283
  public get isSubscribed() {
300
284
  return this._isSubscribed && this.accountSubscriber.isSubscribed;
301
285
  }
@@ -363,9 +347,8 @@ export class DriftClient {
363
347
  config.wallet,
364
348
  this.opts
365
349
  );
366
- this.program = new Program(
367
- driftIDL as Idl,
368
- config.programID ?? new PublicKey(DRIFT_PROGRAM_ID),
350
+ this.program = new Program<Drift>(
351
+ driftIDL as Drift,
369
352
  this.provider,
370
353
  config.coder
371
354
  );
@@ -504,12 +487,12 @@ export class DriftClient {
504
487
  delistedMarketSetting
505
488
  );
506
489
  } else if (config.accountSubscription?.type === 'grpc') {
507
- const accountSubscriberClass =
490
+ const accountSubscriberClass: any =
508
491
  config.accountSubscription?.driftClientAccountSubscriber ??
509
492
  grpcDriftClientAccountSubscriber;
510
493
  this.accountSubscriber = new accountSubscriberClass(
511
494
  config.accountSubscription.grpcConfigs,
512
- this.program,
495
+ this.program as any,
513
496
  config.perpMarketIndexes ?? [],
514
497
  config.spotMarketIndexes ?? [],
515
498
  config.oracleInfos ?? [],
@@ -521,11 +504,11 @@ export class DriftClient {
521
504
  }
522
505
  );
523
506
  } else {
524
- const accountSubscriberClass =
507
+ const accountSubscriberClass: any =
525
508
  config.accountSubscription?.driftClientAccountSubscriber ??
526
509
  WebSocketDriftClientAccountSubscriber;
527
510
  this.accountSubscriber = new accountSubscriberClass(
528
- this.program,
511
+ this.program as any,
529
512
  config.perpMarketIndexes ?? [],
530
513
  config.spotMarketIndexes ?? [],
531
514
  config.oracleInfos ?? [],
@@ -554,8 +537,6 @@ export class DriftClient {
554
537
  opts: this.opts,
555
538
  txHandler: this.txHandler,
556
539
  });
557
-
558
- this.sbOnDemandProgramdId = configs[this.env].SB_ON_DEMAND_PID;
559
540
  }
560
541
 
561
542
  public getUserMapKey(subAccountId: number, authority: PublicKey): string {
@@ -739,7 +720,7 @@ export class DriftClient {
739
720
  this.program.programId,
740
721
  serumMarket
741
722
  );
742
- return (await this.program.account.serumV3FulfillmentConfig.fetch(
723
+ return (await (this.program.account as any).serumV3FulfillmentConfig.fetch(
743
724
  address
744
725
  )) as SerumV3FulfillmentConfigAccount;
745
726
  }
@@ -747,7 +728,9 @@ export class DriftClient {
747
728
  public async getSerumV3FulfillmentConfigs(): Promise<
748
729
  SerumV3FulfillmentConfigAccount[]
749
730
  > {
750
- const accounts = await this.program.account.serumV3FulfillmentConfig.all();
731
+ const accounts = await (
732
+ this.program.account as any
733
+ ).serumV3FulfillmentConfig.all();
751
734
  return accounts.map(
752
735
  (account) => account.account
753
736
  ) as SerumV3FulfillmentConfigAccount[];
@@ -760,7 +743,9 @@ export class DriftClient {
760
743
  this.program.programId,
761
744
  phoenixMarket
762
745
  );
763
- return (await this.program.account.phoenixV1FulfillmentConfig.fetch(
746
+ return (await (
747
+ this.program.account as any
748
+ ).phoenixV1FulfillmentConfig.fetch(
764
749
  address
765
750
  )) as PhoenixV1FulfillmentConfigAccount;
766
751
  }
@@ -768,8 +753,9 @@ export class DriftClient {
768
753
  public async getPhoenixV1FulfillmentConfigs(): Promise<
769
754
  PhoenixV1FulfillmentConfigAccount[]
770
755
  > {
771
- const accounts =
772
- await this.program.account.phoenixV1FulfillmentConfig.all();
756
+ const accounts = await (
757
+ this.program.account as any
758
+ ).phoenixV1FulfillmentConfig.all();
773
759
  return accounts.map(
774
760
  (account) => account.account
775
761
  ) as PhoenixV1FulfillmentConfigAccount[];
@@ -782,7 +768,9 @@ export class DriftClient {
782
768
  this.program.programId,
783
769
  openbookMarket
784
770
  );
785
- return (await this.program.account.openbookV2FulfillmentConfig.fetch(
771
+ return (await (
772
+ this.program.account as any
773
+ ).openbookV2FulfillmentConfig.fetch(
786
774
  address
787
775
  )) as OpenbookV2FulfillmentConfigAccount;
788
776
  }
@@ -790,8 +778,9 @@ export class DriftClient {
790
778
  public async getOpenbookV2FulfillmentConfigs(): Promise<
791
779
  OpenbookV2FulfillmentConfigAccount[]
792
780
  > {
793
- const accounts =
794
- await this.program.account.openbookV2FulfillmentConfig.all();
781
+ const accounts = await (
782
+ this.program.account as any
783
+ ).openbookV2FulfillmentConfig.all();
795
784
  return accounts.map(
796
785
  (account) => account.account
797
786
  ) as OpenbookV2FulfillmentConfigAccount[];
@@ -870,11 +859,7 @@ export class DriftClient {
870
859
  newWallet,
871
860
  this.opts
872
861
  );
873
- const newProgram = new Program(
874
- driftIDL as Idl,
875
- this.program.programId,
876
- newProvider
877
- );
862
+ const newProgram = new Program<Drift>(driftIDL as Drift, newProvider);
878
863
 
879
864
  this.skipLoadUsers = false;
880
865
  // Update provider for txSender with new wallet details
@@ -1419,7 +1404,7 @@ export class DriftClient {
1419
1404
  this.program.programId,
1420
1405
  authority
1421
1406
  );
1422
- return this.program.instruction.migrateReferrer({
1407
+ return (this.program.instruction as any).migrateReferrer({
1423
1408
  accounts: {
1424
1409
  escrow,
1425
1410
  authority,
@@ -1884,21 +1869,14 @@ export class DriftClient {
1884
1869
  perpMarketIndex: number,
1885
1870
  marginRatio: number,
1886
1871
  subAccountId = 0,
1887
- txParams?: TxParams,
1888
- enterHighLeverageMode?: boolean
1872
+ txParams?: TxParams
1889
1873
  ): Promise<TransactionSignature> {
1890
- const ixs = [];
1891
- if (enterHighLeverageMode) {
1892
- const enableIx = await this.getEnableHighLeverageModeIx(subAccountId);
1893
- ixs.push(enableIx);
1894
- }
1895
1874
  const updateIx = await this.getUpdateUserPerpPositionCustomMarginRatioIx(
1896
1875
  perpMarketIndex,
1897
1876
  marginRatio,
1898
1877
  subAccountId
1899
1878
  );
1900
- ixs.push(updateIx);
1901
- const tx = await this.buildTransaction(ixs, txParams ?? this.txParams);
1879
+ const tx = await this.buildTransaction(updateIx, txParams ?? this.txParams);
1902
1880
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
1903
1881
  return txSig;
1904
1882
  }
@@ -2021,7 +1999,7 @@ export class DriftClient {
2021
1999
  advancedLp: boolean,
2022
2000
  subAccountId: number
2023
2001
  ) {
2024
- const ix = await this.program.instruction.updateUserAdvancedLp(
2002
+ const ix = await (this.program.instruction as any).updateUserAdvancedLp(
2025
2003
  subAccountId,
2026
2004
  advancedLp,
2027
2005
  {
@@ -2117,7 +2095,7 @@ export class DriftClient {
2117
2095
  if (!includeIdle) {
2118
2096
  filters = [getNonIdleUserFilter()];
2119
2097
  }
2120
- return (await this.program.account.user.all(
2098
+ return (await (this.program.account as any).user.all(
2121
2099
  filters
2122
2100
  )) as ProgramAccount<UserAccount>[];
2123
2101
  }
@@ -2125,7 +2103,7 @@ export class DriftClient {
2125
2103
  public async getUserAccountsForDelegate(
2126
2104
  delegate: PublicKey
2127
2105
  ): Promise<UserAccount[]> {
2128
- const programAccounts = await this.program.account.user.all([
2106
+ const programAccounts = await (this.program.account as any).user.all([
2129
2107
  {
2130
2108
  memcmp: {
2131
2109
  offset: 40,
@@ -2143,7 +2121,7 @@ export class DriftClient {
2143
2121
  public async getUserAccountsAndAddressesForAuthority(
2144
2122
  authority: PublicKey
2145
2123
  ): Promise<ProgramAccount<UserAccount>[]> {
2146
- const programAccounts = await this.program.account.user.all([
2124
+ const programAccounts = await (this.program.account as any).user.all([
2147
2125
  {
2148
2126
  memcmp: {
2149
2127
  offset: 8,
@@ -2161,7 +2139,7 @@ export class DriftClient {
2161
2139
  public async getUserAccountsForAuthority(
2162
2140
  authority: PublicKey
2163
2141
  ): Promise<UserAccount[]> {
2164
- const programAccounts = await this.program.account.user.all([
2142
+ const programAccounts = await (this.program.account as any).user.all([
2165
2143
  {
2166
2144
  memcmp: {
2167
2145
  offset: 8,
@@ -2179,7 +2157,7 @@ export class DriftClient {
2179
2157
  public async getReferredUserStatsAccountsByReferrer(
2180
2158
  referrer: PublicKey
2181
2159
  ): Promise<UserStatsAccount[]> {
2182
- const programAccounts = await this.program.account.userStats.all([
2160
+ const programAccounts = await (this.program.account as any).userStats.all([
2183
2161
  {
2184
2162
  memcmp: {
2185
2163
  offset: 40,
@@ -2190,14 +2168,16 @@ export class DriftClient {
2190
2168
  ]);
2191
2169
 
2192
2170
  return programAccounts.map(
2193
- (programAccount) => programAccount.account as UserStatsAccount
2171
+ (programAccount) => programAccount.account as unknown as UserStatsAccount
2194
2172
  );
2195
2173
  }
2196
2174
 
2197
2175
  public async getReferrerNameAccountsForAuthority(
2198
2176
  authority: PublicKey
2199
2177
  ): Promise<ReferrerNameAccount[]> {
2200
- const programAccounts = await this.program.account.referrerName.all([
2178
+ const programAccounts = await (
2179
+ this.program.account as any
2180
+ ).referrerName.all([
2201
2181
  {
2202
2182
  memcmp: {
2203
2183
  offset: 8,
@@ -2366,7 +2346,9 @@ export class DriftClient {
2366
2346
  }
2367
2347
 
2368
2348
  public async getSignedMsgUserOrdersDeletionIx(authority: PublicKey) {
2369
- const ix = await this.program.instruction.deleteSignedMsgUserOrders({
2349
+ const ix = await (
2350
+ this.program.instruction as any
2351
+ ).deleteSignedMsgUserOrders({
2370
2352
  accounts: {
2371
2353
  user: authority,
2372
2354
  signedMsgUserOrders: getSignedMsgUserAccountPublicKey(
@@ -2475,7 +2457,7 @@ export class DriftClient {
2475
2457
  this.program.programId,
2476
2458
  nameBuffer
2477
2459
  );
2478
- return (await this.program.account.referrerName.fetch(
2460
+ return (await (this.program.account as any).referrerName.fetch(
2479
2461
  referrerNameAccountPublicKey
2480
2462
  )) as ReferrerNameAccount;
2481
2463
  }
@@ -3191,7 +3173,7 @@ export class DriftClient {
3191
3173
 
3192
3174
  const authority = overrides?.authority ?? this.wallet.publicKey;
3193
3175
  const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
3194
- return await this.program.instruction.deposit(
3176
+ return await (this.program.instruction as any).deposit(
3195
3177
  marketIndex,
3196
3178
  amount,
3197
3179
  reduceOnly,
@@ -3894,7 +3876,7 @@ export class DriftClient {
3894
3876
 
3895
3877
  const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
3896
3878
 
3897
- return await this.program.instruction.withdraw(
3879
+ return await (this.program.instruction as any).withdraw(
3898
3880
  marketIndex,
3899
3881
  amount,
3900
3882
  reduceOnly,
@@ -3988,7 +3970,7 @@ export class DriftClient {
3988
3970
  fromSubAccountId
3989
3971
  );
3990
3972
 
3991
- const fromUserAccount = (await this.program.account.user.fetch(
3973
+ const fromUserAccount = (await (this.program.account as any).user.fetch(
3992
3974
  userAccountPublicKey
3993
3975
  )) as UserAccount;
3994
3976
  remainingAccounts = this.getRemainingAccounts({
@@ -4210,6 +4192,46 @@ export class DriftClient {
4210
4192
  );
4211
4193
  }
4212
4194
 
4195
+ public async specialTransferPerpPositionToVamm(
4196
+ userAccountPublicKey: PublicKey,
4197
+ marketIndex: number,
4198
+ amount?: BN,
4199
+ txParams?: TxParams
4200
+ ): Promise<TransactionSignature> {
4201
+ const ix = await this.getSpecialTransferPerpPositionToVammIx(
4202
+ userAccountPublicKey,
4203
+ marketIndex,
4204
+ amount
4205
+ );
4206
+ const tx = await this.buildTransaction(ix, txParams);
4207
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
4208
+ return txSig;
4209
+ }
4210
+
4211
+ public async getSpecialTransferPerpPositionToVammIx(
4212
+ userAccountPublicKey: PublicKey,
4213
+ marketIndex: number,
4214
+ amount?: BN
4215
+ ): Promise<TransactionInstruction> {
4216
+ const remainingAccounts = this.getRemainingAccounts({
4217
+ userAccounts: [],
4218
+ writablePerpMarketIndexes: [marketIndex],
4219
+ });
4220
+
4221
+ return this.program.instruction.specialTransferPerpPositionToVamm(
4222
+ marketIndex,
4223
+ amount ?? null,
4224
+ {
4225
+ accounts: {
4226
+ state: await this.getStatePublicKey(),
4227
+ user: userAccountPublicKey,
4228
+ authority: this.wallet.publicKey,
4229
+ },
4230
+ remainingAccounts,
4231
+ }
4232
+ );
4233
+ }
4234
+
4213
4235
  async depositIntoIsolatedPerpPosition(
4214
4236
  amount: BN,
4215
4237
  perpMarketIndex: number,
@@ -4538,7 +4560,7 @@ export class DriftClient {
4538
4560
  settleeUserAccountPublicKey: PublicKey,
4539
4561
  marketIndex: number
4540
4562
  ): Promise<TransactionInstruction> {
4541
- const settleeUserAccount = (await this.program.account.user.fetch(
4563
+ const settleeUserAccount = (await (this.program.account as any).user.fetch(
4542
4564
  settleeUserAccountPublicKey
4543
4565
  )) as UserAccount;
4544
4566
 
@@ -4547,7 +4569,7 @@ export class DriftClient {
4547
4569
  writablePerpMarketIndexes: [marketIndex],
4548
4570
  });
4549
4571
 
4550
- return this.program.instruction.settleLp(marketIndex, {
4572
+ return (this.program.instruction as any).settleLp(marketIndex, {
4551
4573
  accounts: {
4552
4574
  state: await this.getStatePublicKey(),
4553
4575
  user: settleeUserAccountPublicKey,
@@ -4603,7 +4625,7 @@ export class DriftClient {
4603
4625
  userAccountPublicKey: PublicKey,
4604
4626
  sharesToBurn?: BN
4605
4627
  ): Promise<TransactionInstruction> {
4606
- const userAccount = (await this.program.account.user.fetch(
4628
+ const userAccount = (await (this.program.account as any).user.fetch(
4607
4629
  userAccountPublicKey
4608
4630
  )) as UserAccount;
4609
4631
 
@@ -4620,7 +4642,7 @@ export class DriftClient {
4620
4642
  console.log('burning lp shares:', sharesToBurn.toString());
4621
4643
  }
4622
4644
 
4623
- return this.program.instruction.removePerpLpSharesInExpiringMarket(
4645
+ return (this.program.instruction as any).removePerpLpSharesInExpiringMarket(
4624
4646
  sharesToBurn,
4625
4647
  marketIndex,
4626
4648
  {
@@ -4654,7 +4676,7 @@ export class DriftClient {
4654
4676
  console.log('burning lp shares:', sharesToBurn.toString());
4655
4677
  }
4656
4678
 
4657
- return this.program.instruction.removePerpLpShares(
4679
+ return (this.program.instruction as any).removePerpLpShares(
4658
4680
  sharesToBurn,
4659
4681
  marketIndex,
4660
4682
  {
@@ -4698,14 +4720,18 @@ export class DriftClient {
4698
4720
  writablePerpMarketIndexes: [marketIndex],
4699
4721
  });
4700
4722
 
4701
- return this.program.instruction.addPerpLpShares(amount, marketIndex, {
4702
- accounts: {
4703
- state: await this.getStatePublicKey(),
4704
- user,
4705
- authority: this.wallet.publicKey,
4706
- },
4707
- remainingAccounts: remainingAccounts,
4708
- });
4723
+ return (this.program.instruction as any).addPerpLpShares(
4724
+ amount,
4725
+ marketIndex,
4726
+ {
4727
+ accounts: {
4728
+ state: await this.getStatePublicKey(),
4729
+ user,
4730
+ authority: this.wallet.publicKey,
4731
+ },
4732
+ remainingAccounts: remainingAccounts,
4733
+ }
4734
+ );
4709
4735
  }
4710
4736
 
4711
4737
  public getQuoteValuePerLpShare(marketIndex: number): BN {
@@ -5018,15 +5044,7 @@ export class DriftClient {
5018
5044
  : undefined,
5019
5045
  });
5020
5046
 
5021
- if (isUpdateHighLeverageMode(orderParams.bitFlags)) {
5022
- remainingAccounts.push({
5023
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
5024
- isWritable: true,
5025
- isSigner: false,
5026
- });
5027
- }
5028
-
5029
- return await this.program.instruction.placePerpOrder(orderParams, {
5047
+ return await (this.program.instruction as any).placePerpOrder(orderParams, {
5030
5048
  accounts: {
5031
5049
  state: await this.getStatePublicKey(),
5032
5050
  user,
@@ -5248,15 +5266,18 @@ export class DriftClient {
5248
5266
  useMarketLastSlotCache: true,
5249
5267
  });
5250
5268
 
5251
- return await this.program.instruction.cancelOrderByUserId(userOrderId, {
5252
- accounts: {
5253
- state: await this.getStatePublicKey(),
5254
- user,
5255
- authority: this.wallet.publicKey,
5256
- oracle,
5257
- },
5258
- remainingAccounts,
5259
- });
5269
+ return await (this.program.instruction as any).cancelOrderByUserId(
5270
+ userOrderId,
5271
+ {
5272
+ accounts: {
5273
+ state: await this.getStatePublicKey(),
5274
+ user,
5275
+ authority: this.wallet.publicKey,
5276
+ oracle,
5277
+ },
5278
+ remainingAccounts,
5279
+ }
5280
+ );
5260
5281
  }
5261
5282
 
5262
5283
  /**
@@ -5514,28 +5535,21 @@ export class DriftClient {
5514
5535
  useMarketLastSlotCache: true,
5515
5536
  });
5516
5537
 
5517
- for (const param of params) {
5518
- if (isUpdateHighLeverageMode(param.bitFlags)) {
5519
- remainingAccounts.push({
5520
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
5521
- isWritable: true,
5522
- isSigner: false,
5523
- });
5524
- }
5525
- }
5526
-
5527
5538
  const formattedParams = params.map((item) => getOrderParams(item));
5528
5539
  const authority = overrides?.authority ?? this.wallet.publicKey;
5529
5540
 
5530
- return await this.program.instruction.placeOrders(formattedParams, {
5531
- accounts: {
5532
- state: await this.getStatePublicKey(),
5533
- user,
5534
- userStats: this.getUserStatsAccountPublicKey(),
5535
- authority,
5536
- },
5537
- remainingAccounts,
5538
- });
5541
+ return await (this.program.instruction as any).placeOrders(
5542
+ formattedParams,
5543
+ {
5544
+ accounts: {
5545
+ state: await this.getStatePublicKey(),
5546
+ user,
5547
+ userStats: this.getUserStatsAccountPublicKey(),
5548
+ authority,
5549
+ },
5550
+ remainingAccounts,
5551
+ }
5552
+ );
5539
5553
  }
5540
5554
 
5541
5555
  public async getPlaceOrdersAndSetPositionMaxLevIx(
@@ -5565,19 +5579,9 @@ export class DriftClient {
5565
5579
  useMarketLastSlotCache: true,
5566
5580
  });
5567
5581
 
5568
- for (const param of params) {
5569
- if (isUpdateHighLeverageMode(param.bitFlags)) {
5570
- remainingAccounts.push({
5571
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
5572
- isWritable: true,
5573
- isSigner: false,
5574
- });
5575
- }
5576
- }
5577
-
5578
5582
  const formattedParams = params.map((item) => getOrderParams(item));
5579
5583
 
5580
- const placeOrdersIxs = await this.program.instruction.placeOrders(
5584
+ const placeOrdersIxs = await (this.program.instruction as any).placeOrders(
5581
5585
  formattedParams,
5582
5586
  {
5583
5587
  accounts: {
@@ -5660,14 +5664,6 @@ export class DriftClient {
5660
5664
  useMarketLastSlotCache: true,
5661
5665
  });
5662
5666
 
5663
- if (isUpdateHighLeverageMode(params.bitFlags)) {
5664
- remainingAccounts.push({
5665
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
5666
- isWritable: true,
5667
- isSigner: false,
5668
- });
5669
- }
5670
-
5671
5667
  const formattedParams = {
5672
5668
  marketType: params.marketType,
5673
5669
  direction: params.direction,
@@ -5683,15 +5679,18 @@ export class DriftClient {
5683
5679
  maxTs: params.maxTs,
5684
5680
  };
5685
5681
 
5686
- return await this.program.instruction.placeScaleOrders(formattedParams, {
5687
- accounts: {
5688
- state: await this.getStatePublicKey(),
5689
- user,
5690
- userStats: this.getUserStatsAccountPublicKey(),
5691
- authority: this.wallet.publicKey,
5692
- },
5693
- remainingAccounts,
5694
- });
5682
+ return await (this.program.instruction as any).placeScaleOrders(
5683
+ formattedParams,
5684
+ {
5685
+ accounts: {
5686
+ state: await this.getStatePublicKey(),
5687
+ user,
5688
+ userStats: this.getUserStatsAccountPublicKey(),
5689
+ authority: this.wallet.publicKey,
5690
+ },
5691
+ remainingAccounts,
5692
+ }
5693
+ );
5695
5694
  }
5696
5695
 
5697
5696
  public async fillPerpOrder(
@@ -5878,179 +5877,60 @@ export class DriftClient {
5878
5877
  }
5879
5878
 
5880
5879
  public async placeSpotOrder(
5881
- orderParams: OptionalOrderParams,
5882
- txParams?: TxParams,
5883
- subAccountId?: number
5880
+ _orderParams: OptionalOrderParams,
5881
+ _txParams?: TxParams,
5882
+ _subAccountId?: number
5884
5883
  ): Promise<TransactionSignature> {
5885
- const { txSig, slot } = await this.sendTransaction(
5886
- (await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId))
5887
- .placeSpotOrderTx,
5888
- [],
5889
- this.opts,
5890
- false
5891
- );
5892
- this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
5893
- this.spotMarketLastSlotCache.set(QUOTE_SPOT_MARKET_INDEX, slot);
5894
- return txSig;
5884
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5895
5885
  }
5896
5886
 
5897
5887
  public async preparePlaceSpotOrderTx(
5898
- orderParams: OptionalOrderParams,
5899
- txParams?: TxParams,
5900
- subAccountId?: number
5888
+ _orderParams: OptionalOrderParams,
5889
+ _txParams?: TxParams,
5890
+ _subAccountId?: number
5901
5891
  ) {
5902
- const tx = await this.buildTransaction(
5903
- await this.getPlaceSpotOrderIx(orderParams, subAccountId),
5904
- txParams
5905
- );
5906
-
5907
- return {
5908
- placeSpotOrderTx: tx,
5909
- };
5892
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5910
5893
  }
5911
5894
 
5912
5895
  public async getPlaceSpotOrderIx(
5913
- orderParams: OptionalOrderParams,
5914
- subAccountId?: number,
5915
- overrides?: {
5896
+ _orderParams: OptionalOrderParams,
5897
+ _subAccountId?: number,
5898
+ _overrides?: {
5916
5899
  authority?: PublicKey;
5917
5900
  }
5918
5901
  ): Promise<TransactionInstruction> {
5919
- orderParams = getOrderParams(orderParams, { marketType: MarketType.SPOT });
5920
- const userAccountPublicKey = await this.getUserAccountPublicKey(
5921
- subAccountId
5922
- );
5923
- const authority = overrides?.authority ?? this.wallet.publicKey;
5924
-
5925
- const remainingAccounts = this.getRemainingAccounts({
5926
- userAccounts: [this.getUserAccount(subAccountId)],
5927
- useMarketLastSlotCache: true,
5928
- readableSpotMarketIndexes: [
5929
- orderParams.marketIndex,
5930
- QUOTE_SPOT_MARKET_INDEX,
5931
- ],
5932
- });
5933
-
5934
- return await this.program.instruction.placeSpotOrder(orderParams, {
5935
- accounts: {
5936
- state: await this.getStatePublicKey(),
5937
- user: userAccountPublicKey,
5938
- userStats: this.getUserStatsAccountPublicKey(),
5939
- authority,
5940
- },
5941
- remainingAccounts,
5942
- });
5902
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5943
5903
  }
5944
5904
 
5945
5905
  public async fillSpotOrder(
5946
- userAccountPublicKey: PublicKey,
5947
- user: UserAccount,
5948
- order?: Pick<Order, 'marketIndex' | 'orderId'>,
5949
- fulfillmentConfig?:
5906
+ _userAccountPublicKey: PublicKey,
5907
+ _user: UserAccount,
5908
+ _order?: Pick<Order, 'marketIndex' | 'orderId'>,
5909
+ _fulfillmentConfig?:
5950
5910
  | SerumV3FulfillmentConfigAccount
5951
5911
  | PhoenixV1FulfillmentConfigAccount
5952
5912
  | OpenbookV2FulfillmentConfigAccount,
5953
- makerInfo?: MakerInfo | MakerInfo[],
5954
- referrerInfo?: ReferrerInfo,
5955
- txParams?: TxParams
5913
+ _makerInfo?: MakerInfo | MakerInfo[],
5914
+ _referrerInfo?: ReferrerInfo,
5915
+ _txParams?: TxParams
5956
5916
  ): Promise<TransactionSignature> {
5957
- const { txSig } = await this.sendTransaction(
5958
- await this.buildTransaction(
5959
- await this.getFillSpotOrderIx(
5960
- userAccountPublicKey,
5961
- user,
5962
- order,
5963
- fulfillmentConfig,
5964
- makerInfo,
5965
- referrerInfo
5966
- ),
5967
- txParams
5968
- ),
5969
- [],
5970
- this.opts
5971
- );
5972
- return txSig;
5917
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5973
5918
  }
5974
5919
 
5975
5920
  public async getFillSpotOrderIx(
5976
- userAccountPublicKey: PublicKey,
5977
- userAccount: UserAccount,
5978
- order?: Pick<Order, 'marketIndex' | 'orderId'>,
5979
- fulfillmentConfig?:
5921
+ _userAccountPublicKey: PublicKey,
5922
+ _userAccount: UserAccount,
5923
+ _order?: Pick<Order, 'marketIndex' | 'orderId'>,
5924
+ _fulfillmentConfig?:
5980
5925
  | SerumV3FulfillmentConfigAccount
5981
5926
  | PhoenixV1FulfillmentConfigAccount
5982
5927
  | OpenbookV2FulfillmentConfigAccount,
5983
- makerInfo?: MakerInfo | MakerInfo[],
5984
- referrerInfo?: ReferrerInfo,
5985
- fillerPublicKey?: PublicKey
5928
+ _makerInfo?: MakerInfo | MakerInfo[],
5929
+ _referrerInfo?: ReferrerInfo,
5930
+ _fillerPublicKey?: PublicKey
5986
5931
  ): Promise<TransactionInstruction> {
5987
- const userStatsPublicKey = getUserStatsAccountPublicKey(
5988
- this.program.programId,
5989
- userAccount.authority
5990
- );
5991
-
5992
- const filler = fillerPublicKey ?? (await this.getUserAccountPublicKey());
5993
- const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
5994
-
5995
- const marketIndex = order
5996
- ? order.marketIndex
5997
- : userAccount.orders.find(
5998
- (order) => order.orderId === userAccount.nextOrderId - 1
5999
- ).marketIndex;
6000
-
6001
- makerInfo = Array.isArray(makerInfo)
6002
- ? makerInfo
6003
- : makerInfo
6004
- ? [makerInfo]
6005
- : [];
6006
-
6007
- const userAccounts = [userAccount];
6008
- for (const maker of makerInfo) {
6009
- userAccounts.push(maker.makerUserAccount);
6010
- }
6011
- const remainingAccounts = this.getRemainingAccounts({
6012
- userAccounts,
6013
- writableSpotMarketIndexes: [marketIndex, QUOTE_SPOT_MARKET_INDEX],
6014
- });
6015
-
6016
- for (const maker of makerInfo) {
6017
- remainingAccounts.push({
6018
- pubkey: maker.maker,
6019
- isWritable: true,
6020
- isSigner: false,
6021
- });
6022
- remainingAccounts.push({
6023
- pubkey: maker.makerStats,
6024
- isWritable: true,
6025
- isSigner: false,
6026
- });
6027
- }
6028
-
6029
- const orderId = order.orderId;
6030
-
6031
- this.addSpotFulfillmentAccounts(
6032
- marketIndex,
6033
- remainingAccounts,
6034
- fulfillmentConfig
6035
- );
6036
-
6037
- return await this.program.instruction.fillSpotOrder(
6038
- orderId,
6039
- fulfillmentConfig ? fulfillmentConfig.fulfillmentType : null,
6040
- null,
6041
- {
6042
- accounts: {
6043
- state: await this.getStatePublicKey(),
6044
- filler,
6045
- fillerStats: fillerStatsPublicKey,
6046
- user: userAccountPublicKey,
6047
- userStats: userStatsPublicKey,
6048
- authority: this.wallet.publicKey,
6049
- },
6050
- remainingAccounts,
6051
- }
6052
- );
6053
- }
5932
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5933
+ }
6054
5934
 
6055
5935
  addSpotFulfillmentAccounts(
6056
5936
  marketIndex: number,
@@ -7238,7 +7118,7 @@ export class DriftClient {
7238
7118
  public async getLogUserBalancesIx(
7239
7119
  userAccountPublicKey: PublicKey
7240
7120
  ): Promise<TransactionInstruction> {
7241
- const userAccount = (await this.program.account.user.fetch(
7121
+ const userAccount = (await (this.program.account as any).user.fetch(
7242
7122
  userAccountPublicKey
7243
7123
  )) as UserAccount;
7244
7124
  const remainingAccounts = this.getRemainingAccounts({
@@ -7292,7 +7172,7 @@ export class DriftClient {
7292
7172
  userAccounts: [userAccount],
7293
7173
  });
7294
7174
 
7295
- return await this.program.instruction.updateUserFuelBonus({
7175
+ return await (this.program.instruction as any).updateUserFuelBonus({
7296
7176
  accounts: {
7297
7177
  state: await this.getStatePublicKey(),
7298
7178
  user: userAccountPublicKey,
@@ -7367,7 +7247,7 @@ export class DriftClient {
7367
7247
  userAccounts: [userAccount],
7368
7248
  });
7369
7249
 
7370
- return await this.program.instruction.updateUserOpenOrdersCount({
7250
+ return await (this.program.instruction as any).updateUserOpenOrdersCount({
7371
7251
  accounts: {
7372
7252
  state: await this.getStatePublicKey(),
7373
7253
  filler,
@@ -7721,14 +7601,6 @@ export class DriftClient {
7721
7601
  }
7722
7602
  }
7723
7603
 
7724
- if (isUpdateHighLeverageMode(orderParams.bitFlags)) {
7725
- remainingAccounts.push({
7726
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
7727
- isWritable: true,
7728
- isSigner: false,
7729
- });
7730
- }
7731
-
7732
7604
  let optionalParams = null;
7733
7605
  if (auctionDurationPercentage || successCondition) {
7734
7606
  optionalParams =
@@ -7926,11 +7798,11 @@ export class DriftClient {
7926
7798
  prefix,
7927
7799
  delegateSigner
7928
7800
  ? this.program.coder.types.encode(
7929
- 'SignedMsgOrderParamsDelegateMessage',
7801
+ 'signedMsgOrderParamsDelegateMessage',
7930
7802
  withBuilderDefaults as SignedMsgOrderParamsDelegateMessage
7931
7803
  )
7932
7804
  : this.program.coder.types.encode(
7933
- 'SignedMsgOrderParamsMessage',
7805
+ 'signedMsgOrderParamsMessage',
7934
7806
  withBuilderDefaults as SignedMsgOrderParamsMessage
7935
7807
  ),
7936
7808
  ]);
@@ -7948,8 +7820,8 @@ export class DriftClient {
7948
7820
  delegateSigner?: boolean
7949
7821
  ): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage {
7950
7822
  const decodeStr = delegateSigner
7951
- ? 'SignedMsgOrderParamsDelegateMessage'
7952
- : 'SignedMsgOrderParamsMessage';
7823
+ ? 'signedMsgOrderParamsDelegateMessage'
7824
+ : 'signedMsgOrderParamsMessage';
7953
7825
  return this.program.coder.types.decode(
7954
7826
  decodeStr,
7955
7827
  Buffer.concat([
@@ -8033,13 +7905,6 @@ export class DriftClient {
8033
7905
  writableSpotMarketIndexes,
8034
7906
  });
8035
7907
 
8036
- if (isUpdateHighLeverageMode(signedMessage.signedMsgOrderParams.bitFlags)) {
8037
- remainingAccounts.push({
8038
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
8039
- isWritable: true,
8040
- isSigner: false,
8041
- });
8042
- }
8043
7908
  if (
8044
7909
  signedMessage.builderFeeTenthBps !== null &&
8045
7910
  signedMessage.builderIdx !== null
@@ -8237,216 +8102,55 @@ export class DriftClient {
8237
8102
  }
8238
8103
 
8239
8104
  public async preparePlaceAndTakeSpotOrder(
8240
- orderParams: OptionalOrderParams,
8241
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8242
- makerInfo?: MakerInfo,
8243
- referrerInfo?: ReferrerInfo,
8244
- txParams?: TxParams,
8245
- subAccountId?: number
8105
+ _orderParams: OptionalOrderParams,
8106
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8107
+ _makerInfo?: MakerInfo,
8108
+ _referrerInfo?: ReferrerInfo,
8109
+ _txParams?: TxParams,
8110
+ _subAccountId?: number
8246
8111
  ) {
8247
- const tx = await this.buildTransaction(
8248
- await this.getPlaceAndTakeSpotOrderIx(
8249
- orderParams,
8250
- fulfillmentConfig,
8251
- makerInfo,
8252
- referrerInfo,
8253
- subAccountId
8254
- ),
8255
- txParams
8256
- );
8257
-
8258
- return {
8259
- placeAndTakeSpotOrderTx: tx,
8260
- };
8112
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8261
8113
  }
8262
8114
 
8263
8115
  public async placeAndTakeSpotOrder(
8264
- orderParams: OptionalOrderParams,
8265
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8266
- makerInfo?: MakerInfo,
8267
- referrerInfo?: ReferrerInfo,
8268
- txParams?: TxParams,
8269
- subAccountId?: number
8116
+ _orderParams: OptionalOrderParams,
8117
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8118
+ _makerInfo?: MakerInfo,
8119
+ _referrerInfo?: ReferrerInfo,
8120
+ _txParams?: TxParams,
8121
+ _subAccountId?: number
8270
8122
  ): Promise<TransactionSignature> {
8271
- const { txSig, slot } = await this.sendTransaction(
8272
- (
8273
- await this.preparePlaceAndTakeSpotOrder(
8274
- orderParams,
8275
- fulfillmentConfig,
8276
- makerInfo,
8277
- referrerInfo,
8278
- txParams,
8279
- subAccountId
8280
- )
8281
- ).placeAndTakeSpotOrderTx,
8282
- [],
8283
- this.opts,
8284
- false
8285
- );
8286
- this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
8287
- this.spotMarketLastSlotCache.set(QUOTE_SPOT_MARKET_INDEX, slot);
8288
- return txSig;
8123
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8289
8124
  }
8290
8125
  public async getPlaceAndTakeSpotOrderIx(
8291
- orderParams: OptionalOrderParams,
8292
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8293
- makerInfo?: MakerInfo,
8294
- referrerInfo?: ReferrerInfo,
8295
- subAccountId?: number
8126
+ _orderParams: OptionalOrderParams,
8127
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8128
+ _makerInfo?: MakerInfo,
8129
+ _referrerInfo?: ReferrerInfo,
8130
+ _subAccountId?: number
8296
8131
  ): Promise<TransactionInstruction> {
8297
- orderParams = getOrderParams(orderParams, { marketType: MarketType.SPOT });
8298
- const userStatsPublicKey = this.getUserStatsAccountPublicKey();
8299
- const user = await this.getUserAccountPublicKey(subAccountId);
8300
-
8301
- const userAccounts = [this.getUserAccount(subAccountId)];
8302
- if (makerInfo !== undefined) {
8303
- userAccounts.push(makerInfo.makerUserAccount);
8304
- }
8305
- const remainingAccounts = this.getRemainingAccounts({
8306
- userAccounts,
8307
- useMarketLastSlotCache: true,
8308
- writableSpotMarketIndexes: [
8309
- orderParams.marketIndex,
8310
- QUOTE_SPOT_MARKET_INDEX,
8311
- ],
8312
- });
8313
-
8314
- let makerOrderId = null;
8315
- if (makerInfo) {
8316
- makerOrderId = makerInfo.order.orderId;
8317
- remainingAccounts.push({
8318
- pubkey: makerInfo.maker,
8319
- isSigner: false,
8320
- isWritable: true,
8321
- });
8322
- remainingAccounts.push({
8323
- pubkey: makerInfo.makerStats,
8324
- isSigner: false,
8325
- isWritable: true,
8326
- });
8327
- }
8328
-
8329
- if (referrerInfo) {
8330
- remainingAccounts.push({
8331
- pubkey: referrerInfo.referrer,
8332
- isWritable: true,
8333
- isSigner: false,
8334
- });
8335
- remainingAccounts.push({
8336
- pubkey: referrerInfo.referrerStats,
8337
- isWritable: true,
8338
- isSigner: false,
8339
- });
8340
- }
8341
-
8342
- this.addSpotFulfillmentAccounts(
8343
- orderParams.marketIndex,
8344
- remainingAccounts,
8345
- fulfillmentConfig
8346
- );
8347
-
8348
- return await this.program.instruction.placeAndTakeSpotOrder(
8349
- orderParams,
8350
- fulfillmentConfig ? fulfillmentConfig.fulfillmentType : null,
8351
- makerOrderId,
8352
- {
8353
- accounts: {
8354
- state: await this.getStatePublicKey(),
8355
- user,
8356
- userStats: userStatsPublicKey,
8357
- authority: this.wallet.publicKey,
8358
- },
8359
- remainingAccounts,
8360
- }
8361
- );
8132
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8362
8133
  }
8363
8134
 
8364
8135
  public async placeAndMakeSpotOrder(
8365
- orderParams: OptionalOrderParams,
8366
- takerInfo: TakerInfo,
8367
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8368
- referrerInfo?: ReferrerInfo,
8369
- txParams?: TxParams,
8370
- subAccountId?: number
8136
+ _orderParams: OptionalOrderParams,
8137
+ _takerInfo: TakerInfo,
8138
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8139
+ _referrerInfo?: ReferrerInfo,
8140
+ _txParams?: TxParams,
8141
+ _subAccountId?: number
8371
8142
  ): Promise<TransactionSignature> {
8372
- const { txSig, slot } = await this.sendTransaction(
8373
- await this.buildTransaction(
8374
- await this.getPlaceAndMakeSpotOrderIx(
8375
- orderParams,
8376
- takerInfo,
8377
- fulfillmentConfig,
8378
- referrerInfo,
8379
- subAccountId
8380
- ),
8381
- txParams
8382
- ),
8383
- [],
8384
- this.opts
8385
- );
8386
- this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
8387
- this.spotMarketLastSlotCache.set(QUOTE_SPOT_MARKET_INDEX, slot);
8388
- return txSig;
8143
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8389
8144
  }
8390
8145
 
8391
8146
  public async getPlaceAndMakeSpotOrderIx(
8392
- orderParams: OptionalOrderParams,
8393
- takerInfo: TakerInfo,
8394
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8395
- referrerInfo?: ReferrerInfo,
8396
- subAccountId?: number
8147
+ _orderParams: OptionalOrderParams,
8148
+ _takerInfo: TakerInfo,
8149
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8150
+ _referrerInfo?: ReferrerInfo,
8151
+ _subAccountId?: number
8397
8152
  ): Promise<TransactionInstruction> {
8398
- orderParams = getOrderParams(orderParams, { marketType: MarketType.SPOT });
8399
- const userStatsPublicKey = this.getUserStatsAccountPublicKey();
8400
- const user = await this.getUserAccountPublicKey(subAccountId);
8401
-
8402
- const remainingAccounts = this.getRemainingAccounts({
8403
- userAccounts: [
8404
- this.getUserAccount(subAccountId),
8405
- takerInfo.takerUserAccount,
8406
- ],
8407
- useMarketLastSlotCache: true,
8408
- writableSpotMarketIndexes: [
8409
- orderParams.marketIndex,
8410
- QUOTE_SPOT_MARKET_INDEX,
8411
- ],
8412
- });
8413
-
8414
- if (referrerInfo) {
8415
- remainingAccounts.push({
8416
- pubkey: referrerInfo.referrer,
8417
- isWritable: true,
8418
- isSigner: false,
8419
- });
8420
- remainingAccounts.push({
8421
- pubkey: referrerInfo.referrerStats,
8422
- isWritable: true,
8423
- isSigner: false,
8424
- });
8425
- }
8426
-
8427
- this.addSpotFulfillmentAccounts(
8428
- orderParams.marketIndex,
8429
- remainingAccounts,
8430
- fulfillmentConfig
8431
- );
8432
-
8433
- const takerOrderId = takerInfo.order.orderId;
8434
- return await this.program.instruction.placeAndMakeSpotOrder(
8435
- orderParams,
8436
- takerOrderId,
8437
- fulfillmentConfig ? fulfillmentConfig.fulfillmentType : null,
8438
- {
8439
- accounts: {
8440
- state: await this.getStatePublicKey(),
8441
- user,
8442
- userStats: userStatsPublicKey,
8443
- taker: takerInfo.taker,
8444
- takerStats: takerInfo.takerStats,
8445
- authority: this.wallet.publicKey,
8446
- },
8447
- remainingAccounts,
8448
- }
8449
- );
8153
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8450
8154
  }
8451
8155
 
8452
8156
  /**
@@ -8655,15 +8359,19 @@ export class DriftClient {
8655
8359
  overrides?.authority ??
8656
8360
  overrides?.user?.getUserAccount().authority ??
8657
8361
  this.wallet.publicKey;
8658
- return await this.program.instruction.modifyOrder(orderId, orderParams, {
8659
- accounts: {
8660
- state: await this.getStatePublicKey(),
8661
- user: userPubKey,
8662
- userStats: this.getUserStatsAccountPublicKey(),
8663
- authority,
8664
- },
8665
- remainingAccounts,
8666
- });
8362
+ return await (this.program.instruction as any).modifyOrder(
8363
+ orderId,
8364
+ orderParams,
8365
+ {
8366
+ accounts: {
8367
+ state: await this.getStatePublicKey(),
8368
+ user: userPubKey,
8369
+ userStats: this.getUserStatsAccountPublicKey(),
8370
+ authority,
8371
+ },
8372
+ remainingAccounts,
8373
+ }
8374
+ );
8667
8375
  }
8668
8376
 
8669
8377
  /**
@@ -8776,7 +8484,7 @@ export class DriftClient {
8776
8484
  maxTs: maxTs || null,
8777
8485
  };
8778
8486
 
8779
- return await this.program.instruction.modifyOrderByUserId(
8487
+ return await (this.program.instruction as any).modifyOrderByUserId(
8780
8488
  userOrderId,
8781
8489
  orderParams,
8782
8490
  {
@@ -10268,7 +9976,7 @@ export class DriftClient {
10268
9976
  public async getSettleFundingPaymentIx(
10269
9977
  userAccountPublicKey: PublicKey
10270
9978
  ): Promise<TransactionInstruction> {
10271
- const userAccount = (await this.program.account.user.fetch(
9979
+ const userAccount = (await (this.program.account as any).user.fetch(
10272
9980
  userAccountPublicKey
10273
9981
  )) as UserAccount;
10274
9982
 
@@ -10651,23 +10359,21 @@ export class DriftClient {
10651
10359
  marketIndex
10652
10360
  );
10653
10361
 
10654
- const ix = await this.program.instruction.requestRemoveInsuranceFundStake(
10655
- marketIndex,
10656
- amount,
10657
- {
10658
- accounts: {
10659
- state: await this.getStatePublicKey(),
10660
- spotMarket: spotMarketAccount.pubkey,
10661
- insuranceFundStake: ifStakeAccountPublicKey,
10662
- userStats: getUserStatsAccountPublicKey(
10663
- this.program.programId,
10664
- this.wallet.publicKey // only allow payer to request remove own insurance fund stake account
10665
- ),
10666
- authority: this.wallet.publicKey,
10667
- insuranceFundVault: spotMarketAccount.insuranceFund.vault,
10668
- },
10669
- }
10670
- );
10362
+ const ix = await (
10363
+ this.program.instruction as any
10364
+ ).requestRemoveInsuranceFundStake(marketIndex, amount, {
10365
+ accounts: {
10366
+ state: await this.getStatePublicKey(),
10367
+ spotMarket: spotMarketAccount.pubkey,
10368
+ insuranceFundStake: ifStakeAccountPublicKey,
10369
+ userStats: getUserStatsAccountPublicKey(
10370
+ this.program.programId,
10371
+ this.wallet.publicKey // only allow payer to request remove own insurance fund stake account
10372
+ ),
10373
+ authority: this.wallet.publicKey,
10374
+ insuranceFundVault: spotMarketAccount.insuranceFund.vault,
10375
+ },
10376
+ });
10671
10377
 
10672
10378
  const tx = await this.buildTransaction(ix, txParams);
10673
10379
 
@@ -10686,23 +10392,21 @@ export class DriftClient {
10686
10392
  marketIndex
10687
10393
  );
10688
10394
 
10689
- const ix =
10690
- await this.program.instruction.cancelRequestRemoveInsuranceFundStake(
10691
- marketIndex,
10692
- {
10693
- accounts: {
10694
- state: await this.getStatePublicKey(),
10695
- spotMarket: spotMarketAccount.pubkey,
10696
- insuranceFundStake: ifStakeAccountPublicKey,
10697
- userStats: getUserStatsAccountPublicKey(
10698
- this.program.programId,
10699
- this.wallet.publicKey // only allow payer to request remove own insurance fund stake account
10700
- ),
10701
- authority: this.wallet.publicKey,
10702
- insuranceFundVault: spotMarketAccount.insuranceFund.vault,
10703
- },
10704
- }
10705
- );
10395
+ const ix = await (
10396
+ this.program.instruction as any
10397
+ ).cancelRequestRemoveInsuranceFundStake(marketIndex, {
10398
+ accounts: {
10399
+ state: await this.getStatePublicKey(),
10400
+ spotMarket: spotMarketAccount.pubkey,
10401
+ insuranceFundStake: ifStakeAccountPublicKey,
10402
+ userStats: getUserStatsAccountPublicKey(
10403
+ this.program.programId,
10404
+ this.wallet.publicKey // only allow payer to request remove own insurance fund stake account
10405
+ ),
10406
+ authority: this.wallet.publicKey,
10407
+ insuranceFundVault: spotMarketAccount.insuranceFund.vault,
10408
+ },
10409
+ });
10706
10410
 
10707
10411
  const tx = await this.buildTransaction(ix, txParams);
10708
10412
 
@@ -11069,14 +10773,10 @@ export class DriftClient {
11069
10773
  public getMarketFees(
11070
10774
  marketType: MarketType,
11071
10775
  marketIndex?: number,
11072
- user?: User,
11073
- enteringHighLeverageMode?: boolean
10776
+ user?: User
11074
10777
  ) {
11075
10778
  let feeTier;
11076
- const userHLM =
11077
- (user?.isHighLeverageMode('Initial') ?? false) ||
11078
- enteringHighLeverageMode;
11079
- if (user && !userHLM) {
10779
+ if (user) {
11080
10780
  feeTier = user.getUserFeeTier(marketType);
11081
10781
  } else {
11082
10782
  const state = this.getStateAccount();
@@ -11098,9 +10798,6 @@ export class DriftClient {
11098
10798
  }
11099
10799
 
11100
10800
  takerFee += (takerFee * marketAccount.feeAdjustment) / 100;
11101
- if (userHLM) {
11102
- takerFee *= 2;
11103
- }
11104
10801
  makerFee += (makerFee * marketAccount.feeAdjustment) / 100;
11105
10802
  }
11106
10803
 
@@ -11141,240 +10838,6 @@ export class DriftClient {
11141
10838
  return undefined;
11142
10839
  }
11143
10840
 
11144
- public getReceiverProgram(): Program<PythSolanaReceiver> {
11145
- if (this.receiverProgram === undefined) {
11146
- this.receiverProgram = new Program(
11147
- pythSolanaReceiverIdl as PythSolanaReceiver,
11148
- DEFAULT_RECEIVER_PROGRAM_ID,
11149
- this.provider
11150
- );
11151
- }
11152
- return this.receiverProgram;
11153
- }
11154
-
11155
- public async getSwitchboardOnDemandProgram(): Promise<Program30<Idl30>> {
11156
- if (this.sbOnDemandProgram === undefined) {
11157
- this.sbOnDemandProgram = await AnchorUtils.loadProgramFromConnection(
11158
- this.connection
11159
- );
11160
- }
11161
- return this.sbOnDemandProgram;
11162
- }
11163
-
11164
- public async postPythPullOracleUpdateAtomic(
11165
- vaaString: string,
11166
- feedId: string
11167
- ): Promise<TransactionSignature> {
11168
- const postIxs = await this.getPostPythPullOracleUpdateAtomicIxs(
11169
- vaaString,
11170
- feedId
11171
- );
11172
- const tx = await this.buildTransaction(postIxs);
11173
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
11174
-
11175
- return txSig;
11176
- }
11177
-
11178
- public async postMultiPythPullOracleUpdatesAtomic(
11179
- vaaString: string,
11180
- feedIds: string[]
11181
- ): Promise<TransactionSignature> {
11182
- const postIxs = await this.getPostPythPullOracleUpdateAtomicIxs(
11183
- vaaString,
11184
- feedIds
11185
- );
11186
- const tx = await this.buildTransaction(postIxs);
11187
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
11188
-
11189
- return txSig;
11190
- }
11191
-
11192
- public async getPostPythPullOracleUpdateAtomicIxs(
11193
- vaaString: string,
11194
- feedIds: string | string[],
11195
- numSignatures = 2
11196
- ): Promise<TransactionInstruction[]> {
11197
- const accumulatorUpdateData = parseAccumulatorUpdateData(
11198
- Buffer.from(vaaString, 'base64')
11199
- );
11200
- const guardianSetIndex = accumulatorUpdateData.vaa.readUInt32BE(1);
11201
- const guardianSet = getGuardianSetPda(
11202
- guardianSetIndex,
11203
- DEFAULT_WORMHOLE_PROGRAM_ID
11204
- );
11205
-
11206
- const trimmedVaa = trimVaaSignatures(
11207
- accumulatorUpdateData.vaa,
11208
- numSignatures
11209
- );
11210
-
11211
- const postIxs: TransactionInstruction[] = [];
11212
- if (accumulatorUpdateData.updates.length > 1) {
11213
- const encodedParams = this.getReceiverProgram().coder.types.encode(
11214
- 'PostMultiUpdatesAtomicParams',
11215
- {
11216
- vaa: trimmedVaa,
11217
- merklePriceUpdates: accumulatorUpdateData.updates,
11218
- }
11219
- );
11220
- const feedIdsToUse: string[] =
11221
- typeof feedIds === 'string' ? [feedIds] : feedIds;
11222
- const pubkeys = feedIdsToUse.map((feedId) => {
11223
- return getPythPullOraclePublicKey(
11224
- this.program.programId,
11225
- getFeedIdUint8Array(feedId)
11226
- );
11227
- });
11228
-
11229
- const remainingAccounts: Array<AccountMeta> = pubkeys.map((pubkey) => {
11230
- return {
11231
- pubkey,
11232
- isSigner: false,
11233
- isWritable: true,
11234
- };
11235
- });
11236
- postIxs.push(
11237
- this.program.instruction.postMultiPythPullOracleUpdatesAtomic(
11238
- encodedParams,
11239
- {
11240
- accounts: {
11241
- keeper: this.wallet.publicKey,
11242
- pythSolanaReceiver: DRIFT_ORACLE_RECEIVER_ID,
11243
- guardianSet,
11244
- },
11245
- remainingAccounts,
11246
- }
11247
- )
11248
- );
11249
- } else {
11250
- let feedIdToUse = typeof feedIds === 'string' ? feedIds : feedIds[0];
11251
- feedIdToUse = trimFeedId(feedIdToUse);
11252
- postIxs.push(
11253
- await this.getSinglePostPythPullOracleAtomicIx(
11254
- {
11255
- vaa: trimmedVaa,
11256
- merklePriceUpdate: accumulatorUpdateData.updates[0],
11257
- },
11258
- feedIdToUse,
11259
- guardianSet
11260
- )
11261
- );
11262
- }
11263
- return postIxs;
11264
- }
11265
-
11266
- private async getSinglePostPythPullOracleAtomicIx(
11267
- params: {
11268
- vaa: Buffer;
11269
- merklePriceUpdate: {
11270
- message: Buffer;
11271
- proof: number[][];
11272
- };
11273
- },
11274
- feedId: string,
11275
- guardianSet: PublicKey
11276
- ): Promise<TransactionInstruction> {
11277
- const feedIdBuffer = getFeedIdUint8Array(feedId);
11278
- const receiverProgram = this.getReceiverProgram();
11279
-
11280
- const encodedParams = receiverProgram.coder.types.encode(
11281
- 'PostUpdateAtomicParams',
11282
- params
11283
- );
11284
-
11285
- return this.program.instruction.postPythPullOracleUpdateAtomic(
11286
- feedIdBuffer,
11287
- encodedParams,
11288
- {
11289
- accounts: {
11290
- keeper: this.wallet.publicKey,
11291
- pythSolanaReceiver: DRIFT_ORACLE_RECEIVER_ID,
11292
- guardianSet,
11293
- priceFeed: getPythPullOraclePublicKey(
11294
- this.program.programId,
11295
- feedIdBuffer
11296
- ),
11297
- },
11298
- }
11299
- );
11300
- }
11301
-
11302
- public async updatePythPullOracle(
11303
- vaaString: string,
11304
- feedId: string
11305
- ): Promise<TransactionSignature> {
11306
- feedId = trimFeedId(feedId);
11307
- const accumulatorUpdateData = parseAccumulatorUpdateData(
11308
- Buffer.from(vaaString, 'base64')
11309
- );
11310
- const guardianSetIndex = accumulatorUpdateData.vaa.readUInt32BE(1);
11311
- const guardianSet = getGuardianSetPda(
11312
- guardianSetIndex,
11313
- DEFAULT_WORMHOLE_PROGRAM_ID
11314
- );
11315
-
11316
- const [postIxs, encodedVaaAddress] = await this.getBuildEncodedVaaIxs(
11317
- accumulatorUpdateData.vaa,
11318
- guardianSet
11319
- );
11320
-
11321
- for (const update of accumulatorUpdateData.updates) {
11322
- postIxs.push(
11323
- await this.getUpdatePythPullOracleIxs(
11324
- {
11325
- merklePriceUpdate: update,
11326
- },
11327
- feedId,
11328
- encodedVaaAddress.publicKey
11329
- )
11330
- );
11331
- }
11332
-
11333
- const tx = await this.buildTransaction(postIxs);
11334
- const { txSig } = await this.sendTransaction(
11335
- tx,
11336
- [encodedVaaAddress],
11337
- this.opts
11338
- );
11339
-
11340
- return txSig;
11341
- }
11342
-
11343
- public async getUpdatePythPullOracleIxs(
11344
- params: {
11345
- merklePriceUpdate: {
11346
- message: Buffer;
11347
- proof: number[][];
11348
- };
11349
- },
11350
- feedId: string,
11351
- encodedVaaAddress: PublicKey
11352
- ): Promise<TransactionInstruction> {
11353
- const feedIdBuffer = getFeedIdUint8Array(feedId);
11354
- const receiverProgram = this.getReceiverProgram();
11355
-
11356
- const encodedParams = receiverProgram.coder.types.encode(
11357
- 'PostUpdateParams',
11358
- params
11359
- );
11360
-
11361
- return this.program.instruction.updatePythPullOracle(
11362
- feedIdBuffer,
11363
- encodedParams,
11364
- {
11365
- accounts: {
11366
- keeper: this.wallet.publicKey,
11367
- pythSolanaReceiver: DRIFT_ORACLE_RECEIVER_ID,
11368
- encodedVaa: encodedVaaAddress,
11369
- priceFeed: getPythPullOraclePublicKey(
11370
- this.program.programId,
11371
- feedIdBuffer
11372
- ),
11373
- },
11374
- }
11375
- );
11376
- }
11377
-
11378
10841
  public async postPythLazerOracleUpdate(
11379
10842
  feedIds: number[],
11380
10843
  pythMessageHex: string
@@ -11426,282 +10889,13 @@ export class DriftClient {
11426
10889
  return [verifyIx, ix];
11427
10890
  }
11428
10891
 
11429
- public async getPostManySwitchboardOnDemandUpdatesAtomicIxs(
11430
- feeds: PublicKey[],
11431
- recentSlothash?: Slothash,
11432
- numSignatures = 3
11433
- ): Promise<TransactionInstruction[] | undefined> {
11434
- const program = await this.getSwitchboardOnDemandProgram();
11435
- const [pullIxs, _luts, _rawResponse] =
11436
- await PullFeed.fetchUpdateManyLightIx(program, {
11437
- feeds,
11438
- numSignatures,
11439
- recentSlothashes: recentSlothash
11440
- ? [[new BN(recentSlothash.slot), recentSlothash.hash]]
11441
- : undefined,
11442
- chain: 'solana',
11443
- network: this.env,
11444
- });
11445
- if (!pullIxs) {
11446
- return undefined;
11447
- }
11448
- return pullIxs;
11449
- }
11450
-
11451
- // @deprecated use getPostManySwitchboardOnDemandUpdatesAtomicIxs instead. This function no longer returns the required ixs due to upstream sdk changes.
11452
- public async getPostSwitchboardOnDemandUpdateAtomicIx(
11453
- feed: PublicKey,
11454
- recentSlothash?: Slothash,
11455
- numSignatures = 3
11456
- ): Promise<TransactionInstruction | undefined> {
11457
- const program = await this.getSwitchboardOnDemandProgram();
11458
- const feedAccount = new PullFeed(program, feed);
11459
- if (!this.sbProgramFeedConfigs) {
11460
- this.sbProgramFeedConfigs = new Map();
11461
- }
11462
- if (!this.sbProgramFeedConfigs.has(feedAccount.pubkey.toString())) {
11463
- const feedConfig = await feedAccount.loadConfigs();
11464
- this.sbProgramFeedConfigs.set(feed.toString(), feedConfig);
11465
- }
11466
- const [pullIx, _responses, success] = await PullFeed.fetchUpdateManyIx(
11467
- program,
11468
- {
11469
- feeds: [feed],
11470
- numSignatures,
11471
- recentSlothashes: recentSlothash
11472
- ? [[new BN(recentSlothash.slot), recentSlothash.hash]]
11473
- : undefined,
11474
- }
11475
- );
11476
- if (!success) {
11477
- return undefined;
11478
- }
11479
- return pullIx[0];
11480
- }
11481
-
11482
- public async postSwitchboardOnDemandUpdate(
11483
- feed: PublicKey,
11484
- recentSlothash?: Slothash,
11485
- numSignatures = 3
11486
- ): Promise<TransactionSignature> {
11487
- const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(
11488
- feed,
11489
- recentSlothash,
11490
- numSignatures
11491
- );
11492
- if (!pullIx) {
11493
- return undefined;
11494
- }
11495
- const tx = await asV0Tx({
11496
- connection: this.connection,
11497
- ixs: [pullIx],
11498
- payer: this.wallet.publicKey,
11499
- computeUnitLimitMultiple: 1.3,
11500
- lookupTables: await this.fetchAllLookupTableAccounts(),
11501
- });
11502
- const { txSig } = await this.sendTransaction(tx, [], {
11503
- commitment: 'processed',
11504
- skipPreflight: true,
11505
- maxRetries: 0,
11506
- });
11507
- return txSig;
11508
- }
11509
-
11510
- private async getBuildEncodedVaaIxs(
11511
- vaa: Buffer,
11512
- guardianSet: PublicKey
11513
- ): Promise<[TransactionInstruction[], Keypair]> {
11514
- const postIxs: TransactionInstruction[] = [];
11515
-
11516
- if (this.wormholeProgram === undefined) {
11517
- this.wormholeProgram = new Program(
11518
- WORMHOLE_CORE_BRIDGE_SOLANA_IDL,
11519
- DEFAULT_WORMHOLE_PROGRAM_ID,
11520
- this.provider
11521
- );
11522
- }
11523
-
11524
- const encodedVaaKeypair = new Keypair();
11525
- postIxs.push(
11526
- await this.wormholeProgram.account.encodedVaa.createInstruction(
11527
- encodedVaaKeypair,
11528
- vaa.length + 46
11529
- )
11530
- );
11531
-
11532
- // Why do we need this too?
11533
- postIxs.push(
11534
- await this.wormholeProgram.methods
11535
- .initEncodedVaa()
11536
- .accounts({
11537
- encodedVaa: encodedVaaKeypair.publicKey,
11538
- })
11539
- .instruction()
11540
- );
11541
-
11542
- // Split the write into two ixs
11543
- postIxs.push(
11544
- await this.wormholeProgram.methods
11545
- .writeEncodedVaa({
11546
- index: 0,
11547
- data: vaa.subarray(0, 755),
11548
- })
11549
- .accounts({
11550
- draftVaa: encodedVaaKeypair.publicKey,
11551
- })
11552
- .instruction()
11553
- );
11554
-
11555
- postIxs.push(
11556
- await this.wormholeProgram.methods
11557
- .writeEncodedVaa({
11558
- index: 755,
11559
- data: vaa.subarray(755),
11560
- })
11561
- .accounts({
11562
- draftVaa: encodedVaaKeypair.publicKey,
11563
- })
11564
- .instruction()
11565
- );
11566
-
11567
- // Verify
11568
- postIxs.push(
11569
- await this.wormholeProgram.methods
11570
- .verifyEncodedVaaV1()
11571
- .accounts({
11572
- guardianSet,
11573
- draftVaa: encodedVaaKeypair.publicKey,
11574
- })
11575
- .instruction()
11576
- );
11577
-
11578
- return [postIxs, encodedVaaKeypair];
11579
- }
11580
-
11581
- public async enableUserHighLeverageMode(
11582
- subAccountId: number,
11583
- txParams?: TxParams
11584
- ): Promise<TransactionSignature> {
11585
- const { txSig } = await this.sendTransaction(
11586
- await this.buildTransaction(
11587
- await this.getEnableHighLeverageModeIx(subAccountId),
11588
- txParams
11589
- ),
11590
- [],
11591
- this.opts
11592
- );
11593
- return txSig;
11594
- }
11595
-
11596
- public async getEnableHighLeverageModeIx(
11597
- subAccountId: number,
11598
- depositToTradeArgs?: {
11599
- isMakingNewAccount: boolean;
11600
- depositMarketIndex: number;
11601
- orderMarketIndex: number;
11602
- },
11603
- overrides?: {
11604
- user?: User;
11605
- signingAuthority?: PublicKey;
11606
- }
11607
- ): Promise<TransactionInstruction> {
11608
- const isDepositToTradeTx = depositToTradeArgs !== undefined;
11609
- const userAccountPublicKey =
11610
- overrides?.user?.getUserAccountPublicKey() ??
11611
- getUserAccountPublicKeySync(
11612
- this.program.programId,
11613
- this.wallet.publicKey,
11614
- subAccountId
11615
- );
11616
- const signingAuthority =
11617
- overrides?.signingAuthority ?? this.wallet.publicKey;
11618
- const userAccount =
11619
- overrides?.user.getUserAccount() ?? this.getUserAccount(subAccountId);
11620
-
11621
- const remainingAccounts = this.getRemainingAccounts({
11622
- userAccounts: depositToTradeArgs?.isMakingNewAccount ? [] : [userAccount],
11623
- useMarketLastSlotCache: false,
11624
- readablePerpMarketIndex: depositToTradeArgs?.orderMarketIndex,
11625
- readableSpotMarketIndexes: isDepositToTradeTx
11626
- ? [depositToTradeArgs?.depositMarketIndex]
11627
- : undefined,
11628
- });
11629
-
11630
- const ix = await this.program.instruction.enableUserHighLeverageMode(
11631
- subAccountId,
11632
- {
11633
- accounts: {
11634
- state: await this.getStatePublicKey(),
11635
- user: userAccountPublicKey,
11636
- authority: signingAuthority,
11637
- highLeverageModeConfig: getHighLeverageModeConfigPublicKey(
11638
- this.program.programId
11639
- ),
11640
- },
11641
- remainingAccounts,
11642
- }
11643
- );
11644
-
11645
- return ix;
11646
- }
11647
-
11648
- public async disableUserHighLeverageMode(
11649
- user: PublicKey,
11650
- userAccount?: UserAccount,
11651
- txParams?: TxParams
11652
- ): Promise<TransactionSignature> {
11653
- const { txSig } = await this.sendTransaction(
11654
- await this.buildTransaction(
11655
- await this.getDisableHighLeverageModeIx(user, userAccount),
11656
- txParams
11657
- ),
11658
- [],
11659
- this.opts
11660
- );
11661
- return txSig;
11662
- }
11663
-
11664
- public async getDisableHighLeverageModeIx(
11665
- user: PublicKey,
11666
- userAccount?: UserAccount,
11667
- maintenance = false
11668
- ): Promise<TransactionInstruction> {
11669
- const remainingAccounts = userAccount
11670
- ? this.getRemainingAccounts({
11671
- userAccounts: [userAccount],
11672
- })
11673
- : undefined;
11674
-
11675
- const ix = await this.program.instruction.disableUserHighLeverageMode(
11676
- maintenance,
11677
- {
11678
- accounts: {
11679
- state: await this.getStatePublicKey(),
11680
- user,
11681
- authority: this.wallet.publicKey,
11682
- highLeverageModeConfig: getHighLeverageModeConfigPublicKey(
11683
- this.program.programId
11684
- ),
11685
- },
11686
- remainingAccounts,
11687
- }
11688
- );
11689
-
11690
- return ix;
11691
- }
11692
-
11693
- public async fetchHighLeverageModeConfig(): Promise<HighLeverageModeConfig> {
11694
- const config = await this.program.account.highLeverageModeConfig.fetch(
11695
- getHighLeverageModeConfigPublicKey(this.program.programId)
11696
- );
11697
- return config as HighLeverageModeConfig;
11698
- }
11699
-
11700
10892
  public async fetchProtectedMakerModeConfig(): Promise<ProtectedMakerModeConfig> {
11701
- const config = await this.program.account.protectedMakerModeConfig.fetch(
10893
+ const config = await (
10894
+ this.program.account as any
10895
+ ).protectedMakerModeConfig.fetch(
11702
10896
  getProtectedMakerModeConfigPublicKey(this.program.programId)
11703
10897
  );
11704
- return config as ProtectedMakerModeConfig;
10898
+ return config as unknown as ProtectedMakerModeConfig;
11705
10899
  }
11706
10900
  public async updateUserProtectedMakerOrders(
11707
10901
  subAccountId: number,
@@ -11887,15 +11081,15 @@ export class DriftClient {
11887
11081
  }
11888
11082
 
11889
11083
  public async getLpPoolAccount(lpPoolId: number): Promise<LPPoolAccount> {
11890
- return (await this.program.account.lpPool.fetch(
11084
+ return (await (this.program.account as any).lpPool.fetch(
11891
11085
  getLpPoolPublicKey(this.program.programId, lpPoolId)
11892
- )) as LPPoolAccount;
11086
+ )) as unknown as LPPoolAccount;
11893
11087
  }
11894
11088
 
11895
11089
  public async getConstituentTargetBaseAccount(
11896
11090
  lpPoolId: number
11897
11091
  ): Promise<ConstituentTargetBaseAccount> {
11898
- return (await this.program.account.constituentTargetBase.fetch(
11092
+ return (await (this.program.account as any).constituentTargetBase.fetch(
11899
11093
  getConstituentTargetBasePublicKey(
11900
11094
  this.program.programId,
11901
11095
  getLpPoolPublicKey(this.program.programId, lpPoolId)
@@ -11904,7 +11098,7 @@ export class DriftClient {
11904
11098
  }
11905
11099
 
11906
11100
  public async getAmmCache(): Promise<AmmCache> {
11907
- return (await this.program.account.ammCache.fetch(
11101
+ return (await (this.program.account as any).ammCache.fetch(
11908
11102
  getAmmCachePublicKey(this.program.programId)
11909
11103
  )) as AmmCache;
11910
11104
  }