@drift-labs/common 1.0.59 → 1.0.61

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 (284) hide show
  1. package/lib/_deprecated/common-math.d.ts +10 -0
  2. package/lib/_deprecated/common-math.js +9 -0
  3. package/lib/_deprecated/common-math.js.map +1 -0
  4. package/lib/_deprecated/common-ui-utils.d.ts +248 -0
  5. package/lib/_deprecated/common-ui-utils.js +59 -0
  6. package/lib/_deprecated/common-ui-utils.js.map +1 -0
  7. package/lib/_deprecated/equality-checks.d.ts +2 -0
  8. package/lib/_deprecated/equality-checks.js +7 -0
  9. package/lib/_deprecated/equality-checks.js.map +1 -0
  10. package/lib/{common-ui-utils/market.d.ts → _deprecated/market-utils.d.ts} +5 -7
  11. package/lib/_deprecated/market-utils.js +18 -0
  12. package/lib/_deprecated/market-utils.js.map +1 -0
  13. package/lib/_deprecated/order-utils.d.ts +12 -0
  14. package/lib/_deprecated/order-utils.js +18 -0
  15. package/lib/_deprecated/order-utils.js.map +1 -0
  16. package/lib/_deprecated/trading-utils.d.ts +52 -0
  17. package/lib/_deprecated/trading-utils.js +27 -0
  18. package/lib/_deprecated/trading-utils.js.map +1 -0
  19. package/lib/_deprecated/user-utils.d.ts +17 -0
  20. package/lib/_deprecated/user-utils.js +12 -0
  21. package/lib/_deprecated/user-utils.js.map +1 -0
  22. package/lib/_deprecated/utils.d.ts +40 -0
  23. package/lib/_deprecated/utils.js +47 -0
  24. package/lib/_deprecated/utils.js.map +1 -0
  25. package/lib/clients/tvFeed.js +2 -2
  26. package/lib/clients/tvFeed.js.map +1 -1
  27. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js +8 -8
  28. package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js.map +1 -1
  29. package/lib/drift/Drift/clients/AuthorityDrift/index.js +9 -9
  30. package/lib/drift/Drift/clients/AuthorityDrift/index.js.map +1 -1
  31. package/lib/drift/Drift/clients/CentralServerDrift/index.js +5 -4
  32. package/lib/drift/Drift/clients/CentralServerDrift/index.js.map +1 -1
  33. package/lib/drift/base/actions/trade/editOrder.d.ts +1 -1
  34. package/lib/drift/base/actions/trade/editOrder.js.map +1 -1
  35. package/lib/drift/base/actions/trade/margin.js +4 -4
  36. package/lib/drift/base/actions/trade/margin.js.map +1 -1
  37. package/lib/drift/base/actions/trade/openPerpOrder/auction.d.ts +1 -1
  38. package/lib/drift/base/actions/trade/openPerpOrder/auction.js +4 -3
  39. package/lib/drift/base/actions/trade/openPerpOrder/auction.js.map +1 -1
  40. package/lib/drift/base/actions/trade/openPerpOrder/dlobServer/index.js +2 -2
  41. package/lib/drift/base/actions/trade/openPerpOrder/dlobServer/index.js.map +1 -1
  42. package/lib/drift/base/actions/trade/openPerpOrder/isolatedPositionDeposit.js +2 -2
  43. package/lib/drift/base/actions/trade/openPerpOrder/isolatedPositionDeposit.js.map +1 -1
  44. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.d.ts +1 -1
  45. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js +4 -4
  46. package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js.map +1 -1
  47. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.d.ts +4 -4
  48. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js +60 -32
  49. package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js.map +1 -1
  50. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js +4 -3
  51. package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js.map +1 -1
  52. package/lib/drift/base/actions/trade/openPerpOrder/positionMaxLeverage.js +2 -2
  53. package/lib/drift/base/actions/trade/openPerpOrder/positionMaxLeverage.js.map +1 -1
  54. package/lib/drift/base/actions/trade/openPerpOrder/types.d.ts +5 -0
  55. package/lib/drift/base/actions/trade/openPerpOrder/types.js.map +1 -1
  56. package/lib/drift/base/actions/user/create.js +2 -2
  57. package/lib/drift/base/actions/user/create.js.map +1 -1
  58. package/lib/drift/base/details/user/balances.js +2 -2
  59. package/lib/drift/base/details/user/balances.js.map +1 -1
  60. package/lib/drift/base/details/user/positions.js +2 -2
  61. package/lib/drift/base/details/user/positions.js.map +1 -1
  62. package/lib/index.d.ts +28 -28
  63. package/lib/index.js +44 -29
  64. package/lib/index.js.map +1 -1
  65. package/lib/utils/accounts/index.d.ts +6 -0
  66. package/lib/utils/accounts/index.js +23 -0
  67. package/lib/utils/accounts/index.js.map +1 -0
  68. package/lib/utils/accounts/init.d.ts +22 -0
  69. package/lib/utils/accounts/init.js +90 -0
  70. package/lib/utils/accounts/init.js.map +1 -0
  71. package/lib/utils/accounts/keys.d.ts +22 -0
  72. package/lib/utils/accounts/keys.js +36 -0
  73. package/lib/utils/accounts/keys.js.map +1 -0
  74. package/lib/utils/accounts/multiple.d.ts +14 -0
  75. package/lib/utils/accounts/multiple.js +45 -0
  76. package/lib/utils/accounts/multiple.js.map +1 -0
  77. package/lib/utils/accounts/signature.d.ts +6 -0
  78. package/lib/utils/accounts/signature.js +53 -0
  79. package/lib/utils/accounts/signature.js.map +1 -0
  80. package/lib/utils/accounts/subaccounts.d.ts +8 -0
  81. package/lib/utils/accounts/subaccounts.js +31 -0
  82. package/lib/utils/accounts/subaccounts.js.map +1 -0
  83. package/lib/utils/{WalletConnectionState.d.ts → accounts/wallet.d.ts} +7 -1
  84. package/lib/utils/{WalletConnectionState.js → accounts/wallet.js} +32 -2
  85. package/lib/utils/accounts/wallet.js.map +1 -0
  86. package/lib/utils/core/arrays.d.ts +2 -0
  87. package/lib/utils/core/arrays.js +25 -0
  88. package/lib/utils/core/arrays.js.map +1 -0
  89. package/lib/utils/core/async.d.ts +5 -0
  90. package/lib/utils/core/async.js +17 -0
  91. package/lib/utils/core/async.js.map +1 -0
  92. package/lib/utils/core/cache.d.ts +1 -0
  93. package/lib/utils/core/cache.js +40 -0
  94. package/lib/utils/core/cache.js.map +1 -0
  95. package/lib/utils/core/data-structures.d.ts +30 -0
  96. package/lib/utils/core/data-structures.js +84 -0
  97. package/lib/utils/core/data-structures.js.map +1 -0
  98. package/lib/utils/{equalityChecks.d.ts → core/equality.d.ts} +1 -1
  99. package/lib/utils/{equalityChecks.js → core/equality.js} +3 -3
  100. package/lib/utils/core/equality.js.map +1 -0
  101. package/lib/utils/core/fetch.js.map +1 -0
  102. package/lib/utils/core/index.d.ts +7 -0
  103. package/lib/utils/core/index.js +24 -0
  104. package/lib/utils/core/index.js.map +1 -0
  105. package/lib/utils/core/serialization.d.ts +30 -0
  106. package/lib/utils/core/serialization.js +92 -0
  107. package/lib/utils/core/serialization.js.map +1 -0
  108. package/lib/utils/{enum.js → enum/index.js} +1 -1
  109. package/lib/utils/enum/index.js.map +1 -0
  110. package/lib/utils/index.d.ts +11 -176
  111. package/lib/utils/index.js +25 -594
  112. package/lib/utils/index.js.map +1 -1
  113. package/lib/utils/markets/balances.d.ts +6 -0
  114. package/lib/utils/markets/balances.js +29 -0
  115. package/lib/utils/markets/balances.js.map +1 -0
  116. package/lib/utils/markets/config.d.ts +5 -0
  117. package/lib/utils/markets/config.js +24 -0
  118. package/lib/utils/markets/config.js.map +1 -0
  119. package/lib/utils/markets/index.d.ts +6 -0
  120. package/lib/utils/markets/index.js +23 -0
  121. package/lib/utils/markets/index.js.map +1 -0
  122. package/lib/utils/markets/interest.d.ts +25 -0
  123. package/lib/utils/markets/interest.js +65 -0
  124. package/lib/utils/markets/interest.js.map +1 -0
  125. package/lib/utils/markets/leverage.d.ts +12 -0
  126. package/lib/utils/markets/leverage.js +60 -0
  127. package/lib/utils/markets/leverage.js.map +1 -0
  128. package/lib/utils/markets/operations.d.ts +21 -0
  129. package/lib/utils/markets/operations.js +59 -0
  130. package/lib/utils/markets/operations.js.map +1 -0
  131. package/lib/utils/math/bignum.d.ts +3 -0
  132. package/lib/utils/math/bignum.js +16 -0
  133. package/lib/utils/math/bignum.js.map +1 -0
  134. package/lib/utils/math/bn.d.ts +7 -0
  135. package/lib/utils/math/bn.js +58 -0
  136. package/lib/utils/math/bn.js.map +1 -0
  137. package/lib/utils/math/index.d.ts +7 -0
  138. package/lib/utils/math/index.js +24 -0
  139. package/lib/utils/math/index.js.map +1 -0
  140. package/lib/utils/math/numbers.d.ts +13 -0
  141. package/lib/utils/math/numbers.js +56 -0
  142. package/lib/utils/math/numbers.js.map +1 -0
  143. package/lib/utils/math/precision.d.ts +19 -0
  144. package/lib/utils/math/precision.js +73 -0
  145. package/lib/utils/math/precision.js.map +1 -0
  146. package/lib/utils/math/price.d.ts +12 -0
  147. package/lib/utils/math/price.js +45 -0
  148. package/lib/utils/math/price.js.map +1 -0
  149. package/lib/utils/math/sort.d.ts +13 -0
  150. package/lib/utils/math/sort.js +33 -0
  151. package/lib/utils/math/sort.js.map +1 -0
  152. package/lib/utils/math/spread.d.ts +8 -0
  153. package/lib/utils/math/spread.js +87 -0
  154. package/lib/utils/math/spread.js.map +1 -0
  155. package/lib/utils/orderbook/index.js +4 -4
  156. package/lib/utils/orderbook/index.js.map +1 -1
  157. package/lib/utils/orders/filters.d.ts +7 -0
  158. package/lib/utils/orders/filters.js +31 -0
  159. package/lib/utils/orders/filters.js.map +1 -0
  160. package/lib/utils/orders/flags.d.ts +12 -0
  161. package/lib/utils/orders/flags.js +44 -0
  162. package/lib/utils/orders/flags.js.map +1 -0
  163. package/lib/utils/orders/index.d.ts +6 -0
  164. package/lib/utils/orders/index.js +23 -0
  165. package/lib/utils/orders/index.js.map +1 -0
  166. package/lib/utils/orders/labels.d.ts +4 -0
  167. package/lib/utils/orders/labels.js +122 -0
  168. package/lib/utils/orders/labels.js.map +1 -0
  169. package/lib/utils/orders/misc.d.ts +11 -0
  170. package/lib/utils/orders/misc.js +27 -0
  171. package/lib/utils/orders/misc.js.map +1 -0
  172. package/lib/utils/orders/oracle.d.ts +5 -0
  173. package/lib/utils/orders/oracle.js +23 -0
  174. package/lib/utils/orders/oracle.js.map +1 -0
  175. package/lib/utils/orders/sort.d.ts +38 -0
  176. package/lib/utils/orders/sort.js +83 -0
  177. package/lib/utils/orders/sort.js.map +1 -0
  178. package/lib/utils/positions/index.d.ts +2 -0
  179. package/lib/{common-ui-utils → utils/positions}/index.js +1 -5
  180. package/lib/utils/positions/index.js.map +1 -0
  181. package/lib/utils/positions/open.d.ts +4 -0
  182. package/lib/{common-ui-utils/user.js → utils/positions/open.js} +10 -81
  183. package/lib/utils/positions/open.js.map +1 -0
  184. package/lib/utils/positions/user.d.ts +37 -0
  185. package/lib/utils/positions/user.js +74 -0
  186. package/lib/utils/positions/user.js.map +1 -0
  187. package/lib/utils/settings/settings.js.map +1 -0
  188. package/lib/utils/strings/convert.d.ts +11 -0
  189. package/lib/utils/{strings.js → strings/convert.js} +2 -51
  190. package/lib/utils/strings/convert.js.map +1 -0
  191. package/lib/utils/strings/format.d.ts +14 -0
  192. package/lib/utils/strings/format.js +61 -0
  193. package/lib/utils/strings/format.js.map +1 -0
  194. package/lib/utils/strings/index.d.ts +4 -0
  195. package/lib/utils/strings/index.js +21 -0
  196. package/lib/utils/strings/index.js.map +1 -0
  197. package/lib/utils/strings/parse.d.ts +4 -0
  198. package/lib/utils/strings/parse.js +25 -0
  199. package/lib/utils/strings/parse.js.map +1 -0
  200. package/lib/utils/strings/status.d.ts +15 -0
  201. package/lib/utils/strings/status.js +21 -0
  202. package/lib/utils/strings/status.js.map +1 -0
  203. package/lib/utils/token/account.d.ts +16 -0
  204. package/lib/utils/token/account.js +36 -0
  205. package/lib/utils/token/account.js.map +1 -0
  206. package/lib/utils/{token.d.ts → token/address.d.ts} +2 -7
  207. package/lib/utils/token/address.js +30 -0
  208. package/lib/utils/token/address.js.map +1 -0
  209. package/lib/utils/token/index.d.ts +3 -0
  210. package/lib/utils/token/index.js +20 -0
  211. package/lib/utils/token/index.js.map +1 -0
  212. package/lib/utils/token/instructions.d.ts +3 -0
  213. package/lib/utils/token/instructions.js +17 -0
  214. package/lib/utils/token/instructions.js.map +1 -0
  215. package/lib/utils/trading/auction.d.ts +82 -0
  216. package/lib/utils/trading/auction.js +208 -0
  217. package/lib/utils/trading/auction.js.map +1 -0
  218. package/lib/utils/trading/index.d.ts +7 -0
  219. package/lib/utils/trading/index.js +24 -0
  220. package/lib/utils/trading/index.js.map +1 -0
  221. package/lib/utils/trading/leverage.d.ts +18 -0
  222. package/lib/utils/trading/leverage.js +79 -0
  223. package/lib/utils/trading/leverage.js.map +1 -0
  224. package/lib/utils/trading/liquidation.d.ts +22 -0
  225. package/lib/utils/trading/liquidation.js +67 -0
  226. package/lib/utils/trading/liquidation.js.map +1 -0
  227. package/lib/utils/trading/lp.d.ts +4 -0
  228. package/lib/utils/trading/lp.js +20 -0
  229. package/lib/utils/trading/lp.js.map +1 -0
  230. package/lib/utils/trading/pnl.d.ts +34 -0
  231. package/lib/utils/trading/pnl.js +88 -0
  232. package/lib/utils/trading/pnl.js.map +1 -0
  233. package/lib/utils/trading/price.d.ts +12 -0
  234. package/lib/utils/trading/price.js +36 -0
  235. package/lib/utils/trading/price.js.map +1 -0
  236. package/lib/utils/trading/size.d.ts +27 -0
  237. package/lib/utils/trading/size.js +83 -0
  238. package/lib/utils/trading/size.js.map +1 -0
  239. package/lib/utils/{validation.d.ts → validation/address.d.ts} +1 -2
  240. package/lib/utils/{validation.js → validation/address.js} +4 -6
  241. package/lib/utils/validation/address.js.map +1 -0
  242. package/lib/utils/validation/index.d.ts +3 -0
  243. package/lib/utils/validation/index.js +20 -0
  244. package/lib/utils/validation/index.js.map +1 -0
  245. package/lib/utils/validation/input.d.ts +3 -0
  246. package/lib/utils/validation/input.js +33 -0
  247. package/lib/utils/validation/input.js.map +1 -0
  248. package/lib/utils/validation/notional.d.ts +2 -0
  249. package/lib/utils/validation/notional.js +8 -0
  250. package/lib/utils/validation/notional.js.map +1 -0
  251. package/package.json +90 -3
  252. package/lib/common-ui-utils/commonUiUtils.d.ts +0 -251
  253. package/lib/common-ui-utils/commonUiUtils.js +0 -647
  254. package/lib/common-ui-utils/commonUiUtils.js.map +0 -1
  255. package/lib/common-ui-utils/index.d.ts +0 -6
  256. package/lib/common-ui-utils/index.js.map +0 -1
  257. package/lib/common-ui-utils/market.js +0 -134
  258. package/lib/common-ui-utils/market.js.map +0 -1
  259. package/lib/common-ui-utils/order.d.ts +0 -25
  260. package/lib/common-ui-utils/order.js +0 -191
  261. package/lib/common-ui-utils/order.js.map +0 -1
  262. package/lib/common-ui-utils/settings/settings.js.map +0 -1
  263. package/lib/common-ui-utils/trading.d.ts +0 -79
  264. package/lib/common-ui-utils/trading.js +0 -313
  265. package/lib/common-ui-utils/trading.js.map +0 -1
  266. package/lib/common-ui-utils/user.d.ts +0 -18
  267. package/lib/common-ui-utils/user.js.map +0 -1
  268. package/lib/utils/WalletConnectionState.js.map +0 -1
  269. package/lib/utils/enum.js.map +0 -1
  270. package/lib/utils/equalityChecks.js.map +0 -1
  271. package/lib/utils/fetch.js.map +0 -1
  272. package/lib/utils/math.d.ts +0 -31
  273. package/lib/utils/math.js +0 -181
  274. package/lib/utils/math.js.map +0 -1
  275. package/lib/utils/strings.d.ts +0 -34
  276. package/lib/utils/strings.js.map +0 -1
  277. package/lib/utils/token.js +0 -45
  278. package/lib/utils/token.js.map +0 -1
  279. package/lib/utils/validation.js.map +0 -1
  280. /package/lib/utils/{fetch.d.ts → core/fetch.d.ts} +0 -0
  281. /package/lib/utils/{fetch.js → core/fetch.js} +0 -0
  282. /package/lib/utils/{enum.d.ts → enum/index.d.ts} +0 -0
  283. /package/lib/{common-ui-utils → utils}/settings/settings.d.ts +0 -0
  284. /package/lib/{common-ui-utils → utils}/settings/settings.js +0 -0
@@ -1,176 +1,11 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { BN, Event, OrderActionRecord, OrderRecord, PublicKey, BigNum, MarketType, DriftClient, SpotMarketConfig } from '@drift-labs/sdk';
4
- import { UIMatchedOrderRecordAndAction, UISerializableOrderActionRecord } from '../serializableTypes';
5
- import { AccountInfo, Connection } from '@solana/web3.js';
6
- import { matchEnum, ENUM_UTILS } from './enum';
7
- export { matchEnum, ENUM_UTILS };
8
- export declare function sleep(ms: any): Promise<unknown>;
9
- /**
10
- * 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.
11
- *
12
- * e.g.
13
- * input : {
14
- * QuoteAmount: BN
15
- * }
16
- *
17
- * output: {
18
- * _bgnm_QuoteAmount: string
19
- * }
20
- * @param value
21
- * @returns
22
- */
23
- export declare const encodeStringifiableObject: (value: any) => any;
24
- /**
25
- * 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_
26
- *
27
- * * e.g.
28
- * input : {
29
- * _bgnm_QuoteAmount: string
30
- * }
31
- *
32
- * output: {
33
- * QuoteAmount: BN
34
- * }
35
- * @param value
36
- * @returns
37
- */
38
- export declare const decodeStringifiableObject: (value: any) => any;
39
- /**
40
- * Returns 1 if the first Order is chronologically later than the second Order, -1 if before, 0 if equal
41
- * @param orderA
42
- * @param orderB
43
- * @returns
44
- */
45
- export declare const getSortScoreForOrderRecords: (orderA: {
46
- slot: number;
47
- }, orderB: {
48
- slot: number;
49
- }) => 0 | 1 | -1;
50
- export declare const getTradeInfoFromActionRecord: (actionRecord: PartialUISerializableOrderActionRecord) => {
51
- ts: BN;
52
- baseAssetAmount: BigNum;
53
- baseAssetAmountFilled: BigNum;
54
- quoteAssetAmountFilled: BigNum;
55
- };
56
- export type PartialOrderActionRecord = PartialUISerializableOrderActionRecord | PartialOrderActionEventRecord;
57
- export type PartialUISerializableOrderActionRecord = Pick<UISerializableOrderActionRecord, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled' | 'ts' | 'slot' | 'action' | 'fillRecordId' | 'taker' | 'takerOrderBaseAssetAmount' | 'makerOrderBaseAssetAmount' | 'takerOrderCumulativeBaseAssetAmountFilled' | 'makerOrderCumulativeBaseAssetAmountFilled' | 'takerOrderCumulativeQuoteAssetAmountFilled' | 'makerOrderCumulativeQuoteAssetAmountFilled' | 'oraclePrice'>;
58
- export type PartialOrderActionEventRecord = Pick<Event<OrderActionRecord>, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled' | 'ts' | 'slot' | 'action' | 'fillRecordId' | 'taker' | 'takerOrderBaseAssetAmount' | 'makerOrderBaseAssetAmount' | 'takerOrderCumulativeBaseAssetAmountFilled' | 'makerOrderCumulativeBaseAssetAmountFilled' | 'takerOrderCumulativeQuoteAssetAmountFilled' | 'makerOrderCumulativeQuoteAssetAmountFilled'>;
59
- /**
60
- * Returns 1 if the first Order is chronologically later than the second Order, -1 if before, 0 if equal
61
- * @param orderA
62
- * @param orderB
63
- * @returns
64
- */
65
- export declare const getSortScoreForOrderActionRecords: (orderA: PartialOrderActionRecord, orderB: PartialOrderActionRecord) => 0 | 1 | -1;
66
- export declare const sortUIMatchedOrderRecordAndAction: (records: UIMatchedOrderRecordAndAction[], direction?: 'asc' | 'desc') => UIMatchedOrderRecordAndAction[];
67
- export declare const sortUIOrderActionRecords: (records: PartialUISerializableOrderActionRecord[], direction?: 'asc' | 'desc') => PartialUISerializableOrderActionRecord[];
68
- export declare const sortUIOrderRecords: <T extends {
69
- slot: number;
70
- }>(records: T[], direction?: 'asc' | 'desc') => T[];
71
- export declare const sortOrderRecords: (records: Event<OrderRecord>[], direction?: 'asc' | 'desc') => Event<OrderRecord>[];
72
- export declare const getLatestOfTwoUIOrderRecords: <T extends {
73
- slot: number;
74
- }>(orderA: T, orderB: T) => T;
75
- export declare const getLatestOfTwoOrderRecords: <T extends {
76
- slot: number;
77
- }>(orderA: T, orderB: T) => T;
78
- export declare const getUIOrderRecordsLaterThanTarget: <T extends {
79
- slot: number;
80
- }>(target: T, records: T[]) => T[];
81
- export declare const orderActionRecordIsTrade: (orderRecord: OrderActionRecord) => boolean;
82
- export declare const uiOrderActionRecordIsTrade: (orderRecord: UISerializableOrderActionRecord) => boolean;
83
- export declare const filterTradeRecordsFromOrderActionRecords: (orderRecords: OrderActionRecord[]) => OrderActionRecord[];
84
- export declare const filterTradeRecordsFromUIOrderRecords: (orderRecords: UISerializableOrderActionRecord[]) => UISerializableOrderActionRecord[];
85
- /**
86
- * Returns the average price for a given base amount and quote amount.
87
- * @param quoteAmount
88
- * @param baseAmount
89
- * @returns PRICE_PRECISION
90
- */
91
- export declare const getPriceForBaseAndQuoteAmount: (quoteAmount: BN, baseAmount: BN) => any;
92
- export declare const getPriceForOrderRecord: (orderRecord: Pick<OrderActionRecord, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled'>) => any;
93
- export declare const getPriceForUIOrderRecord: (orderRecord: Pick<UISerializableOrderActionRecord, 'quoteAssetAmountFilled' | 'baseAssetAmountFilled'>) => BigNum;
94
- export declare const orderIsNull: (order: UISerializableOrderActionRecord | Event<OrderActionRecord>, side: 'taker' | 'maker') => boolean;
95
- export declare const getAnchorEnumString: (enumVal: Record<string, unknown>) => string;
96
- export declare class Ref<T> {
97
- val: T;
98
- constructor(val: T);
99
- set(val: T): void;
100
- get(): T;
101
- }
102
- export declare class Counter {
103
- private val;
104
- get(): number;
105
- increment(value?: number): void;
106
- reset(): void;
107
- }
108
- /**
109
- * 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
110
- *
111
- * If baseState is on => any switch being "on" will turn the multiswitch off.
112
- * If baseState is off => any switch being "off" will turn the multiswitch off.
113
- */
114
- export declare class MultiSwitch {
115
- private baseState;
116
- private switches;
117
- private switchValue;
118
- constructor(baseState?: 'on' | 'off');
119
- private getSwitchKey;
120
- switchOn(key: string): void;
121
- switchOff(key: string): void;
122
- private _switchOff;
123
- private _switchOn;
124
- get isOn(): boolean;
125
- }
126
- export declare const aprFromApy: (apy: number, compoundsPerYear: number) => number;
127
- /**
128
- * Helper utility to get a sort score for "tiered" parameters.
129
- *
130
- * 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.
131
- *
132
- * @param aScores
133
- * @param bScores
134
- * @returns
135
- */
136
- export declare const getTieredSortScore: (aScores: number[], bScores: number[]) => number;
137
- export declare const COMMON_UTILS: {
138
- getIfVaultBalance: (spotMarketConfig: SpotMarketConfig, driftClient: DriftClient) => Promise<BigNum>;
139
- getIfStakingVaultApr: (spotMarketConfig: SpotMarketConfig, driftClient: DriftClient) => Promise<number>;
140
- getCurrentOpenInterestForMarket: (marketIndex: number, marketType: MarketType, driftClient: DriftClient) => number;
141
- getDepositAprForMarket: (marketIndex: number, marketType: MarketType, driftClient: DriftClient) => number;
142
- getBorrowAprForMarket: (marketIndex: number, marketType: MarketType, driftClient: DriftClient) => number;
143
- getTotalBorrowsForMarket: (market: SpotMarketConfig, driftClient: DriftClient) => number;
144
- getTotalDepositsForMarket: (market: SpotMarketConfig, driftClient: DriftClient) => {
145
- totalDepositsBase: number;
146
- totalDepositsQuote: number;
147
- };
148
- dividesExactly: (numerator: number, denominator: number) => boolean;
149
- toSnakeCase: (str: string) => string;
150
- toCamelCase: (str: string) => string;
151
- getTieredSortScore: (aScores: number[], bScores: number[]) => number;
152
- normalizeBaseAssetSymbol: (symbol: string) => string;
153
- calculateZScore: (target: number, previousValues: number[]) => number;
154
- glueArray: <T>(size: number, elements: T[]) => T[][];
155
- timedPromise: <T_1>(promise: T_1) => Promise<{
156
- promiseTime: number;
157
- promiseResult: Awaited<T_1>;
158
- }>;
159
- chunks: <T_2>(array: readonly T_2[], size: number) => T_2[][];
160
- getMultipleAccountsInfoChunked: (connection: Connection, accounts: PublicKey[]) => Promise<(AccountInfo<Buffer> | null)[]>;
161
- MATH: {
162
- NUM: {
163
- mean: (numbers: number[]) => number;
164
- median: (numbers: number[]) => number;
165
- };
166
- BN: {
167
- bnMax: (numbers: BN[]) => BN;
168
- bnMin: (numbers: BN[]) => BN;
169
- bnMean: (numbers: BN[]) => BN;
170
- bnMedian: (numbers: BN[]) => BN;
171
- };
172
- };
173
- };
174
- export { getSwiftConfirmationTimeoutMs } from './signedMsgs';
175
- export { ResultSlotIncrementer } from './ResultSlotIncrementer';
176
- export { MultiplexWebSocket } from './MultiplexWebSocket';
1
+ export * from './math';
2
+ export * from './strings';
3
+ export * from './enum';
4
+ export * from './validation';
5
+ export * from './token';
6
+ export * from './trading';
7
+ export * from './markets';
8
+ export * from './orders';
9
+ export * from './positions';
10
+ export * from './accounts';
11
+ export * from './core';