@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":"featureFlags.js","sourceRoot":"","sources":["../../src/utils/featureFlags.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC5B,iBAAiB,EAAE,IAAI;CACvB,CAAC","sourcesContent":["export const FEATURE_FLAGS = {\n\tUI_ORACLE_CANDLES: true,\n};\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns true if the user is geo-blocked.
3
+ */
4
+ export declare const checkGeoBlock: () => Promise<boolean>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkGeoBlock = void 0;
4
+ const constants_1 = require("../../constants");
5
+ /**
6
+ * Returns true if the user is geo-blocked.
7
+ */
8
+ const checkGeoBlock = async () => {
9
+ const result = await fetch(`https://geolocation.drift-labs.workers.dev/`, {
10
+ cache: 'no-cache',
11
+ });
12
+ if (!result.ok) {
13
+ return;
14
+ }
15
+ const country_code = await result.text();
16
+ const countryIsBlocked = !!constants_1.GEOBLOCK_LIST.find((country) => country.code === country_code);
17
+ return countryIsBlocked;
18
+ };
19
+ exports.checkGeoBlock = checkGeoBlock;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/geoblock/index.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAEhD;;GAEG;AACI,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACvC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,6CAA6C,EAAE;QACzE,KAAK,EAAE,UAAU;KACjB,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO;IACR,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAEzC,MAAM,gBAAgB,GAAG,CAAC,CAAC,yBAAa,CAAC,IAAI,CAC5C,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAC1C,CAAC;IAEF,OAAO,gBAAgB,CAAC;AACzB,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB","sourcesContent":["import { GEOBLOCK_LIST } from '../../constants';\n\n/**\n * Returns true if the user is geo-blocked.\n */\nexport const checkGeoBlock = async () => {\n\tconst result = await fetch(`https://geolocation.drift-labs.workers.dev/`, {\n\t\tcache: 'no-cache',\n\t});\n\n\tif (!result.ok) {\n\t\treturn;\n\t}\n\n\tconst country_code = await result.text();\n\n\tconst countryIsBlocked = !!GEOBLOCK_LIST.find(\n\t\t(country) => country.code === country_code\n\t);\n\n\treturn countryIsBlocked;\n};\n"]}
@@ -0,0 +1,181 @@
1
+ /// <reference types="node" />
2
+ import { BN, Event, OrderActionRecord, OrderRecord, PublicKey, BigNum, MarketType, DriftClient, SpotMarketConfig } from '@drift-labs/sdk';
3
+ import { UIMatchedOrderRecordAndAction, UISerializableOrderActionRecord } from '../serializableTypes';
4
+ import { AccountInfo, Connection } from '@solana/web3.js';
5
+ export declare const matchEnum: (enum1: any, enum2: any) => boolean;
6
+ declare function enumToObj(enumStr: string): {
7
+ [x: string]: {};
8
+ };
9
+ declare function enumToStr(enumStr: Record<string, any>): string;
10
+ export declare const ENUM_UTILS: {
11
+ match: (enum1: any, enum2: any) => boolean;
12
+ toObj: typeof enumToObj;
13
+ toStr: typeof enumToStr;
14
+ };
15
+ export declare function sleep(ms: any): Promise<unknown>;
16
+ /**
17
+ * Converts an objects with potential Pubkeys and BNs in it into a form that can be JSON stringified. When pubkeys get converted a _pbky_ suffix will be added to their key, and _bgnm_ for BNs.
18
+ *
19
+ * e.g.
20
+ * input : {
21
+ * QuoteAmount: BN
22
+ * }
23
+ *
24
+ * output: {
25
+ * _bgnm_QuoteAmount: string
26
+ * }
27
+ * @param value
28
+ * @returns
29
+ */
30
+ export declare const encodeStringifiableObject: (value: any) => any;
31
+ /**
32
+ * Converts a parsed object with potential Pubkeys and BNs in it (in string form) to their proper form. Pubkey values must have a key starting in _pbky_ and BN values must have a key starting in _bnnm_
33
+ *
34
+ * * e.g.
35
+ * input : {
36
+ * _bgnm_QuoteAmount: string
37
+ * }
38
+ *
39
+ * output: {
40
+ * QuoteAmount: BN
41
+ * }
42
+ * @param value
43
+ * @returns
44
+ */
45
+ export declare const decodeStringifiableObject: (value: any) => any;
46
+ /**
47
+ * Returns 1 if the first Order is chronologically later than the second Order, -1 if before, 0 if equal
48
+ * @param orderA
49
+ * @param orderB
50
+ * @returns
51
+ */
52
+ export declare const getSortScoreForOrderRecords: (orderA: {
53
+ slot: number;
54
+ }, orderB: {
55
+ slot: number;
56
+ }) => 0 | 1 | -1;
57
+ export declare const getTradeInfoFromActionRecord: (actionRecord: PartialUISerializableOrderActionRecord) => {
58
+ ts: BN;
59
+ baseAssetAmount: BigNum;
60
+ baseAssetAmountFilled: BigNum;
61
+ quoteAssetAmountFilled: BigNum;
62
+ };
63
+ export type PartialOrderActionRecord = PartialUISerializableOrderActionRecord | PartialOrderActionEventRecord;
64
+ export type PartialUISerializableOrderActionRecord = Pick<UISerializableOrderActionRecord, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled' | 'ts' | 'slot' | 'action' | 'fillRecordId' | 'taker' | 'takerOrderBaseAssetAmount' | 'makerOrderBaseAssetAmount' | 'takerOrderCumulativeBaseAssetAmountFilled' | 'makerOrderCumulativeBaseAssetAmountFilled' | 'takerOrderCumulativeQuoteAssetAmountFilled' | 'makerOrderCumulativeQuoteAssetAmountFilled' | 'oraclePrice'>;
65
+ export type PartialOrderActionEventRecord = Pick<Event<OrderActionRecord>, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled' | 'ts' | 'slot' | 'action' | 'fillRecordId' | 'taker' | 'takerOrderBaseAssetAmount' | 'makerOrderBaseAssetAmount' | 'takerOrderCumulativeBaseAssetAmountFilled' | 'makerOrderCumulativeBaseAssetAmountFilled' | 'takerOrderCumulativeQuoteAssetAmountFilled' | 'makerOrderCumulativeQuoteAssetAmountFilled'>;
66
+ /**
67
+ * Returns 1 if the first Order is chronologically later than the second Order, -1 if before, 0 if equal
68
+ * @param orderA
69
+ * @param orderB
70
+ * @returns
71
+ */
72
+ export declare const getSortScoreForOrderActionRecords: (orderA: PartialOrderActionRecord, orderB: PartialOrderActionRecord) => 0 | 1 | -1;
73
+ export declare const sortUIMatchedOrderRecordAndAction: (records: UIMatchedOrderRecordAndAction[], direction?: 'asc' | 'desc') => UIMatchedOrderRecordAndAction[];
74
+ export declare const sortUIOrderActionRecords: (records: PartialUISerializableOrderActionRecord[], direction?: 'asc' | 'desc') => PartialUISerializableOrderActionRecord[];
75
+ export declare const sortUIOrderRecords: <T extends {
76
+ slot: number;
77
+ }>(records: T[], direction?: 'asc' | 'desc') => T[];
78
+ export declare const sortOrderRecords: (records: Event<OrderRecord>[], direction?: 'asc' | 'desc') => Event<OrderRecord>[];
79
+ export declare const getLatestOfTwoUIOrderRecords: <T extends {
80
+ slot: number;
81
+ }>(orderA: T, orderB: T) => T;
82
+ export declare const getLatestOfTwoOrderRecords: <T extends {
83
+ slot: number;
84
+ }>(orderA: T, orderB: T) => T;
85
+ export declare const getUIOrderRecordsLaterThanTarget: <T extends {
86
+ slot: number;
87
+ }>(target: T, records: T[]) => T[];
88
+ export declare const orderActionRecordIsTrade: (orderRecord: OrderActionRecord) => boolean;
89
+ export declare const uiOrderActionRecordIsTrade: (orderRecord: UISerializableOrderActionRecord) => boolean;
90
+ export declare const filterTradeRecordsFromOrderActionRecords: (orderRecords: OrderActionRecord[]) => OrderActionRecord[];
91
+ export declare const filterTradeRecordsFromUIOrderRecords: (orderRecords: UISerializableOrderActionRecord[]) => UISerializableOrderActionRecord[];
92
+ /**
93
+ * Returns the average price for a given base amount and quote amount.
94
+ * @param quoteAmount
95
+ * @param baseAmount
96
+ * @returns PRICE_PRECISION
97
+ */
98
+ export declare const getPriceForBaseAndQuoteAmount: (quoteAmount: BN, baseAmount: BN) => BN;
99
+ export declare const getPriceForOrderRecord: (orderRecord: Pick<OrderActionRecord, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled'>) => BN;
100
+ export declare const getPriceForUIOrderRecord: (orderRecord: Pick<UISerializableOrderActionRecord, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled'>) => BigNum;
101
+ export declare const orderIsNull: (order: UISerializableOrderActionRecord | Event<OrderActionRecord>, side: 'taker' | 'maker') => boolean;
102
+ export declare const getAnchorEnumString: (enumVal: Record<string, unknown>) => string;
103
+ export declare class Ref<T> {
104
+ val: T;
105
+ constructor(val: T);
106
+ set(val: T): void;
107
+ get(): T;
108
+ }
109
+ export declare class Counter {
110
+ private val;
111
+ get(): number;
112
+ increment(value?: number): void;
113
+ reset(): void;
114
+ }
115
+ /**
116
+ * A class which allows a group of switches to seperately turn a multiswitch on or off. The base state is the state of the "multiswitch" when all of the constituent switches are off. When any of the switches are "on" then the multiswitch flips to the opposite state
117
+ *
118
+ * If baseState is on => any switch being "on" will turn the multiswitch off.
119
+ * If baseState is off => any switch being "off" will turn the multiswitch off.
120
+ */
121
+ export declare class MultiSwitch {
122
+ private baseState;
123
+ private switches;
124
+ private switchValue;
125
+ constructor(baseState?: 'on' | 'off');
126
+ private getSwitchKey;
127
+ switchOn(key: string): void;
128
+ switchOff(key: string): void;
129
+ private _switchOff;
130
+ private _switchOn;
131
+ get isOn(): boolean;
132
+ }
133
+ export declare const aprFromApy: (apy: number, compoundsPerYear: number) => number;
134
+ /**
135
+ * Helper utility to get a sort score for "tiered" parameters.
136
+ *
137
+ * Example: Want to sort students by Grade, but fall back to using Age if they are equal. This method will accept an array for each student of [grade, age] and return the appropriate sort score for each.
138
+ *
139
+ * @param aScores
140
+ * @param bScores
141
+ * @returns
142
+ */
143
+ export declare const getTieredSortScore: (aScores: number[], bScores: number[]) => number;
144
+ export declare const COMMON_UTILS: {
145
+ getIfVaultBalance: (spotMarketConfig: SpotMarketConfig, driftClient: DriftClient) => Promise<BigNum>;
146
+ getIfStakingVaultApr: (spotMarketConfig: SpotMarketConfig, driftClient: DriftClient) => Promise<number>;
147
+ getCurrentOpenInterestForMarket: (marketIndex: number, marketType: MarketType, driftClient: DriftClient) => number;
148
+ getDepositAprForMarket: (marketIndex: number, marketType: MarketType, driftClient: DriftClient) => number;
149
+ getBorrowAprForMarket: (marketIndex: number, marketType: MarketType, driftClient: DriftClient) => number;
150
+ getTotalBorrowsForMarket: (market: SpotMarketConfig, driftClient: DriftClient) => number;
151
+ getTotalDepositsForMarket: (market: SpotMarketConfig, driftClient: DriftClient) => {
152
+ totalDepositsBase: number;
153
+ totalDepositsQuote: number;
154
+ };
155
+ dividesExactly: (numerator: number, denominator: number) => boolean;
156
+ toSnakeCase: (str: string) => string;
157
+ toCamelCase: (str: string) => string;
158
+ getTieredSortScore: (aScores: number[], bScores: number[]) => number;
159
+ normalizeBaseAssetSymbol: (symbol: string) => string;
160
+ calculateZScore: (target: number, previousValues: number[]) => number;
161
+ glueArray: <T>(size: number, elements: T[]) => T[][];
162
+ timedPromise: <T_1>(promise: T_1) => Promise<{
163
+ promiseTime: number;
164
+ promiseResult: Awaited<T_1>;
165
+ }>;
166
+ chunks: <T_2>(array: readonly T_2[], size: number) => T_2[][];
167
+ getMultipleAccountsInfoChunked: (connection: Connection, accounts: PublicKey[]) => Promise<(AccountInfo<Buffer> | null)[]>;
168
+ MATH: {
169
+ NUM: {
170
+ mean: (numbers: number[]) => number;
171
+ median: (numbers: number[]) => number;
172
+ };
173
+ BN: {
174
+ bnMax: (numbers: BN[]) => BN;
175
+ bnMin: (numbers: BN[]) => BN;
176
+ bnMean: (numbers: BN[]) => BN;
177
+ bnMedian: (numbers: BN[]) => BN;
178
+ };
179
+ };
180
+ };
181
+ export {};