@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
@@ -112,11 +112,13 @@ export interface paths {
112
112
  };
113
113
  };
114
114
  put?: never;
115
- /** @description Send an action to nord to execute. */
115
+ /** @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 */
116
116
  post: {
117
117
  parameters: {
118
118
  query?: never;
119
- header?: never;
119
+ header: {
120
+ "content-type": string;
121
+ };
120
122
  path?: never;
121
123
  cookie?: never;
122
124
  };
@@ -135,6 +137,19 @@ export interface paths {
135
137
  "application/octet-stream": unknown;
136
138
  };
137
139
  };
140
+ 415: {
141
+ headers: {
142
+ /**
143
+ * @description Expected request media type
144
+ * @example application/octet-stream
145
+ */
146
+ accept: string;
147
+ [name: string]: unknown;
148
+ };
149
+ content: {
150
+ "application/json": components["schemas"]["AcceptedMediaType"];
151
+ };
152
+ };
138
153
  };
139
154
  };
140
155
  delete?: never;
@@ -409,6 +424,14 @@ export interface paths {
409
424
  "application/json": components["schemas"]["MarketStats"];
410
425
  };
411
426
  };
427
+ 404: {
428
+ headers: {
429
+ [name: string]: unknown;
430
+ };
431
+ content: {
432
+ "application/json": components["schemas"]["MarketNotFound"];
433
+ };
434
+ };
412
435
  };
413
436
  };
414
437
  put?: never;
@@ -637,6 +660,138 @@ export interface paths {
637
660
  patch?: never;
638
661
  trace?: never;
639
662
  };
663
+ "/account/{account_id}/pnl": {
664
+ parameters: {
665
+ query?: never;
666
+ header?: never;
667
+ path?: never;
668
+ cookie?: never;
669
+ };
670
+ /** @description Get account's PnL (Profit and Loss) history, ordered from most recent to oldest.
671
+ *
672
+ * 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.
673
+ *
674
+ * 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. */
675
+ get: {
676
+ parameters: {
677
+ query?: {
678
+ /** @description start with this timestamp (RFC3339); defaults to UNIX epoch start */
679
+ since?: string;
680
+ /** @description end with this timestamp (RFC3339); defaults to current date-time */
681
+ until?: string;
682
+ /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
683
+ startInclusive?: number | null;
684
+ /** @description Query returns up to 50 trades in one go. */
685
+ pageSize?: number | null;
686
+ };
687
+ header?: never;
688
+ path: {
689
+ /** @description Account for which to retrieve PnL history */
690
+ account_id: number;
691
+ };
692
+ cookie?: never;
693
+ };
694
+ requestBody?: never;
695
+ responses: {
696
+ 200: {
697
+ headers: {
698
+ [name: string]: unknown;
699
+ };
700
+ content: {
701
+ "application/json": components["schemas"]["PageResult_for_uint64_and_AccountPnl"];
702
+ };
703
+ };
704
+ };
705
+ };
706
+ put?: never;
707
+ post?: never;
708
+ delete?: never;
709
+ options?: never;
710
+ head?: never;
711
+ patch?: never;
712
+ trace?: never;
713
+ };
714
+ "/account/{account_id}/triggers/history": {
715
+ parameters: {
716
+ query?: never;
717
+ header?: never;
718
+ path?: never;
719
+ cookie?: never;
720
+ };
721
+ get: {
722
+ parameters: {
723
+ query?: {
724
+ /** @description start with this timestamp (RFC3339); defaults to UNIX epoch start */
725
+ since?: string;
726
+ /** @description end with this timestamp (RFC3339); defaults to current date-time */
727
+ until?: string;
728
+ /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
729
+ startInclusive?: number | null;
730
+ /** @description Query returns up to 50 trades in one go. */
731
+ pageSize?: number | null;
732
+ };
733
+ header?: never;
734
+ path: {
735
+ account_id: number;
736
+ };
737
+ cookie?: never;
738
+ };
739
+ requestBody?: never;
740
+ responses: {
741
+ 200: {
742
+ headers: {
743
+ [name: string]: unknown;
744
+ };
745
+ content: {
746
+ "application/json": components["schemas"]["PageResult_for_uint64_and_HistoryTriggerInfo"];
747
+ };
748
+ };
749
+ };
750
+ };
751
+ put?: never;
752
+ post?: never;
753
+ delete?: never;
754
+ options?: never;
755
+ head?: never;
756
+ patch?: never;
757
+ trace?: never;
758
+ };
759
+ "/account/{account_id}/triggers": {
760
+ parameters: {
761
+ query?: never;
762
+ header?: never;
763
+ path?: never;
764
+ cookie?: never;
765
+ };
766
+ get: {
767
+ parameters: {
768
+ query?: never;
769
+ header?: never;
770
+ path: {
771
+ account_id: number;
772
+ };
773
+ cookie?: never;
774
+ };
775
+ requestBody?: never;
776
+ responses: {
777
+ 200: {
778
+ headers: {
779
+ [name: string]: unknown;
780
+ };
781
+ content: {
782
+ "application/json": components["schemas"]["TriggerInfo"][] | null;
783
+ };
784
+ };
785
+ };
786
+ };
787
+ put?: never;
788
+ post?: never;
789
+ delete?: never;
790
+ options?: never;
791
+ head?: never;
792
+ patch?: never;
793
+ trace?: never;
794
+ };
640
795
  "/account/{account_id}/pubkey": {
641
796
  parameters: {
642
797
  query?: never;
@@ -1753,6 +1908,9 @@ export interface components {
1753
1908
  /** Format: uint16 */
1754
1909
  weightBps: number;
1755
1910
  };
1911
+ AcceptedMediaType: {
1912
+ expected: string;
1913
+ };
1756
1914
  ActionsQuery: {
1757
1915
  /** Format: uint64 */
1758
1916
  from: number;
@@ -1762,8 +1920,7 @@ export interface components {
1762
1920
  ActionsItem: {
1763
1921
  /** Format: uint64 */
1764
1922
  actionId: number;
1765
- /** Format: int64 */
1766
- physicalTime: number;
1923
+ physicalTime: string;
1767
1924
  payload: string;
1768
1925
  };
1769
1926
  RangeTooLarge: {
@@ -2009,6 +2166,113 @@ export interface components {
2009
2166
  /** @description See `bankruptcy` in MARKETS.md. In general happens if account does not have enough weighted tokens to covert his debt and negative PnL. */
2010
2167
  bankruptcy: boolean;
2011
2168
  };
2169
+ AccountPnlQuery: {
2170
+ /**
2171
+ * @description start with this timestamp (RFC3339); defaults to UNIX epoch start
2172
+ * @default null
2173
+ */
2174
+ since: string;
2175
+ /**
2176
+ * @description end with this timestamp (RFC3339); defaults to current date-time
2177
+ * @default null
2178
+ */
2179
+ until: string;
2180
+ /**
2181
+ * Format: uint64
2182
+ * @description fetch results starting with this page; query starts with first entry if page isn't specified
2183
+ */
2184
+ startInclusive?: number | null;
2185
+ /**
2186
+ * Format: uint8
2187
+ * @description Query returns up to 50 trades in one go.
2188
+ * @default null
2189
+ */
2190
+ pageSize: number | null;
2191
+ };
2192
+ PageResult_for_uint64_and_AccountPnl: {
2193
+ /** @description Set of items for requested by query. */
2194
+ items: components["schemas"]["AccountPnl"][];
2195
+ /**
2196
+ * Format: uint64
2197
+ * @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.
2198
+ */
2199
+ nextStartInclusive?: number | null;
2200
+ };
2201
+ AccountPnl: {
2202
+ time: string;
2203
+ /** Format: uint64 */
2204
+ actionId: number;
2205
+ /** Format: uint32 */
2206
+ accountId: number;
2207
+ /** Format: double */
2208
+ pnl: number;
2209
+ };
2210
+ AccountTriggersQuery: {
2211
+ /**
2212
+ * @description start with this timestamp (RFC3339); defaults to UNIX epoch start
2213
+ * @default null
2214
+ */
2215
+ since: string;
2216
+ /**
2217
+ * @description end with this timestamp (RFC3339); defaults to current date-time
2218
+ * @default null
2219
+ */
2220
+ until: string;
2221
+ /**
2222
+ * Format: uint64
2223
+ * @description fetch results starting with this page; query starts with first entry if page isn't specified
2224
+ */
2225
+ startInclusive?: number | null;
2226
+ /**
2227
+ * Format: uint8
2228
+ * @description Query returns up to 50 trades in one go.
2229
+ * @default null
2230
+ */
2231
+ pageSize: number | null;
2232
+ };
2233
+ PageResult_for_uint64_and_HistoryTriggerInfo: {
2234
+ /** @description Set of items for requested by query. */
2235
+ items: components["schemas"]["HistoryTriggerInfo"][];
2236
+ /**
2237
+ * Format: uint64
2238
+ * @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.
2239
+ */
2240
+ nextStartInclusive?: number | null;
2241
+ };
2242
+ HistoryTriggerInfo: {
2243
+ /** Format: uint32 */
2244
+ accountId: number;
2245
+ /** Format: uint32 */
2246
+ marketId: number;
2247
+ /** Format: uint64 */
2248
+ price: number;
2249
+ side: components["schemas"]["Side"];
2250
+ kind: components["schemas"]["TriggerKind"];
2251
+ status: components["schemas"]["TriggerStatus"];
2252
+ /** Format: uint64 */
2253
+ createdAtActionId: number;
2254
+ /** Format: uint64 */
2255
+ finalizedAtActionId?: number | null;
2256
+ createdAt: string;
2257
+ finalizedAt: string;
2258
+ };
2259
+ /** @enum {string} */
2260
+ TriggerKind: "stopLoss" | "takeProfit";
2261
+ /** @enum {string} */
2262
+ TriggerStatus: "active" | "success" | "cancel" | "fail" | "remove";
2263
+ TriggerInfo: {
2264
+ /** Format: uint32 */
2265
+ marketId: number;
2266
+ side: components["schemas"]["Side"];
2267
+ kind: components["schemas"]["TriggerKind"];
2268
+ triggerPrice: components["schemas"]["PositivePriceMantissa"];
2269
+ limitPrice?: components["schemas"]["PositivePriceMantissa"] | null;
2270
+ };
2271
+ /**
2272
+ * Format: uint64
2273
+ * @description 63 bit integer, which is always positive
2274
+ */
2275
+ PositivePriceMantissa: number;
2012
2276
  OrderNotFound: null;
2013
2277
  PageResult_for_String_and_Trade: {
2014
2278
  /** @description Set of items for requested by query. */