@lifi/perps-sdk 20.1.1 → 21.1.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 (367) hide show
  1. package/README.md +81 -6
  2. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  3. package/dist/cjs/client/PerpsClient.js +4 -1
  4. package/dist/cjs/client/PerpsClient.js.map +1 -1
  5. package/dist/cjs/{utils/decimal.d.ts → decimal/big.d.ts} +1 -1
  6. package/dist/cjs/decimal/big.d.ts.map +1 -0
  7. package/dist/cjs/{utils/decimal.js → decimal/big.js} +1 -1
  8. package/dist/cjs/decimal/big.js.map +1 -0
  9. package/dist/cjs/decimal/convert.d.ts +11 -0
  10. package/dist/cjs/decimal/convert.d.ts.map +1 -0
  11. package/dist/cjs/decimal/convert.js +70 -0
  12. package/dist/cjs/decimal/convert.js.map +1 -0
  13. package/dist/cjs/decimal/format.d.ts.map +1 -0
  14. package/dist/cjs/decimal/format.js.map +1 -0
  15. package/dist/cjs/decimal/parse.d.ts +6 -0
  16. package/dist/cjs/decimal/parse.d.ts.map +1 -0
  17. package/dist/cjs/{utils → decimal}/parse.js +5 -4
  18. package/dist/cjs/decimal/parse.js.map +1 -0
  19. package/dist/cjs/index.d.ts +17 -15
  20. package/dist/cjs/index.d.ts.map +1 -1
  21. package/dist/cjs/index.js +75 -61
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/math/fills.d.ts +5 -0
  24. package/dist/cjs/math/fills.d.ts.map +1 -0
  25. package/dist/cjs/{utils/fillClassification.js → math/fills.js} +16 -1
  26. package/dist/cjs/math/fills.js.map +1 -0
  27. package/dist/cjs/math/order.d.ts +45 -0
  28. package/dist/cjs/math/order.d.ts.map +1 -0
  29. package/dist/cjs/math/order.js +256 -0
  30. package/dist/cjs/math/order.js.map +1 -0
  31. package/dist/cjs/math/position.d.ts +56 -0
  32. package/dist/cjs/math/position.d.ts.map +1 -0
  33. package/dist/cjs/math/position.js +160 -0
  34. package/dist/cjs/math/position.js.map +1 -0
  35. package/dist/cjs/services/getActivity.d.ts.map +1 -1
  36. package/dist/cjs/services/getActivity.js.map +1 -1
  37. package/dist/cjs/services/getFills.d.ts.map +1 -1
  38. package/dist/cjs/services/getFills.js.map +1 -1
  39. package/dist/cjs/services/getOrder.d.ts.map +1 -1
  40. package/dist/cjs/services/getOrder.js.map +1 -1
  41. package/dist/cjs/services/getOrders.d.ts.map +1 -1
  42. package/dist/cjs/services/getOrders.js.map +1 -1
  43. package/dist/cjs/services/getPositions.d.ts.map +1 -1
  44. package/dist/cjs/services/getPositions.js.map +1 -1
  45. package/dist/cjs/services/resolveQuote.d.ts.map +1 -1
  46. package/dist/cjs/services/resolveQuote.js +2 -2
  47. package/dist/cjs/services/resolveQuote.js.map +1 -1
  48. package/dist/cjs/services/resolveSubscribeQuote.d.ts.map +1 -1
  49. package/dist/cjs/services/resolveSubscribeQuote.js +2 -2
  50. package/dist/cjs/services/resolveSubscribeQuote.js.map +1 -1
  51. package/dist/cjs/types/provider.d.ts +3 -3
  52. package/dist/cjs/types/provider.d.ts.map +1 -1
  53. package/dist/cjs/types/withdrawal.d.ts +2 -0
  54. package/dist/cjs/types/withdrawal.d.ts.map +1 -1
  55. package/dist/cjs/utils/orderClassification.d.ts +1 -3
  56. package/dist/cjs/utils/orderClassification.d.ts.map +1 -1
  57. package/dist/cjs/utils/orderClassification.js +1 -15
  58. package/dist/cjs/utils/orderClassification.js.map +1 -1
  59. package/dist/cjs/version.d.ts +1 -1
  60. package/dist/cjs/version.js +1 -1
  61. package/dist/cjs/wire/orderAmounts.d.ts +18 -0
  62. package/dist/cjs/wire/orderAmounts.d.ts.map +1 -0
  63. package/dist/cjs/wire/orderAmounts.js +79 -0
  64. package/dist/cjs/wire/orderAmounts.js.map +1 -0
  65. package/dist/cjs/wire/refuel.d.ts +8 -0
  66. package/dist/cjs/wire/refuel.d.ts.map +1 -0
  67. package/dist/cjs/wire/refuel.js +23 -0
  68. package/dist/cjs/wire/refuel.js.map +1 -0
  69. package/dist/cjs/wire/requireDecimal.d.ts +4 -0
  70. package/dist/cjs/wire/requireDecimal.d.ts.map +1 -0
  71. package/dist/cjs/wire/requireDecimal.js +16 -0
  72. package/dist/cjs/wire/requireDecimal.js.map +1 -0
  73. package/dist/cjs/wire/snap.d.ts +5 -0
  74. package/dist/cjs/wire/snap.d.ts.map +1 -0
  75. package/dist/cjs/wire/snap.js +12 -0
  76. package/dist/cjs/wire/snap.js.map +1 -0
  77. package/dist/cjs/wire/transferable.d.ts +3 -0
  78. package/dist/cjs/wire/transferable.d.ts.map +1 -0
  79. package/dist/cjs/wire/transferable.js +13 -0
  80. package/dist/cjs/wire/transferable.js.map +1 -0
  81. package/dist/cjs/wire/withdraw.d.ts +4 -0
  82. package/dist/cjs/wire/withdraw.d.ts.map +1 -0
  83. package/dist/cjs/wire/withdraw.js +13 -0
  84. package/dist/cjs/wire/withdraw.js.map +1 -0
  85. package/dist/esm/client/PerpsClient.d.ts +37 -5
  86. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  87. package/dist/esm/client/PerpsClient.js +41 -6
  88. package/dist/esm/client/PerpsClient.js.map +1 -1
  89. package/dist/esm/{utils/decimal.d.ts → decimal/big.d.ts} +1 -1
  90. package/dist/esm/decimal/big.d.ts.map +1 -0
  91. package/dist/esm/{utils/decimal.js → decimal/big.js} +1 -1
  92. package/dist/esm/decimal/big.js.map +1 -0
  93. package/dist/esm/decimal/convert.d.ts +80 -0
  94. package/dist/esm/decimal/convert.d.ts.map +1 -0
  95. package/dist/esm/decimal/convert.js +118 -0
  96. package/dist/esm/decimal/convert.js.map +1 -0
  97. package/dist/esm/decimal/format.d.ts.map +1 -0
  98. package/dist/esm/decimal/format.js.map +1 -0
  99. package/dist/esm/decimal/parse.d.ts +29 -0
  100. package/dist/esm/decimal/parse.d.ts.map +1 -0
  101. package/dist/esm/{utils → decimal}/parse.js +9 -10
  102. package/dist/esm/decimal/parse.js.map +1 -0
  103. package/dist/esm/index.d.ts +17 -15
  104. package/dist/esm/index.d.ts.map +1 -1
  105. package/dist/esm/index.js +12 -12
  106. package/dist/esm/index.js.map +1 -1
  107. package/dist/esm/math/fills.d.ts +26 -0
  108. package/dist/esm/math/fills.d.ts.map +1 -0
  109. package/dist/esm/{utils/fillClassification.js → math/fills.js} +26 -2
  110. package/dist/esm/math/fills.js.map +1 -0
  111. package/dist/esm/{utils/calculations.d.ts → math/order.d.ts} +70 -75
  112. package/dist/esm/math/order.d.ts.map +1 -0
  113. package/dist/esm/{utils/calculations.js → math/order.js} +155 -111
  114. package/dist/esm/math/order.js.map +1 -0
  115. package/dist/esm/math/position.d.ts +211 -0
  116. package/dist/esm/math/position.d.ts.map +1 -0
  117. package/dist/esm/math/position.js +299 -0
  118. package/dist/esm/math/position.js.map +1 -0
  119. package/dist/esm/services/getActivity.d.ts +4 -0
  120. package/dist/esm/services/getActivity.d.ts.map +1 -1
  121. package/dist/esm/services/getActivity.js +4 -0
  122. package/dist/esm/services/getActivity.js.map +1 -1
  123. package/dist/esm/services/getFills.d.ts +4 -0
  124. package/dist/esm/services/getFills.d.ts.map +1 -1
  125. package/dist/esm/services/getFills.js +4 -0
  126. package/dist/esm/services/getFills.js.map +1 -1
  127. package/dist/esm/services/getOrder.d.ts +4 -0
  128. package/dist/esm/services/getOrder.d.ts.map +1 -1
  129. package/dist/esm/services/getOrder.js +4 -0
  130. package/dist/esm/services/getOrder.js.map +1 -1
  131. package/dist/esm/services/getOrders.d.ts +10 -1
  132. package/dist/esm/services/getOrders.d.ts.map +1 -1
  133. package/dist/esm/services/getOrders.js +10 -1
  134. package/dist/esm/services/getOrders.js.map +1 -1
  135. package/dist/esm/services/getPositions.d.ts +4 -0
  136. package/dist/esm/services/getPositions.d.ts.map +1 -1
  137. package/dist/esm/services/getPositions.js +4 -0
  138. package/dist/esm/services/getPositions.js.map +1 -1
  139. package/dist/esm/services/resolveQuote.d.ts.map +1 -1
  140. package/dist/esm/services/resolveQuote.js +1 -1
  141. package/dist/esm/services/resolveQuote.js.map +1 -1
  142. package/dist/esm/services/resolveSubscribeQuote.d.ts.map +1 -1
  143. package/dist/esm/services/resolveSubscribeQuote.js +1 -1
  144. package/dist/esm/services/resolveSubscribeQuote.js.map +1 -1
  145. package/dist/esm/types/provider.d.ts +23 -11
  146. package/dist/esm/types/provider.d.ts.map +1 -1
  147. package/dist/esm/types/withdrawal.d.ts +12 -0
  148. package/dist/esm/types/withdrawal.d.ts.map +1 -1
  149. package/dist/esm/utils/orderClassification.d.ts +1 -14
  150. package/dist/esm/utils/orderClassification.d.ts.map +1 -1
  151. package/dist/esm/utils/orderClassification.js +1 -25
  152. package/dist/esm/utils/orderClassification.js.map +1 -1
  153. package/dist/esm/version.d.ts +1 -1
  154. package/dist/esm/version.js +1 -1
  155. package/dist/esm/wire/orderAmounts.d.ts +55 -0
  156. package/dist/esm/wire/orderAmounts.d.ts.map +1 -0
  157. package/dist/esm/wire/orderAmounts.js +114 -0
  158. package/dist/esm/wire/orderAmounts.js.map +1 -0
  159. package/dist/esm/wire/refuel.d.ts +28 -0
  160. package/dist/esm/wire/refuel.d.ts.map +1 -0
  161. package/dist/esm/wire/refuel.js +36 -0
  162. package/dist/esm/wire/refuel.js.map +1 -0
  163. package/dist/esm/wire/requireDecimal.d.ts +11 -0
  164. package/dist/esm/wire/requireDecimal.d.ts.map +1 -0
  165. package/dist/esm/wire/requireDecimal.js +17 -0
  166. package/dist/esm/wire/requireDecimal.js.map +1 -0
  167. package/dist/esm/wire/snap.d.ts +24 -0
  168. package/dist/esm/wire/snap.d.ts.map +1 -0
  169. package/dist/esm/wire/snap.js +27 -0
  170. package/dist/esm/wire/snap.js.map +1 -0
  171. package/dist/esm/wire/transferable.d.ts +15 -0
  172. package/dist/esm/wire/transferable.d.ts.map +1 -0
  173. package/dist/esm/wire/transferable.js +22 -0
  174. package/dist/esm/wire/transferable.js.map +1 -0
  175. package/dist/esm/wire/withdraw.d.ts +14 -0
  176. package/dist/esm/wire/withdraw.d.ts.map +1 -0
  177. package/dist/esm/wire/withdraw.js +20 -0
  178. package/dist/esm/wire/withdraw.js.map +1 -0
  179. package/dist/types/client/PerpsClient.d.ts +37 -5
  180. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  181. package/dist/types/{utils/decimal.d.ts → decimal/big.d.ts} +1 -1
  182. package/dist/types/decimal/big.d.ts.map +1 -0
  183. package/dist/types/decimal/convert.d.ts +80 -0
  184. package/dist/types/decimal/convert.d.ts.map +1 -0
  185. package/dist/types/decimal/format.d.ts.map +1 -0
  186. package/dist/types/decimal/parse.d.ts +29 -0
  187. package/dist/types/decimal/parse.d.ts.map +1 -0
  188. package/dist/types/index.d.ts +17 -15
  189. package/dist/types/index.d.ts.map +1 -1
  190. package/dist/types/math/fills.d.ts +26 -0
  191. package/dist/types/math/fills.d.ts.map +1 -0
  192. package/dist/types/{utils/calculations.d.ts → math/order.d.ts} +70 -75
  193. package/dist/types/math/order.d.ts.map +1 -0
  194. package/dist/types/math/position.d.ts +211 -0
  195. package/dist/types/math/position.d.ts.map +1 -0
  196. package/dist/types/services/getActivity.d.ts +4 -0
  197. package/dist/types/services/getActivity.d.ts.map +1 -1
  198. package/dist/types/services/getFills.d.ts +4 -0
  199. package/dist/types/services/getFills.d.ts.map +1 -1
  200. package/dist/types/services/getOrder.d.ts +4 -0
  201. package/dist/types/services/getOrder.d.ts.map +1 -1
  202. package/dist/types/services/getOrders.d.ts +10 -1
  203. package/dist/types/services/getOrders.d.ts.map +1 -1
  204. package/dist/types/services/getPositions.d.ts +4 -0
  205. package/dist/types/services/getPositions.d.ts.map +1 -1
  206. package/dist/types/services/resolveQuote.d.ts.map +1 -1
  207. package/dist/types/services/resolveSubscribeQuote.d.ts.map +1 -1
  208. package/dist/types/types/provider.d.ts +23 -11
  209. package/dist/types/types/provider.d.ts.map +1 -1
  210. package/dist/types/types/withdrawal.d.ts +12 -0
  211. package/dist/types/types/withdrawal.d.ts.map +1 -1
  212. package/dist/types/utils/orderClassification.d.ts +1 -14
  213. package/dist/types/utils/orderClassification.d.ts.map +1 -1
  214. package/dist/types/version.d.ts +1 -1
  215. package/dist/types/wire/orderAmounts.d.ts +55 -0
  216. package/dist/types/wire/orderAmounts.d.ts.map +1 -0
  217. package/dist/types/wire/refuel.d.ts +28 -0
  218. package/dist/types/wire/refuel.d.ts.map +1 -0
  219. package/dist/types/wire/requireDecimal.d.ts +11 -0
  220. package/dist/types/wire/requireDecimal.d.ts.map +1 -0
  221. package/dist/types/wire/snap.d.ts +24 -0
  222. package/dist/types/wire/snap.d.ts.map +1 -0
  223. package/dist/types/wire/transferable.d.ts +15 -0
  224. package/dist/types/wire/transferable.d.ts.map +1 -0
  225. package/dist/types/wire/withdraw.d.ts +14 -0
  226. package/dist/types/wire/withdraw.d.ts.map +1 -0
  227. package/package.json +2 -2
  228. package/src/client/PerpsClient.ts +41 -6
  229. package/src/decimal/convert.ts +164 -0
  230. package/src/{utils → decimal}/parse.ts +13 -11
  231. package/src/index.ts +80 -57
  232. package/src/{utils/fillClassification.ts → math/fills.ts} +30 -1
  233. package/src/{utils/calculations.ts → math/order.ts} +205 -127
  234. package/src/{utils/positionMath.ts → math/position.ts} +173 -21
  235. package/src/services/getActivity.ts +4 -0
  236. package/src/services/getFills.ts +4 -0
  237. package/src/services/getOrder.ts +4 -0
  238. package/src/services/getOrders.ts +10 -1
  239. package/src/services/getPositions.ts +4 -0
  240. package/src/services/resolveQuote.ts +1 -1
  241. package/src/services/resolveSubscribeQuote.ts +1 -1
  242. package/src/types/provider.ts +23 -10
  243. package/src/types/withdrawal.ts +12 -0
  244. package/src/utils/orderClassification.ts +0 -30
  245. package/src/version.ts +1 -1
  246. package/src/wire/orderAmounts.ts +172 -0
  247. package/src/wire/refuel.ts +51 -0
  248. package/src/wire/requireDecimal.ts +24 -0
  249. package/src/wire/snap.ts +38 -0
  250. package/src/wire/transferable.ts +26 -0
  251. package/src/wire/withdraw.ts +29 -0
  252. package/dist/cjs/utils/calculations.d.ts +0 -47
  253. package/dist/cjs/utils/calculations.d.ts.map +0 -1
  254. package/dist/cjs/utils/calculations.js +0 -214
  255. package/dist/cjs/utils/calculations.js.map +0 -1
  256. package/dist/cjs/utils/decimal.d.ts.map +0 -1
  257. package/dist/cjs/utils/decimal.js.map +0 -1
  258. package/dist/cjs/utils/fillClassification.d.ts +0 -3
  259. package/dist/cjs/utils/fillClassification.d.ts.map +0 -1
  260. package/dist/cjs/utils/fillClassification.js.map +0 -1
  261. package/dist/cjs/utils/format.d.ts.map +0 -1
  262. package/dist/cjs/utils/format.js.map +0 -1
  263. package/dist/cjs/utils/math.d.ts +0 -4
  264. package/dist/cjs/utils/math.d.ts.map +0 -1
  265. package/dist/cjs/utils/math.js +0 -8
  266. package/dist/cjs/utils/math.js.map +0 -1
  267. package/dist/cjs/utils/orderEntry.d.ts +0 -6
  268. package/dist/cjs/utils/orderEntry.d.ts.map +0 -1
  269. package/dist/cjs/utils/orderEntry.js +0 -20
  270. package/dist/cjs/utils/orderEntry.js.map +0 -1
  271. package/dist/cjs/utils/orderMath.d.ts +0 -6
  272. package/dist/cjs/utils/orderMath.d.ts.map +0 -1
  273. package/dist/cjs/utils/orderMath.js +0 -85
  274. package/dist/cjs/utils/orderMath.js.map +0 -1
  275. package/dist/cjs/utils/parse.d.ts +0 -3
  276. package/dist/cjs/utils/parse.d.ts.map +0 -1
  277. package/dist/cjs/utils/parse.js.map +0 -1
  278. package/dist/cjs/utils/positionMath.d.ts +0 -37
  279. package/dist/cjs/utils/positionMath.d.ts.map +0 -1
  280. package/dist/cjs/utils/positionMath.js +0 -99
  281. package/dist/cjs/utils/positionMath.js.map +0 -1
  282. package/dist/cjs/utils/scaleToInteger.d.ts +0 -3
  283. package/dist/cjs/utils/scaleToInteger.d.ts.map +0 -1
  284. package/dist/cjs/utils/scaleToInteger.js +0 -30
  285. package/dist/cjs/utils/scaleToInteger.js.map +0 -1
  286. package/dist/cjs/utils/units.d.ts +0 -3
  287. package/dist/cjs/utils/units.d.ts.map +0 -1
  288. package/dist/cjs/utils/units.js +0 -18
  289. package/dist/cjs/utils/units.js.map +0 -1
  290. package/dist/cjs/utils/validation.d.ts +0 -2
  291. package/dist/cjs/utils/validation.d.ts.map +0 -1
  292. package/dist/cjs/utils/validation.js +0 -16
  293. package/dist/cjs/utils/validation.js.map +0 -1
  294. package/dist/esm/utils/calculations.d.ts.map +0 -1
  295. package/dist/esm/utils/calculations.js.map +0 -1
  296. package/dist/esm/utils/decimal.d.ts.map +0 -1
  297. package/dist/esm/utils/decimal.js.map +0 -1
  298. package/dist/esm/utils/fillClassification.d.ts +0 -13
  299. package/dist/esm/utils/fillClassification.d.ts.map +0 -1
  300. package/dist/esm/utils/fillClassification.js.map +0 -1
  301. package/dist/esm/utils/format.d.ts.map +0 -1
  302. package/dist/esm/utils/format.js.map +0 -1
  303. package/dist/esm/utils/math.d.ts +0 -6
  304. package/dist/esm/utils/math.d.ts.map +0 -1
  305. package/dist/esm/utils/math.js +0 -5
  306. package/dist/esm/utils/math.js.map +0 -1
  307. package/dist/esm/utils/orderEntry.d.ts +0 -26
  308. package/dist/esm/utils/orderEntry.d.ts.map +0 -1
  309. package/dist/esm/utils/orderEntry.js +0 -34
  310. package/dist/esm/utils/orderEntry.js.map +0 -1
  311. package/dist/esm/utils/orderMath.d.ts +0 -37
  312. package/dist/esm/utils/orderMath.d.ts.map +0 -1
  313. package/dist/esm/utils/orderMath.js +0 -113
  314. package/dist/esm/utils/orderMath.js.map +0 -1
  315. package/dist/esm/utils/parse.d.ts +0 -28
  316. package/dist/esm/utils/parse.d.ts.map +0 -1
  317. package/dist/esm/utils/parse.js.map +0 -1
  318. package/dist/esm/utils/positionMath.d.ts +0 -120
  319. package/dist/esm/utils/positionMath.d.ts.map +0 -1
  320. package/dist/esm/utils/positionMath.js +0 -173
  321. package/dist/esm/utils/positionMath.js.map +0 -1
  322. package/dist/esm/utils/scaleToInteger.d.ts +0 -22
  323. package/dist/esm/utils/scaleToInteger.d.ts.map +0 -1
  324. package/dist/esm/utils/scaleToInteger.js +0 -34
  325. package/dist/esm/utils/scaleToInteger.js.map +0 -1
  326. package/dist/esm/utils/units.d.ts +0 -27
  327. package/dist/esm/utils/units.d.ts.map +0 -1
  328. package/dist/esm/utils/units.js +0 -38
  329. package/dist/esm/utils/units.js.map +0 -1
  330. package/dist/esm/utils/validation.d.ts +0 -18
  331. package/dist/esm/utils/validation.d.ts.map +0 -1
  332. package/dist/esm/utils/validation.js +0 -29
  333. package/dist/esm/utils/validation.js.map +0 -1
  334. package/dist/types/utils/calculations.d.ts.map +0 -1
  335. package/dist/types/utils/decimal.d.ts.map +0 -1
  336. package/dist/types/utils/fillClassification.d.ts +0 -13
  337. package/dist/types/utils/fillClassification.d.ts.map +0 -1
  338. package/dist/types/utils/format.d.ts.map +0 -1
  339. package/dist/types/utils/math.d.ts +0 -6
  340. package/dist/types/utils/math.d.ts.map +0 -1
  341. package/dist/types/utils/orderEntry.d.ts +0 -26
  342. package/dist/types/utils/orderEntry.d.ts.map +0 -1
  343. package/dist/types/utils/orderMath.d.ts +0 -37
  344. package/dist/types/utils/orderMath.d.ts.map +0 -1
  345. package/dist/types/utils/parse.d.ts +0 -28
  346. package/dist/types/utils/parse.d.ts.map +0 -1
  347. package/dist/types/utils/positionMath.d.ts +0 -120
  348. package/dist/types/utils/positionMath.d.ts.map +0 -1
  349. package/dist/types/utils/scaleToInteger.d.ts +0 -22
  350. package/dist/types/utils/scaleToInteger.d.ts.map +0 -1
  351. package/dist/types/utils/units.d.ts +0 -27
  352. package/dist/types/utils/units.d.ts.map +0 -1
  353. package/dist/types/utils/validation.d.ts +0 -18
  354. package/dist/types/utils/validation.d.ts.map +0 -1
  355. package/src/utils/math.ts +0 -7
  356. package/src/utils/orderEntry.ts +0 -38
  357. package/src/utils/orderMath.ts +0 -152
  358. package/src/utils/scaleToInteger.ts +0 -56
  359. package/src/utils/units.ts +0 -39
  360. package/src/utils/validation.ts +0 -38
  361. /package/dist/cjs/{utils → decimal}/format.d.ts +0 -0
  362. /package/dist/cjs/{utils → decimal}/format.js +0 -0
  363. /package/dist/esm/{utils → decimal}/format.d.ts +0 -0
  364. /package/dist/esm/{utils → decimal}/format.js +0 -0
  365. /package/dist/types/{utils → decimal}/format.d.ts +0 -0
  366. /package/src/{utils/decimal.ts → decimal/big.ts} +0 -0
  367. /package/src/{utils → decimal}/format.ts +0 -0
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Display-tier position formulas. Every function takes and gives `number`;
3
+ * exact decimal arithmetic happens internally with `DivBig`.
4
+ *
5
+ * Sign convention: long = +1, short = -1. Sizes passed to the `estimate*`
6
+ * helpers are always non-negative magnitudes; direction is carried by
7
+ * `isLong`.
8
+ */
9
+ /**
10
+ * Direction sign for a position.
11
+ *
12
+ * @deprecated Inline `isLong ? 1 : -1`. Removed in the next major.
13
+ */
14
+ export declare function directionSign(isLong: boolean): 1 | -1;
15
+ /**
16
+ * Calculate notional value of a position.
17
+ *
18
+ * @param size - Position size in asset units
19
+ * @param price - Current asset price
20
+ * @returns Notional value in USD
21
+ * @public
22
+ */
23
+ export declare function calculateNotionalValue(size: number, price: number): number;
24
+ /**
25
+ * Calculate unrealized PnL.
26
+ *
27
+ * @param entryPrice - Position entry price
28
+ * @param currentPrice - Current market price
29
+ * @param size - Position size (positive for long, negative for short)
30
+ * @returns Unrealized PnL in USD
31
+ * @public
32
+ */
33
+ export declare function calculateUnrealizedPnl(entryPrice: number, currentPrice: number, size: number): number;
34
+ /**
35
+ * Calculate return on equity (ROE) percentage.
36
+ *
37
+ * @param pnl - Profit/loss in USD
38
+ * @param margin - Initial margin in USD
39
+ * @returns ROE as percentage (e.g., 10 for 10%)
40
+ * @public
41
+ */
42
+ export declare function calculateRoe(pnl: number, margin: number): number;
43
+ /**
44
+ * Calculate required margin for a position.
45
+ *
46
+ * @param notionalValue - Position notional value in USD
47
+ * @param leverage - Position leverage
48
+ * @returns Required margin in USD
49
+ * @public
50
+ */
51
+ export declare function calculateRequiredMargin(notionalValue: number, leverage: number): number;
52
+ /**
53
+ * Distance from the current price to the liquidation price, as a percentage of
54
+ * the current price.
55
+ *
56
+ * @param liquidationPrice - The position's liquidation price
57
+ * @param currentPrice - Current market price
58
+ * @returns Absolute distance as a percentage, or 0 when current price is zero
59
+ * @public
60
+ */
61
+ export declare function calculateLiquidationDistance(params: {
62
+ liquidationPrice: number;
63
+ currentPrice: number;
64
+ }): number;
65
+ /**
66
+ * @deprecated Use `calculateLiquidationDistance`. Removed in the next major.
67
+ */
68
+ export declare const liquidationDistancePercent: typeof calculateLiquidationDistance;
69
+ /**
70
+ * Effective leverage of an open position.
71
+ *
72
+ * leverage = positionValueUsd / marginUsd
73
+ *
74
+ * @param positionValueUsd - Position notional value in USD
75
+ * @param marginUsd - Margin backing the position in USD
76
+ * @returns Effective leverage, or 0 when margin is zero
77
+ * @public
78
+ */
79
+ export declare function calculateEffectiveLeverage(params: {
80
+ positionValueUsd: number;
81
+ marginUsd: number;
82
+ }): number;
83
+ /**
84
+ * @deprecated Use `calculateEffectiveLeverage`. Removed in the next major.
85
+ */
86
+ export declare const effectiveLeverage: typeof calculateEffectiveLeverage;
87
+ /**
88
+ * Estimated liquidation price for an isolated-margin position, parameterised
89
+ * by the venue's maintenance margin rate.
90
+ *
91
+ * Standard isolated-margin model (new position, no existing exposure):
92
+ * margin_per_unit = entryPrice / leverage
93
+ * maintenance_per_unit = entryPrice * mmr
94
+ * margin_available = margin_per_unit - maintenance_per_unit
95
+ * liq_price = entryPrice - side * margin_available / (1 - mmr * side)
96
+ *
97
+ * For existing positions, prefer `Position.liquidationPrice` from the venue.
98
+ *
99
+ * @param maintenanceMarginRate - Venue maintenance margin rate as a fraction
100
+ * (e.g. 0.01 = 1%).
101
+ * @returns Estimated liquidation price, or undefined if the inputs cannot
102
+ * produce one (zero leverage, degenerate denominator).
103
+ * @public
104
+ */
105
+ export declare function estimateLiquidationPrice(params: {
106
+ entryPrice: number;
107
+ leverage: number;
108
+ isLong: boolean;
109
+ maintenanceMarginRate: number;
110
+ }): number | undefined;
111
+ /**
112
+ * @deprecated Use `estimateLiquidationPrice`. Removed in the next major.
113
+ */
114
+ export declare const estimateIsolatedLiquidationPrice: typeof estimateLiquidationPrice;
115
+ /**
116
+ * Whether an isolated position with this liquidation price is already past
117
+ * liquidation at `currentPrice`: a long liquidates when the price falls to its
118
+ * liquidation level, a short when it rises to it. A non-positive price on
119
+ * either side counts as unknown, so the result is `false`.
120
+ *
121
+ * @public
122
+ */
123
+ export declare function wouldImmediatelyLiquidate(params: {
124
+ liquidationPrice: number;
125
+ currentPrice: number;
126
+ isLong: boolean;
127
+ }): boolean;
128
+ /**
129
+ * Estimated average entry price after adding to an existing position.
130
+ *
131
+ * Weighted average of the current entry and the new fill price, weighted by
132
+ * the size of each leg in coin units. Both legs assumed in the same direction
133
+ * (this helper is for adding to, not flipping, a position).
134
+ *
135
+ * @param currentSize - Existing position size in coin units (>= 0).
136
+ * @param currentEntry - Existing position's average entry price.
137
+ * @param addSize - Size being added in coin units (>= 0).
138
+ * @param fillPrice - Price the new size is expected to fill at (mid for
139
+ * market, limitPrice for limit orders).
140
+ * @returns The new weighted-average entry price, or undefined if the inputs
141
+ * cannot produce a valid average (zero combined size, non-finite values).
142
+ * @public
143
+ */
144
+ export declare function estimateAverageEntryPrice(params: {
145
+ currentSize: number;
146
+ currentEntry: number;
147
+ addSize: number;
148
+ fillPrice: number;
149
+ }): number | undefined;
150
+ /**
151
+ * @deprecated Use `estimateAverageEntryPrice`. Removed in the next major.
152
+ */
153
+ export declare const predictAverageEntryPrice: typeof estimateAverageEntryPrice;
154
+ /**
155
+ * Estimated effective leverage after adding margin and notional.
156
+ *
157
+ * leverage = totalNotional / totalMargin. The caller computes notional from
158
+ * size and price (`calculateNotionalValue`) and supplies the additional
159
+ * margin the user is about to put up.
160
+ *
161
+ * @returns The new effective leverage, or undefined if total margin is
162
+ * non-positive.
163
+ * @public
164
+ */
165
+ export declare function estimateNewLeverage(params: {
166
+ currentNotional: number;
167
+ currentMargin: number;
168
+ addNotional: number;
169
+ addMargin: number;
170
+ }): number | undefined;
171
+ /**
172
+ * @deprecated Use `estimateNewLeverage`. Removed in the next major.
173
+ */
174
+ export declare const predictNewLeverage: typeof estimateNewLeverage;
175
+ /**
176
+ * Estimated unrealised PnL at the current mark price.
177
+ *
178
+ * `pnl = (markPrice - entryPrice) * size * (isLong ? 1 : -1)`
179
+ *
180
+ * @param size - Position size as a non-negative magnitude.
181
+ * @public
182
+ */
183
+ export declare function estimateUnrealizedPnl(params: {
184
+ entryPrice: number;
185
+ markPrice: number;
186
+ size: number;
187
+ isLong: boolean;
188
+ }): number;
189
+ /**
190
+ * @deprecated Use `estimateUnrealizedPnl`. Removed in the next major.
191
+ */
192
+ export declare const predictUnrealizedPnl: typeof estimateUnrealizedPnl;
193
+ /**
194
+ * Realised PnL on the portion of a position being closed.
195
+ *
196
+ * `rPnl = (closePrice - entryPrice) * closeSize * (isLong ? 1 : -1)`
197
+ *
198
+ * @param closeSize - Size being closed as a non-negative magnitude.
199
+ * @public
200
+ */
201
+ export declare function calculateRealizedPnl(params: {
202
+ entryPrice: number;
203
+ closePrice: number;
204
+ closeSize: number;
205
+ isLong: boolean;
206
+ }): number;
207
+ /**
208
+ * @deprecated Use `calculateRealizedPnl`. Removed in the next major.
209
+ */
210
+ export declare const realizedPnlOnClose: typeof calculateRealizedPnl;
211
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/math/position.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAErD;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,M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CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,MAAM,GAAG,SAAS,CAiBrB;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,kCAA4B,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,MAAM,GAAG,SAAS,CAarB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,4BAAsB,CAAA;AAErD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;CAChB,GAAG,MAAM,CAUT;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,8BAAwB,CAAA;AAEzD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;CAChB,GAAG,MAAM,CAUT;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,6BAAuB,CAAA"}
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Display-tier position formulas. Every function takes and gives `number`;
3
+ * exact decimal arithmetic happens internally with `DivBig`.
4
+ *
5
+ * Sign convention: long = +1, short = -1. Sizes passed to the `estimate*`
6
+ * helpers are always non-negative magnitudes; direction is carried by
7
+ * `isLong`.
8
+ */
9
+ import { areFinite, DivBig } from '../decimal/big.js';
10
+ /**
11
+ * Direction sign for a position.
12
+ *
13
+ * @deprecated Inline `isLong ? 1 : -1`. Removed in the next major.
14
+ */
15
+ export function directionSign(isLong) {
16
+ return isLong ? 1 : -1;
17
+ }
18
+ /**
19
+ * Calculate notional value of a position.
20
+ *
21
+ * @param size - Position size in asset units
22
+ * @param price - Current asset price
23
+ * @returns Notional value in USD
24
+ * @public
25
+ */
26
+ export function calculateNotionalValue(size, price) {
27
+ if (!areFinite(size, price)) {
28
+ return Number.NaN;
29
+ }
30
+ return new DivBig(size).abs().times(price).toNumber();
31
+ }
32
+ /**
33
+ * Calculate unrealized PnL.
34
+ *
35
+ * @param entryPrice - Position entry price
36
+ * @param currentPrice - Current market price
37
+ * @param size - Position size (positive for long, negative for short)
38
+ * @returns Unrealized PnL in USD
39
+ * @public
40
+ */
41
+ export function calculateUnrealizedPnl(entryPrice, currentPrice, size) {
42
+ if (!areFinite(entryPrice, currentPrice, size)) {
43
+ return Number.NaN;
44
+ }
45
+ return new DivBig(currentPrice).minus(entryPrice).times(size).toNumber();
46
+ }
47
+ /**
48
+ * Calculate return on equity (ROE) percentage.
49
+ *
50
+ * @param pnl - Profit/loss in USD
51
+ * @param margin - Initial margin in USD
52
+ * @returns ROE as percentage (e.g., 10 for 10%)
53
+ * @public
54
+ */
55
+ export function calculateRoe(pnl, margin) {
56
+ if (margin === 0) {
57
+ return 0;
58
+ }
59
+ if (!areFinite(pnl, margin)) {
60
+ return Number.NaN;
61
+ }
62
+ return new DivBig(pnl).div(margin).times(100).toNumber();
63
+ }
64
+ /**
65
+ * Calculate required margin for a position.
66
+ *
67
+ * @param notionalValue - Position notional value in USD
68
+ * @param leverage - Position leverage
69
+ * @returns Required margin in USD
70
+ * @public
71
+ */
72
+ export function calculateRequiredMargin(notionalValue, leverage) {
73
+ if (leverage === 0) {
74
+ return notionalValue / leverage;
75
+ }
76
+ if (!areFinite(notionalValue, leverage)) {
77
+ return Number.NaN;
78
+ }
79
+ return new DivBig(notionalValue).div(leverage).toNumber();
80
+ }
81
+ /**
82
+ * Distance from the current price to the liquidation price, as a percentage of
83
+ * the current price.
84
+ *
85
+ * @param liquidationPrice - The position's liquidation price
86
+ * @param currentPrice - Current market price
87
+ * @returns Absolute distance as a percentage, or 0 when current price is zero
88
+ * @public
89
+ */
90
+ export function calculateLiquidationDistance(params) {
91
+ const { liquidationPrice, currentPrice } = params;
92
+ if (currentPrice === 0) {
93
+ return 0;
94
+ }
95
+ return Math.abs((liquidationPrice - currentPrice) / currentPrice) * 100;
96
+ }
97
+ /**
98
+ * @deprecated Use `calculateLiquidationDistance`. Removed in the next major.
99
+ */
100
+ export const liquidationDistancePercent = calculateLiquidationDistance;
101
+ /**
102
+ * Effective leverage of an open position.
103
+ *
104
+ * leverage = positionValueUsd / marginUsd
105
+ *
106
+ * @param positionValueUsd - Position notional value in USD
107
+ * @param marginUsd - Margin backing the position in USD
108
+ * @returns Effective leverage, or 0 when margin is zero
109
+ * @public
110
+ */
111
+ export function calculateEffectiveLeverage(params) {
112
+ const { positionValueUsd, marginUsd } = params;
113
+ if (marginUsd === 0) {
114
+ return 0;
115
+ }
116
+ if (!areFinite(positionValueUsd, marginUsd)) {
117
+ return Number.NaN;
118
+ }
119
+ return new DivBig(positionValueUsd).div(marginUsd).toNumber();
120
+ }
121
+ /**
122
+ * @deprecated Use `calculateEffectiveLeverage`. Removed in the next major.
123
+ */
124
+ export const effectiveLeverage = calculateEffectiveLeverage;
125
+ /**
126
+ * Estimated liquidation price for an isolated-margin position, parameterised
127
+ * by the venue's maintenance margin rate.
128
+ *
129
+ * Standard isolated-margin model (new position, no existing exposure):
130
+ * margin_per_unit = entryPrice / leverage
131
+ * maintenance_per_unit = entryPrice * mmr
132
+ * margin_available = margin_per_unit - maintenance_per_unit
133
+ * liq_price = entryPrice - side * margin_available / (1 - mmr * side)
134
+ *
135
+ * For existing positions, prefer `Position.liquidationPrice` from the venue.
136
+ *
137
+ * @param maintenanceMarginRate - Venue maintenance margin rate as a fraction
138
+ * (e.g. 0.01 = 1%).
139
+ * @returns Estimated liquidation price, or undefined if the inputs cannot
140
+ * produce one (zero leverage, degenerate denominator).
141
+ * @public
142
+ */
143
+ export function estimateLiquidationPrice(params) {
144
+ const { entryPrice, leverage, isLong, maintenanceMarginRate } = params;
145
+ if (leverage === 0) {
146
+ return undefined;
147
+ }
148
+ const side = isLong ? 1 : -1;
149
+ const denominator = 1 - maintenanceMarginRate * side;
150
+ if (denominator === 0) {
151
+ return undefined;
152
+ }
153
+ if (!areFinite(entryPrice, leverage, maintenanceMarginRate)) {
154
+ return Number.NaN;
155
+ }
156
+ const mmr = new DivBig(maintenanceMarginRate);
157
+ const marginAvailable = new DivBig(1)
158
+ .div(leverage)
159
+ .minus(mmr)
160
+ .times(entryPrice);
161
+ return new DivBig(entryPrice)
162
+ .minus(marginAvailable.times(side).div(mmr.times(-side).plus(1)))
163
+ .toNumber();
164
+ }
165
+ /**
166
+ * @deprecated Use `estimateLiquidationPrice`. Removed in the next major.
167
+ */
168
+ export const estimateIsolatedLiquidationPrice = estimateLiquidationPrice;
169
+ /**
170
+ * Whether an isolated position with this liquidation price is already past
171
+ * liquidation at `currentPrice`: a long liquidates when the price falls to its
172
+ * liquidation level, a short when it rises to it. A non-positive price on
173
+ * either side counts as unknown, so the result is `false`.
174
+ *
175
+ * @public
176
+ */
177
+ export function wouldImmediatelyLiquidate(params) {
178
+ const { liquidationPrice, currentPrice, isLong } = params;
179
+ if (currentPrice <= 0 || liquidationPrice <= 0) {
180
+ return false;
181
+ }
182
+ return isLong
183
+ ? liquidationPrice >= currentPrice
184
+ : liquidationPrice <= currentPrice;
185
+ }
186
+ /**
187
+ * Estimated average entry price after adding to an existing position.
188
+ *
189
+ * Weighted average of the current entry and the new fill price, weighted by
190
+ * the size of each leg in coin units. Both legs assumed in the same direction
191
+ * (this helper is for adding to, not flipping, a position).
192
+ *
193
+ * @param currentSize - Existing position size in coin units (>= 0).
194
+ * @param currentEntry - Existing position's average entry price.
195
+ * @param addSize - Size being added in coin units (>= 0).
196
+ * @param fillPrice - Price the new size is expected to fill at (mid for
197
+ * market, limitPrice for limit orders).
198
+ * @returns The new weighted-average entry price, or undefined if the inputs
199
+ * cannot produce a valid average (zero combined size, non-finite values).
200
+ * @public
201
+ */
202
+ export function estimateAverageEntryPrice(params) {
203
+ const { currentSize, currentEntry, addSize, fillPrice } = params;
204
+ const totalSize = currentSize + addSize;
205
+ if (totalSize <= 0) {
206
+ return undefined;
207
+ }
208
+ if (!Number.isFinite(currentEntry) || !Number.isFinite(fillPrice)) {
209
+ return undefined;
210
+ }
211
+ if (!areFinite(currentSize, addSize)) {
212
+ return Number.NaN;
213
+ }
214
+ return new DivBig(currentSize)
215
+ .times(currentEntry)
216
+ .plus(new DivBig(addSize).times(fillPrice))
217
+ .div(new DivBig(currentSize).plus(addSize))
218
+ .toNumber();
219
+ }
220
+ /**
221
+ * @deprecated Use `estimateAverageEntryPrice`. Removed in the next major.
222
+ */
223
+ export const predictAverageEntryPrice = estimateAverageEntryPrice;
224
+ /**
225
+ * Estimated effective leverage after adding margin and notional.
226
+ *
227
+ * leverage = totalNotional / totalMargin. The caller computes notional from
228
+ * size and price (`calculateNotionalValue`) and supplies the additional
229
+ * margin the user is about to put up.
230
+ *
231
+ * @returns The new effective leverage, or undefined if total margin is
232
+ * non-positive.
233
+ * @public
234
+ */
235
+ export function estimateNewLeverage(params) {
236
+ const { currentNotional, currentMargin, addNotional, addMargin } = params;
237
+ const totalMargin = currentMargin + addMargin;
238
+ if (totalMargin <= 0) {
239
+ return undefined;
240
+ }
241
+ if (!areFinite(currentNotional, currentMargin, addNotional, addMargin)) {
242
+ return Number.NaN;
243
+ }
244
+ return new DivBig(currentNotional)
245
+ .plus(addNotional)
246
+ .div(new DivBig(currentMargin).plus(addMargin))
247
+ .toNumber();
248
+ }
249
+ /**
250
+ * @deprecated Use `estimateNewLeverage`. Removed in the next major.
251
+ */
252
+ export const predictNewLeverage = estimateNewLeverage;
253
+ /**
254
+ * Estimated unrealised PnL at the current mark price.
255
+ *
256
+ * `pnl = (markPrice - entryPrice) * size * (isLong ? 1 : -1)`
257
+ *
258
+ * @param size - Position size as a non-negative magnitude.
259
+ * @public
260
+ */
261
+ export function estimateUnrealizedPnl(params) {
262
+ const { entryPrice, markPrice, size, isLong } = params;
263
+ if (!areFinite(entryPrice, markPrice, size)) {
264
+ return Number.NaN;
265
+ }
266
+ return new DivBig(markPrice)
267
+ .minus(entryPrice)
268
+ .times(size)
269
+ .times(isLong ? 1 : -1)
270
+ .toNumber();
271
+ }
272
+ /**
273
+ * @deprecated Use `estimateUnrealizedPnl`. Removed in the next major.
274
+ */
275
+ export const predictUnrealizedPnl = estimateUnrealizedPnl;
276
+ /**
277
+ * Realised PnL on the portion of a position being closed.
278
+ *
279
+ * `rPnl = (closePrice - entryPrice) * closeSize * (isLong ? 1 : -1)`
280
+ *
281
+ * @param closeSize - Size being closed as a non-negative magnitude.
282
+ * @public
283
+ */
284
+ export function calculateRealizedPnl(params) {
285
+ const { entryPrice, closePrice, closeSize, isLong } = params;
286
+ if (!areFinite(entryPrice, closePrice, closeSize)) {
287
+ return Number.NaN;
288
+ }
289
+ return new DivBig(closePrice)
290
+ .minus(entryPrice)
291
+ .times(closeSize)
292
+ .times(isLong ? 1 : -1)
293
+ .toNumber();
294
+ }
295
+ /**
296
+ * @deprecated Use `calculateRealizedPnl`. Removed in the next major.
297
+ */
298
+ export const realizedPnlOnClose = calculateRealizedPnl;
299
+ //# sourceMappingURL=position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.js","sourceRoot":"","sources":["../../../src/math/position.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,MAA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1B,KAAK,CAAC,UAAU,CAAC;SACjB,KAAK,CAAC,SAAS,CAAC;SAChB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtB,QAAQ,EAAE,CAAA;AACf,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAA"}
@@ -27,6 +27,10 @@ export interface GetActivityParams {
27
27
  *
28
28
  * @throws {PerpsError} When the provider plugin is not registered, or on
29
29
  * backend / network / parsing errors.
30
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
31
+ * Lighter auth token or an Ondo session) and none is stored.
32
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
33
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
30
34
  * @example
31
35
  * ```ts
32
36
  * const { items, pagination } = await getActivity(client, {
@@ -1 +1 @@
1
- {"version":3,"file":"getActivity.d.ts","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,YAAY,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAY7B"}
1
+ {"version":3,"file":"getActivity.d.ts","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,YAAY,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,kBAAkB,CAAC,CAY7B"}
@@ -6,6 +6,10 @@ import { requireProvider } from '../client/requireProvider.js';
6
6
  *
7
7
  * @throws {PerpsError} When the provider plugin is not registered, or on
8
8
  * backend / network / parsing errors.
9
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
10
+ * Lighter auth token or an Ondo session) and none is stored.
11
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
12
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
9
13
  * @example
10
14
  * ```ts
11
15
  * const { items, pagination } = await getActivity(client, {
@@ -1 +1 @@
1
- {"version":3,"file":"getActivity.js","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAuB9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,MAAyB,EACzB,OAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,CACzD;QACE,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,EACD,OAAO,CACR,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"getActivity.js","sourceRoot":"","sources":["../../../src/services/getActivity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAuB9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,MAAyB,EACzB,OAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,CACzD;QACE,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,EACD,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -26,6 +26,10 @@ export interface GetFillsParams {
26
26
  *
27
27
  * @throws {PerpsError} When the provider plugin is not registered, or on
28
28
  * backend / network / parsing errors.
29
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
30
+ * Lighter auth token or an Ondo session) and none is stored.
31
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
32
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
29
33
  * @example
30
34
  * ```ts
31
35
  * const { items, pagination } = await getFills(client, {
@@ -1 +1 @@
1
- {"version":3,"file":"getFills.d.ts","sourceRoot":"","sources":["../../../src/services/getFills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAWxB"}
1
+ {"version":3,"file":"getFills.d.ts","sourceRoot":"","sources":["../../../src/services/getFills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAWxB"}
@@ -6,6 +6,10 @@ import { requireProvider } from '../client/requireProvider.js';
6
6
  *
7
7
  * @throws {PerpsError} When the provider plugin is not registered, or on
8
8
  * backend / network / parsing errors.
9
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
10
+ * Lighter auth token or an Ondo session) and none is stored.
11
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
12
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
9
13
  * @example
10
14
  * ```ts
11
15
  * const { items, pagination } = await getFills(client, {
@@ -1 +1 @@
1
- {"version":3,"file":"getFills.js","sourceRoot":"","sources":["../../../src/services/getFills.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAsB9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAsB,EACtB,MAAsB,EACtB,OAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CACtD;QACE,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,EACD,OAAO,CACR,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"getFills.js","sourceRoot":"","sources":["../../../src/services/getFills.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAsB9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAsB,EACtB,MAAsB,EACtB,OAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CACtD;QACE,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,EACD,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -20,6 +20,10 @@ export interface GetOrderParams {
20
20
  *
21
21
  * @throws {PerpsError} When the provider plugin is not registered, or on
22
22
  * backend / network / parsing errors.
23
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
24
+ * Lighter auth token or an Ondo session) and none is stored.
25
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
26
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
23
27
  * @example
24
28
  * ```ts
25
29
  * const order = await getOrder(client, {
@@ -1 +1 @@
1
- {"version":3,"file":"getOrder.d.ts","sourceRoot":"","sources":["../../../src/services/getOrder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,KAAK,CAAC,CAKhB"}
1
+ {"version":3,"file":"getOrder.d.ts","sourceRoot":"","sources":["../../../src/services/getOrder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,KAAK,CAAC,CAKhB"}
@@ -6,6 +6,10 @@ import { requireProvider } from '../client/requireProvider.js';
6
6
  *
7
7
  * @throws {PerpsError} When the provider plugin is not registered, or on
8
8
  * backend / network / parsing errors.
9
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
10
+ * Lighter auth token or an Ondo session) and none is stored.
11
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
12
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
9
13
  * @example
10
14
  * ```ts
11
15
  * const order = await getOrder(client, {
@@ -1 +1 @@
1
- {"version":3,"file":"getOrder.js","sourceRoot":"","sources":["../../../src/services/getOrder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAgB9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAsB,EACtB,MAAsB,EACtB,OAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CACtD,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAC1C,OAAO,CACR,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"getOrder.js","sourceRoot":"","sources":["../../../src/services/getOrder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAgB9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAsB,EACtB,MAAsB,EACtB,OAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CACtD,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAC1C,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -18,6 +18,15 @@ export interface GetOrdersParams {
18
18
  /** Opaque pagination cursor from the previous response. */
19
19
  cursor?: string;
20
20
  }
21
- /** Read account orders with active lifecycle statuses as the default filter. */
21
+ /**
22
+ * Read account orders with active lifecycle statuses as the default filter.
23
+ *
24
+ * @throws {PerpsError} When the provider plugin is not registered, or on
25
+ * backend / network / parsing errors.
26
+ * @throws {PerpsError} `SetupRequired` when the venue needs a credential (a
27
+ * Lighter auth token or an Ondo session) and none is stored.
28
+ * @throws {PerpsError} `Unauthorized` when the venue rejects the credential.
29
+ * @throws {PerpsError} `AccountNotFound` when the wallet has no venue account.
30
+ */
22
31
  export declare function getOrders(client: PerpsSDKClient, params: GetOrdersParams, options?: SDKRequestOptions): Promise<OrdersResponse>;
23
32
  //# sourceMappingURL=getOrders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getOrders.d.ts","sourceRoot":"","sources":["../../../src/services/getOrders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG1D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;IACxB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,gFAAgF;AAChF,wBAAsB,SAAS,CAC7B,MAAM,EAAE,cAAc,EACtB,MAAM,EA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