@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.
- package/LICENSE +22 -0
- package/README.md +101 -0
- package/dist/client.d.ts +164 -0
- package/dist/client.js +967 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +7 -0
- package/dist/constants.js.map +1 -0
- package/dist/endpoints.d.ts +67 -0
- package/dist/endpoints.js +82 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +16 -0
- package/dist/errors.js.map +1 -0
- package/dist/headers/index.d.ts +6 -0
- package/dist/headers/index.js +42 -0
- package/dist/headers/index.js.map +1 -0
- package/dist/http-helpers/index.d.ts +21 -0
- package/dist/http-helpers/index.js +151 -0
- package/dist/http-helpers/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/order-builder/builder.d.ts +29 -0
- package/dist/order-builder/builder.js +52 -0
- package/dist/order-builder/builder.js.map +1 -0
- package/dist/order-builder/helpers.d.ts +50 -0
- package/dist/order-builder/helpers.js +276 -0
- package/dist/order-builder/helpers.js.map +1 -0
- package/dist/order-builder/index.d.ts +1 -0
- package/dist/order-builder/index.js +2 -0
- package/dist/order-builder/index.js.map +1 -0
- package/dist/order-utils/exchange.order.builder.d.ts +31 -0
- package/dist/order-utils/exchange.order.builder.js +120 -0
- package/dist/order-utils/exchange.order.builder.js.map +1 -0
- package/dist/order-utils/exchange.order.const.d.ts +13 -0
- package/dist/order-utils/exchange.order.const.js +28 -0
- package/dist/order-utils/exchange.order.const.js.map +1 -0
- package/dist/order-utils/index.d.ts +6 -0
- package/dist/order-utils/index.js +7 -0
- package/dist/order-utils/index.js.map +1 -0
- package/dist/order-utils/model/eip712.model.d.ts +25 -0
- package/dist/order-utils/model/eip712.model.js +2 -0
- package/dist/order-utils/model/eip712.model.js.map +1 -0
- package/dist/order-utils/model/order-side.model.d.ts +4 -0
- package/dist/order-utils/model/order-side.model.js +6 -0
- package/dist/order-utils/model/order-side.model.js.map +1 -0
- package/dist/order-utils/model/order.model.d.ts +112 -0
- package/dist/order-utils/model/order.model.js +2 -0
- package/dist/order-utils/model/order.model.js.map +1 -0
- package/dist/order-utils/model/signature-types.model.d.ts +14 -0
- package/dist/order-utils/model/signature-types.model.js +16 -0
- package/dist/order-utils/model/signature-types.model.js.map +1 -0
- package/dist/order-utils/utils.d.ts +1 -0
- package/dist/order-utils/utils.js +4 -0
- package/dist/order-utils/utils.js.map +1 -0
- package/dist/rfq-client.d.ts +64 -0
- package/dist/rfq-client.js +403 -0
- package/dist/rfq-client.js.map +1 -0
- package/dist/rfq-deps.d.ts +44 -0
- package/dist/rfq-deps.js +2 -0
- package/dist/rfq-deps.js.map +1 -0
- package/dist/signer.d.ts +22 -0
- package/dist/signer.js +50 -0
- package/dist/signer.js.map +1 -0
- package/dist/signing/constants.d.ts +14 -0
- package/dist/signing/constants.js +16 -0
- package/dist/signing/constants.js.map +1 -0
- package/dist/signing/eip712.d.ts +9 -0
- package/dist/signing/eip712.js +40 -0
- package/dist/signing/eip712.js.map +1 -0
- package/dist/signing/hmac.d.ts +9 -0
- package/dist/signing/hmac.js +58 -0
- package/dist/signing/hmac.js.map +1 -0
- package/dist/signing/index.d.ts +2 -0
- package/dist/signing/index.js +3 -0
- package/dist/signing/index.js.map +1 -0
- package/dist/types.d.ts +667 -0
- package/dist/types.js +37 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities.d.ts +16 -0
- package/dist/utilities.js +93 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Side as UtilsSide } from "./order-utils/index.js";
|
|
2
|
+
import { OrderType, Side } from "./types.js";
|
|
3
|
+
export function orderToJson(order, owner, orderType, deferExec = false, postOnly) {
|
|
4
|
+
if (postOnly === true && orderType !== OrderType.GTC && orderType !== OrderType.GTD) {
|
|
5
|
+
throw new Error("postOnly is only supported for GTC and GTD orders");
|
|
6
|
+
}
|
|
7
|
+
let side = Side.BUY;
|
|
8
|
+
if (order.side === UtilsSide.BUY) {
|
|
9
|
+
side = Side.BUY;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
side = Side.SELL;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
deferExec,
|
|
16
|
+
order: {
|
|
17
|
+
salt: Number.parseInt(order.salt, 10),
|
|
18
|
+
maker: order.maker,
|
|
19
|
+
signer: order.signer,
|
|
20
|
+
taker: order.taker,
|
|
21
|
+
tokenId: order.tokenId,
|
|
22
|
+
makerAmount: order.makerAmount,
|
|
23
|
+
takerAmount: order.takerAmount,
|
|
24
|
+
side,
|
|
25
|
+
expiration: order.expiration,
|
|
26
|
+
nonce: order.nonce,
|
|
27
|
+
feeRateBps: order.feeRateBps,
|
|
28
|
+
signatureType: order.signatureType,
|
|
29
|
+
signature: order.signature,
|
|
30
|
+
},
|
|
31
|
+
owner,
|
|
32
|
+
orderType,
|
|
33
|
+
...(typeof postOnly === "boolean" ? { postOnly } : {}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export const roundNormal = (num, decimals) => {
|
|
37
|
+
if (decimalPlaces(num) <= decimals) {
|
|
38
|
+
return num;
|
|
39
|
+
}
|
|
40
|
+
return Math.round((num + Number.EPSILON) * 10 ** decimals) / 10 ** decimals;
|
|
41
|
+
};
|
|
42
|
+
export const roundDown = (num, decimals) => {
|
|
43
|
+
if (decimalPlaces(num) <= decimals) {
|
|
44
|
+
return num;
|
|
45
|
+
}
|
|
46
|
+
return Math.floor(num * 10 ** decimals) / 10 ** decimals;
|
|
47
|
+
};
|
|
48
|
+
export const roundUp = (num, decimals) => {
|
|
49
|
+
if (decimalPlaces(num) <= decimals) {
|
|
50
|
+
return num;
|
|
51
|
+
}
|
|
52
|
+
return Math.ceil(num * 10 ** decimals) / 10 ** decimals;
|
|
53
|
+
};
|
|
54
|
+
export const decimalPlaces = (num) => {
|
|
55
|
+
if (Number.isInteger(num)) {
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
const arr = num.toString().split(".");
|
|
59
|
+
if (arr.length <= 1) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
return arr[1].length;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Converts ArrayBuffer to hex string
|
|
66
|
+
*/
|
|
67
|
+
function arrayBufferToHex(buffer) {
|
|
68
|
+
const bytes = new Uint8Array(buffer);
|
|
69
|
+
return Array.from(bytes)
|
|
70
|
+
.map(b => b.toString(16).padStart(2, "0"))
|
|
71
|
+
.join("");
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Calculates the hash for the given orderbook
|
|
75
|
+
* @param orderbook
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
export const generateOrderBookSummaryHash = async (orderbook) => {
|
|
79
|
+
orderbook.hash = "";
|
|
80
|
+
const message = JSON.stringify(orderbook);
|
|
81
|
+
const messageBuffer = new TextEncoder().encode(message);
|
|
82
|
+
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-1", messageBuffer);
|
|
83
|
+
const hash = arrayBufferToHex(hashBuffer);
|
|
84
|
+
orderbook.hash = hash;
|
|
85
|
+
return hash;
|
|
86
|
+
};
|
|
87
|
+
export const isTickSizeSmaller = (a, b) => {
|
|
88
|
+
return Number.parseFloat(a) < Number.parseFloat(b);
|
|
89
|
+
};
|
|
90
|
+
export const priceValid = (price, tickSize) => {
|
|
91
|
+
return price >= Number.parseFloat(tickSize) && price <= 1 - Number.parseFloat(tickSize);
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities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CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,QAAkB,EAAW,EAAE;IACrE,OAAO,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC5F,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kuestcom/clob-client",
|
|
3
|
+
"description": "Typescript client for Kuest's CLOB",
|
|
4
|
+
"version": "5.8.1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/kuestcom/clob-client.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/kuestcom/clob-client",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/kuestcom/clob-client/issues"
|
|
12
|
+
},
|
|
13
|
+
"contributors": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Jonathan Amenechi",
|
|
16
|
+
"url": "https://github.com/JonathanAmenechi"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Rodrigo Calvo",
|
|
20
|
+
"url": "https://github.com/poly-rodr"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Matt Walker",
|
|
24
|
+
"url": "https://github.com/mttwlkr"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Liam Kovatch",
|
|
28
|
+
"url": "https://github.com/l-kov"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Mike Shrieve",
|
|
32
|
+
"url": "https://github.com/mshrieve"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Danny Dresner",
|
|
36
|
+
"url": "https://github.com/ddresner-pm"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "Bruno Maciel",
|
|
40
|
+
"url": "https://github.com/ibruno"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"main": "dist/index.js",
|
|
44
|
+
"types": "dist/index.d.ts",
|
|
45
|
+
"type": "module",
|
|
46
|
+
"files": [
|
|
47
|
+
"/dist"
|
|
48
|
+
],
|
|
49
|
+
"sideEffects": false,
|
|
50
|
+
"keywords": [
|
|
51
|
+
"blockchain",
|
|
52
|
+
"ethereum"
|
|
53
|
+
],
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=20.10"
|
|
56
|
+
},
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"packageManager": "pnpm@10.30.3",
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
61
|
+
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
62
|
+
"test": "pnpm typecheck && vitest run --coverage",
|
|
63
|
+
"lint": "biome check ./src",
|
|
64
|
+
"ci": "pnpm lint && pnpm test && pnpm build",
|
|
65
|
+
"deploy": "pnpm build && npm publish --access public --provenance"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@kuestcom/builder-signing-sdk": "^1.0.0",
|
|
69
|
+
"axios": "1.14.0",
|
|
70
|
+
"browser-or-node": "^2.1.1",
|
|
71
|
+
"viem": "^2.46.3"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@biomejs/biome": "^2.4.5",
|
|
75
|
+
"@ethersproject/wallet": "^5.8.0",
|
|
76
|
+
"@types/node": "^22.19.1",
|
|
77
|
+
"@types/ws": "^8.5.3",
|
|
78
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
79
|
+
"dotenv": "^17.3.1",
|
|
80
|
+
"ethers": "^5.8.0",
|
|
81
|
+
"typescript": "^6.0.0",
|
|
82
|
+
"vitest": "^4.0.18",
|
|
83
|
+
"ws": "^8.11.0"
|
|
84
|
+
}
|
|
85
|
+
}
|