@drift-labs/sdk-browser 2.162.0-beta.2 → 2.163.0-beta.9

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 +11 -9
  49. package/lib/browser/adminClient.js +30 -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 +7 -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 +32 -59
  71. package/lib/browser/driftClient.js +85 -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 +25708 -0
  79. package/lib/browser/idl/drift.js +2 -0
  80. package/lib/browser/idl/drift.json +20850 -15287
  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 +19 -31
  128. package/lib/browser/types.js +6 -11
  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 +11 -9
  212. package/lib/node/adminClient.d.ts.map +1 -1
  213. package/lib/node/adminClient.js +30 -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 +7 -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 +32 -59
  249. package/lib/node/driftClient.d.ts.map +1 -1
  250. package/lib/node/driftClient.js +85 -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 +25709 -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 +20850 -15287
  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 +19 -31
  338. package/lib/node/types.d.ts.map +1 -1
  339. package/lib/node/types.js +6 -11
  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 +154 -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 +7 -25
  400. package/src/dlob/DLOB.ts +12 -0
  401. package/src/dlob/orderBookLevels.ts +0 -1
  402. package/src/driftClient.ts +245 -1091
  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 +20850 -15287
  408. package/src/idl/drift.ts +25708 -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 +16 -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 +0 -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({
@@ -4538,7 +4520,7 @@ export class DriftClient {
4538
4520
  settleeUserAccountPublicKey: PublicKey,
4539
4521
  marketIndex: number
4540
4522
  ): Promise<TransactionInstruction> {
4541
- const settleeUserAccount = (await this.program.account.user.fetch(
4523
+ const settleeUserAccount = (await (this.program.account as any).user.fetch(
4542
4524
  settleeUserAccountPublicKey
4543
4525
  )) as UserAccount;
4544
4526
 
@@ -4547,7 +4529,7 @@ export class DriftClient {
4547
4529
  writablePerpMarketIndexes: [marketIndex],
4548
4530
  });
4549
4531
 
4550
- return this.program.instruction.settleLp(marketIndex, {
4532
+ return (this.program.instruction as any).settleLp(marketIndex, {
4551
4533
  accounts: {
4552
4534
  state: await this.getStatePublicKey(),
4553
4535
  user: settleeUserAccountPublicKey,
@@ -4603,7 +4585,7 @@ export class DriftClient {
4603
4585
  userAccountPublicKey: PublicKey,
4604
4586
  sharesToBurn?: BN
4605
4587
  ): Promise<TransactionInstruction> {
4606
- const userAccount = (await this.program.account.user.fetch(
4588
+ const userAccount = (await (this.program.account as any).user.fetch(
4607
4589
  userAccountPublicKey
4608
4590
  )) as UserAccount;
4609
4591
 
@@ -4620,7 +4602,7 @@ export class DriftClient {
4620
4602
  console.log('burning lp shares:', sharesToBurn.toString());
4621
4603
  }
4622
4604
 
4623
- return this.program.instruction.removePerpLpSharesInExpiringMarket(
4605
+ return (this.program.instruction as any).removePerpLpSharesInExpiringMarket(
4624
4606
  sharesToBurn,
4625
4607
  marketIndex,
4626
4608
  {
@@ -4654,7 +4636,7 @@ export class DriftClient {
4654
4636
  console.log('burning lp shares:', sharesToBurn.toString());
4655
4637
  }
4656
4638
 
4657
- return this.program.instruction.removePerpLpShares(
4639
+ return (this.program.instruction as any).removePerpLpShares(
4658
4640
  sharesToBurn,
4659
4641
  marketIndex,
4660
4642
  {
@@ -4698,14 +4680,18 @@ export class DriftClient {
4698
4680
  writablePerpMarketIndexes: [marketIndex],
4699
4681
  });
4700
4682
 
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
- });
4683
+ return (this.program.instruction as any).addPerpLpShares(
4684
+ amount,
4685
+ marketIndex,
4686
+ {
4687
+ accounts: {
4688
+ state: await this.getStatePublicKey(),
4689
+ user,
4690
+ authority: this.wallet.publicKey,
4691
+ },
4692
+ remainingAccounts: remainingAccounts,
4693
+ }
4694
+ );
4709
4695
  }
4710
4696
 
4711
4697
  public getQuoteValuePerLpShare(marketIndex: number): BN {
@@ -5018,15 +5004,7 @@ export class DriftClient {
5018
5004
  : undefined,
5019
5005
  });
5020
5006
 
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, {
5007
+ return await (this.program.instruction as any).placePerpOrder(orderParams, {
5030
5008
  accounts: {
5031
5009
  state: await this.getStatePublicKey(),
5032
5010
  user,
@@ -5248,15 +5226,18 @@ export class DriftClient {
5248
5226
  useMarketLastSlotCache: true,
5249
5227
  });
5250
5228
 
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
- });
5229
+ return await (this.program.instruction as any).cancelOrderByUserId(
5230
+ userOrderId,
5231
+ {
5232
+ accounts: {
5233
+ state: await this.getStatePublicKey(),
5234
+ user,
5235
+ authority: this.wallet.publicKey,
5236
+ oracle,
5237
+ },
5238
+ remainingAccounts,
5239
+ }
5240
+ );
5260
5241
  }
5261
5242
 
5262
5243
  /**
@@ -5514,28 +5495,21 @@ export class DriftClient {
5514
5495
  useMarketLastSlotCache: true,
5515
5496
  });
5516
5497
 
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
5498
  const formattedParams = params.map((item) => getOrderParams(item));
5528
5499
  const authority = overrides?.authority ?? this.wallet.publicKey;
5529
5500
 
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
- });
5501
+ return await (this.program.instruction as any).placeOrders(
5502
+ formattedParams,
5503
+ {
5504
+ accounts: {
5505
+ state: await this.getStatePublicKey(),
5506
+ user,
5507
+ userStats: this.getUserStatsAccountPublicKey(),
5508
+ authority,
5509
+ },
5510
+ remainingAccounts,
5511
+ }
5512
+ );
5539
5513
  }
5540
5514
 
5541
5515
  public async getPlaceOrdersAndSetPositionMaxLevIx(
@@ -5565,19 +5539,9 @@ export class DriftClient {
5565
5539
  useMarketLastSlotCache: true,
5566
5540
  });
5567
5541
 
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
5542
  const formattedParams = params.map((item) => getOrderParams(item));
5579
5543
 
5580
- const placeOrdersIxs = await this.program.instruction.placeOrders(
5544
+ const placeOrdersIxs = await (this.program.instruction as any).placeOrders(
5581
5545
  formattedParams,
5582
5546
  {
5583
5547
  accounts: {
@@ -5660,14 +5624,6 @@ export class DriftClient {
5660
5624
  useMarketLastSlotCache: true,
5661
5625
  });
5662
5626
 
5663
- if (isUpdateHighLeverageMode(params.bitFlags)) {
5664
- remainingAccounts.push({
5665
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
5666
- isWritable: true,
5667
- isSigner: false,
5668
- });
5669
- }
5670
-
5671
5627
  const formattedParams = {
5672
5628
  marketType: params.marketType,
5673
5629
  direction: params.direction,
@@ -5683,15 +5639,18 @@ export class DriftClient {
5683
5639
  maxTs: params.maxTs,
5684
5640
  };
5685
5641
 
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
- });
5642
+ return await (this.program.instruction as any).placeScaleOrders(
5643
+ formattedParams,
5644
+ {
5645
+ accounts: {
5646
+ state: await this.getStatePublicKey(),
5647
+ user,
5648
+ userStats: this.getUserStatsAccountPublicKey(),
5649
+ authority: this.wallet.publicKey,
5650
+ },
5651
+ remainingAccounts,
5652
+ }
5653
+ );
5695
5654
  }
5696
5655
 
5697
5656
  public async fillPerpOrder(
@@ -5878,178 +5837,59 @@ export class DriftClient {
5878
5837
  }
5879
5838
 
5880
5839
  public async placeSpotOrder(
5881
- orderParams: OptionalOrderParams,
5882
- txParams?: TxParams,
5883
- subAccountId?: number
5840
+ _orderParams: OptionalOrderParams,
5841
+ _txParams?: TxParams,
5842
+ _subAccountId?: number
5884
5843
  ): 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;
5844
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5895
5845
  }
5896
5846
 
5897
5847
  public async preparePlaceSpotOrderTx(
5898
- orderParams: OptionalOrderParams,
5899
- txParams?: TxParams,
5900
- subAccountId?: number
5848
+ _orderParams: OptionalOrderParams,
5849
+ _txParams?: TxParams,
5850
+ _subAccountId?: number
5901
5851
  ) {
5902
- const tx = await this.buildTransaction(
5903
- await this.getPlaceSpotOrderIx(orderParams, subAccountId),
5904
- txParams
5905
- );
5906
-
5907
- return {
5908
- placeSpotOrderTx: tx,
5909
- };
5852
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5910
5853
  }
5911
5854
 
5912
5855
  public async getPlaceSpotOrderIx(
5913
- orderParams: OptionalOrderParams,
5914
- subAccountId?: number,
5915
- overrides?: {
5856
+ _orderParams: OptionalOrderParams,
5857
+ _subAccountId?: number,
5858
+ _overrides?: {
5916
5859
  authority?: PublicKey;
5917
5860
  }
5918
5861
  ): 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
- });
5862
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5943
5863
  }
5944
5864
 
5945
5865
  public async fillSpotOrder(
5946
- userAccountPublicKey: PublicKey,
5947
- user: UserAccount,
5948
- order?: Pick<Order, 'marketIndex' | 'orderId'>,
5949
- fulfillmentConfig?:
5866
+ _userAccountPublicKey: PublicKey,
5867
+ _user: UserAccount,
5868
+ _order?: Pick<Order, 'marketIndex' | 'orderId'>,
5869
+ _fulfillmentConfig?:
5950
5870
  | SerumV3FulfillmentConfigAccount
5951
5871
  | PhoenixV1FulfillmentConfigAccount
5952
5872
  | OpenbookV2FulfillmentConfigAccount,
5953
- makerInfo?: MakerInfo | MakerInfo[],
5954
- referrerInfo?: ReferrerInfo,
5955
- txParams?: TxParams
5873
+ _makerInfo?: MakerInfo | MakerInfo[],
5874
+ _referrerInfo?: ReferrerInfo,
5875
+ _txParams?: TxParams
5956
5876
  ): 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;
5877
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
5973
5878
  }
5974
5879
 
5975
5880
  public async getFillSpotOrderIx(
5976
- userAccountPublicKey: PublicKey,
5977
- userAccount: UserAccount,
5978
- order?: Pick<Order, 'marketIndex' | 'orderId'>,
5979
- fulfillmentConfig?:
5881
+ _userAccountPublicKey: PublicKey,
5882
+ _userAccount: UserAccount,
5883
+ _order?: Pick<Order, 'marketIndex' | 'orderId'>,
5884
+ _fulfillmentConfig?:
5980
5885
  | SerumV3FulfillmentConfigAccount
5981
5886
  | PhoenixV1FulfillmentConfigAccount
5982
5887
  | OpenbookV2FulfillmentConfigAccount,
5983
- makerInfo?: MakerInfo | MakerInfo[],
5984
- referrerInfo?: ReferrerInfo,
5985
- fillerPublicKey?: PublicKey
5888
+ _makerInfo?: MakerInfo | MakerInfo[],
5889
+ _referrerInfo?: ReferrerInfo,
5890
+ _fillerPublicKey?: PublicKey
5986
5891
  ): 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
- );
5892
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
6053
5893
  }
6054
5894
 
6055
5895
  addSpotFulfillmentAccounts(
@@ -7238,7 +7078,7 @@ export class DriftClient {
7238
7078
  public async getLogUserBalancesIx(
7239
7079
  userAccountPublicKey: PublicKey
7240
7080
  ): Promise<TransactionInstruction> {
7241
- const userAccount = (await this.program.account.user.fetch(
7081
+ const userAccount = (await (this.program.account as any).user.fetch(
7242
7082
  userAccountPublicKey
7243
7083
  )) as UserAccount;
7244
7084
  const remainingAccounts = this.getRemainingAccounts({
@@ -7292,7 +7132,7 @@ export class DriftClient {
7292
7132
  userAccounts: [userAccount],
7293
7133
  });
7294
7134
 
7295
- return await this.program.instruction.updateUserFuelBonus({
7135
+ return await (this.program.instruction as any).updateUserFuelBonus({
7296
7136
  accounts: {
7297
7137
  state: await this.getStatePublicKey(),
7298
7138
  user: userAccountPublicKey,
@@ -7367,7 +7207,7 @@ export class DriftClient {
7367
7207
  userAccounts: [userAccount],
7368
7208
  });
7369
7209
 
7370
- return await this.program.instruction.updateUserOpenOrdersCount({
7210
+ return await (this.program.instruction as any).updateUserOpenOrdersCount({
7371
7211
  accounts: {
7372
7212
  state: await this.getStatePublicKey(),
7373
7213
  filler,
@@ -7721,14 +7561,6 @@ export class DriftClient {
7721
7561
  }
7722
7562
  }
7723
7563
 
7724
- if (isUpdateHighLeverageMode(orderParams.bitFlags)) {
7725
- remainingAccounts.push({
7726
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
7727
- isWritable: true,
7728
- isSigner: false,
7729
- });
7730
- }
7731
-
7732
7564
  let optionalParams = null;
7733
7565
  if (auctionDurationPercentage || successCondition) {
7734
7566
  optionalParams =
@@ -7926,11 +7758,11 @@ export class DriftClient {
7926
7758
  prefix,
7927
7759
  delegateSigner
7928
7760
  ? this.program.coder.types.encode(
7929
- 'SignedMsgOrderParamsDelegateMessage',
7761
+ 'signedMsgOrderParamsDelegateMessage',
7930
7762
  withBuilderDefaults as SignedMsgOrderParamsDelegateMessage
7931
7763
  )
7932
7764
  : this.program.coder.types.encode(
7933
- 'SignedMsgOrderParamsMessage',
7765
+ 'signedMsgOrderParamsMessage',
7934
7766
  withBuilderDefaults as SignedMsgOrderParamsMessage
7935
7767
  ),
7936
7768
  ]);
@@ -7948,8 +7780,8 @@ export class DriftClient {
7948
7780
  delegateSigner?: boolean
7949
7781
  ): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage {
7950
7782
  const decodeStr = delegateSigner
7951
- ? 'SignedMsgOrderParamsDelegateMessage'
7952
- : 'SignedMsgOrderParamsMessage';
7783
+ ? 'signedMsgOrderParamsDelegateMessage'
7784
+ : 'signedMsgOrderParamsMessage';
7953
7785
  return this.program.coder.types.decode(
7954
7786
  decodeStr,
7955
7787
  Buffer.concat([
@@ -8033,13 +7865,6 @@ export class DriftClient {
8033
7865
  writableSpotMarketIndexes,
8034
7866
  });
8035
7867
 
8036
- if (isUpdateHighLeverageMode(signedMessage.signedMsgOrderParams.bitFlags)) {
8037
- remainingAccounts.push({
8038
- pubkey: getHighLeverageModeConfigPublicKey(this.program.programId),
8039
- isWritable: true,
8040
- isSigner: false,
8041
- });
8042
- }
8043
7868
  if (
8044
7869
  signedMessage.builderFeeTenthBps !== null &&
8045
7870
  signedMessage.builderIdx !== null
@@ -8237,216 +8062,55 @@ export class DriftClient {
8237
8062
  }
8238
8063
 
8239
8064
  public async preparePlaceAndTakeSpotOrder(
8240
- orderParams: OptionalOrderParams,
8241
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8242
- makerInfo?: MakerInfo,
8243
- referrerInfo?: ReferrerInfo,
8244
- txParams?: TxParams,
8245
- subAccountId?: number
8065
+ _orderParams: OptionalOrderParams,
8066
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8067
+ _makerInfo?: MakerInfo,
8068
+ _referrerInfo?: ReferrerInfo,
8069
+ _txParams?: TxParams,
8070
+ _subAccountId?: number
8246
8071
  ) {
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
- };
8072
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8261
8073
  }
8262
8074
 
8263
8075
  public async placeAndTakeSpotOrder(
8264
- orderParams: OptionalOrderParams,
8265
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8266
- makerInfo?: MakerInfo,
8267
- referrerInfo?: ReferrerInfo,
8268
- txParams?: TxParams,
8269
- subAccountId?: number
8076
+ _orderParams: OptionalOrderParams,
8077
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8078
+ _makerInfo?: MakerInfo,
8079
+ _referrerInfo?: ReferrerInfo,
8080
+ _txParams?: TxParams,
8081
+ _subAccountId?: number
8270
8082
  ): 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;
8083
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8289
8084
  }
8290
8085
  public async getPlaceAndTakeSpotOrderIx(
8291
- orderParams: OptionalOrderParams,
8292
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8293
- makerInfo?: MakerInfo,
8294
- referrerInfo?: ReferrerInfo,
8295
- subAccountId?: number
8086
+ _orderParams: OptionalOrderParams,
8087
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8088
+ _makerInfo?: MakerInfo,
8089
+ _referrerInfo?: ReferrerInfo,
8090
+ _subAccountId?: number
8296
8091
  ): 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
- );
8092
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8362
8093
  }
8363
8094
 
8364
8095
  public async placeAndMakeSpotOrder(
8365
- orderParams: OptionalOrderParams,
8366
- takerInfo: TakerInfo,
8367
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8368
- referrerInfo?: ReferrerInfo,
8369
- txParams?: TxParams,
8370
- subAccountId?: number
8096
+ _orderParams: OptionalOrderParams,
8097
+ _takerInfo: TakerInfo,
8098
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8099
+ _referrerInfo?: ReferrerInfo,
8100
+ _txParams?: TxParams,
8101
+ _subAccountId?: number
8371
8102
  ): 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;
8103
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8389
8104
  }
8390
8105
 
8391
8106
  public async getPlaceAndMakeSpotOrderIx(
8392
- orderParams: OptionalOrderParams,
8393
- takerInfo: TakerInfo,
8394
- fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8395
- referrerInfo?: ReferrerInfo,
8396
- subAccountId?: number
8107
+ _orderParams: OptionalOrderParams,
8108
+ _takerInfo: TakerInfo,
8109
+ _fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
8110
+ _referrerInfo?: ReferrerInfo,
8111
+ _subAccountId?: number
8397
8112
  ): 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
- );
8113
+ throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
8450
8114
  }
8451
8115
 
8452
8116
  /**
@@ -8655,15 +8319,19 @@ export class DriftClient {
8655
8319
  overrides?.authority ??
8656
8320
  overrides?.user?.getUserAccount().authority ??
8657
8321
  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
- });
8322
+ return await (this.program.instruction as any).modifyOrder(
8323
+ orderId,
8324
+ orderParams,
8325
+ {
8326
+ accounts: {
8327
+ state: await this.getStatePublicKey(),
8328
+ user: userPubKey,
8329
+ userStats: this.getUserStatsAccountPublicKey(),
8330
+ authority,
8331
+ },
8332
+ remainingAccounts,
8333
+ }
8334
+ );
8667
8335
  }
8668
8336
 
8669
8337
  /**
@@ -8776,7 +8444,7 @@ export class DriftClient {
8776
8444
  maxTs: maxTs || null,
8777
8445
  };
8778
8446
 
8779
- return await this.program.instruction.modifyOrderByUserId(
8447
+ return await (this.program.instruction as any).modifyOrderByUserId(
8780
8448
  userOrderId,
8781
8449
  orderParams,
8782
8450
  {
@@ -10268,7 +9936,7 @@ export class DriftClient {
10268
9936
  public async getSettleFundingPaymentIx(
10269
9937
  userAccountPublicKey: PublicKey
10270
9938
  ): Promise<TransactionInstruction> {
10271
- const userAccount = (await this.program.account.user.fetch(
9939
+ const userAccount = (await (this.program.account as any).user.fetch(
10272
9940
  userAccountPublicKey
10273
9941
  )) as UserAccount;
10274
9942
 
@@ -10651,23 +10319,21 @@ export class DriftClient {
10651
10319
  marketIndex
10652
10320
  );
10653
10321
 
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
- );
10322
+ const ix = await (
10323
+ this.program.instruction as any
10324
+ ).requestRemoveInsuranceFundStake(marketIndex, amount, {
10325
+ accounts: {
10326
+ state: await this.getStatePublicKey(),
10327
+ spotMarket: spotMarketAccount.pubkey,
10328
+ insuranceFundStake: ifStakeAccountPublicKey,
10329
+ userStats: getUserStatsAccountPublicKey(
10330
+ this.program.programId,
10331
+ this.wallet.publicKey // only allow payer to request remove own insurance fund stake account
10332
+ ),
10333
+ authority: this.wallet.publicKey,
10334
+ insuranceFundVault: spotMarketAccount.insuranceFund.vault,
10335
+ },
10336
+ });
10671
10337
 
10672
10338
  const tx = await this.buildTransaction(ix, txParams);
10673
10339
 
@@ -10686,23 +10352,21 @@ export class DriftClient {
10686
10352
  marketIndex
10687
10353
  );
10688
10354
 
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
- );
10355
+ const ix = await (
10356
+ this.program.instruction as any
10357
+ ).cancelRequestRemoveInsuranceFundStake(marketIndex, {
10358
+ accounts: {
10359
+ state: await this.getStatePublicKey(),
10360
+ spotMarket: spotMarketAccount.pubkey,
10361
+ insuranceFundStake: ifStakeAccountPublicKey,
10362
+ userStats: getUserStatsAccountPublicKey(
10363
+ this.program.programId,
10364
+ this.wallet.publicKey // only allow payer to request remove own insurance fund stake account
10365
+ ),
10366
+ authority: this.wallet.publicKey,
10367
+ insuranceFundVault: spotMarketAccount.insuranceFund.vault,
10368
+ },
10369
+ });
10706
10370
 
10707
10371
  const tx = await this.buildTransaction(ix, txParams);
10708
10372
 
@@ -11069,14 +10733,10 @@ export class DriftClient {
11069
10733
  public getMarketFees(
11070
10734
  marketType: MarketType,
11071
10735
  marketIndex?: number,
11072
- user?: User,
11073
- enteringHighLeverageMode?: boolean
10736
+ user?: User
11074
10737
  ) {
11075
10738
  let feeTier;
11076
- const userHLM =
11077
- (user?.isHighLeverageMode('Initial') ?? false) ||
11078
- enteringHighLeverageMode;
11079
- if (user && !userHLM) {
10739
+ if (user) {
11080
10740
  feeTier = user.getUserFeeTier(marketType);
11081
10741
  } else {
11082
10742
  const state = this.getStateAccount();
@@ -11098,9 +10758,6 @@ export class DriftClient {
11098
10758
  }
11099
10759
 
11100
10760
  takerFee += (takerFee * marketAccount.feeAdjustment) / 100;
11101
- if (userHLM) {
11102
- takerFee *= 2;
11103
- }
11104
10761
  makerFee += (makerFee * marketAccount.feeAdjustment) / 100;
11105
10762
  }
11106
10763
 
@@ -11141,240 +10798,6 @@ export class DriftClient {
11141
10798
  return undefined;
11142
10799
  }
11143
10800
 
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
10801
  public async postPythLazerOracleUpdate(
11379
10802
  feedIds: number[],
11380
10803
  pythMessageHex: string
@@ -11426,282 +10849,13 @@ export class DriftClient {
11426
10849
  return [verifyIx, ix];
11427
10850
  }
11428
10851
 
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
10852
  public async fetchProtectedMakerModeConfig(): Promise<ProtectedMakerModeConfig> {
11701
- const config = await this.program.account.protectedMakerModeConfig.fetch(
10853
+ const config = await (
10854
+ this.program.account as any
10855
+ ).protectedMakerModeConfig.fetch(
11702
10856
  getProtectedMakerModeConfigPublicKey(this.program.programId)
11703
10857
  );
11704
- return config as ProtectedMakerModeConfig;
10858
+ return config as unknown as ProtectedMakerModeConfig;
11705
10859
  }
11706
10860
  public async updateUserProtectedMakerOrders(
11707
10861
  subAccountId: number,
@@ -11887,15 +11041,15 @@ export class DriftClient {
11887
11041
  }
11888
11042
 
11889
11043
  public async getLpPoolAccount(lpPoolId: number): Promise<LPPoolAccount> {
11890
- return (await this.program.account.lpPool.fetch(
11044
+ return (await (this.program.account as any).lpPool.fetch(
11891
11045
  getLpPoolPublicKey(this.program.programId, lpPoolId)
11892
- )) as LPPoolAccount;
11046
+ )) as unknown as LPPoolAccount;
11893
11047
  }
11894
11048
 
11895
11049
  public async getConstituentTargetBaseAccount(
11896
11050
  lpPoolId: number
11897
11051
  ): Promise<ConstituentTargetBaseAccount> {
11898
- return (await this.program.account.constituentTargetBase.fetch(
11052
+ return (await (this.program.account as any).constituentTargetBase.fetch(
11899
11053
  getConstituentTargetBasePublicKey(
11900
11054
  this.program.programId,
11901
11055
  getLpPoolPublicKey(this.program.programId, lpPoolId)
@@ -11904,7 +11058,7 @@ export class DriftClient {
11904
11058
  }
11905
11059
 
11906
11060
  public async getAmmCache(): Promise<AmmCache> {
11907
- return (await this.program.account.ammCache.fetch(
11061
+ return (await (this.program.account as any).ammCache.fetch(
11908
11062
  getAmmCachePublicKey(this.program.programId)
11909
11063
  )) as AmmCache;
11910
11064
  }