@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 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/drift/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,6CAAkE;AAClE,yCAYyB;AACzB,yCAAiC;AACjC,2EAAwE;AAExE,oCAAsC;AACtC,iDAA+C;AAC/C,2CAA6B;AAG7B,4CAA4C;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,uBAAuB;AACvB,IAAI,kBAAsC,CAAC;AAC3C,IAAI,MAAqB,CAAC;AAM1B;;GAEG;AACH,SAAS,SAAS,CAAC,IAAc;IAChC,MAAM,MAAM,GAAY,EAAE,CAAC;IAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,GAAG,EAAE,KA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EAAsE;QACtE,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as anchor from '@coral-xyz/anchor';\nimport { PublicKey, VersionedTransaction } from '@solana/web3.js';\nimport {\n\tBN,\n\tloadKeypair,\n\tPositionDirection,\n\tOrderType,\n\tPostOnlyParams,\n\tSwapMode,\n\tBASE_PRECISION,\n\tQUOTE_PRECISION,\n\tPRICE_PRECISION,\n\tMainnetSpotMarkets,\n\tDevnetSpotMarkets,\n} from '@drift-labs/sdk';\nimport { sign } from 'tweetnacl';\nimport { CentralServerDrift } from './Drift/clients/CentralServerDrift';\nimport { SwiftOrderResult } from './base/actions/trade/openPerpOrder/openSwiftOrder';\nimport { ENUM_UTILS } from '../utils';\nimport { API_URLS } from './constants/apiUrls';\nimport * as path from 'path';\nimport { NonMarketOrderType } from './utils/orderParams';\n\n// Load environment variables from .env file\nconst dotenv = require('dotenv');\ndotenv.config({ path: path.resolve(__dirname, '.env') });\n\n/**\n * CLI Tool for CentralServerDrift client\n *\n * This CLI tool allows you to execute various Drift protocol operations via command line\n * with human-readable parameters that are automatically converted to the proper precision.\n *\n * Prerequisites:\n * - Create a .env file in the same directory as this CLI file with:\n * ANCHOR_WALLET=[private key byte array]\n * ENDPOINT=https://your-rpc-endpoint.com\n *\n * Usage Examples:\n * ts-node cli.ts deposit --marketIndex=0 --amount=2 --userAccount=11111111111111111111111111111111\n * ts-node cli.ts withdraw --marketIndex=0 --amount=1.5 --userAccount=11111111111111111111111111111111\n * ts-node cli.ts settleFunding --userAccount=11111111111111111111111111111111\n * ts-node cli.ts settlePnl --marketIndexes=0,1 --userAccount=11111111111111111111111111111111\n * ts-node cli.ts openPerpMarketOrder --marketIndex=0 --direction=long --amount=0.1 --assetType=base --userAccount=11111111111111111111111111111111\n * ts-node cli.ts openPerpMarketOrderSwift --marketIndex=0 --direction=short --amount=100 --assetType=quote --userAccount=11111111111111111111111111111111\n * ts-node cli.ts openPerpNonMarketOrder --marketIndex=0 --direction=long --baseAssetAmount=0.1 --orderType=limit --limitPrice=100 --userAccount=11111111111111111111111111111111\n * ts-node cli.ts openPerpNonMarketOrderSwift --marketIndex=0 --direction=long --baseAssetAmount=0.1 --orderType=limit --limitPrice=99.5 --userAccount=11111111111111111111111111111111\n * ts-node cli.ts editOrder --userAccount=11111111111111111111111111111111 --orderId=123 --newLimitPrice=105.5\n * ts-node cli.ts cancelOrder --userAccount=11111111111111111111111111111111 --orderIds=123,456,789\n * ts-node cli.ts cancelAllOrders --userAccount=11111111111111111111111111111111 --marketType=perp\n * ts-node cli.ts swap --userAccount=11111111111111111111111111111111 --fromMarketIndex=1 --toMarketIndex=0 --fromAmount=1.5 --slippage=100 --swapMode=ExactIn\n * ts-node cli.ts swap --userAccount=11111111111111111111111111111111 --fromMarketIndex=1 --toMarketIndex=0 --toAmount=150 --slippage=100 --swapMode=ExactOut\n */\n\n// Shared configuration\nlet centralServerDrift: CentralServerDrift;\nlet wallet: anchor.Wallet;\n\ninterface CliArgs {\n\t[key: string]: string | string[];\n}\n\n/**\n * Parse command line arguments into a key-value object\n */\nfunction parseArgs(args: string[]): CliArgs {\n\tconst parsed: CliArgs = {};\n\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst arg = args[i];\n\t\tif (arg.startsWith('--')) {\n\t\t\tconst [key, value] = arg.substring(2).split('=');\n\t\t\tif (value !== undefined) {\n\t\t\t\t// Handle comma-separated arrays\n\t\t\t\tif (value.includes(',')) {\n\t\t\t\t\tparsed[key] = value.split(',');\n\t\t\t\t} else {\n\t\t\t\t\tparsed[key] = value;\n\t\t\t\t}\n\t\t\t} else if (i + 1 < args.length && !args[i + 1].startsWith('--')) {\n\t\t\t\t// Handle space-separated values\n\t\t\t\tconst nextValue = args[i + 1];\n\t\t\t\tif (nextValue.includes(',')) {\n\t\t\t\t\tparsed[key] = nextValue.split(',');\n\t\t\t\t} else {\n\t\t\t\t\tparsed[key] = nextValue;\n\t\t\t\t}\n\t\t\t\ti++; // Skip the next argument as it's the value\n\t\t\t} else {\n\t\t\t\tparsed[key] = 'true'; // Boolean flag\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parsed;\n}\n\n/**\n * Convert human-readable amount to BN with proper precision\n */\nfunction parseAmount(amount: string, precision: BN = QUOTE_PRECISION): BN {\n\tconst floatAmount = parseFloat(amount);\n\tif (isNaN(floatAmount)) {\n\t\tthrow new Error(`Invalid amount: ${amount}`);\n\t}\n\n\t// Convert to the proper precision\n\tconst scaledAmount = Math.floor(floatAmount * precision.toNumber());\n\treturn new BN(scaledAmount);\n}\n\n/**\n * Parse direction string to PositionDirection\n */\nfunction parseDirection(direction: string): PositionDirection {\n\tconst normalized = direction.toLowerCase();\n\tif (normalized === 'long' || normalized === 'buy') {\n\t\treturn PositionDirection.LONG;\n\t} else if (normalized === 'short' || normalized === 'sell') {\n\t\treturn PositionDirection.SHORT;\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Invalid direction: ${direction}. Use 'long', 'short', 'buy', or 'sell'`\n\t\t);\n\t}\n}\n\n/**\n * Parse order type string to OrderType\n */\nfunction _parseOrderType(orderType: string): OrderType {\n\tconst normalized = orderType.toLowerCase();\n\tswitch (normalized) {\n\t\tcase 'limit':\n\t\t\treturn OrderType.LIMIT;\n\t\tcase 'market':\n\t\t\treturn OrderType.MARKET;\n\t\tcase 'oracle':\n\t\t\treturn OrderType.ORACLE;\n\t\tcase 'trigger_market':\n\t\tcase 'stopmarket':\n\t\t\treturn OrderType.TRIGGER_MARKET;\n\t\tcase 'trigger_limit':\n\t\tcase 'stoplimit':\n\t\t\treturn OrderType.TRIGGER_LIMIT;\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid order type: ${orderType}. Use 'limit', 'market', 'oracle', 'trigger_market', or 'trigger_limit'`\n\t\t\t);\n\t}\n}\n\n/**\n * Parse post only string to PostOnlyParams\n */\nfunction parsePostOnly(postOnly: string): PostOnlyParams {\n\tconst normalized = postOnly.toLowerCase();\n\tswitch (normalized) {\n\t\tcase 'none':\n\t\tcase 'false':\n\t\t\treturn PostOnlyParams.NONE;\n\t\tcase 'must_post_only':\n\t\tcase 'true':\n\t\t\treturn PostOnlyParams.MUST_POST_ONLY;\n\t\tcase 'try_post_only':\n\t\t\treturn PostOnlyParams.TRY_POST_ONLY;\n\t\tcase 'slide':\n\t\t\treturn PostOnlyParams.SLIDE;\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid post only: ${postOnly}. Use 'none', 'must_post_only', 'try_post_only', or 'slide'`\n\t\t\t);\n\t}\n}\n\n/**\n * Parse swap mode string to SwapMode\n */\nfunction parseSwapMode(swapMode: string): SwapMode {\n\tconst normalized = swapMode.toLowerCase();\n\tswitch (normalized) {\n\t\tcase 'exactin':\n\t\tcase 'exact_in':\n\t\t\treturn 'ExactIn';\n\t\tcase 'exactout':\n\t\tcase 'exact_out':\n\t\t\treturn 'ExactOut';\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid swap mode: ${swapMode}. Use 'ExactIn' or 'ExactOut'`\n\t\t\t);\n\t}\n}\n\n/**\n * Get the precision for a spot market based on environment and market index\n */\nfunction getMarketPrecision(\n\tmarketIndex: number,\n\tisMainnet: boolean = true\n): BN {\n\tconst markets = isMainnet ? MainnetSpotMarkets : DevnetSpotMarkets;\n\tconst market = markets.find((m) => m.marketIndex === marketIndex);\n\n\tif (!market) {\n\t\tconsole.warn(\n\t\t\t`āš ļø Market ${marketIndex} not found, using QUOTE_PRECISION as fallback`\n\t\t);\n\t\treturn QUOTE_PRECISION;\n\t}\n\n\treturn market.precision;\n}\n\n/**\n * Initialize CentralServerDrift instance\n */\nasync function initializeCentralServerDrift(): Promise<void> {\n\tconsole.log('šŸš€ Initializing CentralServerDrift...\\n');\n\n\t// Validate required environment variables\n\tif (!process.env.ANCHOR_WALLET) {\n\t\tthrow new Error('ANCHOR_WALLET must be set in .env file');\n\t}\n\n\tif (!process.env.ENDPOINT) {\n\t\tthrow new Error(\n\t\t\t'ENDPOINT environment variable must be set to your Solana RPC endpoint'\n\t\t);\n\t}\n\n\t// Set up the wallet\n\twallet = new anchor.Wallet(loadKeypair(process.env.ANCHOR_WALLET as string));\n\n\tconsole.log(`āœ… Wallet Public Key: ${wallet.publicKey.toString()}`);\n\tconsole.log(`āœ… RPC Endpoint: ${process.env.ENDPOINT}\\n`);\n\n\t// Initialize CentralServerDrift\n\tconsole.log('šŸ—ļø Initializing CentralServerDrift...');\n\tcentralServerDrift = new CentralServerDrift({\n\t\tsolanaRpcEndpoint: process.env.ENDPOINT as string,\n\t\tdriftEnv: 'mainnet-beta', // Change to 'devnet' for devnet testing\n\t\tadditionalDriftClientConfig: {\n\t\t\ttxVersion: 0,\n\t\t\ttxParams: {\n\t\t\t\tcomputeUnits: 200000,\n\t\t\t\tcomputeUnitsPrice: 1000,\n\t\t\t},\n\t\t},\n\t});\n\n\tconsole.log('āœ… CentralServerDrift instance created successfully\\n');\n\n\t// Subscribe to market data\n\tconsole.log('šŸ“” Subscribing to market data...');\n\tawait centralServerDrift.subscribe();\n\tconsole.log('āœ… Successfully subscribed to market data\\n');\n}\n\n/**\n * Execute a regular transaction\n */\nasync function executeTransaction(\n\ttxn: VersionedTransaction,\n\ttransactionType: string\n): Promise<void> {\n\tconsole.log(`āœ… ${transactionType} transaction created successfully`);\n\tconsole.log('\\nšŸ“ Signing Transaction...');\n\n\ttxn.sign([wallet.payer]);\n\tconsole.log('āœ… Transaction signed successfully');\n\n\tconsole.log('\\nšŸš€ Sending transaction to the network...');\n\tconst { txSig } = await centralServerDrift.sendSignedTransaction(txn);\n\n\tconsole.log('āœ… Transaction sent successfully!');\n\tconsole.log(`šŸ“‹ Transaction Signature: ${txSig?.toString()}`);\n\tconsole.log(`šŸ” View on Solscan: https://solscan.io/tx/${txSig?.toString()}`);\n}\n\n/**\n * Handle Swift order observable\n */\nfunction handleSwiftOrder(\n\tswiftResult: SwiftOrderResult,\n\torderType: string\n): void {\n\tif (swiftResult.swiftOrderObservable) {\n\t\tconsole.log('\\nšŸ‘ļø Monitoring order status...');\n\n\t\tswiftResult.swiftOrderObservable.subscribe({\n\t\t\tnext: (event) => {\n\t\t\t\tif (event.type === 'sent') {\n\t\t\t\t\tconsole.log(`āœ… ${orderType} Swift order submitted successfully`);\n\t\t\t\t} else if (event.type === 'confirmed') {\n\t\t\t\t\tconsole.log('āœ… Order confirmed!');\n\t\t\t\t\tconsole.log(`šŸ“‹ Order ID: ${event.orderId}`);\n\t\t\t\t\tconsole.log(`šŸ“‹ Hash: ${event.hash}`);\n\t\t\t\t} else if (event.type === 'errored') {\n\t\t\t\t\tconsole.error('āŒ Order failed:', event.message);\n\t\t\t\t\tconsole.error(`šŸ“‹ Status: ${event.status}`);\n\t\t\t\t} else if (event.type === 'expired') {\n\t\t\t\t\tconsole.error('ā° Order expired:', event.message);\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: (error) => {\n\t\t\t\tconsole.error('āŒ Observable error:', error);\n\t\t\t},\n\t\t\tcomplete: () => {\n\t\t\t\tconsole.log('šŸ Order monitoring completed');\n\t\t\t},\n\t\t});\n\t} else {\n\t\tconsole.log('šŸ Order confirmed and processing complete');\n\t}\n}\n\n/**\n * CLI Command: deposit\n */\nasync function depositCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndex = parseInt(args.marketIndex as string);\n\tconst amount = args.amount as string;\n\n\tif (!userAccount || isNaN(marketIndex) || !amount) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndex, --amount'\n\t\t);\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst amountBN = parseAmount(amount, QUOTE_PRECISION); // Most deposits are USDC (quote precision)\n\n\tconsole.log('--- šŸ“„ Deposit Transaction ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Index: ${marketIndex}`);\n\tconsole.log(`šŸ’° Amount: ${amount} (${amountBN.toString()} raw units)`);\n\n\tconst depositTxn = await centralServerDrift.getDepositTxn(\n\t\tuserAccountPubkey,\n\t\tamountBN,\n\t\tmarketIndex\n\t);\n\n\tawait executeTransaction(depositTxn as VersionedTransaction, 'Deposit');\n}\n\n/**\n * CLI Command: withdraw\n */\nasync function withdrawCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndex = parseInt(args.marketIndex as string);\n\tconst amount = args.amount as string;\n\tconst isBorrow = args.isBorrow === 'true';\n\tconst isMax = args.isMax === 'true';\n\n\tif (!userAccount || isNaN(marketIndex) || !amount) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndex, --amount'\n\t\t);\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst amountBN = parseAmount(amount, QUOTE_PRECISION);\n\n\tconsole.log('--- šŸ“¤ Withdraw Transaction ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Index: ${marketIndex}`);\n\tconsole.log(`šŸ’° Amount: ${amount} (${amountBN.toString()} raw units)`);\n\tconsole.log(`šŸ’³ Is Borrow: ${isBorrow}`);\n\tconsole.log(`šŸ“Š Is Max: ${isMax}`);\n\n\tconst withdrawTxn = await centralServerDrift.getWithdrawTxn(\n\t\tuserAccountPubkey,\n\t\tamountBN,\n\t\tmarketIndex,\n\t\t{ isBorrow, isMax }\n\t);\n\n\tawait executeTransaction(withdrawTxn as VersionedTransaction, 'Withdraw');\n}\n\n/**\n * CLI Command: settleFunding\n */\nasync function settleFundingCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\n\tif (!userAccount) {\n\t\tthrow new Error('Required arguments: --userAccount');\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\n\tconsole.log('--- šŸ’° Settle Funding Transaction ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\n\tconst settleFundingTxn = await centralServerDrift.getSettleFundingTxn(\n\t\tuserAccountPubkey\n\t);\n\n\tawait executeTransaction(\n\t\tsettleFundingTxn as VersionedTransaction,\n\t\t'Settle Funding'\n\t);\n}\n\n/**\n * CLI Command: settlePnl\n */\nasync function settlePnlCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndexesArg = args.marketIndexes;\n\n\tif (!userAccount || !marketIndexesArg) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndexes (comma-separated)'\n\t\t);\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst marketIndexes = Array.isArray(marketIndexesArg)\n\t\t? marketIndexesArg.map((idx) => parseInt(idx))\n\t\t: [parseInt(marketIndexesArg as string)];\n\n\tconsole.log('--- šŸ“ˆ Settle PnL Transaction ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸ“Š Market Indexes: ${marketIndexes.join(', ')}`);\n\n\tconst settlePnlTxn = await centralServerDrift.getSettlePnlTxn(\n\t\tuserAccountPubkey,\n\t\tmarketIndexes\n\t);\n\n\tawait executeTransaction(settlePnlTxn as VersionedTransaction, 'Settle PnL');\n}\n\n/**\n * CLI Command: openPerpMarketOrder (regular transaction)\n */\nasync function openPerpMarketOrderCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndex = parseInt(args.marketIndex as string);\n\tconst direction = args.direction as string;\n\tconst amount = args.amount as string;\n\tconst assetType = (args.assetType as string) || 'base';\n\tconst dlobServerHttpUrl = API_URLS.DLOB;\n\n\tif (!userAccount || isNaN(marketIndex) || !direction || !amount) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndex, --direction, --amount'\n\t\t);\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst directionEnum = parseDirection(direction);\n\tconst precision = assetType === 'base' ? BASE_PRECISION : QUOTE_PRECISION;\n\tconst amountBN = parseAmount(amount, precision);\n\n\tconsole.log('--- šŸŽÆ Open Perp Order Transaction ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Index: ${marketIndex}`);\n\tconsole.log(\n\t\t`šŸ“Š Direction: ${direction} (${ENUM_UTILS.toStr(directionEnum)})`\n\t);\n\tconsole.log(`šŸ’° Amount: ${amount} (${amountBN.toString()} raw units)`);\n\tconsole.log(`šŸ’± Asset Type: ${assetType}`);\n\tconsole.log(`🌐 DLOB Server: ${dlobServerHttpUrl}`);\n\n\tconst orderTxn = await centralServerDrift.getOpenPerpMarketOrderTxn(\n\t\tuserAccountPubkey,\n\t\tassetType as 'base' | 'quote',\n\t\tmarketIndex,\n\t\tdirectionEnum,\n\t\tamountBN,\n\t\tdlobServerHttpUrl,\n\t\tundefined, // auctionParamsOptions\n\t\tfalse // useSwift\n\t);\n\n\tawait executeTransaction(orderTxn as VersionedTransaction, 'Open Perp Order');\n}\n\n/**\n * CLI Command: openPerpMarketOrderSwift (Swift signed message order)\n */\nasync function openPerpMarketOrderSwiftCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndex = parseInt(args.marketIndex as string);\n\tconst direction = args.direction as string;\n\tconst amount = args.amount as string;\n\tconst assetType = (args.assetType as string) || 'base';\n\tconst dlobServerHttpUrl = API_URLS.DLOB;\n\tconst swiftServerUrl = (args.swiftServerUrl as string) || API_URLS.SWIFT;\n\n\tif (!userAccount || isNaN(marketIndex) || !direction || !amount) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndex, --direction, --amount'\n\t\t);\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst directionEnum = parseDirection(direction);\n\tconst precision = assetType === 'base' ? BASE_PRECISION : QUOTE_PRECISION;\n\tconst amountBN = parseAmount(amount, precision);\n\n\tconsole.log('--- ⚔ Open Perp Order Swift ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Index: ${marketIndex}`);\n\tconsole.log(\n\t\t`šŸ“Š Direction: ${direction} (${ENUM_UTILS.toStr(directionEnum)})`\n\t);\n\tconsole.log(`šŸ’° Amount: ${amount} (${amountBN.toString()} raw units)`);\n\tconsole.log(`šŸ’± Asset Type: ${assetType}`);\n\tconsole.log(`🌐 DLOB Server: ${dlobServerHttpUrl}`);\n\tconsole.log(`⚔ Swift Server: ${swiftServerUrl}`);\n\tconsole.log(`šŸ”‘ Wallet Public Key: ${wallet.publicKey.toString()}`);\n\n\tlet swiftResult: SwiftOrderResult;\n\ttry {\n\t\tswiftResult = (await centralServerDrift.getOpenPerpMarketOrderTxn(\n\t\t\tuserAccountPubkey,\n\t\t\tassetType as 'base' | 'quote',\n\t\t\tmarketIndex,\n\t\t\tdirectionEnum,\n\t\t\tamountBN,\n\t\t\tdlobServerHttpUrl,\n\t\t\tundefined, // auctionParamsOptions\n\t\t\ttrue, // useSwift\n\t\t\t{\n\t\t\t\twallet: {\n\t\t\t\t\tsignMessage: async (message: Uint8Array) => {\n\t\t\t\t\t\t// Sign the message using the keypair\n\t\t\t\t\t\tconst signature = sign.detached(message, wallet.payer.secretKey);\n\t\t\t\t\t\treturn new Uint8Array(signature);\n\t\t\t\t\t},\n\t\t\t\t\tpublicKey: wallet.publicKey,\n\t\t\t\t},\n\t\t\t\tswiftServerUrl,\n\t\t\t\tconfirmDuration: 30000,\n\t\t\t}\n\t\t)) as SwiftOrderResult;\n\t\tconsole.log('āœ… [CLI] Swift order transaction created successfully!');\n\t} catch (error) {\n\t\tconsole.error('āŒ [CLI] Error creating Swift order:', error);\n\t\tthrow error;\n\t}\n\n\thandleSwiftOrder(swiftResult, 'Open Perp Order');\n}\n\n/**\n * CLI Command: openPerpNonMarketOrder (regular limit/oracle order)\n */\nasync function openPerpNonMarketOrderCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndex = parseInt(args.marketIndex as string);\n\tconst direction = args.direction as string;\n\tconst amount = args.amount as string;\n\tconst assetType = (args.assetType as string) || 'base';\n\tconst baseAssetAmount = args.baseAssetAmount as string;\n\tconst orderType = args.orderType as string;\n\tconst limitPrice = args.limitPrice as string;\n\tconst triggerPrice = args.triggerPrice as string;\n\tconst reduceOnly = (args.reduceOnly as string) === 'true';\n\tconst postOnly = (args.postOnly as string) || 'none';\n\tconst oraclePriceOffset = args.oraclePriceOffset as string;\n\n\tif (!userAccount || isNaN(marketIndex) || !direction || !orderType) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndex, --direction, --orderType'\n\t\t);\n\t}\n\n\tif (!amount && !baseAssetAmount) {\n\t\tthrow new Error('Either --amount or --baseAssetAmount must be provided');\n\t}\n\n\t// Validate price requirements based on order type\n\tif (orderType === 'limit') {\n\t\tif (!limitPrice) {\n\t\t\tthrow new Error(`Order type '${orderType}' requires --limitPrice`);\n\t\t}\n\t} else if (orderType === 'takeProfit' || orderType === 'stopLoss') {\n\t\tif (!triggerPrice) {\n\t\t\tthrow new Error(`Order type '${orderType}' requires --triggerPrice`);\n\t\t}\n\t} else if (orderType === 'oracleLimit') {\n\t\tif (!oraclePriceOffset) {\n\t\t\tthrow new Error(`Order type '${orderType}' requires --oraclePriceOffset`);\n\t\t}\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst directionEnum = parseDirection(direction);\n\tconst postOnlyEnum = parsePostOnly(postOnly);\n\tconst limitPriceBN = limitPrice\n\t\t? parseAmount(limitPrice, PRICE_PRECISION)\n\t\t: undefined;\n\tconst triggerPriceBN = triggerPrice\n\t\t? parseAmount(triggerPrice, PRICE_PRECISION)\n\t\t: undefined;\n\n\tconsole.log('--- šŸ“‹ Open Perp Non-Market Order ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Index: ${marketIndex}`);\n\tconsole.log(\n\t\t`šŸ“Š Direction: ${direction} (${ENUM_UTILS.toStr(directionEnum)})`\n\t);\n\n\tif (amount) {\n\t\tconst precision = assetType === 'base' ? BASE_PRECISION : QUOTE_PRECISION;\n\t\tconst amountBN = parseAmount(amount, precision);\n\t\tconsole.log(`šŸ’° Amount: ${amount} (${amountBN.toString()} raw units)`);\n\t\tconsole.log(`šŸ’± Asset Type: ${assetType}`);\n\t} else {\n\t\tconst amountBN = parseAmount(baseAssetAmount, BASE_PRECISION);\n\t\tconsole.log(\n\t\t\t`šŸ’° Base Asset Amount: ${baseAssetAmount} (${amountBN.toString()} raw units)`\n\t\t);\n\t}\n\n\tif (limitPriceBN) {\n\t\tconsole.log(\n\t\t\t`šŸ’µ Limit Price: ${limitPrice} (${limitPriceBN.toString()} raw units)`\n\t\t);\n\t}\n\tif (triggerPriceBN) {\n\t\tconsole.log(\n\t\t\t`šŸŽÆ Trigger Price: ${triggerPrice} (${triggerPriceBN.toString()} raw units)`\n\t\t);\n\t}\n\tconsole.log(`šŸ“ Order Type: ${orderType}`);\n\tconsole.log(`šŸ”„ Reduce Only: ${reduceOnly}`);\n\tconsole.log(`šŸ“Œ Post Only: ${postOnly} (${ENUM_UTILS.toStr(postOnlyEnum)})`);\n\n\t// Just call the main method - it will handle both approaches internally\n\tconst orderTxn = await centralServerDrift.getOpenPerpNonMarketOrderTxn(\n\t\tuserAccountPubkey,\n\t\tmarketIndex,\n\t\tdirectionEnum,\n\t\tamount\n\t\t\t? parseAmount(\n\t\t\t\t\tamount,\n\t\t\t\t\tassetType === 'base' ? BASE_PRECISION : QUOTE_PRECISION\n\t\t\t )\n\t\t\t: parseAmount(baseAssetAmount, BASE_PRECISION),\n\t\tamount ? (assetType as 'base' | 'quote') : 'base',\n\t\tlimitPriceBN,\n\t\ttriggerPriceBN,\n\t\torderType as NonMarketOrderType,\n\t\treduceOnly,\n\t\tpostOnlyEnum,\n\t\tfalse // useSwift\n\t);\n\n\tawait executeTransaction(\n\t\torderTxn as VersionedTransaction,\n\t\t'Open Perp Non-Market Order'\n\t);\n}\n\n/**\n * CLI Command: openPerpNonMarketOrderSwift (Swift signed message limit order)\n */\nasync function openPerpNonMarketOrderSwiftCommand(\n\targs: CliArgs\n): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketIndex = parseInt(args.marketIndex as string);\n\tconst direction = args.direction as string;\n\tconst amount = args.amount as string;\n\tconst assetType = (args.assetType as string) || 'base';\n\tconst baseAssetAmount = args.baseAssetAmount as string;\n\tconst orderType = args.orderType as string;\n\tconst limitPrice = args.limitPrice as string;\n\tconst reduceOnly = (args.reduceOnly as string) === 'true';\n\tconst postOnly = (args.postOnly as string) || 'none';\n\tconst swiftServerUrl = API_URLS.SWIFT;\n\n\tif (!userAccount || isNaN(marketIndex) || !direction || !orderType) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --marketIndex, --direction, --orderType'\n\t\t);\n\t}\n\n\tif (!amount && !baseAssetAmount) {\n\t\tthrow new Error('Either --amount or --baseAssetAmount must be provided');\n\t}\n\n\t// Swift orders only support LIMIT order type\n\tif (orderType.toLowerCase() !== 'limit') {\n\t\tthrow new Error('Swift orders only support LIMIT order type');\n\t}\n\n\t// LIMIT orders require limitPrice\n\tif (!limitPrice) {\n\t\tthrow new Error('LIMIT orders require --limitPrice');\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst directionEnum = parseDirection(direction);\n\tconst postOnlyEnum = parsePostOnly(postOnly);\n\tconst limitPriceBN = parseAmount(limitPrice, PRICE_PRECISION);\n\n\tconsole.log('--- ⚔ Open Perp Non-Market Order Swift ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Index: ${marketIndex}`);\n\tconsole.log(\n\t\t`šŸ“Š Direction: ${direction} (${ENUM_UTILS.toStr(directionEnum)})`\n\t);\n\n\tif (amount) {\n\t\tconst precision = assetType === 'base' ? BASE_PRECISION : QUOTE_PRECISION;\n\t\tconst amountBN = parseAmount(amount, precision);\n\t\tconsole.log(`šŸ’° Amount: ${amount} (${amountBN.toString()} raw units)`);\n\t\tconsole.log(`šŸ’± Asset Type: ${assetType}`);\n\t} else {\n\t\tconst amountBN = parseAmount(baseAssetAmount, BASE_PRECISION);\n\t\tconsole.log(\n\t\t\t`šŸ’° Base Asset Amount: ${baseAssetAmount} (${amountBN.toString()} raw units)`\n\t\t);\n\t}\n\n\tconsole.log(\n\t\t`šŸ’µ Limit Price: ${limitPrice} (${limitPriceBN.toString()} raw units)`\n\t);\n\tconsole.log(`šŸ“ Order Type: ${orderType})`);\n\tconsole.log(`šŸ”„ Reduce Only: ${reduceOnly}`);\n\tconsole.log(`šŸ“Œ Post Only: ${postOnly} (${ENUM_UTILS.toStr(postOnlyEnum)})`);\n\tconsole.log(`⚔ Swift Server: ${swiftServerUrl}`);\n\tconsole.log(`šŸ”‘ Wallet Public Key: ${wallet.publicKey.toString()}`);\n\n\tlet swiftResult: SwiftOrderResult;\n\ttry {\n\t\tconst swiftOptions = {\n\t\t\twallet: {\n\t\t\t\tsignMessage: async (message: Uint8Array) => {\n\t\t\t\t\tconst signature = sign.detached(message, wallet.payer.secretKey);\n\t\t\t\t\treturn new Uint8Array(signature);\n\t\t\t\t},\n\t\t\t\tpublicKey: wallet.publicKey,\n\t\t\t},\n\t\t\tswiftServerUrl,\n\t\t\tconfirmDuration: 30000,\n\t\t};\n\n\t\t// Use the main method - it handles both approaches internally\n\t\tswiftResult = (await centralServerDrift.getOpenPerpNonMarketOrderTxn(\n\t\t\tuserAccountPubkey,\n\t\t\tmarketIndex,\n\t\t\tdirectionEnum,\n\t\t\tamount\n\t\t\t\t? parseAmount(\n\t\t\t\t\t\tamount,\n\t\t\t\t\t\tassetType === 'base' ? BASE_PRECISION : QUOTE_PRECISION\n\t\t\t\t )\n\t\t\t\t: parseAmount(baseAssetAmount, BASE_PRECISION),\n\t\t\tamount ? (assetType as 'base' | 'quote') : 'base',\n\t\t\tlimitPriceBN,\n\t\t\tundefined, // triggerPrice - not used for LIMIT orders\n\t\t\torderType as NonMarketOrderType,\n\t\t\treduceOnly,\n\t\t\tpostOnlyEnum,\n\t\t\ttrue, // useSwift\n\t\t\tswiftOptions\n\t\t)) as SwiftOrderResult;\n\t\tconsole.log(\n\t\t\t'āœ… [CLI] Swift non-market order transaction created successfully!'\n\t\t);\n\t} catch (error) {\n\t\tconsole.error('āŒ [CLI] Error creating Swift non-market order:', error);\n\t\tthrow error;\n\t}\n\n\thandleSwiftOrder(swiftResult, 'Open Perp Non-Market Order');\n}\n\n/**\n * Show CLI usage information\n */\nfunction showUsage(): void {\n\tconsole.log('šŸ“‹ Drift CLI Usage');\n\tconsole.log('');\n\tconsole.log('Available Commands:');\n\tconsole.log('');\n\n\tconsole.log('šŸ’° deposit');\n\tconsole.log(\n\t\t' ts-node cli.ts deposit --userAccount=<pubkey> --marketIndex=<num> --amount=<num>'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts deposit --userAccount=11111111111111111111111111111111 --marketIndex=0 --amount=100'\n\t);\n\tconsole.log('');\n\n\tconsole.log('šŸ’ø withdraw');\n\tconsole.log(\n\t\t' ts-node cli.ts withdraw --userAccount=<pubkey> --marketIndex=<num> --amount=<num> [--isBorrow=<bool>] [--isMax=<bool>]'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts withdraw --userAccount=11111111111111111111111111111111 --marketIndex=0 --amount=50'\n\t);\n\tconsole.log('');\n\n\tconsole.log('šŸ¦ settleFunding');\n\tconsole.log(' ts-node cli.ts settleFunding --userAccount=<pubkey>');\n\tconsole.log(\n\t\t' Example: ts-node cli.ts settleFunding --userAccount=11111111111111111111111111111111'\n\t);\n\tconsole.log('');\n\n\tconsole.log('šŸ“Š settlePnl');\n\tconsole.log(\n\t\t' ts-node cli.ts settlePnl --userAccount=<pubkey> --marketIndexes=<comma-separated>'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts settlePnl --userAccount=11111111111111111111111111111111 --marketIndexes=0,1'\n\t);\n\tconsole.log('');\n\n\tconsole.log('šŸŽÆ openPerpMarketOrder');\n\tconsole.log(\n\t\t' ts-node cli.ts openPerpMarketOrder --userAccount=<pubkey> --marketIndex=<num> --direction=<long|short> --amount=<num> [--assetType=<base|quote>]'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts openPerpMarketOrder --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=long --amount=0.1 --assetType=base'\n\t);\n\tconsole.log('');\n\n\tconsole.log('⚔ openPerpMarketOrderSwift');\n\tconsole.log(\n\t\t' ts-node cli.ts openPerpMarketOrderSwift --userAccount=<pubkey> --marketIndex=<num> --direction=<long|short> --amount=<num> [--assetType=<base|quote>]'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts openPerpMarketOrderSwift --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=short --amount=100 --assetType=quote'\n\t);\n\tconsole.log('');\n\n\tconsole.log('šŸ“‹ openPerpNonMarketOrder');\n\tconsole.log(\n\t\t' ts-node cli.ts openPerpNonMarketOrder --userAccount=<pubkey> --marketIndex=<num> --direction=<long|short> --amount=<num> [--assetType=<base|quote>] --orderType=<limit|trigger_limit|trigger_market|oracle> [--limitPrice=<num>] [--triggerPrice=<num>] [--reduceOnly=<true|false>] [--postOnly=<none|must_post_only|try_post_only|slide>]'\n\t);\n\tconsole.log(\n\t\t' New LIMIT: ts-node cli.ts openPerpNonMarketOrder --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=long --amount=0.1 --assetType=base --orderType=limit --limitPrice=100'\n\t);\n\tconsole.log(\n\t\t' New QUOTE: ts-node cli.ts openPerpNonMarketOrder --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=long --amount=100 --assetType=quote --orderType=limit --limitPrice=100'\n\t);\n\tconsole.log(\n\t\t' Legacy: ts-node cli.ts openPerpNonMarketOrder --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=long --baseAssetAmount=0.1 --orderType=limit --limitPrice=100'\n\t);\n\tconsole.log('');\n\n\tconsole.log('⚔ openPerpNonMarketOrderSwift');\n\tconsole.log(\n\t\t' ts-node cli.ts openPerpNonMarketOrderSwift --userAccount=<pubkey> --marketIndex=<num> --direction=<long|short> --amount=<num> [--assetType=<base|quote>] --orderType=limit --limitPrice=<num> [--reduceOnly=<true|false>] [--postOnly=<none|must_post_only|try_post_only|slide>]'\n\t);\n\tconsole.log(\n\t\t' New: ts-node cli.ts openPerpNonMarketOrderSwift --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=long --amount=0.1 --assetType=base --orderType=limit --limitPrice=99.5'\n\t);\n\tconsole.log(\n\t\t' Legacy: ts-node cli.ts openPerpNonMarketOrderSwift --userAccount=11111111111111111111111111111111 --marketIndex=0 --direction=long --baseAssetAmount=0.1 --orderType=limit --limitPrice=99.5'\n\t);\n\tconsole.log('');\n\n\tconsole.log('āœļø editOrder');\n\tconsole.log(\n\t\t' ts-node cli.ts editOrder --userAccount=<pubkey> --orderId=<num> [--newDirection=<long|short>] [--newBaseAmount=<num>] [--newLimitPrice=<num>] [--newTriggerPrice=<num>] [--reduceOnly=<true|false>] [--postOnly=<true|false>]'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts editOrder --userAccount=11111111111111111111111111111111 --orderId=123 --newLimitPrice=105.5'\n\t);\n\tconsole.log('');\n\n\tconsole.log('āŒ cancelOrder');\n\tconsole.log(\n\t\t' ts-node cli.ts cancelOrder --userAccount=<pubkey> --orderIds=<comma-separated-list>'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts cancelOrder --userAccount=11111111111111111111111111111111 --orderIds=123,456,789'\n\t);\n\tconsole.log('');\n\n\tconsole.log('🧹 cancelAllOrders');\n\tconsole.log(\n\t\t' ts-node cli.ts cancelAllOrders --userAccount=<pubkey> [--marketType=<perp|spot>] [--marketIndex=<num>] [--direction=<long|short>]'\n\t);\n\tconsole.log(\n\t\t' Example: ts-node cli.ts cancelAllOrders --userAccount=11111111111111111111111111111111 --marketType=perp'\n\t);\n\tconsole.log('');\n\n\tconsole.log('šŸ”„ swap');\n\tconsole.log(\n\t\t' ts-node cli.ts swap --userAccount=<pubkey> --fromMarketIndex=<num> --toMarketIndex=<num> [--fromAmount=<num>] [--toAmount=<num>] [--slippage=<bps>] [--swapMode=<ExactIn|ExactOut>]'\n\t);\n\tconsole.log(\n\t\t' ExactIn: ts-node cli.ts swap --userAccount=11111111111111111111111111111111 --fromMarketIndex=1 --toMarketIndex=0 --fromAmount=1.5 --swapMode=ExactIn'\n\t);\n\tconsole.log(\n\t\t' ExactOut: ts-node cli.ts swap --userAccount=11111111111111111111111111111111 --fromMarketIndex=1 --toMarketIndex=0 --toAmount=150 --swapMode=ExactOut'\n\t);\n\tconsole.log('');\n\n\tconsole.log('Options:');\n\tconsole.log(' --help, -h Show this help message');\n\tconsole.log('');\n\tconsole.log('Notes:');\n\tconsole.log(\n\t\t' - Amounts are in human-readable format (e.g., 1.5 USDC, 0.1 SOL)'\n\t);\n\tconsole.log(' - Direction can be: long, short, buy, sell');\n\tconsole.log(\n\t\t' - Asset type: base (for native tokens like SOL) or quote (for USDC amounts)'\n\t);\n\tconsole.log(' - Swap modes:');\n\tconsole.log(\n\t\t' * ExactIn: Specify --fromAmount (how much input token to swap)'\n\t);\n\tconsole.log(\n\t\t' * ExactOut: Specify --toAmount (how much output token to receive)'\n\t);\n\tconsole.log(' - Ensure your .env file contains ANCHOR_WALLET and ENDPOINT');\n}\n\n/**\n * CLI Command: editOrder\n */\nasync function editOrderCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst orderId = parseInt(args.orderId as string);\n\tconst newDirection = args.newDirection as string;\n\tconst newBaseAmount = args.newBaseAmount as string;\n\tconst newLimitPrice = args.newLimitPrice as string;\n\tconst newTriggerPrice = args.newTriggerPrice as string;\n\tconst reduceOnly = (args.reduceOnly as string) === 'true';\n\tconst postOnly = (args.postOnly as string) === 'true';\n\n\tif (!userAccount || isNaN(orderId)) {\n\t\tthrow new Error('Required arguments: --userAccount, --orderId');\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst editParams: any = {};\n\n\tif (newDirection) {\n\t\teditParams.newDirection = parseDirection(newDirection);\n\t}\n\n\tif (newBaseAmount) {\n\t\teditParams.newBaseAmount = parseAmount(newBaseAmount, BASE_PRECISION);\n\t}\n\n\tif (newLimitPrice) {\n\t\teditParams.newLimitPrice = parseAmount(newLimitPrice, PRICE_PRECISION);\n\t}\n\n\tif (newTriggerPrice) {\n\t\teditParams.newTriggerPrice = parseAmount(newTriggerPrice, PRICE_PRECISION);\n\t}\n\n\tif (reduceOnly) {\n\t\teditParams.reduceOnly = true;\n\t}\n\n\tif (postOnly) {\n\t\teditParams.postOnly = true;\n\t}\n\n\tconsole.log('--- āœļø Edit Order ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸ†” Order ID: ${orderId}`);\n\tconsole.log(`šŸ“ Edit Parameters:`, editParams);\n\n\tconst editOrderTxn = await centralServerDrift.getEditOrderTxn(\n\t\tuserAccountPubkey,\n\t\torderId,\n\t\teditParams\n\t);\n\n\tawait executeTransaction(editOrderTxn as VersionedTransaction, 'Edit Order');\n}\n\n/**\n * CLI Command: cancelOrder\n */\nasync function cancelOrderCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst orderIds = args.orderIds as string;\n\n\tif (!userAccount || !orderIds) {\n\t\tthrow new Error('Required arguments: --userAccount, --orderIds');\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tconst orderIdArray = orderIds.split(',').map((id) => parseInt(id.trim()));\n\n\tconsole.log('--- āŒ Cancel Orders ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸ†” Order IDs: ${orderIdArray.join(', ')}`);\n\n\tconst cancelOrderTxn = await centralServerDrift.getCancelOrdersTxn(\n\t\tuserAccountPubkey,\n\t\torderIdArray\n\t);\n\n\tawait executeTransaction(\n\t\tcancelOrderTxn as VersionedTransaction,\n\t\t'Cancel Orders'\n\t);\n}\n\n/**\n * CLI Command: cancelAllOrders\n */\nasync function cancelAllOrdersCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst marketType = args.marketType as string;\n\tconst marketIndex = args.marketIndex\n\t\t? parseInt(args.marketIndex as string)\n\t\t: undefined;\n\tconst direction = args.direction as string;\n\n\tif (!userAccount) {\n\t\tthrow new Error('Required arguments: --userAccount');\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\tlet marketTypeEnum = undefined;\n\tlet directionEnum = undefined;\n\n\tif (marketType) {\n\t\tmarketTypeEnum =\n\t\t\tmarketType.toLowerCase() === 'perp' ? { perp: {} } : { spot: {} };\n\t}\n\n\tif (direction) {\n\t\tdirectionEnum = parseDirection(direction);\n\t}\n\n\tconsole.log('--- 🧹 Cancel All Orders ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸŖ Market Type Filter: ${marketType || 'none'}`);\n\tconsole.log(\n\t\t`šŸ“Š Market Index Filter: ${\n\t\t\tmarketIndex !== undefined ? marketIndex : 'none'\n\t\t}`\n\t);\n\tconsole.log(`šŸ“ˆ Direction Filter: ${direction || 'none'}`);\n\n\tconst cancelAllOrdersTxn = await centralServerDrift.getCancelAllOrdersTxn(\n\t\tuserAccountPubkey,\n\t\tmarketTypeEnum,\n\t\tmarketIndex,\n\t\tdirectionEnum\n\t);\n\n\tawait executeTransaction(\n\t\tcancelAllOrdersTxn as VersionedTransaction,\n\t\t'Cancel All Orders'\n\t);\n}\n\n/**\n * CLI Command: swap\n */\nasync function swapCommand(args: CliArgs): Promise<void> {\n\tconst userAccount = args.userAccount as string;\n\tconst fromMarketIndex = parseInt(args.fromMarketIndex as string);\n\tconst toMarketIndex = parseInt(args.toMarketIndex as string);\n\tconst fromAmount = args.fromAmount as string;\n\tconst toAmount = args.toAmount as string;\n\tconst slippage = args.slippage ? parseInt(args.slippage as string) : 10; // Default 0.1%\n\tconst swapMode = (args.swapMode as string) || 'ExactIn';\n\n\tif (!userAccount || isNaN(fromMarketIndex) || isNaN(toMarketIndex)) {\n\t\tthrow new Error(\n\t\t\t'Required arguments: --userAccount, --fromMarketIndex, --toMarketIndex'\n\t\t);\n\t}\n\n\tconst swapModeEnum = parseSwapMode(swapMode);\n\n\t// Validate amount parameters based on swap mode\n\tif (swapModeEnum === 'ExactIn') {\n\t\tif (!fromAmount) {\n\t\t\tthrow new Error('ExactIn swap mode requires --fromAmount');\n\t\t}\n\t\tif (toAmount) {\n\t\t\tconsole.warn(\n\t\t\t\t'āš ļø Warning: --toAmount ignored in ExactIn mode, using --fromAmount'\n\t\t\t);\n\t\t}\n\t} else if (swapModeEnum === 'ExactOut') {\n\t\tif (!toAmount) {\n\t\t\tthrow new Error('ExactOut swap mode requires --toAmount');\n\t\t}\n\t\tif (fromAmount) {\n\t\t\tconsole.warn(\n\t\t\t\t'āš ļø Warning: --fromAmount ignored in ExactOut mode, using --toAmount'\n\t\t\t);\n\t\t}\n\t}\n\n\tconst userAccountPubkey = new PublicKey(userAccount);\n\n\t// Use the appropriate amount based on swap mode\n\tconst amount = swapModeEnum === 'ExactIn' ? fromAmount : toAmount;\n\n\t// Determine which market to use for precision (input market for ExactIn, output market for ExactOut)\n\tconst precisionMarketIndex =\n\t\tswapModeEnum === 'ExactIn' ? fromMarketIndex : toMarketIndex;\n\n\t// Get the appropriate precision for the amount based on the market\n\tconst isMainnet = true; // Default to mainnet, could be made configurable\n\tconst precision = getMarketPrecision(precisionMarketIndex, isMainnet);\n\tconst amountBN = parseAmount(amount, precision);\n\n\tconsole.log('--- šŸ”„ Swap Transaction ---');\n\tconsole.log(`šŸ‘¤ User Account: ${userAccount}`);\n\tconsole.log(`šŸ“¤ From Market Index: ${fromMarketIndex}`);\n\tconsole.log(`šŸ“„ To Market Index: ${toMarketIndex}`);\n\tconsole.log(`šŸ”„ Swap Mode: ${swapMode}`);\n\tconsole.log(\n\t\t`šŸŽÆ Using precision from market ${precisionMarketIndex}: ${precision.toString()}`\n\t);\n\n\tif (swapModeEnum === 'ExactIn') {\n\t\tconsole.log(\n\t\t\t`šŸ’° From Amount: ${fromAmount} (${amountBN.toString()} raw units)`\n\t\t);\n\t\tconsole.log(`šŸ’° To Amount: Will be calculated based on quote`);\n\t} else {\n\t\tconsole.log(`šŸ’° From Amount: Will be calculated based on quote`);\n\t\tconsole.log(`šŸ’° To Amount: ${toAmount} (${amountBN.toString()} raw units)`);\n\t}\n\n\tconsole.log(`šŸ“Š Slippage: ${slippage} BPS (${slippage / 100}%)`);\n\n\tconst swapTxn = await centralServerDrift.getSwapTxn(\n\t\tuserAccountPubkey,\n\t\tfromMarketIndex,\n\t\ttoMarketIndex,\n\t\tamountBN,\n\t\t{\n\t\t\tslippageBps: slippage,\n\t\t\tswapMode: swapModeEnum,\n\t\t}\n\t);\n\n\tawait executeTransaction(swapTxn as VersionedTransaction, 'Swap');\n}\n\n/**\n * Main CLI entry point\n */\nasync function main(): Promise<void> {\n\tconst args = process.argv.slice(2);\n\n\tif (\n\t\targs.length === 0 ||\n\t\targs[0] === '--help' ||\n\t\targs[0] === '-h' ||\n\t\targs[0] === 'help'\n\t) {\n\t\tshowUsage();\n\t\treturn;\n\t}\n\n\tconst command = args[0];\n\tconst parsedArgs = parseArgs(args.slice(1));\n\n\t// Initialize the client first\n\tawait initializeCentralServerDrift();\n\n\t// Route to appropriate command\n\tswitch (command) {\n\t\tcase 'deposit':\n\t\t\tawait depositCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'withdraw':\n\t\t\tawait withdrawCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'settleFunding':\n\t\t\tawait settleFundingCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'settlePnl':\n\t\t\tawait settlePnlCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'openPerpMarketOrder':\n\t\t\tawait openPerpMarketOrderCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'openPerpMarketOrderSwift':\n\t\t\tawait openPerpMarketOrderSwiftCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'openPerpNonMarketOrder':\n\t\t\tawait openPerpNonMarketOrderCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'openPerpNonMarketOrderSwift':\n\t\t\tawait openPerpNonMarketOrderSwiftCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'editOrder':\n\t\t\tawait editOrderCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'cancelOrder':\n\t\t\tawait cancelOrderCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'cancelAllOrders':\n\t\t\tawait cancelAllOrdersCommand(parsedArgs);\n\t\t\tbreak;\n\t\tcase 'swap':\n\t\t\tawait swapCommand(parsedArgs);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tconsole.error(`āŒ Unknown command: ${command}`);\n\t\t\tconsole.error('');\n\t\t\tshowUsage();\n\t\t\tprocess.exit(1);\n\t}\n}\n\n// Run CLI if this file is executed directly\nif (require.main === module) {\n\tmain()\n\t\t.then(() => {\n\t\t\tconsole.log('\\n✨ Command executed successfully!');\n\t\t\t// Don't exit immediately for Swift orders (they need time to process)\n\t\t\tsetTimeout(() => process.exit(0), 2000);\n\t\t})\n\t\t.catch((error) => {\n\t\t\tconsole.error('\\nšŸ’„ Command failed:', error.message || error);\n\t\t\tprocess.exit(1);\n\t\t});\n}\n\nexport { main, parseArgs, parseAmount, parseDirection, parseSwapMode };\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * API URL constants for Drift protocol services
3
+ *
4
+ * These constants define the URLs used within the drift directory for various Drift services.
5
+ */
6
+ export declare const API_URLS: {
7
+ /**
8
+ * Data API - Used for historical data, funding rates, candles, etc.
9
+ */
10
+ readonly DATA_API: "https://data.api.drift.trade";
11
+ /**
12
+ * DLOB (Decentralized Limit Order Book) Server - Used for auction parameters, priority fees, etc.
13
+ */
14
+ readonly DLOB: "https://dlob.drift.trade";
15
+ /**
16
+ * Swift Server - Used for signed message (gasless) orders
17
+ */
18
+ readonly SWIFT: "https://swift.drift.trade";
19
+ };
20
+ /**
21
+ * API endpoints for specific functionality
22
+ */
23
+ export declare const API_ENDPOINTS: {
24
+ readonly FUNDING_RATES: "/fundingRates";
25
+ readonly BATCH_PRIORITY_FEES: "/batchPriorityFees";
26
+ readonly AUCTION_PARAMS: "/auctionParams";
27
+ };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * API URL constants for Drift protocol services
4
+ *
5
+ * These constants define the URLs used within the drift directory for various Drift services.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.API_ENDPOINTS = exports.API_URLS = void 0;
9
+ exports.API_URLS = {
10
+ /**
11
+ * Data API - Used for historical data, funding rates, candles, etc.
12
+ */
13
+ DATA_API: 'https://data.api.drift.trade',
14
+ /**
15
+ * DLOB (Decentralized Limit Order Book) Server - Used for auction parameters, priority fees, etc.
16
+ */
17
+ DLOB: 'https://dlob.drift.trade',
18
+ /**
19
+ * Swift Server - Used for signed message (gasless) orders
20
+ */
21
+ SWIFT: 'https://swift.drift.trade',
22
+ };
23
+ /**
24
+ * API endpoints for specific functionality
25
+ */
26
+ exports.API_ENDPOINTS = {
27
+ FUNDING_RATES: '/fundingRates',
28
+ BATCH_PRIORITY_FEES: '/batchPriorityFees',
29
+ AUCTION_PARAMS: '/auctionParams',
30
+ };
31
+ //# sourceMappingURL=apiUrls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiUrls.js","sourceRoot":"","sources":["../../../src/drift/constants/apiUrls.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEU,QAAA,QAAQ,GAAG;IACvB;;OAEG;IACH,QAAQ,EAAE,8BAA8B;IAExC;;OAEG;IACH,IAAI,EAAE,0BAA0B;IAEhC;;OAEG;IACH,KAAK,EAAE,2BAA2B;CACzB,CAAC;AAEX;;GAEG;AACU,QAAA,aAAa,GAAG;IAC5B,aAAa,EAAE,eAAe;IAC9B,mBAAmB,EAAE,oBAAoB;IACzC,cAAc,EAAE,gBAAgB;CACvB,CAAC","sourcesContent":["/**\n * API URL constants for Drift protocol services\n *\n * These constants define the URLs used within the drift directory for various Drift services.\n */\n\nexport const API_URLS = {\n\t/**\n\t * Data API - Used for historical data, funding rates, candles, etc.\n\t */\n\tDATA_API: 'https://data.api.drift.trade',\n\n\t/**\n\t * DLOB (Decentralized Limit Order Book) Server - Used for auction parameters, priority fees, etc.\n\t */\n\tDLOB: 'https://dlob.drift.trade',\n\n\t/**\n\t * Swift Server - Used for signed message (gasless) orders\n\t */\n\tSWIFT: 'https://swift.drift.trade',\n} as const;\n\n/**\n * API endpoints for specific functionality\n */\nexport const API_ENDPOINTS = {\n\tFUNDING_RATES: '/fundingRates',\n\tBATCH_PRIORITY_FEES: '/batchPriorityFees',\n\tAUCTION_PARAMS: '/auctionParams',\n} as const;\n"]}
@@ -0,0 +1,19 @@
1
+ declare function initializeCentralServerDrift(): Promise<void>;
2
+ /**
3
+ * Example 1: Deposit and Withdraw transactions
4
+ */
5
+ declare function depositWithdrawExample(): Promise<void>;
6
+ /**
7
+ * Example 2: Settle Funding Payments
8
+ */
9
+ declare function settleFundingExample(): Promise<void>;
10
+ /**
11
+ * Example 3: Settle PnL for Multiple Markets
12
+ */
13
+ declare function settlePnlExample(): Promise<void>;
14
+ /**
15
+ * Run all examples in sequence
16
+ */
17
+ declare function runAllExamples(): Promise<void>;
18
+ export { initializeCentralServerDrift, depositWithdrawExample, settleFundingExample, settlePnlExample, runAllExamples, };
19
+ export declare const runCentralServerDriftExample: typeof runAllExamples;
@@ -0,0 +1,249 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.runCentralServerDriftExample = exports.runAllExamples = exports.settlePnlExample = exports.settleFundingExample = exports.depositWithdrawExample = exports.initializeCentralServerDrift = void 0;
27
+ const anchor = __importStar(require("@coral-xyz/anchor"));
28
+ const web3_js_1 = require("@solana/web3.js");
29
+ const sdk_1 = require("@drift-labs/sdk");
30
+ const CentralServerDrift_1 = require("./Drift/clients/CentralServerDrift");
31
+ const path = __importStar(require("path"));
32
+ // Load environment variables from .env file
33
+ const dotenv = require('dotenv');
34
+ dotenv.config({ path: path.resolve(__dirname, '.env') });
35
+ /**
36
+ * Example usage of CentralServerDrift client
37
+ *
38
+ * This file contains multiple examples demonstrating how to:
39
+ * 1. Set up an Anchor wallet with a private key
40
+ * 2. Initialize a CentralServerDrift instance
41
+ * 3. Create and execute various transaction types
42
+ *
43
+ * Prerequisites:
44
+ * - Create a .env file in the same directory as this example file with:
45
+ * ANCHOR_WALLET=[private key byte array]
46
+ * ENDPOINT=https://your-rpc-endpoint.com
47
+ *
48
+ * Usage:
49
+ * - Run all examples: ts-node example.ts
50
+ * - Run specific example: ts-node example.ts <example-name>
51
+ * Available examples: depositWithdraw, settleFunding, settlePnl
52
+ */
53
+ // Shared configuration and setup
54
+ let centralServerDrift;
55
+ let wallet;
56
+ const userAccountPublicKey = new web3_js_1.PublicKey('11111111111111111111111111111111'); // enter the publickey for the drift account here
57
+ async function initializeCentralServerDrift() {
58
+ console.log('šŸš€ Initializing CentralServerDrift...\n');
59
+ // Validate required environment variables
60
+ if (!process.env.ANCHOR_WALLET) {
61
+ throw new Error('ANCHOR_WALLET must be set');
62
+ }
63
+ if (!process.env.ENDPOINT) {
64
+ throw new Error('ENDPOINT environment variable must be set to your Solana RPC endpoint');
65
+ }
66
+ // Set up the wallet
67
+ wallet = new anchor.Wallet((0, sdk_1.loadKeypair)(process.env.ANCHOR_WALLET));
68
+ console.log(`āœ… Wallet Public Key: ${wallet.publicKey.toString()}`);
69
+ console.log(`āœ… RPC Endpoint: ${process.env.ENDPOINT}\n`);
70
+ // Initialize CentralServerDrift
71
+ console.log('šŸ—ļø Initializing CentralServerDrift...');
72
+ centralServerDrift = new CentralServerDrift_1.CentralServerDrift({
73
+ solanaRpcEndpoint: process.env.ENDPOINT,
74
+ driftEnv: 'mainnet-beta', // Change to 'devnet' for devnet testing
75
+ additionalDriftClientConfig: {
76
+ // Optional: Add additional DriftClient configuration
77
+ txVersion: 0,
78
+ txParams: {
79
+ computeUnits: 200000,
80
+ computeUnitsPrice: 1000,
81
+ },
82
+ },
83
+ });
84
+ console.log('āœ… CentralServerDrift instance created successfully\n');
85
+ // Subscribe to market data
86
+ console.log('šŸ“” Subscribing to market data...');
87
+ await centralServerDrift.subscribe();
88
+ console.log('āœ… Successfully subscribed to market data\n');
89
+ }
90
+ exports.initializeCentralServerDrift = initializeCentralServerDrift;
91
+ /**
92
+ * Reusable function to handle transaction signing and sending
93
+ */
94
+ async function executeVersionedTransaction(txn, transactionType) {
95
+ console.log(`āœ… ${transactionType} transaction created successfully`);
96
+ console.log(`šŸ“‹ Transaction Type: ${txn.constructor.name}`);
97
+ console.log('\nšŸ“ Signing Transaction...');
98
+ // Sign with the wallet's keypair
99
+ txn.sign([wallet.payer]);
100
+ console.log('āœ… Transaction signed successfully');
101
+ console.log(` Signatures Count After Signing: ${txn.signatures.length}`);
102
+ console.log(` First Signature Present: ${txn.signatures[0] && txn.signatures[0].length > 0}`);
103
+ console.log('\nšŸš€ Sending transaction to the network...');
104
+ const txSig = await centralServerDrift.sendSignedTransaction(txn);
105
+ console.log('āœ… Transaction sent successfully!');
106
+ console.log(`šŸ“‹ Transaction Signature: ${txSig}`);
107
+ console.log(`šŸ” View on Solscan: https://solscan.io/tx/${txSig}`);
108
+ }
109
+ /**
110
+ * Example 1: Deposit and Withdraw transactions
111
+ */
112
+ async function depositWithdrawExample() {
113
+ console.log('šŸš€ Starting Deposit/Withdraw Example...\n');
114
+ // Configuration for this example
115
+ const amount = new sdk_1.BN(1000000); // 1 USDC (6 decimals)
116
+ const spotMarketIndex = 0; // USDC market index
117
+ // Example 1: Create a deposit transaction
118
+ console.log('--- šŸ“„ Creating Deposit Transaction ---');
119
+ try {
120
+ console.log(`šŸ’° Deposit Amount: ${amount.toString()} raw units`);
121
+ console.log(`šŸŖ Spot Market Index: ${spotMarketIndex}`);
122
+ const depositTxn = await centralServerDrift.getDepositTxn(userAccountPublicKey, amount, spotMarketIndex);
123
+ await executeVersionedTransaction(depositTxn, 'Deposit');
124
+ }
125
+ catch (error) {
126
+ console.error('āŒ Error during deposit transaction flow:', error);
127
+ }
128
+ // Example 2: Create a withdraw transaction
129
+ console.log('\n--- šŸ“¤ Creating Withdraw Transaction ---');
130
+ try {
131
+ console.log(`šŸ’° Withdraw Amount: ${amount.toString()} raw units`);
132
+ console.log(`šŸŖ Spot Market Index: ${spotMarketIndex}`);
133
+ const withdrawTxn = await centralServerDrift.getWithdrawTxn(userAccountPublicKey, amount, spotMarketIndex, {
134
+ isBorrow: false, // true = borrow, false = reduce-only withdraw
135
+ isMax: false, // true = withdraw maximum available
136
+ });
137
+ await executeVersionedTransaction(withdrawTxn, 'Withdraw');
138
+ }
139
+ catch (error) {
140
+ console.error('āŒ Error during withdraw transaction flow:', error);
141
+ }
142
+ }
143
+ exports.depositWithdrawExample = depositWithdrawExample;
144
+ /**
145
+ * Example 2: Settle Funding Payments
146
+ */
147
+ async function settleFundingExample() {
148
+ console.log('šŸš€ Starting Settle Funding Example...\n');
149
+ console.log('--- šŸ’° Creating Settle Funding Transaction ---');
150
+ try {
151
+ console.log(`šŸ‘¤ User Account: ${userAccountPublicKey.toString()}`);
152
+ console.log('šŸ“‹ Settling funding payments for all perp positions...');
153
+ const settleFundingTxn = await centralServerDrift.getSettleFundingTxn(userAccountPublicKey);
154
+ await executeVersionedTransaction(settleFundingTxn, 'Settle Funding');
155
+ }
156
+ catch (error) {
157
+ console.error('āŒ Error during settle funding transaction flow:', error);
158
+ }
159
+ }
160
+ exports.settleFundingExample = settleFundingExample;
161
+ /**
162
+ * Example 3: Settle PnL for Multiple Markets
163
+ */
164
+ async function settlePnlExample() {
165
+ console.log('šŸš€ Starting Settle PnL Example...\n');
166
+ // Configuration for this example
167
+ const marketIndexes = [1]; // BTC-PERP
168
+ console.log('--- šŸ“ˆ Creating Settle PnL Transaction ---');
169
+ try {
170
+ console.log(`šŸ‘¤ User Account: ${userAccountPublicKey.toString()}`);
171
+ console.log(`šŸ“Š Market Indexes: ${marketIndexes.join(', ')}`);
172
+ const settlePnlTxn = await centralServerDrift.getSettlePnlTxn(userAccountPublicKey, marketIndexes);
173
+ await executeVersionedTransaction(settlePnlTxn, 'Settle PnL');
174
+ }
175
+ catch (error) {
176
+ console.error('āŒ Error during settle PnL transaction flow:', error);
177
+ }
178
+ }
179
+ exports.settlePnlExample = settlePnlExample;
180
+ /**
181
+ * Run all examples in sequence
182
+ */
183
+ async function runAllExamples() {
184
+ console.log('šŸš€ Running All CentralServerDrift Examples...\n');
185
+ await initializeCentralServerDrift();
186
+ console.log('='.repeat(50));
187
+ await depositWithdrawExample();
188
+ console.log('\n' + '='.repeat(50));
189
+ await settleFundingExample();
190
+ console.log('\n' + '='.repeat(50));
191
+ await settlePnlExample();
192
+ }
193
+ exports.runAllExamples = runAllExamples;
194
+ // Legacy export for backward compatibility
195
+ exports.runCentralServerDriftExample = runAllExamples;
196
+ // Helper functions for command line handling
197
+ function showUsage() {
198
+ console.log('šŸ“‹ Usage: ts-node example.ts [example-name]');
199
+ console.log('\nAvailable examples:');
200
+ console.log(' depositWithdraw - Run deposit and withdraw transaction examples');
201
+ console.log(' settleFunding - Run settle funding payment transaction example');
202
+ console.log(' settlePnl - Run settle PnL transaction example');
203
+ console.log(' all - Run all examples in sequence (default)');
204
+ console.log('\nExamples:');
205
+ console.log(' ts-node example.ts # Run all examples');
206
+ console.log(' ts-node example.ts depositWithdraw # Run only deposit/withdraw example');
207
+ console.log(' ts-node example.ts settleFunding # Run only settle funding example');
208
+ console.log(' ts-node example.ts settlePnl # Run only settle PnL example');
209
+ }
210
+ async function runCliExample(exampleName) {
211
+ const availableExamples = {
212
+ depositWithdraw: () => initializeCentralServerDrift().then(() => depositWithdrawExample()),
213
+ settleFunding: () => initializeCentralServerDrift().then(() => settleFundingExample()),
214
+ settlePnl: () => initializeCentralServerDrift().then(() => settlePnlExample()),
215
+ all: runAllExamples,
216
+ };
217
+ if (exampleName === 'help' ||
218
+ exampleName === '--help' ||
219
+ exampleName === '-h') {
220
+ showUsage();
221
+ return;
222
+ }
223
+ const exampleToRun = exampleName
224
+ ? availableExamples[exampleName]
225
+ : availableExamples['all'];
226
+ if (!exampleToRun) {
227
+ console.error(`āŒ Unknown example: ${exampleName}`);
228
+ console.error('');
229
+ showUsage();
230
+ process.exit(1);
231
+ }
232
+ console.log(`šŸš€ Running example: ${exampleName || 'all'}\n`);
233
+ await exampleToRun();
234
+ }
235
+ // Command line argument handling
236
+ if (require.main === module) {
237
+ const args = process.argv.slice(2);
238
+ const exampleName = args[0];
239
+ runCliExample(exampleName)
240
+ .then(() => {
241
+ console.log('\n✨ Example execution completed successfully!');
242
+ process.exit(0);
243
+ })
244
+ .catch((error) => {
245
+ console.error('\nšŸ’„ Example execution failed:', error);
246
+ process.exit(1);
247
+ });
248
+ }
249
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/drift/example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,6CAAkE;AAClE,yCAAkD;AAClD,2EAAwE;AACxE,2CAA6B;AAE7B,4CAA4C;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AAEH,iCAAiC;AACjC,IAAI,kBAAsC,CAAC;AAC3C,IAAI,MAAqB,CAAC;AAC1B,MAAM,oBAAoB,GAAG,IAAI,mBAAS,CAAC,kCAAkC,CAAC,CAAC,CAAC,iDAAiD;AAEjI,KAAK,UAAU,4BAA4B;IAC1C,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAEvD,0CAA0C;IAC1C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACd,uEAAuE,CACvE,CAAC;IACH,CAAC;IAED,oBAAoB;IACpB,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAA,iBAA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;IAED,MAAM,YAAY,GAAG,WAAW;QAC/B,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC;QAChC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAE5B,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClB,SAAS,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,WAAW,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7D,MAAM,YAAY,EAAE,CAAC;AACtB,CAAC;AAED,iCAAiC;AACjC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAE5B,aAAa,CAAC,WAAW,CAAC;SACxB,IAAI,CAAC,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as anchor from '@coral-xyz/anchor';\nimport { PublicKey, VersionedTransaction } from '@solana/web3.js';\nimport { BN, loadKeypair } from '@drift-labs/sdk';\nimport { CentralServerDrift } from './Drift/clients/CentralServerDrift';\nimport * as path from 'path';\n\n// Load environment variables from .env file\nconst dotenv = require('dotenv');\ndotenv.config({ path: path.resolve(__dirname, '.env') });\n\n/**\n * Example usage of CentralServerDrift client\n *\n * This file contains multiple examples demonstrating how to:\n * 1. Set up an Anchor wallet with a private key\n * 2. Initialize a CentralServerDrift instance\n * 3. Create and execute various transaction types\n *\n * Prerequisites:\n * - Create a .env file in the same directory as this example file with:\n * ANCHOR_WALLET=[private key byte array]\n * ENDPOINT=https://your-rpc-endpoint.com\n *\n * Usage:\n * - Run all examples: ts-node example.ts\n * - Run specific example: ts-node example.ts <example-name>\n * Available examples: depositWithdraw, settleFunding, settlePnl\n */\n\n// Shared configuration and setup\nlet centralServerDrift: CentralServerDrift;\nlet wallet: anchor.Wallet;\nconst userAccountPublicKey = new PublicKey('11111111111111111111111111111111'); // enter the publickey for the drift account here\n\nasync function initializeCentralServerDrift(): Promise<void> {\n\tconsole.log('šŸš€ Initializing CentralServerDrift...\\n');\n\n\t// Validate required environment variables\n\tif (!process.env.ANCHOR_WALLET) {\n\t\tthrow new Error('ANCHOR_WALLET must be set');\n\t}\n\n\tif (!process.env.ENDPOINT) {\n\t\tthrow new Error(\n\t\t\t'ENDPOINT environment variable must be set to your Solana RPC endpoint'\n\t\t);\n\t}\n\n\t// Set up the wallet\n\twallet = new anchor.Wallet(loadKeypair(process.env.ANCHOR_WALLET as string));\n\n\tconsole.log(`āœ… Wallet Public Key: ${wallet.publicKey.toString()}`);\n\tconsole.log(`āœ… RPC Endpoint: ${process.env.ENDPOINT}\\n`);\n\n\t// Initialize CentralServerDrift\n\tconsole.log('šŸ—ļø Initializing CentralServerDrift...');\n\tcentralServerDrift = new CentralServerDrift({\n\t\tsolanaRpcEndpoint: process.env.ENDPOINT as string,\n\t\tdriftEnv: 'mainnet-beta', // Change to 'devnet' for devnet testing\n\t\tadditionalDriftClientConfig: {\n\t\t\t// Optional: Add additional DriftClient configuration\n\t\t\ttxVersion: 0,\n\t\t\ttxParams: {\n\t\t\t\tcomputeUnits: 200000,\n\t\t\t\tcomputeUnitsPrice: 1000,\n\t\t\t},\n\t\t},\n\t});\n\n\tconsole.log('āœ… CentralServerDrift instance created successfully\\n');\n\n\t// Subscribe to market data\n\tconsole.log('šŸ“” Subscribing to market data...');\n\tawait centralServerDrift.subscribe();\n\tconsole.log('āœ… Successfully subscribed to market data\\n');\n}\n\n/**\n * Reusable function to handle transaction signing and sending\n */\nasync function executeVersionedTransaction(\n\ttxn: VersionedTransaction,\n\ttransactionType: string\n): Promise<void> {\n\tconsole.log(`āœ… ${transactionType} transaction created successfully`);\n\tconsole.log(`šŸ“‹ Transaction Type: ${txn.constructor.name}`);\n\tconsole.log('\\nšŸ“ Signing Transaction...');\n\t// Sign with the wallet's keypair\n\ttxn.sign([wallet.payer]);\n\n\tconsole.log('āœ… Transaction signed successfully');\n\tconsole.log(` Signatures Count After Signing: ${txn.signatures.length}`);\n\tconsole.log(\n\t\t` First Signature Present: ${\n\t\t\ttxn.signatures[0] && txn.signatures[0].length > 0\n\t\t}`\n\t);\n\n\tconsole.log('\\nšŸš€ Sending transaction to the network...');\n\n\tconst txSig = await centralServerDrift.sendSignedTransaction(txn);\n\n\tconsole.log('āœ… Transaction sent successfully!');\n\tconsole.log(`šŸ“‹ Transaction Signature: ${txSig}`);\n\tconsole.log(`šŸ” View on Solscan: https://solscan.io/tx/${txSig}`);\n}\n\n/**\n * Example 1: Deposit and Withdraw transactions\n */\nasync function depositWithdrawExample() {\n\tconsole.log('šŸš€ Starting Deposit/Withdraw Example...\\n');\n\n\t// Configuration for this example\n\tconst amount = new BN(1000000); // 1 USDC (6 decimals)\n\tconst spotMarketIndex = 0; // USDC market index\n\n\t// Example 1: Create a deposit transaction\n\tconsole.log('--- šŸ“„ Creating Deposit Transaction ---');\n\n\ttry {\n\t\tconsole.log(`šŸ’° Deposit Amount: ${amount.toString()} raw units`);\n\t\tconsole.log(`šŸŖ Spot Market Index: ${spotMarketIndex}`);\n\n\t\tconst depositTxn = await centralServerDrift.getDepositTxn(\n\t\t\tuserAccountPublicKey,\n\t\t\tamount,\n\t\t\tspotMarketIndex\n\t\t);\n\n\t\tawait executeVersionedTransaction(\n\t\t\tdepositTxn as VersionedTransaction,\n\t\t\t'Deposit'\n\t\t);\n\t} catch (error) {\n\t\tconsole.error('āŒ Error during deposit transaction flow:', error);\n\t}\n\n\t// Example 2: Create a withdraw transaction\n\tconsole.log('\\n--- šŸ“¤ Creating Withdraw Transaction ---');\n\n\ttry {\n\t\tconsole.log(`šŸ’° Withdraw Amount: ${amount.toString()} raw units`);\n\t\tconsole.log(`šŸŖ Spot Market Index: ${spotMarketIndex}`);\n\n\t\tconst withdrawTxn = await centralServerDrift.getWithdrawTxn(\n\t\t\tuserAccountPublicKey,\n\t\t\tamount,\n\t\t\tspotMarketIndex,\n\t\t\t{\n\t\t\t\tisBorrow: false, // true = borrow, false = reduce-only withdraw\n\t\t\t\tisMax: false, // true = withdraw maximum available\n\t\t\t}\n\t\t);\n\n\t\tawait executeVersionedTransaction(\n\t\t\twithdrawTxn as VersionedTransaction,\n\t\t\t'Withdraw'\n\t\t);\n\t} catch (error) {\n\t\tconsole.error('āŒ Error during withdraw transaction flow:', error);\n\t}\n}\n\n/**\n * Example 2: Settle Funding Payments\n */\nasync function settleFundingExample() {\n\tconsole.log('šŸš€ Starting Settle Funding Example...\\n');\n\n\tconsole.log('--- šŸ’° Creating Settle Funding Transaction ---');\n\n\ttry {\n\t\tconsole.log(`šŸ‘¤ User Account: ${userAccountPublicKey.toString()}`);\n\t\tconsole.log('šŸ“‹ Settling funding payments for all perp positions...');\n\n\t\tconst settleFundingTxn = await centralServerDrift.getSettleFundingTxn(\n\t\t\tuserAccountPublicKey\n\t\t);\n\n\t\tawait executeVersionedTransaction(\n\t\t\tsettleFundingTxn as VersionedTransaction,\n\t\t\t'Settle Funding'\n\t\t);\n\t} catch (error) {\n\t\tconsole.error('āŒ Error during settle funding transaction flow:', error);\n\t}\n}\n\n/**\n * Example 3: Settle PnL for Multiple Markets\n */\nasync function settlePnlExample() {\n\tconsole.log('šŸš€ Starting Settle PnL Example...\\n');\n\n\t// Configuration for this example\n\tconst marketIndexes = [1]; // BTC-PERP\n\n\tconsole.log('--- šŸ“ˆ Creating Settle PnL Transaction ---');\n\n\ttry {\n\t\tconsole.log(`šŸ‘¤ User Account: ${userAccountPublicKey.toString()}`);\n\t\tconsole.log(`šŸ“Š Market Indexes: ${marketIndexes.join(', ')}`);\n\n\t\tconst settlePnlTxn = await centralServerDrift.getSettlePnlTxn(\n\t\t\tuserAccountPublicKey,\n\t\t\tmarketIndexes\n\t\t);\n\n\t\tawait executeVersionedTransaction(\n\t\t\tsettlePnlTxn as VersionedTransaction,\n\t\t\t'Settle PnL'\n\t\t);\n\t} catch (error) {\n\t\tconsole.error('āŒ Error during settle PnL transaction flow:', error);\n\t}\n}\n\n/**\n * Run all examples in sequence\n */\nasync function runAllExamples() {\n\tconsole.log('šŸš€ Running All CentralServerDrift Examples...\\n');\n\n\tawait initializeCentralServerDrift();\n\n\tconsole.log('='.repeat(50));\n\tawait depositWithdrawExample();\n\n\tconsole.log('\\n' + '='.repeat(50));\n\tawait settleFundingExample();\n\n\tconsole.log('\\n' + '='.repeat(50));\n\tawait settlePnlExample();\n}\n\n// Export example functions for use in other files\nexport {\n\tinitializeCentralServerDrift,\n\tdepositWithdrawExample,\n\tsettleFundingExample,\n\tsettlePnlExample,\n\trunAllExamples,\n};\n\n// Legacy export for backward compatibility\nexport const runCentralServerDriftExample = runAllExamples;\n\n// Helper functions for command line handling\nfunction showUsage() {\n\tconsole.log('šŸ“‹ Usage: ts-node example.ts [example-name]');\n\tconsole.log('\\nAvailable examples:');\n\tconsole.log(\n\t\t' depositWithdraw - Run deposit and withdraw transaction examples'\n\t);\n\tconsole.log(\n\t\t' settleFunding - Run settle funding payment transaction example'\n\t);\n\tconsole.log(' settlePnl - Run settle PnL transaction example');\n\tconsole.log(' all - Run all examples in sequence (default)');\n\tconsole.log('\\nExamples:');\n\tconsole.log(' ts-node example.ts # Run all examples');\n\tconsole.log(\n\t\t' ts-node example.ts depositWithdraw # Run only deposit/withdraw example'\n\t);\n\tconsole.log(\n\t\t' ts-node example.ts settleFunding # Run only settle funding example'\n\t);\n\tconsole.log(\n\t\t' ts-node example.ts settlePnl # Run only settle PnL example'\n\t);\n}\n\nasync function runCliExample(exampleName: string) {\n\tconst availableExamples = {\n\t\tdepositWithdraw: () =>\n\t\t\tinitializeCentralServerDrift().then(() => depositWithdrawExample()),\n\t\tsettleFunding: () =>\n\t\t\tinitializeCentralServerDrift().then(() => settleFundingExample()),\n\t\tsettlePnl: () =>\n\t\t\tinitializeCentralServerDrift().then(() => settlePnlExample()),\n\t\tall: runAllExamples,\n\t};\n\n\tif (\n\t\texampleName === 'help' ||\n\t\texampleName === '--help' ||\n\t\texampleName === '-h'\n\t) {\n\t\tshowUsage();\n\t\treturn;\n\t}\n\n\tconst exampleToRun = exampleName\n\t\t? availableExamples[exampleName]\n\t\t: availableExamples['all'];\n\n\tif (!exampleToRun) {\n\t\tconsole.error(`āŒ Unknown example: ${exampleName}`);\n\t\tconsole.error('');\n\t\tshowUsage();\n\t\tprocess.exit(1);\n\t}\n\n\tconsole.log(`šŸš€ Running example: ${exampleName || 'all'}\\n`);\n\tawait exampleToRun();\n}\n\n// Command line argument handling\nif (require.main === module) {\n\tconst args = process.argv.slice(2);\n\tconst exampleName = args[0];\n\n\trunCliExample(exampleName)\n\t\t.then(() => {\n\t\t\tconsole.log('\\n✨ Example execution completed successfully!');\n\t\t\tprocess.exit(0);\n\t\t})\n\t\t.catch((error) => {\n\t\t\tconsole.error('\\nšŸ’„ Example execution failed:', error);\n\t\t\tprocess.exit(1);\n\t\t});\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './base/actions';
2
+ export * from './base/details';
3
+ export * from './Drift';
@@ -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("./base/actions"), exports);
18
+ __exportStar(require("./base/details"), exports);
19
+ __exportStar(require("./Drift"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drift/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,iDAA+B;AAC/B,0CAAwB","sourcesContent":["export * from './base/actions';\nexport * from './base/details';\nexport * from './Drift';\n"]}
@@ -0,0 +1,45 @@
1
+ import { BN, OrderType, MarketType, PositionDirection, PostOnlyParams, OrderTriggerCondition } from '@drift-labs/sdk';
2
+ export interface ServerAuctionParamsResponse {
3
+ data: {
4
+ params: {
5
+ orderType?: string;
6
+ marketType?: string;
7
+ userOrderId?: number;
8
+ direction?: string;
9
+ baseAssetAmount?: string | number;
10
+ marketIndex?: number;
11
+ reduceOnly?: boolean;
12
+ postOnly?: string;
13
+ immediateOrCancel?: boolean;
14
+ triggerPrice?: string | number | null;
15
+ triggerCondition?: string;
16
+ oraclePriceOffset?: string | number;
17
+ auctionDuration?: number;
18
+ maxTs?: string | number | null;
19
+ auctionStartPrice?: string | number;
20
+ auctionEndPrice?: string | number;
21
+ };
22
+ };
23
+ }
24
+ export interface MappedAuctionParams {
25
+ orderType: OrderType;
26
+ marketType: MarketType;
27
+ userOrderId?: number;
28
+ direction: PositionDirection;
29
+ baseAssetAmount: BN;
30
+ marketIndex: number;
31
+ reduceOnly?: boolean;
32
+ postOnly?: PostOnlyParams;
33
+ immediateOrCancel?: boolean;
34
+ triggerPrice?: BN | null;
35
+ triggerCondition?: OrderTriggerCondition;
36
+ oraclePriceOffset?: BN;
37
+ auctionDuration: number | undefined;
38
+ maxTs?: BN | null;
39
+ auctionStartPrice: BN | undefined;
40
+ auctionEndPrice: BN | undefined;
41
+ }
42
+ /**
43
+ * Maps the server response from getOrderParams back to proper client-side types
44
+ */
45
+ export declare function mapAuctionParamsResponse(serverResponse: ServerAuctionParamsResponse): MappedAuctionParams;