@polymarket/clob-client-v2 0.0.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 +21 -0
- package/README.md +1 -0
- package/dist/client.d.ts +125 -0
- package/dist/client.js +999 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +37 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +13 -0
- package/dist/constants.js.map +1 -0
- package/dist/endpoints.d.ts +52 -0
- package/dist/endpoints.js +68 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/headers/index.d.ts +5 -0
- package/dist/headers/index.js +43 -0
- package/dist/headers/index.js.map +1 -0
- package/dist/http-helpers/index.d.ts +18 -0
- package/dist/http-helpers/index.js +112 -0
- package/dist/http-helpers/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.d.ts +6 -0
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js +32 -0
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js.map +1 -0
- package/dist/order-builder/helpers/buildOrder.d.ts +15 -0
- package/dist/order-builder/helpers/buildOrder.js +36 -0
- package/dist/order-builder/helpers/buildOrder.js.map +1 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.d.ts +6 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.js +32 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.js.map +1 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.d.ts +8 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js +38 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js.map +1 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.d.ts +8 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.js +38 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.js.map +1 -0
- package/dist/order-builder/helpers/createMarketOrder.d.ts +6 -0
- package/dist/order-builder/helpers/createMarketOrder.js +40 -0
- package/dist/order-builder/helpers/createMarketOrder.js.map +1 -0
- package/dist/order-builder/helpers/createOrder.d.ts +6 -0
- package/dist/order-builder/helpers/createOrder.js +40 -0
- package/dist/order-builder/helpers/createOrder.js.map +1 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.d.ts +6 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js +41 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js.map +1 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.d.ts +6 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.js +41 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.js.map +1 -0
- package/dist/order-builder/helpers/index.d.ts +10 -0
- package/dist/order-builder/helpers/index.js +24 -0
- package/dist/order-builder/helpers/index.js.map +1 -0
- package/dist/order-builder/helpers/roundingConfig.d.ts +2 -0
- package/dist/order-builder/helpers/roundingConfig.js +26 -0
- package/dist/order-builder/helpers/roundingConfig.js.map +1 -0
- package/dist/order-builder/index.d.ts +1 -0
- package/dist/order-builder/index.js +5 -0
- package/dist/order-builder/index.js.map +1 -0
- package/dist/order-builder/orderBuilder.d.ts +29 -0
- package/dist/order-builder/orderBuilder.js +47 -0
- package/dist/order-builder/orderBuilder.js.map +1 -0
- package/dist/order-utils/abi/ExchangeV1.d.ts +1444 -0
- package/dist/order-utils/abi/ExchangeV1.js +1856 -0
- package/dist/order-utils/abi/ExchangeV1.js.map +1 -0
- package/dist/order-utils/abi/ExchangeV2.d.ts +1116 -0
- package/dist/order-utils/abi/ExchangeV2.js +1433 -0
- package/dist/order-utils/abi/ExchangeV2.js.map +1 -0
- package/dist/order-utils/exchangeOrderBuilderV1.d.ts +43 -0
- package/dist/order-utils/exchangeOrderBuilderV1.js +143 -0
- package/dist/order-utils/exchangeOrderBuilderV1.js.map +1 -0
- package/dist/order-utils/exchangeOrderBuilderV2.d.ts +43 -0
- package/dist/order-utils/exchangeOrderBuilderV2.js +114 -0
- package/dist/order-utils/exchangeOrderBuilderV2.js.map +1 -0
- package/dist/order-utils/index.d.ts +8 -0
- package/dist/order-utils/index.js +13 -0
- package/dist/order-utils/index.js.map +1 -0
- package/dist/order-utils/model/abi.d.ts +21 -0
- package/dist/order-utils/model/abi.js +3 -0
- package/dist/order-utils/model/abi.js.map +1 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.d.ts +6 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.js +20 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.js.map +1 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.d.ts +6 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.js +19 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.js.map +1 -0
- package/dist/order-utils/model/eip712.d.ts +29 -0
- package/dist/order-utils/model/eip712.js +10 -0
- package/dist/order-utils/model/eip712.js.map +1 -0
- package/dist/order-utils/model/order.d.ts +2 -0
- package/dist/order-utils/model/order.js +3 -0
- package/dist/order-utils/model/order.js.map +1 -0
- package/dist/order-utils/model/orderDataV1.d.ts +111 -0
- package/dist/order-utils/model/orderDataV1.js +3 -0
- package/dist/order-utils/model/orderDataV1.js.map +1 -0
- package/dist/order-utils/model/orderDataV2.d.ts +111 -0
- package/dist/order-utils/model/orderDataV2.js +3 -0
- package/dist/order-utils/model/orderDataV2.js.map +1 -0
- package/dist/order-utils/model/side.d.ts +8 -0
- package/dist/order-utils/model/side.js +14 -0
- package/dist/order-utils/model/side.js.map +1 -0
- package/dist/order-utils/model/signatureTypeV1.d.ts +14 -0
- package/dist/order-utils/model/signatureTypeV1.js +19 -0
- package/dist/order-utils/model/signatureTypeV1.js.map +1 -0
- package/dist/order-utils/model/signatureTypeV2.d.ts +18 -0
- package/dist/order-utils/model/signatureTypeV2.js +23 -0
- package/dist/order-utils/model/signatureTypeV2.js.map +1 -0
- package/dist/order-utils/utils.d.ts +1 -0
- package/dist/order-utils/utils.js +7 -0
- package/dist/order-utils/utils.js.map +1 -0
- package/dist/signing/constants.d.ts +14 -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.js +39 -0
- package/dist/signing/eip712.js.map +1 -0
- package/dist/signing/hmac.d.ts +9 -0
- package/dist/signing/hmac.js +32 -0
- package/dist/signing/hmac.js.map +1 -0
- package/dist/signing/index.d.ts +2 -0
- package/dist/signing/index.js +6 -0
- package/dist/signing/index.js.map +1 -0
- package/dist/types/clob.d.ts +377 -0
- package/dist/types/clob.js +31 -0
- package/dist/types/clob.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ordersV1.d.ts +106 -0
- package/dist/types/ordersV1.js +3 -0
- package/dist/types/ordersV1.js.map +1 -0
- package/dist/types/ordersV2.d.ts +89 -0
- package/dist/types/ordersV2.js +3 -0
- package/dist/types/ordersV2.js.map +1 -0
- package/dist/types/unifiedOrder.d.ts +34 -0
- package/dist/types/unifiedOrder.js +12 -0
- package/dist/types/unifiedOrder.js.map +1 -0
- package/dist/utilities.d.ts +17 -0
- package/dist/utilities.js +120 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Side } from "../../types/index.ts";
|
|
2
|
+
import type { EIP712Object } from "./eip712.ts";
|
|
3
|
+
import type { OrderSignature } from "./order.ts";
|
|
4
|
+
import type { SignatureTypeV1 } from "./signatureTypeV1.ts";
|
|
5
|
+
export interface OrderDataV1 {
|
|
6
|
+
/**
|
|
7
|
+
* Maker of the order, i.e the source of funds for the order
|
|
8
|
+
*/
|
|
9
|
+
maker: string;
|
|
10
|
+
/**
|
|
11
|
+
* Address of the order taker. The zero address is used to indicate a public order
|
|
12
|
+
*/
|
|
13
|
+
taker: string;
|
|
14
|
+
/**
|
|
15
|
+
* Token Id of the CTF ERC1155 asset to be bought or sold.
|
|
16
|
+
* If BUY, this is the tokenId of the asset to be bought, i.e the makerAssetId
|
|
17
|
+
* If SELL, this is the tokenId of the asset to be sold, i.e the takerAssetId
|
|
18
|
+
*/
|
|
19
|
+
tokenId: string;
|
|
20
|
+
/**
|
|
21
|
+
* Maker amount, i.e the max amount of tokens to be sold
|
|
22
|
+
*/
|
|
23
|
+
makerAmount: string;
|
|
24
|
+
/**
|
|
25
|
+
* Taker amount, i.e the minimum amount of tokens to be received
|
|
26
|
+
*/
|
|
27
|
+
takerAmount: string;
|
|
28
|
+
/**
|
|
29
|
+
* The side of the order, BUY or SELL
|
|
30
|
+
*/
|
|
31
|
+
side: Side;
|
|
32
|
+
/**
|
|
33
|
+
* Fee rate, in basis points, charged to the order maker, charged on proceeds
|
|
34
|
+
*/
|
|
35
|
+
feeRateBps: string;
|
|
36
|
+
/**
|
|
37
|
+
* Nonce used for onchain cancellations
|
|
38
|
+
*/
|
|
39
|
+
nonce: string;
|
|
40
|
+
/**
|
|
41
|
+
* Signer of the order. Optional, if it is not present the signer is the maker of the order.
|
|
42
|
+
*/
|
|
43
|
+
signer?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Timestamp after which the order is expired.
|
|
46
|
+
* Optional, if it is not present the value is '0' (no expiration)
|
|
47
|
+
*/
|
|
48
|
+
expiration?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Signature type used by the Order. Default value 'EOA'
|
|
51
|
+
*/
|
|
52
|
+
signatureType?: SignatureTypeV1;
|
|
53
|
+
}
|
|
54
|
+
export interface OrderV1 extends EIP712Object {
|
|
55
|
+
/**
|
|
56
|
+
* Unique salt to ensure entropy
|
|
57
|
+
*/
|
|
58
|
+
readonly salt: string;
|
|
59
|
+
/**
|
|
60
|
+
* Maker of the order, i.e the source of funds for the order
|
|
61
|
+
*/
|
|
62
|
+
readonly maker: string;
|
|
63
|
+
/**
|
|
64
|
+
* Signer of the order
|
|
65
|
+
*/
|
|
66
|
+
readonly signer: string;
|
|
67
|
+
/**
|
|
68
|
+
* Address of the order taker. The zero address is used to indicate a public order
|
|
69
|
+
*/
|
|
70
|
+
readonly taker: string;
|
|
71
|
+
/**
|
|
72
|
+
* Token Id of the CTF ERC1155 asset to be bought or sold.
|
|
73
|
+
* If BUY, this is the tokenId of the asset to be bought, i.e the makerAssetId
|
|
74
|
+
* If SELL, this is the tokenId of the asset to be sold, i.e the takerAssetId
|
|
75
|
+
*/
|
|
76
|
+
readonly tokenId: string;
|
|
77
|
+
/**
|
|
78
|
+
* Maker amount, i.e the max amount of tokens to be sold
|
|
79
|
+
*/
|
|
80
|
+
readonly makerAmount: string;
|
|
81
|
+
/**
|
|
82
|
+
* Taker amount, i.e the minimum amount of tokens to be received
|
|
83
|
+
*/
|
|
84
|
+
readonly takerAmount: string;
|
|
85
|
+
/**
|
|
86
|
+
* Timestamp after which the order is expired
|
|
87
|
+
*/
|
|
88
|
+
readonly expiration: string;
|
|
89
|
+
/**
|
|
90
|
+
* Nonce used for onchain cancellations
|
|
91
|
+
*/
|
|
92
|
+
readonly nonce: string;
|
|
93
|
+
/**
|
|
94
|
+
* Fee rate, in basis points, charged to the order maker, charged on proceeds
|
|
95
|
+
*/
|
|
96
|
+
readonly feeRateBps: string;
|
|
97
|
+
/**
|
|
98
|
+
* The side of the order, BUY or SELL
|
|
99
|
+
*/
|
|
100
|
+
readonly side: Side;
|
|
101
|
+
/**
|
|
102
|
+
* Signature type used by the Order
|
|
103
|
+
*/
|
|
104
|
+
readonly signatureType: SignatureTypeV1;
|
|
105
|
+
}
|
|
106
|
+
export interface SignedOrderV1 extends OrderV1 {
|
|
107
|
+
/**
|
|
108
|
+
* The order signature
|
|
109
|
+
*/
|
|
110
|
+
readonly signature: OrderSignature;
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderDataV1.js","sourceRoot":"","sources":["../../../src/order-utils/model/orderDataV1.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Side } from "../../types/index.ts";
|
|
2
|
+
import type { EIP712Object } from "./eip712.ts";
|
|
3
|
+
import type { OrderSignature } from "./order.ts";
|
|
4
|
+
import type { SignatureTypeV2 } from "./signatureTypeV2.ts";
|
|
5
|
+
export interface OrderDataV2 {
|
|
6
|
+
/**
|
|
7
|
+
* Maker of the order, i.e the source of funds for the order
|
|
8
|
+
*/
|
|
9
|
+
maker: string;
|
|
10
|
+
/**
|
|
11
|
+
* Token Id of the CTF ERC1155 asset to be bought or sold.
|
|
12
|
+
* If BUY, this is the tokenId of the asset to be bought, i.e the makerAssetId
|
|
13
|
+
* If SELL, this is the tokenId of the asset to be sold, i.e the takerAssetId
|
|
14
|
+
*/
|
|
15
|
+
tokenId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Maker amount, i.e the max amount of tokens to be sold
|
|
18
|
+
*/
|
|
19
|
+
makerAmount: string;
|
|
20
|
+
/**
|
|
21
|
+
* Taker amount, i.e the minimum amount of tokens to be received
|
|
22
|
+
*/
|
|
23
|
+
takerAmount: string;
|
|
24
|
+
/**
|
|
25
|
+
* The side of the order, BUY or SELL
|
|
26
|
+
*/
|
|
27
|
+
side: Side;
|
|
28
|
+
/**
|
|
29
|
+
* Signer of the order. Optional, if it is not present the signer is the maker of the order.
|
|
30
|
+
*/
|
|
31
|
+
signer?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Timestamp after which the order is expired.
|
|
34
|
+
* Optional, if it is not present the value is '0' (no expiration)
|
|
35
|
+
*/
|
|
36
|
+
expiration?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Signature type used by the Order. Default value 'EOA'
|
|
39
|
+
*/
|
|
40
|
+
signatureType?: SignatureTypeV2;
|
|
41
|
+
/**
|
|
42
|
+
* Timestamp of the order
|
|
43
|
+
*/
|
|
44
|
+
timestamp?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Metadata of the order
|
|
47
|
+
*/
|
|
48
|
+
readonly metadata?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Builder of the order
|
|
51
|
+
*/
|
|
52
|
+
readonly builder?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface OrderV2 extends EIP712Object {
|
|
55
|
+
/**
|
|
56
|
+
* Unique salt to ensure entropy
|
|
57
|
+
*/
|
|
58
|
+
readonly salt: string;
|
|
59
|
+
/**
|
|
60
|
+
* Maker of the order, i.e the source of funds for the order
|
|
61
|
+
*/
|
|
62
|
+
readonly maker: string;
|
|
63
|
+
/**
|
|
64
|
+
* Signer of the order
|
|
65
|
+
*/
|
|
66
|
+
readonly signer: string;
|
|
67
|
+
/**
|
|
68
|
+
* Token Id of the CTF ERC1155 asset to be bought or sold.
|
|
69
|
+
* If BUY, this is the tokenId of the asset to be bought, i.e the makerAssetId
|
|
70
|
+
* If SELL, this is the tokenId of the asset to be sold, i.e the takerAssetId
|
|
71
|
+
*/
|
|
72
|
+
readonly tokenId: string;
|
|
73
|
+
/**
|
|
74
|
+
* Maker amount, i.e the max amount of tokens to be sold
|
|
75
|
+
*/
|
|
76
|
+
readonly makerAmount: string;
|
|
77
|
+
/**
|
|
78
|
+
* Taker amount, i.e the minimum amount of tokens to be received
|
|
79
|
+
*/
|
|
80
|
+
readonly takerAmount: string;
|
|
81
|
+
/**
|
|
82
|
+
* Timestamp after which the order is expired
|
|
83
|
+
*/
|
|
84
|
+
readonly expiration: string;
|
|
85
|
+
/**
|
|
86
|
+
* The side of the order, BUY or SELL
|
|
87
|
+
*/
|
|
88
|
+
readonly side: Side;
|
|
89
|
+
/**
|
|
90
|
+
* Signature type used by the Order
|
|
91
|
+
*/
|
|
92
|
+
readonly signatureType: SignatureTypeV2;
|
|
93
|
+
/**
|
|
94
|
+
* Timestamp of the order
|
|
95
|
+
*/
|
|
96
|
+
readonly timestamp: string;
|
|
97
|
+
/**
|
|
98
|
+
* Metadata of the order
|
|
99
|
+
*/
|
|
100
|
+
readonly metadata: string;
|
|
101
|
+
/**
|
|
102
|
+
* Builder of the order
|
|
103
|
+
*/
|
|
104
|
+
readonly builder: string;
|
|
105
|
+
}
|
|
106
|
+
export interface SignedOrderV2 extends OrderV2 {
|
|
107
|
+
/**
|
|
108
|
+
* The order signature
|
|
109
|
+
*/
|
|
110
|
+
readonly signature: OrderSignature;
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderDataV2.js","sourceRoot":"","sources":["../../../src/order-utils/model/orderDataV2.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SideString = exports.Side = void 0;
|
|
4
|
+
var Side;
|
|
5
|
+
(function (Side) {
|
|
6
|
+
Side[Side["BUY"] = 0] = "BUY";
|
|
7
|
+
Side[Side["SELL"] = 1] = "SELL";
|
|
8
|
+
})(Side || (exports.Side = Side = {}));
|
|
9
|
+
var SideString;
|
|
10
|
+
(function (SideString) {
|
|
11
|
+
SideString["BUY"] = "BUY";
|
|
12
|
+
SideString["SELL"] = "SELL";
|
|
13
|
+
})(SideString || (exports.SideString = SideString = {}));
|
|
14
|
+
//# sourceMappingURL=side.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side.js","sourceRoot":"","sources":["../../../src/order-utils/model/side.ts"],"names":[],"mappings":";;;AAAA,IAAY,IAGX;AAHD,WAAY,IAAI;IACf,6BAAG,CAAA;IACH,+BAAI,CAAA;AACL,CAAC,EAHW,IAAI,oBAAJ,IAAI,QAGf;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACrB,yBAAW,CAAA;IACX,2BAAa,CAAA;AACd,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum SignatureTypeV1 {
|
|
2
|
+
/**
|
|
3
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
4
|
+
*/
|
|
5
|
+
EOA = 0,
|
|
6
|
+
/**
|
|
7
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
8
|
+
*/
|
|
9
|
+
POLY_PROXY = 1,
|
|
10
|
+
/**
|
|
11
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
12
|
+
*/
|
|
13
|
+
POLY_GNOSIS_SAFE = 2
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignatureTypeV1 = void 0;
|
|
4
|
+
var SignatureTypeV1;
|
|
5
|
+
(function (SignatureTypeV1) {
|
|
6
|
+
/**
|
|
7
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
8
|
+
*/
|
|
9
|
+
SignatureTypeV1[SignatureTypeV1["EOA"] = 0] = "EOA";
|
|
10
|
+
/**
|
|
11
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
12
|
+
*/
|
|
13
|
+
SignatureTypeV1[SignatureTypeV1["POLY_PROXY"] = 1] = "POLY_PROXY";
|
|
14
|
+
/**
|
|
15
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
16
|
+
*/
|
|
17
|
+
SignatureTypeV1[SignatureTypeV1["POLY_GNOSIS_SAFE"] = 2] = "POLY_GNOSIS_SAFE";
|
|
18
|
+
})(SignatureTypeV1 || (exports.SignatureTypeV1 = SignatureTypeV1 = {}));
|
|
19
|
+
//# sourceMappingURL=signatureTypeV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureTypeV1.js","sourceRoot":"","sources":["../../../src/order-utils/model/signatureTypeV1.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAeX;AAfD,WAAY,eAAe;IAC1B;;OAEG;IACH,mDAAO,CAAA;IAEP;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;AACrB,CAAC,EAfW,eAAe,+BAAf,eAAe,QAe1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum SignatureTypeV2 {
|
|
2
|
+
/**
|
|
3
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
4
|
+
*/
|
|
5
|
+
EOA = 0,
|
|
6
|
+
/**
|
|
7
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
8
|
+
*/
|
|
9
|
+
POLY_PROXY = 1,
|
|
10
|
+
/**
|
|
11
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
12
|
+
*/
|
|
13
|
+
POLY_GNOSIS_SAFE = 2,
|
|
14
|
+
/**
|
|
15
|
+
* EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
|
|
16
|
+
*/
|
|
17
|
+
POLY_1271 = 3
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignatureTypeV2 = void 0;
|
|
4
|
+
var SignatureTypeV2;
|
|
5
|
+
(function (SignatureTypeV2) {
|
|
6
|
+
/**
|
|
7
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
8
|
+
*/
|
|
9
|
+
SignatureTypeV2[SignatureTypeV2["EOA"] = 0] = "EOA";
|
|
10
|
+
/**
|
|
11
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
12
|
+
*/
|
|
13
|
+
SignatureTypeV2[SignatureTypeV2["POLY_PROXY"] = 1] = "POLY_PROXY";
|
|
14
|
+
/**
|
|
15
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
16
|
+
*/
|
|
17
|
+
SignatureTypeV2[SignatureTypeV2["POLY_GNOSIS_SAFE"] = 2] = "POLY_GNOSIS_SAFE";
|
|
18
|
+
/**
|
|
19
|
+
* EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
|
|
20
|
+
*/
|
|
21
|
+
SignatureTypeV2[SignatureTypeV2["POLY_1271"] = 3] = "POLY_1271";
|
|
22
|
+
})(SignatureTypeV2 || (exports.SignatureTypeV2 = SignatureTypeV2 = {}));
|
|
23
|
+
//# sourceMappingURL=signatureTypeV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureTypeV2.js","sourceRoot":"","sources":["../../../src/order-utils/model/signatureTypeV2.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAoBX;AApBD,WAAY,eAAe;IAC1B;;OAEG;IACH,mDAAO,CAAA;IAEP;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;IAEpB;;OAEG;IACH,+DAAa,CAAA;AACd,CAAC,EApBW,eAAe,+BAAf,eAAe,QAoB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateOrderSalt(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/order-utils/utils.ts"],"names":[],"mappings":";;AAAA,8CAEC;AAFD,SAAgB,iBAAiB;IAChC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CLOB_DOMAIN_NAME = "ClobAuthDomain";
|
|
2
|
+
export declare const CLOB_VERSION = "1";
|
|
3
|
+
export declare const MSG_TO_SIGN = "This message attests that I control the given wallet";
|
|
4
|
+
export declare const CLOB_DOMAIN: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
chainId: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const CLOB_TYPES: {
|
|
10
|
+
ClobAuth: {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
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,
|
|
10
|
+
chainId: 1,
|
|
11
|
+
};
|
|
12
|
+
exports.CLOB_TYPES = {
|
|
13
|
+
ClobAuth: [
|
|
14
|
+
{ name: "address", type: "address" },
|
|
15
|
+
{ name: "timestamp", type: "string" },
|
|
16
|
+
{ name: "message", type: "string" },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;IAC1B,IAAI,EAAE,wBAAgB;IACtB,OAAO,EAAE,oBAAY;IACrB,OAAO,EAAE,CAAC;CACV,CAAC;AAEW,QAAA,UAAU,GAAG;IACzB,QAAQ,EAAE;QACT,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;KACnC;CACD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JsonRpcSigner } from "@ethersproject/providers";
|
|
2
|
+
import type { Wallet } from "@ethersproject/wallet";
|
|
3
|
+
import type { Chain } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
6
|
+
* @param signer
|
|
7
|
+
* @param ts
|
|
8
|
+
* @returns string
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildClobEip712Signature: (signer: Wallet | JsonRpcSigner, chainId: Chain, timestamp: number, nonce: number) => Promise<string>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildClobEip712Signature = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
8
|
+
* @param signer
|
|
9
|
+
* @param ts
|
|
10
|
+
* @returns string
|
|
11
|
+
*/
|
|
12
|
+
const buildClobEip712Signature = (signer, chainId, timestamp, nonce) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const address = yield signer.getAddress();
|
|
14
|
+
const ts = timestamp.toString();
|
|
15
|
+
const domain = {
|
|
16
|
+
name: "ClobAuthDomain",
|
|
17
|
+
version: "1",
|
|
18
|
+
chainId: chainId,
|
|
19
|
+
};
|
|
20
|
+
const types = {
|
|
21
|
+
ClobAuth: [
|
|
22
|
+
{ name: "address", type: "address" },
|
|
23
|
+
{ name: "timestamp", type: "string" },
|
|
24
|
+
{ name: "nonce", type: "uint256" },
|
|
25
|
+
{ name: "message", type: "string" },
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
const value = {
|
|
29
|
+
address,
|
|
30
|
+
timestamp: ts,
|
|
31
|
+
nonce,
|
|
32
|
+
message: constants_1.MSG_TO_SIGN,
|
|
33
|
+
};
|
|
34
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
35
|
+
const sig = yield signer._signTypedData(domain, types, value);
|
|
36
|
+
return sig;
|
|
37
|
+
});
|
|
38
|
+
exports.buildClobEip712Signature = buildClobEip712Signature;
|
|
39
|
+
//# sourceMappingURL=eip712.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":";;;;AAKA,2CAA0C;AAE1C;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CACvC,MAA8B,EAC9B,OAAc,EACd,SAAiB,EACjB,KAAa,EACK,EAAE;IACpB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1C,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;IAEhC,MAAM,MAAM,GAAG;QACd,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,OAAO;KAChB,CAAC;IAEF,MAAM,KAAK,GAAG;QACb,QAAQ,EAAE;YACT,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;YACrC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;SACnC;KACD,CAAC;IACF,MAAM,KAAK,GAAG;QACb,OAAO;QACP,SAAS,EAAE,EAAE;QACb,KAAK;QACL,OAAO,EAAE,uBAAW;KACpB,CAAC;IACF,gDAAgD;IAChD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACZ,CAAC,CAAA,CAAC;AAhCW,QAAA,wBAAwB,4BAgCnC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the canonical Polymarket CLOB HMAC signature
|
|
3
|
+
* @param signer
|
|
4
|
+
* @param key
|
|
5
|
+
* @param secret
|
|
6
|
+
* @param passphrase
|
|
7
|
+
* @returns string
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildPolyHmacSignature: (secret: string, timestamp: number, method: string, requestPath: string, body?: string) => string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildPolyHmacSignature = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
6
|
+
function replaceAll(s, search, replace) {
|
|
7
|
+
return s.split(search).join(replace);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Builds the canonical Polymarket CLOB HMAC signature
|
|
11
|
+
* @param signer
|
|
12
|
+
* @param key
|
|
13
|
+
* @param secret
|
|
14
|
+
* @param passphrase
|
|
15
|
+
* @returns string
|
|
16
|
+
*/
|
|
17
|
+
const buildPolyHmacSignature = (secret, timestamp, method, requestPath, body) => {
|
|
18
|
+
let message = timestamp + method + requestPath;
|
|
19
|
+
if (body !== undefined) {
|
|
20
|
+
message += body;
|
|
21
|
+
}
|
|
22
|
+
const base64Secret = Buffer.from(secret, "base64");
|
|
23
|
+
const hmac = node_crypto_1.default.createHmac("sha256", base64Secret);
|
|
24
|
+
const sig = hmac.update(message).digest("base64");
|
|
25
|
+
// NOTE: Must be url safe base64 encoding, but keep base64 "=" suffix
|
|
26
|
+
// Convert '+' to '-'
|
|
27
|
+
// Convert '/' to '_'
|
|
28
|
+
const sigUrlSafe = replaceAll(replaceAll(sig, "+", "-"), "/", "_");
|
|
29
|
+
return sigUrlSafe;
|
|
30
|
+
};
|
|
31
|
+
exports.buildPolyHmacSignature = buildPolyHmacSignature;
|
|
32
|
+
//# sourceMappingURL=hmac.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":";;;;AAAA,sEAAiC;AAEjC,SAAS,UAAU,CAAC,CAAS,EAAE,MAAc,EAAE,OAAe;IAC7D,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,WAAmB,EACnB,IAAa,EACJ,EAAE;IACX,IAAI,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;IAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,IAAI,CAAC;IACjB,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,qBAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,qEAAqE;IACrE,qBAAqB;IACrB,qBAAqB;IACrB,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AApBW,QAAA,sBAAsB,0BAoBjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,iDAAuB"}
|