@polymarket/clob-client 1.0.1 → 1.0.4
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/README.md +1 -4
- package/dist/client.d.ts +16 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +261 -11
- package/dist/client.js.map +1 -1
- package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/{src/contracts → contracts}/index.d.ts +0 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +85 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/{src/endpoints.d.ts → endpoints.d.ts} +0 -0
- package/dist/endpoints.d.ts.map +1 -0
- package/dist/endpoints.js +12 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/{src/errors.d.ts → errors.d.ts} +0 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/{src/headers → headers}/index.d.ts +0 -0
- package/dist/headers/index.d.ts.map +1 -0
- package/dist/headers/index.js +84 -0
- package/dist/headers/index.js.map +1 -0
- package/dist/{src/http_helpers → http_helpers}/index.d.ts +0 -0
- package/dist/http_helpers/index.d.ts.map +1 -0
- package/dist/http_helpers/index.js +90 -0
- package/dist/http_helpers/index.js.map +1 -0
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/{src/order-builder → order-builder}/builder.d.ts +0 -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/{src/order-builder → order-builder}/constants.d.ts +0 -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/{src/order-builder → order-builder}/helpers.d.ts +0 -0
- package/dist/order-builder/helpers.d.ts.map +1 -0
- package/dist/order-builder/helpers.js +293 -0
- package/dist/order-builder/helpers.js.map +1 -0
- package/dist/{src/order-builder → order-builder}/index.d.ts +0 -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/{src/order-builder → order-builder}/utils.d.ts +0 -0
- package/dist/order-builder/utils.d.ts.map +1 -0
- package/dist/order-builder/utils.js +62 -0
- package/dist/order-builder/utils.js.map +1 -0
- package/dist/signing/constants.js +10 -7
- package/dist/signing/constants.js.map +1 -1
- package/dist/signing/eip712.js +72 -25
- package/dist/signing/eip712.js.map +1 -1
- package/dist/signing/hmac.d.ts.map +1 -1
- package/dist/signing/hmac.js +60 -16
- package/dist/signing/hmac.js.map +1 -1
- package/dist/signing/index.js +14 -2
- package/dist/signing/index.js.map +1 -1
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -1
- package/dist/{src/utilities.d.ts → utilities.d.ts} +0 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/{src/utilities.js → utilities.js} +5 -2
- package/dist/utilities.js.map +1 -0
- package/package.json +14 -15
- package/dist/examples/createApiKey.d.ts +0 -2
- package/dist/examples/createApiKey.d.ts.map +0 -1
- package/dist/examples/createApiKey.js +0 -19
- package/dist/examples/createApiKey.js.map +0 -1
- package/dist/examples/createOrder.d.ts +0 -2
- package/dist/examples/createOrder.d.ts.map +0 -1
- package/dist/examples/createOrder.js +0 -34
- package/dist/examples/createOrder.js.map +0 -1
- package/dist/examples/getApiKeys.d.ts +0 -2
- package/dist/examples/getApiKeys.d.ts.map +0 -1
- package/dist/examples/getApiKeys.js +0 -23
- package/dist/examples/getApiKeys.js.map +0 -1
- package/dist/examples/getOpenOrders.d.ts +0 -2
- package/dist/examples/getOpenOrders.d.ts.map +0 -1
- package/dist/examples/getOpenOrders.js +0 -23
- package/dist/examples/getOpenOrders.js.map +0 -1
- package/dist/examples/getServerTime.d.ts +0 -2
- package/dist/examples/getServerTime.d.ts.map +0 -1
- package/dist/examples/getServerTime.js +0 -11
- package/dist/examples/getServerTime.js.map +0 -1
- package/dist/examples/getTradeHistory.d.ts +0 -2
- package/dist/examples/getTradeHistory.d.ts.map +0 -1
- package/dist/examples/getTradeHistory.js +0 -23
- package/dist/examples/getTradeHistory.js.map +0 -1
- package/dist/examples/marketOrder.d.ts +0 -2
- package/dist/examples/marketOrder.d.ts.map +0 -1
- package/dist/examples/marketOrder.js +0 -42
- package/dist/examples/marketOrder.js.map +0 -1
- package/dist/examples/testMarketBuy.d.ts +0 -2
- package/dist/examples/testMarketBuy.d.ts.map +0 -1
- package/dist/examples/testMarketBuy.js +0 -50
- package/dist/examples/testMarketBuy.js.map +0 -1
- package/dist/examples/testMarketSell.d.ts +0 -2
- package/dist/examples/testMarketSell.d.ts.map +0 -1
- package/dist/examples/testMarketSell.js +0 -50
- package/dist/examples/testMarketSell.js.map +0 -1
- package/dist/examples/testMultiSigMarketBuy.d.ts +0 -2
- package/dist/examples/testMultiSigMarketBuy.d.ts.map +0 -1
- package/dist/examples/testMultiSigMarketBuy.js +0 -52
- package/dist/examples/testMultiSigMarketBuy.js.map +0 -1
- package/dist/examples/testPolyProxyMarketBuy.d.ts +0 -2
- package/dist/examples/testPolyProxyMarketBuy.d.ts.map +0 -1
- package/dist/examples/testPolyProxyMarketBuy.js +0 -52
- package/dist/examples/testPolyProxyMarketBuy.js.map +0 -1
- package/dist/examples/testPolyProxyMarketSell.d.ts +0 -2
- package/dist/examples/testPolyProxyMarketSell.d.ts.map +0 -1
- package/dist/examples/testPolyProxyMarketSell.js +0 -52
- package/dist/examples/testPolyProxyMarketSell.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -5
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -16
- package/dist/helpers/index.js.map +0 -1
- package/dist/keys.ts/index.d.ts +0 -4
- package/dist/keys.ts/index.d.ts.map +0 -1
- package/dist/keys.ts/index.js +0 -14
- package/dist/keys.ts/index.js.map +0 -1
- package/dist/src/client.d.ts +0 -26
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js +0 -134
- package/dist/src/client.js.map +0 -1
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -5
- package/dist/src/constants.js.map +0 -1
- package/dist/src/contracts/index.d.ts.map +0 -1
- package/dist/src/contracts/index.js +0 -21
- package/dist/src/contracts/index.js.map +0 -1
- package/dist/src/endpoints.d.ts.map +0 -1
- package/dist/src/endpoints.js +0 -9
- package/dist/src/endpoints.js.map +0 -1
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -3
- package/dist/src/errors.js.map +0 -1
- package/dist/src/headers/index.d.ts.map +0 -1
- package/dist/src/headers/index.js +0 -26
- package/dist/src/headers/index.js.map +0 -1
- package/dist/src/http_helpers/index.d.ts.map +0 -1
- package/dist/src/http_helpers/index.js +0 -25
- package/dist/src/http_helpers/index.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +0 -1
- package/dist/src/order-builder/builder.d.ts.map +0 -1
- package/dist/src/order-builder/builder.js +0 -22
- package/dist/src/order-builder/builder.js.map +0 -1
- package/dist/src/order-builder/constants.d.ts.map +0 -1
- package/dist/src/order-builder/constants.js +0 -3
- package/dist/src/order-builder/constants.js.map +0 -1
- package/dist/src/order-builder/helpers.d.ts.map +0 -1
- package/dist/src/order-builder/helpers.js +0 -221
- package/dist/src/order-builder/helpers.js.map +0 -1
- package/dist/src/order-builder/index.d.ts.map +0 -1
- package/dist/src/order-builder/index.js +0 -3
- package/dist/src/order-builder/index.js.map +0 -1
- package/dist/src/order-builder/utils.d.ts.map +0 -1
- package/dist/src/order-builder/utils.js +0 -21
- package/dist/src/order-builder/utils.js.map +0 -1
- package/dist/src/signing/constants.d.ts +0 -15
- package/dist/src/signing/constants.d.ts.map +0 -1
- package/dist/src/signing/constants.js +0 -16
- package/dist/src/signing/constants.js.map +0 -1
- package/dist/src/signing/eip712.d.ts +0 -10
- package/dist/src/signing/eip712.d.ts.map +0 -1
- package/dist/src/signing/eip712.js +0 -32
- package/dist/src/signing/eip712.js.map +0 -1
- package/dist/src/signing/hmac.d.ts +0 -10
- package/dist/src/signing/hmac.d.ts.map +0 -1
- package/dist/src/signing/hmac.js +0 -25
- package/dist/src/signing/hmac.js.map +0 -1
- package/dist/src/signing/index.d.ts +0 -3
- package/dist/src/signing/index.d.ts.map +0 -1
- package/dist/src/signing/index.js +0 -3
- package/dist/src/signing/index.js.map +0 -1
- package/dist/src/types.d.ts +0 -71
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -7
- package/dist/src/types.js.map +0 -1
- package/dist/src/utilities.d.ts.map +0 -1
- package/dist/src/utilities.js.map +0 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOB_TYPES = exports.CLOB_DOMAIN = exports.MSG_TO_SIGN = exports.CLOB_VERSION = exports.CLOB_DOMAIN_NAME = void 0;
|
|
4
|
+
exports.CLOB_DOMAIN_NAME = "ClobAuthDomain";
|
|
5
|
+
exports.CLOB_VERSION = "1";
|
|
6
|
+
exports.MSG_TO_SIGN = "This message attests that I control the given wallet";
|
|
7
|
+
exports.CLOB_DOMAIN = {
|
|
8
|
+
name: exports.CLOB_DOMAIN_NAME,
|
|
9
|
+
version: exports.CLOB_VERSION,
|
|
7
10
|
chainId: 1,
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
exports.CLOB_TYPES = {
|
|
10
13
|
ClobAuth: [
|
|
11
14
|
{ name: "address", type: "address" },
|
|
12
15
|
{ name: "timestamp", type: "string" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/signing/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/signing/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,YAAY,GAAG,GAAG,CAAC;AACnB,QAAA,WAAW,GAAG,sDAAsD,CAAC;AAErE,QAAA,WAAW,GAAG;IACvB,IAAI,EAAE,wBAAgB;IACtB,OAAO,EAAE,oBAAY;IACrB,OAAO,EAAE,CAAC;CACb,CAAC;AAEW,QAAA,UAAU,GAAG;IACtB,QAAQ,EAAE;QACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;QACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;KACtC;CACJ,CAAC"}
|
package/dist/signing/eip712.js
CHANGED
|
@@ -1,32 +1,79 @@
|
|
|
1
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.buildClobEip712Signature = void 0;
|
|
40
|
+
var constants_1 = require("./constants");
|
|
2
41
|
/**
|
|
3
42
|
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
4
43
|
* @param signer
|
|
5
44
|
* @param ts
|
|
6
45
|
* @returns string
|
|
7
46
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
exports.buildClobEip712Signature = function (signer, timestamp) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var address, ts, domain, types, value, sig;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, signer.getAddress()];
|
|
52
|
+
case 1:
|
|
53
|
+
address = _a.sent();
|
|
54
|
+
ts = "" + timestamp;
|
|
55
|
+
domain = {
|
|
56
|
+
name: "ClobAuthDomain",
|
|
57
|
+
version: "1",
|
|
58
|
+
chainId: 1,
|
|
59
|
+
};
|
|
60
|
+
types = {
|
|
61
|
+
ClobAuth: [
|
|
62
|
+
{ name: "address", type: "address" },
|
|
63
|
+
{ name: "timestamp", type: "string" },
|
|
64
|
+
{ name: "message", type: "string" },
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
value = {
|
|
68
|
+
address: address,
|
|
69
|
+
timestamp: ts,
|
|
70
|
+
message: constants_1.MSG_TO_SIGN,
|
|
71
|
+
};
|
|
72
|
+
return [4 /*yield*/, signer._signTypedData(domain, types, value)];
|
|
73
|
+
case 2:
|
|
74
|
+
sig = _a.sent();
|
|
75
|
+
return [2 /*return*/, sig];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); };
|
|
32
79
|
//# sourceMappingURL=eip712.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,yCAA0C;AAE1C;;;;;GAKG;AACU,QAAA,wBAAwB,GAAG,UAAO,MAA8B,EAAE,SAAiB;;;;oBAC5E,qBAAM,MAAM,CAAC,UAAU,EAAE,EAAA;;gBAAnC,OAAO,GAAG,SAAyB;gBACnC,EAAE,GAAG,KAAG,SAAW,CAAC;gBAEpB,MAAM,GAAG;oBACX,IAAI,EAAE,gBAAgB;oBACtB,OAAO,EAAE,GAAG;oBACZ,OAAO,EAAE,CAAC;iBACb,CAAC;gBAEI,KAAK,GAAG;oBACV,QAAQ,EAAE;wBACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;wBACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;qBACtC;iBACJ,CAAC;gBACI,KAAK,GAAG;oBACV,OAAO,SAAA;oBACP,SAAS,EAAE,EAAE;oBACb,OAAO,EAAE,uBAAW;iBACvB,CAAC;gBAEU,qBAAM,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,EAAA;;gBAAvD,GAAG,GAAG,SAAiD;gBAC7D,sBAAO,GAAG,EAAC;;;KACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,WACvB,MAAM,aACH,MAAM,UACT,MAAM,eACD,MAAM,gCAEpB,OAAO,CAAC,MAAM,CAchB,CAAC"}
|
package/dist/signing/hmac.js
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
}
|
|
3
47
|
/**
|
|
4
48
|
* Builds the canonical Polymarket CLOB HMAC signature
|
|
5
49
|
* @param signer
|
|
@@ -8,18 +52,18 @@ import crypto from "crypto";
|
|
|
8
52
|
* @param passphrase
|
|
9
53
|
* @returns string
|
|
10
54
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
message
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
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
|
+
}); };
|
|
25
69
|
//# sourceMappingURL=hmac.js.map
|
package/dist/signing/hmac.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|
package/dist/signing/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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);
|
|
3
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
export * from "@polymarket/order-utils";
|
|
1
2
|
export interface ApiKeyCreds {
|
|
2
3
|
key: string;
|
|
3
4
|
secret: string;
|
|
4
5
|
passphrase: string;
|
|
5
6
|
}
|
|
7
|
+
export interface L2HeaderArgs {
|
|
8
|
+
method: string;
|
|
9
|
+
requestPath: string;
|
|
10
|
+
body?: string;
|
|
11
|
+
}
|
|
6
12
|
export interface L1PolyHeader {
|
|
7
13
|
POLY_ADDRESS: string;
|
|
8
14
|
POLY_SIGNATURE: string;
|
|
@@ -15,4 +21,51 @@ export interface L2PolyHeader {
|
|
|
15
21
|
POLY_API_KEY: string;
|
|
16
22
|
POLY_PASSPHRASE: string;
|
|
17
23
|
}
|
|
24
|
+
export declare enum Side {
|
|
25
|
+
BUY = "buy",
|
|
26
|
+
SELL = "sell"
|
|
27
|
+
}
|
|
28
|
+
export interface Asset {
|
|
29
|
+
address: string;
|
|
30
|
+
condition: string;
|
|
31
|
+
}
|
|
32
|
+
export interface UserLimitOrder {
|
|
33
|
+
asset: Asset;
|
|
34
|
+
price: number;
|
|
35
|
+
size: number;
|
|
36
|
+
side: Side;
|
|
37
|
+
}
|
|
38
|
+
export interface UserMarketOrder {
|
|
39
|
+
asset: Asset;
|
|
40
|
+
size: number;
|
|
41
|
+
side: Side;
|
|
42
|
+
}
|
|
43
|
+
export interface OrderPayload {
|
|
44
|
+
orderID: string;
|
|
45
|
+
}
|
|
46
|
+
export interface OrderCreationArgs {
|
|
47
|
+
chainID: number;
|
|
48
|
+
exchange: string;
|
|
49
|
+
signer: string;
|
|
50
|
+
maker: string;
|
|
51
|
+
makerAsset: string;
|
|
52
|
+
makerAmount: string;
|
|
53
|
+
makerAssetID?: number;
|
|
54
|
+
takerAsset: string;
|
|
55
|
+
takerAmount: string;
|
|
56
|
+
takerAssetID?: number;
|
|
57
|
+
signatureType: number;
|
|
58
|
+
}
|
|
59
|
+
export interface MarketOrderCreationArgs {
|
|
60
|
+
chainID: number;
|
|
61
|
+
exchange: string;
|
|
62
|
+
signer: string;
|
|
63
|
+
maker: string;
|
|
64
|
+
makerAsset: string;
|
|
65
|
+
makerAmount: string;
|
|
66
|
+
makerAssetID?: number;
|
|
67
|
+
takerAsset: string;
|
|
68
|
+
takerAssetID?: number;
|
|
69
|
+
signatureType: number;
|
|
70
|
+
}
|
|
18
71
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,YAAY;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,WAAW,YAAY;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CAC3B"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,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,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W,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACzB"}
|
package/dist/types.js
CHANGED
|
@@ -1 +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 = {}));
|
|
1
20
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0DAAwC;AA8BxC,IAAY,IAGX;AAHD,WAAY,IAAI;IACZ,mBAAW,CAAA;IACX,qBAAa,CAAA;AACjB,CAAC,EAHW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAGf"}
|
|
File without changes
|
|
@@ -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;AAE1F,eAAO,MAAM,gBAAgB,UAAW,sBAAsB,KAAG,GAmBhE,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,uBAAuB,KAAG,GAerE,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.marketOrderToJson = exports.limitOrderToJson = void 0;
|
|
4
|
+
exports.limitOrderToJson = function (order) {
|
|
2
5
|
return {
|
|
3
6
|
order: {
|
|
4
7
|
salt: parseInt(order.order.salt, 10),
|
|
@@ -18,7 +21,7 @@ export const limitOrderToJson = (order) => {
|
|
|
18
21
|
orderType: order.orderType,
|
|
19
22
|
};
|
|
20
23
|
};
|
|
21
|
-
|
|
24
|
+
exports.marketOrderToJson = function (mktOrder) {
|
|
22
25
|
return {
|
|
23
26
|
order: {
|
|
24
27
|
salt: parseInt(mktOrder.order.salt, 10),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG,UAAC,KAA6B;IAC1D,OAAO;QACH,KAAK,EAAE;YACH,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACpC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU;YAClC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU;YAClC,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,cAAc;YAC1C,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,cAAc;YAC1C,cAAc,EAAE,KAAK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
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Jonathan Amenechi",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
],
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
|
-
"
|
|
13
|
+
"dependencies": {
|
|
14
14
|
"@commitlint/cli": "^9.1.2",
|
|
15
15
|
"@commitlint/config-conventional": "^9.1.2",
|
|
16
|
-
"@ethersproject/abstract-provider": "^5.
|
|
17
|
-
"@ethersproject/abstract-signer": "^5.
|
|
18
|
-
"@ethersproject/bignumber": "^5.
|
|
19
|
-
"@ethersproject/constants": "^5.
|
|
20
|
-
"@ethersproject/contracts": "^5.
|
|
21
|
-
"@ethersproject/hash": "^5.
|
|
22
|
-
"@ethersproject/providers": "^5.
|
|
23
|
-
"@ethersproject/random": "^5.
|
|
24
|
-
"@ethersproject/transactions": "^5.
|
|
25
|
-
"@ethersproject/wallet": "^5.
|
|
16
|
+
"@ethersproject/abstract-provider": "^5.5.1",
|
|
17
|
+
"@ethersproject/abstract-signer": "^5.5.0",
|
|
18
|
+
"@ethersproject/bignumber": "^5.5.0",
|
|
19
|
+
"@ethersproject/constants": "^5.5.0",
|
|
20
|
+
"@ethersproject/contracts": "^5.5.0",
|
|
21
|
+
"@ethersproject/hash": "^5.5.0",
|
|
22
|
+
"@ethersproject/providers": "^5.5.1",
|
|
23
|
+
"@ethersproject/random": "^5.5.0",
|
|
24
|
+
"@ethersproject/transactions": "^5.5.0",
|
|
25
|
+
"@ethersproject/wallet": "^5.5.0",
|
|
26
26
|
"@polymarket/order-utils": "^1.1.5",
|
|
27
27
|
"axios": "^0.21.1",
|
|
28
28
|
"commitizen": "^4.2.1",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"eslint-config-airbnb-base-typescript-prettier": "^4.1.0",
|
|
33
33
|
"eslint-config-prettier": "^6.12.0",
|
|
34
34
|
"eslint-plugin-import": "^2.22.1",
|
|
35
|
-
"ethers": "^5.
|
|
35
|
+
"ethers": "^5.5.2",
|
|
36
36
|
"husky": "^4.3.0",
|
|
37
37
|
"mocha": "^8.1.3",
|
|
38
38
|
"prettier": "^2.1.2",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsc",
|
|
54
|
-
"deploy": "yarn build && npm publish"
|
|
55
|
-
"lint": "eslint --config ./.eslintrc.js --ignore-path ./.eslintignore src"
|
|
54
|
+
"deploy": "yarn build && npm publish"
|
|
56
55
|
}
|
|
57
56
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createApiKey.d.ts","sourceRoot":"","sources":["../../examples/createApiKey.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { config as dotenvConfig } from "dotenv";
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import { ClobClient } from "../src";
|
|
5
|
-
dotenvConfig({ path: resolve(__dirname, "../.env") });
|
|
6
|
-
async function main() {
|
|
7
|
-
const provider = new ethers.providers.JsonRpcProvider(process.env.ETH_RPC_URL);
|
|
8
|
-
const pk = new ethers.Wallet(`${process.env.PK}`);
|
|
9
|
-
const wallet = pk.connect(provider);
|
|
10
|
-
console.log(`Address: ${await wallet.getAddress()}`);
|
|
11
|
-
const host = "http://localhost:8080";
|
|
12
|
-
const clobClient = new ClobClient(host, wallet);
|
|
13
|
-
console.log(`Response: `);
|
|
14
|
-
const resp = await clobClient.createApiKey();
|
|
15
|
-
console.log(resp);
|
|
16
|
-
console.log(`Complete!`);
|
|
17
|
-
}
|
|
18
|
-
main();
|
|
19
|
-
//# sourceMappingURL=createApiKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createApiKey.js","sourceRoot":"","sources":["../../examples/createApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAEtD,KAAK,UAAU,IAAI;IACf,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC/E,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAErD,MAAM,IAAI,GAAG,uBAAuB,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,YAAY,EAAE,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC7B,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOrder.d.ts","sourceRoot":"","sources":["../../examples/createOrder.ts"],"names":[],"mappings":""}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { config as dotenvConfig } from "dotenv";
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import { ClobClient, Side } from "../src";
|
|
5
|
-
dotenvConfig({ path: resolve(__dirname, "../.env") });
|
|
6
|
-
async function main() {
|
|
7
|
-
const provider = new ethers.providers.JsonRpcProvider(process.env.ETH_RPC_URL);
|
|
8
|
-
const pk = new ethers.Wallet(`${process.env.PK}`);
|
|
9
|
-
const wallet = pk.connect(provider);
|
|
10
|
-
console.log(`Address: ${await wallet.getAddress()}`);
|
|
11
|
-
const host = "http://localhost:8080";
|
|
12
|
-
const creds = {
|
|
13
|
-
key: `${process.env.CLOB_API_KEY}`,
|
|
14
|
-
secret: `${process.env.CLOB_SECRET}`,
|
|
15
|
-
passphrase: `${process.env.CLOB_PASS_PHRASE}`,
|
|
16
|
-
};
|
|
17
|
-
const clobClient = new ClobClient(host, wallet, creds);
|
|
18
|
-
// Create a buy order for 100 YES for 0.50c
|
|
19
|
-
const order = await clobClient.createLimitOrder({
|
|
20
|
-
asset: {
|
|
21
|
-
address: "0xadbeD21409324e0fcB80AE8b5e662B0C857D85ed",
|
|
22
|
-
condition: "YES",
|
|
23
|
-
},
|
|
24
|
-
price: 0.5,
|
|
25
|
-
side: Side.BUY,
|
|
26
|
-
size: 100,
|
|
27
|
-
});
|
|
28
|
-
// Send it to the server
|
|
29
|
-
const resp = await clobClient.postLimitOrder(order);
|
|
30
|
-
console.log(resp);
|
|
31
|
-
console.log(`Done!`);
|
|
32
|
-
}
|
|
33
|
-
main();
|
|
34
|
-
//# sourceMappingURL=createOrder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOrder.js","sourceRoot":"","sources":["../../examples/createOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAe,UAAU,EAAE,IAAI,EAAE,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B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getApiKeys.d.ts","sourceRoot":"","sources":["../../examples/getApiKeys.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { config as dotenvConfig } from "dotenv";
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import { ClobClient } from "../src";
|
|
5
|
-
dotenvConfig({ path: resolve(__dirname, "../.env") });
|
|
6
|
-
async function main() {
|
|
7
|
-
const provider = new ethers.providers.JsonRpcProvider(process.env.ETH_RPC_URL);
|
|
8
|
-
const pk = new ethers.Wallet(`${process.env.PK}`);
|
|
9
|
-
const wallet = pk.connect(provider);
|
|
10
|
-
console.log(`Address: ${await wallet.getAddress()}`);
|
|
11
|
-
const host = "http://localhost:8080";
|
|
12
|
-
const creds = {
|
|
13
|
-
key: `${process.env.CLOB_API_KEY}`,
|
|
14
|
-
secret: `${process.env.CLOB_SECRET}`,
|
|
15
|
-
passphrase: `${process.env.CLOB_PASS_PHRASE}`,
|
|
16
|
-
};
|
|
17
|
-
const clobClient = new ClobClient(host, wallet, creds);
|
|
18
|
-
console.log(`Response: `);
|
|
19
|
-
const resp = await clobClient.getApiKeys();
|
|
20
|
-
console.log(resp);
|
|
21
|
-
}
|
|
22
|
-
main();
|
|
23
|
-
//# sourceMappingURL=getApiKeys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getApiKeys.js","sourceRoot":"","sources":["../../examples/getApiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EA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|
2
|
-
import { config as dotenvConfig } from "dotenv";
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import { ClobClient } from "../src";
|
|
5
|
-
dotenvConfig({ path: resolve(__dirname, "../.env") });
|
|
6
|
-
async function main() {
|
|
7
|
-
const provider = new ethers.providers.JsonRpcProvider(process.env.ETH_RPC_URL);
|
|
8
|
-
const pk = new ethers.Wallet(`${process.env.PK}`);
|
|
9
|
-
const wallet = pk.connect(provider);
|
|
10
|
-
console.log(`Address: ${await wallet.getAddress()}`);
|
|
11
|
-
const host = "http://localhost:8080";
|
|
12
|
-
const creds = {
|
|
13
|
-
key: `${process.env.CLOB_API_KEY}`,
|
|
14
|
-
secret: `${process.env.CLOB_SECRET}`,
|
|
15
|
-
passphrase: `${process.env.CLOB_PASS_PHRASE}`,
|
|
16
|
-
};
|
|
17
|
-
const clobClient = new ClobClient(host, wallet, creds);
|
|
18
|
-
const resp = await clobClient.getOpenOrders();
|
|
19
|
-
console.log(resp);
|
|
20
|
-
console.log(`Done!`);
|
|
21
|
-
}
|
|
22
|
-
main();
|
|
23
|
-
//# sourceMappingURL=getOpenOrders.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getOpenOrders.js","sourceRoot":"","sources":["../../examples/getOpenOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAe,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEjD,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAEtD,KAAK,UAAU,IAAI;IACf,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW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