@polymarket/clob-client 1.0.37 → 1.0.40
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/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +417 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/endpoints.d.ts +19 -0
- package/dist/endpoints.d.ts.map +1 -0
- package/dist/endpoints.js +22 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/headers/index.d.ts +6 -0
- package/dist/headers/index.d.ts.map +1 -0
- package/dist/headers/index.js +89 -0
- package/dist/headers/index.js.map +1 -0
- package/dist/http_helpers/index.d.ts +10 -0
- package/dist/http_helpers/index.d.ts.map +1 -0
- package/dist/http_helpers/index.js +107 -0
- package/dist/http_helpers/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/order-builder/builder.d.ts +19 -0
- package/dist/order-builder/builder.d.ts.map +1 -0
- package/dist/order-builder/builder.js +71 -0
- package/dist/order-builder/builder.js.map +1 -0
- package/dist/order-builder/constants.d.ts +3 -0
- package/dist/order-builder/constants.d.ts.map +1 -0
- package/dist/order-builder/constants.js +6 -0
- package/dist/order-builder/constants.js.map +1 -0
- package/dist/order-builder/helpers.d.ts +15 -0
- package/dist/order-builder/helpers.d.ts.map +1 -0
- package/dist/order-builder/helpers.js +336 -0
- package/dist/order-builder/helpers.js.map +1 -0
- package/dist/order-builder/index.d.ts +3 -0
- package/dist/order-builder/index.d.ts.map +1 -0
- package/dist/order-builder/index.js +15 -0
- package/dist/order-builder/index.js.map +1 -0
- package/dist/order-builder/utils.d.ts +4 -0
- package/dist/order-builder/utils.d.ts.map +1 -0
- package/dist/order-builder/utils.js +50 -0
- package/dist/order-builder/utils.js.map +1 -0
- package/dist/signing/constants.d.ts +15 -0
- package/dist/signing/constants.d.ts.map +1 -0
- package/dist/signing/constants.js +19 -0
- package/dist/signing/constants.js.map +1 -0
- package/dist/signing/eip712.d.ts +10 -0
- package/dist/signing/eip712.d.ts.map +1 -0
- package/dist/signing/eip712.js +84 -0
- package/dist/signing/eip712.js.map +1 -0
- package/dist/signing/hmac.d.ts +10 -0
- package/dist/signing/hmac.d.ts.map +1 -0
- package/dist/signing/hmac.js +69 -0
- package/dist/signing/hmac.js.map +1 -0
- package/dist/signing/index.d.ts +3 -0
- package/dist/signing/index.d.ts.map +1 -0
- package/dist/signing/index.js +15 -0
- package/dist/signing/index.js.map +1 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +20 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities.d.ts +9 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js +85 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +10 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.buildPolyHmacSignature = void 0;
|
|
43
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
44
|
+
function replaceAll(s, search, replace) {
|
|
45
|
+
return s.split(search).join(replace);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Builds the canonical Polymarket CLOB HMAC signature
|
|
49
|
+
* @param signer
|
|
50
|
+
* @param key
|
|
51
|
+
* @param secret
|
|
52
|
+
* @param passphrase
|
|
53
|
+
* @returns string
|
|
54
|
+
*/
|
|
55
|
+
exports.buildPolyHmacSignature = function (secret, timestamp, method, requestPath, body) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var message, base64Secret, hmac, sig, sigUrlSafe;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
message = timestamp + method + requestPath;
|
|
59
|
+
if (body !== undefined) {
|
|
60
|
+
message += body;
|
|
61
|
+
}
|
|
62
|
+
base64Secret = Buffer.from(secret, "base64");
|
|
63
|
+
hmac = crypto_1.default.createHmac("sha256", base64Secret);
|
|
64
|
+
sig = hmac.update(message).digest("base64");
|
|
65
|
+
sigUrlSafe = replaceAll(replaceAll(sig, "+", "-"), "/", "_");
|
|
66
|
+
return [2 /*return*/, sigUrlSafe];
|
|
67
|
+
});
|
|
68
|
+
}); };
|
|
69
|
+
//# sourceMappingURL=hmac.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAE5B,SAAS,UAAU,CAAC,CAAS,EAAE,MAAc,EAAE,OAAe;IAC1D,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACU,QAAA,sBAAsB,GAAG,UAClC,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,WAAmB,EACnB,IAAa;;;QAET,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;QAC/C,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,OAAO,IAAI,IAAI,CAAC;SACnB;QACK,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC7C,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACjD,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAK5C,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACnE,sBAAO,UAAU,EAAC;;KACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./eip712"), exports);
|
|
14
|
+
__exportStar(require("./hmac"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { MarketOrder, TimeInForce } from "@polymarket/order-utils";
|
|
2
|
+
export * from "@polymarket/order-utils";
|
|
3
|
+
export interface ApiKeyCreds {
|
|
4
|
+
key: string;
|
|
5
|
+
secret: string;
|
|
6
|
+
passphrase: string;
|
|
7
|
+
}
|
|
8
|
+
export interface L2HeaderArgs {
|
|
9
|
+
method: string;
|
|
10
|
+
requestPath: string;
|
|
11
|
+
body?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface L1PolyHeader {
|
|
14
|
+
POLY_ADDRESS: string;
|
|
15
|
+
POLY_SIGNATURE: string;
|
|
16
|
+
POLY_TIMESTAMP: string;
|
|
17
|
+
POLY_NONCE: string;
|
|
18
|
+
}
|
|
19
|
+
export interface L2PolyHeader {
|
|
20
|
+
POLY_ADDRESS: string;
|
|
21
|
+
POLY_SIGNATURE: string;
|
|
22
|
+
POLY_TIMESTAMP: string;
|
|
23
|
+
POLY_API_KEY: string;
|
|
24
|
+
POLY_PASSPHRASE: string;
|
|
25
|
+
}
|
|
26
|
+
export declare enum Side {
|
|
27
|
+
BUY = "buy",
|
|
28
|
+
SELL = "sell"
|
|
29
|
+
}
|
|
30
|
+
export interface UserLimitOrder {
|
|
31
|
+
tokenID: string;
|
|
32
|
+
price: number;
|
|
33
|
+
size: number;
|
|
34
|
+
side: Side;
|
|
35
|
+
}
|
|
36
|
+
export interface UserMarketOrder {
|
|
37
|
+
tokenID: string;
|
|
38
|
+
size: number;
|
|
39
|
+
side: Side;
|
|
40
|
+
worstPrice?: number;
|
|
41
|
+
timeInForce?: TimeInForce;
|
|
42
|
+
}
|
|
43
|
+
export interface OrderPayload {
|
|
44
|
+
orderID: string;
|
|
45
|
+
}
|
|
46
|
+
export interface OrderCreationArgs {
|
|
47
|
+
chainID: number;
|
|
48
|
+
exchange: string;
|
|
49
|
+
executor: string;
|
|
50
|
+
signer: string;
|
|
51
|
+
maker: string;
|
|
52
|
+
makerAsset: string;
|
|
53
|
+
makerAmount: string;
|
|
54
|
+
makerAssetID?: string;
|
|
55
|
+
takerAsset: string;
|
|
56
|
+
takerAmount: string;
|
|
57
|
+
takerAssetID?: string;
|
|
58
|
+
signatureType: number;
|
|
59
|
+
}
|
|
60
|
+
export interface MarketOrderCreationArgs {
|
|
61
|
+
chainID: number;
|
|
62
|
+
exchange: string;
|
|
63
|
+
signer: string;
|
|
64
|
+
maker: string;
|
|
65
|
+
makerAsset: string;
|
|
66
|
+
makerAmount: string;
|
|
67
|
+
makerAssetID?: string;
|
|
68
|
+
takerAsset: string;
|
|
69
|
+
takerAssetID?: string;
|
|
70
|
+
signatureType: number;
|
|
71
|
+
minAmountReceived: string;
|
|
72
|
+
timeInForce: TimeInForce;
|
|
73
|
+
}
|
|
74
|
+
export interface ApiKeysResponse {
|
|
75
|
+
apiKeys: ApiKeyCreds[];
|
|
76
|
+
}
|
|
77
|
+
export interface OrderResponse {
|
|
78
|
+
success: boolean;
|
|
79
|
+
errorMsg: string;
|
|
80
|
+
orderID: string;
|
|
81
|
+
transactionHash: string;
|
|
82
|
+
status: string;
|
|
83
|
+
}
|
|
84
|
+
export interface Order {
|
|
85
|
+
orderID: string;
|
|
86
|
+
owner: string;
|
|
87
|
+
timestamp: string;
|
|
88
|
+
price: string;
|
|
89
|
+
size: string;
|
|
90
|
+
side: string;
|
|
91
|
+
tokenID: string;
|
|
92
|
+
}
|
|
93
|
+
export interface OpenOrdersResponse {
|
|
94
|
+
orders: Order[];
|
|
95
|
+
}
|
|
96
|
+
export interface FilterParams {
|
|
97
|
+
market?: string;
|
|
98
|
+
max?: number;
|
|
99
|
+
startTs?: number;
|
|
100
|
+
endTs?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface Trade {
|
|
103
|
+
tradeID: string;
|
|
104
|
+
market: string;
|
|
105
|
+
timestamp: string;
|
|
106
|
+
marketOrderID: string;
|
|
107
|
+
limitOrderIDs: string[];
|
|
108
|
+
filledAmount: string;
|
|
109
|
+
side: string;
|
|
110
|
+
owner: string;
|
|
111
|
+
avgPrice: string;
|
|
112
|
+
}
|
|
113
|
+
export interface TradeHistory {
|
|
114
|
+
history: Trade[];
|
|
115
|
+
}
|
|
116
|
+
export interface OrderHistory {
|
|
117
|
+
history: Order[];
|
|
118
|
+
}
|
|
119
|
+
export interface MarketOrderHistory {
|
|
120
|
+
history: MarketOrder[];
|
|
121
|
+
}
|
|
122
|
+
export declare type OptionalParams = {
|
|
123
|
+
[query: string]: string;
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEnE,cAAc,yBAAyB,CAAC;AAExC,MAAM,WAAW,WAAW;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,YAAY;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,YAAY;IACzB,YAAY,EAAE,MA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AAY;IACzB,OAAO,EAAE,KAAK,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,KAAK,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,oBAAY,cAAc,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.Side = void 0;
|
|
14
|
+
__exportStar(require("@polymarket/order-utils"), exports);
|
|
15
|
+
var Side;
|
|
16
|
+
(function (Side) {
|
|
17
|
+
Side["BUY"] = "buy";
|
|
18
|
+
Side["SELL"] = "sell";
|
|
19
|
+
})(Side = exports.Side || (exports.Side = {}));
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,0DAAwC;AA+BxC,IAAY,IAGX;AAHD,WAAY,IAAI;IACZ,mBAAW,CAAA;IACX,qBAAa,CAAA;AACjB,CAAC,EAHW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAGf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LimitOrderAndSignature, MarketOrderAndSignature } from "@polymarket/order-utils";
|
|
2
|
+
import { FilterParams } from "./types";
|
|
3
|
+
export declare const limitOrderToJson: (order: LimitOrderAndSignature) => any;
|
|
4
|
+
export declare const marketOrderToJson: (mktOrder: MarketOrderAndSignature) => any;
|
|
5
|
+
export declare const addQueryParamsToUrl: (baseUrl: string, params?: FilterParams | undefined) => string;
|
|
6
|
+
export declare const roundNormal: (num: number, decimals: number) => number;
|
|
7
|
+
export declare const roundDown: (num: number, decimals: number) => number;
|
|
8
|
+
export declare const roundUp: (num: number, decimals: number) => number;
|
|
9
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,gBAAgB,UAAW,sBAAsB,KAAG,GAmBhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,uBAAuB,KAAG,GAkBrE,CAAC;AAgBF,eAAO,MAAM,mBAAmB,YAAa,MAAM,wCAA0B,MAkB5E,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,MAAM,YAAY,MAAM,KAAG,MAE3D,CAAA;AAED,eAAO,MAAM,SAAS,QAAS,MAAM,YAAY,MAAM,KAAG,MAEzD,CAAA;AAED,eAAO,MAAM,OAAO,QAAS,MAAM,YAAY,MAAM,KAAG,MAEvD,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roundUp = exports.roundDown = exports.roundNormal = exports.addQueryParamsToUrl = exports.marketOrderToJson = exports.limitOrderToJson = void 0;
|
|
4
|
+
exports.limitOrderToJson = function (order) {
|
|
5
|
+
return {
|
|
6
|
+
order: {
|
|
7
|
+
salt: parseInt(order.order.salt, 10),
|
|
8
|
+
makerAsset: order.order.makerAsset,
|
|
9
|
+
takerAsset: order.order.takerAsset,
|
|
10
|
+
makerAssetData: order.order.makerAssetData,
|
|
11
|
+
takerAssetData: order.order.takerAssetData,
|
|
12
|
+
getMakerAmount: order.order.getMakerAmount,
|
|
13
|
+
getTakerAmount: order.order.getTakerAmount,
|
|
14
|
+
predicate: order.order.predicate,
|
|
15
|
+
permit: order.order.permit,
|
|
16
|
+
interaction: order.order.interaction,
|
|
17
|
+
signer: order.order.signer,
|
|
18
|
+
sigType: order.order.sigType,
|
|
19
|
+
},
|
|
20
|
+
signature: order.signature,
|
|
21
|
+
orderType: "limit",
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.marketOrderToJson = function (mktOrder) {
|
|
25
|
+
return {
|
|
26
|
+
order: {
|
|
27
|
+
salt: parseInt(mktOrder.order.salt, 10),
|
|
28
|
+
maker: mktOrder.order.maker,
|
|
29
|
+
makerAsset: mktOrder.order.makerAsset,
|
|
30
|
+
makerAmount: mktOrder.order.makerAmount,
|
|
31
|
+
makerAssetID: mktOrder.order.makerAssetID,
|
|
32
|
+
takerAsset: mktOrder.order.takerAsset,
|
|
33
|
+
takerAssetID: mktOrder.order.takerAssetID,
|
|
34
|
+
signer: mktOrder.order.signer,
|
|
35
|
+
sigType: mktOrder.order.sigType,
|
|
36
|
+
},
|
|
37
|
+
signature: mktOrder.signature,
|
|
38
|
+
orderType: "market",
|
|
39
|
+
minAmountReceived: mktOrder.minAmountReceived,
|
|
40
|
+
timeInForce: mktOrder.timeInForce,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var buildQueryParams = function (url, param, value) {
|
|
44
|
+
var urlWithParams = url;
|
|
45
|
+
var last = url.charAt(url.length - 1);
|
|
46
|
+
// Check the last char in the url string
|
|
47
|
+
// if ?, append the param directly: api.com?param=value
|
|
48
|
+
if (last === "?") {
|
|
49
|
+
urlWithParams = "" + urlWithParams + param + "=" + value;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// else append "&" then the param: api.com?param1=value1¶m2=value2
|
|
53
|
+
urlWithParams = urlWithParams + "&" + param + "=" + value;
|
|
54
|
+
}
|
|
55
|
+
return urlWithParams;
|
|
56
|
+
};
|
|
57
|
+
exports.addQueryParamsToUrl = function (baseUrl, params) {
|
|
58
|
+
var url = baseUrl;
|
|
59
|
+
if (params !== undefined) {
|
|
60
|
+
url = url + "?";
|
|
61
|
+
if (params.market !== undefined) {
|
|
62
|
+
url = buildQueryParams(url, "market", params.market);
|
|
63
|
+
}
|
|
64
|
+
if (params.max !== undefined) {
|
|
65
|
+
url = buildQueryParams(url, "max", "" + params.max);
|
|
66
|
+
}
|
|
67
|
+
if (params.startTs !== undefined) {
|
|
68
|
+
url = buildQueryParams(url, "startTs", "" + params.startTs);
|
|
69
|
+
}
|
|
70
|
+
if (params.endTs !== undefined) {
|
|
71
|
+
url = buildQueryParams(url, "endTs", "" + params.endTs);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return url;
|
|
75
|
+
};
|
|
76
|
+
exports.roundNormal = function (num, decimals) {
|
|
77
|
+
return Math.round((num + Number.EPSILON) * (Math.pow(10, decimals))) / (Math.pow(10, decimals));
|
|
78
|
+
};
|
|
79
|
+
exports.roundDown = function (num, decimals) {
|
|
80
|
+
return Math.floor(num * (Math.pow(10, decimals))) / (Math.pow(10, decimals));
|
|
81
|
+
};
|
|
82
|
+
exports.roundUp = function (num, decimals) {
|
|
83
|
+
return Math.ceil(num * (Math.pow(10, decimals))) / (Math.pow(10, decimals));
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;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BAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAG,MAAM,CAAC,OAAS,CAAC,CAAC;SAC/D;QACD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAG,MAAM,CAAC,KAAO,CAAC,CAAC;SAC3D;KACJ;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEW,QAAA,WAAW,GAAG,UAAC,GAAW,EAAE,QAAgB;IACrD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAA,EAAE,EAAE,QAAQ,CAAA,CAAC,CAAC,GAAG,CAAC,SAAA,EAAE,EAAE,QAAQ,CAAA,CAAC,CAAA;AAC/E,CAAC,CAAA;AAEY,QAAA,SAAS,GAAG,UAAC,GAAW,EAAE,QAAgB;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,SAAA,EAAE,EAAE,QAAQ,CAAA,CAAC,CAAC,GAAG,CAAC,SAAA,EAAE,EAAE,QAAQ,CAAA,CAAC,CAAA;AAC5D,CAAC,CAAA;AAEY,QAAA,OAAO,GAAG,UAAC,GAAW,EAAE,QAAgB;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAA,EAAE,EAAE,QAAQ,CAAA,CAAC,CAAC,GAAG,CAAC,SAAA,EAAE,EAAE,QAAQ,CAAA,CAAC,CAAA;AAC3D,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarket/clob-client",
|
|
3
3
|
"description": "Typescript client for Polymarket's CLOB",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.40",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Jonathan Amenechi",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"eth-sig-util": "^3.0.1",
|
|
36
36
|
"ethers": "^5.5.2",
|
|
37
37
|
"husky": "^4.3.0",
|
|
38
|
-
"mocha": "^
|
|
38
|
+
"mocha": "^10.0.0",
|
|
39
39
|
"prettier": "^2.1.2",
|
|
40
40
|
"ts-generator": "^0.1.1",
|
|
41
41
|
"ts-node": "^9.1.1",
|
|
@@ -51,7 +51,13 @@
|
|
|
51
51
|
],
|
|
52
52
|
"license": "MIT",
|
|
53
53
|
"scripts": {
|
|
54
|
-
"
|
|
55
|
-
"deploy": "yarn build && npm publish"
|
|
54
|
+
"w": "tsc",
|
|
55
|
+
"deploy": "yarn build && npm publish",
|
|
56
|
+
"test": "mocha --require ts-node/register test/**/*.test.ts"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/chai": "^4.3.1",
|
|
60
|
+
"@types/mocha": "^9.1.1",
|
|
61
|
+
"chai": "^4.3.6"
|
|
56
62
|
}
|
|
57
63
|
}
|