@n1xyz/nord-ts 0.0.21 → 0.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 (46) hide show
  1. package/README.md +20 -16
  2. package/dist/api/client.d.ts +14 -0
  3. package/dist/api/client.js +45 -0
  4. package/dist/bridge/client.d.ts +151 -0
  5. package/dist/bridge/client.js +434 -0
  6. package/dist/bridge/const.d.ts +23 -0
  7. package/dist/bridge/const.js +47 -0
  8. package/dist/bridge/index.d.ts +4 -0
  9. package/dist/bridge/index.js +23 -0
  10. package/dist/bridge/types.d.ts +120 -0
  11. package/dist/bridge/types.js +18 -0
  12. package/dist/bridge/utils.d.ts +64 -0
  13. package/dist/bridge/utils.js +131 -0
  14. package/dist/gen/common.d.ts +68 -0
  15. package/dist/gen/common.js +215 -0
  16. package/dist/gen/nord_pb.d.ts +3719 -0
  17. package/dist/gen/nord_pb.js +945 -0
  18. package/dist/gen/openapi.d.ts +268 -4
  19. package/dist/idl/bridge.d.ts +569 -0
  20. package/dist/idl/bridge.js +8 -0
  21. package/dist/idl/bridge.json +1506 -0
  22. package/dist/idl/index.d.ts +607 -0
  23. package/dist/idl/index.js +8 -0
  24. package/dist/nord/api/actions.d.ts +31 -72
  25. package/dist/nord/api/actions.js +199 -201
  26. package/dist/nord/api/market.d.ts +36 -0
  27. package/dist/nord/api/market.js +96 -0
  28. package/dist/nord/api/queries.d.ts +46 -0
  29. package/dist/nord/api/queries.js +109 -0
  30. package/dist/nord/client/Nord.js +3 -3
  31. package/dist/nord/client/NordUser.d.ts +26 -13
  32. package/dist/nord/client/NordUser.js +13 -10
  33. package/dist/types.d.ts +12 -1
  34. package/dist/types.js +29 -2
  35. package/dist/utils.d.ts +6 -20
  36. package/dist/utils.js +17 -35
  37. package/dist/websocket/NordWebSocketClient.js +2 -6
  38. package/package.json +26 -23
  39. package/src/gen/nord_pb.ts +4257 -0
  40. package/src/gen/openapi.ts +268 -4
  41. package/src/nord/api/actions.ts +278 -369
  42. package/src/nord/client/Nord.ts +3 -3
  43. package/src/nord/client/NordUser.ts +40 -19
  44. package/src/types.ts +32 -1
  45. package/src/utils.ts +24 -43
  46. package/src/websocket/NordWebSocketClient.ts +2 -8
@@ -111,11 +111,13 @@ export interface paths {
111
111
  };
112
112
  };
113
113
  put?: never;
114
- /** @description Send an action to nord to execute. */
114
+ /** @description Send an action to nord to execute. This doesn't use `Protobuf<T>` since we want to length-delimit this message. `body` - (length prefix of action, action data protobuf, and signature). signature has exact length, but depend on action kind. body is exact payload used via other transports and journalled for rexecution */
115
115
  post: {
116
116
  parameters: {
117
117
  query?: never;
118
- header?: never;
118
+ header: {
119
+ "content-type": string;
120
+ };
119
121
  path?: never;
120
122
  cookie?: never;
121
123
  };
@@ -134,6 +136,19 @@ export interface paths {
134
136
  "application/octet-stream": unknown;
135
137
  };
136
138
  };
139
+ 415: {
140
+ headers: {
141
+ /**
142
+ * @description Expected request media type
143
+ * @example application/octet-stream
144
+ */
145
+ accept: string;
146
+ [name: string]: unknown;
147
+ };
148
+ content: {
149
+ "application/json": components["schemas"]["AcceptedMediaType"];
150
+ };
151
+ };
137
152
  };
138
153
  };
139
154
  delete?: never;
@@ -408,6 +423,14 @@ export interface paths {
408
423
  "application/json": components["schemas"]["MarketStats"];
409
424
  };
410
425
  };
426
+ 404: {
427
+ headers: {
428
+ [name: string]: unknown;
429
+ };
430
+ content: {
431
+ "application/json": components["schemas"]["MarketNotFound"];
432
+ };
433
+ };
411
434
  };
412
435
  };
413
436
  put?: never;
@@ -636,6 +659,138 @@ export interface paths {
636
659
  patch?: never;
637
660
  trace?: never;
638
661
  };
662
+ "/account/{account_id}/pnl": {
663
+ parameters: {
664
+ query?: never;
665
+ header?: never;
666
+ path?: never;
667
+ cookie?: never;
668
+ };
669
+ /** @description Get account's PnL (Profit and Loss) history, ordered from most recent to oldest.
670
+ *
671
+ * Pagination Results include account PnL records with timestamp, account_id, action_id, and pnl value. Use query parameters `since` and `until` for time-based filtering, and `startInclusive` for pagination.
672
+ *
673
+ * To fetch more data, use the same `since` and `until` parameters and set `startInclusive` to the `nextStartInclusive` value from the previous response. If `nextStartInclusive` is absent, it means there's no more data to fetch, even if the max number of entries were returned. */
674
+ get: {
675
+ parameters: {
676
+ query?: {
677
+ /** @description start with this timestamp (RFC3339); defaults to UNIX epoch start */
678
+ since?: string;
679
+ /** @description end with this timestamp (RFC3339); defaults to current date-time */
680
+ until?: string;
681
+ /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
682
+ startInclusive?: number | null;
683
+ /** @description Query returns up to 50 trades in one go. */
684
+ pageSize?: number | null;
685
+ };
686
+ header?: never;
687
+ path: {
688
+ /** @description Account for which to retrieve PnL history */
689
+ account_id: number;
690
+ };
691
+ cookie?: never;
692
+ };
693
+ requestBody?: never;
694
+ responses: {
695
+ 200: {
696
+ headers: {
697
+ [name: string]: unknown;
698
+ };
699
+ content: {
700
+ "application/json": components["schemas"]["PageResult_for_uint64_and_AccountPnl"];
701
+ };
702
+ };
703
+ };
704
+ };
705
+ put?: never;
706
+ post?: never;
707
+ delete?: never;
708
+ options?: never;
709
+ head?: never;
710
+ patch?: never;
711
+ trace?: never;
712
+ };
713
+ "/account/{account_id}/triggers/history": {
714
+ parameters: {
715
+ query?: never;
716
+ header?: never;
717
+ path?: never;
718
+ cookie?: never;
719
+ };
720
+ get: {
721
+ parameters: {
722
+ query?: {
723
+ /** @description start with this timestamp (RFC3339); defaults to UNIX epoch start */
724
+ since?: string;
725
+ /** @description end with this timestamp (RFC3339); defaults to current date-time */
726
+ until?: string;
727
+ /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
728
+ startInclusive?: number | null;
729
+ /** @description Query returns up to 50 trades in one go. */
730
+ pageSize?: number | null;
731
+ };
732
+ header?: never;
733
+ path: {
734
+ account_id: number;
735
+ };
736
+ cookie?: never;
737
+ };
738
+ requestBody?: never;
739
+ responses: {
740
+ 200: {
741
+ headers: {
742
+ [name: string]: unknown;
743
+ };
744
+ content: {
745
+ "application/json": components["schemas"]["PageResult_for_uint64_and_HistoryTriggerInfo"];
746
+ };
747
+ };
748
+ };
749
+ };
750
+ put?: never;
751
+ post?: never;
752
+ delete?: never;
753
+ options?: never;
754
+ head?: never;
755
+ patch?: never;
756
+ trace?: never;
757
+ };
758
+ "/account/{account_id}/triggers": {
759
+ parameters: {
760
+ query?: never;
761
+ header?: never;
762
+ path?: never;
763
+ cookie?: never;
764
+ };
765
+ get: {
766
+ parameters: {
767
+ query?: never;
768
+ header?: never;
769
+ path: {
770
+ account_id: number;
771
+ };
772
+ cookie?: never;
773
+ };
774
+ requestBody?: never;
775
+ responses: {
776
+ 200: {
777
+ headers: {
778
+ [name: string]: unknown;
779
+ };
780
+ content: {
781
+ "application/json": components["schemas"]["TriggerInfo"][] | null;
782
+ };
783
+ };
784
+ };
785
+ };
786
+ put?: never;
787
+ post?: never;
788
+ delete?: never;
789
+ options?: never;
790
+ head?: never;
791
+ patch?: never;
792
+ trace?: never;
793
+ };
639
794
  "/account/{account_id}/pubkey": {
640
795
  parameters: {
641
796
  query?: never;
@@ -1752,6 +1907,9 @@ export interface components {
1752
1907
  /** Format: uint16 */
1753
1908
  weightBps: number;
1754
1909
  };
1910
+ AcceptedMediaType: {
1911
+ expected: string;
1912
+ };
1755
1913
  ActionsQuery: {
1756
1914
  /** Format: uint64 */
1757
1915
  from: number;
@@ -1761,8 +1919,7 @@ export interface components {
1761
1919
  ActionsItem: {
1762
1920
  /** Format: uint64 */
1763
1921
  actionId: number;
1764
- /** Format: int64 */
1765
- physicalTime: number;
1922
+ physicalTime: string;
1766
1923
  payload: string;
1767
1924
  };
1768
1925
  RangeTooLarge: {
@@ -2008,6 +2165,113 @@ export interface components {
2008
2165
  /** @description See `bankruptcy` in MARKETS.md. In general happens if account does not have enough weighted tokens to covert his debt and negative PnL. */
2009
2166
  bankruptcy: boolean;
2010
2167
  };
2168
+ AccountPnlQuery: {
2169
+ /**
2170
+ * @description start with this timestamp (RFC3339); defaults to UNIX epoch start
2171
+ * @default null
2172
+ */
2173
+ since: string;
2174
+ /**
2175
+ * @description end with this timestamp (RFC3339); defaults to current date-time
2176
+ * @default null
2177
+ */
2178
+ until: string;
2179
+ /**
2180
+ * Format: uint64
2181
+ * @description fetch results starting with this page; query starts with first entry if page isn't specified
2182
+ */
2183
+ startInclusive?: number | null;
2184
+ /**
2185
+ * Format: uint8
2186
+ * @description Query returns up to 50 trades in one go.
2187
+ * @default null
2188
+ */
2189
+ pageSize: number | null;
2190
+ };
2191
+ PageResult_for_uint64_and_AccountPnl: {
2192
+ /** @description Set of items for requested by query. */
2193
+ items: components["schemas"]["AccountPnl"][];
2194
+ /**
2195
+ * Format: uint64
2196
+ * @description If request contains more data, this is the id is set with which next request should be performed to get next page. If no more data, then it is undefined.
2197
+ */
2198
+ nextStartInclusive?: number | null;
2199
+ };
2200
+ AccountPnl: {
2201
+ time: string;
2202
+ /** Format: uint64 */
2203
+ actionId: number;
2204
+ /** Format: uint32 */
2205
+ accountId: number;
2206
+ /** Format: double */
2207
+ pnl: number;
2208
+ };
2209
+ AccountTriggersQuery: {
2210
+ /**
2211
+ * @description start with this timestamp (RFC3339); defaults to UNIX epoch start
2212
+ * @default null
2213
+ */
2214
+ since: string;
2215
+ /**
2216
+ * @description end with this timestamp (RFC3339); defaults to current date-time
2217
+ * @default null
2218
+ */
2219
+ until: string;
2220
+ /**
2221
+ * Format: uint64
2222
+ * @description fetch results starting with this page; query starts with first entry if page isn't specified
2223
+ */
2224
+ startInclusive?: number | null;
2225
+ /**
2226
+ * Format: uint8
2227
+ * @description Query returns up to 50 trades in one go.
2228
+ * @default null
2229
+ */
2230
+ pageSize: number | null;
2231
+ };
2232
+ PageResult_for_uint64_and_HistoryTriggerInfo: {
2233
+ /** @description Set of items for requested by query. */
2234
+ items: components["schemas"]["HistoryTriggerInfo"][];
2235
+ /**
2236
+ * Format: uint64
2237
+ * @description If request contains more data, this is the id is set with which next request should be performed to get next page. If no more data, then it is undefined.
2238
+ */
2239
+ nextStartInclusive?: number | null;
2240
+ };
2241
+ HistoryTriggerInfo: {
2242
+ /** Format: uint32 */
2243
+ accountId: number;
2244
+ /** Format: uint32 */
2245
+ marketId: number;
2246
+ /** Format: uint64 */
2247
+ price: number;
2248
+ side: components["schemas"]["Side"];
2249
+ kind: components["schemas"]["TriggerKind"];
2250
+ status: components["schemas"]["TriggerStatus"];
2251
+ /** Format: uint64 */
2252
+ createdAtActionId: number;
2253
+ /** Format: uint64 */
2254
+ finalizedAtActionId?: number | null;
2255
+ createdAt: string;
2256
+ finalizedAt: string;
2257
+ };
2258
+ /** @enum {string} */
2259
+ TriggerKind: "stopLoss" | "takeProfit";
2260
+ /** @enum {string} */
2261
+ TriggerStatus: "active" | "success" | "cancel" | "fail" | "remove";
2262
+ TriggerInfo: {
2263
+ /** Format: uint32 */
2264
+ marketId: number;
2265
+ side: components["schemas"]["Side"];
2266
+ kind: components["schemas"]["TriggerKind"];
2267
+ triggerPrice: components["schemas"]["PositivePriceMantissa"];
2268
+ limitPrice?: components["schemas"]["PositivePriceMantissa"] | null;
2269
+ };
2270
+ /**
2271
+ * Format: uint64
2272
+ * @description 63 bit integer, which is always positive
2273
+ */
2274
+ PositivePriceMantissa: number;
2011
2275
  OrderNotFound: null;
2012
2276
  PageResult_for_String_and_Trade: {
2013
2277
  /** @description Set of items for requested by query. */