@nadohq/otc-client 0.50.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 (59) hide show
  1. package/README.md +91 -0
  2. package/dist/OtcClient-qUPYb1BP.cjs +88 -0
  3. package/dist/OtcClient-qUPYb1BP.cjs.map +1 -0
  4. package/dist/OtcClient.cjs +3 -0
  5. package/dist/OtcClient.d.cts +44 -0
  6. package/dist/OtcClient.d.cts.map +1 -0
  7. package/dist/OtcClient.d.ts +44 -0
  8. package/dist/OtcClient.d.ts.map +1 -0
  9. package/dist/OtcClient.js +60 -0
  10. package/dist/OtcClient.js.map +1 -0
  11. package/dist/clientTypes-B7w3RxqK.d.cts +57 -0
  12. package/dist/clientTypes-B7w3RxqK.d.cts.map +1 -0
  13. package/dist/clientTypes-DVAoYtGx.d.ts +57 -0
  14. package/dist/clientTypes-DVAoYtGx.d.ts.map +1 -0
  15. package/dist/endpoints.cjs +24 -0
  16. package/dist/endpoints.cjs.map +1 -0
  17. package/dist/endpoints.d.cts +15 -0
  18. package/dist/endpoints.d.cts.map +1 -0
  19. package/dist/endpoints.d.ts +15 -0
  20. package/dist/endpoints.d.ts.map +1 -0
  21. package/dist/endpoints.js +22 -0
  22. package/dist/endpoints.js.map +1 -0
  23. package/dist/index.cjs +9 -0
  24. package/dist/index.d.cts +6 -0
  25. package/dist/index.d.ts +6 -0
  26. package/dist/index.js +5 -0
  27. package/dist/rfqSubscription.cjs +28 -0
  28. package/dist/rfqSubscription.cjs.map +1 -0
  29. package/dist/rfqSubscription.d.cts +14 -0
  30. package/dist/rfqSubscription.d.cts.map +1 -0
  31. package/dist/rfqSubscription.d.ts +14 -0
  32. package/dist/rfqSubscription.d.ts.map +1 -0
  33. package/dist/rfqSubscription.js +27 -0
  34. package/dist/rfqSubscription.js.map +1 -0
  35. package/dist/serverTypes-CZOJ78c_.d.cts +93 -0
  36. package/dist/serverTypes-CZOJ78c_.d.cts.map +1 -0
  37. package/dist/serverTypes-CZOJ78c_.d.ts +93 -0
  38. package/dist/serverTypes-CZOJ78c_.d.ts.map +1 -0
  39. package/dist/types/clientTypes.cjs +0 -0
  40. package/dist/types/clientTypes.d.cts +2 -0
  41. package/dist/types/clientTypes.d.ts +2 -0
  42. package/dist/types/clientTypes.js +1 -0
  43. package/dist/types/index.cjs +0 -0
  44. package/dist/types/index.d.cts +3 -0
  45. package/dist/types/index.d.ts +3 -0
  46. package/dist/types/index.js +1 -0
  47. package/dist/types/serverTypes.cjs +0 -0
  48. package/dist/types/serverTypes.d.cts +2 -0
  49. package/dist/types/serverTypes.d.ts +2 -0
  50. package/dist/types/serverTypes.js +1 -0
  51. package/package.json +52 -0
  52. package/src/OtcClient.ts +90 -0
  53. package/src/endpoints.ts +20 -0
  54. package/src/index.ts +4 -0
  55. package/src/rfqSubscription.test.ts +50 -0
  56. package/src/rfqSubscription.ts +36 -0
  57. package/src/types/clientTypes.ts +66 -0
  58. package/src/types/index.ts +2 -0
  59. package/src/types/serverTypes.ts +111 -0
@@ -0,0 +1,111 @@
1
+ export type OtcQuoteSizeUnit = 'base' | 'quote';
2
+
3
+ interface OtcServerExecutionDiagnostics {
4
+ failure_source?: string;
5
+ failure_stage?: string;
6
+ upstream_error_code?: number;
7
+ retryable?: boolean;
8
+ /**
9
+ * Documented values are `retry_same_request`, `sign_new_order`, `reconcile`, `wait`, and
10
+ * `none`. Anything else is returned as-is and does not authorize a resend.
11
+ */
12
+ recovery_action?: string;
13
+ retry_after_ms?: number;
14
+ }
15
+
16
+ export interface OtcServerExecutionSuccess {
17
+ status: 'success';
18
+ deal_id: string;
19
+ taker_digest: string;
20
+ settlement_id?: string;
21
+ }
22
+
23
+ export interface OtcServerExecutionFailure extends OtcServerExecutionDiagnostics {
24
+ status: 'failure';
25
+ error: string;
26
+ error_code: number;
27
+ deal_id?: string;
28
+ taker_digest?: string;
29
+ }
30
+
31
+ export interface OtcServerExecutionPendingResolution extends OtcServerExecutionDiagnostics {
32
+ status: 'pending_resolution';
33
+ deal_id: string;
34
+ taker_digest: string;
35
+ error?: string;
36
+ error_code?: number;
37
+ }
38
+
39
+ /** JSON body from `POST /v1/executor` and `POST /v1/executor/status`, including non-200 responses. */
40
+ export type OtcServerExecutionResponse =
41
+ | OtcServerExecutionSuccess
42
+ | OtcServerExecutionFailure
43
+ | OtcServerExecutionPendingResolution;
44
+
45
+ export interface OtcServerQuoteStream {
46
+ type: 'quote';
47
+ product_id: number;
48
+ wallet: string;
49
+ size: string;
50
+ size_unit: OtcQuoteSizeUnit;
51
+ pricer_id?: string;
52
+ }
53
+
54
+ export interface OtcServerRfqSubscribeStreamRequest {
55
+ method: 'subscribe';
56
+ id: number;
57
+ stream: OtcServerQuoteStream;
58
+ }
59
+
60
+ export interface OtcServerRfqSubscribeStreamsRequest {
61
+ method: 'subscribe';
62
+ id: number;
63
+ streams: OtcServerQuoteStream[];
64
+ }
65
+
66
+ export interface OtcServerRfqUnsubscribeStreamRequest {
67
+ method: 'unsubscribe';
68
+ id: number;
69
+ stream: OtcServerQuoteStream;
70
+ }
71
+
72
+ export interface OtcServerRfqUnsubscribeStreamsRequest {
73
+ method: 'unsubscribe';
74
+ id: number;
75
+ streams: OtcServerQuoteStream[];
76
+ }
77
+
78
+ export type OtcServerRfqSubscriptionRequest =
79
+ | OtcServerRfqSubscribeStreamRequest
80
+ | OtcServerRfqSubscribeStreamsRequest
81
+ | OtcServerRfqUnsubscribeStreamRequest
82
+ | OtcServerRfqUnsubscribeStreamsRequest;
83
+
84
+ /** One quote inside a `quote_batch`. `available` includes price fields; `unavailable` omits them. */
85
+ export interface OtcServerQuote {
86
+ product_id: number;
87
+ type: 'quote';
88
+ size_unit: OtcQuoteSizeUnit;
89
+ size: string;
90
+ wallet: string;
91
+ pricer_id: string;
92
+ status: string;
93
+ price_x18?: string;
94
+ valid_until_ms?: string;
95
+ base_size?: string;
96
+ }
97
+
98
+ export interface OtcServerQuoteBatch {
99
+ type: 'quote_batch';
100
+ time: string;
101
+ quotes: OtcServerQuote[];
102
+ }
103
+
104
+ export interface OtcServerRfqAck {
105
+ result: null;
106
+ id: number;
107
+ /** Set when the server rejected the request. Absent on success. */
108
+ error?: string;
109
+ }
110
+
111
+ export type OtcServerRfqMessage = OtcServerRfqAck | OtcServerQuoteBatch;