@drift-labs/sdk-browser 2.104.0-beta.21

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 (935) hide show
  1. package/README.md +276 -0
  2. package/VERSION +1 -0
  3. package/bun.lockb +0 -0
  4. package/get_events.ts +47 -0
  5. package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +27 -0
  6. package/lib/browser/accounts/basicUserAccountSubscriber.js +38 -0
  7. package/lib/browser/accounts/bulkAccountLoader.d.ts +37 -0
  8. package/lib/browser/accounts/bulkAccountLoader.js +222 -0
  9. package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +7 -0
  10. package/lib/browser/accounts/bulkUserStatsSubscription.js +21 -0
  11. package/lib/browser/accounts/bulkUserSubscription.d.ts +7 -0
  12. package/lib/browser/accounts/bulkUserSubscription.js +21 -0
  13. package/lib/browser/accounts/fetch.d.ts +6 -0
  14. package/lib/browser/accounts/fetch.js +30 -0
  15. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +16 -0
  16. package/lib/browser/accounts/grpcAccountSubscriber.js +154 -0
  17. package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
  18. package/lib/browser/accounts/grpcDriftClientAccountSubscriber.js +98 -0
  19. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
  20. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
  21. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
  22. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +171 -0
  23. package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +10 -0
  24. package/lib/browser/accounts/grpcUserAccountSubscriber.js +28 -0
  25. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
  26. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +28 -0
  27. package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
  28. package/lib/browser/accounts/oneShotUserAccountSubscriber.js +48 -0
  29. package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
  30. package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +418 -0
  31. package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
  32. package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
  33. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
  34. package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
  35. package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
  36. package/lib/browser/accounts/pollingOracleAccountSubscriber.js +78 -0
  37. package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
  38. package/lib/browser/accounts/pollingTokenAccountSubscriber.js +78 -0
  39. package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +29 -0
  40. package/lib/browser/accounts/pollingUserAccountSubscriber.js +102 -0
  41. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
  42. package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +94 -0
  43. package/lib/browser/accounts/testBulkAccountLoader.d.ts +4 -0
  44. package/lib/browser/accounts/testBulkAccountLoader.js +45 -0
  45. package/lib/browser/accounts/types.d.ts +168 -0
  46. package/lib/browser/accounts/types.js +16 -0
  47. package/lib/browser/accounts/utils.d.ts +8 -0
  48. package/lib/browser/accounts/utils.js +49 -0
  49. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +29 -0
  50. package/lib/browser/accounts/webSocketAccountSubscriber.js +149 -0
  51. package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
  52. package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +358 -0
  53. package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
  54. package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
  55. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
  56. package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
  57. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
  58. package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +120 -0
  59. package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
  60. package/lib/browser/accounts/webSocketUserAccountSubscriber.js +61 -0
  61. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
  62. package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
  63. package/lib/browser/addresses/marketAddresses.d.ts +2 -0
  64. package/lib/browser/addresses/marketAddresses.js +15 -0
  65. package/lib/browser/addresses/pda.d.ts +32 -0
  66. package/lib/browser/addresses/pda.js +211 -0
  67. package/lib/browser/adminClient.d.ts +206 -0
  68. package/lib/browser/adminClient.js +1858 -0
  69. package/lib/browser/assert/assert.d.ts +1 -0
  70. package/lib/browser/assert/assert.js +9 -0
  71. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +14 -0
  72. package/lib/browser/auctionSubscriber/auctionSubscriber.js +32 -0
  73. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
  74. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
  75. package/lib/browser/auctionSubscriber/index.d.ts +3 -0
  76. package/lib/browser/auctionSubscriber/index.js +19 -0
  77. package/lib/browser/auctionSubscriber/types.d.ts +14 -0
  78. package/lib/browser/auctionSubscriber/types.js +2 -0
  79. package/lib/browser/bankrun/bankrunConnection.d.ts +75 -0
  80. package/lib/browser/bankrun/bankrunConnection.js +332 -0
  81. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
  82. package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +89 -0
  83. package/lib/browser/blockhashSubscriber/index.d.ts +1 -0
  84. package/lib/browser/blockhashSubscriber/index.js +17 -0
  85. package/lib/browser/blockhashSubscriber/types.d.ts +7 -0
  86. package/lib/browser/blockhashSubscriber/types.js +2 -0
  87. package/lib/browser/clock/clockSubscriber.d.ts +31 -0
  88. package/lib/browser/clock/clockSubscriber.js +80 -0
  89. package/lib/browser/config.d.ts +60 -0
  90. package/lib/browser/config.js +130 -0
  91. package/lib/browser/constants/numericConstants.d.ts +71 -0
  92. package/lib/browser/constants/numericConstants.js +75 -0
  93. package/lib/browser/constants/perpMarkets.d.ts +19 -0
  94. package/lib/browser/constants/perpMarkets.js +997 -0
  95. package/lib/browser/constants/spotMarkets.d.ts +24 -0
  96. package/lib/browser/constants/spotMarkets.js +470 -0
  97. package/lib/browser/constants/txConstants.d.ts +1 -0
  98. package/lib/browser/constants/txConstants.js +4 -0
  99. package/lib/browser/decode/phoenix.d.ts +7 -0
  100. package/lib/browser/decode/phoenix.js +159 -0
  101. package/lib/browser/decode/user.d.ts +4 -0
  102. package/lib/browser/decode/user.js +339 -0
  103. package/lib/browser/dlob/DLOB.d.ts +186 -0
  104. package/lib/browser/dlob/DLOB.js +1039 -0
  105. package/lib/browser/dlob/DLOBNode.d.ts +68 -0
  106. package/lib/browser/dlob/DLOBNode.js +100 -0
  107. package/lib/browser/dlob/DLOBSubscriber.d.ts +54 -0
  108. package/lib/browser/dlob/DLOBSubscriber.js +139 -0
  109. package/lib/browser/dlob/NodeList.d.ts +25 -0
  110. package/lib/browser/dlob/NodeList.js +126 -0
  111. package/lib/browser/dlob/orderBookLevels.d.ts +72 -0
  112. package/lib/browser/dlob/orderBookLevels.js +438 -0
  113. package/lib/browser/dlob/types.d.ts +18 -0
  114. package/lib/browser/dlob/types.js +2 -0
  115. package/lib/browser/driftClient.d.ts +861 -0
  116. package/lib/browser/driftClient.js +4768 -0
  117. package/lib/browser/driftClientConfig.d.ts +49 -0
  118. package/lib/browser/driftClientConfig.js +2 -0
  119. package/lib/browser/events/eventList.d.ts +22 -0
  120. package/lib/browser/events/eventList.js +80 -0
  121. package/lib/browser/events/eventSubscriber.d.ts +46 -0
  122. package/lib/browser/events/eventSubscriber.js +223 -0
  123. package/lib/browser/events/eventsServerLogProvider.d.ts +21 -0
  124. package/lib/browser/events/eventsServerLogProvider.js +121 -0
  125. package/lib/browser/events/fetchLogs.d.ts +25 -0
  126. package/lib/browser/events/fetchLogs.js +99 -0
  127. package/lib/browser/events/parse.d.ts +6 -0
  128. package/lib/browser/events/parse.js +106 -0
  129. package/lib/browser/events/pollingLogProvider.d.ts +17 -0
  130. package/lib/browser/events/pollingLogProvider.js +58 -0
  131. package/lib/browser/events/sort.d.ts +2 -0
  132. package/lib/browser/events/sort.js +24 -0
  133. package/lib/browser/events/txEventCache.d.ts +24 -0
  134. package/lib/browser/events/txEventCache.js +71 -0
  135. package/lib/browser/events/types.d.ts +79 -0
  136. package/lib/browser/events/types.js +32 -0
  137. package/lib/browser/events/webSocketLogProvider.d.ts +24 -0
  138. package/lib/browser/events/webSocketLogProvider.js +96 -0
  139. package/lib/browser/factory/bigNum.d.ts +122 -0
  140. package/lib/browser/factory/bigNum.js +457 -0
  141. package/lib/browser/factory/oracleClient.d.ts +5 -0
  142. package/lib/browser/factory/oracleClient.js +56 -0
  143. package/lib/browser/idl/drift.json +14440 -0
  144. package/lib/browser/idl/openbook.json +3854 -0
  145. package/lib/browser/idl/pyth_solana_receiver.json +628 -0
  146. package/lib/browser/idl/switchboard.json +8354 -0
  147. package/lib/browser/idl/switchboard_on_demand_30.json +4546 -0
  148. package/lib/browser/idl/token_faucet.json +142 -0
  149. package/lib/browser/index.d.ts +125 -0
  150. package/lib/browser/index.js +147 -0
  151. package/lib/browser/isomorphic/grpc.browser.d.ts +1 -0
  152. package/lib/browser/isomorphic/grpc.browser.js +8 -0
  153. package/lib/browser/isomorphic/grpc.d.ts +1 -0
  154. package/lib/browser/isomorphic/grpc.js +8 -0
  155. package/lib/browser/jupiter/jupiterClient.d.ts +302 -0
  156. package/lib/browser/jupiter/jupiterClient.js +178 -0
  157. package/lib/browser/keypair.d.ts +2 -0
  158. package/lib/browser/keypair.js +28 -0
  159. package/lib/browser/marinade/index.d.ts +12 -0
  160. package/lib/browser/marinade/index.js +36 -0
  161. package/lib/browser/marinade/types.d.ts +1963 -0
  162. package/lib/browser/marinade/types.js +1965 -0
  163. package/lib/browser/math/amm.d.ts +98 -0
  164. package/lib/browser/math/amm.js +626 -0
  165. package/lib/browser/math/auction.d.ts +23 -0
  166. package/lib/browser/math/auction.js +130 -0
  167. package/lib/browser/math/bankruptcy.d.ts +2 -0
  168. package/lib/browser/math/bankruptcy.js +31 -0
  169. package/lib/browser/math/conversion.d.ts +2 -0
  170. package/lib/browser/math/conversion.js +11 -0
  171. package/lib/browser/math/exchangeStatus.d.ts +6 -0
  172. package/lib/browser/math/exchangeStatus.js +77 -0
  173. package/lib/browser/math/fuel.d.ts +6 -0
  174. package/lib/browser/math/fuel.js +55 -0
  175. package/lib/browser/math/funding.d.ts +34 -0
  176. package/lib/browser/math/funding.js +209 -0
  177. package/lib/browser/math/insurance.d.ts +7 -0
  178. package/lib/browser/math/insurance.js +73 -0
  179. package/lib/browser/math/margin.d.ts +39 -0
  180. package/lib/browser/math/margin.js +184 -0
  181. package/lib/browser/math/market.d.ts +39 -0
  182. package/lib/browser/math/market.js +163 -0
  183. package/lib/browser/math/oracles.d.ts +14 -0
  184. package/lib/browser/math/oracles.js +134 -0
  185. package/lib/browser/math/orders.d.ts +23 -0
  186. package/lib/browser/math/orders.js +216 -0
  187. package/lib/browser/math/position.d.ts +70 -0
  188. package/lib/browser/math/position.js +225 -0
  189. package/lib/browser/math/repeg.d.ts +22 -0
  190. package/lib/browser/math/repeg.js +164 -0
  191. package/lib/browser/math/spotBalance.d.ts +83 -0
  192. package/lib/browser/math/spotBalance.js +373 -0
  193. package/lib/browser/math/spotMarket.d.ts +11 -0
  194. package/lib/browser/math/spotMarket.js +49 -0
  195. package/lib/browser/math/spotPosition.d.ts +19 -0
  196. package/lib/browser/math/spotPosition.js +78 -0
  197. package/lib/browser/math/state.d.ts +5 -0
  198. package/lib/browser/math/state.js +30 -0
  199. package/lib/browser/math/superStake.d.ts +167 -0
  200. package/lib/browser/math/superStake.js +306 -0
  201. package/lib/browser/math/tiers.d.ts +4 -0
  202. package/lib/browser/math/tiers.js +52 -0
  203. package/lib/browser/math/trade.d.ts +117 -0
  204. package/lib/browser/math/trade.js +637 -0
  205. package/lib/browser/math/userStatus.d.ts +2 -0
  206. package/lib/browser/math/userStatus.js +8 -0
  207. package/lib/browser/math/utils.d.ts +23 -0
  208. package/lib/browser/math/utils.js +112 -0
  209. package/lib/browser/memcmp.d.ts +11 -0
  210. package/lib/browser/memcmp.js +99 -0
  211. package/lib/browser/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
  212. package/lib/browser/openbook/openbookV2FulfillmentConfigMap.js +17 -0
  213. package/lib/browser/openbook/openbookV2Subscriber.d.ts +36 -0
  214. package/lib/browser/openbook/openbookV2Subscriber.js +104 -0
  215. package/lib/browser/oracles/oracleClientCache.d.ts +9 -0
  216. package/lib/browser/oracles/oracleClientCache.js +19 -0
  217. package/lib/browser/oracles/oracleId.d.ts +4 -0
  218. package/lib/browser/oracles/oracleId.js +38 -0
  219. package/lib/browser/oracles/prelaunchOracleClient.d.ts +12 -0
  220. package/lib/browser/oracles/prelaunchOracleClient.js +24 -0
  221. package/lib/browser/oracles/pythClient.d.ts +14 -0
  222. package/lib/browser/oracles/pythClient.js +51 -0
  223. package/lib/browser/oracles/pythLazerClient.d.ts +16 -0
  224. package/lib/browser/oracles/pythLazerClient.js +61 -0
  225. package/lib/browser/oracles/pythPullClient.d.ts +19 -0
  226. package/lib/browser/oracles/pythPullClient.js +60 -0
  227. package/lib/browser/oracles/quoteAssetOracleClient.d.ts +10 -0
  228. package/lib/browser/oracles/quoteAssetOracleClient.js +21 -0
  229. package/lib/browser/oracles/strictOraclePrice.d.ts +9 -0
  230. package/lib/browser/oracles/strictOraclePrice.js +17 -0
  231. package/lib/browser/oracles/switchboardClient.d.ts +12 -0
  232. package/lib/browser/oracles/switchboardClient.js +40 -0
  233. package/lib/browser/oracles/switchboardOnDemandClient.d.ts +12 -0
  234. package/lib/browser/oracles/switchboardOnDemandClient.js +32 -0
  235. package/lib/browser/oracles/types.d.ts +23 -0
  236. package/lib/browser/oracles/types.js +2 -0
  237. package/lib/browser/orderParams.d.ts +29 -0
  238. package/lib/browser/orderParams.js +44 -0
  239. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +42 -0
  240. package/lib/browser/orderSubscriber/OrderSubscriber.js +172 -0
  241. package/lib/browser/orderSubscriber/PollingSubscription.d.ts +12 -0
  242. package/lib/browser/orderSubscriber/PollingSubscription.js +23 -0
  243. package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +23 -0
  244. package/lib/browser/orderSubscriber/WebsocketSubscription.js +67 -0
  245. package/lib/browser/orderSubscriber/grpcSubscription.d.ts +22 -0
  246. package/lib/browser/orderSubscriber/grpcSubscription.js +66 -0
  247. package/lib/browser/orderSubscriber/index.d.ts +2 -0
  248. package/lib/browser/orderSubscriber/index.js +18 -0
  249. package/lib/browser/orderSubscriber/types.d.ts +34 -0
  250. package/lib/browser/orderSubscriber/types.js +2 -0
  251. package/lib/browser/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
  252. package/lib/browser/phoenix/phoenixFulfillmentConfigMap.js +17 -0
  253. package/lib/browser/phoenix/phoenixSubscriber.d.ts +41 -0
  254. package/lib/browser/phoenix/phoenixSubscriber.js +152 -0
  255. package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
  256. package/lib/browser/priorityFee/averageOverSlotsStrategy.js +16 -0
  257. package/lib/browser/priorityFee/averageStrategy.d.ts +5 -0
  258. package/lib/browser/priorityFee/averageStrategy.js +11 -0
  259. package/lib/browser/priorityFee/driftPriorityFeeMethod.d.ts +13 -0
  260. package/lib/browser/priorityFee/driftPriorityFeeMethod.js +26 -0
  261. package/lib/browser/priorityFee/ewmaStrategy.d.ts +11 -0
  262. package/lib/browser/priorityFee/ewmaStrategy.js +33 -0
  263. package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
  264. package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +46 -0
  265. package/lib/browser/priorityFee/index.d.ts +11 -0
  266. package/lib/browser/priorityFee/index.js +27 -0
  267. package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
  268. package/lib/browser/priorityFee/maxOverSlotsStrategy.js +17 -0
  269. package/lib/browser/priorityFee/maxStrategy.d.ts +7 -0
  270. package/lib/browser/priorityFee/maxStrategy.js +9 -0
  271. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +46 -0
  272. package/lib/browser/priorityFee/priorityFeeSubscriber.js +188 -0
  273. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
  274. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +88 -0
  275. package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
  276. package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +21 -0
  277. package/lib/browser/priorityFee/types.d.ts +31 -0
  278. package/lib/browser/priorityFee/types.js +10 -0
  279. package/lib/browser/serum/serumFulfillmentConfigMap.d.ts +10 -0
  280. package/lib/browser/serum/serumFulfillmentConfigMap.js +17 -0
  281. package/lib/browser/serum/serumSubscriber.d.ts +32 -0
  282. package/lib/browser/serum/serumSubscriber.js +107 -0
  283. package/lib/browser/serum/types.d.ts +13 -0
  284. package/lib/browser/serum/types.js +2 -0
  285. package/lib/browser/slot/SlotSubscriber.d.ts +27 -0
  286. package/lib/browser/slot/SlotSubscriber.js +71 -0
  287. package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
  288. package/lib/browser/slot/SlothashSubscriber.js +85 -0
  289. package/lib/browser/testClient.d.ts +8 -0
  290. package/lib/browser/testClient.js +23 -0
  291. package/lib/browser/token/index.d.ts +5 -0
  292. package/lib/browser/token/index.js +15 -0
  293. package/lib/browser/tokenFaucet.d.ts +41 -0
  294. package/lib/browser/tokenFaucet.js +188 -0
  295. package/lib/browser/tx/baseTxSender.d.ts +59 -0
  296. package/lib/browser/tx/baseTxSender.js +294 -0
  297. package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
  298. package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
  299. package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
  300. package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
  301. package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
  302. package/lib/browser/tx/blockhashFetcher/types.js +2 -0
  303. package/lib/browser/tx/fastSingleTxSender.d.ts +41 -0
  304. package/lib/browser/tx/fastSingleTxSender.js +86 -0
  305. package/lib/browser/tx/forwardOnlyTxSender.d.ts +37 -0
  306. package/lib/browser/tx/forwardOnlyTxSender.js +92 -0
  307. package/lib/browser/tx/priorityFeeCalculator.d.ts +44 -0
  308. package/lib/browser/tx/priorityFeeCalculator.js +85 -0
  309. package/lib/browser/tx/reportTransactionError.d.ts +20 -0
  310. package/lib/browser/tx/reportTransactionError.js +103 -0
  311. package/lib/browser/tx/retryTxSender.d.ts +37 -0
  312. package/lib/browser/tx/retryTxSender.js +86 -0
  313. package/lib/browser/tx/txHandler.d.ts +154 -0
  314. package/lib/browser/tx/txHandler.js +453 -0
  315. package/lib/browser/tx/txParamProcessor.d.ts +25 -0
  316. package/lib/browser/tx/txParamProcessor.js +88 -0
  317. package/lib/browser/tx/types.d.ts +29 -0
  318. package/lib/browser/tx/types.js +20 -0
  319. package/lib/browser/tx/utils.d.ts +2 -0
  320. package/lib/browser/tx/utils.js +10 -0
  321. package/lib/browser/tx/whileValidTxSender.d.ts +45 -0
  322. package/lib/browser/tx/whileValidTxSender.js +167 -0
  323. package/lib/browser/types.d.ts +1385 -0
  324. package/lib/browser/types.js +366 -0
  325. package/lib/browser/user.d.ts +411 -0
  326. package/lib/browser/user.js +2151 -0
  327. package/lib/browser/userConfig.d.ts +26 -0
  328. package/lib/browser/userConfig.js +2 -0
  329. package/lib/browser/userMap/PollingSubscription.d.ts +16 -0
  330. package/lib/browser/userMap/PollingSubscription.js +30 -0
  331. package/lib/browser/userMap/WebsocketSubscription.d.ts +27 -0
  332. package/lib/browser/userMap/WebsocketSubscription.js +45 -0
  333. package/lib/browser/userMap/grpcSubscription.d.ts +27 -0
  334. package/lib/browser/userMap/grpcSubscription.js +44 -0
  335. package/lib/browser/userMap/referrerMap.d.ts +45 -0
  336. package/lib/browser/userMap/referrerMap.js +181 -0
  337. package/lib/browser/userMap/userMap.d.ts +90 -0
  338. package/lib/browser/userMap/userMap.js +467 -0
  339. package/lib/browser/userMap/userMapConfig.d.ts +39 -0
  340. package/lib/browser/userMap/userMapConfig.js +2 -0
  341. package/lib/browser/userMap/userStatsMap.d.ts +46 -0
  342. package/lib/browser/userMap/userStatsMap.js +165 -0
  343. package/lib/browser/userName.d.ts +5 -0
  344. package/lib/browser/userName.js +21 -0
  345. package/lib/browser/userStats.d.ts +22 -0
  346. package/lib/browser/userStats.js +91 -0
  347. package/lib/browser/userStatsConfig.d.ts +25 -0
  348. package/lib/browser/userStatsConfig.js +2 -0
  349. package/lib/browser/util/TransactionConfirmationManager.d.ts +16 -0
  350. package/lib/browser/util/TransactionConfirmationManager.js +174 -0
  351. package/lib/browser/util/chainClock.d.ts +17 -0
  352. package/lib/browser/util/chainClock.js +29 -0
  353. package/lib/browser/util/computeUnits.d.ts +8 -0
  354. package/lib/browser/util/computeUnits.js +48 -0
  355. package/lib/browser/util/digest.d.ts +4 -0
  356. package/lib/browser/util/digest.js +14 -0
  357. package/lib/browser/util/promiseTimeout.d.ts +1 -0
  358. package/lib/browser/util/promiseTimeout.js +14 -0
  359. package/lib/browser/util/pythOracleUtils.d.ts +17 -0
  360. package/lib/browser/util/pythOracleUtils.js +107 -0
  361. package/lib/browser/util/tps.d.ts +2 -0
  362. package/lib/browser/util/tps.js +16 -0
  363. package/lib/browser/wallet.d.ts +11 -0
  364. package/lib/browser/wallet.js +32 -0
  365. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +27 -0
  366. package/lib/node/accounts/basicUserAccountSubscriber.js +38 -0
  367. package/lib/node/accounts/bulkAccountLoader.d.ts +37 -0
  368. package/lib/node/accounts/bulkAccountLoader.js +222 -0
  369. package/lib/node/accounts/bulkUserStatsSubscription.d.ts +7 -0
  370. package/lib/node/accounts/bulkUserStatsSubscription.js +21 -0
  371. package/lib/node/accounts/bulkUserSubscription.d.ts +7 -0
  372. package/lib/node/accounts/bulkUserSubscription.js +21 -0
  373. package/lib/node/accounts/fetch.d.ts +6 -0
  374. package/lib/node/accounts/fetch.js +30 -0
  375. package/lib/node/accounts/grpcAccountSubscriber.d.ts +16 -0
  376. package/lib/node/accounts/grpcAccountSubscriber.js +154 -0
  377. package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
  378. package/lib/node/accounts/grpcDriftClientAccountSubscriber.js +98 -0
  379. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
  380. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
  381. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
  382. package/lib/node/accounts/grpcProgramAccountSubscriber.js +171 -0
  383. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +10 -0
  384. package/lib/node/accounts/grpcUserAccountSubscriber.js +28 -0
  385. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
  386. package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +28 -0
  387. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
  388. package/lib/node/accounts/oneShotUserAccountSubscriber.js +48 -0
  389. package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
  390. package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +418 -0
  391. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
  392. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
  393. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
  394. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
  395. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
  396. package/lib/node/accounts/pollingOracleAccountSubscriber.js +78 -0
  397. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
  398. package/lib/node/accounts/pollingTokenAccountSubscriber.js +78 -0
  399. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +29 -0
  400. package/lib/node/accounts/pollingUserAccountSubscriber.js +102 -0
  401. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
  402. package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +94 -0
  403. package/lib/node/accounts/testBulkAccountLoader.d.ts +4 -0
  404. package/lib/node/accounts/testBulkAccountLoader.js +45 -0
  405. package/lib/node/accounts/types.d.ts +168 -0
  406. package/lib/node/accounts/types.js +16 -0
  407. package/lib/node/accounts/utils.d.ts +8 -0
  408. package/lib/node/accounts/utils.js +49 -0
  409. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +29 -0
  410. package/lib/node/accounts/webSocketAccountSubscriber.js +149 -0
  411. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
  412. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +358 -0
  413. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
  414. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
  415. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
  416. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
  417. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
  418. package/lib/node/accounts/webSocketProgramAccountSubscriber.js +120 -0
  419. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
  420. package/lib/node/accounts/webSocketUserAccountSubscriber.js +61 -0
  421. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
  422. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
  423. package/lib/node/addresses/marketAddresses.d.ts +2 -0
  424. package/lib/node/addresses/marketAddresses.js +15 -0
  425. package/lib/node/addresses/pda.d.ts +32 -0
  426. package/lib/node/addresses/pda.js +211 -0
  427. package/lib/node/adminClient.d.ts +206 -0
  428. package/lib/node/adminClient.js +1858 -0
  429. package/lib/node/assert/assert.d.ts +1 -0
  430. package/lib/node/assert/assert.js +9 -0
  431. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +14 -0
  432. package/lib/node/auctionSubscriber/auctionSubscriber.js +32 -0
  433. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
  434. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
  435. package/lib/node/auctionSubscriber/index.d.ts +3 -0
  436. package/lib/node/auctionSubscriber/index.js +19 -0
  437. package/lib/node/auctionSubscriber/types.d.ts +14 -0
  438. package/lib/node/auctionSubscriber/types.js +2 -0
  439. package/lib/node/bankrun/bankrunConnection.d.ts +75 -0
  440. package/lib/node/bankrun/bankrunConnection.js +332 -0
  441. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
  442. package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +89 -0
  443. package/lib/node/blockhashSubscriber/index.d.ts +1 -0
  444. package/lib/node/blockhashSubscriber/index.js +17 -0
  445. package/lib/node/blockhashSubscriber/types.d.ts +7 -0
  446. package/lib/node/blockhashSubscriber/types.js +2 -0
  447. package/lib/node/clock/clockSubscriber.d.ts +31 -0
  448. package/lib/node/clock/clockSubscriber.js +80 -0
  449. package/lib/node/config.d.ts +60 -0
  450. package/lib/node/config.js +130 -0
  451. package/lib/node/constants/numericConstants.d.ts +71 -0
  452. package/lib/node/constants/numericConstants.js +75 -0
  453. package/lib/node/constants/perpMarkets.d.ts +19 -0
  454. package/lib/node/constants/perpMarkets.js +997 -0
  455. package/lib/node/constants/spotMarkets.d.ts +24 -0
  456. package/lib/node/constants/spotMarkets.js +470 -0
  457. package/lib/node/constants/txConstants.d.ts +1 -0
  458. package/lib/node/constants/txConstants.js +4 -0
  459. package/lib/node/decode/phoenix.d.ts +7 -0
  460. package/lib/node/decode/phoenix.js +159 -0
  461. package/lib/node/decode/user.d.ts +4 -0
  462. package/lib/node/decode/user.js +339 -0
  463. package/lib/node/dlob/DLOB.d.ts +186 -0
  464. package/lib/node/dlob/DLOB.js +1039 -0
  465. package/lib/node/dlob/DLOBNode.d.ts +68 -0
  466. package/lib/node/dlob/DLOBNode.js +100 -0
  467. package/lib/node/dlob/DLOBSubscriber.d.ts +54 -0
  468. package/lib/node/dlob/DLOBSubscriber.js +139 -0
  469. package/lib/node/dlob/NodeList.d.ts +25 -0
  470. package/lib/node/dlob/NodeList.js +126 -0
  471. package/lib/node/dlob/orderBookLevels.d.ts +72 -0
  472. package/lib/node/dlob/orderBookLevels.js +438 -0
  473. package/lib/node/dlob/types.d.ts +18 -0
  474. package/lib/node/dlob/types.js +2 -0
  475. package/lib/node/driftClient.d.ts +861 -0
  476. package/lib/node/driftClient.js +4768 -0
  477. package/lib/node/driftClientConfig.d.ts +49 -0
  478. package/lib/node/driftClientConfig.js +2 -0
  479. package/lib/node/events/eventList.d.ts +22 -0
  480. package/lib/node/events/eventList.js +80 -0
  481. package/lib/node/events/eventSubscriber.d.ts +46 -0
  482. package/lib/node/events/eventSubscriber.js +223 -0
  483. package/lib/node/events/eventsServerLogProvider.d.ts +21 -0
  484. package/lib/node/events/eventsServerLogProvider.js +121 -0
  485. package/lib/node/events/fetchLogs.d.ts +25 -0
  486. package/lib/node/events/fetchLogs.js +99 -0
  487. package/lib/node/events/parse.d.ts +6 -0
  488. package/lib/node/events/parse.js +106 -0
  489. package/lib/node/events/pollingLogProvider.d.ts +17 -0
  490. package/lib/node/events/pollingLogProvider.js +58 -0
  491. package/lib/node/events/sort.d.ts +2 -0
  492. package/lib/node/events/sort.js +24 -0
  493. package/lib/node/events/txEventCache.d.ts +24 -0
  494. package/lib/node/events/txEventCache.js +71 -0
  495. package/lib/node/events/types.d.ts +79 -0
  496. package/lib/node/events/types.js +32 -0
  497. package/lib/node/events/webSocketLogProvider.d.ts +24 -0
  498. package/lib/node/events/webSocketLogProvider.js +96 -0
  499. package/lib/node/factory/bigNum.d.ts +122 -0
  500. package/lib/node/factory/bigNum.js +457 -0
  501. package/lib/node/factory/oracleClient.d.ts +5 -0
  502. package/lib/node/factory/oracleClient.js +56 -0
  503. package/lib/node/idl/drift.json +14440 -0
  504. package/lib/node/idl/openbook.json +3854 -0
  505. package/lib/node/idl/pyth_solana_receiver.json +628 -0
  506. package/lib/node/idl/switchboard.json +8354 -0
  507. package/lib/node/idl/switchboard_on_demand_30.json +4546 -0
  508. package/lib/node/idl/token_faucet.json +142 -0
  509. package/lib/node/index.d.ts +125 -0
  510. package/lib/node/index.js +147 -0
  511. package/lib/node/isomorphic/grpc.browser.d.ts +1 -0
  512. package/lib/node/isomorphic/grpc.browser.js +8 -0
  513. package/lib/node/isomorphic/grpc.d.ts +1 -0
  514. package/lib/node/isomorphic/grpc.js +8 -0
  515. package/lib/node/jupiter/jupiterClient.d.ts +302 -0
  516. package/lib/node/jupiter/jupiterClient.js +178 -0
  517. package/lib/node/keypair.d.ts +2 -0
  518. package/lib/node/keypair.js +28 -0
  519. package/lib/node/marinade/index.d.ts +12 -0
  520. package/lib/node/marinade/index.js +36 -0
  521. package/lib/node/marinade/types.d.ts +1963 -0
  522. package/lib/node/marinade/types.js +1965 -0
  523. package/lib/node/math/amm.d.ts +98 -0
  524. package/lib/node/math/amm.js +626 -0
  525. package/lib/node/math/auction.d.ts +23 -0
  526. package/lib/node/math/auction.js +130 -0
  527. package/lib/node/math/bankruptcy.d.ts +2 -0
  528. package/lib/node/math/bankruptcy.js +31 -0
  529. package/lib/node/math/conversion.d.ts +2 -0
  530. package/lib/node/math/conversion.js +11 -0
  531. package/lib/node/math/exchangeStatus.d.ts +6 -0
  532. package/lib/node/math/exchangeStatus.js +77 -0
  533. package/lib/node/math/fuel.d.ts +6 -0
  534. package/lib/node/math/fuel.js +55 -0
  535. package/lib/node/math/funding.d.ts +34 -0
  536. package/lib/node/math/funding.js +209 -0
  537. package/lib/node/math/insurance.d.ts +7 -0
  538. package/lib/node/math/insurance.js +73 -0
  539. package/lib/node/math/margin.d.ts +39 -0
  540. package/lib/node/math/margin.js +184 -0
  541. package/lib/node/math/market.d.ts +39 -0
  542. package/lib/node/math/market.js +163 -0
  543. package/lib/node/math/oracles.d.ts +14 -0
  544. package/lib/node/math/oracles.js +134 -0
  545. package/lib/node/math/orders.d.ts +23 -0
  546. package/lib/node/math/orders.js +216 -0
  547. package/lib/node/math/position.d.ts +70 -0
  548. package/lib/node/math/position.js +225 -0
  549. package/lib/node/math/repeg.d.ts +22 -0
  550. package/lib/node/math/repeg.js +164 -0
  551. package/lib/node/math/spotBalance.d.ts +83 -0
  552. package/lib/node/math/spotBalance.js +373 -0
  553. package/lib/node/math/spotMarket.d.ts +11 -0
  554. package/lib/node/math/spotMarket.js +49 -0
  555. package/lib/node/math/spotPosition.d.ts +19 -0
  556. package/lib/node/math/spotPosition.js +78 -0
  557. package/lib/node/math/state.d.ts +5 -0
  558. package/lib/node/math/state.js +30 -0
  559. package/lib/node/math/superStake.d.ts +167 -0
  560. package/lib/node/math/superStake.js +306 -0
  561. package/lib/node/math/tiers.d.ts +4 -0
  562. package/lib/node/math/tiers.js +52 -0
  563. package/lib/node/math/trade.d.ts +117 -0
  564. package/lib/node/math/trade.js +637 -0
  565. package/lib/node/math/userStatus.d.ts +2 -0
  566. package/lib/node/math/userStatus.js +8 -0
  567. package/lib/node/math/utils.d.ts +23 -0
  568. package/lib/node/math/utils.js +112 -0
  569. package/lib/node/memcmp.d.ts +11 -0
  570. package/lib/node/memcmp.js +99 -0
  571. package/lib/node/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
  572. package/lib/node/openbook/openbookV2FulfillmentConfigMap.js +17 -0
  573. package/lib/node/openbook/openbookV2Subscriber.d.ts +36 -0
  574. package/lib/node/openbook/openbookV2Subscriber.js +104 -0
  575. package/lib/node/oracles/oracleClientCache.d.ts +9 -0
  576. package/lib/node/oracles/oracleClientCache.js +19 -0
  577. package/lib/node/oracles/oracleId.d.ts +4 -0
  578. package/lib/node/oracles/oracleId.js +38 -0
  579. package/lib/node/oracles/prelaunchOracleClient.d.ts +12 -0
  580. package/lib/node/oracles/prelaunchOracleClient.js +24 -0
  581. package/lib/node/oracles/pythClient.d.ts +14 -0
  582. package/lib/node/oracles/pythClient.js +51 -0
  583. package/lib/node/oracles/pythLazerClient.d.ts +16 -0
  584. package/lib/node/oracles/pythLazerClient.js +61 -0
  585. package/lib/node/oracles/pythPullClient.d.ts +19 -0
  586. package/lib/node/oracles/pythPullClient.js +60 -0
  587. package/lib/node/oracles/quoteAssetOracleClient.d.ts +10 -0
  588. package/lib/node/oracles/quoteAssetOracleClient.js +21 -0
  589. package/lib/node/oracles/strictOraclePrice.d.ts +9 -0
  590. package/lib/node/oracles/strictOraclePrice.js +17 -0
  591. package/lib/node/oracles/switchboardClient.d.ts +12 -0
  592. package/lib/node/oracles/switchboardClient.js +40 -0
  593. package/lib/node/oracles/switchboardOnDemandClient.d.ts +12 -0
  594. package/lib/node/oracles/switchboardOnDemandClient.js +32 -0
  595. package/lib/node/oracles/types.d.ts +23 -0
  596. package/lib/node/oracles/types.js +2 -0
  597. package/lib/node/orderParams.d.ts +29 -0
  598. package/lib/node/orderParams.js +44 -0
  599. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +42 -0
  600. package/lib/node/orderSubscriber/OrderSubscriber.js +172 -0
  601. package/lib/node/orderSubscriber/PollingSubscription.d.ts +12 -0
  602. package/lib/node/orderSubscriber/PollingSubscription.js +23 -0
  603. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +23 -0
  604. package/lib/node/orderSubscriber/WebsocketSubscription.js +67 -0
  605. package/lib/node/orderSubscriber/grpcSubscription.d.ts +22 -0
  606. package/lib/node/orderSubscriber/grpcSubscription.js +66 -0
  607. package/lib/node/orderSubscriber/index.d.ts +2 -0
  608. package/lib/node/orderSubscriber/index.js +18 -0
  609. package/lib/node/orderSubscriber/types.d.ts +34 -0
  610. package/lib/node/orderSubscriber/types.js +2 -0
  611. package/lib/node/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
  612. package/lib/node/phoenix/phoenixFulfillmentConfigMap.js +17 -0
  613. package/lib/node/phoenix/phoenixSubscriber.d.ts +41 -0
  614. package/lib/node/phoenix/phoenixSubscriber.js +152 -0
  615. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
  616. package/lib/node/priorityFee/averageOverSlotsStrategy.js +16 -0
  617. package/lib/node/priorityFee/averageStrategy.d.ts +5 -0
  618. package/lib/node/priorityFee/averageStrategy.js +11 -0
  619. package/lib/node/priorityFee/driftPriorityFeeMethod.d.ts +13 -0
  620. package/lib/node/priorityFee/driftPriorityFeeMethod.js +26 -0
  621. package/lib/node/priorityFee/ewmaStrategy.d.ts +11 -0
  622. package/lib/node/priorityFee/ewmaStrategy.js +33 -0
  623. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
  624. package/lib/node/priorityFee/heliusPriorityFeeMethod.js +46 -0
  625. package/lib/node/priorityFee/index.d.ts +11 -0
  626. package/lib/node/priorityFee/index.js +27 -0
  627. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
  628. package/lib/node/priorityFee/maxOverSlotsStrategy.js +17 -0
  629. package/lib/node/priorityFee/maxStrategy.d.ts +7 -0
  630. package/lib/node/priorityFee/maxStrategy.js +9 -0
  631. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +46 -0
  632. package/lib/node/priorityFee/priorityFeeSubscriber.js +188 -0
  633. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
  634. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +88 -0
  635. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
  636. package/lib/node/priorityFee/solanaPriorityFeeMethod.js +21 -0
  637. package/lib/node/priorityFee/types.d.ts +31 -0
  638. package/lib/node/priorityFee/types.js +10 -0
  639. package/lib/node/serum/serumFulfillmentConfigMap.d.ts +10 -0
  640. package/lib/node/serum/serumFulfillmentConfigMap.js +17 -0
  641. package/lib/node/serum/serumSubscriber.d.ts +32 -0
  642. package/lib/node/serum/serumSubscriber.js +107 -0
  643. package/lib/node/serum/types.d.ts +13 -0
  644. package/lib/node/serum/types.js +2 -0
  645. package/lib/node/slot/SlotSubscriber.d.ts +27 -0
  646. package/lib/node/slot/SlotSubscriber.js +71 -0
  647. package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
  648. package/lib/node/slot/SlothashSubscriber.js +85 -0
  649. package/lib/node/testClient.d.ts +8 -0
  650. package/lib/node/testClient.js +23 -0
  651. package/lib/node/token/index.d.ts +5 -0
  652. package/lib/node/token/index.js +15 -0
  653. package/lib/node/tokenFaucet.d.ts +41 -0
  654. package/lib/node/tokenFaucet.js +188 -0
  655. package/lib/node/tx/baseTxSender.d.ts +59 -0
  656. package/lib/node/tx/baseTxSender.js +294 -0
  657. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
  658. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
  659. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
  660. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
  661. package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
  662. package/lib/node/tx/blockhashFetcher/types.js +2 -0
  663. package/lib/node/tx/fastSingleTxSender.d.ts +41 -0
  664. package/lib/node/tx/fastSingleTxSender.js +86 -0
  665. package/lib/node/tx/forwardOnlyTxSender.d.ts +37 -0
  666. package/lib/node/tx/forwardOnlyTxSender.js +92 -0
  667. package/lib/node/tx/priorityFeeCalculator.d.ts +44 -0
  668. package/lib/node/tx/priorityFeeCalculator.js +85 -0
  669. package/lib/node/tx/reportTransactionError.d.ts +20 -0
  670. package/lib/node/tx/reportTransactionError.js +103 -0
  671. package/lib/node/tx/retryTxSender.d.ts +37 -0
  672. package/lib/node/tx/retryTxSender.js +86 -0
  673. package/lib/node/tx/txHandler.d.ts +154 -0
  674. package/lib/node/tx/txHandler.js +453 -0
  675. package/lib/node/tx/txParamProcessor.d.ts +25 -0
  676. package/lib/node/tx/txParamProcessor.js +88 -0
  677. package/lib/node/tx/types.d.ts +29 -0
  678. package/lib/node/tx/types.js +20 -0
  679. package/lib/node/tx/utils.d.ts +2 -0
  680. package/lib/node/tx/utils.js +10 -0
  681. package/lib/node/tx/whileValidTxSender.d.ts +45 -0
  682. package/lib/node/tx/whileValidTxSender.js +167 -0
  683. package/lib/node/types.d.ts +1385 -0
  684. package/lib/node/types.js +366 -0
  685. package/lib/node/user.d.ts +411 -0
  686. package/lib/node/user.js +2151 -0
  687. package/lib/node/userConfig.d.ts +26 -0
  688. package/lib/node/userConfig.js +2 -0
  689. package/lib/node/userMap/PollingSubscription.d.ts +16 -0
  690. package/lib/node/userMap/PollingSubscription.js +30 -0
  691. package/lib/node/userMap/WebsocketSubscription.d.ts +27 -0
  692. package/lib/node/userMap/WebsocketSubscription.js +45 -0
  693. package/lib/node/userMap/grpcSubscription.d.ts +27 -0
  694. package/lib/node/userMap/grpcSubscription.js +44 -0
  695. package/lib/node/userMap/referrerMap.d.ts +45 -0
  696. package/lib/node/userMap/referrerMap.js +181 -0
  697. package/lib/node/userMap/userMap.d.ts +90 -0
  698. package/lib/node/userMap/userMap.js +467 -0
  699. package/lib/node/userMap/userMapConfig.d.ts +39 -0
  700. package/lib/node/userMap/userMapConfig.js +2 -0
  701. package/lib/node/userMap/userStatsMap.d.ts +46 -0
  702. package/lib/node/userMap/userStatsMap.js +165 -0
  703. package/lib/node/userName.d.ts +5 -0
  704. package/lib/node/userName.js +21 -0
  705. package/lib/node/userStats.d.ts +22 -0
  706. package/lib/node/userStats.js +91 -0
  707. package/lib/node/userStatsConfig.d.ts +25 -0
  708. package/lib/node/userStatsConfig.js +2 -0
  709. package/lib/node/util/TransactionConfirmationManager.d.ts +16 -0
  710. package/lib/node/util/TransactionConfirmationManager.js +174 -0
  711. package/lib/node/util/chainClock.d.ts +17 -0
  712. package/lib/node/util/chainClock.js +29 -0
  713. package/lib/node/util/computeUnits.d.ts +8 -0
  714. package/lib/node/util/computeUnits.js +48 -0
  715. package/lib/node/util/digest.d.ts +4 -0
  716. package/lib/node/util/digest.js +14 -0
  717. package/lib/node/util/promiseTimeout.d.ts +1 -0
  718. package/lib/node/util/promiseTimeout.js +14 -0
  719. package/lib/node/util/pythOracleUtils.d.ts +17 -0
  720. package/lib/node/util/pythOracleUtils.js +107 -0
  721. package/lib/node/util/tps.d.ts +2 -0
  722. package/lib/node/util/tps.js +16 -0
  723. package/lib/node/wallet.d.ts +11 -0
  724. package/lib/node/wallet.js +32 -0
  725. package/package.json +92 -0
  726. package/scripts/postbuild.js +95 -0
  727. package/scripts/updateVersion.js +28 -0
  728. package/src/accounts/basicUserAccountSubscriber.ts +59 -0
  729. package/src/accounts/bulkAccountLoader.ts +294 -0
  730. package/src/accounts/bulkUserStatsSubscription.ts +33 -0
  731. package/src/accounts/bulkUserSubscription.ts +33 -0
  732. package/src/accounts/fetch.ts +66 -0
  733. package/src/accounts/grpcAccountSubscriber.ts +160 -0
  734. package/src/accounts/grpcDriftClientAccountSubscriber.ts +203 -0
  735. package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +56 -0
  736. package/src/accounts/grpcProgramAccountSubscriber.ts +190 -0
  737. package/src/accounts/grpcUserAccountSubscriber.ts +48 -0
  738. package/src/accounts/grpcUserStatsAccountSubscriber.ts +50 -0
  739. package/src/accounts/oneShotUserAccountSubscriber.ts +68 -0
  740. package/src/accounts/pollingDriftClientAccountSubscriber.ts +644 -0
  741. package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +189 -0
  742. package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +185 -0
  743. package/src/accounts/pollingOracleAccountSubscriber.ts +125 -0
  744. package/src/accounts/pollingTokenAccountSubscriber.ts +118 -0
  745. package/src/accounts/pollingUserAccountSubscriber.ts +160 -0
  746. package/src/accounts/pollingUserStatsAccountSubscriber.ts +156 -0
  747. package/src/accounts/testBulkAccountLoader.ts +53 -0
  748. package/src/accounts/types.ts +245 -0
  749. package/src/accounts/utils.ts +62 -0
  750. package/src/accounts/webSocketAccountSubscriber.ts +205 -0
  751. package/src/accounts/webSocketDriftClientAccountSubscriber.ts +621 -0
  752. package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +131 -0
  753. package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +129 -0
  754. package/src/accounts/webSocketProgramAccountSubscriber.ts +182 -0
  755. package/src/accounts/webSocketUserAccountSubscriber.ts +104 -0
  756. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +98 -0
  757. package/src/addresses/marketAddresses.ts +17 -0
  758. package/src/addresses/pda.ts +355 -0
  759. package/src/adminClient.ts +4030 -0
  760. package/src/assert/assert.ts +5 -0
  761. package/src/auctionSubscriber/auctionSubscriber.ts +66 -0
  762. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +70 -0
  763. package/src/auctionSubscriber/index.ts +3 -0
  764. package/src/auctionSubscriber/types.ts +20 -0
  765. package/src/bankrun/bankrunConnection.ts +534 -0
  766. package/src/blockhashSubscriber/BlockhashSubscriber.ts +126 -0
  767. package/src/blockhashSubscriber/index.ts +1 -0
  768. package/src/blockhashSubscriber/types.ts +12 -0
  769. package/src/clock/clockSubscriber.ts +121 -0
  770. package/src/config.ts +212 -0
  771. package/src/constants/numericConstants.ts +113 -0
  772. package/src/constants/perpMarkets.ts +1084 -0
  773. package/src/constants/spotMarkets.ts +565 -0
  774. package/src/constants/txConstants.ts +1 -0
  775. package/src/decode/phoenix.ts +207 -0
  776. package/src/decode/user.ts +368 -0
  777. package/src/dlob/DLOB.ts +1897 -0
  778. package/src/dlob/DLOBNode.ts +197 -0
  779. package/src/dlob/DLOBSubscriber.ts +201 -0
  780. package/src/dlob/NodeList.ts +173 -0
  781. package/src/dlob/orderBookLevels.ts +643 -0
  782. package/src/dlob/types.ts +22 -0
  783. package/src/driftClient.ts +9032 -0
  784. package/src/driftClientConfig.ts +60 -0
  785. package/src/events/eventList.ts +97 -0
  786. package/src/events/eventSubscriber.ts +364 -0
  787. package/src/events/eventsServerLogProvider.ts +152 -0
  788. package/src/events/fetchLogs.ts +169 -0
  789. package/src/events/parse.ts +133 -0
  790. package/src/events/pollingLogProvider.ts +89 -0
  791. package/src/events/sort.ts +39 -0
  792. package/src/events/txEventCache.ts +74 -0
  793. package/src/events/types.ts +185 -0
  794. package/src/events/webSocketLogProvider.ts +121 -0
  795. package/src/factory/bigNum.ts +660 -0
  796. package/src/factory/oracleClient.ts +72 -0
  797. package/src/idl/drift.json +14440 -0
  798. package/src/idl/openbook.json +3854 -0
  799. package/src/idl/pyth.json +142 -0
  800. package/src/idl/pyth_solana_receiver.json +628 -0
  801. package/src/idl/switchboard.json +8354 -0
  802. package/src/idl/switchboard_on_demand_30.json +4546 -0
  803. package/src/idl/token_faucet.json +142 -0
  804. package/src/index.ts +127 -0
  805. package/src/isomorphic/README.md +19 -0
  806. package/src/isomorphic/grpc.browser.ts +4 -0
  807. package/src/isomorphic/grpc.node.ts +23 -0
  808. package/src/isomorphic/grpc.ts +1 -0
  809. package/src/jupiter/jupiterClient.ts +510 -0
  810. package/src/keypair.ts +24 -0
  811. package/src/marinade/idl/idl.json +1962 -0
  812. package/src/marinade/index.ts +64 -0
  813. package/src/marinade/types.ts +3925 -0
  814. package/src/math/amm.ts +1162 -0
  815. package/src/math/auction.ts +173 -0
  816. package/src/math/bankruptcy.ts +34 -0
  817. package/src/math/conversion.ts +13 -0
  818. package/src/math/exchangeStatus.ts +121 -0
  819. package/src/math/fuel.ts +70 -0
  820. package/src/math/funding.ts +342 -0
  821. package/src/math/insurance.ts +110 -0
  822. package/src/math/margin.ts +340 -0
  823. package/src/math/market.ts +336 -0
  824. package/src/math/oracles.ts +228 -0
  825. package/src/math/orders.ts +343 -0
  826. package/src/math/position.ts +324 -0
  827. package/src/math/repeg.ts +214 -0
  828. package/src/math/spotBalance.ts +630 -0
  829. package/src/math/spotMarket.ts +82 -0
  830. package/src/math/spotPosition.ts +184 -0
  831. package/src/math/state.ts +29 -0
  832. package/src/math/superStake.ts +525 -0
  833. package/src/math/tiers.ts +44 -0
  834. package/src/math/trade.ts +993 -0
  835. package/src/math/userStatus.ts +5 -0
  836. package/src/math/utils.ts +120 -0
  837. package/src/memcmp.ts +94 -0
  838. package/src/openbook/openbookV2FulfillmentConfigMap.ts +29 -0
  839. package/src/openbook/openbookV2Subscriber.ts +165 -0
  840. package/src/oracles/oracleClientCache.ts +25 -0
  841. package/src/oracles/oracleId.ts +28 -0
  842. package/src/oracles/prelaunchOracleClient.ts +37 -0
  843. package/src/oracles/pythClient.ts +85 -0
  844. package/src/oracles/pythLazerClient.ts +102 -0
  845. package/src/oracles/pythPullClient.ts +111 -0
  846. package/src/oracles/quoteAssetOracleClient.ts +25 -0
  847. package/src/oracles/strictOraclePrice.ts +19 -0
  848. package/src/oracles/switchboardClient.ts +77 -0
  849. package/src/oracles/switchboardOnDemandClient.ts +56 -0
  850. package/src/oracles/types.ts +23 -0
  851. package/src/orderParams.ts +79 -0
  852. package/src/orderSubscriber/OrderSubscriber.ts +249 -0
  853. package/src/orderSubscriber/PollingSubscription.ts +39 -0
  854. package/src/orderSubscriber/WebsocketSubscription.ts +119 -0
  855. package/src/orderSubscriber/grpcSubscription.ts +121 -0
  856. package/src/orderSubscriber/index.ts +2 -0
  857. package/src/orderSubscriber/types.ts +54 -0
  858. package/src/phoenix/phoenixFulfillmentConfigMap.ts +26 -0
  859. package/src/phoenix/phoenixSubscriber.ts +235 -0
  860. package/src/priorityFee/averageOverSlotsStrategy.ts +16 -0
  861. package/src/priorityFee/averageStrategy.ts +12 -0
  862. package/src/priorityFee/driftPriorityFeeMethod.ts +42 -0
  863. package/src/priorityFee/ewmaStrategy.ts +41 -0
  864. package/src/priorityFee/heliusPriorityFeeMethod.ts +57 -0
  865. package/src/priorityFee/index.ts +11 -0
  866. package/src/priorityFee/maxOverSlotsStrategy.ts +17 -0
  867. package/src/priorityFee/maxStrategy.ts +7 -0
  868. package/src/priorityFee/priorityFeeSubscriber.ts +251 -0
  869. package/src/priorityFee/priorityFeeSubscriberMap.ts +112 -0
  870. package/src/priorityFee/solanaPriorityFeeMethod.ts +34 -0
  871. package/src/priorityFee/types.ts +60 -0
  872. package/src/serum/serumFulfillmentConfigMap.ts +26 -0
  873. package/src/serum/serumSubscriber.ts +169 -0
  874. package/src/serum/types.ts +17 -0
  875. package/src/slot/SlotSubscriber.ts +101 -0
  876. package/src/slot/SlothashSubscriber.ts +126 -0
  877. package/src/testClient.ts +41 -0
  878. package/src/token/index.ts +13 -0
  879. package/src/tokenFaucet.ts +269 -0
  880. package/src/tx/baseTxSender.ts +477 -0
  881. package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +19 -0
  882. package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +90 -0
  883. package/src/tx/blockhashFetcher/types.ts +5 -0
  884. package/src/tx/fastSingleTxSender.ts +142 -0
  885. package/src/tx/forwardOnlyTxSender.ts +145 -0
  886. package/src/tx/priorityFeeCalculator.ts +117 -0
  887. package/src/tx/reportTransactionError.ts +159 -0
  888. package/src/tx/retryTxSender.ts +135 -0
  889. package/src/tx/txHandler.ts +737 -0
  890. package/src/tx/txParamProcessor.ts +155 -0
  891. package/src/tx/types.ts +71 -0
  892. package/src/tx/utils.ts +11 -0
  893. package/src/tx/whileValidTxSender.ts +265 -0
  894. package/src/types.ts +1386 -0
  895. package/src/user.ts +4054 -0
  896. package/src/userConfig.ts +32 -0
  897. package/src/userMap/PollingSubscription.ts +47 -0
  898. package/src/userMap/WebsocketSubscription.ts +84 -0
  899. package/src/userMap/grpcSubscription.ts +85 -0
  900. package/src/userMap/referrerMap.ts +267 -0
  901. package/src/userMap/userMap.ts +654 -0
  902. package/src/userMap/userMapConfig.ts +63 -0
  903. package/src/userMap/userStatsMap.ts +218 -0
  904. package/src/userName.ts +21 -0
  905. package/src/userStats.ts +174 -0
  906. package/src/userStatsConfig.ts +31 -0
  907. package/src/util/TransactionConfirmationManager.ts +292 -0
  908. package/src/util/chainClock.ts +41 -0
  909. package/src/util/computeUnits.ts +65 -0
  910. package/src/util/digest.ts +11 -0
  911. package/src/util/promiseTimeout.ts +14 -0
  912. package/src/util/pythOracleUtils.ts +136 -0
  913. package/src/util/tps.ts +27 -0
  914. package/src/wallet.ts +43 -0
  915. package/tests/amm/test.ts +2092 -0
  916. package/tests/auctions/test.ts +81 -0
  917. package/tests/bn/test.ts +341 -0
  918. package/tests/ci/idl.ts +101 -0
  919. package/tests/ci/verifyConstants.ts +278 -0
  920. package/tests/decode/phoenix.ts +71 -0
  921. package/tests/decode/test.ts +266 -0
  922. package/tests/decode/userAccountBufferStrings.ts +102 -0
  923. package/tests/dlob/helpers.ts +749 -0
  924. package/tests/dlob/test.ts +6623 -0
  925. package/tests/insurance/test.ts +40 -0
  926. package/tests/spot/test.ts +226 -0
  927. package/tests/subscriber/openbook.ts +62 -0
  928. package/tests/tx/TransactionConfirmationManager.test.ts +305 -0
  929. package/tests/tx/cachedBlockhashFetcher.test.ts +96 -0
  930. package/tests/tx/priorityFeeCalculator.ts +77 -0
  931. package/tests/tx/priorityFeeStrategy.ts +95 -0
  932. package/tests/user/helpers.ts +92 -0
  933. package/tests/user/test.ts +517 -0
  934. package/tsconfig.browser.json +13 -0
  935. package/tsconfig.json +13 -0
@@ -0,0 +1,861 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="bn.js" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ import * as anchor from '@coral-xyz/anchor';
6
+ import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
7
+ import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
8
+ import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, RFQMakerOrderParams, RFQMatch, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SwiftOrderParamsMessage, SwiftServerMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount } from './types';
9
+ import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
10
+ import { TokenFaucet } from './tokenFaucet';
11
+ import { EventEmitter } from 'events';
12
+ import StrictEventEmitter from 'strict-event-emitter-types';
13
+ import { DataAndSlot, DriftClientAccountEvents, DriftClientAccountSubscriber } from './accounts/types';
14
+ import { TxSender, TxSigAndSlot } from './tx/types';
15
+ import { OraclePriceData } from './oracles/types';
16
+ import { DriftClientConfig } from './driftClientConfig';
17
+ import { User } from './user';
18
+ import { UserSubscriptionConfig } from './userConfig';
19
+ import { DriftEnv } from './config';
20
+ import { UserStats } from './userStats';
21
+ import { JupiterClient, QuoteResponse, Route, SwapMode } from './jupiter/jupiterClient';
22
+ import { UserStatsSubscriptionConfig } from './userStatsConfig';
23
+ import { TxHandler } from './tx/txHandler';
24
+ import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/idl/wormhole_core_bridge_solana';
25
+ import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/pyth_solana_receiver';
26
+ import { Slothash } from './slot/SlothashSubscriber';
27
+ type RemainingAccountParams = {
28
+ userAccounts: UserAccount[];
29
+ writablePerpMarketIndexes?: number[];
30
+ writableSpotMarketIndexes?: number[];
31
+ readablePerpMarketIndex?: number | number[];
32
+ readableSpotMarketIndexes?: number[];
33
+ useMarketLastSlotCache?: boolean;
34
+ };
35
+ /**
36
+ * # DriftClient
37
+ * This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
38
+ */
39
+ export declare class DriftClient {
40
+ connection: Connection;
41
+ wallet: IWallet;
42
+ program: Program;
43
+ swiftID: PublicKey;
44
+ provider: AnchorProvider;
45
+ opts?: ConfirmOptions;
46
+ users: Map<string, User>;
47
+ userStats?: UserStats;
48
+ activeSubAccountId: number;
49
+ userAccountSubscriptionConfig: UserSubscriptionConfig;
50
+ userStatsAccountSubscriptionConfig: UserStatsSubscriptionConfig;
51
+ accountSubscriber: DriftClientAccountSubscriber;
52
+ eventEmitter: StrictEventEmitter<EventEmitter, DriftClientAccountEvents>;
53
+ metricsEventEmitter: StrictEventEmitter<EventEmitter, DriftClientMetricsEvents>;
54
+ _isSubscribed: boolean;
55
+ txSender: TxSender;
56
+ perpMarketLastSlotCache: Map<number, number>;
57
+ spotMarketLastSlotCache: Map<number, number>;
58
+ mustIncludePerpMarketIndexes: Set<number>;
59
+ mustIncludeSpotMarketIndexes: Set<number>;
60
+ authority: PublicKey;
61
+ marketLookupTable: PublicKey;
62
+ lookupTableAccount: AddressLookupTableAccount;
63
+ includeDelegates?: boolean;
64
+ authoritySubAccountMap?: Map<string, number[]>;
65
+ skipLoadUsers?: boolean;
66
+ txVersion: TransactionVersion;
67
+ txParams: TxParams;
68
+ enableMetricsEvents?: boolean;
69
+ txHandler: TxHandler;
70
+ receiverProgram?: Program<PythSolanaReceiver>;
71
+ wormholeProgram?: Program<WormholeCoreBridgeSolana>;
72
+ sbOnDemandProgramdId: PublicKey;
73
+ sbOnDemandProgram?: Program30<Idl30>;
74
+ sbProgramFeedConfigs?: Map<string, any>;
75
+ get isSubscribed(): boolean;
76
+ set isSubscribed(val: boolean);
77
+ constructor(config: DriftClientConfig);
78
+ getUserMapKey(subAccountId: number, authority: PublicKey): string;
79
+ createUser(subAccountId: number, accountSubscriptionConfig: UserSubscriptionConfig, authority?: PublicKey): User;
80
+ subscribe(): Promise<boolean>;
81
+ subscribeUsers(): Promise<boolean>[];
82
+ /**
83
+ * Forces the accountSubscriber to fetch account updates from rpc
84
+ */
85
+ fetchAccounts(): Promise<void>;
86
+ unsubscribe(): Promise<void>;
87
+ unsubscribeUsers(): Promise<void>[];
88
+ statePublicKey?: PublicKey;
89
+ getStatePublicKey(): Promise<PublicKey>;
90
+ signerPublicKey?: PublicKey;
91
+ getSignerPublicKey(): PublicKey;
92
+ getStateAccount(): StateAccount;
93
+ /**
94
+ * Forces a fetch to rpc before returning accounts. Useful for anchor tests.
95
+ */
96
+ forceGetStateAccount(): Promise<StateAccount>;
97
+ getPerpMarketAccount(marketIndex: number): PerpMarketAccount | undefined;
98
+ /**
99
+ * Forces a fetch to rpc before returning accounts. Useful for anchor tests.
100
+ * @param marketIndex
101
+ */
102
+ forceGetPerpMarketAccount(marketIndex: number): Promise<PerpMarketAccount | undefined>;
103
+ getPerpMarketAccounts(): PerpMarketAccount[];
104
+ getSpotMarketAccount(marketIndex: number): SpotMarketAccount | undefined;
105
+ /**
106
+ * Forces a fetch to rpc before returning accounts. Useful for anchor tests.
107
+ * @param marketIndex
108
+ */
109
+ forceGetSpotMarketAccount(marketIndex: number): Promise<SpotMarketAccount | undefined>;
110
+ getSpotMarketAccounts(): SpotMarketAccount[];
111
+ getQuoteSpotMarketAccount(): SpotMarketAccount;
112
+ getOraclePriceDataAndSlot(oraclePublicKey: PublicKey, oracleSource: OracleSource): DataAndSlot<OraclePriceData> | undefined;
113
+ getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>;
114
+ getSerumV3FulfillmentConfigs(): Promise<SerumV3FulfillmentConfigAccount[]>;
115
+ getPhoenixV1FulfillmentConfig(phoenixMarket: PublicKey): Promise<PhoenixV1FulfillmentConfigAccount>;
116
+ getPhoenixV1FulfillmentConfigs(): Promise<PhoenixV1FulfillmentConfigAccount[]>;
117
+ getOpenbookV2FulfillmentConfig(openbookMarket: PublicKey): Promise<OpenbookV2FulfillmentConfigAccount>;
118
+ getOpenbookV2FulfillmentConfigs(): Promise<OpenbookV2FulfillmentConfigAccount[]>;
119
+ fetchMarketLookupTableAccount(): Promise<AddressLookupTableAccount>;
120
+ /**
121
+ * Update the wallet to use for drift transactions and linked user account
122
+ * @param newWallet
123
+ * @param subAccountIds
124
+ * @param activeSubAccountId
125
+ * @param includeDelegates
126
+ */
127
+ updateWallet(newWallet: IWallet, subAccountIds?: number[], activeSubAccountId?: number, includeDelegates?: boolean, authoritySubaccountMap?: Map<string, number[]>): Promise<boolean>;
128
+ /**
129
+ * Update the subscribed accounts to a given authority, while leaving the
130
+ * connected wallet intact. This allows a user to emulate another user's
131
+ * account on the UI and sign permissionless transactions with their own wallet.
132
+ * @param emulateAuthority
133
+ */
134
+ emulateAccount(emulateAuthority: PublicKey): Promise<boolean>;
135
+ switchActiveUser(subAccountId: number, authority?: PublicKey): Promise<void>;
136
+ addUser(subAccountId: number, authority?: PublicKey, userAccount?: UserAccount): Promise<boolean>;
137
+ /**
138
+ * Adds and subscribes to users based on params set by the constructor or by updateWallet.
139
+ */
140
+ addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
141
+ initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
142
+ getInitializeUserStatsIx(): Promise<TransactionInstruction>;
143
+ initializeRFQUser(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
144
+ getInitializeRFQUserInstruction(userAccountPublicKey: PublicKey): Promise<[PublicKey, TransactionInstruction]>;
145
+ initializeSwiftUserOrders(userAccountPublicKey: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
146
+ getInitializeSwiftUserOrdersAccountIx(userAccountPublicKey: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>;
147
+ resizeSwiftUserOrders(userAccountPublicKey: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
148
+ getResizeSwiftUserOrdersInstruction(userAccountPublicKey: PublicKey, numOrders: number): Promise<TransactionInstruction>;
149
+ getInitializeUserInstructions(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
150
+ getNextSubAccountId(): Promise<number>;
151
+ initializeReferrerName(name: string): Promise<TransactionSignature>;
152
+ updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
153
+ updateUserCustomMarginRatio(updates: {
154
+ marginRatio: number;
155
+ subAccountId: number;
156
+ }[], txParams?: TxParams): Promise<TransactionSignature>;
157
+ getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>;
158
+ getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
159
+ updateUserMarginTradingEnabled(updates: {
160
+ marginTradingEnabled: boolean;
161
+ subAccountId: number;
162
+ }[]): Promise<TransactionSignature>;
163
+ updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
164
+ updateUserAdvancedLp(updates: {
165
+ advancedLp: boolean;
166
+ subAccountId: number;
167
+ }[]): Promise<TransactionSignature>;
168
+ getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
169
+ updateUserReduceOnly(updates: {
170
+ reduceOnly: boolean;
171
+ subAccountId: number;
172
+ }[]): Promise<TransactionSignature>;
173
+ getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
174
+ updateUserPoolId(updates: {
175
+ poolId: number;
176
+ subAccountId: number;
177
+ }[]): Promise<TransactionSignature>;
178
+ getUpdateUserPoolIdIx(poolId: number, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
179
+ fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
180
+ getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
181
+ getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
182
+ getUserAccountsForAuthority(authority: PublicKey): Promise<UserAccount[]>;
183
+ getReferredUserStatsAccountsByReferrer(referrer: PublicKey): Promise<UserStatsAccount[]>;
184
+ getReferrerNameAccountsForAuthority(authority: PublicKey): Promise<ReferrerNameAccount[]>;
185
+ deleteUser(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
186
+ getUserDeletionIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>;
187
+ forceDeleteUser(userAccountPublicKey: PublicKey, userAccount: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
188
+ getForceDeleteUserIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<anchor.web3.TransactionInstruction>;
189
+ deleteSwiftUserOrders(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
190
+ getSwiftUserOrdersDeletionIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>;
191
+ reclaimRent(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
192
+ getReclaimRentIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>;
193
+ getUser(subAccountId?: number, authority?: PublicKey): User;
194
+ hasUser(subAccountId?: number, authority?: PublicKey): boolean;
195
+ getUsers(): User[];
196
+ getUserStats(): UserStats;
197
+ fetchReferrerNameAccount(name: string): Promise<ReferrerNameAccount | undefined>;
198
+ userStatsAccountPublicKey: PublicKey;
199
+ getUserStatsAccountPublicKey(): PublicKey;
200
+ getUserAccountPublicKey(subAccountId?: number, authority?: PublicKey): Promise<PublicKey>;
201
+ getUserAccount(subAccountId?: number, authority?: PublicKey): UserAccount | undefined;
202
+ /**
203
+ * Forces a fetch to rpc before returning accounts. Useful for anchor tests.
204
+ * @param subAccountId
205
+ */
206
+ forceGetUserAccount(subAccountId?: number): Promise<UserAccount | undefined>;
207
+ getUserAccountAndSlot(subAccountId?: number): DataAndSlot<UserAccount> | undefined;
208
+ getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined;
209
+ getQuoteAssetTokenAmount(): BN;
210
+ /**
211
+ * Returns the token amount for a given market. The spot market precision is based on the token mint decimals.
212
+ * Positive if it is a deposit, negative if it is a borrow.
213
+ * @param marketIndex
214
+ */
215
+ getTokenAmount(marketIndex: number): BN;
216
+ /**
217
+ * Converts an amount to the spot precision for a given market. The spot market precision is based on the token mint decimals.
218
+ * @param marketIndex
219
+ * @param amount
220
+ */
221
+ convertToSpotPrecision(marketIndex: number, amount: BN | number): BN;
222
+ /**
223
+ * Converts an amount to the perp precision. The perp market precision is {@link BASE_PRECISION} (1e9).
224
+ * @param amount
225
+ */
226
+ convertToPerpPrecision(amount: BN | number): BN;
227
+ /**
228
+ * Converts an amount to the price precision. The perp market precision is {@link PRICE_PRECISION} (1e6).
229
+ * @param amount
230
+ */
231
+ convertToPricePrecision(amount: BN | number): BN;
232
+ /**
233
+ * Each drift instruction must include perp and sport market accounts in the ix remaining accounts.
234
+ * Use this function to force a subset of markets to be included in the remaining accounts for every ix
235
+ *
236
+ * @param perpMarketIndexes
237
+ * @param spotMarketIndexes
238
+ */
239
+ mustIncludeMarketsInIx({ perpMarketIndexes, spotMarketIndexes, }: {
240
+ perpMarketIndexes: number[];
241
+ spotMarketIndexes: number[];
242
+ }): void;
243
+ getRemainingAccounts(params: RemainingAccountParams): AccountMeta[];
244
+ addPerpMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>, perpMarketAccountMap: Map<number, AccountMeta>): void;
245
+ addSpotMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>): void;
246
+ getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): {
247
+ oracleAccountMap: Map<string, AccountMeta>;
248
+ spotMarketAccountMap: Map<number, AccountMeta>;
249
+ perpMarketAccountMap: Map<number, AccountMeta>;
250
+ };
251
+ getOrder(orderId: number, subAccountId?: number): Order | undefined;
252
+ getOrderByUserId(userOrderId: number, subAccountId?: number): Order | undefined;
253
+ /**
254
+ * Get the associated token address for the given spot market
255
+ * @param marketIndex
256
+ * @param useNative
257
+ * @param tokenProgram
258
+ */
259
+ getAssociatedTokenAccount(marketIndex: number, useNative?: boolean, tokenProgram?: anchor.web3.PublicKey): Promise<PublicKey>;
260
+ createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: anchor.web3.PublicKey): TransactionInstruction;
261
+ getDepositTxnIx(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionInstruction[]>;
262
+ createDepositTxn(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<VersionedTransaction | Transaction>;
263
+ /**
264
+ * Deposit funds into the given spot market
265
+ *
266
+ * @param amount to deposit
267
+ * @param marketIndex spot market index to deposit into
268
+ * @param associatedTokenAccount can be the wallet public key if using native sol
269
+ * @param subAccountId subaccountId to deposit
270
+ * @param reduceOnly if true, deposit must not increase account risk
271
+ */
272
+ deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<TransactionSignature>;
273
+ getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
274
+ private checkIfAccountExists;
275
+ getWrappedSolAccountCreationIxs(amount: BN, includeRent?: boolean): Promise<{
276
+ ixs: anchor.web3.TransactionInstruction[];
277
+ /** @deprecated - this array is always going to be empty, in the current implementation */
278
+ signers: Signer[];
279
+ pubkey: PublicKey;
280
+ }>;
281
+ getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
282
+ addTokenMintToRemainingAccounts(spotMarketAccount: SpotMarketAccount, remainingAccounts: AccountMeta[]): void;
283
+ getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey, tokenProgram: PublicKey): anchor.web3.TransactionInstruction;
284
+ createInitializeUserAccountAndDepositCollateralIxs(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, customMaxMarginRatio?: number): Promise<{
285
+ ixs: TransactionInstruction[];
286
+ userAccountPublicKey: PublicKey;
287
+ }>;
288
+ createInitializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number): Promise<[Transaction | VersionedTransaction, PublicKey]>;
289
+ /**
290
+ * Creates the User account for a user, and deposits some initial collateral
291
+ * @param amount
292
+ * @param userTokenAccount
293
+ * @param marketIndex
294
+ * @param subAccountId
295
+ * @param name
296
+ * @param fromSubAccountId
297
+ * @param referrerInfo
298
+ * @param donateAmount
299
+ * @param txParams
300
+ * @returns
301
+ */
302
+ initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number): Promise<[TransactionSignature, PublicKey]>;
303
+ initializeUserAccountForDevnet(subAccountId: number, name: string, marketIndex: number, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
304
+ getWithdrawalIxs(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, updateFuel?: boolean): Promise<TransactionInstruction[]>;
305
+ /**
306
+ * Withdraws from a user account. If deposit doesn't already exist, creates a borrow
307
+ * @param amount
308
+ * @param marketIndex
309
+ * @param associatedTokenAddress - the token account to withdraw to. can be the wallet public key if using native sol
310
+ * @param reduceOnly
311
+ */
312
+ withdraw(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, txParams?: TxParams, updateFuel?: boolean): Promise<TransactionSignature>;
313
+ withdrawAllDustPositions(subAccountId?: number, txParams?: TxParams, opts?: {
314
+ dustPositionCountCallback?: (count: number) => void;
315
+ }): Promise<TransactionSignature | undefined>;
316
+ getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionInstruction>;
317
+ /**
318
+ * Withdraws from the fromSubAccount and deposits into the toSubAccount
319
+ * @param amount
320
+ * @param marketIndex
321
+ * @param fromSubAccountId
322
+ * @param toSubAccountId
323
+ * @param txParams
324
+ */
325
+ transferDeposit(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
326
+ getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
327
+ updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
328
+ updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
329
+ settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
330
+ settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise<TransactionInstruction>;
331
+ removePerpLpShares(marketIndex: number, sharesToBurn?: BN, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
332
+ removePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN, txParams?: TxParams): Promise<TransactionSignature>;
333
+ getRemovePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN): Promise<TransactionInstruction>;
334
+ getRemovePerpLpSharesIx(marketIndex: number, sharesToBurn?: BN, subAccountId?: number): Promise<TransactionInstruction>;
335
+ addPerpLpShares(amount: BN, marketIndex: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
336
+ getAddPerpLpSharesIx(amount: BN, marketIndex: number, subAccountId?: number): Promise<TransactionInstruction>;
337
+ getQuoteValuePerLpShare(marketIndex: number): BN;
338
+ /**
339
+ * @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
340
+ */
341
+ openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
342
+ sendSignedTx(tx: Transaction | VersionedTransaction, opts?: ConfirmOptions): Promise<TransactionSignature>;
343
+ prepareMarketOrderTxs(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{
344
+ cancelExistingOrdersTx?: Transaction | VersionedTransaction;
345
+ settlePnlTx?: Transaction | VersionedTransaction;
346
+ fillTx?: Transaction | VersionedTransaction;
347
+ marketOrderTx: Transaction | VersionedTransaction;
348
+ }>;
349
+ /**
350
+ * Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
351
+ * @param orderParams
352
+ * @param userAccountPublicKey
353
+ * @param userAccount
354
+ * @param makerInfo
355
+ * @param txParams
356
+ * @param bracketOrdersParams
357
+ * @param cancelExistingOrders - Builds and returns an extra transaciton to cancel the existing orders in the same perp market. Intended use is to auto-cancel TP/SL orders when closing a position. Ignored if orderParams.marketType is not MarketType.PERP
358
+ * @returns
359
+ */
360
+ sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{
361
+ txSig: TransactionSignature;
362
+ signedFillTx?: Transaction;
363
+ signedCancelExistingOrdersTx?: Transaction;
364
+ signedSettlePnlTx?: Transaction;
365
+ }>;
366
+ placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
367
+ getPlacePerpOrderIx(orderParams: OptionalOrderParams, subAccountId?: number, depositToTradeArgs?: {
368
+ isMakingNewAccount: boolean;
369
+ depositMarketIndex: number;
370
+ }): Promise<TransactionInstruction>;
371
+ updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
372
+ getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>;
373
+ settleExpiredMarket(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
374
+ getSettleExpiredMarketIx(marketIndex: number): Promise<TransactionInstruction>;
375
+ settleExpiredMarketPoolsToRevenuePool(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
376
+ getSettleExpiredMarketPoolsToRevenuePoolIx(perpMarketIndex: number): Promise<TransactionInstruction>;
377
+ cancelOrder(orderId?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
378
+ getCancelOrderIx(orderId?: number, subAccountId?: number): Promise<TransactionInstruction>;
379
+ cancelOrderByUserId(userOrderId: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
380
+ getCancelOrderByUserIdIx(userOrderId: number, subAccountId?: number): Promise<TransactionInstruction>;
381
+ cancelOrdersByIds(orderIds?: number[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
382
+ getCancelOrdersByIdsIx(orderIds?: number[], subAccountId?: number): Promise<TransactionInstruction>;
383
+ cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
384
+ getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null, subAccountId?: number): Promise<TransactionInstruction>;
385
+ cancelAndPlaceOrders(cancelOrderParams: {
386
+ marketType?: MarketType;
387
+ marketIndex?: number;
388
+ direction?: PositionDirection;
389
+ }, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
390
+ placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
391
+ preparePlaceOrdersTx(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<{
392
+ placeOrdersTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
393
+ }>;
394
+ getPlaceOrdersIx(params: OptionalOrderParams[], subAccountId?: number): Promise<TransactionInstruction>;
395
+ fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, fillerPublicKey?: number): Promise<TransactionSignature>;
396
+ getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerSubAccountId?: number, isSwift?: boolean): Promise<TransactionInstruction>;
397
+ getRevertFillIx(fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
398
+ placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
399
+ preparePlaceSpotOrderTx(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<{
400
+ placeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
401
+ }>;
402
+ getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise<TransactionInstruction>;
403
+ fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
404
+ getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
405
+ addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount): void;
406
+ addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void;
407
+ addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): void;
408
+ addOpenbookRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: OpenbookV2FulfillmentConfigAccount): void;
409
+ /**
410
+ * Swap tokens in drift account using jupiter
411
+ * @param jupiterClient jupiter client to find routes and jupiter instructions
412
+ * @param outMarketIndex the market index of the token you're buying
413
+ * @param inMarketIndex the market index of the token you're selling
414
+ * @param outAssociatedTokenAccount the token account to receive the token being sold on jupiter
415
+ * @param inAssociatedTokenAccount the token account to
416
+ * @param amount the amount of TokenIn, regardless of swapMode
417
+ * @param slippageBps the max slippage passed to jupiter api
418
+ * @param swapMode jupiter swapMode (ExactIn or ExactOut), default is ExactIn
419
+ * @param route the jupiter route to use for the swap
420
+ * @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
421
+ * @param txParams
422
+ */
423
+ swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, onlyDirectRoutes, }: {
424
+ jupiterClient: JupiterClient;
425
+ outMarketIndex: number;
426
+ inMarketIndex: number;
427
+ outAssociatedTokenAccount?: PublicKey;
428
+ inAssociatedTokenAccount?: PublicKey;
429
+ amount: BN;
430
+ slippageBps?: number;
431
+ swapMode?: SwapMode;
432
+ route?: Route;
433
+ reduceOnly?: SwapReduceOnly;
434
+ txParams?: TxParams;
435
+ onlyDirectRoutes?: boolean;
436
+ v6?: {
437
+ quote?: QuoteResponse;
438
+ };
439
+ }): Promise<TransactionSignature>;
440
+ getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, route, reduceOnly, userAccountPublicKey, }: {
441
+ jupiterClient: JupiterClient;
442
+ outMarketIndex: number;
443
+ inMarketIndex: number;
444
+ outAssociatedTokenAccount?: PublicKey;
445
+ inAssociatedTokenAccount?: PublicKey;
446
+ amount: BN;
447
+ slippageBps?: number;
448
+ swapMode?: SwapMode;
449
+ onlyDirectRoutes?: boolean;
450
+ route?: Route;
451
+ reduceOnly?: SwapReduceOnly;
452
+ userAccountPublicKey?: PublicKey;
453
+ }): Promise<{
454
+ ixs: TransactionInstruction[];
455
+ lookupTables: AddressLookupTableAccount[];
456
+ }>;
457
+ getJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, quote, reduceOnly, userAccountPublicKey, }: {
458
+ jupiterClient: JupiterClient;
459
+ outMarketIndex: number;
460
+ inMarketIndex: number;
461
+ outAssociatedTokenAccount?: PublicKey;
462
+ inAssociatedTokenAccount?: PublicKey;
463
+ amount: BN;
464
+ slippageBps?: number;
465
+ swapMode?: SwapMode;
466
+ onlyDirectRoutes?: boolean;
467
+ quote?: QuoteResponse;
468
+ reduceOnly?: SwapReduceOnly;
469
+ userAccountPublicKey?: PublicKey;
470
+ }): Promise<{
471
+ ixs: TransactionInstruction[];
472
+ lookupTables: AddressLookupTableAccount[];
473
+ }>;
474
+ /**
475
+ * Get the drift begin_swap and end_swap instructions
476
+ *
477
+ * @param outMarketIndex the market index of the token you're buying
478
+ * @param inMarketIndex the market index of the token you're selling
479
+ * @param amountIn the amount of the token to sell
480
+ * @param inTokenAccount the token account to move the tokens being sold
481
+ * @param outTokenAccount the token account to receive the tokens being bought
482
+ * @param limitPrice the limit price of the swap
483
+ * @param reduceOnly
484
+ * @param userAccountPublicKey optional, specify a custom userAccountPublicKey to use instead of getting the current user account; can be helpful if the account is being created within the current tx
485
+ */
486
+ getSwapIx({ outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, userAccountPublicKey, }: {
487
+ outMarketIndex: number;
488
+ inMarketIndex: number;
489
+ amountIn: BN;
490
+ inTokenAccount: PublicKey;
491
+ outTokenAccount: PublicKey;
492
+ limitPrice?: BN;
493
+ reduceOnly?: SwapReduceOnly;
494
+ userAccountPublicKey?: PublicKey;
495
+ }): Promise<{
496
+ beginSwapIx: TransactionInstruction;
497
+ endSwapIx: TransactionInstruction;
498
+ }>;
499
+ stakeForMSOL({ amount }: {
500
+ amount: BN;
501
+ }): Promise<TxSigAndSlot>;
502
+ getStakeForMSOLIx({ amount, userAccountPublicKey, }: {
503
+ amount: BN;
504
+ userAccountPublicKey?: PublicKey;
505
+ }): Promise<TransactionInstruction[]>;
506
+ triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
507
+ getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
508
+ forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
509
+ getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
510
+ updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
511
+ getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
512
+ logUserBalances(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
513
+ getLogUserBalancesIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
514
+ updateUserFuelBonus(userAccountPublicKey: PublicKey, user: UserAccount, userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
515
+ getUpdateUserFuelBonusIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, userAuthority: PublicKey): Promise<TransactionInstruction>;
516
+ updateUserStatsReferrerStatus(userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
517
+ getUpdateUserStatsReferrerStatusIx(userAuthority: PublicKey): Promise<TransactionInstruction>;
518
+ updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
519
+ getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
520
+ placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
521
+ preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean, auctionDurationPercentage?: number): Promise<{
522
+ placeAndTakeTx: Transaction | VersionedTransaction;
523
+ cancelExistingOrdersTx: Transaction | VersionedTransaction;
524
+ settlePnlTx: Transaction | VersionedTransaction;
525
+ }>;
526
+ placeAndTakePerpWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean): Promise<{
527
+ txSig: TransactionSignature;
528
+ signedCancelExistingOrdersTx?: Transaction;
529
+ signedSettlePnlTx?: Transaction;
530
+ }>;
531
+ getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number): Promise<TransactionInstruction>;
532
+ placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
533
+ getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
534
+ encodeSwiftServerMessage(message: SwiftServerMessage): Buffer;
535
+ decodeSwiftServerMessage(encodedMessage: Buffer): SwiftServerMessage;
536
+ signSwiftServerMessage(message: SwiftServerMessage): Buffer;
537
+ signSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
538
+ encodeSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
539
+ decodeSwiftOrderParamsMessage(encodedMessage: Buffer): SwiftOrderParamsMessage;
540
+ signMessage(message: Uint8Array, keypair?: Keypair): Buffer;
541
+ placeSwiftTakerOrder(swiftServerMessage: Buffer, swiftSignature: Buffer, swiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, marketIndex: number, takerInfo: {
542
+ taker: PublicKey;
543
+ takerStats: PublicKey;
544
+ takerUserAccount: UserAccount;
545
+ }, txParams?: TxParams): Promise<TransactionSignature>;
546
+ getPlaceSwiftTakerPerpOrderIxs(encodedSwiftServerMessage: Buffer, swiftSignature: Buffer, encodedSwiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, marketIndex: number, takerInfo: {
547
+ taker: PublicKey;
548
+ takerStats: PublicKey;
549
+ takerUserAccount: UserAccount;
550
+ }, authority?: PublicKey): Promise<TransactionInstruction[]>;
551
+ placeAndMakeSwiftPerpOrder(encodedSwiftMessage: Buffer, swiftSignature: Buffer, encodedSwiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, swiftOrderUuid: Uint8Array, takerInfo: {
552
+ taker: PublicKey;
553
+ takerStats: PublicKey;
554
+ takerUserAccount: UserAccount;
555
+ }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
556
+ getPlaceAndMakeSwiftPerpOrderIxs(encodedSwiftMessage: Buffer, swiftSignature: Buffer, encodedSwiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, swiftOrderUuid: Uint8Array, takerInfo: {
557
+ taker: PublicKey;
558
+ takerStats: PublicKey;
559
+ takerUserAccount: UserAccount;
560
+ }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction[]>;
561
+ encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
562
+ placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
563
+ getPlaceAndMatchRFQOrdersIxs(rfqMatches: RFQMatch[]): Promise<TransactionInstruction[]>;
564
+ preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{
565
+ placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
566
+ }>;
567
+ placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
568
+ getPlaceAndTakeSpotOrderIx(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
569
+ placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
570
+ getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
571
+ /**
572
+ * @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
573
+ */
574
+ closePosition(marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
575
+ /**
576
+ * Modifies an open order by closing it and replacing it with a new order.
577
+ * @deprecated use modifyOrder instead
578
+ * @param orderId: The open order to modify
579
+ * @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
580
+ * @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
581
+ * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
582
+ * @returns
583
+ */
584
+ modifyPerpOrder(orderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>;
585
+ /**
586
+ * Modifies an open order by closing it and replacing it with a new order.
587
+ * @deprecated use modifyOrderByUserOrderId instead
588
+ * @param userOrderId: The open order to modify
589
+ * @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
590
+ * @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
591
+ * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
592
+ * @returns
593
+ */
594
+ modifyPerpOrderByUserOrderId(userOrderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>;
595
+ /**
596
+ * Modifies an open order (spot or perp) by closing it and replacing it with a new order.
597
+ * @param orderParams.orderId: The open order to modify
598
+ * @param orderParams.newDirection: The new direction for the order
599
+ * @param orderParams.newBaseAmount: The new base amount for the order
600
+ * @param orderParams.newLimitPice: The new limit price for the order
601
+ * @param orderParams.newOraclePriceOffset: The new oracle price offset for the order
602
+ * @param orderParams.newTriggerPrice: Optional - Thew new trigger price for the order.
603
+ * @param orderParams.auctionDuration:
604
+ * @param orderParams.auctionStartPrice:
605
+ * @param orderParams.auctionEndPrice:
606
+ * @param orderParams.reduceOnly:
607
+ * @param orderParams.postOnly:
608
+ * @param orderParams.immediateOrCancel:
609
+ * @param orderParams.policy:
610
+ * @param orderParams.maxTs:
611
+ * @returns
612
+ */
613
+ modifyOrder(orderParams: {
614
+ orderId: number;
615
+ newDirection?: PositionDirection;
616
+ newBaseAmount?: BN;
617
+ newLimitPrice?: BN;
618
+ newOraclePriceOffset?: number;
619
+ newTriggerPrice?: BN;
620
+ newTriggerCondition?: OrderTriggerCondition;
621
+ auctionDuration?: number;
622
+ auctionStartPrice?: BN;
623
+ auctionEndPrice?: BN;
624
+ reduceOnly?: boolean;
625
+ postOnly?: boolean;
626
+ immediateOrCancel?: boolean;
627
+ maxTs?: BN;
628
+ policy?: number;
629
+ }, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
630
+ getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
631
+ orderId: number;
632
+ newDirection?: PositionDirection;
633
+ newBaseAmount?: BN;
634
+ newLimitPrice?: BN;
635
+ newOraclePriceOffset?: number;
636
+ newTriggerPrice?: BN;
637
+ newTriggerCondition?: OrderTriggerCondition;
638
+ auctionDuration?: number;
639
+ auctionStartPrice?: BN;
640
+ auctionEndPrice?: BN;
641
+ reduceOnly?: boolean;
642
+ postOnly?: boolean;
643
+ immediateOrCancel?: boolean;
644
+ maxTs?: BN;
645
+ policy?: number;
646
+ }, subAccountId?: number): Promise<TransactionInstruction>;
647
+ /**
648
+ * Modifies an open order by closing it and replacing it with a new order.
649
+ * @param orderParams.userOrderId: The open order to modify
650
+ * @param orderParams.newDirection: The new direction for the order
651
+ * @param orderParams.newBaseAmount: The new base amount for the order
652
+ * @param orderParams.newLimitPice: The new limit price for the order
653
+ * @param orderParams.newOraclePriceOffset: The new oracle price offset for the order
654
+ * @param orderParams.newTriggerPrice: Optional - Thew new trigger price for the order.
655
+ * @param orderParams.auctionDuration: Only required if order type changed to market from something else
656
+ * @param orderParams.auctionStartPrice: Only required if order type changed to market from something else
657
+ * @param orderParams.auctionEndPrice: Only required if order type changed to market from something else
658
+ * @param orderParams.reduceOnly:
659
+ * @param orderParams.postOnly:
660
+ * @param orderParams.immediateOrCancel:
661
+ * @param orderParams.policy:
662
+ * @param orderParams.maxTs:
663
+ * @returns
664
+ */
665
+ modifyOrderByUserOrderId(orderParams: {
666
+ userOrderId: number;
667
+ newDirection?: PositionDirection;
668
+ newBaseAmount?: BN;
669
+ newLimitPrice?: BN;
670
+ newOraclePriceOffset?: number;
671
+ newTriggerPrice?: BN;
672
+ newTriggerCondition?: OrderTriggerCondition;
673
+ auctionDuration?: number;
674
+ auctionStartPrice?: BN;
675
+ auctionEndPrice?: BN;
676
+ reduceOnly?: boolean;
677
+ postOnly?: boolean;
678
+ immediateOrCancel?: boolean;
679
+ policy?: ModifyOrderPolicy;
680
+ maxTs?: BN;
681
+ }, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
682
+ getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
683
+ userOrderId: number;
684
+ newDirection?: PositionDirection;
685
+ newBaseAmount?: BN;
686
+ newLimitPrice?: BN;
687
+ newOraclePriceOffset?: number;
688
+ newTriggerPrice?: BN;
689
+ newTriggerCondition?: OrderTriggerCondition;
690
+ auctionDuration?: number;
691
+ auctionStartPrice?: BN;
692
+ auctionEndPrice?: BN;
693
+ reduceOnly?: boolean;
694
+ postOnly?: boolean;
695
+ immediateOrCancel?: boolean;
696
+ policy?: ModifyOrderPolicy;
697
+ maxTs?: BN;
698
+ txParams?: TxParams;
699
+ }, subAccountId?: number): Promise<TransactionInstruction>;
700
+ settlePNLs(users: {
701
+ settleeUserAccountPublicKey: PublicKey;
702
+ settleeUserAccount: UserAccount;
703
+ }[], marketIndexes: number[], opts?: {
704
+ filterInvalidMarkets?: boolean;
705
+ }, txParams?: TxParams): Promise<TransactionSignature>;
706
+ getSettlePNLsIxs(users: {
707
+ settleeUserAccountPublicKey: PublicKey;
708
+ settleeUserAccount: UserAccount;
709
+ }[], marketIndexes: number[]): Promise<Array<TransactionInstruction>>;
710
+ settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
711
+ settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
712
+ settleMultiplePNLs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature>;
713
+ settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature[]>;
714
+ settleMultiplePNLsIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode): Promise<TransactionInstruction>;
715
+ getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
716
+ setUserStatusToBeingLiquidated(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionSignature>;
717
+ liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
718
+ getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
719
+ liquidatePerpWithFill(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
720
+ getLiquidatePerpWithFillIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
721
+ liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
722
+ getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
723
+ liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
724
+ getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
725
+ liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
726
+ getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
727
+ resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
728
+ getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
729
+ resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
730
+ getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
731
+ updateFundingRate(perpMarketIndex: number, oracle: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
732
+ getUpdateFundingRateIx(perpMarketIndex: number, oracle: PublicKey): Promise<TransactionInstruction>;
733
+ updatePrelaunchOracle(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
734
+ getUpdatePrelaunchOracleIx(perpMarketIndex: number): Promise<TransactionInstruction>;
735
+ updatePerpBidAskTwap(perpMarketIndex: number, makers: [PublicKey, PublicKey][], txParams?: TxParams): Promise<TransactionSignature>;
736
+ getUpdatePerpBidAskTwapIx(perpMarketIndex: number, makers: [PublicKey, PublicKey][]): Promise<TransactionInstruction>;
737
+ settleFundingPayment(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
738
+ getSettleFundingPaymentIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
739
+ triggerEvent(eventName: keyof DriftClientAccountEvents, data?: any): void;
740
+ getOracleDataForPerpMarket(marketIndex: number): OraclePriceData;
741
+ getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
742
+ initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
743
+ getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
744
+ getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
745
+ /**
746
+ * Add to an insurance fund stake and optionally initialize the account
747
+ */
748
+ addInsuranceFundStake({ marketIndex, amount, collateralAccountPublicKey, initializeStakeAccount, fromSubaccount, txParams, }: {
749
+ /**
750
+ * Spot market index
751
+ */
752
+ marketIndex: number;
753
+ amount: BN;
754
+ /**
755
+ * The account where the funds to stake come from. Usually an associated token account
756
+ */
757
+ collateralAccountPublicKey: PublicKey;
758
+ /**
759
+ * Add instructions to initialize the staking account -- required if its the first time the currrent authority has staked in this market
760
+ */
761
+ initializeStakeAccount?: boolean;
762
+ /**
763
+ * Optional -- withdraw from current subaccount to fund stake amount, instead of wallet balance
764
+ */
765
+ fromSubaccount?: boolean;
766
+ txParams?: TxParams;
767
+ }): Promise<TransactionSignature>;
768
+ requestRemoveInsuranceFundStake(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
769
+ cancelRequestRemoveInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
770
+ removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
771
+ updateUserQuoteAssetInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
772
+ getUpdateUserQuoteAssetInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
773
+ updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams, env?: DriftEnv): Promise<TransactionSignature>;
774
+ getUpdateUserGovTokenInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
775
+ getUpdateUserGovTokenInsuranceStakeDevnetIx(authority: PublicKey, amount?: BN): Promise<TransactionInstruction>;
776
+ settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
777
+ getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
778
+ resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
779
+ getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
780
+ getDepositIntoSpotMarketRevenuePoolIx(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
781
+ /**
782
+ * This ix will donate your funds to drift revenue pool. It does not deposit into your user account
783
+ * @param marketIndex
784
+ * @param amount
785
+ * @param userTokenAccountPublicKey
786
+ * @returns
787
+ */
788
+ depositIntoSpotMarketRevenuePool(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionSignature>;
789
+ getPerpMarketExtendedInfo(marketIndex: number): PerpMarketExtendedInfo;
790
+ /**
791
+ * Calculates taker / maker fee (as a percentage, e.g. .001 = 10 basis points) for particular marketType
792
+ * @param marketType
793
+ * @param positionMarketIndex
794
+ * @returns : {takerFee: number, makerFee: number} Precision None
795
+ */
796
+ getMarketFees(marketType: MarketType, marketIndex?: number, user?: User): {
797
+ takerFee: number;
798
+ makerFee: number;
799
+ };
800
+ /**
801
+ * Returns the market index and type for a given market name
802
+ * E.g. "SOL-PERP" -> { marketIndex: 0, marketType: MarketType.PERP }
803
+ *
804
+ * @param name
805
+ */
806
+ getMarketIndexAndType(name: string): {
807
+ marketIndex: number;
808
+ marketType: MarketType;
809
+ } | undefined;
810
+ getReceiverProgram(): Program<PythSolanaReceiver>;
811
+ getSwitchboardOnDemandProgram(): Promise<Program30<Idl30>>;
812
+ postPythPullOracleUpdateAtomic(vaaString: string, feedId: string): Promise<TransactionSignature>;
813
+ postMultiPythPullOracleUpdatesAtomic(vaaString: string, feedIds: string[]): Promise<TransactionSignature>;
814
+ getPostPythPullOracleUpdateAtomicIxs(vaaString: string, feedIds: string | string[], numSignatures?: number): Promise<TransactionInstruction[]>;
815
+ private getSinglePostPythPullOracleAtomicIx;
816
+ updatePythPullOracle(vaaString: string, feedId: string): Promise<TransactionSignature>;
817
+ getUpdatePythPullOracleIxs(params: {
818
+ merklePriceUpdate: {
819
+ message: Buffer;
820
+ proof: number[][];
821
+ };
822
+ }, feedId: string, encodedVaaAddress: PublicKey): Promise<TransactionInstruction>;
823
+ postPythLazerOracleUpdate(feedIds: number[], pythMessageHex: string): Promise<string>;
824
+ getPostPythLazerOracleUpdateIxs(feedIds: number[], pythMessageHex: string, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): TransactionInstruction[];
825
+ getPostSwitchboardOnDemandUpdateAtomicIx(feed: PublicKey, recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionInstruction | undefined>;
826
+ postSwitchboardOnDemandUpdate(feed: PublicKey, recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionSignature>;
827
+ private getBuildEncodedVaaIxs;
828
+ enableUserHighLeverageMode(subAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
829
+ getEnableHighLeverageModeIx(subAccountId: number, depositToTradeArgs?: {
830
+ isMakingNewAccount: boolean;
831
+ depositMarketIndex: number;
832
+ orderMarketIndex: number;
833
+ }): Promise<TransactionInstruction>;
834
+ disableUserHighLeverageMode(user: PublicKey, userAccount?: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
835
+ getDisableHighLeverageModeIx(user: PublicKey, userAccount?: UserAccount): Promise<TransactionInstruction>;
836
+ fetchHighLeverageModeConfig(): Promise<HighLeverageModeConfig>;
837
+ private handleSignedTransaction;
838
+ private handlePreSignedTransaction;
839
+ private isVersionedTransaction;
840
+ /**
841
+ * Send a transaction.
842
+ *
843
+ * @param tx
844
+ * @param additionalSigners
845
+ * @param opts :: Will fallback to DriftClient's opts if not provided
846
+ * @param preSigned
847
+ * @returns
848
+ */
849
+ sendTransaction(tx: Transaction | VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
850
+ buildTransaction(instructions: TransactionInstruction | TransactionInstruction[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean, recentBlockhash?: BlockhashWithExpiryBlockHeight): Promise<Transaction | VersionedTransaction>;
851
+ buildBulkTransactions(instructions: (TransactionInstruction | TransactionInstruction[])[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<(Transaction | VersionedTransaction)[]>;
852
+ buildTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<MappedRecord<Record<string, anchor.web3.TransactionInstruction | anchor.web3.TransactionInstruction[]>, anchor.web3.Transaction | anchor.web3.VersionedTransaction>>;
853
+ buildAndSignTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<{
854
+ signedTxMap: Record<string, anchor.web3.Transaction>;
855
+ signedTxData: SignedTxData[];
856
+ } | {
857
+ signedTxMap: MappedRecord<Record<string, anchor.web3.TransactionInstruction | anchor.web3.TransactionInstruction[]>, anchor.web3.Transaction | anchor.web3.VersionedTransaction>;
858
+ signedTxData: SignedTxData[];
859
+ }>;
860
+ }
861
+ export {};