@drift-labs/common 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/lib/Config.d.ts +26 -0
  2. package/lib/Config.js +29 -0
  3. package/lib/Config.js.map +1 -0
  4. package/lib/EnvironmentConstants.d.ts +40 -0
  5. package/lib/EnvironmentConstants.js +64 -0
  6. package/lib/EnvironmentConstants.js.map +1 -0
  7. package/lib/actions/actionHelpers/accountDeletionHelpers.d.ts +16 -0
  8. package/lib/actions/actionHelpers/accountDeletionHelpers.js +151 -0
  9. package/lib/actions/actionHelpers/accountDeletionHelpers.js.map +1 -0
  10. package/lib/actions/actionHelpers/actionHelpers.d.ts +13 -0
  11. package/lib/actions/actionHelpers/actionHelpers.js +8 -0
  12. package/lib/actions/actionHelpers/actionHelpers.js.map +1 -0
  13. package/lib/chartConstants.d.ts +2 -0
  14. package/lib/chartConstants.js +14 -0
  15. package/lib/chartConstants.js.map +1 -0
  16. package/lib/clients/candleClient.d.ts +74 -0
  17. package/lib/clients/candleClient.js +364 -0
  18. package/lib/clients/candleClient.js.map +1 -0
  19. package/lib/clients/dataApiWsClient.d.ts +33 -0
  20. package/lib/clients/dataApiWsClient.js +118 -0
  21. package/lib/clients/dataApiWsClient.js.map +1 -0
  22. package/lib/clients/index.d.ts +1 -0
  23. package/lib/clients/index.js +19 -0
  24. package/lib/clients/index.js.map +1 -0
  25. package/lib/clients/marketDataFeed.d.ts +42 -0
  26. package/lib/clients/marketDataFeed.js +422 -0
  27. package/lib/clients/marketDataFeed.js.map +1 -0
  28. package/lib/clients/redisClient.d.ts +89 -0
  29. package/lib/clients/redisClient.js +647 -0
  30. package/lib/clients/redisClient.js.map +1 -0
  31. package/lib/clients/swiftClient.d.ts +57 -0
  32. package/lib/clients/swiftClient.js +289 -0
  33. package/lib/clients/swiftClient.js.map +1 -0
  34. package/lib/clients/tvFeed.d.ts +63 -0
  35. package/lib/clients/tvFeed.js +351 -0
  36. package/lib/clients/tvFeed.js.map +1 -0
  37. package/lib/common-ui-utils/commonUiUtils.d.ts +211 -0
  38. package/lib/common-ui-utils/commonUiUtils.js +624 -0
  39. package/lib/common-ui-utils/commonUiUtils.js.map +1 -0
  40. package/lib/common-ui-utils/index.d.ts +6 -0
  41. package/lib/common-ui-utils/index.js +23 -0
  42. package/lib/common-ui-utils/index.js.map +1 -0
  43. package/lib/common-ui-utils/market.d.ts +27 -0
  44. package/lib/common-ui-utils/market.js +80 -0
  45. package/lib/common-ui-utils/market.js.map +1 -0
  46. package/lib/common-ui-utils/order.d.ts +11 -0
  47. package/lib/common-ui-utils/order.js +161 -0
  48. package/lib/common-ui-utils/order.js.map +1 -0
  49. package/lib/common-ui-utils/settings/settings.d.ts +51 -0
  50. package/lib/common-ui-utils/settings/settings.js +84 -0
  51. package/lib/common-ui-utils/settings/settings.js.map +1 -0
  52. package/lib/common-ui-utils/trading.d.ts +56 -0
  53. package/lib/common-ui-utils/trading.js +200 -0
  54. package/lib/common-ui-utils/trading.js.map +1 -0
  55. package/lib/common-ui-utils/user.d.ts +13 -0
  56. package/lib/common-ui-utils/user.js +124 -0
  57. package/lib/common-ui-utils/user.js.map +1 -0
  58. package/lib/constants/autogenerated/driftErrors.json +1787 -0
  59. package/lib/constants/autogenerated/jup-v4-error-codes.json +67 -0
  60. package/lib/constants/autogenerated/jup-v6-error-codes.json +115 -0
  61. package/lib/constants/dev.d.ts +15 -0
  62. package/lib/constants/dev.js +19 -0
  63. package/lib/constants/dev.js.map +1 -0
  64. package/lib/constants/geoblockList.d.ts +4 -0
  65. package/lib/constants/geoblockList.js +32 -0
  66. package/lib/constants/geoblockList.js.map +1 -0
  67. package/lib/constants/index.d.ts +9 -0
  68. package/lib/constants/index.js +26 -0
  69. package/lib/constants/index.js.map +1 -0
  70. package/lib/constants/markets.d.ts +1 -0
  71. package/lib/constants/markets.js +5 -0
  72. package/lib/constants/markets.js.map +1 -0
  73. package/lib/constants/misc.d.ts +23 -0
  74. package/lib/constants/misc.js +27 -0
  75. package/lib/constants/misc.js.map +1 -0
  76. package/lib/constants/orders.d.ts +12 -0
  77. package/lib/constants/orders.js +79 -0
  78. package/lib/constants/orders.js.map +1 -0
  79. package/lib/constants/pools.d.ts +5 -0
  80. package/lib/constants/pools.js +9 -0
  81. package/lib/constants/pools.js.map +1 -0
  82. package/lib/constants/predictionMarket.d.ts +3 -0
  83. package/lib/constants/predictionMarket.js +7 -0
  84. package/lib/constants/predictionMarket.js.map +1 -0
  85. package/lib/constants/superstake.d.ts +22 -0
  86. package/lib/constants/superstake.js +45 -0
  87. package/lib/constants/superstake.js.map +1 -0
  88. package/lib/constants/trade.d.ts +2 -0
  89. package/lib/constants/trade.js +9 -0
  90. package/lib/constants/trade.js.map +1 -0
  91. package/lib/drift/Drift/clients/AuthorityDrift/DriftL2OrderbookManager.d.ts +68 -0
  92. package/lib/drift/Drift/clients/AuthorityDrift/DriftL2OrderbookManager.js +146 -0
  93. package/lib/drift/Drift/clients/AuthorityDrift/DriftL2OrderbookManager.js.map +1 -0
  94. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.d.ts +204 -0
  95. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js +530 -0
  96. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js.map +1 -0
  97. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.d.ts +90 -0
  98. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.js +3 -0
  99. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.js.map +1 -0
  100. package/lib/drift/Drift/clients/AuthorityDrift/SubscriptionManager.d.ts +139 -0
  101. package/lib/drift/Drift/clients/AuthorityDrift/SubscriptionManager.js +287 -0
  102. package/lib/drift/Drift/clients/AuthorityDrift/SubscriptionManager.js.map +1 -0
  103. package/lib/drift/Drift/clients/AuthorityDrift/index.d.ts +242 -0
  104. package/lib/drift/Drift/clients/AuthorityDrift/index.js +503 -0
  105. package/lib/drift/Drift/clients/AuthorityDrift/index.js.map +1 -0
  106. package/lib/drift/Drift/clients/CentralServerDrift.d.ts +91 -0
  107. package/lib/drift/Drift/clients/CentralServerDrift.js +326 -0
  108. package/lib/drift/Drift/clients/CentralServerDrift.js.map +1 -0
  109. package/lib/drift/Drift/clients/index.d.ts +3 -0
  110. package/lib/drift/Drift/clients/index.js +20 -0
  111. package/lib/drift/Drift/clients/index.js.map +1 -0
  112. package/lib/drift/Drift/constants/blockchain.d.ts +24 -0
  113. package/lib/drift/Drift/constants/blockchain.js +32 -0
  114. package/lib/drift/Drift/constants/blockchain.js.map +1 -0
  115. package/lib/drift/Drift/constants/errors.d.ts +6 -0
  116. package/lib/drift/Drift/constants/errors.js +14 -0
  117. package/lib/drift/Drift/constants/errors.js.map +1 -0
  118. package/lib/drift/Drift/constants/index.d.ts +3 -0
  119. package/lib/drift/Drift/constants/index.js +20 -0
  120. package/lib/drift/Drift/constants/index.js.map +1 -0
  121. package/lib/drift/Drift/constants/orderbook.d.ts +7 -0
  122. package/lib/drift/Drift/constants/orderbook.js +10 -0
  123. package/lib/drift/Drift/constants/orderbook.js.map +1 -0
  124. package/lib/drift/Drift/data/PollingDlob.d.ts +154 -0
  125. package/lib/drift/Drift/data/PollingDlob.js +387 -0
  126. package/lib/drift/Drift/data/PollingDlob.js.map +1 -0
  127. package/lib/drift/Drift/data/index.d.ts +1 -0
  128. package/lib/drift/Drift/data/index.js +18 -0
  129. package/lib/drift/Drift/data/index.js.map +1 -0
  130. package/lib/drift/Drift/index.d.ts +4 -0
  131. package/lib/drift/Drift/index.js +21 -0
  132. package/lib/drift/Drift/index.js.map +1 -0
  133. package/lib/drift/Drift/stores/MarkPriceCache.d.ts +27 -0
  134. package/lib/drift/Drift/stores/MarkPriceCache.js +59 -0
  135. package/lib/drift/Drift/stores/MarkPriceCache.js.map +1 -0
  136. package/lib/drift/Drift/stores/OraclePriceCache.d.ts +21 -0
  137. package/lib/drift/Drift/stores/OraclePriceCache.js +57 -0
  138. package/lib/drift/Drift/stores/OraclePriceCache.js.map +1 -0
  139. package/lib/drift/Drift/stores/UserAccountCache.d.ts +49 -0
  140. package/lib/drift/Drift/stores/UserAccountCache.js +107 -0
  141. package/lib/drift/Drift/stores/UserAccountCache.js.map +1 -0
  142. package/lib/drift/Drift/stores/index.d.ts +3 -0
  143. package/lib/drift/Drift/stores/index.js +20 -0
  144. package/lib/drift/Drift/stores/index.js.map +1 -0
  145. package/lib/drift/base/actions/index.d.ts +4 -0
  146. package/lib/drift/base/actions/index.js +21 -0
  147. package/lib/drift/base/actions/index.js.map +1 -0
  148. package/lib/drift/base/actions/perp/index.d.ts +2 -0
  149. package/lib/drift/base/actions/perp/index.js +19 -0
  150. package/lib/drift/base/actions/perp/index.js.map +1 -0
  151. package/lib/drift/base/actions/perp/settleFunding.d.ts +25 -0
  152. package/lib/drift/base/actions/perp/settleFunding.js +41 -0
  153. package/lib/drift/base/actions/perp/settleFunding.js.map +1 -0
  154. package/lib/drift/base/actions/perp/settlePnl.d.ts +35 -0
  155. package/lib/drift/base/actions/perp/settlePnl.js +44 -0
  156. package/lib/drift/base/actions/perp/settlePnl.js.map +1 -0
  157. package/lib/drift/base/actions/spot/borrow.d.ts +1 -0
  158. package/lib/drift/base/actions/spot/borrow.js +8 -0
  159. package/lib/drift/base/actions/spot/borrow.js.map +1 -0
  160. package/lib/drift/base/actions/spot/deposit.d.ts +40 -0
  161. package/lib/drift/base/actions/spot/deposit.js +82 -0
  162. package/lib/drift/base/actions/spot/deposit.js.map +1 -0
  163. package/lib/drift/base/actions/spot/index.d.ts +3 -0
  164. package/lib/drift/base/actions/spot/index.js +20 -0
  165. package/lib/drift/base/actions/spot/index.js.map +1 -0
  166. package/lib/drift/base/actions/spot/withdraw.d.ts +16 -0
  167. package/lib/drift/base/actions/spot/withdraw.js +39 -0
  168. package/lib/drift/base/actions/spot/withdraw.js.map +1 -0
  169. package/lib/drift/base/actions/trade/cancelOrder.d.ts +47 -0
  170. package/lib/drift/base/actions/trade/cancelOrder.js +55 -0
  171. package/lib/drift/base/actions/trade/cancelOrder.js.map +1 -0
  172. package/lib/drift/base/actions/trade/editOrder.d.ts +55 -0
  173. package/lib/drift/base/actions/trade/editOrder.js +35 -0
  174. package/lib/drift/base/actions/trade/editOrder.js.map +1 -0
  175. package/lib/drift/base/actions/trade/index.d.ts +4 -0
  176. package/lib/drift/base/actions/trade/index.js +21 -0
  177. package/lib/drift/base/actions/trade/index.js.map +1 -0
  178. package/lib/drift/base/actions/trade/openPerpOrder/index.d.ts +3 -0
  179. package/lib/drift/base/actions/trade/openPerpOrder/index.js +20 -0
  180. package/lib/drift/base/actions/trade/openPerpOrder/index.js.map +1 -0
  181. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.d.ts +84 -0
  182. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js +293 -0
  183. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js.map +1 -0
  184. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.d.ts +19 -0
  185. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js +161 -0
  186. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js.map +1 -0
  187. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.d.ts +166 -0
  188. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js +156 -0
  189. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js.map +1 -0
  190. package/lib/drift/base/actions/trade/swap.d.ts +62 -0
  191. package/lib/drift/base/actions/trade/swap.js +60 -0
  192. package/lib/drift/base/actions/trade/swap.js.map +1 -0
  193. package/lib/drift/base/actions/user/create.d.ts +75 -0
  194. package/lib/drift/base/actions/user/create.js +104 -0
  195. package/lib/drift/base/actions/user/create.js.map +1 -0
  196. package/lib/drift/base/actions/user/delete.d.ts +47 -0
  197. package/lib/drift/base/actions/user/delete.js +39 -0
  198. package/lib/drift/base/actions/user/delete.js.map +1 -0
  199. package/lib/drift/base/actions/user/index.d.ts +1 -0
  200. package/lib/drift/base/actions/user/index.js +18 -0
  201. package/lib/drift/base/actions/user/index.js.map +1 -0
  202. package/lib/drift/base/constants/accountNames.d.ts +1 -0
  203. package/lib/drift/base/constants/accountNames.js +13 -0
  204. package/lib/drift/base/constants/accountNames.js.map +1 -0
  205. package/lib/drift/base/details/index.d.ts +2 -0
  206. package/lib/drift/base/details/index.js +19 -0
  207. package/lib/drift/base/details/index.js.map +1 -0
  208. package/lib/drift/base/details/market/funding.d.ts +9 -0
  209. package/lib/drift/base/details/market/funding.js +50 -0
  210. package/lib/drift/base/details/market/funding.js.map +1 -0
  211. package/lib/drift/base/details/market/index.d.ts +2 -0
  212. package/lib/drift/base/details/market/index.js +19 -0
  213. package/lib/drift/base/details/market/index.js.map +1 -0
  214. package/lib/drift/base/details/market/openInterest.d.ts +5 -0
  215. package/lib/drift/base/details/market/openInterest.js +12 -0
  216. package/lib/drift/base/details/market/openInterest.js.map +1 -0
  217. package/lib/drift/base/details/user/balances.d.ts +40 -0
  218. package/lib/drift/base/details/user/balances.js +39 -0
  219. package/lib/drift/base/details/user/balances.js.map +1 -0
  220. package/lib/drift/base/details/user/index.d.ts +4 -0
  221. package/lib/drift/base/details/user/index.js +21 -0
  222. package/lib/drift/base/details/user/index.js.map +1 -0
  223. package/lib/drift/base/details/user/marginInfo.d.ts +29 -0
  224. package/lib/drift/base/details/user/marginInfo.js +49 -0
  225. package/lib/drift/base/details/user/marginInfo.js.map +1 -0
  226. package/lib/drift/base/details/user/orders.d.ts +3 -0
  227. package/lib/drift/base/details/user/orders.js +11 -0
  228. package/lib/drift/base/details/user/orders.js.map +1 -0
  229. package/lib/drift/base/details/user/positions.d.ts +70 -0
  230. package/lib/drift/base/details/user/positions.js +146 -0
  231. package/lib/drift/base/details/user/positions.js.map +1 -0
  232. package/lib/drift/cli.d.ts +25 -0
  233. package/lib/drift/cli.js +900 -0
  234. package/lib/drift/cli.js.map +1 -0
  235. package/lib/drift/constants/apiUrls.d.ts +27 -0
  236. package/lib/drift/constants/apiUrls.js +31 -0
  237. package/lib/drift/constants/apiUrls.js.map +1 -0
  238. package/lib/drift/example.d.ts +19 -0
  239. package/lib/drift/example.js +249 -0
  240. package/lib/drift/example.js.map +1 -0
  241. package/lib/drift/index.d.ts +3 -0
  242. package/lib/drift/index.js +20 -0
  243. package/lib/drift/index.js.map +1 -0
  244. package/lib/drift/utils/auctionParamsResponseMapper.d.ts +45 -0
  245. package/lib/drift/utils/auctionParamsResponseMapper.js +148 -0
  246. package/lib/drift/utils/auctionParamsResponseMapper.js.map +1 -0
  247. package/lib/drift/utils/funding.d.ts +2 -0
  248. package/lib/drift/utils/funding.js +9 -0
  249. package/lib/drift/utils/funding.js.map +1 -0
  250. package/lib/drift/utils/index.d.ts +3 -0
  251. package/lib/drift/utils/index.js +23 -0
  252. package/lib/drift/utils/index.js.map +1 -0
  253. package/lib/drift/utils/orderParams.d.ts +48 -0
  254. package/lib/drift/utils/orderParams.js +140 -0
  255. package/lib/drift/utils/orderParams.js.map +1 -0
  256. package/lib/index.d.ts +45 -0
  257. package/lib/index.js +68 -0
  258. package/lib/index.js.map +1 -0
  259. package/lib/serializableTypes.d.ts +961 -0
  260. package/lib/serializableTypes.js +3887 -0
  261. package/lib/serializableTypes.js.map +1 -0
  262. package/lib/types/MarketId.d.ts +26 -0
  263. package/lib/types/MarketId.js +64 -0
  264. package/lib/types/MarketId.js.map +1 -0
  265. package/lib/types/Superstake.d.ts +7 -0
  266. package/lib/types/Superstake.js +3 -0
  267. package/lib/types/Superstake.js.map +1 -0
  268. package/lib/types/UIEnv.d.ts +26 -0
  269. package/lib/types/UIEnv.js +49 -0
  270. package/lib/types/UIEnv.js.map +1 -0
  271. package/lib/types/UIMarket.d.ts +94 -0
  272. package/lib/types/UIMarket.js +224 -0
  273. package/lib/types/UIMarket.js.map +1 -0
  274. package/lib/types/candles.d.ts +4 -0
  275. package/lib/types/candles.js +9 -0
  276. package/lib/types/candles.js.map +1 -0
  277. package/lib/types/dataServer.d.ts +53 -0
  278. package/lib/types/dataServer.js +3 -0
  279. package/lib/types/dataServer.js.map +1 -0
  280. package/lib/types/historyServer.d.ts +38 -0
  281. package/lib/types/historyServer.js +11 -0
  282. package/lib/types/historyServer.js.map +1 -0
  283. package/lib/types/index.d.ts +12 -0
  284. package/lib/types/index.js +29 -0
  285. package/lib/types/index.js.map +1 -0
  286. package/lib/types/leaderboard.d.ts +80 -0
  287. package/lib/types/leaderboard.js +11 -0
  288. package/lib/types/leaderboard.js.map +1 -0
  289. package/lib/types/remote-configs.d.ts +61 -0
  290. package/lib/types/remote-configs.js +3 -0
  291. package/lib/types/remote-configs.js.map +1 -0
  292. package/lib/types/trade.d.ts +18 -0
  293. package/lib/types/trade.js +3 -0
  294. package/lib/types/trade.js.map +1 -0
  295. package/lib/types/user.d.ts +40 -0
  296. package/lib/types/user.js +3 -0
  297. package/lib/types/user.js.map +1 -0
  298. package/lib/types/utility.d.ts +15 -0
  299. package/lib/types/utility.js +3 -0
  300. package/lib/types/utility.js.map +1 -0
  301. package/lib/utils/CircularBuffers/CircularBuffer.d.ts +22 -0
  302. package/lib/utils/CircularBuffers/CircularBuffer.js +73 -0
  303. package/lib/utils/CircularBuffers/CircularBuffer.js.map +1 -0
  304. package/lib/utils/CircularBuffers/UniqueCircularBuffer.d.ts +19 -0
  305. package/lib/utils/CircularBuffers/UniqueCircularBuffer.js +78 -0
  306. package/lib/utils/CircularBuffers/UniqueCircularBuffer.js.map +1 -0
  307. package/lib/utils/CircularBuffers/index.d.ts +2 -0
  308. package/lib/utils/CircularBuffers/index.js +19 -0
  309. package/lib/utils/CircularBuffers/index.js.map +1 -0
  310. package/lib/utils/MultiplexWebSocket.d.ts +95 -0
  311. package/lib/utils/MultiplexWebSocket.js +416 -0
  312. package/lib/utils/MultiplexWebSocket.js.map +1 -0
  313. package/lib/utils/NumLib.d.ts +106 -0
  314. package/lib/utils/NumLib.js +300 -0
  315. package/lib/utils/NumLib.js.map +1 -0
  316. package/lib/utils/SharedInterval.d.ts +21 -0
  317. package/lib/utils/SharedInterval.js +47 -0
  318. package/lib/utils/SharedInterval.js.map +1 -0
  319. package/lib/utils/SlotBasedResultValidator.d.ts +9 -0
  320. package/lib/utils/SlotBasedResultValidator.js +27 -0
  321. package/lib/utils/SlotBasedResultValidator.js.map +1 -0
  322. package/lib/utils/Stopwatch.d.ts +15 -0
  323. package/lib/utils/Stopwatch.js +31 -0
  324. package/lib/utils/Stopwatch.js.map +1 -0
  325. package/lib/utils/StrictEventEmitter.d.ts +15 -0
  326. package/lib/utils/StrictEventEmitter.js +55 -0
  327. package/lib/utils/StrictEventEmitter.js.map +1 -0
  328. package/lib/utils/WalletConnectionState.d.ts +31 -0
  329. package/lib/utils/WalletConnectionState.js +83 -0
  330. package/lib/utils/WalletConnectionState.js.map +1 -0
  331. package/lib/utils/assert.d.ts +1 -0
  332. package/lib/utils/assert.js +10 -0
  333. package/lib/utils/assert.js.map +1 -0
  334. package/lib/utils/candles/Candle.d.ts +94 -0
  335. package/lib/utils/candles/Candle.js +580 -0
  336. package/lib/utils/candles/Candle.js.map +1 -0
  337. package/lib/utils/candles/types.d.ts +8 -0
  338. package/lib/utils/candles/types.js +3 -0
  339. package/lib/utils/candles/types.js.map +1 -0
  340. package/lib/utils/dlob-server/DlobServerWebsocketUtils.d.ts +57 -0
  341. package/lib/utils/dlob-server/DlobServerWebsocketUtils.js +137 -0
  342. package/lib/utils/dlob-server/DlobServerWebsocketUtils.js.map +1 -0
  343. package/lib/utils/driftEvents.d.ts +10 -0
  344. package/lib/utils/driftEvents.js +123 -0
  345. package/lib/utils/driftEvents.js.map +1 -0
  346. package/lib/utils/equalityChecks.d.ts +12 -0
  347. package/lib/utils/equalityChecks.js +71 -0
  348. package/lib/utils/equalityChecks.js.map +1 -0
  349. package/lib/utils/featureFlags.d.ts +3 -0
  350. package/lib/utils/featureFlags.js +7 -0
  351. package/lib/utils/featureFlags.js.map +1 -0
  352. package/lib/utils/geoblock/index.d.ts +4 -0
  353. package/lib/utils/geoblock/index.js +20 -0
  354. package/lib/utils/geoblock/index.js.map +1 -0
  355. package/lib/utils/index.d.ts +181 -0
  356. package/lib/utils/index.js +608 -0
  357. package/lib/utils/index.js.map +1 -0
  358. package/lib/utils/insuranceFund.d.ts +15 -0
  359. package/lib/utils/insuranceFund.js +84 -0
  360. package/lib/utils/insuranceFund.js.map +1 -0
  361. package/lib/utils/logger.d.ts +5 -0
  362. package/lib/utils/logger.js +53 -0
  363. package/lib/utils/logger.js.map +1 -0
  364. package/lib/utils/math.d.ts +10 -0
  365. package/lib/utils/math.js +89 -0
  366. package/lib/utils/math.js.map +1 -0
  367. package/lib/utils/orderbook/index.d.ts +65 -0
  368. package/lib/utils/orderbook/index.js +80 -0
  369. package/lib/utils/orderbook/index.js.map +1 -0
  370. package/lib/utils/pollingSequenceGuard.d.ts +9 -0
  371. package/lib/utils/pollingSequenceGuard.js +24 -0
  372. package/lib/utils/pollingSequenceGuard.js.map +1 -0
  373. package/lib/utils/priority-fees/PriorityFeeCalculator.d.ts +24 -0
  374. package/lib/utils/priority-fees/PriorityFeeCalculator.js +53 -0
  375. package/lib/utils/priority-fees/PriorityFeeCalculator.js.map +1 -0
  376. package/lib/utils/priority-fees/PriorityFeeStrategies.d.ts +5 -0
  377. package/lib/utils/priority-fees/PriorityFeeStrategies.js +43 -0
  378. package/lib/utils/priority-fees/PriorityFeeStrategies.js.map +1 -0
  379. package/lib/utils/priority-fees/index.d.ts +2 -0
  380. package/lib/utils/priority-fees/index.js +19 -0
  381. package/lib/utils/priority-fees/index.js.map +1 -0
  382. package/lib/utils/priorityFees.d.ts +14 -0
  383. package/lib/utils/priorityFees.js +68 -0
  384. package/lib/utils/priorityFees.js.map +1 -0
  385. package/lib/utils/rpcLatency.d.ts +7 -0
  386. package/lib/utils/rpcLatency.js +49 -0
  387. package/lib/utils/rpcLatency.js.map +1 -0
  388. package/lib/utils/rxjs.d.ts +11 -0
  389. package/lib/utils/rxjs.js +24 -0
  390. package/lib/utils/rxjs.js.map +1 -0
  391. package/lib/utils/s3Buckets.d.ts +43 -0
  392. package/lib/utils/s3Buckets.js +108 -0
  393. package/lib/utils/s3Buckets.js.map +1 -0
  394. package/lib/utils/superstake.d.ts +86 -0
  395. package/lib/utils/superstake.js +224 -0
  396. package/lib/utils/superstake.js.map +1 -0
  397. package/lib/utils/token.d.ts +16 -0
  398. package/lib/utils/token.js +44 -0
  399. package/lib/utils/token.js.map +1 -0
  400. package/package.json +87 -0
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBorrowIx = void 0;
4
+ const createBorrowIx = async () => {
5
+ // TODO:
6
+ };
7
+ exports.createBorrowIx = createBorrowIx;
8
+ //# sourceMappingURL=borrow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"borrow.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/spot/borrow.ts"],"names":[],"mappings":";;;AAAO,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE;IACxC,QAAQ;AACT,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB","sourcesContent":["export const createBorrowIx = async () => {\n\t// TODO:\n};\n"]}
@@ -0,0 +1,40 @@
1
+ import { BigNum, DriftClient, SpotMarketConfig, TxParams, User } from '@drift-labs/sdk';
2
+ import { Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
3
+ interface CreateDepositIxParams {
4
+ driftClient: DriftClient;
5
+ user: User;
6
+ amount: BigNum;
7
+ spotMarketConfig: Pick<SpotMarketConfig, 'mint' | 'marketIndex'>;
8
+ isMaxBorrowRepayment?: boolean;
9
+ }
10
+ /**
11
+ * Creates transaction instructions for depositing a spot token.
12
+ *
13
+ * @param driftClient - The Drift client instance for interacting with the protocol
14
+ * @param user - The user account that will perform the deposit
15
+ * @param amount - The amount to deposit (in BigNum format)
16
+ * @param spotMarketConfig - The spot market configuration for the token being deposited
17
+ * @param isMaxBorrowRepayment - Whether this deposit is for maximum borrow repayment (scales amount by 2x, set to reduce only)
18
+ *
19
+ * @returns Promise resolving to an array of transaction instructions for the deposit
20
+ */
21
+ export declare const createDepositIxs: ({ driftClient, user, amount, spotMarketConfig, isMaxBorrowRepayment, }: CreateDepositIxParams) => Promise<TransactionInstruction[]>;
22
+ interface CreateDepositTxnParams extends CreateDepositIxParams {
23
+ txParams?: TxParams;
24
+ initSwiftAccount?: boolean;
25
+ }
26
+ /**
27
+ * Creates a complete transaction for depositing assets into a spot market.
28
+ *
29
+ * @param driftClient - The Drift client instance for interacting with the protocol
30
+ * @param user - The user account that will perform the deposit
31
+ * @param amount - The amount to deposit (in BigNum format)
32
+ * @param spotMarketConfig - The spot market configuration for the token being deposited
33
+ * @param isMaxBorrowRepayment - Whether this deposit is for maximum borrow repayment (scales amount by 2x)
34
+ * @param txParams - Optional transaction parameters for building the transaction (compute units, priority fees, etc.)
35
+ * @param initSwiftAccount - Optional flag to initialize a Swift account during the deposit
36
+ *
37
+ * @returns Promise resolving to a built transaction ready for signing (Transaction or VersionedTransaction)
38
+ */
39
+ export declare const createDepositTxn: ({ driftClient, user, amount, spotMarketConfig, isMaxBorrowRepayment, txParams: _txParams, initSwiftAccount: _initSwiftAccount, }: CreateDepositTxnParams) => Promise<Transaction | VersionedTransaction>;
40
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDepositTxn = exports.createDepositIxs = void 0;
4
+ const token_1 = require("../../../../utils/token");
5
+ /**
6
+ * Creates transaction instructions for depositing a spot token.
7
+ *
8
+ * @param driftClient - The Drift client instance for interacting with the protocol
9
+ * @param user - The user account that will perform the deposit
10
+ * @param amount - The amount to deposit (in BigNum format)
11
+ * @param spotMarketConfig - The spot market configuration for the token being deposited
12
+ * @param isMaxBorrowRepayment - Whether this deposit is for maximum borrow repayment (scales amount by 2x, set to reduce only)
13
+ *
14
+ * @returns Promise resolving to an array of transaction instructions for the deposit
15
+ */
16
+ const createDepositIxs = async ({ driftClient, user, amount, spotMarketConfig, isMaxBorrowRepayment, }) => {
17
+ const authority = user.getUserAccount().authority;
18
+ const associatedDepositTokenAddress = await (0, token_1.getTokenAddressForDepositAndWithdraw)(spotMarketConfig.mint, authority);
19
+ let finalDepositAmount = amount;
20
+ if (isMaxBorrowRepayment) {
21
+ // we over-estimate to ensure that there is no borrow dust left
22
+ // since isMaxBorrowRepayment = reduceOnly, it is safe to over-estimate
23
+ finalDepositAmount = finalDepositAmount.scale(2, 1);
24
+ }
25
+ const depositIxs = await driftClient.getDepositTxnIx(finalDepositAmount.val, spotMarketConfig.marketIndex, associatedDepositTokenAddress, user.getUserAccount().subAccountId, isMaxBorrowRepayment);
26
+ return depositIxs;
27
+ };
28
+ exports.createDepositIxs = createDepositIxs;
29
+ /**
30
+ * Creates a complete transaction for depositing assets into a spot market.
31
+ *
32
+ * @param driftClient - The Drift client instance for interacting with the protocol
33
+ * @param user - The user account that will perform the deposit
34
+ * @param amount - The amount to deposit (in BigNum format)
35
+ * @param spotMarketConfig - The spot market configuration for the token being deposited
36
+ * @param isMaxBorrowRepayment - Whether this deposit is for maximum borrow repayment (scales amount by 2x)
37
+ * @param txParams - Optional transaction parameters for building the transaction (compute units, priority fees, etc.)
38
+ * @param initSwiftAccount - Optional flag to initialize a Swift account during the deposit
39
+ *
40
+ * @returns Promise resolving to a built transaction ready for signing (Transaction or VersionedTransaction)
41
+ */
42
+ const createDepositTxn = async ({ driftClient, user, amount, spotMarketConfig, isMaxBorrowRepayment, txParams: _txParams, initSwiftAccount: _initSwiftAccount, }) => {
43
+ // const authority = user.getUserAccount().authority;
44
+ // const associatedDepositTokenAddress =
45
+ // await getTokenAddressForDepositAndWithdraw(
46
+ // spotMarketConfig.mint,
47
+ // authority
48
+ // );
49
+ let finalDepositAmount = amount;
50
+ if (isMaxBorrowRepayment) {
51
+ // we over-estimate to ensure that there is no borrow dust left
52
+ // since isMaxBorrowRepayment = reduceOnly, it is safe to over-estimate
53
+ finalDepositAmount = finalDepositAmount.scale(2, 1);
54
+ }
55
+ // we choose to not use createDepositIxs here because it doesn't have the initSwiftAccount logic
56
+ // const depositTxn = await driftClient.createDepositTxn(
57
+ // finalDepositAmount.val,
58
+ // spotMarketConfig.marketIndex,
59
+ // associatedDepositTokenAddress,
60
+ // user.getUserAccount().subAccountId,
61
+ // isMaxBorrowRepayment,
62
+ // txParams,
63
+ // initSwiftAccount
64
+ // );
65
+ const depositIxs = await (0, exports.createDepositIxs)({
66
+ driftClient,
67
+ user,
68
+ amount: finalDepositAmount,
69
+ spotMarketConfig,
70
+ isMaxBorrowRepayment,
71
+ });
72
+ const depositTxn = await driftClient.txHandler.buildTransaction({
73
+ instructions: depositIxs,
74
+ txVersion: 0,
75
+ connection: driftClient.connection,
76
+ preFlightCommitment: 'confirmed',
77
+ fetchAllMarketLookupTableAccounts: driftClient.fetchAllLookupTableAccounts.bind(driftClient),
78
+ });
79
+ return depositTxn;
80
+ };
81
+ exports.createDepositTxn = createDepositTxn;
82
+ //# sourceMappingURL=deposit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/spot/deposit.ts"],"names":[],"mappings":";;;AAYA,mDAA+E;AAU/E;;;;;;;;;;GAUG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACtC,WAAW,EACX,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,GACG,EAAqC,EAAE;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC;IAClD,MAAM,6BAA6B,GAClC,MAAM,IAAA,4CAAoC,EACzC,gBAAgB,CAAC,IAAI,EACrB,SAAS,CACT,CAAC;IAEH,IAAI,kBAAkB,GAAG,MAAM,CAAC;IAEhC,IAAI,oBAAoB,EAAE,CAAC;QAC1B,+DAA+D;QAC/D,uEAAuE;QACvE,kBAAkB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,eAAe,CACnD,kBAAkB,CAAC,GAAG,EACtB,gBAAgB,CAAC,WAAW,EAC5B,6BAA6B,EAC7B,IAAI,CAAC,cAAc,EAAE,CAAC,YAAY,EAClC,oBAAoB,CACpB,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AA/BW,QAAA,gBAAgB,oBA+B3B;AAOF;;;;;;;;;;;;GAYG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACtC,WAAW,EACX,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EAAE,SAAS,EACnB,gBAAgB,EAAE,iBAAiB,GACX,EAA+C,EAAE;IACzE,qDAAqD;IACrD,wCAAwC;IACxC,+CAA+C;IAC/C,2BAA2B;IAC3B,cAAc;IACd,MAAM;IAEN,IAAI,kBAAkB,GAAG,MAAM,CAAC;IAEhC,IAAI,oBAAoB,EAAE,CAAC;QAC1B,+DAA+D;QAC/D,uEAAuE;QACvE,kBAAkB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,gGAAgG;IAChG,yDAAyD;IACzD,2BAA2B;IAC3B,iCAAiC;IACjC,kCAAkC;IAClC,uCAAuC;IACvC,yBAAyB;IACzB,aAAa;IACb,oBAAoB;IACpB,KAAK;IACL,MAAM,UAAU,GAAG,MAAM,IAAA,wBAAgB,EAAC;QACzC,WAAW;QACX,IAAI;QACJ,MAAM,EAAE,kBAAkB;QAC1B,gBAAgB;QAChB,oBAAoB;KACpB,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC;QAC/D,YAAY,EAAE,UAAU;QACxB,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,mBAAmB,EAAE,WAAW;QAChC,iCAAiC,EAChC,WAAW,CAAC,2BAA2B,CAAC,IAAI,CAAC,WAAW,CAAC;KAC1D,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AApDW,QAAA,gBAAgB,oBAoD3B","sourcesContent":["import {\n\tBigNum,\n\tDriftClient,\n\tSpotMarketConfig,\n\tTxParams,\n\tUser,\n} from '@drift-labs/sdk';\nimport {\n\tTransaction,\n\tTransactionInstruction,\n\tVersionedTransaction,\n} from '@solana/web3.js';\nimport { getTokenAddressForDepositAndWithdraw } from '../../../../utils/token';\n\ninterface CreateDepositIxParams {\n\tdriftClient: DriftClient;\n\tuser: User;\n\tamount: BigNum;\n\tspotMarketConfig: Pick<SpotMarketConfig, 'mint' | 'marketIndex'>;\n\tisMaxBorrowRepayment?: boolean;\n}\n\n/**\n * Creates transaction instructions for depositing a spot token.\n *\n * @param driftClient - The Drift client instance for interacting with the protocol\n * @param user - The user account that will perform the deposit\n * @param amount - The amount to deposit (in BigNum format)\n * @param spotMarketConfig - The spot market configuration for the token being deposited\n * @param isMaxBorrowRepayment - Whether this deposit is for maximum borrow repayment (scales amount by 2x, set to reduce only)\n *\n * @returns Promise resolving to an array of transaction instructions for the deposit\n */\nexport const createDepositIxs = async ({\n\tdriftClient,\n\tuser,\n\tamount,\n\tspotMarketConfig,\n\tisMaxBorrowRepayment,\n}: CreateDepositIxParams): Promise<TransactionInstruction[]> => {\n\tconst authority = user.getUserAccount().authority;\n\tconst associatedDepositTokenAddress =\n\t\tawait getTokenAddressForDepositAndWithdraw(\n\t\t\tspotMarketConfig.mint,\n\t\t\tauthority\n\t\t);\n\n\tlet finalDepositAmount = amount;\n\n\tif (isMaxBorrowRepayment) {\n\t\t// we over-estimate to ensure that there is no borrow dust left\n\t\t// since isMaxBorrowRepayment = reduceOnly, it is safe to over-estimate\n\t\tfinalDepositAmount = finalDepositAmount.scale(2, 1);\n\t}\n\n\tconst depositIxs = await driftClient.getDepositTxnIx(\n\t\tfinalDepositAmount.val,\n\t\tspotMarketConfig.marketIndex,\n\t\tassociatedDepositTokenAddress,\n\t\tuser.getUserAccount().subAccountId,\n\t\tisMaxBorrowRepayment\n\t);\n\n\treturn depositIxs;\n};\n\ninterface CreateDepositTxnParams extends CreateDepositIxParams {\n\ttxParams?: TxParams;\n\tinitSwiftAccount?: boolean;\n}\n\n/**\n * Creates a complete transaction for depositing assets into a spot market.\n *\n * @param driftClient - The Drift client instance for interacting with the protocol\n * @param user - The user account that will perform the deposit\n * @param amount - The amount to deposit (in BigNum format)\n * @param spotMarketConfig - The spot market configuration for the token being deposited\n * @param isMaxBorrowRepayment - Whether this deposit is for maximum borrow repayment (scales amount by 2x)\n * @param txParams - Optional transaction parameters for building the transaction (compute units, priority fees, etc.)\n * @param initSwiftAccount - Optional flag to initialize a Swift account during the deposit\n *\n * @returns Promise resolving to a built transaction ready for signing (Transaction or VersionedTransaction)\n */\nexport const createDepositTxn = async ({\n\tdriftClient,\n\tuser,\n\tamount,\n\tspotMarketConfig,\n\tisMaxBorrowRepayment,\n\ttxParams: _txParams,\n\tinitSwiftAccount: _initSwiftAccount,\n}: CreateDepositTxnParams): Promise<Transaction | VersionedTransaction> => {\n\t// const authority = user.getUserAccount().authority;\n\t// const associatedDepositTokenAddress =\n\t// \tawait getTokenAddressForDepositAndWithdraw(\n\t// \t\tspotMarketConfig.mint,\n\t// \t\tauthority\n\t// \t);\n\n\tlet finalDepositAmount = amount;\n\n\tif (isMaxBorrowRepayment) {\n\t\t// we over-estimate to ensure that there is no borrow dust left\n\t\t// since isMaxBorrowRepayment = reduceOnly, it is safe to over-estimate\n\t\tfinalDepositAmount = finalDepositAmount.scale(2, 1);\n\t}\n\n\t// we choose to not use createDepositIxs here because it doesn't have the initSwiftAccount logic\n\t// const depositTxn = await driftClient.createDepositTxn(\n\t// \tfinalDepositAmount.val,\n\t// \tspotMarketConfig.marketIndex,\n\t// \tassociatedDepositTokenAddress,\n\t// \tuser.getUserAccount().subAccountId,\n\t// \tisMaxBorrowRepayment,\n\t// \ttxParams,\n\t// \tinitSwiftAccount\n\t// );\n\tconst depositIxs = await createDepositIxs({\n\t\tdriftClient,\n\t\tuser,\n\t\tamount: finalDepositAmount,\n\t\tspotMarketConfig,\n\t\tisMaxBorrowRepayment,\n\t});\n\n\tconst depositTxn = await driftClient.txHandler.buildTransaction({\n\t\tinstructions: depositIxs,\n\t\ttxVersion: 0,\n\t\tconnection: driftClient.connection,\n\t\tpreFlightCommitment: 'confirmed',\n\t\tfetchAllMarketLookupTableAccounts:\n\t\t\tdriftClient.fetchAllLookupTableAccounts.bind(driftClient),\n\t});\n\n\treturn depositTxn;\n};\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './borrow';
2
+ export * from './deposit';
3
+ export * from './withdraw';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./borrow"), exports);
18
+ __exportStar(require("./deposit"), exports);
19
+ __exportStar(require("./withdraw"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/spot/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B","sourcesContent":["export * from './borrow';\nexport * from './deposit';\nexport * from './withdraw';\n"]}
@@ -0,0 +1,16 @@
1
+ import { BigNum, DriftClient, SpotMarketConfig, TxParams, User } from '@drift-labs/sdk';
2
+ import { Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
3
+ interface CreateWithdrawIxParams {
4
+ driftClient: DriftClient;
5
+ user: User;
6
+ amount: BigNum;
7
+ spotMarketConfig: SpotMarketConfig;
8
+ isBorrow?: boolean;
9
+ isMax?: boolean;
10
+ }
11
+ export declare const createWithdrawIx: ({ driftClient, amount, spotMarketConfig, user, isBorrow, isMax, }: CreateWithdrawIxParams) => Promise<TransactionInstruction[]>;
12
+ interface CreateWithdrawTxnParams extends CreateWithdrawIxParams {
13
+ txParams?: TxParams;
14
+ }
15
+ export declare const createWithdrawTxn: ({ driftClient, amount, spotMarketConfig, user, isBorrow, isMax, txParams, }: CreateWithdrawTxnParams) => Promise<Transaction | VersionedTransaction>;
16
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWithdrawTxn = exports.createWithdrawIx = void 0;
4
+ const token_1 = require("../../../../utils/token");
5
+ const createWithdrawIx = async ({ driftClient, amount, spotMarketConfig, user, isBorrow, isMax, }) => {
6
+ const reduceOnly = !isBorrow;
7
+ let finalWithdrawAmount = amount;
8
+ if (isMax && reduceOnly) {
9
+ // we over-estimate to ensure that there is no borrow dust left
10
+ // since reduceOnly is true, it is safe to over-estimate
11
+ finalWithdrawAmount = finalWithdrawAmount.scale(2, 1);
12
+ }
13
+ const authority = user.getUserAccount().authority;
14
+ const associatedDepositTokenAddress = await (0, token_1.getTokenAddressForDepositAndWithdraw)(spotMarketConfig.mint, authority);
15
+ const withdrawIxs = await driftClient.getWithdrawalIxs(finalWithdrawAmount.val, spotMarketConfig.marketIndex, associatedDepositTokenAddress, reduceOnly, user.getUserAccount().subAccountId, undefined);
16
+ return withdrawIxs;
17
+ };
18
+ exports.createWithdrawIx = createWithdrawIx;
19
+ const createWithdrawTxn = async ({ driftClient, amount, spotMarketConfig, user, isBorrow, isMax, txParams, }) => {
20
+ const withdrawIxs = await (0, exports.createWithdrawIx)({
21
+ driftClient,
22
+ amount,
23
+ spotMarketConfig,
24
+ user,
25
+ isBorrow,
26
+ isMax,
27
+ });
28
+ const withdrawTxn = await driftClient.txHandler.buildTransaction({
29
+ instructions: withdrawIxs,
30
+ txVersion: 0,
31
+ connection: driftClient.connection,
32
+ preFlightCommitment: 'confirmed',
33
+ fetchAllMarketLookupTableAccounts: driftClient.fetchAllLookupTableAccounts.bind(driftClient),
34
+ txParams,
35
+ });
36
+ return withdrawTxn;
37
+ };
38
+ exports.createWithdrawTxn = createWithdrawTxn;
39
+ //# sourceMappingURL=withdraw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withdraw.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/spot/withdraw.ts"],"names":[],"mappings":";;;AAYA,mDAA+E;AAWxE,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACtC,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,KAAK,GACmB,EAAqC,EAAE;IAC/D,MAAM,UAAU,GAAG,CAAC,QAAQ,CAAC;IAE7B,IAAI,mBAAmB,GAAG,MAAM,CAAC;IAEjC,IAAI,KAAK,IAAI,UAAU,EAAE,CAAC;QACzB,+DAA+D;QAC/D,wDAAwD;QACxD,mBAAmB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC;IAClD,MAAM,6BAA6B,GAClC,MAAM,IAAA,4CAAoC,EACzC,gBAAgB,CAAC,IAAI,EACrB,SAAS,CACT,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,gBAAgB,CACrD,mBAAmB,CAAC,GAAG,EACvB,gBAAgB,CAAC,WAAW,EAC5B,6BAA6B,EAC7B,UAAU,EACV,IAAI,CAAC,cAAc,EAAE,CAAC,YAAY,EAClC,SAAS,CACT,CAAC;IAEF,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AAnCW,QAAA,gBAAgB,oBAmC3B;AAMK,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACvC,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAQ,GACiB,EAA+C,EAAE;IAC1E,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAgB,EAAC;QAC1C,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,IAAI;QACJ,QAAQ;QACR,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC;QAChE,YAAY,EAAE,WAAW;QACzB,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,mBAAmB,EAAE,WAAW;QAChC,iCAAiC,EAChC,WAAW,CAAC,2BAA2B,CAAC,IAAI,CAAC,WAAW,CAAC;QAC1D,QAAQ;KACR,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AA7BW,QAAA,iBAAiB,qBA6B5B","sourcesContent":["import {\n\tBigNum,\n\tDriftClient,\n\tSpotMarketConfig,\n\tTxParams,\n\tUser,\n} from '@drift-labs/sdk';\nimport {\n\tTransaction,\n\tTransactionInstruction,\n\tVersionedTransaction,\n} from '@solana/web3.js';\nimport { getTokenAddressForDepositAndWithdraw } from '../../../../utils/token';\n\ninterface CreateWithdrawIxParams {\n\tdriftClient: DriftClient;\n\tuser: User;\n\tamount: BigNum;\n\tspotMarketConfig: SpotMarketConfig;\n\tisBorrow?: boolean;\n\tisMax?: boolean;\n}\n\nexport const createWithdrawIx = async ({\n\tdriftClient,\n\tamount,\n\tspotMarketConfig,\n\tuser,\n\tisBorrow,\n\tisMax,\n}: CreateWithdrawIxParams): Promise<TransactionInstruction[]> => {\n\tconst reduceOnly = !isBorrow;\n\n\tlet finalWithdrawAmount = amount;\n\n\tif (isMax && reduceOnly) {\n\t\t// we over-estimate to ensure that there is no borrow dust left\n\t\t// since reduceOnly is true, it is safe to over-estimate\n\t\tfinalWithdrawAmount = finalWithdrawAmount.scale(2, 1);\n\t}\n\n\tconst authority = user.getUserAccount().authority;\n\tconst associatedDepositTokenAddress =\n\t\tawait getTokenAddressForDepositAndWithdraw(\n\t\t\tspotMarketConfig.mint,\n\t\t\tauthority\n\t\t);\n\n\tconst withdrawIxs = await driftClient.getWithdrawalIxs(\n\t\tfinalWithdrawAmount.val,\n\t\tspotMarketConfig.marketIndex,\n\t\tassociatedDepositTokenAddress,\n\t\treduceOnly,\n\t\tuser.getUserAccount().subAccountId,\n\t\tundefined\n\t);\n\n\treturn withdrawIxs;\n};\n\ninterface CreateWithdrawTxnParams extends CreateWithdrawIxParams {\n\ttxParams?: TxParams;\n}\n\nexport const createWithdrawTxn = async ({\n\tdriftClient,\n\tamount,\n\tspotMarketConfig,\n\tuser,\n\tisBorrow,\n\tisMax,\n\ttxParams,\n}: CreateWithdrawTxnParams): Promise<Transaction | VersionedTransaction> => {\n\tconst withdrawIxs = await createWithdrawIx({\n\t\tdriftClient,\n\t\tamount,\n\t\tspotMarketConfig,\n\t\tuser,\n\t\tisBorrow,\n\t\tisMax,\n\t});\n\n\tconst withdrawTxn = await driftClient.txHandler.buildTransaction({\n\t\tinstructions: withdrawIxs,\n\t\ttxVersion: 0,\n\t\tconnection: driftClient.connection,\n\t\tpreFlightCommitment: 'confirmed',\n\t\tfetchAllMarketLookupTableAccounts:\n\t\t\tdriftClient.fetchAllLookupTableAccounts.bind(driftClient),\n\t\ttxParams,\n\t});\n\n\treturn withdrawTxn;\n};\n"]}
@@ -0,0 +1,47 @@
1
+ import { DriftClient, TxParams, User } from '@drift-labs/sdk';
2
+ import { Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
3
+ /**
4
+ * Creates a transaction instruction to cancel multiple orders by their order IDs.
5
+ *
6
+ * @param driftClient - The Drift client instance.
7
+ * @param orderIds - Array of order IDs to cancel. Each ID corresponds to a specific order
8
+ * @param user - The user client that owns the orders to be cancelled
9
+ *
10
+ * @returns Promise resolving to a TransactionInstruction that cancels the specified orders
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const instruction = await cancelOrderIxs(
15
+ * driftClient,
16
+ * [123, 456, 789], // Cancel orders with IDs 123, 456, and 789
17
+ * user
18
+ * );
19
+ *
20
+ * ```
21
+ */
22
+ export declare const createCancelOrdersIx: (driftClient: DriftClient, orderIds: number[], user: User) => Promise<TransactionInstruction>;
23
+ /**
24
+ * Creates a transaction to cancel multiple orders by their IDs.
25
+ *
26
+ * @param driftClient - The Drift client instance.
27
+ * @param orderIds - Array of order IDs to cancel. Each ID corresponds to a specific order
28
+ * @param user - The user client that owns the orders to be cancelled
29
+ * @param txParams - Optional transaction parameters for customizing the transaction
30
+ *
31
+ * @returns Promise resolving to a Transaction or VersionedTransaction ready for signing
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Cancel multiple orders
36
+ * const transaction = await cancelOrderTxn(
37
+ * driftClient,
38
+ * [123, 456], // Cancel orders with IDs 123 and 456
39
+ * user,
40
+ * { computeUnits: 200000 } // Optional transaction parameters
41
+ * );
42
+ *
43
+ * // Sign and send the transaction
44
+ * const signature = await wallet.sendTransaction(transaction, connection);
45
+ * ```
46
+ */
47
+ export declare const createCancelOrdersTxn: (driftClient: DriftClient, user: User, orderIds: number[], txParams?: TxParams) => Promise<Transaction | VersionedTransaction>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCancelOrdersTxn = exports.createCancelOrdersIx = void 0;
4
+ /**
5
+ * Creates a transaction instruction to cancel multiple orders by their order IDs.
6
+ *
7
+ * @param driftClient - The Drift client instance.
8
+ * @param orderIds - Array of order IDs to cancel. Each ID corresponds to a specific order
9
+ * @param user - The user client that owns the orders to be cancelled
10
+ *
11
+ * @returns Promise resolving to a TransactionInstruction that cancels the specified orders
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const instruction = await cancelOrderIxs(
16
+ * driftClient,
17
+ * [123, 456, 789], // Cancel orders with IDs 123, 456, and 789
18
+ * user
19
+ * );
20
+ *
21
+ * ```
22
+ */
23
+ const createCancelOrdersIx = async (driftClient, orderIds, user) => {
24
+ return driftClient.getCancelOrdersByIdsIx(orderIds, undefined, user);
25
+ };
26
+ exports.createCancelOrdersIx = createCancelOrdersIx;
27
+ /**
28
+ * Creates a transaction to cancel multiple orders by their IDs.
29
+ *
30
+ * @param driftClient - The Drift client instance.
31
+ * @param orderIds - Array of order IDs to cancel. Each ID corresponds to a specific order
32
+ * @param user - The user client that owns the orders to be cancelled
33
+ * @param txParams - Optional transaction parameters for customizing the transaction
34
+ *
35
+ * @returns Promise resolving to a Transaction or VersionedTransaction ready for signing
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Cancel multiple orders
40
+ * const transaction = await cancelOrderTxn(
41
+ * driftClient,
42
+ * [123, 456], // Cancel orders with IDs 123 and 456
43
+ * user,
44
+ * { computeUnits: 200000 } // Optional transaction parameters
45
+ * );
46
+ *
47
+ * // Sign and send the transaction
48
+ * const signature = await wallet.sendTransaction(transaction, connection);
49
+ * ```
50
+ */
51
+ const createCancelOrdersTxn = async (driftClient, user, orderIds, txParams) => {
52
+ return driftClient.buildTransaction(await (0, exports.createCancelOrdersIx)(driftClient, orderIds, user), txParams);
53
+ };
54
+ exports.createCancelOrdersTxn = createCancelOrdersTxn;
55
+ //# sourceMappingURL=cancelOrder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/trade/cancelOrder.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,oBAAoB,GAAG,KAAK,EACxC,WAAwB,EACxB,QAAkB,EAClB,IAAU,EACwB,EAAE;IACpC,OAAO,WAAW,CAAC,sBAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACtE,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,qBAAqB,GAAG,KAAK,EACzC,WAAwB,EACxB,IAAU,EACV,QAAkB,EAClB,QAAmB,EAC2B,EAAE;IAChD,OAAO,WAAW,CAAC,gBAAgB,CAClC,MAAM,IAAA,4BAAoB,EAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,EACvD,QAAQ,CACR,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC","sourcesContent":["import { DriftClient, TxParams, User } from '@drift-labs/sdk';\nimport {\n\tTransaction,\n\tTransactionInstruction,\n\tVersionedTransaction,\n} from '@solana/web3.js';\n\n/**\n * Creates a transaction instruction to cancel multiple orders by their order IDs.\n *\n * @param driftClient - The Drift client instance.\n * @param orderIds - Array of order IDs to cancel. Each ID corresponds to a specific order\n * @param user - The user client that owns the orders to be cancelled\n *\n * @returns Promise resolving to a TransactionInstruction that cancels the specified orders\n *\n * @example\n * ```typescript\n * const instruction = await cancelOrderIxs(\n * driftClient,\n * [123, 456, 789], // Cancel orders with IDs 123, 456, and 789\n * user\n * );\n *\n * ```\n */\nexport const createCancelOrdersIx = async (\n\tdriftClient: DriftClient,\n\torderIds: number[],\n\tuser: User\n): Promise<TransactionInstruction> => {\n\treturn driftClient.getCancelOrdersByIdsIx(orderIds, undefined, user);\n};\n\n/**\n * Creates a transaction to cancel multiple orders by their IDs.\n *\n * @param driftClient - The Drift client instance.\n * @param orderIds - Array of order IDs to cancel. Each ID corresponds to a specific order\n * @param user - The user client that owns the orders to be cancelled\n * @param txParams - Optional transaction parameters for customizing the transaction\n *\n * @returns Promise resolving to a Transaction or VersionedTransaction ready for signing\n *\n * @example\n * ```typescript\n * // Cancel multiple orders\n * const transaction = await cancelOrderTxn(\n * driftClient,\n * [123, 456], // Cancel orders with IDs 123 and 456\n * user,\n * { computeUnits: 200000 } // Optional transaction parameters\n * );\n *\n * // Sign and send the transaction\n * const signature = await wallet.sendTransaction(transaction, connection);\n * ```\n */\nexport const createCancelOrdersTxn = async (\n\tdriftClient: DriftClient,\n\tuser: User,\n\torderIds: number[],\n\ttxParams?: TxParams\n): Promise<Transaction | VersionedTransaction> => {\n\treturn driftClient.buildTransaction(\n\t\tawait createCancelOrdersIx(driftClient, orderIds, user),\n\t\ttxParams\n\t);\n};\n"]}
@@ -0,0 +1,55 @@
1
+ import { BN, DriftClient, OrderTriggerCondition, PositionDirection, TxParams, User } from '@drift-labs/sdk';
2
+ import { Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
3
+ /**
4
+ * Parameters for editing an existing order
5
+ */
6
+ interface EditOrderParams {
7
+ /** New direction for the order (long/short) */
8
+ newDirection?: PositionDirection;
9
+ /** New base amount for the order */
10
+ newBaseAmount?: BN;
11
+ /** New limit price for the order */
12
+ newLimitPrice?: BN;
13
+ /** New oracle price offset for oracle market/limit orders */
14
+ newOraclePriceOffset?: number;
15
+ /** New trigger price for conditional orders */
16
+ newTriggerPrice?: BN;
17
+ /** New trigger condition for conditional orders */
18
+ newTriggerCondition?: OrderTriggerCondition;
19
+ /** Duration of the auction in slots */
20
+ auctionDuration?: number;
21
+ /** Starting price for the auction */
22
+ auctionStartPrice?: BN;
23
+ /** Ending price for the auction */
24
+ auctionEndPrice?: BN;
25
+ /** Whether the order should only reduce position size */
26
+ reduceOnly?: boolean;
27
+ /** Whether the order should only be posted (maker only) */
28
+ postOnly?: boolean;
29
+ /** Bit flags for additional order configuration */
30
+ bitFlags?: number;
31
+ /** Maximum timestamp for order validity */
32
+ maxTs?: BN;
33
+ /** Order policy configuration */
34
+ policy?: number;
35
+ }
36
+ /**
37
+ * Creates a transaction instruction to edit an existing order
38
+ * @param driftClient - The DriftClient instance
39
+ * @param userPublicKey - The public key of the user who owns the order
40
+ * @param orderId - The ID of the order to edit
41
+ * @param editOrderParams - Parameters containing the new order values
42
+ * @returns Promise that resolves to a TransactionInstruction
43
+ */
44
+ export declare const createEditOrderIx: (driftClient: DriftClient, user: User, orderId: number, editOrderParams: EditOrderParams) => Promise<TransactionInstruction>;
45
+ /**
46
+ * Creates a complete transaction to edit an existing order
47
+ * @param driftClient - The DriftClient instance
48
+ * @param userPublicKey - The public key of the user who owns the order
49
+ * @param orderId - The ID of the order to edit
50
+ * @param editOrderParams - Parameters containing the new order values
51
+ * @param txParams - Optional transaction parameters (compute units, priority fees, etc.)
52
+ * @returns Promise that resolves to a Transaction or VersionedTransaction
53
+ */
54
+ export declare const createEditOrderTxn: (driftClient: DriftClient, user: User, orderId: number, editOrderParams: EditOrderParams, txParams?: TxParams) => Promise<Transaction | VersionedTransaction>;
55
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEditOrderTxn = exports.createEditOrderIx = void 0;
4
+ /**
5
+ * Creates a transaction instruction to edit an existing order
6
+ * @param driftClient - The DriftClient instance
7
+ * @param userPublicKey - The public key of the user who owns the order
8
+ * @param orderId - The ID of the order to edit
9
+ * @param editOrderParams - Parameters containing the new order values
10
+ * @returns Promise that resolves to a TransactionInstruction
11
+ */
12
+ const createEditOrderIx = async (driftClient, user, orderId, editOrderParams) => {
13
+ const userPublicKey = user.getUserAccountPublicKey();
14
+ const _currentOrder = user.getOrderByUserOrderId(orderId);
15
+ // TODO: handle auction params
16
+ return driftClient.getModifyOrderIx({
17
+ orderId,
18
+ ...editOrderParams,
19
+ }, undefined, userPublicKey);
20
+ };
21
+ exports.createEditOrderIx = createEditOrderIx;
22
+ /**
23
+ * Creates a complete transaction to edit an existing order
24
+ * @param driftClient - The DriftClient instance
25
+ * @param userPublicKey - The public key of the user who owns the order
26
+ * @param orderId - The ID of the order to edit
27
+ * @param editOrderParams - Parameters containing the new order values
28
+ * @param txParams - Optional transaction parameters (compute units, priority fees, etc.)
29
+ * @returns Promise that resolves to a Transaction or VersionedTransaction
30
+ */
31
+ const createEditOrderTxn = async (driftClient, user, orderId, editOrderParams, txParams) => {
32
+ return driftClient.buildTransaction(await (0, exports.createEditOrderIx)(driftClient, user, orderId, editOrderParams), txParams);
33
+ };
34
+ exports.createEditOrderTxn = createEditOrderTxn;
35
+ //# sourceMappingURL=editOrder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editOrder.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/trade/editOrder.ts"],"names":[],"mappings":";;;AAgDA;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACrC,WAAwB,EACxB,IAAU,EACV,OAAe,EACf,eAAgC,EACE,EAAE;IACpC,MAAM,aAAa,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACrD,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE1D,8BAA8B;IAE9B,OAAO,WAAW,CAAC,gBAAgB,CAClC;QACC,OAAO;QACP,GAAG,eAAe;KAClB,EACD,SAAS,EACT,aAAa,CACb,CAAC;AACH,CAAC,CAAC;AAnBW,QAAA,iBAAiB,qBAmB5B;AAEF;;;;;;;;GAQG;AACI,MAAM,kBAAkB,GAAG,KAAK,EACtC,WAAwB,EACxB,IAAU,EACV,OAAe,EACf,eAAgC,EAChC,QAAmB,EAC2B,EAAE;IAChD,OAAO,WAAW,CAAC,gBAAgB,CAClC,MAAM,IAAA,yBAAiB,EAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,QAAQ,CACR,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B","sourcesContent":["import {\n\tBN,\n\tDriftClient,\n\tOrderTriggerCondition,\n\tPositionDirection,\n\tTxParams,\n\tUser,\n} from '@drift-labs/sdk';\nimport {\n\tTransaction,\n\tTransactionInstruction,\n\tVersionedTransaction,\n} from '@solana/web3.js';\n\n/**\n * Parameters for editing an existing order\n */\ninterface EditOrderParams {\n\t/** New direction for the order (long/short) */\n\tnewDirection?: PositionDirection;\n\t/** New base amount for the order */\n\tnewBaseAmount?: BN;\n\t/** New limit price for the order */\n\tnewLimitPrice?: BN;\n\t/** New oracle price offset for oracle market/limit orders */\n\tnewOraclePriceOffset?: number;\n\t/** New trigger price for conditional orders */\n\tnewTriggerPrice?: BN;\n\t/** New trigger condition for conditional orders */\n\tnewTriggerCondition?: OrderTriggerCondition;\n\t/** Duration of the auction in slots */\n\tauctionDuration?: number;\n\t/** Starting price for the auction */\n\tauctionStartPrice?: BN;\n\t/** Ending price for the auction */\n\tauctionEndPrice?: BN;\n\t/** Whether the order should only reduce position size */\n\treduceOnly?: boolean;\n\t/** Whether the order should only be posted (maker only) */\n\tpostOnly?: boolean;\n\t/** Bit flags for additional order configuration */\n\tbitFlags?: number;\n\t/** Maximum timestamp for order validity */\n\tmaxTs?: BN;\n\t/** Order policy configuration */\n\tpolicy?: number;\n}\n\n/**\n * Creates a transaction instruction to edit an existing order\n * @param driftClient - The DriftClient instance\n * @param userPublicKey - The public key of the user who owns the order\n * @param orderId - The ID of the order to edit\n * @param editOrderParams - Parameters containing the new order values\n * @returns Promise that resolves to a TransactionInstruction\n */\nexport const createEditOrderIx = async (\n\tdriftClient: DriftClient,\n\tuser: User,\n\torderId: number,\n\teditOrderParams: EditOrderParams\n): Promise<TransactionInstruction> => {\n\tconst userPublicKey = user.getUserAccountPublicKey();\n\tconst _currentOrder = user.getOrderByUserOrderId(orderId);\n\n\t// TODO: handle auction params\n\n\treturn driftClient.getModifyOrderIx(\n\t\t{\n\t\t\torderId,\n\t\t\t...editOrderParams,\n\t\t},\n\t\tundefined,\n\t\tuserPublicKey\n\t);\n};\n\n/**\n * Creates a complete transaction to edit an existing order\n * @param driftClient - The DriftClient instance\n * @param userPublicKey - The public key of the user who owns the order\n * @param orderId - The ID of the order to edit\n * @param editOrderParams - Parameters containing the new order values\n * @param txParams - Optional transaction parameters (compute units, priority fees, etc.)\n * @returns Promise that resolves to a Transaction or VersionedTransaction\n */\nexport const createEditOrderTxn = async (\n\tdriftClient: DriftClient,\n\tuser: User,\n\torderId: number,\n\teditOrderParams: EditOrderParams,\n\ttxParams?: TxParams\n): Promise<Transaction | VersionedTransaction> => {\n\treturn driftClient.buildTransaction(\n\t\tawait createEditOrderIx(driftClient, user, orderId, editOrderParams),\n\t\ttxParams\n\t);\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './openPerpOrder';
2
+ export * from './cancelOrder';
3
+ export * from './editOrder';
4
+ export * from './swap';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./openPerpOrder"), exports);
18
+ __exportStar(require("./cancelOrder"), exports);
19
+ __exportStar(require("./editOrder"), exports);
20
+ __exportStar(require("./swap"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/drift/base/actions/trade/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB","sourcesContent":["export * from './openPerpOrder';\nexport * from './cancelOrder';\nexport * from './editOrder';\nexport * from './swap';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './openPerpMarketOrder';
2
+ export * from './openPerpNonMarketOrder';
3
+ export * from './openSwiftOrder';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./openPerpMarketOrder"), exports);
18
+ __exportStar(require("./openPerpNonMarketOrder"), exports);
19
+ __exportStar(require("./openSwiftOrder"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/drift/base/actions/trade/openPerpOrder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,2DAAyC;AACzC,mDAAiC","sourcesContent":["export * from './openPerpMarketOrder';\nexport * from './openPerpNonMarketOrder';\nexport * from './openSwiftOrder';\n"]}
@@ -0,0 +1,84 @@
1
+ import { DriftClient, User, BN, PositionDirection, MarketType } from '@drift-labs/sdk';
2
+ import { Transaction, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
3
+ import { OptionalTriggerOrderParams, SwiftOrderOptions, SwiftOrderResult } from '../openSwiftOrder';
4
+ export interface AuctionParamsRequestOptions {
5
+ maxLeverageSelected?: boolean;
6
+ maxLeverageOrderSize?: BN;
7
+ reduceOnly?: boolean;
8
+ auctionDuration?: number;
9
+ auctionStartPriceOffset?: number;
10
+ auctionEndPriceOffset?: number;
11
+ auctionStartPriceOffsetFrom?: string;
12
+ auctionEndPriceOffsetFrom?: string;
13
+ slippageTolerance?: number | 'dynamic';
14
+ auctionPriceCaps?: {
15
+ min: BN;
16
+ max: BN;
17
+ };
18
+ isOracleOrder?: boolean;
19
+ additionalEndPriceBuffer?: BN;
20
+ forceUpToSlippage?: boolean;
21
+ orderType?: 'market' | 'oracle';
22
+ }
23
+ export type OpenPerpMarketOrderParams<T extends boolean = boolean> = {
24
+ driftClient: DriftClient;
25
+ user: User;
26
+ assetType: 'base' | 'quote';
27
+ marketIndex: number;
28
+ direction: PositionDirection;
29
+ amount: BN;
30
+ auctionParamsOptions?: AuctionParamsRequestOptions;
31
+ dlobServerHttpUrl: string;
32
+ bracketOrders?: {
33
+ takeProfit?: OptionalTriggerOrderParams;
34
+ stopLoss?: OptionalTriggerOrderParams;
35
+ };
36
+ marketType?: MarketType;
37
+ useSwift: T;
38
+ } & (T extends true ? {
39
+ swiftOptions: SwiftOrderOptions;
40
+ } : {
41
+ swiftOptions?: never;
42
+ });
43
+ /**
44
+ * Creates transaction instructions for opening a perp market order.
45
+ * If swiftOptions is provided, it will create a Swift (signed message) order instead.
46
+ *
47
+ * @param driftClient - The Drift client instance for interacting with the protocol
48
+ * @param user - The user account that will place the order
49
+ * @param assetType - Whether the amount is in base or quote units
50
+ * @param marketIndex - The perp market index to trade
51
+ * @param direction - The direction of the trade (long/short)
52
+ * @param amount - The amount to trade
53
+ * @param dlobServerHttpUrl - Server URL for the auction params endpoint
54
+ * @param auctionParamsOptions - Optional parameters for auction params endpoint and order configuration
55
+ * @param useSwift - Whether to use Swift (signed message) orders instead of regular transactions
56
+ * @param swiftOptions - Options for Swift (signed message) orders. Required if useSwift is true
57
+ *
58
+ * @returns Promise resolving to an array of transaction instructions for regular orders, or empty array for Swift orders
59
+ */
60
+ export declare const createOpenPerpMarketOrderIx: ({ driftClient, user, assetType, marketIndex, direction, amount, dlobServerHttpUrl, auctionParamsOptions, useSwift, swiftOptions, }: OpenPerpMarketOrderParams) => Promise<TransactionInstruction[]>;
61
+ /**
62
+ * Creates a complete transaction for opening a perp market order.
63
+ *
64
+ * @param driftClient - The Drift client instance for interacting with the protocol
65
+ * @param user - The user account that will place the order
66
+ * @param marketIndex - The perp market index to trade
67
+ * @param direction - The direction of the trade (long/short)
68
+ * @param amount - The amount to trade
69
+ * @param auctionParamsOptions - Optional parameters for auction params endpoint and order configuration
70
+ * @param dlobServerHttpUrl - Server URL for the auction params endpoint
71
+ *
72
+ * @returns Promise resolving to a built transaction ready for signing (Transaction or VersionedTransaction)
73
+ */
74
+ export declare const createOpenPerpMarketOrderTxn: <T extends boolean>({ driftClient, user, assetType, marketIndex, direction, amount, dlobServerHttpUrl, auctionParamsOptions, bracketOrders, useSwift, swiftOptions, }: OpenPerpMarketOrderParams<T>) => Promise<T extends true ? SwiftOrderResult : Transaction | VersionedTransaction>;
75
+ /**
76
+ * Creates a Swift (signed message) order directly.
77
+ * This is a convenience function for when you only want to create Swift orders.
78
+ *
79
+ * @param params - All the parameters needed for creating a Swift order
80
+ * @returns Promise resolving to SwiftOrderResult with observable and order UUID
81
+ */
82
+ export declare const createSwiftPerpMarketOrder: (params: Omit<OpenPerpMarketOrderParams, 'useSwift'> & {
83
+ swiftOptions: SwiftOrderOptions;
84
+ }) => Promise<SwiftOrderResult>;