@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
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # `@nadohq/otc-client`
2
+
3
+ HTTP client for the Nado OTC service. Submits an already-signed fill-or-kill taker order,
4
+ reads that execution back, and builds quote subscriptions. No bearer token and no wallet client.
5
+
6
+ The caller opens the quote WebSocket. A quote can prefill a form; `execute` does not
7
+ require one.
8
+
9
+ [Full SDK Documentation](https://nadohq.github.io/nado-typescript-sdk/index.html)
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { OtcClient, OTC_CLIENT_ENDPOINTS } from '@nadohq/otc-client';
15
+
16
+ const otc = new OtcClient({ url: OTC_CLIENT_ENDPOINTS.inkMainnet });
17
+
18
+ const result = await otc.execute({
19
+ dealId: crypto.randomUUID(),
20
+ taker,
21
+ });
22
+
23
+ if (result.deal_id && result.taker_digest) {
24
+ const status = await otc.getExecutionStatus({
25
+ dealId: result.deal_id,
26
+ takerDigest: result.taker_digest,
27
+ });
28
+ }
29
+ ```
30
+
31
+ A `failure` from admission has no digest, so there is nothing to poll. Poll an in-progress
32
+ failure once it includes `taker_digest`.
33
+
34
+ It is also available on a `NadoClient` context.
35
+
36
+ ```ts
37
+ const result = await nadoClient.context.otcClient.execute({ dealId, taker });
38
+ ```
39
+
40
+ ## Quotes
41
+
42
+ `subscribe` and `unsubscribe` are the only RFQ methods. Pass one `stream`, or `streams` for
43
+ several. `unsubscribe` repeats the same stream fields. `wallet` is a 20-byte address.
44
+ Socket messages use the server types directly.
45
+
46
+ ```ts
47
+ import {
48
+ buildOtcRfqSubscriptionMessage,
49
+ OTC_RFQ_WS_CLIENT_ENDPOINTS,
50
+ OtcServerRfqMessage,
51
+ } from '@nadohq/otc-client';
52
+
53
+ const ws = new WebSocket(OTC_RFQ_WS_CLIENT_ENDPOINTS.inkMainnet);
54
+
55
+ ws.onopen = () => {
56
+ ws.send(
57
+ JSON.stringify(
58
+ buildOtcRfqSubscriptionMessage('subscribe', {
59
+ id: 1,
60
+ stream: {
61
+ type: 'quote',
62
+ productId: 2,
63
+ wallet,
64
+ size: '-1000000000000000000',
65
+ sizeUnit: 'base',
66
+ },
67
+ }),
68
+ ),
69
+ );
70
+ };
71
+
72
+ ws.onmessage = (event) => {
73
+ const message = JSON.parse(String(event.data)) as OtcServerRfqMessage;
74
+ if ('type' in message && message.type === 'quote_batch') {
75
+ for (const quote of message.quotes) {
76
+ if (quote.status === 'available' && quote.price_x18) {
77
+ // quote.price_x18, quote.valid_until_ms, quote.base_size
78
+ }
79
+ }
80
+ }
81
+ };
82
+ ```
83
+
84
+ An ack has `result: null` and sets `error` when the server rejected that request. A
85
+ `quote_batch` follows a successful subscribe. `status: 'available'` carries `price_x18`,
86
+ `valid_until_ms`, and `base_size`. `status: 'unavailable'` does not.
87
+
88
+ `execute` and `getExecutionStatus` return the JSON body for success, failure, and
89
+ `pending_resolution`, including non-200 admission responses. Branch on `status` and
90
+ `recovery_action`, not the HTTP code. `getReady` reports whether a route's quote and deal
91
+ coverage overlap.
@@ -0,0 +1,88 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let _nadohq_shared = require("@nadohq/shared");
24
+ let axios = require("axios");
25
+ axios = __toESM(axios, 1);
26
+ //#region src/OtcClient.ts
27
+ /**
28
+ * Client for the public OTC service.
29
+ *
30
+ * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
31
+ * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
32
+ * start or resume one.
33
+ *
34
+ * Responses are the JSON body as returned, including non-200 admission responses. Branch on
35
+ * `status` and `recovery_action`.
36
+ */
37
+ var OtcClient = class {
38
+ constructor(opts) {
39
+ this.opts = opts;
40
+ this.axiosInstance = axios.default.create({
41
+ withCredentials: false,
42
+ validateStatus: () => true,
43
+ headers: (0, _nadohq_shared.getNadoClientTypeHeaders)(opts.clientType)
44
+ });
45
+ }
46
+ /**
47
+ * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
48
+ */
49
+ async execute(params) {
50
+ return this.postExecution("/v1/executor", {
51
+ deal_id: params.dealId,
52
+ taker: params.taker,
53
+ ...params.pricerId ? { pricer_id: params.pricerId } : {}
54
+ });
55
+ }
56
+ /**
57
+ * Reads one execution. Use it after a lost response, a refresh, or `wait`.
58
+ */
59
+ async getExecutionStatus(params) {
60
+ return this.postExecution("/v1/executor/status", {
61
+ deal_id: params.dealId,
62
+ taker_digest: params.takerDigest
63
+ });
64
+ }
65
+ /**
66
+ * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`
67
+ * asks the service default. A direct execution needs a matching deal worker, not a prior quote.
68
+ */
69
+ async getReady(params = {}) {
70
+ const response = await this.axiosInstance.get(`${this.opts.url}/ready`, { params: params.pricerId ? { pricer_id: params.pricerId } : void 0 });
71
+ return {
72
+ httpStatus: response.status,
73
+ ready: response.status === 200
74
+ };
75
+ }
76
+ async postExecution(path, body) {
77
+ return (await this.axiosInstance.post(`${this.opts.url}${path}`, body)).data;
78
+ }
79
+ };
80
+ //#endregion
81
+ Object.defineProperty(exports, "OtcClient", {
82
+ enumerable: true,
83
+ get: function() {
84
+ return OtcClient;
85
+ }
86
+ });
87
+
88
+ //# sourceMappingURL=OtcClient-qUPYb1BP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtcClient-qUPYb1BP.cjs","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import { getNadoClientTypeHeaders } from '@nadohq/shared';\nimport axios, { AxiosInstance } from 'axios';\nimport {\n OtcExecuteParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcReadyResult,\n} from './types/clientTypes';\nimport { OtcServerExecutionResponse } from './types/serverTypes';\n\nexport interface OtcClientOpts {\n /**\n * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.\n */\n url: string;\n // If provided, identifies the calling client, sent as a header with every request\n clientType?: string;\n}\n\n/**\n * Client for the public OTC service.\n *\n * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.\n * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not\n * start or resume one.\n *\n * Responses are the JSON body as returned, including non-200 admission responses. Branch on\n * `status` and `recovery_action`.\n */\nexport class OtcClient {\n readonly opts: OtcClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: OtcClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: false,\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Submits a signed taker order. Send this body unchanged on `retry_same_request`.\n */\n async execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor', {\n deal_id: params.dealId,\n taker: params.taker,\n ...(params.pricerId ? { pricer_id: params.pricerId } : {}),\n });\n }\n\n /**\n * Reads one execution. Use it after a lost response, a refresh, or `wait`.\n */\n async getExecutionStatus(\n params: OtcGetExecutionStatusParams,\n ): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor/status', {\n deal_id: params.dealId,\n taker_digest: params.takerDigest,\n });\n }\n\n /**\n * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`\n * asks the service default. A direct execution needs a matching deal worker, not a prior quote.\n */\n async getReady(params: OtcGetReadyParams = {}): Promise<OtcReadyResult> {\n const response = await this.axiosInstance.get(`${this.opts.url}/ready`, {\n params: params.pricerId ? { pricer_id: params.pricerId } : undefined,\n });\n return {\n httpStatus: response.status,\n ready: response.status === 200,\n };\n }\n\n private async postExecution(\n path: string,\n body: unknown,\n ): Promise<OtcServerExecutionResponse> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n );\n return response.data as OtcServerExecutionResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,YAAb,MAAuB;CAIrB,YAAY,MAAqB;EAC/B,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GACjB,sBAAsB;GACtB,UAAA,GAAA,eAAA,0BAAkC,KAAK,UAAU;EACnD,CAAC;CACH;;;;CAKA,MAAM,QAAQ,QAA+D;EAC3E,OAAO,KAAK,cAAc,gBAAgB;GACxC,SAAS,OAAO;GAChB,OAAO,OAAO;GACd,GAAI,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,CAAC;EAC1D,CAAC;CACH;;;;CAKA,MAAM,mBACJ,QACqC;EACrC,OAAO,KAAK,cAAc,uBAAuB;GAC/C,SAAS,OAAO;GAChB,cAAc,OAAO;EACvB,CAAC;CACH;;;;;CAMA,MAAM,SAAS,SAA4B,CAAC,GAA4B;EACtE,MAAM,WAAW,MAAM,KAAK,cAAc,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,EACtE,QAAQ,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,KAAA,EAC7D,CAAC;EACD,OAAO;GACL,YAAY,SAAS;GACrB,OAAO,SAAS,WAAW;EAC7B;CACF;CAEA,MAAc,cACZ,MACA,MACqC;EAKrC,QAAO,MAJgB,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,IACF,GACgB;CAClB;AACF"}
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_OtcClient = require("./OtcClient-qUPYb1BP.cjs");
3
+ exports.OtcClient = require_OtcClient.OtcClient;
@@ -0,0 +1,44 @@
1
+ import { i as OtcServerExecutionResponse } from "./serverTypes-CZOJ78c_.cjs";
2
+ import { a as OtcReadyResult, n as OtcGetExecutionStatusParams, r as OtcGetReadyParams, t as OtcExecuteParams } from "./clientTypes-B7w3RxqK.cjs";
3
+ import { AxiosInstance } from "axios";
4
+
5
+ //#region src/OtcClient.d.ts
6
+ interface OtcClientOpts {
7
+ /**
8
+ * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.
9
+ */
10
+ url: string;
11
+ clientType?: string;
12
+ }
13
+ /**
14
+ * Client for the public OTC service.
15
+ *
16
+ * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
17
+ * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
18
+ * start or resume one.
19
+ *
20
+ * Responses are the JSON body as returned, including non-200 admission responses. Branch on
21
+ * `status` and `recovery_action`.
22
+ */
23
+ declare class OtcClient {
24
+ readonly opts: OtcClientOpts;
25
+ readonly axiosInstance: AxiosInstance;
26
+ constructor(opts: OtcClientOpts);
27
+ /**
28
+ * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
29
+ */
30
+ execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse>;
31
+ /**
32
+ * Reads one execution. Use it after a lost response, a refresh, or `wait`.
33
+ */
34
+ getExecutionStatus(params: OtcGetExecutionStatusParams): Promise<OtcServerExecutionResponse>;
35
+ /**
36
+ * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`
37
+ * asks the service default. A direct execution needs a matching deal worker, not a prior quote.
38
+ */
39
+ getReady(params?: OtcGetReadyParams): Promise<OtcReadyResult>;
40
+ private postExecution;
41
+ }
42
+ //#endregion
43
+ export { OtcClient, OtcClientOpts };
44
+ //# sourceMappingURL=OtcClient.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtcClient.d.cts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;UAUiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,UAAU;AAAA;AAaZ;;;;;;;;;;AAAA,cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAoC8B;;;EAxB1C,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAflC;;;EA0BT,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAzBO;;;;EAoCZ,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAAA,QAU1C,aAAA;AAAA"}
@@ -0,0 +1,44 @@
1
+ import { i as OtcServerExecutionResponse } from "./serverTypes-CZOJ78c_.js";
2
+ import { a as OtcReadyResult, n as OtcGetExecutionStatusParams, r as OtcGetReadyParams, t as OtcExecuteParams } from "./clientTypes-DVAoYtGx.js";
3
+ import { AxiosInstance } from "axios";
4
+
5
+ //#region src/OtcClient.d.ts
6
+ interface OtcClientOpts {
7
+ /**
8
+ * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.
9
+ */
10
+ url: string;
11
+ clientType?: string;
12
+ }
13
+ /**
14
+ * Client for the public OTC service.
15
+ *
16
+ * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
17
+ * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
18
+ * start or resume one.
19
+ *
20
+ * Responses are the JSON body as returned, including non-200 admission responses. Branch on
21
+ * `status` and `recovery_action`.
22
+ */
23
+ declare class OtcClient {
24
+ readonly opts: OtcClientOpts;
25
+ readonly axiosInstance: AxiosInstance;
26
+ constructor(opts: OtcClientOpts);
27
+ /**
28
+ * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
29
+ */
30
+ execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse>;
31
+ /**
32
+ * Reads one execution. Use it after a lost response, a refresh, or `wait`.
33
+ */
34
+ getExecutionStatus(params: OtcGetExecutionStatusParams): Promise<OtcServerExecutionResponse>;
35
+ /**
36
+ * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`
37
+ * asks the service default. A direct execution needs a matching deal worker, not a prior quote.
38
+ */
39
+ getReady(params?: OtcGetReadyParams): Promise<OtcReadyResult>;
40
+ private postExecution;
41
+ }
42
+ //#endregion
43
+ export { OtcClient, OtcClientOpts };
44
+ //# sourceMappingURL=OtcClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtcClient.d.ts","names":[],"sources":["../src/src/OtcClient.ts"],"mappings":";;;;;UAUiB,aAAA;;AAAjB;;EAIE,GAAA;EAEA,UAAU;AAAA;AAaZ;;;;;;;;;;AAAA,cAAa,SAAA;EAAA,SACF,IAAA,EAAM,aAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,aAAA;EAoC8B;;;EAxB1C,OAAA,CAAQ,MAAA,EAAQ,gBAAA,GAAmB,OAAA,CAAQ,0BAAA;EAflC;;;EA0BT,kBAAA,CACJ,MAAA,EAAQ,2BAAA,GACP,OAAA,CAAQ,0BAAA;EAzBO;;;;EAoCZ,QAAA,CAAS,MAAA,GAAQ,iBAAA,GAAyB,OAAA,CAAQ,cAAA;EAAA,QAU1C,aAAA;AAAA"}
@@ -0,0 +1,60 @@
1
+ import { getNadoClientTypeHeaders } from "@nadohq/shared";
2
+ import axios from "axios";
3
+ //#region src/OtcClient.ts
4
+ /**
5
+ * Client for the public OTC service.
6
+ *
7
+ * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.
8
+ * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not
9
+ * start or resume one.
10
+ *
11
+ * Responses are the JSON body as returned, including non-200 admission responses. Branch on
12
+ * `status` and `recovery_action`.
13
+ */
14
+ var OtcClient = class {
15
+ constructor(opts) {
16
+ this.opts = opts;
17
+ this.axiosInstance = axios.create({
18
+ withCredentials: false,
19
+ validateStatus: () => true,
20
+ headers: getNadoClientTypeHeaders(opts.clientType)
21
+ });
22
+ }
23
+ /**
24
+ * Submits a signed taker order. Send this body unchanged on `retry_same_request`.
25
+ */
26
+ async execute(params) {
27
+ return this.postExecution("/v1/executor", {
28
+ deal_id: params.dealId,
29
+ taker: params.taker,
30
+ ...params.pricerId ? { pricer_id: params.pricerId } : {}
31
+ });
32
+ }
33
+ /**
34
+ * Reads one execution. Use it after a lost response, a refresh, or `wait`.
35
+ */
36
+ async getExecutionStatus(params) {
37
+ return this.postExecution("/v1/executor/status", {
38
+ deal_id: params.dealId,
39
+ taker_digest: params.takerDigest
40
+ });
41
+ }
42
+ /**
43
+ * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`
44
+ * asks the service default. A direct execution needs a matching deal worker, not a prior quote.
45
+ */
46
+ async getReady(params = {}) {
47
+ const response = await this.axiosInstance.get(`${this.opts.url}/ready`, { params: params.pricerId ? { pricer_id: params.pricerId } : void 0 });
48
+ return {
49
+ httpStatus: response.status,
50
+ ready: response.status === 200
51
+ };
52
+ }
53
+ async postExecution(path, body) {
54
+ return (await this.axiosInstance.post(`${this.opts.url}${path}`, body)).data;
55
+ }
56
+ };
57
+ //#endregion
58
+ export { OtcClient };
59
+
60
+ //# sourceMappingURL=OtcClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtcClient.js","names":[],"sources":["../src/OtcClient.ts"],"sourcesContent":["import { getNadoClientTypeHeaders } from '@nadohq/shared';\nimport axios, { AxiosInstance } from 'axios';\nimport {\n OtcExecuteParams,\n OtcGetExecutionStatusParams,\n OtcGetReadyParams,\n OtcReadyResult,\n} from './types/clientTypes';\nimport { OtcServerExecutionResponse } from './types/serverTypes';\n\nexport interface OtcClientOpts {\n /**\n * OTC service origin, without a path, e.g. {@link OTC_CLIENT_ENDPOINTS}.\n */\n url: string;\n // If provided, identifies the calling client, sent as a header with every request\n clientType?: string;\n}\n\n/**\n * Client for the public OTC service.\n *\n * {@link OtcClient.execute} does not sign. The caller supplies an already-signed taker order.\n * A quote is not required. {@link OtcClient.getExecutionStatus} only reads a deal; it does not\n * start or resume one.\n *\n * Responses are the JSON body as returned, including non-200 admission responses. Branch on\n * `status` and `recovery_action`.\n */\nexport class OtcClient {\n readonly opts: OtcClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: OtcClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: false,\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Submits a signed taker order. Send this body unchanged on `retry_same_request`.\n */\n async execute(params: OtcExecuteParams): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor', {\n deal_id: params.dealId,\n taker: params.taker,\n ...(params.pricerId ? { pricer_id: params.pricerId } : {}),\n });\n }\n\n /**\n * Reads one execution. Use it after a lost response, a refresh, or `wait`.\n */\n async getExecutionStatus(\n params: OtcGetExecutionStatusParams,\n ): Promise<OtcServerExecutionResponse> {\n return this.postExecution('/v1/executor/status', {\n deal_id: params.dealId,\n taker_digest: params.takerDigest,\n });\n }\n\n /**\n * Checks that quote and deal product scopes overlap for a route. An omitted `pricerId`\n * asks the service default. A direct execution needs a matching deal worker, not a prior quote.\n */\n async getReady(params: OtcGetReadyParams = {}): Promise<OtcReadyResult> {\n const response = await this.axiosInstance.get(`${this.opts.url}/ready`, {\n params: params.pricerId ? { pricer_id: params.pricerId } : undefined,\n });\n return {\n httpStatus: response.status,\n ready: response.status === 200,\n };\n }\n\n private async postExecution(\n path: string,\n body: unknown,\n ): Promise<OtcServerExecutionResponse> {\n const response = await this.axiosInstance.post(\n `${this.opts.url}${path}`,\n body,\n );\n return response.data as OtcServerExecutionResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,IAAa,YAAb,MAAuB;CAIrB,YAAY,MAAqB;EAC/B,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GACjB,sBAAsB;GACtB,SAAS,yBAAyB,KAAK,UAAU;EACnD,CAAC;CACH;;;;CAKA,MAAM,QAAQ,QAA+D;EAC3E,OAAO,KAAK,cAAc,gBAAgB;GACxC,SAAS,OAAO;GAChB,OAAO,OAAO;GACd,GAAI,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,CAAC;EAC1D,CAAC;CACH;;;;CAKA,MAAM,mBACJ,QACqC;EACrC,OAAO,KAAK,cAAc,uBAAuB;GAC/C,SAAS,OAAO;GAChB,cAAc,OAAO;EACvB,CAAC;CACH;;;;;CAMA,MAAM,SAAS,SAA4B,CAAC,GAA4B;EACtE,MAAM,WAAW,MAAM,KAAK,cAAc,IAAI,GAAG,KAAK,KAAK,IAAI,SAAS,EACtE,QAAQ,OAAO,WAAW,EAAE,WAAW,OAAO,SAAS,IAAI,KAAA,EAC7D,CAAC;EACD,OAAO;GACL,YAAY,SAAS;GACrB,OAAO,SAAS,WAAW;EAC7B;CACF;CAEA,MAAc,cACZ,MACA,MACqC;EAKrC,QAAO,MAJgB,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,MAAM,QACnB,IACF,GACgB;CAClB;AACF"}
@@ -0,0 +1,57 @@
1
+ import { t as OtcQuoteSizeUnit } from "./serverTypes-CZOJ78c_.cjs";
2
+ import { EngineServerPlaceOrderParams } from "@nadohq/engine-client";
3
+
4
+ //#region src/types/clientTypes.d.ts
5
+ /**
6
+ * Signed Nado order the OTC service settles. An engine `place_order` payload without
7
+ * `id`, `spot_leverage`, and `borrow_margin`.
8
+ */
9
+ type OtcServerTakerOrderParams = Omit<EngineServerPlaceOrderParams, 'id' | 'spot_leverage' | 'borrow_margin'>;
10
+ interface OtcExecuteParams {
11
+ /** Client-generated idempotency key, 1–128 bytes. Kept across retries of this intent. */
12
+ dealId: string;
13
+ taker: OtcServerTakerOrderParams;
14
+ /** Execution route. Omitted selects the service default (`awr`). */
15
+ pricerId?: string;
16
+ }
17
+ interface OtcGetExecutionStatusParams {
18
+ dealId: string;
19
+ takerDigest: string;
20
+ }
21
+ interface OtcGetReadyParams {
22
+ pricerId?: string;
23
+ }
24
+ /**
25
+ * Route coverage. HTTP 200 is ready; 400 and 503 are not. This does not guarantee liquidity
26
+ * or that an order will be accepted.
27
+ */
28
+ interface OtcReadyResult {
29
+ httpStatus: number;
30
+ ready: boolean;
31
+ }
32
+ /**
33
+ * One quote subscription. `wallet` is a 20-byte address, not a 32-byte subaccount.
34
+ * `size` is a non-zero signed x18 integer string.
35
+ */
36
+ interface OtcQuoteStream {
37
+ type: 'quote';
38
+ productId: number;
39
+ wallet: string;
40
+ size: string;
41
+ sizeUnit: OtcQuoteSizeUnit;
42
+ /** Execution route. Omitted selects the service default (`awr`). */
43
+ pricerId?: string;
44
+ }
45
+ interface OtcRfqSubscriptionStreamParams {
46
+ id: number;
47
+ stream: OtcQuoteStream;
48
+ }
49
+ interface OtcRfqSubscriptionStreamsParams {
50
+ id: number;
51
+ streams: OtcQuoteStream[];
52
+ }
53
+ /** Subscribe or unsubscribe target. Pass one stream, or several. */
54
+ type OtcRfqSubscriptionParams = OtcRfqSubscriptionStreamParams | OtcRfqSubscriptionStreamsParams;
55
+ //#endregion
56
+ export { OtcReadyResult as a, OtcRfqSubscriptionStreamsParams as c, OtcQuoteStream as i, OtcServerTakerOrderParams as l, OtcGetExecutionStatusParams as n, OtcRfqSubscriptionParams as o, OtcGetReadyParams as r, OtcRfqSubscriptionStreamParams as s, OtcExecuteParams as t };
57
+ //# sourceMappingURL=clientTypes-B7w3RxqK.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientTypes-B7w3RxqK.d.cts","names":[],"sources":["../src/types/src/types/clientTypes.ts"],"mappings":";;;;;;AAOA;;KAAY,yBAAA,GAA4B,IAAI,CAC1C,4BAAA;AAAA,UAIe,gBAAA;EAJa;EAM5B,MAAA;EACA,KAAA,EAAO,yBAAyB;;EAEhC,QAAA;AAAA;AAAA,UAGe,2BAAA;EACf,MAAA;EACA,WAAW;AAAA;AAAA,UAGI,iBAAA;EACf,QAAQ;AAAA;;;AAJG;AAGb;UAQiB,cAAA;EACf,UAAA;EACA,KAAK;AAAA;AAFP;;;;AAAA,UASiB,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EAH1B;EAKA,QAAA;AAAA;AAAA,UAGe,8BAAA;EACf,EAAA;EACA,MAAA,EAAQ,cAAc;AAAA;AAAA,UAGP,+BAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA;;KAIb,wBAAA,GACR,8BAAA,GACA,+BAA+B"}
@@ -0,0 +1,57 @@
1
+ import { t as OtcQuoteSizeUnit } from "./serverTypes-CZOJ78c_.js";
2
+ import { EngineServerPlaceOrderParams } from "@nadohq/engine-client";
3
+
4
+ //#region src/types/clientTypes.d.ts
5
+ /**
6
+ * Signed Nado order the OTC service settles. An engine `place_order` payload without
7
+ * `id`, `spot_leverage`, and `borrow_margin`.
8
+ */
9
+ type OtcServerTakerOrderParams = Omit<EngineServerPlaceOrderParams, 'id' | 'spot_leverage' | 'borrow_margin'>;
10
+ interface OtcExecuteParams {
11
+ /** Client-generated idempotency key, 1–128 bytes. Kept across retries of this intent. */
12
+ dealId: string;
13
+ taker: OtcServerTakerOrderParams;
14
+ /** Execution route. Omitted selects the service default (`awr`). */
15
+ pricerId?: string;
16
+ }
17
+ interface OtcGetExecutionStatusParams {
18
+ dealId: string;
19
+ takerDigest: string;
20
+ }
21
+ interface OtcGetReadyParams {
22
+ pricerId?: string;
23
+ }
24
+ /**
25
+ * Route coverage. HTTP 200 is ready; 400 and 503 are not. This does not guarantee liquidity
26
+ * or that an order will be accepted.
27
+ */
28
+ interface OtcReadyResult {
29
+ httpStatus: number;
30
+ ready: boolean;
31
+ }
32
+ /**
33
+ * One quote subscription. `wallet` is a 20-byte address, not a 32-byte subaccount.
34
+ * `size` is a non-zero signed x18 integer string.
35
+ */
36
+ interface OtcQuoteStream {
37
+ type: 'quote';
38
+ productId: number;
39
+ wallet: string;
40
+ size: string;
41
+ sizeUnit: OtcQuoteSizeUnit;
42
+ /** Execution route. Omitted selects the service default (`awr`). */
43
+ pricerId?: string;
44
+ }
45
+ interface OtcRfqSubscriptionStreamParams {
46
+ id: number;
47
+ stream: OtcQuoteStream;
48
+ }
49
+ interface OtcRfqSubscriptionStreamsParams {
50
+ id: number;
51
+ streams: OtcQuoteStream[];
52
+ }
53
+ /** Subscribe or unsubscribe target. Pass one stream, or several. */
54
+ type OtcRfqSubscriptionParams = OtcRfqSubscriptionStreamParams | OtcRfqSubscriptionStreamsParams;
55
+ //#endregion
56
+ export { OtcReadyResult as a, OtcRfqSubscriptionStreamsParams as c, OtcQuoteStream as i, OtcServerTakerOrderParams as l, OtcGetExecutionStatusParams as n, OtcRfqSubscriptionParams as o, OtcGetReadyParams as r, OtcRfqSubscriptionStreamParams as s, OtcExecuteParams as t };
57
+ //# sourceMappingURL=clientTypes-DVAoYtGx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientTypes-DVAoYtGx.d.ts","names":[],"sources":["../src/types/src/types/clientTypes.ts"],"mappings":";;;;;;AAOA;;KAAY,yBAAA,GAA4B,IAAI,CAC1C,4BAAA;AAAA,UAIe,gBAAA;EAJa;EAM5B,MAAA;EACA,KAAA,EAAO,yBAAyB;;EAEhC,QAAA;AAAA;AAAA,UAGe,2BAAA;EACf,MAAA;EACA,WAAW;AAAA;AAAA,UAGI,iBAAA;EACf,QAAQ;AAAA;;;AAJG;AAGb;UAQiB,cAAA;EACf,UAAA;EACA,KAAK;AAAA;AAFP;;;;AAAA,UASiB,cAAA;EACf,IAAA;EACA,SAAA;EACA,MAAA;EACA,IAAA;EACA,QAAA,EAAU,gBAAgB;EAH1B;EAKA,QAAA;AAAA;AAAA,UAGe,8BAAA;EACf,EAAA;EACA,MAAA,EAAQ,cAAc;AAAA;AAAA,UAGP,+BAAA;EACf,EAAA;EACA,OAAA,EAAS,cAAc;AAAA;;KAIb,wBAAA,GACR,8BAAA,GACA,+BAA+B"}
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/endpoints.ts
3
+ /**
4
+ * OTC service origin per chain env. `local` uses the testnet service; there is no localhost
5
+ * deployment.
6
+ */
7
+ const OTC_CLIENT_ENDPOINTS = {
8
+ local: "https://otc.test.nado-backend.xyz",
9
+ inkTestnet: "https://otc.test.nado-backend.xyz",
10
+ inkMainnet: "https://otc.prod.nado-backend.xyz"
11
+ };
12
+ /**
13
+ * Taker quote socket per chain env. The caller opens it.
14
+ */
15
+ const OTC_RFQ_WS_CLIENT_ENDPOINTS = {
16
+ local: "wss://otc.test.nado-backend.xyz/v1/rfqs/ws",
17
+ inkTestnet: "wss://otc.test.nado-backend.xyz/v1/rfqs/ws",
18
+ inkMainnet: "wss://otc.prod.nado-backend.xyz/v1/rfqs/ws"
19
+ };
20
+ //#endregion
21
+ exports.OTC_CLIENT_ENDPOINTS = OTC_CLIENT_ENDPOINTS;
22
+ exports.OTC_RFQ_WS_CLIENT_ENDPOINTS = OTC_RFQ_WS_CLIENT_ENDPOINTS;
23
+
24
+ //# sourceMappingURL=endpoints.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.cjs","names":[],"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\n/**\n * OTC service origin per chain env. `local` uses the testnet service; there is no localhost\n * deployment.\n */\nexport const OTC_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'https://otc.test.nado-backend.xyz',\n inkTestnet: 'https://otc.test.nado-backend.xyz',\n inkMainnet: 'https://otc.prod.nado-backend.xyz',\n};\n\n/**\n * Taker quote socket per chain env. The caller opens it.\n */\nexport const OTC_RFQ_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'wss://otc.test.nado-backend.xyz/v1/rfqs/ws',\n inkTestnet: 'wss://otc.test.nado-backend.xyz/v1/rfqs/ws',\n inkMainnet: 'wss://otc.prod.nado-backend.xyz/v1/rfqs/ws',\n};\n"],"mappings":";;;;;;AAMA,MAAa,uBAAiD;CAC5D,OAAO;CACP,YAAY;CACZ,YAAY;AACd;;;;AAKA,MAAa,8BAAwD;CACnE,OAAO;CACP,YAAY;CACZ,YAAY;AACd"}
@@ -0,0 +1,15 @@
1
+ import { ChainEnv } from "@nadohq/shared";
2
+
3
+ //#region src/endpoints.d.ts
4
+ /**
5
+ * OTC service origin per chain env. `local` uses the testnet service; there is no localhost
6
+ * deployment.
7
+ */
8
+ declare const OTC_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
9
+ /**
10
+ * Taker quote socket per chain env. The caller opens it.
11
+ */
12
+ declare const OTC_RFQ_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
13
+ //#endregion
14
+ export { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS };
15
+ //# sourceMappingURL=endpoints.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.cts","names":[],"sources":["../src/src/endpoints.ts"],"mappings":";;;;;AAMA;;cAAa,oBAAA,EAAsB,MAAM,CAAC,QAAA;;AAAQ;AASlD;cAAa,2BAAA,EAA6B,MAAM,CAAC,QAAA"}
@@ -0,0 +1,15 @@
1
+ import { ChainEnv } from "@nadohq/shared";
2
+
3
+ //#region src/endpoints.d.ts
4
+ /**
5
+ * OTC service origin per chain env. `local` uses the testnet service; there is no localhost
6
+ * deployment.
7
+ */
8
+ declare const OTC_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
9
+ /**
10
+ * Taker quote socket per chain env. The caller opens it.
11
+ */
12
+ declare const OTC_RFQ_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
13
+ //#endregion
14
+ export { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS };
15
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","names":[],"sources":["../src/src/endpoints.ts"],"mappings":";;;;;AAMA;;cAAa,oBAAA,EAAsB,MAAM,CAAC,QAAA;;AAAQ;AASlD;cAAa,2BAAA,EAA6B,MAAM,CAAC,QAAA"}
@@ -0,0 +1,22 @@
1
+ //#region src/endpoints.ts
2
+ /**
3
+ * OTC service origin per chain env. `local` uses the testnet service; there is no localhost
4
+ * deployment.
5
+ */
6
+ const OTC_CLIENT_ENDPOINTS = {
7
+ local: "https://otc.test.nado-backend.xyz",
8
+ inkTestnet: "https://otc.test.nado-backend.xyz",
9
+ inkMainnet: "https://otc.prod.nado-backend.xyz"
10
+ };
11
+ /**
12
+ * Taker quote socket per chain env. The caller opens it.
13
+ */
14
+ const OTC_RFQ_WS_CLIENT_ENDPOINTS = {
15
+ local: "wss://otc.test.nado-backend.xyz/v1/rfqs/ws",
16
+ inkTestnet: "wss://otc.test.nado-backend.xyz/v1/rfqs/ws",
17
+ inkMainnet: "wss://otc.prod.nado-backend.xyz/v1/rfqs/ws"
18
+ };
19
+ //#endregion
20
+ export { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS };
21
+
22
+ //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.js","names":[],"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\n/**\n * OTC service origin per chain env. `local` uses the testnet service; there is no localhost\n * deployment.\n */\nexport const OTC_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'https://otc.test.nado-backend.xyz',\n inkTestnet: 'https://otc.test.nado-backend.xyz',\n inkMainnet: 'https://otc.prod.nado-backend.xyz',\n};\n\n/**\n * Taker quote socket per chain env. The caller opens it.\n */\nexport const OTC_RFQ_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'wss://otc.test.nado-backend.xyz/v1/rfqs/ws',\n inkTestnet: 'wss://otc.test.nado-backend.xyz/v1/rfqs/ws',\n inkMainnet: 'wss://otc.prod.nado-backend.xyz/v1/rfqs/ws',\n};\n"],"mappings":";;;;;AAMA,MAAa,uBAAiD;CAC5D,OAAO;CACP,YAAY;CACZ,YAAY;AACd;;;;AAKA,MAAa,8BAAwD;CACnE,OAAO;CACP,YAAY;CACZ,YAAY;AACd"}
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_OtcClient = require("./OtcClient-qUPYb1BP.cjs");
3
+ const require_endpoints = require("./endpoints.cjs");
4
+ const require_rfqSubscription = require("./rfqSubscription.cjs");
5
+ require("./types/index.cjs");
6
+ exports.OTC_CLIENT_ENDPOINTS = require_endpoints.OTC_CLIENT_ENDPOINTS;
7
+ exports.OTC_RFQ_WS_CLIENT_ENDPOINTS = require_endpoints.OTC_RFQ_WS_CLIENT_ENDPOINTS;
8
+ exports.OtcClient = require_OtcClient.OtcClient;
9
+ exports.buildOtcRfqSubscriptionMessage = require_rfqSubscription.buildOtcRfqSubscriptionMessage;
@@ -0,0 +1,6 @@
1
+ import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamRequest, f as OtcServerRfqSubscribeStreamsRequest, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, m as OtcServerRfqUnsubscribeStreamRequest, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqSubscriptionRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "./serverTypes-CZOJ78c_.cjs";
2
+ import { a as OtcReadyResult, c as OtcRfqSubscriptionStreamsParams, i as OtcQuoteStream, l as OtcServerTakerOrderParams, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcRfqSubscriptionStreamParams, t as OtcExecuteParams } from "./clientTypes-B7w3RxqK.cjs";
3
+ import { OtcClient, OtcClientOpts } from "./OtcClient.cjs";
4
+ import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.cjs";
5
+ import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.cjs";
6
+ export { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS, OtcClient, OtcClientOpts, OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcRfqSubscriptionStreamParams, OtcRfqSubscriptionStreamsParams, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamRequest, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, buildOtcRfqSubscriptionMessage };
@@ -0,0 +1,6 @@
1
+ import { a as OtcServerExecutionSuccess, c as OtcServerQuoteStream, d as OtcServerRfqSubscribeStreamRequest, f as OtcServerRfqSubscribeStreamsRequest, h as OtcServerRfqUnsubscribeStreamsRequest, i as OtcServerExecutionResponse, l as OtcServerRfqAck, m as OtcServerRfqUnsubscribeStreamRequest, n as OtcServerExecutionFailure, o as OtcServerQuote, p as OtcServerRfqSubscriptionRequest, r as OtcServerExecutionPendingResolution, s as OtcServerQuoteBatch, t as OtcQuoteSizeUnit, u as OtcServerRfqMessage } from "./serverTypes-CZOJ78c_.js";
2
+ import { a as OtcReadyResult, c as OtcRfqSubscriptionStreamsParams, i as OtcQuoteStream, l as OtcServerTakerOrderParams, n as OtcGetExecutionStatusParams, o as OtcRfqSubscriptionParams, r as OtcGetReadyParams, s as OtcRfqSubscriptionStreamParams, t as OtcExecuteParams } from "./clientTypes-DVAoYtGx.js";
3
+ import { OtcClient, OtcClientOpts } from "./OtcClient.js";
4
+ import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.js";
5
+ import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.js";
6
+ export { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS, OtcClient, OtcClientOpts, OtcExecuteParams, OtcGetExecutionStatusParams, OtcGetReadyParams, OtcQuoteSizeUnit, OtcQuoteStream, OtcReadyResult, OtcRfqSubscriptionParams, OtcRfqSubscriptionStreamParams, OtcRfqSubscriptionStreamsParams, OtcServerExecutionFailure, OtcServerExecutionPendingResolution, OtcServerExecutionResponse, OtcServerExecutionSuccess, OtcServerQuote, OtcServerQuoteBatch, OtcServerQuoteStream, OtcServerRfqAck, OtcServerRfqMessage, OtcServerRfqSubscribeStreamRequest, OtcServerRfqSubscribeStreamsRequest, OtcServerRfqSubscriptionRequest, OtcServerRfqUnsubscribeStreamRequest, OtcServerRfqUnsubscribeStreamsRequest, OtcServerTakerOrderParams, buildOtcRfqSubscriptionMessage };
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { OtcClient } from "./OtcClient.js";
2
+ import { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS } from "./endpoints.js";
3
+ import { buildOtcRfqSubscriptionMessage } from "./rfqSubscription.js";
4
+ import "./types/index.js";
5
+ export { OTC_CLIENT_ENDPOINTS, OTC_RFQ_WS_CLIENT_ENDPOINTS, OtcClient, buildOtcRfqSubscriptionMessage };
@@ -0,0 +1,28 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/rfqSubscription.ts
3
+ function toServerStream(stream) {
4
+ return {
5
+ type: "quote",
6
+ product_id: stream.productId,
7
+ wallet: stream.wallet,
8
+ size: stream.size,
9
+ size_unit: stream.sizeUnit,
10
+ ...stream.pricerId ? { pricer_id: stream.pricerId } : {}
11
+ };
12
+ }
13
+ /**
14
+ * Builds a subscribe or unsubscribe message for the RFQ socket.
15
+ * `unsubscribe` uses the same stream fields as the original `subscribe`.
16
+ */
17
+ function buildOtcRfqSubscriptionMessage(method, params) {
18
+ const body = "stream" in params ? { stream: toServerStream(params.stream) } : { streams: params.streams.map(toServerStream) };
19
+ return {
20
+ method,
21
+ id: params.id,
22
+ ...body
23
+ };
24
+ }
25
+ //#endregion
26
+ exports.buildOtcRfqSubscriptionMessage = buildOtcRfqSubscriptionMessage;
27
+
28
+ //# sourceMappingURL=rfqSubscription.cjs.map