@lifi/perps-sdk-provider-ondo 0.0.0-preview-7ff840c

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 (280) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +38 -0
  3. package/dist/cjs/OndoProvider.d.ts +8 -0
  4. package/dist/cjs/OndoProvider.d.ts.map +1 -0
  5. package/dist/cjs/OndoProvider.js +338 -0
  6. package/dist/cjs/OndoProvider.js.map +1 -0
  7. package/dist/cjs/accountConfig.d.ts +3 -0
  8. package/dist/cjs/accountConfig.d.ts.map +1 -0
  9. package/dist/cjs/accountConfig.js +59 -0
  10. package/dist/cjs/accountConfig.js.map +1 -0
  11. package/dist/cjs/accountSummary.d.ts +3 -0
  12. package/dist/cjs/accountSummary.d.ts.map +1 -0
  13. package/dist/cjs/accountSummary.js +8 -0
  14. package/dist/cjs/accountSummary.js.map +1 -0
  15. package/dist/cjs/auth/OndoTokenStore.d.ts +13 -0
  16. package/dist/cjs/auth/OndoTokenStore.d.ts.map +1 -0
  17. package/dist/cjs/auth/OndoTokenStore.js +53 -0
  18. package/dist/cjs/auth/OndoTokenStore.js.map +1 -0
  19. package/dist/cjs/auth/completeSiweLogin.d.ts +13 -0
  20. package/dist/cjs/auth/completeSiweLogin.d.ts.map +1 -0
  21. package/dist/cjs/auth/completeSiweLogin.js +15 -0
  22. package/dist/cjs/auth/completeSiweLogin.js.map +1 -0
  23. package/dist/cjs/auth/index.d.ts +4 -0
  24. package/dist/cjs/auth/index.d.ts.map +1 -0
  25. package/dist/cjs/auth/index.js +11 -0
  26. package/dist/cjs/auth/index.js.map +1 -0
  27. package/dist/cjs/auth/signActions.d.ts +13 -0
  28. package/dist/cjs/auth/signActions.d.ts.map +1 -0
  29. package/dist/cjs/auth/signActions.js +86 -0
  30. package/dist/cjs/auth/signActions.js.map +1 -0
  31. package/dist/cjs/constants.d.ts +9 -0
  32. package/dist/cjs/constants.d.ts.map +1 -0
  33. package/dist/cjs/constants.js +12 -0
  34. package/dist/cjs/constants.js.map +1 -0
  35. package/dist/cjs/index.d.ts +9 -0
  36. package/dist/cjs/index.d.ts.map +1 -0
  37. package/dist/cjs/index.js +37 -0
  38. package/dist/cjs/index.js.map +1 -0
  39. package/dist/cjs/package.json +1 -0
  40. package/dist/cjs/types/auth.d.ts +16 -0
  41. package/dist/cjs/types/auth.d.ts.map +1 -0
  42. package/dist/cjs/types/auth.js +3 -0
  43. package/dist/cjs/types/auth.js.map +1 -0
  44. package/dist/cjs/types/index.d.ts +4 -0
  45. package/dist/cjs/types/index.d.ts.map +1 -0
  46. package/dist/cjs/types/index.js +3 -0
  47. package/dist/cjs/types/index.js.map +1 -0
  48. package/dist/cjs/types/wire.d.ts +154 -0
  49. package/dist/cjs/types/wire.d.ts.map +1 -0
  50. package/dist/cjs/types/wire.js +3 -0
  51. package/dist/cjs/types/wire.js.map +1 -0
  52. package/dist/cjs/types/ws.d.ts +92 -0
  53. package/dist/cjs/types/ws.d.ts.map +1 -0
  54. package/dist/cjs/types/ws.js +3 -0
  55. package/dist/cjs/types/ws.js.map +1 -0
  56. package/dist/cjs/utils/activityCursor.d.ts +9 -0
  57. package/dist/cjs/utils/activityCursor.d.ts.map +1 -0
  58. package/dist/cjs/utils/activityCursor.js +79 -0
  59. package/dist/cjs/utils/activityCursor.js.map +1 -0
  60. package/dist/cjs/utils/apiClient.d.ts +43 -0
  61. package/dist/cjs/utils/apiClient.d.ts.map +1 -0
  62. package/dist/cjs/utils/apiClient.js +134 -0
  63. package/dist/cjs/utils/apiClient.js.map +1 -0
  64. package/dist/cjs/utils/index.d.ts +11 -0
  65. package/dist/cjs/utils/index.d.ts.map +1 -0
  66. package/dist/cjs/utils/index.js +39 -0
  67. package/dist/cjs/utils/index.js.map +1 -0
  68. package/dist/cjs/utils/liquidation.d.ts +4 -0
  69. package/dist/cjs/utils/liquidation.d.ts.map +1 -0
  70. package/dist/cjs/utils/liquidation.js +16 -0
  71. package/dist/cjs/utils/liquidation.js.map +1 -0
  72. package/dist/cjs/utils/mapActivity.d.ts +5 -0
  73. package/dist/cjs/utils/mapActivity.d.ts.map +1 -0
  74. package/dist/cjs/utils/mapActivity.js +34 -0
  75. package/dist/cjs/utils/mapActivity.js.map +1 -0
  76. package/dist/cjs/utils/mapFill.d.ts +4 -0
  77. package/dist/cjs/utils/mapFill.d.ts.map +1 -0
  78. package/dist/cjs/utils/mapFill.js +36 -0
  79. package/dist/cjs/utils/mapFill.js.map +1 -0
  80. package/dist/cjs/utils/mapOrder.d.ts +16 -0
  81. package/dist/cjs/utils/mapOrder.d.ts.map +1 -0
  82. package/dist/cjs/utils/mapOrder.js +135 -0
  83. package/dist/cjs/utils/mapOrder.js.map +1 -0
  84. package/dist/cjs/utils/mapPosition.d.ts +5 -0
  85. package/dist/cjs/utils/mapPosition.d.ts.map +1 -0
  86. package/dist/cjs/utils/mapPosition.js +26 -0
  87. package/dist/cjs/utils/mapPosition.js.map +1 -0
  88. package/dist/cjs/utils/ohlcvInterval.d.ts +4 -0
  89. package/dist/cjs/utils/ohlcvInterval.d.ts.map +1 -0
  90. package/dist/cjs/utils/ohlcvInterval.js +49 -0
  91. package/dist/cjs/utils/ohlcvInterval.js.map +1 -0
  92. package/dist/cjs/utils/ondoAsset.d.ts +3 -0
  93. package/dist/cjs/utils/ondoAsset.d.ts.map +1 -0
  94. package/dist/cjs/utils/ondoAsset.js +12 -0
  95. package/dist/cjs/utils/ondoAsset.js.map +1 -0
  96. package/dist/cjs/utils/orderFormatting.d.ts +4 -0
  97. package/dist/cjs/utils/orderFormatting.d.ts.map +1 -0
  98. package/dist/cjs/utils/orderFormatting.js +40 -0
  99. package/dist/cjs/utils/orderFormatting.js.map +1 -0
  100. package/dist/cjs/websocket/OndoWsProvider.d.ts +56 -0
  101. package/dist/cjs/websocket/OndoWsProvider.d.ts.map +1 -0
  102. package/dist/cjs/websocket/OndoWsProvider.js +515 -0
  103. package/dist/cjs/websocket/OndoWsProvider.js.map +1 -0
  104. package/dist/esm/OndoProvider.d.ts +39 -0
  105. package/dist/esm/OndoProvider.d.ts.map +1 -0
  106. package/dist/esm/OndoProvider.js +366 -0
  107. package/dist/esm/OndoProvider.js.map +1 -0
  108. package/dist/esm/accountConfig.d.ts +13 -0
  109. package/dist/esm/accountConfig.d.ts.map +1 -0
  110. package/dist/esm/accountConfig.js +77 -0
  111. package/dist/esm/accountConfig.js.map +1 -0
  112. package/dist/esm/accountSummary.d.ts +12 -0
  113. package/dist/esm/accountSummary.d.ts.map +1 -0
  114. package/dist/esm/accountSummary.js +14 -0
  115. package/dist/esm/accountSummary.js.map +1 -0
  116. package/dist/esm/auth/OndoTokenStore.d.ts +20 -0
  117. package/dist/esm/auth/OndoTokenStore.d.ts.map +1 -0
  118. package/dist/esm/auth/OndoTokenStore.js +61 -0
  119. package/dist/esm/auth/OndoTokenStore.js.map +1 -0
  120. package/dist/esm/auth/completeSiweLogin.d.ts +28 -0
  121. package/dist/esm/auth/completeSiweLogin.d.ts.map +1 -0
  122. package/dist/esm/auth/completeSiweLogin.js +21 -0
  123. package/dist/esm/auth/completeSiweLogin.js.map +1 -0
  124. package/dist/esm/auth/index.d.ts +4 -0
  125. package/dist/esm/auth/index.d.ts.map +1 -0
  126. package/dist/esm/auth/index.js +5 -0
  127. package/dist/esm/auth/index.js.map +1 -0
  128. package/dist/esm/auth/signActions.d.ts +35 -0
  129. package/dist/esm/auth/signActions.d.ts.map +1 -0
  130. package/dist/esm/auth/signActions.js +103 -0
  131. package/dist/esm/auth/signActions.js.map +1 -0
  132. package/dist/esm/constants.d.ts +35 -0
  133. package/dist/esm/constants.d.ts.map +1 -0
  134. package/dist/esm/constants.js +35 -0
  135. package/dist/esm/constants.js.map +1 -0
  136. package/dist/esm/index.d.ts +19 -0
  137. package/dist/esm/index.d.ts.map +1 -0
  138. package/dist/esm/index.js +21 -0
  139. package/dist/esm/index.js.map +1 -0
  140. package/dist/esm/package.json +1 -0
  141. package/dist/esm/types/auth.d.ts +32 -0
  142. package/dist/esm/types/auth.d.ts.map +1 -0
  143. package/dist/esm/types/auth.js +2 -0
  144. package/dist/esm/types/auth.js.map +1 -0
  145. package/dist/esm/types/index.d.ts +4 -0
  146. package/dist/esm/types/index.d.ts.map +1 -0
  147. package/dist/esm/types/index.js +3 -0
  148. package/dist/esm/types/index.js.map +1 -0
  149. package/dist/esm/types/wire.d.ts +195 -0
  150. package/dist/esm/types/wire.d.ts.map +1 -0
  151. package/dist/esm/types/wire.js +7 -0
  152. package/dist/esm/types/wire.js.map +1 -0
  153. package/dist/esm/types/ws.d.ts +108 -0
  154. package/dist/esm/types/ws.d.ts.map +1 -0
  155. package/dist/esm/types/ws.js +7 -0
  156. package/dist/esm/types/ws.js.map +1 -0
  157. package/dist/esm/utils/activityCursor.d.ts +47 -0
  158. package/dist/esm/utils/activityCursor.d.ts.map +1 -0
  159. package/dist/esm/utils/activityCursor.js +93 -0
  160. package/dist/esm/utils/activityCursor.js.map +1 -0
  161. package/dist/esm/utils/apiClient.d.ts +90 -0
  162. package/dist/esm/utils/apiClient.d.ts.map +1 -0
  163. package/dist/esm/utils/apiClient.js +169 -0
  164. package/dist/esm/utils/apiClient.js.map +1 -0
  165. package/dist/esm/utils/index.d.ts +11 -0
  166. package/dist/esm/utils/index.d.ts.map +1 -0
  167. package/dist/esm/utils/index.js +12 -0
  168. package/dist/esm/utils/index.js.map +1 -0
  169. package/dist/esm/utils/liquidation.d.ts +20 -0
  170. package/dist/esm/utils/liquidation.d.ts.map +1 -0
  171. package/dist/esm/utils/liquidation.js +29 -0
  172. package/dist/esm/utils/liquidation.js.map +1 -0
  173. package/dist/esm/utils/mapActivity.d.ts +21 -0
  174. package/dist/esm/utils/mapActivity.d.ts.map +1 -0
  175. package/dist/esm/utils/mapActivity.js +45 -0
  176. package/dist/esm/utils/mapActivity.js.map +1 -0
  177. package/dist/esm/utils/mapFill.d.ts +12 -0
  178. package/dist/esm/utils/mapFill.d.ts.map +1 -0
  179. package/dist/esm/utils/mapFill.js +37 -0
  180. package/dist/esm/utils/mapFill.js.map +1 -0
  181. package/dist/esm/utils/mapOrder.d.ts +50 -0
  182. package/dist/esm/utils/mapOrder.d.ts.map +1 -0
  183. package/dist/esm/utils/mapOrder.js +155 -0
  184. package/dist/esm/utils/mapOrder.js.map +1 -0
  185. package/dist/esm/utils/mapPosition.d.ts +19 -0
  186. package/dist/esm/utils/mapPosition.d.ts.map +1 -0
  187. package/dist/esm/utils/mapPosition.js +32 -0
  188. package/dist/esm/utils/mapPosition.js.map +1 -0
  189. package/dist/esm/utils/ohlcvInterval.d.ts +11 -0
  190. package/dist/esm/utils/ohlcvInterval.d.ts.map +1 -0
  191. package/dist/esm/utils/ohlcvInterval.js +59 -0
  192. package/dist/esm/utils/ohlcvInterval.js.map +1 -0
  193. package/dist/esm/utils/ondoAsset.d.ts +4 -0
  194. package/dist/esm/utils/ondoAsset.d.ts.map +1 -0
  195. package/dist/esm/utils/ondoAsset.js +9 -0
  196. package/dist/esm/utils/ondoAsset.js.map +1 -0
  197. package/dist/esm/utils/orderFormatting.d.ts +33 -0
  198. package/dist/esm/utils/orderFormatting.d.ts.map +1 -0
  199. package/dist/esm/utils/orderFormatting.js +62 -0
  200. package/dist/esm/utils/orderFormatting.js.map +1 -0
  201. package/dist/esm/websocket/OndoWsProvider.d.ts +122 -0
  202. package/dist/esm/websocket/OndoWsProvider.d.ts.map +1 -0
  203. package/dist/esm/websocket/OndoWsProvider.js +591 -0
  204. package/dist/esm/websocket/OndoWsProvider.js.map +1 -0
  205. package/dist/types/OndoProvider.d.ts +39 -0
  206. package/dist/types/OndoProvider.d.ts.map +1 -0
  207. package/dist/types/accountConfig.d.ts +13 -0
  208. package/dist/types/accountConfig.d.ts.map +1 -0
  209. package/dist/types/accountSummary.d.ts +12 -0
  210. package/dist/types/accountSummary.d.ts.map +1 -0
  211. package/dist/types/auth/OndoTokenStore.d.ts +20 -0
  212. package/dist/types/auth/OndoTokenStore.d.ts.map +1 -0
  213. package/dist/types/auth/completeSiweLogin.d.ts +28 -0
  214. package/dist/types/auth/completeSiweLogin.d.ts.map +1 -0
  215. package/dist/types/auth/index.d.ts +4 -0
  216. package/dist/types/auth/index.d.ts.map +1 -0
  217. package/dist/types/auth/signActions.d.ts +35 -0
  218. package/dist/types/auth/signActions.d.ts.map +1 -0
  219. package/dist/types/constants.d.ts +35 -0
  220. package/dist/types/constants.d.ts.map +1 -0
  221. package/dist/types/index.d.ts +19 -0
  222. package/dist/types/index.d.ts.map +1 -0
  223. package/dist/types/types/auth.d.ts +32 -0
  224. package/dist/types/types/auth.d.ts.map +1 -0
  225. package/dist/types/types/index.d.ts +4 -0
  226. package/dist/types/types/index.d.ts.map +1 -0
  227. package/dist/types/types/wire.d.ts +195 -0
  228. package/dist/types/types/wire.d.ts.map +1 -0
  229. package/dist/types/types/ws.d.ts +108 -0
  230. package/dist/types/types/ws.d.ts.map +1 -0
  231. package/dist/types/utils/activityCursor.d.ts +47 -0
  232. package/dist/types/utils/activityCursor.d.ts.map +1 -0
  233. package/dist/types/utils/apiClient.d.ts +90 -0
  234. package/dist/types/utils/apiClient.d.ts.map +1 -0
  235. package/dist/types/utils/index.d.ts +11 -0
  236. package/dist/types/utils/index.d.ts.map +1 -0
  237. package/dist/types/utils/liquidation.d.ts +20 -0
  238. package/dist/types/utils/liquidation.d.ts.map +1 -0
  239. package/dist/types/utils/mapActivity.d.ts +21 -0
  240. package/dist/types/utils/mapActivity.d.ts.map +1 -0
  241. package/dist/types/utils/mapFill.d.ts +12 -0
  242. package/dist/types/utils/mapFill.d.ts.map +1 -0
  243. package/dist/types/utils/mapOrder.d.ts +50 -0
  244. package/dist/types/utils/mapOrder.d.ts.map +1 -0
  245. package/dist/types/utils/mapPosition.d.ts +19 -0
  246. package/dist/types/utils/mapPosition.d.ts.map +1 -0
  247. package/dist/types/utils/ohlcvInterval.d.ts +11 -0
  248. package/dist/types/utils/ohlcvInterval.d.ts.map +1 -0
  249. package/dist/types/utils/ondoAsset.d.ts +4 -0
  250. package/dist/types/utils/ondoAsset.d.ts.map +1 -0
  251. package/dist/types/utils/orderFormatting.d.ts +33 -0
  252. package/dist/types/utils/orderFormatting.d.ts.map +1 -0
  253. package/dist/types/websocket/OndoWsProvider.d.ts +122 -0
  254. package/dist/types/websocket/OndoWsProvider.d.ts.map +1 -0
  255. package/package.json +64 -0
  256. package/src/OndoProvider.ts +635 -0
  257. package/src/accountConfig.ts +105 -0
  258. package/src/accountSummary.ts +22 -0
  259. package/src/auth/OndoTokenStore.ts +83 -0
  260. package/src/auth/completeSiweLogin.ts +43 -0
  261. package/src/auth/index.ts +12 -0
  262. package/src/auth/signActions.ts +160 -0
  263. package/src/constants.ts +38 -0
  264. package/src/index.ts +36 -0
  265. package/src/types/auth.ts +32 -0
  266. package/src/types/index.ts +5 -0
  267. package/src/types/wire.ts +228 -0
  268. package/src/types/ws.ts +79 -0
  269. package/src/utils/activityCursor.ts +140 -0
  270. package/src/utils/apiClient.ts +257 -0
  271. package/src/utils/index.ts +35 -0
  272. package/src/utils/liquidation.ts +37 -0
  273. package/src/utils/mapActivity.ts +61 -0
  274. package/src/utils/mapFill.ts +47 -0
  275. package/src/utils/mapOrder.ts +201 -0
  276. package/src/utils/mapPosition.ts +44 -0
  277. package/src/utils/ohlcvInterval.ts +69 -0
  278. package/src/utils/ondoAsset.ts +10 -0
  279. package/src/utils/orderFormatting.ts +70 -0
  280. package/src/websocket/OndoWsProvider.ts +752 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Ondo WebSocket wire types. Client ops are `{op, ...args}` envelopes (only
3
+ * `login` nests its arguments); server data frames are
4
+ * `{type: 'update', channel, data}`.
5
+ */
6
+ import type { OndoFill, OndoOrder, OndoPosition } from './wire.js';
7
+ /** Level tuple as streamed: `[price, size]`, both decimal strings. @public */
8
+ export type OndoBookLevel = [string, string];
9
+ /** Streamed order-book snapshot (`depthBooksPerps`/`topOfBooksPerps`). @public */
10
+ export interface OndoBookSnapshot {
11
+ market: string;
12
+ time: string;
13
+ asks: OndoBookLevel[];
14
+ bids: OndoBookLevel[];
15
+ depthLevels?: string;
16
+ }
17
+ /** Streamed public trade (`tradesPerps`). @public */
18
+ export interface OndoWsTrade {
19
+ market: string;
20
+ price: string;
21
+ size: string;
22
+ cost: string;
23
+ aggressor_side: 'buy' | 'sell';
24
+ time: string;
25
+ id: string;
26
+ }
27
+ /**
28
+ * Streamed candlestick (`kLinePerps`). Prices and volume arrive as numbers,
29
+ * unlike the string-typed REST shapes; `s`/`e`/`t` are Unix seconds.
30
+ * @public
31
+ */
32
+ export interface OndoKline {
33
+ m: string;
34
+ t: number;
35
+ s: number;
36
+ e: number;
37
+ o: number;
38
+ h: number;
39
+ l: number;
40
+ c: number;
41
+ v: number;
42
+ x: boolean;
43
+ }
44
+ /** Streamed mark price (`markPricesPerps`). @public */
45
+ export interface OndoMarkPrice {
46
+ market: string;
47
+ markPrice: string;
48
+ }
49
+ /** Streamed funding rate (`fundingRatesPerps`). @public */
50
+ export interface OndoFundingRate {
51
+ market: string;
52
+ rate: string;
53
+ intervalEnds: string;
54
+ premiums?: unknown[];
55
+ }
56
+ /** Server frame envelope. Non-`update` types are acks or errors. @public */
57
+ export type OndoWsMessage = {
58
+ type: 'update';
59
+ channel: 'depthBooksPerps';
60
+ data: OndoBookSnapshot[];
61
+ } | {
62
+ type: 'update';
63
+ channel: 'tradesPerps';
64
+ data: OndoWsTrade[];
65
+ } | {
66
+ type: 'update';
67
+ channel: 'kLinePerps';
68
+ data: OndoKline;
69
+ } | {
70
+ type: 'update';
71
+ channel: 'markPricesPerps';
72
+ data: OndoMarkPrice[];
73
+ } | {
74
+ type: 'update';
75
+ channel: 'fundingRatesPerps';
76
+ data: OndoFundingRate[];
77
+ } | {
78
+ type: 'update';
79
+ channel: 'ordersPerps';
80
+ data: OndoOrder[];
81
+ } | {
82
+ type: 'update';
83
+ channel: 'fillsPerps';
84
+ data: OndoFill[];
85
+ } | {
86
+ type: 'update';
87
+ channel: 'positionsPerps';
88
+ data: OndoPosition[];
89
+ } | {
90
+ type: 'update';
91
+ channel: string;
92
+ data: unknown;
93
+ } | {
94
+ type: 'pong';
95
+ } | {
96
+ type: 'loggedIn';
97
+ msg?: string;
98
+ } | {
99
+ type: 'subscribed';
100
+ channel?: string;
101
+ } | {
102
+ type: 'unsubscribed';
103
+ channel?: string;
104
+ } | {
105
+ type: 'error';
106
+ msg?: string;
107
+ };
108
+ //# sourceMappingURL=ws.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/types/ws.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAElE,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE5C,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,KAAK,GAAG,MAAM,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IAC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EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Ondo WebSocket wire types. Client ops are `{op, ...args}` envelopes (only
3
+ * `login` nests its arguments); server data frames are
4
+ * `{type: 'update', channel, data}`.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=ws.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ws.js","sourceRoot":"","sources":["../../../src/types/ws.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,47 @@
1
+ import { type ActivityItem } from '@lifi/perps-types';
2
+ /**
3
+ * Per-endpoint cursor envelope for Ondo activity pagination.
4
+ *
5
+ * Each key holds the `pageInfo.nextCursor` returned by that endpoint on the
6
+ * previous call. When a key is **present** with a non-empty string the
7
+ * corresponding endpoint will be re-fetched at that cursor on the next call;
8
+ * when a key is **absent** the endpoint is treated as exhausted (or never
9
+ * paged because the type filter excluded it) and skipped.
10
+ *
11
+ * The envelope is round-tripped through `cursor` as base64url JSON so callers
12
+ * don't need to know the per-endpoint shape.
13
+ * @public
14
+ */
15
+ export interface OndoActivityCursor {
16
+ fundings?: string;
17
+ liquidations?: string;
18
+ /**
19
+ * Already-fetched, merged-and-sorted rows that did not fit under the page
20
+ * `limit`. The upstream cursors above have advanced past these rows, so they
21
+ * are replayed (prepended) on the next page before any fresh fetch — without
22
+ * them the tail would be lost forever.
23
+ */
24
+ overflow?: ActivityItem[];
25
+ }
26
+ /**
27
+ * Encode an `OndoActivityCursor` as the base64url-of-JSON cursor string
28
+ * persisted between activity pages. Returns `undefined` when every
29
+ * per-endpoint key is empty and no `overflow` rows remain — the caller
30
+ * should report `hasMore: false` and omit `cursor` from `Pagination` then.
31
+ *
32
+ * Browser-direct: `Buffer` is Node-only. We use `btoa` over a Latin-1
33
+ * encoding of the UTF-8 bytes and then rewrite `+/=` to base64url. This is
34
+ * the same byte sequence Node's `Buffer.from(json, 'utf8').toString('base64url')`
35
+ * produces, so cursors round-trip across environments.
36
+ * @public
37
+ */
38
+ export declare const encodeActivityCursor: (env: OndoActivityCursor) => string | undefined;
39
+ /**
40
+ * Decode a previously-encoded activity cursor. Returns `undefined` for an
41
+ * absent cursor (first page) and throws {@link PerpsError} with
42
+ * `ValidationError` if the string is malformed — we'd rather fail loudly than
43
+ * silently re-page from page 1 and re-deliver already-paginated rows.
44
+ * @public
45
+ */
46
+ export declare const decodeActivityCursor: (cursor: string | undefined) => OndoActivityCursor | undefined;
47
+ //# sourceMappingURL=activityCursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activityCursor.d.ts","sourceRoot":"","sources":["../../../src/utils/activityCursor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,mBAAmB,CAAA;AAErE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;CAC1B;AAOD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,kBAAkB,KACtB,MAAM,GAAG,SAcX,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,GAAG,SAAS,KACzB,kBAAkB,GAAG,SA6CvB,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { PerpsError } from '@lifi/perps-sdk';
2
+ import { PerpsErrorCode } from '@lifi/perps-types';
3
+ const CURSOR_KEYS = ['fundings', 'liquidations'];
4
+ const isNonEmpty = (v) => typeof v === 'string' && v.length > 0;
5
+ /**
6
+ * Encode an `OndoActivityCursor` as the base64url-of-JSON cursor string
7
+ * persisted between activity pages. Returns `undefined` when every
8
+ * per-endpoint key is empty and no `overflow` rows remain — the caller
9
+ * should report `hasMore: false` and omit `cursor` from `Pagination` then.
10
+ *
11
+ * Browser-direct: `Buffer` is Node-only. We use `btoa` over a Latin-1
12
+ * encoding of the UTF-8 bytes and then rewrite `+/=` to base64url. This is
13
+ * the same byte sequence Node's `Buffer.from(json, 'utf8').toString('base64url')`
14
+ * produces, so cursors round-trip across environments.
15
+ * @public
16
+ */
17
+ export const encodeActivityCursor = (env) => {
18
+ const compact = {};
19
+ for (const key of CURSOR_KEYS) {
20
+ if (isNonEmpty(env[key])) {
21
+ compact[key] = env[key];
22
+ }
23
+ }
24
+ if (env.overflow !== undefined && env.overflow.length > 0) {
25
+ compact.overflow = env.overflow;
26
+ }
27
+ if (Object.keys(compact).length === 0) {
28
+ return undefined;
29
+ }
30
+ return toBase64Url(JSON.stringify(compact));
31
+ };
32
+ /**
33
+ * Decode a previously-encoded activity cursor. Returns `undefined` for an
34
+ * absent cursor (first page) and throws {@link PerpsError} with
35
+ * `ValidationError` if the string is malformed — we'd rather fail loudly than
36
+ * silently re-page from page 1 and re-deliver already-paginated rows.
37
+ * @public
38
+ */
39
+ export const decodeActivityCursor = (cursor) => {
40
+ if (cursor === undefined) {
41
+ return undefined;
42
+ }
43
+ let parsed;
44
+ try {
45
+ parsed = JSON.parse(fromBase64Url(cursor));
46
+ }
47
+ catch {
48
+ throw new PerpsError(PerpsErrorCode.ValidationError, 'Invalid Ondo activity cursor: not base64url-encoded JSON');
49
+ }
50
+ if (parsed === null || typeof parsed !== 'object') {
51
+ throw new PerpsError(PerpsErrorCode.ValidationError, 'Invalid Ondo activity cursor: expected JSON object');
52
+ }
53
+ const cursorRecord = parsed;
54
+ const env = {};
55
+ for (const key of CURSOR_KEYS) {
56
+ const v = cursorRecord[key];
57
+ if (v === undefined) {
58
+ continue;
59
+ }
60
+ if (typeof v !== 'string') {
61
+ throw new PerpsError(PerpsErrorCode.ValidationError, `Invalid Ondo activity cursor: ${key} must be a string`);
62
+ }
63
+ env[key] = v;
64
+ }
65
+ const overflow = cursorRecord.overflow;
66
+ if (overflow !== undefined) {
67
+ if (!Array.isArray(overflow)) {
68
+ throw new PerpsError(PerpsErrorCode.ValidationError, 'Invalid Ondo activity cursor: overflow must be an array');
69
+ }
70
+ env.overflow = overflow;
71
+ }
72
+ return env;
73
+ };
74
+ const toBase64Url = (s) => {
75
+ if (typeof Buffer !== 'undefined') {
76
+ return Buffer.from(s, 'utf8').toString('base64url');
77
+ }
78
+ const utf8 = unescape(encodeURIComponent(s));
79
+ return btoa(utf8).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
80
+ };
81
+ const fromBase64Url = (s) => {
82
+ if (typeof Buffer !== 'undefined') {
83
+ return Buffer.from(s, 'base64url').toString('utf8');
84
+ }
85
+ const padded = s.replace(/-/g, '+').replace(/_/g, '/') + padFor(s);
86
+ const decoded = atob(padded);
87
+ return decodeURIComponent(escape(decoded));
88
+ };
89
+ const padFor = (s) => {
90
+ const rem = s.length % 4;
91
+ return rem === 0 ? '' : '='.repeat(4 - rem);
92
+ };
93
+ //# sourceMappingURL=activityCursor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activityCursor.js","sourceRoot":"","sources":["../../../src/utils/activityCursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACrD,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC9E,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,CAAS,EAAU,EAAE;IAC1C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACrD,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IAClE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5B,OAAO,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;AAC5C,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE;IACnC,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IACxB,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;AAC7C,CAAC,CAAA"}
@@ -0,0 +1,90 @@
1
+ import { PerpsError, type ResolvedRetryPolicy } from '@lifi/perps-sdk';
2
+ import type { OndoPageInfo } from '../types/wire.js';
3
+ /** @internal */
4
+ export type ApiParams = Record<string, string | number | boolean>;
5
+ /** One page of a paginated Ondo response: `pageInfo` is a SIBLING of `result`. @public */
6
+ export interface OndoPage<T> {
7
+ result: T[];
8
+ pageInfo: OndoPageInfo | undefined;
9
+ }
10
+ /** @internal */
11
+ export type OndoHttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
12
+ /**
13
+ * Ondo request failure — a non-2xx HTTP status, a `success: false` envelope,
14
+ * or a body that is not a `GenericResponse` envelope at all. `errorCode`
15
+ * carries the wire `error_code` when the envelope advertised one.
16
+ *
17
+ * @public
18
+ */
19
+ export declare class OndoApiError extends PerpsError {
20
+ readonly errorCode: string | undefined;
21
+ constructor(message: string, errorCode?: string);
22
+ }
23
+ /**
24
+ * The Ondo session JWT was rejected (HTTP 401). Distinct from
25
+ * {@link OndoApiError} so callers can evict the stored token and re-run the
26
+ * SIWE login instead of surfacing a generic venue failure.
27
+ *
28
+ * @public
29
+ */
30
+ export declare class OndoSessionExpiredError extends PerpsError {
31
+ constructor(message: string);
32
+ }
33
+ /** @internal */
34
+ export declare const ONDO_RETRY_DEFAULTS: ResolvedRetryPolicy;
35
+ /** @internal */
36
+ export interface OndoApiClientOptions {
37
+ signal?: AbortSignal;
38
+ policy?: ResolvedRetryPolicy;
39
+ fetchImpl?: typeof fetch;
40
+ }
41
+ /** @internal */
42
+ export interface OndoRequestOptions {
43
+ params?: ApiParams;
44
+ /** Ondo session JWT, sent as `Authorization: Bearer <token>`. */
45
+ authToken?: string;
46
+ }
47
+ /**
48
+ * HTTP boundary against Ondo's REST API.
49
+ *
50
+ * Browser-direct by design: the session JWT lives client-side only, so
51
+ * credentialed calls (`authToken` option) go straight to Ondo — never through
52
+ * the LI.FI backend. Every response is an `OndoGenericResponse` envelope; the
53
+ * client unwraps `result` on success and throws {@link OndoApiError} (carrying
54
+ * the wire `error_code`) otherwise. An HTTP 401 throws
55
+ * {@link OndoSessionExpiredError} so callers can re-run the SIWE login.
56
+ * @public
57
+ */
58
+ export declare class OndoApiClient {
59
+ private readonly baseUrl;
60
+ private readonly signal;
61
+ private readonly policy;
62
+ private readonly fetchImpl;
63
+ constructor(baseUrl: string, options?: OndoApiClientOptions);
64
+ get<T>(path: string, options?: OndoRequestOptions): Promise<T>;
65
+ /**
66
+ * GET a paginated endpoint, preserving the `pageInfo` sibling that
67
+ * {@link get}'s envelope unwrap would otherwise drop.
68
+ */
69
+ getPage<T>(path: string, options?: OndoRequestOptions): Promise<OndoPage<T>>;
70
+ /**
71
+ * Arbitrary-method request with caller-prebuilt headers — the execution
72
+ * surface for credential-bearing `RestCallSignedActionStep`s, whose
73
+ * `Authorization` header is attached by `signActions` from the token store.
74
+ * Only GET is ever retried; writes are not idempotent.
75
+ */
76
+ send<T>(method: OndoHttpMethod, path: string, options?: {
77
+ body?: unknown;
78
+ headers?: Record<string, string>;
79
+ }): Promise<T>;
80
+ /**
81
+ * POSTs are never auto-retried regardless of policy: Ondo writes (order
82
+ * placement, login completion) are not idempotent, and a retried request
83
+ * whose first attempt landed would double-submit.
84
+ */
85
+ post<T>(path: string, body?: unknown, options?: Pick<OndoRequestOptions, 'authToken'>): Promise<T>;
86
+ private buildUrl;
87
+ private perform;
88
+ private unwrap;
89
+ }
90
+ //# sourceMappingURL=apiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../../../src/utils/apiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAA;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,gBAAgB;AAChB,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;AAEjE,0FAA0F;AAC1F,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,MAAM,EAAE,CAAC,EAAE,CAAA;IACX,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAA;CACnC;AAED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;IAYvB;;;;;OAKG;IACG,IAAI,CAAC,CAAC,EACV,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAC7D,OAAO,CAAC,CAAC,CAAC;IAUb;;;;OAIG;IACG,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAC9C,OAAO,CAAC,CAAC,CAAC;IAUb,OAAO,CAAC,QAAQ;YAaF,OAAO;IAgCrB,OAAO,CAAC,MAAM;CAyBf"}
@@ -0,0 +1,169 @@
1
+ import { DISABLED_RETRY, fetchWithRetry, PerpsError, } from '@lifi/perps-sdk';
2
+ import { PerpsErrorCode } from '@lifi/perps-types';
3
+ /**
4
+ * Ondo request failure — a non-2xx HTTP status, a `success: false` envelope,
5
+ * or a body that is not a `GenericResponse` envelope at all. `errorCode`
6
+ * carries the wire `error_code` when the envelope advertised one.
7
+ *
8
+ * @public
9
+ */
10
+ export class OndoApiError extends PerpsError {
11
+ errorCode;
12
+ constructor(message, errorCode) {
13
+ super(PerpsErrorCode.ThirdPartyError, message);
14
+ this.errorCode = errorCode;
15
+ }
16
+ }
17
+ /**
18
+ * The Ondo session JWT was rejected (HTTP 401). Distinct from
19
+ * {@link OndoApiError} so callers can evict the stored token and re-run the
20
+ * SIWE login instead of surfacing a generic venue failure.
21
+ *
22
+ * @public
23
+ */
24
+ export class OndoSessionExpiredError extends PerpsError {
25
+ constructor(message) {
26
+ super(PerpsErrorCode.Unauthorized, message);
27
+ }
28
+ }
29
+ /** @internal */
30
+ export const ONDO_RETRY_DEFAULTS = {
31
+ enabled: true,
32
+ maxAttempts: 2,
33
+ baseDelayMs: 1_000,
34
+ maxDelayMs: 30_000,
35
+ respectRetryAfter: true,
36
+ classify: ({ response }) => {
37
+ if (response.status === 429) {
38
+ return 'retry-rate-limit';
39
+ }
40
+ if (response.status === 502 ||
41
+ response.status === 503 ||
42
+ response.status === 504) {
43
+ return 'retry-server';
44
+ }
45
+ return 'fail';
46
+ },
47
+ };
48
+ const isGenericResponse = (data) => typeof data === 'object' &&
49
+ data !== null &&
50
+ typeof data.success === 'boolean';
51
+ /**
52
+ * HTTP boundary against Ondo's REST API.
53
+ *
54
+ * Browser-direct by design: the session JWT lives client-side only, so
55
+ * credentialed calls (`authToken` option) go straight to Ondo — never through
56
+ * the LI.FI backend. Every response is an `OndoGenericResponse` envelope; the
57
+ * client unwraps `result` on success and throws {@link OndoApiError} (carrying
58
+ * the wire `error_code`) otherwise. An HTTP 401 throws
59
+ * {@link OndoSessionExpiredError} so callers can re-run the SIWE login.
60
+ * @public
61
+ */
62
+ export class OndoApiClient {
63
+ baseUrl;
64
+ signal;
65
+ policy;
66
+ fetchImpl;
67
+ constructor(baseUrl, options) {
68
+ this.baseUrl = baseUrl.replace(/\/$/, '');
69
+ this.signal = options?.signal;
70
+ this.policy = options?.policy ?? ONDO_RETRY_DEFAULTS;
71
+ this.fetchImpl = options?.fetchImpl;
72
+ }
73
+ async get(path, options) {
74
+ const { status, data } = await this.perform(path, {
75
+ method: 'GET',
76
+ params: options?.params,
77
+ authToken: options?.authToken,
78
+ policy: this.policy,
79
+ });
80
+ return this.unwrap(path, status, data);
81
+ }
82
+ /**
83
+ * GET a paginated endpoint, preserving the `pageInfo` sibling that
84
+ * {@link get}'s envelope unwrap would otherwise drop.
85
+ */
86
+ async getPage(path, options) {
87
+ const { status, data } = await this.perform(path, {
88
+ method: 'GET',
89
+ params: options?.params,
90
+ authToken: options?.authToken,
91
+ policy: this.policy,
92
+ });
93
+ const result = this.unwrap(path, status, data);
94
+ const pageInfo = data.pageInfo;
95
+ return { result: result ?? [], pageInfo };
96
+ }
97
+ /**
98
+ * Arbitrary-method request with caller-prebuilt headers — the execution
99
+ * surface for credential-bearing `RestCallSignedActionStep`s, whose
100
+ * `Authorization` header is attached by `signActions` from the token store.
101
+ * Only GET is ever retried; writes are not idempotent.
102
+ */
103
+ async send(method, path, options) {
104
+ const { status, data } = await this.perform(path, {
105
+ method,
106
+ body: options?.body,
107
+ headers: options?.headers,
108
+ policy: method === 'GET' ? this.policy : DISABLED_RETRY,
109
+ });
110
+ return this.unwrap(path, status, data);
111
+ }
112
+ /**
113
+ * POSTs are never auto-retried regardless of policy: Ondo writes (order
114
+ * placement, login completion) are not idempotent, and a retried request
115
+ * whose first attempt landed would double-submit.
116
+ */
117
+ async post(path, body, options) {
118
+ const { status, data } = await this.perform(path, {
119
+ method: 'POST',
120
+ body,
121
+ authToken: options?.authToken,
122
+ policy: DISABLED_RETRY,
123
+ });
124
+ return this.unwrap(path, status, data);
125
+ }
126
+ buildUrl(path, params) {
127
+ const url = `${this.baseUrl}${path}`;
128
+ if (!params || Object.keys(params).length === 0) {
129
+ return url;
130
+ }
131
+ const qs = Object.entries(params)
132
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
133
+ .join('&');
134
+ return `${url}?${qs}`;
135
+ }
136
+ async perform(path, options) {
137
+ const headers = {
138
+ Accept: 'application/json',
139
+ ...options.headers,
140
+ };
141
+ if (options.authToken) {
142
+ headers.Authorization = `Bearer ${options.authToken}`;
143
+ }
144
+ const init = { method: options.method, headers };
145
+ if (options.method !== 'GET' && options.method !== 'DELETE') {
146
+ headers['Content-Type'] = 'application/json';
147
+ init.body = JSON.stringify(options.body ?? {});
148
+ }
149
+ const response = await fetchWithRetry(this.buildUrl(path, options.params), init, { policy: options.policy, fetchImpl: this.fetchImpl, signal: this.signal });
150
+ const data = await response.json().catch(() => undefined);
151
+ return { status: response.status, data };
152
+ }
153
+ unwrap(path, status, data) {
154
+ if (status === 401) {
155
+ throw new OndoSessionExpiredError(`Ondo rejected the session token for ${path}`);
156
+ }
157
+ if (status < 200 || status >= 300) {
158
+ throw new OndoApiError(`Ondo API request failed: ${status} — ${JSON.stringify(data).slice(0, 200)}`, isGenericResponse(data) ? data.error_code : undefined);
159
+ }
160
+ if (!isGenericResponse(data)) {
161
+ throw new OndoApiError(`Ondo API returned an unexpected body for ${path}: ${JSON.stringify(data).slice(0, 200)}`);
162
+ }
163
+ if (!data.success) {
164
+ throw new OndoApiError(`Ondo API error for ${path}: ${data.error_code ?? 'unknown'} — ${data.error ?? 'no error message'}`, data.error_code);
165
+ }
166
+ return data.result;
167
+ }
168
+ }
169
+ //# sourceMappingURL=apiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../../src/utils/apiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,UAAU,GAEX,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAgBlD;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,UAAU;IACjC,SAAS,CAAoB;IAEtC,YAAY,OAAe,EAAE,SAAkB;QAC7C,KAAK,CAAC,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;QAC9C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,uBAAwB,SAAQ,UAAU;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACtD,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,MAAM;IAClB,iBAAiB,EAAE,IAAI;IACvB,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACzB,IAAI,QAAQ,CAAC,MAAM,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AI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,YAAY,CACpB,sBAAsB,IAAI,KAAK,IAAI,CAAC,UAAU,IAAI,SAAS,MAAM,IAAI,CAAC,KAAK,IAAI,kBAAkB,EAAE,EACnG,IAAI,CAAC,UAAU,CAChB,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,MAAW,CAAA;IACzB,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ export { decodeActivityCursor, encodeActivityCursor, type OndoActivityCursor, } from './activityCursor.js';
2
+ export { type ApiParams, ONDO_RETRY_DEFAULTS, OndoApiClient, type OndoApiClientOptions, OndoApiError, type OndoHttpMethod, type OndoPage, type OndoRequestOptions, OndoSessionExpiredError, } from './apiClient.js';
3
+ export { estimateLiquidationPrice } from './liquidation.js';
4
+ export { mapFundingActivity, mapLiquidationActivity } from './mapActivity.js';
5
+ export { mapFill } from './mapFill.js';
6
+ export { classifyAndMapOrders, isTriggerOrder, mapOrder, mapOrderDetail, mapOrderStatus, mapOrderType, mapStatusReason, mapTriggerOrder, } from './mapOrder.js';
7
+ export { mapOpenPositions, mapPosition } from './mapPosition.js';
8
+ export { intervalFromBarSpan, mapInterval } from './ohlcvInterval.js';
9
+ export { ondoAsset } from './ondoAsset.js';
10
+ export { formatOrderPrice, formatOrderSize } from './orderFormatting.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,KAAK,SAAS,EACd,mBAAmB,EACnB,aAAa,EACb,KAAK,oBAAoB,EACzB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,uBAAuB,GACxB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,12 @@
1
+ // biome-ignore-all lint/performance/noBarrelFile: module public entry point.
2
+ export { decodeActivityCursor, encodeActivityCursor, } from './activityCursor.js';
3
+ export { ONDO_RETRY_DEFAULTS, OndoApiClient, OndoApiError, OndoSessionExpiredError, } from './apiClient.js';
4
+ export { estimateLiquidationPrice } from './liquidation.js';
5
+ export { mapFundingActivity, mapLiquidationActivity } from './mapActivity.js';
6
+ export { mapFill } from './mapFill.js';
7
+ export { classifyAndMapOrders, isTriggerOrder, mapOrder, mapOrderDetail, mapOrderStatus, mapOrderType, mapStatusReason, mapTriggerOrder, } from './mapOrder.js';
8
+ export { mapOpenPositions, mapPosition } from './mapPosition.js';
9
+ export { intervalFromBarSpan, mapInterval } from './ohlcvInterval.js';
10
+ export { ondoAsset } from './ondoAsset.js';
11
+ export { formatOrderPrice, formatOrderSize } from './orderFormatting.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,mBAAmB,EACnB,aAAa,EAEb,YAAY,EAIZ,uBAAuB,GACxB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Ondo liquidation price estimation.
3
+ *
4
+ * The LI.FI backend surfaces Ondo's per-market maintenance margin rate on the
5
+ * generic {@link PerpsMarket} as `maintenanceMarginRate`. The estimate is the
6
+ * standard isolated-margin model parameterised by that rate.
7
+ */
8
+ import { type LiquidationEstimateParams } from '@lifi/perps-sdk';
9
+ import type { PerpsMarket } from '@lifi/perps-types';
10
+ /**
11
+ * Estimate the liquidation price of a new position on an Ondo market.
12
+ *
13
+ * @returns The estimated liquidation price, or `undefined` when
14
+ * `market.maintenanceMarginRate` is absent (the model cannot be evaluated
15
+ * without the venue's maintenance margin rate) or the inputs are
16
+ * degenerate.
17
+ * @public
18
+ */
19
+ export declare function estimateLiquidationPrice(market: PerpsMarket, params: LiquidationEstimateParams): number | undefined;
20
+ //# sourceMappingURL=liquidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liquidation.d.ts","sourceRoot":"","sources":["../../../src/utils/liquidation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,yBAAyB,GAChC,MAAM,GAAG,SAAS,CAUpB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Ondo liquidation price estimation.
3
+ *
4
+ * The LI.FI backend surfaces Ondo's per-market maintenance margin rate on the
5
+ * generic {@link PerpsMarket} as `maintenanceMarginRate`. The estimate is the
6
+ * standard isolated-margin model parameterised by that rate.
7
+ */
8
+ import { estimateIsolatedLiquidationPrice, } from '@lifi/perps-sdk';
9
+ /**
10
+ * Estimate the liquidation price of a new position on an Ondo market.
11
+ *
12
+ * @returns The estimated liquidation price, or `undefined` when
13
+ * `market.maintenanceMarginRate` is absent (the model cannot be evaluated
14
+ * without the venue's maintenance margin rate) or the inputs are
15
+ * degenerate.
16
+ * @public
17
+ */
18
+ export function estimateLiquidationPrice(market, params) {
19
+ if (market.maintenanceMarginRate === undefined) {
20
+ return undefined;
21
+ }
22
+ return estimateIsolatedLiquidationPrice({
23
+ entryPrice: params.entryPrice,
24
+ leverage: params.leverage,
25
+ isLong: params.isLong,
26
+ maintenanceMarginRate: market.maintenanceMarginRate,
27
+ });
28
+ }
29
+ //# sourceMappingURL=liquidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liquidation.js","sourceRoot":"","sources":["../../../src/utils/liquidation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,gCAAgC,GAEjC,MAAM,iBAAiB,CAAA;AAGxB;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAmB,EACnB,MAAiC;IAEjC,IAAI,MAAM,CAAC,qBAAqB,KAAK,SAAS,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,gCAAgC,CAAC;QACtC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;KACpD,CAAC,CAAA;AACJ,CAAC"}