@n1xyz/nord-ts 0.1.12 → 0.3.1

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.
@@ -707,7 +707,7 @@ export interface paths {
707
707
  /** @description end with this timestamp (RFC3339); defaults to current date-time */
708
708
  until?: string;
709
709
  /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
710
- startInclusive?: number | null;
710
+ startInclusive?: string | null;
711
711
  /** @description Query returns up to 50 trades in one go. */
712
712
  pageSize?: number | null;
713
713
  };
@@ -725,7 +725,49 @@ export interface paths {
725
725
  [name: string]: unknown;
726
726
  };
727
727
  content: {
728
- "application/json": components["schemas"]["PageResult_for_uint64_and_AccountPnl"];
728
+ "application/json": components["schemas"]["PageResult_for_String_and_AccountPnlInfo"];
729
+ };
730
+ };
731
+ };
732
+ };
733
+ put?: never;
734
+ post?: never;
735
+ delete?: never;
736
+ options?: never;
737
+ head?: never;
738
+ patch?: never;
739
+ trace?: never;
740
+ };
741
+ "/account/{account_id}/pnl/funding/history/PT1H": {
742
+ parameters: {
743
+ query?: never;
744
+ header?: never;
745
+ path?: never;
746
+ cookie?: never;
747
+ };
748
+ /** @description 11:00 - funding rate captured 11:30 - position 10 funding 0.01 12:00 - capture 12:20 - position zeroed
749
+ *
750
+ * will return - used payed funding for 11:00-12.00, using last position before 12:00 capture using funding index formed at 11:30 and market funding index formed at 12:00 - 12:00 - 13:00 PnL will not be returned at all.
751
+ *
752
+ * For exact applied PnL use more per trade PnL. */
753
+ get: {
754
+ parameters: {
755
+ query?: never;
756
+ header?: never;
757
+ path: {
758
+ /** @description Account for which to retrieve PnL history */
759
+ account_id: number;
760
+ };
761
+ cookie?: never;
762
+ };
763
+ requestBody?: never;
764
+ responses: {
765
+ 200: {
766
+ headers: {
767
+ [name: string]: unknown;
768
+ };
769
+ content: {
770
+ "application/json": components["schemas"]["AccountPnlHistInfo"][];
729
771
  };
730
772
  };
731
773
  };
@@ -753,7 +795,7 @@ export interface paths {
753
795
  /** @description end with this timestamp (RFC3339); defaults to current date-time */
754
796
  until?: string;
755
797
  /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
756
- startInclusive?: number | null;
798
+ startInclusive?: string | null;
757
799
  /** @description Query returns up to 50 trades in one go. */
758
800
  pageSize?: number | null;
759
801
  };
@@ -770,7 +812,7 @@ export interface paths {
770
812
  [name: string]: unknown;
771
813
  };
772
814
  content: {
773
- "application/json": components["schemas"]["PageResult_for_uint64_and_Trigger"];
815
+ "application/json": components["schemas"]["PageResult_for_String_and_Trigger"];
774
816
  };
775
817
  };
776
818
  };
@@ -806,7 +848,7 @@ export interface paths {
806
848
  [name: string]: unknown;
807
849
  };
808
850
  content: {
809
- "application/json": components["schemas"]["AccountTriggerInfo"][] | null;
851
+ "application/json": components["schemas"]["TriggerInfo"][] | null;
810
852
  };
811
853
  };
812
854
  };
@@ -1383,7 +1425,7 @@ export interface paths {
1383
1425
  /** @description end with this timestamp (RFC3339); defaults to current date-time */
1384
1426
  until?: string;
1385
1427
  /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
1386
- startInclusive?: number | null;
1428
+ startInclusive?: string | null;
1387
1429
  /** @description Query returns up to 50 trades in one go. */
1388
1430
  pageSize?: number | null;
1389
1431
  };
@@ -1401,7 +1443,7 @@ export interface paths {
1401
1443
  [name: string]: unknown;
1402
1444
  };
1403
1445
  content: {
1404
- "application/json": components["schemas"]["PageResult_for_uint64_and_Withdrawal"];
1446
+ "application/json": components["schemas"]["PageResult_for_String_and_Withdrawal"];
1405
1447
  };
1406
1448
  };
1407
1449
  404: {
@@ -1458,6 +1500,43 @@ export interface paths {
1458
1500
  patch?: never;
1459
1501
  trace?: never;
1460
1502
  };
1503
+ "/market/{market_id}/history/PT1H": {
1504
+ parameters: {
1505
+ query?: never;
1506
+ header?: never;
1507
+ path?: never;
1508
+ cookie?: never;
1509
+ };
1510
+ /** @description Gets market updates history for some period of time. Default is hourly for last 24 hours */
1511
+ get: {
1512
+ parameters: {
1513
+ query?: never;
1514
+ header?: never;
1515
+ path: {
1516
+ market_id: number;
1517
+ };
1518
+ cookie?: never;
1519
+ };
1520
+ requestBody?: never;
1521
+ responses: {
1522
+ 200: {
1523
+ headers: {
1524
+ [name: string]: unknown;
1525
+ };
1526
+ content: {
1527
+ "application/json": components["schemas"]["PageResult_for_String_and_MarketHistoryInfo"];
1528
+ };
1529
+ };
1530
+ };
1531
+ };
1532
+ put?: never;
1533
+ post?: never;
1534
+ delete?: never;
1535
+ options?: never;
1536
+ head?: never;
1537
+ patch?: never;
1538
+ trace?: never;
1539
+ };
1461
1540
  }
1462
1541
  export type webhooks = Record<string, never>;
1463
1542
  export interface components {
@@ -2427,7 +2506,9 @@ export interface components {
2427
2506
  indexPriceConf: number;
2428
2507
  frozen?: boolean;
2429
2508
  /** Format: double */
2430
- volume24h: number;
2509
+ volumeBase24h: number;
2510
+ /** Format: double */
2511
+ volumeQuote24h: number;
2431
2512
  /** Format: double */
2432
2513
  high24h: number;
2433
2514
  /** Format: double */
@@ -2508,8 +2589,7 @@ export interface components {
2508
2589
  placedSize: number;
2509
2590
  /** Format: double */
2510
2591
  filledSize?: number | null;
2511
- /** Format: uint64 */
2512
- updateActionId: number;
2592
+ updateActionId: string;
2513
2593
  isReduceOnly: boolean;
2514
2594
  fillMode: components["schemas"]["FillMode"];
2515
2595
  /** Format: double */
@@ -2644,11 +2724,8 @@ export interface components {
2644
2724
  * @default null
2645
2725
  */
2646
2726
  until: string;
2647
- /**
2648
- * Format: uint64
2649
- * @description fetch results starting with this page; query starts with first entry if page isn't specified
2650
- */
2651
- startInclusive?: number | null;
2727
+ /** @description fetch results starting with this page; query starts with first entry if page isn't specified */
2728
+ startInclusive?: string | null;
2652
2729
  /**
2653
2730
  * Format: uint8
2654
2731
  * @description Query returns up to 50 trades in one go.
@@ -2656,32 +2733,64 @@ export interface components {
2656
2733
  */
2657
2734
  pageSize: number | null;
2658
2735
  };
2659
- PageResult_for_uint64_and_AccountPnl: {
2736
+ PageResult_for_String_and_AccountPnlInfo: {
2660
2737
  /** @description Set of items for requested by query. */
2661
- items: components["schemas"]["AccountPnl"][];
2662
- /**
2663
- * Format: uint64
2664
- * @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.
2665
- */
2666
- nextStartInclusive?: number | null;
2738
+ items: components["schemas"]["AccountPnlInfo"][];
2739
+ /** @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. */
2740
+ nextStartInclusive?: string | null;
2667
2741
  };
2668
- AccountPnl: {
2742
+ AccountPnlInfo: {
2669
2743
  time: string;
2670
- /** Format: uint64 */
2671
- actionId: number;
2744
+ actionId: string;
2672
2745
  /** Format: uint32 */
2673
2746
  accountId: number;
2674
2747
  /** Format: double */
2748
+ pricePnlDelta: number;
2749
+ /** Format: double */
2750
+ fundingPnlDelta: number;
2751
+ /**
2752
+ * Format: double
2753
+ * @description Total PnL update
2754
+ */
2675
2755
  pnl: number;
2676
2756
  };
2677
- PageResult_for_uint64_and_Trigger: {
2678
- /** @description Set of items for requested by query. */
2679
- items: components["schemas"]["Trigger"][];
2757
+ AccountPnlHistInfo: {
2758
+ /** @description Same time when funding is applied */
2759
+ time: string;
2680
2760
  /**
2681
- * Format: uint64
2682
- * @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.
2761
+ * Format: double
2762
+ * @description Funding rate used to calculate this funding payment
2683
2763
  */
2684
- nextStartInclusive?: number | null;
2764
+ fundingRate: number;
2765
+ /**
2766
+ * Format: double
2767
+ * @description Size used to calculated funding payment
2768
+ */
2769
+ fundingSize?: number | null;
2770
+ /** @description Side on time of funding application. */
2771
+ side?: components["schemas"]["Side"] | null;
2772
+ /**
2773
+ * Format: double
2774
+ * @description Result of `user_funding_index - market_Funding_index`.
2775
+ */
2776
+ fundingIndexChange?: number | null;
2777
+ /**
2778
+ * Format: double
2779
+ * @description Funding pnl for this funding period, i.e. funding_size * funding_index_change. Negate for the funding paid by the account for this period.
2780
+ */
2781
+ fundingPnl: number;
2782
+ market: components["schemas"]["MarketIdInfo"];
2783
+ };
2784
+ MarketIdInfo: {
2785
+ /** Format: uint32 */
2786
+ market_id: number;
2787
+ market_symbol: string;
2788
+ };
2789
+ PageResult_for_String_and_Trigger: {
2790
+ /** @description Set of items for requested by query. */
2791
+ items: components["schemas"]["Trigger"][];
2792
+ /** @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. */
2793
+ nextStartInclusive?: string | null;
2685
2794
  };
2686
2795
  Trigger: {
2687
2796
  /** Format: uint32 */
@@ -2693,10 +2802,8 @@ export interface components {
2693
2802
  side: components["schemas"]["Side"];
2694
2803
  kind: components["schemas"]["TriggerKind"];
2695
2804
  status: components["schemas"]["TriggerStatus"];
2696
- /** Format: uint64 */
2697
- createdAtActionId: number;
2698
- /** Format: uint64 */
2699
- finalizedAtActionId?: number | null;
2805
+ createdAtActionId: string;
2806
+ finalizedAtActionId?: string | null;
2700
2807
  createdAt: string;
2701
2808
  finalizedAt: string;
2702
2809
  };
@@ -2709,22 +2816,20 @@ export interface components {
2709
2816
  TriggerKind: "stopLoss" | "takeProfit";
2710
2817
  /** @enum {string} */
2711
2818
  TriggerStatus: "Active" | "Success" | "Removed" | "Canceled";
2712
- /** @description Trigger into per account. */
2713
- AccountTriggerInfo: {
2819
+ TriggerInfo: {
2820
+ /** Format: uint32 */
2821
+ accountId: number;
2714
2822
  /** Format: uint32 */
2715
2823
  marketId: number;
2716
- key: components["schemas"]["TriggerKey"];
2717
- triggerPrices: components["schemas"]["TriggerPrice"];
2718
- /** Format: uint64 */
2719
- actionId: number;
2720
- };
2721
- TriggerKey: {
2824
+ /** Format: int64 */
2825
+ triggerPrice: number;
2826
+ /** Format: int64 */
2827
+ limitPrice?: number | null;
2722
2828
  side: components["schemas"]["Side"];
2723
2829
  kind: components["schemas"]["TriggerKind"];
2724
- };
2725
- TriggerPrice: {
2726
- trigger: components["schemas"]["PositivePriceMantissa"];
2727
- settlement?: components["schemas"]["PositivePriceMantissa"] | null;
2830
+ /** @description created_at_action_id */
2831
+ actionId: string;
2832
+ createdAt: string;
2728
2833
  };
2729
2834
  OrderNotFound: null;
2730
2835
  PageResult_for_String_and_Trade: {
@@ -2787,13 +2892,17 @@ export interface components {
2787
2892
  */
2788
2893
  pageSize: number | null;
2789
2894
  };
2790
- DownloadFilter: components["schemas"]["Op_for_DataDateTime"] | components["schemas"]["Op_for_uint64"] | components["schemas"]["Op_for_uint64"] | null;
2895
+ DownloadFilter: components["schemas"]["Op_for_DataDateTime"] | components["schemas"]["Op_for_String"] | components["schemas"]["Op_for_uint64"] | null;
2791
2896
  /** @description Parses tag (anycase), and value in round braces using `from_str`. */
2792
2897
  Op_for_DataDateTime: {
2793
2898
  le: components["schemas"]["DataDateTime"];
2794
2899
  };
2795
2900
  DataDateTime: string;
2796
2901
  /** @description Parses tag (anycase), and value in round braces using `from_str`. */
2902
+ Op_for_String: {
2903
+ le: string;
2904
+ };
2905
+ /** @description Parses tag (anycase), and value in round braces using `from_str`. */
2797
2906
  Op_for_uint64: {
2798
2907
  /** Format: uint64 */
2799
2908
  le: number;
@@ -2884,7 +2993,9 @@ export interface components {
2884
2993
  /** Format: uint32 */
2885
2994
  marketId: number;
2886
2995
  /** Format: double */
2887
- volume: number;
2996
+ volumeBase: number;
2997
+ /** Format: double */
2998
+ volumeQuote: number;
2888
2999
  };
2889
3000
  GetPrevMarketPriceQuery: {
2890
3001
  atOrBefore: string;
@@ -2895,19 +3006,15 @@ export interface components {
2895
3006
  /** Format: double */
2896
3007
  price?: number | null;
2897
3008
  };
2898
- PageResult_for_uint64_and_Withdrawal: {
3009
+ PageResult_for_String_and_Withdrawal: {
2899
3010
  /** @description Set of items for requested by query. */
2900
3011
  items: components["schemas"]["Withdrawal"][];
2901
- /**
2902
- * Format: uint64
2903
- * @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.
2904
- */
2905
- nextStartInclusive?: number | null;
3012
+ /** @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. */
3013
+ nextStartInclusive?: string | null;
2906
3014
  };
2907
3015
  Withdrawal: {
2908
3016
  time: string;
2909
- /** Format: uint64 */
2910
- actionId: number;
3017
+ actionId: string;
2911
3018
  /** Format: uint32 */
2912
3019
  accountId: number;
2913
3020
  /** Format: uint32 */
@@ -3083,6 +3190,26 @@ export interface components {
3083
3190
  };
3084
3191
  /** @description Empty object, to make quotes item conform to API error spec */
3085
3192
  TvQuotesErrorValues: Record<string, never>;
3193
+ PageResult_for_String_and_MarketHistoryInfo: {
3194
+ /** @description Set of items for requested by query. */
3195
+ items: components["schemas"]["MarketHistoryInfo"][];
3196
+ /** @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. */
3197
+ nextStartInclusive?: string | null;
3198
+ };
3199
+ MarketHistoryInfo: {
3200
+ /** Format: uint32 */
3201
+ marketId: number;
3202
+ time: string;
3203
+ actionId: string;
3204
+ fundingIndex: components["schemas"]["FundingIndexMantissa"];
3205
+ /** Format: double */
3206
+ fundingRate: number;
3207
+ };
3208
+ /**
3209
+ * Format: int128
3210
+ * @description Consist of some sum of `SignedBasisPoints` weighted by `PriceMantissa`(with market decimals). Funding rate jitters around 0, so really hard to get big numbers. Is `basic points numerator * market price mantissa` unit.
3211
+ */
3212
+ FundingIndexMantissa: number;
3086
3213
  };
3087
3214
  responses: never;
3088
3215
  parameters: never;
@@ -0,0 +1,128 @@
1
+ import Decimal from "decimal.js";
2
+ import * as proto from "../../gen/nord_pb";
3
+ import { paths } from "../../gen/openapi";
4
+ import { Client } from "openapi-fetch";
5
+ import { FillMode, Side, QuoteSize, TriggerKind } from "../../types";
6
+ import { BigIntValue } from "../../utils";
7
+ type ReceiptKind = NonNullable<proto.Receipt["kind"]>;
8
+ type ExtractReceiptKind<K extends ReceiptKind["case"]> = Extract<ReceiptKind, {
9
+ case: K;
10
+ }>;
11
+ export declare function formatReceiptError(receipt: proto.Receipt): string;
12
+ export declare function expectReceiptKind<K extends ReceiptKind["case"]>(receipt: proto.Receipt, expected: K, action: string): asserts receipt is proto.Receipt & {
13
+ kind: ExtractReceiptKind<K>;
14
+ };
15
+ export declare function createAction(currentTimestamp: bigint, nonce: number, kind: proto.Action["kind"]): proto.Action;
16
+ export declare function sendAction(serverUrl: string, makeSignedMessage: (message: Uint8Array) => Promise<Uint8Array>, action: proto.Action, client?: Client<paths>): Promise<proto.Receipt>;
17
+ export declare function prepareAction(action: proto.Action, makeSignedMessage: (message: Uint8Array) => Promise<Uint8Array>): Promise<Uint8Array<ArrayBufferLike>>;
18
+ export declare function createSession(serverUrl: string, walletSignFn: (x: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
19
+ userPubkey: Uint8Array;
20
+ sessionPubkey: Uint8Array;
21
+ expiryTimestamp?: bigint;
22
+ }, client?: Client<paths>): Promise<{
23
+ actionId: bigint;
24
+ sessionId: bigint;
25
+ }>;
26
+ export declare function revokeSession(serverUrl: string, walletSignFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
27
+ sessionId: BigIntValue;
28
+ }, client?: Client<paths>): Promise<{
29
+ actionId: bigint;
30
+ }>;
31
+ export declare function withdraw(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
32
+ sizeDecimals: number;
33
+ sessionId: BigIntValue;
34
+ tokenId: number;
35
+ amount: Decimal.Value;
36
+ }): Promise<{
37
+ actionId: bigint;
38
+ } & proto.Receipt_WithdrawResult>;
39
+ export declare function placeOrder(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
40
+ sessionId: BigIntValue;
41
+ senderId?: number;
42
+ sizeDecimals: number;
43
+ priceDecimals: number;
44
+ marketId: number;
45
+ side: Side;
46
+ fillMode: FillMode;
47
+ isReduceOnly: boolean;
48
+ size?: Decimal.Value;
49
+ price?: Decimal.Value;
50
+ quoteSize?: QuoteSize;
51
+ liquidateeId?: number;
52
+ clientOrderId?: BigIntValue;
53
+ }): Promise<{
54
+ actionId: bigint;
55
+ orderId?: bigint;
56
+ fills: proto.Receipt_Trade[];
57
+ }>;
58
+ export declare function cancelOrder(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
59
+ sessionId: BigIntValue;
60
+ senderId?: number;
61
+ orderId: BigIntValue;
62
+ liquidateeId?: number;
63
+ }): Promise<{
64
+ actionId: bigint;
65
+ orderId: bigint;
66
+ accountId: number;
67
+ }>;
68
+ export declare function transfer(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
69
+ sessionId: BigIntValue;
70
+ fromAccountId: number;
71
+ toAccountId?: number;
72
+ tokenId: number;
73
+ tokenDecimals: number;
74
+ amount: Decimal.Value;
75
+ }): Promise<{
76
+ actionId: bigint;
77
+ fromAccountId: number;
78
+ toAccountId?: number;
79
+ tokenId: number;
80
+ amount: bigint;
81
+ accountCreated: boolean;
82
+ }>;
83
+ export declare function addTrigger(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
84
+ sessionId: BigIntValue;
85
+ marketId: number;
86
+ side: Side;
87
+ kind: TriggerKind;
88
+ priceDecimals: number;
89
+ triggerPrice: Decimal.Value;
90
+ limitPrice?: Decimal.Value;
91
+ accountId?: number;
92
+ }): Promise<{
93
+ actionId: bigint;
94
+ }>;
95
+ export declare function removeTrigger(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
96
+ sessionId: BigIntValue;
97
+ marketId: number;
98
+ side: Side;
99
+ kind: TriggerKind;
100
+ accountId?: number;
101
+ }): Promise<{
102
+ actionId: bigint;
103
+ }>;
104
+ export type AtomicSubaction = {
105
+ kind: "place";
106
+ marketId: number;
107
+ side: Side;
108
+ fillMode: FillMode;
109
+ isReduceOnly: boolean;
110
+ sizeDecimals: number;
111
+ priceDecimals: number;
112
+ size?: Decimal.Value;
113
+ price?: Decimal.Value;
114
+ quoteSize?: QuoteSize;
115
+ clientOrderId?: BigIntValue;
116
+ } | {
117
+ kind: "cancel";
118
+ orderId: BigIntValue;
119
+ };
120
+ export declare function atomic(serverUrl: string, signFn: (message: Uint8Array) => Promise<Uint8Array>, currentTimestamp: bigint, nonce: number, params: {
121
+ sessionId: BigIntValue;
122
+ accountId?: number;
123
+ actions: AtomicSubaction[];
124
+ }, client?: Client<paths>): Promise<{
125
+ actionId: bigint;
126
+ results: proto.Receipt_AtomicSubactionResultKind[];
127
+ }>;
128
+ export {};