@kuestcom/clob-client 5.8.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.
Files changed (87) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +101 -0
  3. package/dist/client.d.ts +164 -0
  4. package/dist/client.js +967 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/config.d.ts +12 -0
  7. package/dist/config.js +28 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/constants.d.ts +3 -0
  10. package/dist/constants.js +7 -0
  11. package/dist/constants.js.map +1 -0
  12. package/dist/endpoints.d.ts +67 -0
  13. package/dist/endpoints.js +82 -0
  14. package/dist/endpoints.js.map +1 -0
  15. package/dist/errors.d.ts +10 -0
  16. package/dist/errors.js +16 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/headers/index.d.ts +6 -0
  19. package/dist/headers/index.js +42 -0
  20. package/dist/headers/index.js.map +1 -0
  21. package/dist/http-helpers/index.d.ts +21 -0
  22. package/dist/http-helpers/index.js +151 -0
  23. package/dist/http-helpers/index.js.map +1 -0
  24. package/dist/index.d.ts +11 -0
  25. package/dist/index.js +10 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/order-builder/builder.d.ts +29 -0
  28. package/dist/order-builder/builder.js +52 -0
  29. package/dist/order-builder/builder.js.map +1 -0
  30. package/dist/order-builder/helpers.d.ts +50 -0
  31. package/dist/order-builder/helpers.js +276 -0
  32. package/dist/order-builder/helpers.js.map +1 -0
  33. package/dist/order-builder/index.d.ts +1 -0
  34. package/dist/order-builder/index.js +2 -0
  35. package/dist/order-builder/index.js.map +1 -0
  36. package/dist/order-utils/exchange.order.builder.d.ts +31 -0
  37. package/dist/order-utils/exchange.order.builder.js +120 -0
  38. package/dist/order-utils/exchange.order.builder.js.map +1 -0
  39. package/dist/order-utils/exchange.order.const.d.ts +13 -0
  40. package/dist/order-utils/exchange.order.const.js +28 -0
  41. package/dist/order-utils/exchange.order.const.js.map +1 -0
  42. package/dist/order-utils/index.d.ts +6 -0
  43. package/dist/order-utils/index.js +7 -0
  44. package/dist/order-utils/index.js.map +1 -0
  45. package/dist/order-utils/model/eip712.model.d.ts +25 -0
  46. package/dist/order-utils/model/eip712.model.js +2 -0
  47. package/dist/order-utils/model/eip712.model.js.map +1 -0
  48. package/dist/order-utils/model/order-side.model.d.ts +4 -0
  49. package/dist/order-utils/model/order-side.model.js +6 -0
  50. package/dist/order-utils/model/order-side.model.js.map +1 -0
  51. package/dist/order-utils/model/order.model.d.ts +112 -0
  52. package/dist/order-utils/model/order.model.js +2 -0
  53. package/dist/order-utils/model/order.model.js.map +1 -0
  54. package/dist/order-utils/model/signature-types.model.d.ts +14 -0
  55. package/dist/order-utils/model/signature-types.model.js +16 -0
  56. package/dist/order-utils/model/signature-types.model.js.map +1 -0
  57. package/dist/order-utils/utils.d.ts +1 -0
  58. package/dist/order-utils/utils.js +4 -0
  59. package/dist/order-utils/utils.js.map +1 -0
  60. package/dist/rfq-client.d.ts +64 -0
  61. package/dist/rfq-client.js +403 -0
  62. package/dist/rfq-client.js.map +1 -0
  63. package/dist/rfq-deps.d.ts +44 -0
  64. package/dist/rfq-deps.js +2 -0
  65. package/dist/rfq-deps.js.map +1 -0
  66. package/dist/signer.d.ts +22 -0
  67. package/dist/signer.js +50 -0
  68. package/dist/signer.js.map +1 -0
  69. package/dist/signing/constants.d.ts +14 -0
  70. package/dist/signing/constants.js +16 -0
  71. package/dist/signing/constants.js.map +1 -0
  72. package/dist/signing/eip712.d.ts +9 -0
  73. package/dist/signing/eip712.js +40 -0
  74. package/dist/signing/eip712.js.map +1 -0
  75. package/dist/signing/hmac.d.ts +9 -0
  76. package/dist/signing/hmac.js +58 -0
  77. package/dist/signing/hmac.js.map +1 -0
  78. package/dist/signing/index.d.ts +2 -0
  79. package/dist/signing/index.js +3 -0
  80. package/dist/signing/index.js.map +1 -0
  81. package/dist/types.d.ts +667 -0
  82. package/dist/types.js +37 -0
  83. package/dist/types.js.map +1 -0
  84. package/dist/utilities.d.ts +16 -0
  85. package/dist/utilities.js +93 -0
  86. package/dist/utilities.js.map +1 -0
  87. package/package.json +85 -0
@@ -0,0 +1,7 @@
1
+ export * from "./exchange.order.builder.js";
2
+ export * from "./exchange.order.const.js";
3
+ export * from "./model/eip712.model.js";
4
+ export * from "./model/order.model.js";
5
+ export * from "./model/order-side.model.js";
6
+ export * from "./model/signature-types.model.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/order-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAE1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,25 @@
1
+ export interface EIP712TypedData {
2
+ types: EIP712Types;
3
+ domain: EIP712Object;
4
+ message: EIP712Object;
5
+ primaryType: string;
6
+ }
7
+ export interface EIP712Types {
8
+ [key: string]: EIP712Parameter[];
9
+ }
10
+ export interface EIP712Parameter {
11
+ name: string;
12
+ type: string;
13
+ }
14
+ export type EIP712ObjectValue = string | number | EIP712Object;
15
+ export interface EIP712Object {
16
+ [key: string]: EIP712ObjectValue;
17
+ }
18
+ export interface MessageTypes {
19
+ [additionalProperties: string]: MessageTypeProperty[];
20
+ EIP712Domain: MessageTypeProperty[];
21
+ }
22
+ export interface MessageTypeProperty {
23
+ name: string;
24
+ type: string;
25
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=eip712.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip712.model.js","sourceRoot":"","sources":["../../../src/order-utils/model/eip712.model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export declare enum Side {
2
+ BUY = 0,
3
+ SELL = 1
4
+ }
@@ -0,0 +1,6 @@
1
+ export var Side;
2
+ (function (Side) {
3
+ Side[Side["BUY"] = 0] = "BUY";
4
+ Side[Side["SELL"] = 1] = "SELL";
5
+ })(Side || (Side = {}));
6
+ //# sourceMappingURL=order-side.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-side.model.js","sourceRoot":"","sources":["../../../src/order-utils/model/order-side.model.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,IAIX;AAJD,WAAY,IAAI;IACZ,6BAAO,CAAA;IAEP,+BAAQ,CAAA;AACZ,CAAC,EAJW,IAAI,KAAJ,IAAI,QAIf"}
@@ -0,0 +1,112 @@
1
+ import type { EIP712Object } from "./eip712.model.ts";
2
+ import type { Side } from "./order-side.model.ts";
3
+ import type { SignatureType } from "./signature-types.model.ts";
4
+ export type OrderSignature = string;
5
+ export type OrderHash = string;
6
+ export interface OrderData {
7
+ /**
8
+ * Maker of the order, i.e the source of funds for the order
9
+ */
10
+ maker: string;
11
+ /**
12
+ * Address of the order taker. The zero address is used to indicate a public order
13
+ */
14
+ taker: string;
15
+ /**
16
+ * Token Id of the CTF ERC1155 asset to be bought or sold.
17
+ * If BUY, this is the tokenId of the asset to be bought, i.e the makerAssetId
18
+ * If SELL, this is the tokenId of the asset to be sold, i.e the takerAssetId
19
+ */
20
+ tokenId: string;
21
+ /**
22
+ * Maker amount, i.e the max amount of tokens to be sold
23
+ */
24
+ makerAmount: string;
25
+ /**
26
+ * Taker amount, i.e the minimum amount of tokens to be received
27
+ */
28
+ takerAmount: string;
29
+ /**
30
+ * The side of the order, BUY or SELL
31
+ */
32
+ side: Side;
33
+ /**
34
+ * Fee rate, in basis points, charged to the order maker, charged on proceeds
35
+ */
36
+ feeRateBps: string;
37
+ /**
38
+ * Nonce used for onchain cancellations
39
+ */
40
+ nonce: string;
41
+ /**
42
+ * Signer of the order. Optional, if it is not present the signer is the maker of the order.
43
+ */
44
+ signer?: string;
45
+ /**
46
+ * Timestamp after which the order is expired.
47
+ * Optional, if it is not present the value is "0" (no expiration)
48
+ */
49
+ expiration?: string;
50
+ /**
51
+ * Signature type used by the Order. Default value "EOA"
52
+ */
53
+ signatureType?: SignatureType;
54
+ }
55
+ export interface Order extends EIP712Object {
56
+ /**
57
+ * Unique salt to ensure entropy
58
+ */
59
+ readonly salt: string;
60
+ /**
61
+ * Maker of the order, i.e the source of funds for the order
62
+ */
63
+ readonly maker: string;
64
+ /**
65
+ * Signer of the order
66
+ */
67
+ readonly signer: string;
68
+ /**
69
+ * Address of the order taker. The zero address is used to indicate a public order
70
+ */
71
+ readonly taker: string;
72
+ /**
73
+ * Token Id of the CTF ERC1155 asset to be bought or sold.
74
+ * If BUY, this is the tokenId of the asset to be bought, i.e the makerAssetId
75
+ * If SELL, this is the tokenId of the asset to be sold, i.e the takerAssetId
76
+ */
77
+ readonly tokenId: string;
78
+ /**
79
+ * Maker amount, i.e the max amount of tokens to be sold
80
+ */
81
+ readonly makerAmount: string;
82
+ /**
83
+ * Taker amount, i.e the minimum amount of tokens to be received
84
+ */
85
+ readonly takerAmount: string;
86
+ /**
87
+ * Timestamp after which the order is expired
88
+ */
89
+ readonly expiration: string;
90
+ /**
91
+ * Nonce used for onchain cancellations
92
+ */
93
+ readonly nonce: string;
94
+ /**
95
+ * Fee rate, in basis points, charged to the order maker, charged on proceeds
96
+ */
97
+ readonly feeRateBps: string;
98
+ /**
99
+ * The side of the order, BUY or SELL
100
+ */
101
+ readonly side: Side;
102
+ /**
103
+ * Signature type used by the Order
104
+ */
105
+ readonly signatureType: SignatureType;
106
+ }
107
+ export interface SignedOrder extends Order {
108
+ /**
109
+ * The order signature
110
+ */
111
+ readonly signature: OrderSignature;
112
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=order.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order.model.js","sourceRoot":"","sources":["../../../src/order-utils/model/order.model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ export declare enum SignatureType {
2
+ /**
3
+ * ECDSA EIP712 signatures signed by EOAs
4
+ */
5
+ EOA = 0,
6
+ /**
7
+ * EIP712 signatures signed by EOAs that own Kuest Proxy wallets
8
+ */
9
+ KUEST_PROXY = 1,
10
+ /**
11
+ * EIP712 signatures signed by EOAs that own Kuest Gnosis safes
12
+ */
13
+ KUEST_GNOSIS_SAFE = 2
14
+ }
@@ -0,0 +1,16 @@
1
+ export var SignatureType;
2
+ (function (SignatureType) {
3
+ /**
4
+ * ECDSA EIP712 signatures signed by EOAs
5
+ */
6
+ SignatureType[SignatureType["EOA"] = 0] = "EOA";
7
+ /**
8
+ * EIP712 signatures signed by EOAs that own Kuest Proxy wallets
9
+ */
10
+ SignatureType[SignatureType["KUEST_PROXY"] = 1] = "KUEST_PROXY";
11
+ /**
12
+ * EIP712 signatures signed by EOAs that own Kuest Gnosis safes
13
+ */
14
+ SignatureType[SignatureType["KUEST_GNOSIS_SAFE"] = 2] = "KUEST_GNOSIS_SAFE";
15
+ })(SignatureType || (SignatureType = {}));
16
+ //# sourceMappingURL=signature-types.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature-types.model.js","sourceRoot":"","sources":["../../../src/order-utils/model/signature-types.model.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAeX;AAfD,WAAY,aAAa;IACrB;;OAEG;IACH,+CAAO,CAAA;IAEP;;OAEG;IACH,+DAAe,CAAA;IAEf;;OAEG;IACH,2EAAqB,CAAA;AACzB,CAAC,EAfW,aAAa,KAAb,aAAa,QAexB"}
@@ -0,0 +1 @@
1
+ export declare function generateOrderSalt(): string;
@@ -0,0 +1,4 @@
1
+ export function generateOrderSalt() {
2
+ return Math.round(Math.random() * Date.now()).toString();
3
+ }
4
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/order-utils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB;IAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { IRfqClient, RfqDeps } from "./rfq-deps.ts";
2
+ import type { AcceptQuoteParams, ApproveOrderParams, CancelRfqQuoteParams, CancelRfqRequestParams, CreateOrderOptions, GetRfqBestQuoteParams, GetRfqQuotesParams, GetRfqRequestsParams, RfqQuote, RfqQuoteResponse, RfqQuotesResponse, RfqRequestResponse, RfqRequestsResponse, RfqUserOrder, RfqUserQuote } from "./types.ts";
3
+ /**
4
+ * RfqClient provides RFQ (Request for Quote) functionality on top of a CLOB client.
5
+ */
6
+ export declare class RfqClient implements IRfqClient {
7
+ private readonly deps;
8
+ constructor(deps: RfqDeps);
9
+ /**
10
+ * Creates and posts an RFQ request from user order parameters.
11
+ * Converts the order into the proper RFQ request format with asset amounts and submits it.
12
+ */
13
+ createRfqRequest(userOrder: RfqUserOrder, options?: Partial<CreateOrderOptions>): Promise<RfqRequestResponse>;
14
+ /**
15
+ * Cancels an existing RFQ request
16
+ */
17
+ cancelRfqRequest(request: CancelRfqRequestParams): Promise<"OK">;
18
+ /**
19
+ * Gets RFQ requests with optional filtering parameters
20
+ */
21
+ getRfqRequests(params?: GetRfqRequestsParams): Promise<RfqRequestsResponse>;
22
+ /**
23
+ * Creates a quote in response to an RFQ request.
24
+ * Converts user-friendly parameters into the proper RFQ quote format with asset amounts and submits it.
25
+ */
26
+ createRfqQuote(userQuote: RfqUserQuote, options?: Partial<CreateOrderOptions>): Promise<RfqQuoteResponse>;
27
+ /**
28
+ * Gets quotes on requests created by the authenticated user (requester view).
29
+ * Returns quotes that others have made on your requests.
30
+ */
31
+ getRfqRequesterQuotes(params?: GetRfqQuotesParams): Promise<RfqQuotesResponse>;
32
+ /**
33
+ * Gets quotes created by the authenticated user (quoter view).
34
+ * Returns quotes that you have made on others' requests.
35
+ */
36
+ getRfqQuoterQuotes(params?: GetRfqQuotesParams): Promise<RfqQuotesResponse>;
37
+ /**
38
+ * Gets the best quote for a given request ID
39
+ */
40
+ getRfqBestQuote(params?: GetRfqBestQuoteParams): Promise<RfqQuote>;
41
+ /**
42
+ * Cancels an existing quote
43
+ */
44
+ cancelRfqQuote(quote: CancelRfqQuoteParams): Promise<"OK">;
45
+ /**
46
+ * Gets the RFQ configuration from the server
47
+ */
48
+ rfqConfig(): Promise<any>;
49
+ /**
50
+ * Accepts a quote and creates an order (taker side)
51
+ * This fetches the request details, creates an order, and submits the acceptance
52
+ */
53
+ acceptRfqQuote(payload: AcceptQuoteParams): Promise<"OK">;
54
+ /**
55
+ * Approves a quote and creates an order (maker side)
56
+ * This fetches the quote details, creates an order, and submits the approval
57
+ */
58
+ approveRfqOrder(payload: ApproveOrderParams): Promise<"OK">;
59
+ /**
60
+ * Ensures L2 authentication is available for RFQ endpoints.
61
+ */
62
+ protected ensureL2Auth(): void;
63
+ private getRequestOrderCreationPayload;
64
+ }