@polymarket/clob-client-v2 1.0.5 → 1.0.6-pr79.0
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 +3 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/client.cjs +886 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +165 -0
- package/dist/client.d.ts +167 -0
- package/dist/client.js +886 -0
- package/dist/client.js.map +1 -0
- package/dist/config.cjs +37 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +17 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +34 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.cjs +15 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -0
- package/dist/endpoints.cjs +125 -0
- package/dist/endpoints.cjs.map +1 -0
- package/dist/endpoints.js +65 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/errors.cjs +20 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +11 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/fees/index.cjs +21 -0
- package/dist/fees/index.cjs.map +1 -0
- package/dist/fees/index.d.cts +5 -0
- package/dist/fees/index.d.ts +5 -0
- package/dist/fees/index.js +19 -0
- package/dist/fees/index.js.map +1 -0
- package/dist/headers/index.cjs +34 -0
- package/dist/headers/index.cjs.map +1 -0
- package/dist/headers/index.d.cts +9 -0
- package/dist/headers/index.d.ts +11 -0
- package/dist/headers/index.js +33 -0
- package/dist/headers/index.js.map +1 -0
- package/dist/http-helpers/index.cjs +109 -0
- package/dist/http-helpers/index.cjs.map +1 -0
- package/dist/http-helpers/index.js +101 -0
- package/dist/http-helpers/index.js.map +1 -0
- package/dist/index.cjs +35 -2620
- package/dist/index.d.cts +14 -1039
- package/dist/index.d.ts +16 -1039
- package/dist/index.js +15 -2563
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.cjs +43 -0
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.cjs.map +1 -0
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js +42 -0
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js.map +1 -0
- package/dist/order-builder/helpers/buildOrder.cjs +34 -0
- package/dist/order-builder/helpers/buildOrder.cjs.map +1 -0
- package/dist/order-builder/helpers/buildOrder.js +34 -0
- package/dist/order-builder/helpers/buildOrder.js.map +1 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.cjs +45 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.cjs.map +1 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.js +44 -0
- package/dist/order-builder/helpers/buildOrderCreationArgs.js.map +1 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.cjs +24 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.cjs.map +1 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js +24 -0
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js.map +1 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.cjs +24 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.cjs.map +1 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.js +24 -0
- package/dist/order-builder/helpers/calculateSellMarketPrice.js.map +1 -0
- package/dist/order-builder/helpers/createMarketOrder.cjs +34 -0
- package/dist/order-builder/helpers/createMarketOrder.cjs.map +1 -0
- package/dist/order-builder/helpers/createMarketOrder.js +34 -0
- package/dist/order-builder/helpers/createMarketOrder.js.map +1 -0
- package/dist/order-builder/helpers/createOrder.cjs +34 -0
- package/dist/order-builder/helpers/createOrder.cjs.map +1 -0
- package/dist/order-builder/helpers/createOrder.js +34 -0
- package/dist/order-builder/helpers/createOrder.js.map +1 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.cjs +36 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.cjs.map +1 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js +36 -0
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js.map +1 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.cjs +36 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.cjs.map +1 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.js +36 -0
- package/dist/order-builder/helpers/getOrderRawAmounts.js.map +1 -0
- package/dist/order-builder/helpers/roundingConfig.cjs +28 -0
- package/dist/order-builder/helpers/roundingConfig.cjs.map +1 -0
- package/dist/order-builder/helpers/roundingConfig.js +27 -0
- package/dist/order-builder/helpers/roundingConfig.js.map +1 -0
- package/dist/order-builder/index.d.ts +1 -0
- package/dist/order-builder/orderBuilder.cjs +51 -0
- package/dist/order-builder/orderBuilder.cjs.map +1 -0
- package/dist/order-builder/orderBuilder.d.cts +37 -0
- package/dist/order-builder/orderBuilder.d.ts +39 -0
- package/dist/order-builder/orderBuilder.js +51 -0
- package/dist/order-builder/orderBuilder.js.map +1 -0
- package/dist/order-utils/exchangeOrderBuilderV1.cjs +128 -0
- package/dist/order-utils/exchangeOrderBuilderV1.cjs.map +1 -0
- package/dist/order-utils/exchangeOrderBuilderV1.d.ts +2 -0
- package/dist/order-utils/exchangeOrderBuilderV1.js +127 -0
- package/dist/order-utils/exchangeOrderBuilderV1.js.map +1 -0
- package/dist/order-utils/exchangeOrderBuilderV2.cjs +196 -0
- package/dist/order-utils/exchangeOrderBuilderV2.cjs.map +1 -0
- package/dist/order-utils/exchangeOrderBuilderV2.d.ts +2 -0
- package/dist/order-utils/exchangeOrderBuilderV2.js +194 -0
- package/dist/order-utils/exchangeOrderBuilderV2.js.map +1 -0
- package/dist/order-utils/index.d.ts +7 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.cjs +60 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.cjs.map +1 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.js +57 -0
- package/dist/order-utils/model/ctfExchangeV1TypedData.js.map +1 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.cjs +58 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.cjs.map +1 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.js +54 -0
- package/dist/order-utils/model/ctfExchangeV2TypedData.js.map +1 -0
- package/dist/order-utils/model/eip712.cjs +24 -0
- package/dist/order-utils/model/eip712.cjs.map +1 -0
- package/dist/order-utils/model/eip712.d.cts +9 -0
- package/dist/order-utils/model/eip712.d.ts +9 -0
- package/dist/order-utils/model/eip712.js +23 -0
- package/dist/order-utils/model/eip712.js.map +1 -0
- package/dist/order-utils/model/order.d.cts +5 -0
- package/dist/order-utils/model/order.d.ts +5 -0
- package/dist/order-utils/model/orderDataV1.d.cts +68 -0
- package/dist/order-utils/model/orderDataV1.d.ts +69 -0
- package/dist/order-utils/model/orderDataV2.d.cts +68 -0
- package/dist/order-utils/model/orderDataV2.d.ts +69 -0
- package/dist/order-utils/model/side.cjs +11 -0
- package/dist/order-utils/model/side.cjs.map +1 -0
- package/dist/order-utils/model/side.d.cts +8 -0
- package/dist/order-utils/model/side.d.ts +8 -0
- package/dist/order-utils/model/side.js +10 -0
- package/dist/order-utils/model/side.js.map +1 -0
- package/dist/order-utils/model/signatureTypeV1.cjs +21 -0
- package/dist/order-utils/model/signatureTypeV1.cjs.map +1 -0
- package/dist/order-utils/model/signatureTypeV1.d.cts +18 -0
- package/dist/order-utils/model/signatureTypeV1.d.ts +18 -0
- package/dist/order-utils/model/signatureTypeV1.js +20 -0
- package/dist/order-utils/model/signatureTypeV1.js.map +1 -0
- package/dist/order-utils/model/signatureTypeV2.cjs +25 -0
- package/dist/order-utils/model/signatureTypeV2.cjs.map +1 -0
- package/dist/order-utils/model/signatureTypeV2.d.cts +22 -0
- package/dist/order-utils/model/signatureTypeV2.d.ts +22 -0
- package/dist/order-utils/model/signatureTypeV2.js +24 -0
- package/dist/order-utils/model/signatureTypeV2.js.map +1 -0
- package/dist/order-utils/utils.cjs +9 -0
- package/dist/order-utils/utils.cjs.map +1 -0
- package/dist/order-utils/utils.js +8 -0
- package/dist/order-utils/utils.js.map +1 -0
- package/dist/signing/constants.cjs +7 -0
- package/dist/signing/constants.cjs.map +1 -0
- package/dist/signing/constants.js +6 -0
- package/dist/signing/constants.js.map +1 -0
- package/dist/signing/eip712.cjs +51 -0
- package/dist/signing/eip712.cjs.map +1 -0
- package/dist/signing/eip712.d.ts +2 -0
- package/dist/signing/eip712.js +51 -0
- package/dist/signing/eip712.js.map +1 -0
- package/dist/signing/hmac.cjs +40 -0
- package/dist/signing/hmac.cjs.map +1 -0
- package/dist/signing/hmac.js +39 -0
- package/dist/signing/hmac.js.map +1 -0
- package/dist/signing/index.d.ts +2 -0
- package/dist/signing/signer.cjs +41 -0
- package/dist/signing/signer.cjs.map +1 -0
- package/dist/signing/signer.d.cts +17 -0
- package/dist/signing/signer.d.ts +17 -0
- package/dist/signing/signer.js +39 -0
- package/dist/signing/signer.js.map +1 -0
- package/dist/types/clob.cjs +35 -0
- package/dist/types/clob.cjs.map +1 -0
- package/dist/types/clob.d.cts +427 -0
- package/dist/types/clob.d.ts +427 -0
- package/dist/types/clob.js +32 -0
- package/dist/types/clob.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/ordersV1.cjs +29 -0
- package/dist/types/ordersV1.cjs.map +1 -0
- package/dist/types/ordersV1.d.cts +115 -0
- package/dist/types/ordersV1.d.ts +116 -0
- package/dist/types/ordersV1.js +28 -0
- package/dist/types/ordersV1.js.map +1 -0
- package/dist/types/ordersV2.cjs +30 -0
- package/dist/types/ordersV2.cjs.map +1 -0
- package/dist/types/ordersV2.d.cts +113 -0
- package/dist/types/ordersV2.d.ts +114 -0
- package/dist/types/ordersV2.js +29 -0
- package/dist/types/ordersV2.js.map +1 -0
- package/dist/types/unifiedOrder.cjs +10 -0
- package/dist/types/unifiedOrder.cjs.map +1 -0
- package/dist/types/unifiedOrder.d.cts +56 -0
- package/dist/types/unifiedOrder.d.ts +57 -0
- package/dist/types/unifiedOrder.js +9 -0
- package/dist/types/unifiedOrder.js.map +1 -0
- package/dist/utilities.cjs +50 -0
- package/dist/utilities.cjs.map +1 -0
- package/dist/utilities.js +43 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +3 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/order-utils/model/signatureTypeV1.ts
|
|
2
|
+
let SignatureTypeV1 = /* @__PURE__ */ function(SignatureTypeV1$1) {
|
|
3
|
+
/**
|
|
4
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
5
|
+
*/
|
|
6
|
+
SignatureTypeV1$1[SignatureTypeV1$1["EOA"] = 0] = "EOA";
|
|
7
|
+
/**
|
|
8
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
9
|
+
*/
|
|
10
|
+
SignatureTypeV1$1[SignatureTypeV1$1["POLY_PROXY"] = 1] = "POLY_PROXY";
|
|
11
|
+
/**
|
|
12
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
13
|
+
*/
|
|
14
|
+
SignatureTypeV1$1[SignatureTypeV1$1["POLY_GNOSIS_SAFE"] = 2] = "POLY_GNOSIS_SAFE";
|
|
15
|
+
return SignatureTypeV1$1;
|
|
16
|
+
}({});
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { SignatureTypeV1 };
|
|
20
|
+
//# sourceMappingURL=signatureTypeV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureTypeV1.js","names":[],"sources":["../../../src/order-utils/model/signatureTypeV1.ts"],"sourcesContent":["export enum SignatureTypeV1 {\n\t/**\n\t * ECDSA EIP712 signatures signed by EOAs\n\t */\n\tEOA = 0,\n\n\t/**\n\t * EIP712 signatures signed by EOAs that own Polymarket Proxy wallets\n\t */\n\tPOLY_PROXY = 1,\n\n\t/**\n\t * EIP712 signatures signed by EOAs that own Polymarket Gnosis safes\n\t */\n\tPOLY_GNOSIS_SAFE = 2,\n}\n"],"mappings":";AAAA,IAAY,8DAAL;;;;AAIN;;;;AAKA;;;;AAKA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/order-utils/model/signatureTypeV2.ts
|
|
3
|
+
let SignatureTypeV2 = /* @__PURE__ */ function(SignatureTypeV2$1) {
|
|
4
|
+
/**
|
|
5
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
6
|
+
*/
|
|
7
|
+
SignatureTypeV2$1[SignatureTypeV2$1["EOA"] = 0] = "EOA";
|
|
8
|
+
/**
|
|
9
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
10
|
+
*/
|
|
11
|
+
SignatureTypeV2$1[SignatureTypeV2$1["POLY_PROXY"] = 1] = "POLY_PROXY";
|
|
12
|
+
/**
|
|
13
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
14
|
+
*/
|
|
15
|
+
SignatureTypeV2$1[SignatureTypeV2$1["POLY_GNOSIS_SAFE"] = 2] = "POLY_GNOSIS_SAFE";
|
|
16
|
+
/**
|
|
17
|
+
* EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
|
|
18
|
+
*/
|
|
19
|
+
SignatureTypeV2$1[SignatureTypeV2$1["POLY_1271"] = 3] = "POLY_1271";
|
|
20
|
+
return SignatureTypeV2$1;
|
|
21
|
+
}({});
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.SignatureTypeV2 = SignatureTypeV2;
|
|
25
|
+
//# sourceMappingURL=signatureTypeV2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureTypeV2.cjs","names":[],"sources":["../../../src/order-utils/model/signatureTypeV2.ts"],"sourcesContent":["export enum SignatureTypeV2 {\n\t/**\n\t * ECDSA EIP712 signatures signed by EOAs\n\t */\n\tEOA = 0,\n\n\t/**\n\t * EIP712 signatures signed by EOAs that own Polymarket Proxy wallets\n\t */\n\tPOLY_PROXY = 1,\n\n\t/**\n\t * EIP712 signatures signed by EOAs that own Polymarket Gnosis safes\n\t */\n\tPOLY_GNOSIS_SAFE = 2,\n\n\t/**\n\t * EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults\n\t */\n\tPOLY_1271 = 3,\n}\n"],"mappings":";;AAAA,IAAY,8DAAL;;;;AAIN;;;;AAKA;;;;AAKA;;;;AAKA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/order-utils/model/signatureTypeV2.d.ts
|
|
2
|
+
declare enum SignatureTypeV2 {
|
|
3
|
+
/**
|
|
4
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
5
|
+
*/
|
|
6
|
+
EOA = 0,
|
|
7
|
+
/**
|
|
8
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
9
|
+
*/
|
|
10
|
+
POLY_PROXY = 1,
|
|
11
|
+
/**
|
|
12
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
13
|
+
*/
|
|
14
|
+
POLY_GNOSIS_SAFE = 2,
|
|
15
|
+
/**
|
|
16
|
+
* EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
|
|
17
|
+
*/
|
|
18
|
+
POLY_1271 = 3,
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SignatureTypeV2 };
|
|
22
|
+
//# sourceMappingURL=signatureTypeV2.d.cts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/order-utils/model/signatureTypeV2.d.ts
|
|
2
|
+
declare enum SignatureTypeV2 {
|
|
3
|
+
/**
|
|
4
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
5
|
+
*/
|
|
6
|
+
EOA = 0,
|
|
7
|
+
/**
|
|
8
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
9
|
+
*/
|
|
10
|
+
POLY_PROXY = 1,
|
|
11
|
+
/**
|
|
12
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
13
|
+
*/
|
|
14
|
+
POLY_GNOSIS_SAFE = 2,
|
|
15
|
+
/**
|
|
16
|
+
* EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
|
|
17
|
+
*/
|
|
18
|
+
POLY_1271 = 3,
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SignatureTypeV2 };
|
|
22
|
+
//# sourceMappingURL=signatureTypeV2.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/order-utils/model/signatureTypeV2.ts
|
|
2
|
+
let SignatureTypeV2 = /* @__PURE__ */ function(SignatureTypeV2$1) {
|
|
3
|
+
/**
|
|
4
|
+
* ECDSA EIP712 signatures signed by EOAs
|
|
5
|
+
*/
|
|
6
|
+
SignatureTypeV2$1[SignatureTypeV2$1["EOA"] = 0] = "EOA";
|
|
7
|
+
/**
|
|
8
|
+
* EIP712 signatures signed by EOAs that own Polymarket Proxy wallets
|
|
9
|
+
*/
|
|
10
|
+
SignatureTypeV2$1[SignatureTypeV2$1["POLY_PROXY"] = 1] = "POLY_PROXY";
|
|
11
|
+
/**
|
|
12
|
+
* EIP712 signatures signed by EOAs that own Polymarket Gnosis safes
|
|
13
|
+
*/
|
|
14
|
+
SignatureTypeV2$1[SignatureTypeV2$1["POLY_GNOSIS_SAFE"] = 2] = "POLY_GNOSIS_SAFE";
|
|
15
|
+
/**
|
|
16
|
+
* EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults
|
|
17
|
+
*/
|
|
18
|
+
SignatureTypeV2$1[SignatureTypeV2$1["POLY_1271"] = 3] = "POLY_1271";
|
|
19
|
+
return SignatureTypeV2$1;
|
|
20
|
+
}({});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SignatureTypeV2 };
|
|
24
|
+
//# sourceMappingURL=signatureTypeV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureTypeV2.js","names":[],"sources":["../../../src/order-utils/model/signatureTypeV2.ts"],"sourcesContent":["export enum SignatureTypeV2 {\n\t/**\n\t * ECDSA EIP712 signatures signed by EOAs\n\t */\n\tEOA = 0,\n\n\t/**\n\t * EIP712 signatures signed by EOAs that own Polymarket Proxy wallets\n\t */\n\tPOLY_PROXY = 1,\n\n\t/**\n\t * EIP712 signatures signed by EOAs that own Polymarket Gnosis safes\n\t */\n\tPOLY_GNOSIS_SAFE = 2,\n\n\t/**\n\t * EIP1271 signatures signed by smart contracts. To be used by smart contract wallets or vaults\n\t */\n\tPOLY_1271 = 3,\n}\n"],"mappings":";AAAA,IAAY,8DAAL;;;;AAIN;;;;AAKA;;;;AAKA;;;;AAKA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../src/order-utils/utils.ts"],"sourcesContent":["export function generateOrderSalt(): string {\n\treturn `${Math.round(Math.random() * Date.now())}`;\n}\n"],"mappings":";;AAAA,SAAgB,oBAA4B;AAC3C,QAAO,GAAG,KAAK,MAAM,KAAK,QAAQ,GAAG,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/order-utils/utils.ts"],"sourcesContent":["export function generateOrderSalt(): string {\n\treturn `${Math.round(Math.random() * Date.now())}`;\n}\n"],"mappings":";AAAA,SAAgB,oBAA4B;AAC3C,QAAO,GAAG,KAAK,MAAM,KAAK,QAAQ,GAAG,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/signing/constants.ts"],"sourcesContent":["export const CLOB_DOMAIN_NAME = \"ClobAuthDomain\";\nexport const CLOB_VERSION = \"1\";\nexport const MSG_TO_SIGN = \"This message attests that I control the given wallet\";\n\nexport const CLOB_DOMAIN = {\n\tname: CLOB_DOMAIN_NAME,\n\tversion: CLOB_VERSION,\n\tchainId: 1,\n};\n\nexport const CLOB_TYPES = {\n\tClobAuth: [\n\t\t{ name: \"address\", type: \"address\" },\n\t\t{ name: \"timestamp\", type: \"string\" },\n\t\t{ name: \"message\", type: \"string\" },\n\t],\n};\n"],"mappings":";;AAEA,MAAa,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/signing/constants.ts"],"sourcesContent":["export const CLOB_DOMAIN_NAME = \"ClobAuthDomain\";\nexport const CLOB_VERSION = \"1\";\nexport const MSG_TO_SIGN = \"This message attests that I control the given wallet\";\n\nexport const CLOB_DOMAIN = {\n\tname: CLOB_DOMAIN_NAME,\n\tversion: CLOB_VERSION,\n\tchainId: 1,\n};\n\nexport const CLOB_TYPES = {\n\tClobAuth: [\n\t\t{ name: \"address\", type: \"address\" },\n\t\t{ name: \"timestamp\", type: \"string\" },\n\t\t{ name: \"message\", type: \"string\" },\n\t],\n};\n"],"mappings":";AAEA,MAAa,cAAc"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const require_constants = require('./constants.cjs');
|
|
2
|
+
const require_signer = require('./signer.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/signing/eip712.ts
|
|
5
|
+
/**
|
|
6
|
+
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
7
|
+
* @param signer
|
|
8
|
+
* @param ts
|
|
9
|
+
* @returns string
|
|
10
|
+
*/
|
|
11
|
+
const buildClobEip712Signature = async (signer, chainId, timestamp, nonce, address) => {
|
|
12
|
+
const resolvedAddress = address ?? await require_signer.getSignerAddress(signer);
|
|
13
|
+
const ts = timestamp.toString();
|
|
14
|
+
return await require_signer.signTypedDataWithSigner({
|
|
15
|
+
signer,
|
|
16
|
+
domain: {
|
|
17
|
+
name: "ClobAuthDomain",
|
|
18
|
+
version: "1",
|
|
19
|
+
chainId
|
|
20
|
+
},
|
|
21
|
+
types: { ClobAuth: [
|
|
22
|
+
{
|
|
23
|
+
name: "address",
|
|
24
|
+
type: "address"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "timestamp",
|
|
28
|
+
type: "string"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "nonce",
|
|
32
|
+
type: "uint256"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "message",
|
|
36
|
+
type: "string"
|
|
37
|
+
}
|
|
38
|
+
] },
|
|
39
|
+
value: {
|
|
40
|
+
address: resolvedAddress,
|
|
41
|
+
timestamp: ts,
|
|
42
|
+
nonce,
|
|
43
|
+
message: require_constants.MSG_TO_SIGN
|
|
44
|
+
},
|
|
45
|
+
primaryType: "ClobAuth"
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.buildClobEip712Signature = buildClobEip712Signature;
|
|
51
|
+
//# sourceMappingURL=eip712.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip712.cjs","names":["getSignerAddress","signTypedDataWithSigner","MSG_TO_SIGN"],"sources":["../../src/signing/eip712.ts"],"sourcesContent":["import type { Chain } from \"../types/index.js\";\n\nimport { MSG_TO_SIGN } from \"./constants.js\";\nimport { type ClobSigner, getSignerAddress, signTypedDataWithSigner } from \"./signer.js\";\n\n/**\n * Builds the canonical Polymarket CLOB EIP712 signature\n * @param signer\n * @param ts\n * @returns string\n */\nexport const buildClobEip712Signature = async (\n\tsigner: ClobSigner,\n\tchainId: Chain,\n\ttimestamp: number,\n\tnonce: number,\n\taddress?: string,\n): Promise<string> => {\n\tconst resolvedAddress = address ?? (await getSignerAddress(signer));\n\tconst ts = timestamp.toString();\n\n\tconst domain = {\n\t\tname: \"ClobAuthDomain\",\n\t\tversion: \"1\",\n\t\tchainId: chainId,\n\t};\n\n\tconst types = {\n\t\tClobAuth: [\n\t\t\t{ name: \"address\", type: \"address\" },\n\t\t\t{ name: \"timestamp\", type: \"string\" },\n\t\t\t{ name: \"nonce\", type: \"uint256\" },\n\t\t\t{ name: \"message\", type: \"string\" },\n\t\t],\n\t};\n\tconst value = {\n\t\taddress: resolvedAddress,\n\t\ttimestamp: ts,\n\t\tnonce,\n\t\tmessage: MSG_TO_SIGN,\n\t};\n\tconst sig = await signTypedDataWithSigner({\n\t\tsigner,\n\t\tdomain,\n\t\ttypes,\n\t\tvalue,\n\t\tprimaryType: \"ClobAuth\",\n\t});\n\treturn sig;\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,2BAA2B,OACvC,QACA,SACA,WACA,OACA,YACqB;CACrB,MAAM,kBAAkB,WAAY,MAAMA,gCAAiB,OAAO;CAClE,MAAM,KAAK,UAAU,UAAU;AA6B/B,QAPY,MAAMC,uCAAwB;EACzC;EACA,QAtBc;GACd,MAAM;GACN,SAAS;GACA;GACT;EAmBA,OAjBa,EACb,UAAU;GACT;IAAE,MAAM;IAAW,MAAM;IAAW;GACpC;IAAE,MAAM;IAAa,MAAM;IAAU;GACrC;IAAE,MAAM;IAAS,MAAM;IAAW;GAClC;IAAE,MAAM;IAAW,MAAM;IAAU;GACnC,EACD;EAWA,OAVa;GACb,SAAS;GACT,WAAW;GACX;GACA,SAASC;GACT;EAMA,aAAa;EACb,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MSG_TO_SIGN } from "./constants.js";
|
|
2
|
+
import { getSignerAddress, signTypedDataWithSigner } from "./signer.js";
|
|
3
|
+
|
|
4
|
+
//#region src/signing/eip712.ts
|
|
5
|
+
/**
|
|
6
|
+
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
7
|
+
* @param signer
|
|
8
|
+
* @param ts
|
|
9
|
+
* @returns string
|
|
10
|
+
*/
|
|
11
|
+
const buildClobEip712Signature = async (signer, chainId, timestamp, nonce, address) => {
|
|
12
|
+
const resolvedAddress = address ?? await getSignerAddress(signer);
|
|
13
|
+
const ts = timestamp.toString();
|
|
14
|
+
return await signTypedDataWithSigner({
|
|
15
|
+
signer,
|
|
16
|
+
domain: {
|
|
17
|
+
name: "ClobAuthDomain",
|
|
18
|
+
version: "1",
|
|
19
|
+
chainId
|
|
20
|
+
},
|
|
21
|
+
types: { ClobAuth: [
|
|
22
|
+
{
|
|
23
|
+
name: "address",
|
|
24
|
+
type: "address"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "timestamp",
|
|
28
|
+
type: "string"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "nonce",
|
|
32
|
+
type: "uint256"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "message",
|
|
36
|
+
type: "string"
|
|
37
|
+
}
|
|
38
|
+
] },
|
|
39
|
+
value: {
|
|
40
|
+
address: resolvedAddress,
|
|
41
|
+
timestamp: ts,
|
|
42
|
+
nonce,
|
|
43
|
+
message: MSG_TO_SIGN
|
|
44
|
+
},
|
|
45
|
+
primaryType: "ClobAuth"
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { buildClobEip712Signature };
|
|
51
|
+
//# sourceMappingURL=eip712.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip712.js","names":[],"sources":["../../src/signing/eip712.ts"],"sourcesContent":["import type { Chain } from \"../types/index.js\";\n\nimport { MSG_TO_SIGN } from \"./constants.js\";\nimport { type ClobSigner, getSignerAddress, signTypedDataWithSigner } from \"./signer.js\";\n\n/**\n * Builds the canonical Polymarket CLOB EIP712 signature\n * @param signer\n * @param ts\n * @returns string\n */\nexport const buildClobEip712Signature = async (\n\tsigner: ClobSigner,\n\tchainId: Chain,\n\ttimestamp: number,\n\tnonce: number,\n\taddress?: string,\n): Promise<string> => {\n\tconst resolvedAddress = address ?? (await getSignerAddress(signer));\n\tconst ts = timestamp.toString();\n\n\tconst domain = {\n\t\tname: \"ClobAuthDomain\",\n\t\tversion: \"1\",\n\t\tchainId: chainId,\n\t};\n\n\tconst types = {\n\t\tClobAuth: [\n\t\t\t{ name: \"address\", type: \"address\" },\n\t\t\t{ name: \"timestamp\", type: \"string\" },\n\t\t\t{ name: \"nonce\", type: \"uint256\" },\n\t\t\t{ name: \"message\", type: \"string\" },\n\t\t],\n\t};\n\tconst value = {\n\t\taddress: resolvedAddress,\n\t\ttimestamp: ts,\n\t\tnonce,\n\t\tmessage: MSG_TO_SIGN,\n\t};\n\tconst sig = await signTypedDataWithSigner({\n\t\tsigner,\n\t\tdomain,\n\t\ttypes,\n\t\tvalue,\n\t\tprimaryType: \"ClobAuth\",\n\t});\n\treturn sig;\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,2BAA2B,OACvC,QACA,SACA,WACA,OACA,YACqB;CACrB,MAAM,kBAAkB,WAAY,MAAM,iBAAiB,OAAO;CAClE,MAAM,KAAK,UAAU,UAAU;AA6B/B,QAPY,MAAM,wBAAwB;EACzC;EACA,QAtBc;GACd,MAAM;GACN,SAAS;GACA;GACT;EAmBA,OAjBa,EACb,UAAU;GACT;IAAE,MAAM;IAAW,MAAM;IAAW;GACpC;IAAE,MAAM;IAAa,MAAM;IAAU;GACrC;IAAE,MAAM;IAAS,MAAM;IAAW;GAClC;IAAE,MAAM;IAAW,MAAM;IAAU;GACnC,EACD;EAWA,OAVa;GACb,SAAS;GACT,WAAW;GACX;GACA,SAAS;GACT;EAMA,aAAa;EACb,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/signing/hmac.ts
|
|
3
|
+
const decodeBase64Secret = (secret) => {
|
|
4
|
+
const normalized = secret.replace(/-/g, "+").replace(/_/g, "/");
|
|
5
|
+
const padded = normalized + "=".repeat((4 - normalized.length % 4) % 4);
|
|
6
|
+
const binary = atob(padded);
|
|
7
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
8
|
+
const bytes = new Uint8Array(buffer);
|
|
9
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
10
|
+
return bytes;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Builds the canonical Polymarket CLOB HMAC signature
|
|
14
|
+
* @param secret
|
|
15
|
+
* @param timestamp
|
|
16
|
+
* @param method
|
|
17
|
+
* @param requestPath
|
|
18
|
+
* @param body
|
|
19
|
+
* @returns string
|
|
20
|
+
*/
|
|
21
|
+
const buildPolyHmacSignature = async (secret, timestamp, method, requestPath, body) => {
|
|
22
|
+
if (!secret) throw new Error("buildPolyHmacSignature: secret is empty");
|
|
23
|
+
if (!globalThis.crypto?.subtle) throw new Error("buildPolyHmacSignature: globalThis.crypto.subtle is unavailable. Requires Node >=20 or a secure browser context (HTTPS or localhost).");
|
|
24
|
+
let message = timestamp + method + requestPath;
|
|
25
|
+
if (body !== void 0) message += body;
|
|
26
|
+
const keyBytes = decodeBase64Secret(secret);
|
|
27
|
+
const key = await globalThis.crypto.subtle.importKey("raw", keyBytes, {
|
|
28
|
+
name: "HMAC",
|
|
29
|
+
hash: "SHA-256"
|
|
30
|
+
}, false, ["sign"]);
|
|
31
|
+
const sigBuffer = await globalThis.crypto.subtle.sign("HMAC", key, new TextEncoder().encode(message));
|
|
32
|
+
const sigBytes = new Uint8Array(sigBuffer);
|
|
33
|
+
let binary = "";
|
|
34
|
+
for (let i = 0; i < sigBytes.length; i++) binary += String.fromCharCode(sigBytes[i]);
|
|
35
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.buildPolyHmacSignature = buildPolyHmacSignature;
|
|
40
|
+
//# sourceMappingURL=hmac.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac.cjs","names":[],"sources":["../../src/signing/hmac.ts"],"sourcesContent":["const decodeBase64Secret = (secret: string): Uint8Array<ArrayBuffer> => {\n\tconst normalized = secret.replace(/-/g, \"+\").replace(/_/g, \"/\");\n\tconst padded = normalized + \"=\".repeat((4 - (normalized.length % 4)) % 4);\n\tconst binary = atob(padded);\n\tconst buffer = new ArrayBuffer(binary.length);\n\tconst bytes = new Uint8Array(buffer);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tbytes[i] = binary.charCodeAt(i);\n\t}\n\treturn bytes;\n};\n\n/**\n * Builds the canonical Polymarket CLOB HMAC signature\n * @param secret\n * @param timestamp\n * @param method\n * @param requestPath\n * @param body\n * @returns string\n */\nexport const buildPolyHmacSignature = async (\n\tsecret: string,\n\ttimestamp: number,\n\tmethod: string,\n\trequestPath: string,\n\tbody?: string,\n): Promise<string> => {\n\tif (!secret) {\n\t\tthrow new Error(\"buildPolyHmacSignature: secret is empty\");\n\t}\n\tif (!globalThis.crypto?.subtle) {\n\t\tthrow new Error(\n\t\t\t\"buildPolyHmacSignature: globalThis.crypto.subtle is unavailable. Requires Node >=20 or a secure browser context (HTTPS or localhost).\",\n\t\t);\n\t}\n\n\tlet message = timestamp + method + requestPath;\n\tif (body !== undefined) {\n\t\tmessage += body;\n\t}\n\n\tconst keyBytes = decodeBase64Secret(secret);\n\n\tconst key = await globalThis.crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tkeyBytes,\n\t\t{ name: \"HMAC\", hash: \"SHA-256\" },\n\t\tfalse,\n\t\t[\"sign\"],\n\t);\n\n\tconst sigBuffer = await globalThis.crypto.subtle.sign(\n\t\t\"HMAC\",\n\t\tkey,\n\t\tnew TextEncoder().encode(message),\n\t);\n\n\tconst sigBytes = new Uint8Array(sigBuffer);\n\tlet binary = \"\";\n\tfor (let i = 0; i < sigBytes.length; i++) {\n\t\tbinary += String.fromCharCode(sigBytes[i]);\n\t}\n\t// NOTE: Must be url safe base64 encoding, but keep base64 \"=\" suffix\n\t// Convert '+' to '-'\n\t// Convert '/' to '_'\n\treturn btoa(binary).replace(/\\+/g, \"-\").replace(/\\//g, \"_\");\n};\n"],"mappings":";;AAAA,MAAM,sBAAsB,WAA4C;CACvE,MAAM,aAAa,OAAO,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,IAAI;CAC/D,MAAM,SAAS,aAAa,IAAI,QAAQ,IAAK,WAAW,SAAS,KAAM,EAAE;CACzE,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,SAAS,IAAI,YAAY,OAAO,OAAO;CAC7C,MAAM,QAAQ,IAAI,WAAW,OAAO;AACpC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IAClC,OAAM,KAAK,OAAO,WAAW,EAAE;AAEhC,QAAO;;;;;;;;;;;AAYR,MAAa,yBAAyB,OACrC,QACA,WACA,QACA,aACA,SACqB;AACrB,KAAI,CAAC,OACJ,OAAM,IAAI,MAAM,0CAA0C;AAE3D,KAAI,CAAC,WAAW,QAAQ,OACvB,OAAM,IAAI,MACT,wIACA;CAGF,IAAI,UAAU,YAAY,SAAS;AACnC,KAAI,SAAS,OACZ,YAAW;CAGZ,MAAM,WAAW,mBAAmB,OAAO;CAE3C,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO,UAC1C,OACA,UACA;EAAE,MAAM;EAAQ,MAAM;EAAW,EACjC,OACA,CAAC,OAAO,CACR;CAED,MAAM,YAAY,MAAM,WAAW,OAAO,OAAO,KAChD,QACA,KACA,IAAI,aAAa,CAAC,OAAO,QAAQ,CACjC;CAED,MAAM,WAAW,IAAI,WAAW,UAAU;CAC1C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACpC,WAAU,OAAO,aAAa,SAAS,GAAG;AAK3C,QAAO,KAAK,OAAO,CAAC,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/signing/hmac.ts
|
|
2
|
+
const decodeBase64Secret = (secret) => {
|
|
3
|
+
const normalized = secret.replace(/-/g, "+").replace(/_/g, "/");
|
|
4
|
+
const padded = normalized + "=".repeat((4 - normalized.length % 4) % 4);
|
|
5
|
+
const binary = atob(padded);
|
|
6
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
7
|
+
const bytes = new Uint8Array(buffer);
|
|
8
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
9
|
+
return bytes;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Builds the canonical Polymarket CLOB HMAC signature
|
|
13
|
+
* @param secret
|
|
14
|
+
* @param timestamp
|
|
15
|
+
* @param method
|
|
16
|
+
* @param requestPath
|
|
17
|
+
* @param body
|
|
18
|
+
* @returns string
|
|
19
|
+
*/
|
|
20
|
+
const buildPolyHmacSignature = async (secret, timestamp, method, requestPath, body) => {
|
|
21
|
+
if (!secret) throw new Error("buildPolyHmacSignature: secret is empty");
|
|
22
|
+
if (!globalThis.crypto?.subtle) throw new Error("buildPolyHmacSignature: globalThis.crypto.subtle is unavailable. Requires Node >=20 or a secure browser context (HTTPS or localhost).");
|
|
23
|
+
let message = timestamp + method + requestPath;
|
|
24
|
+
if (body !== void 0) message += body;
|
|
25
|
+
const keyBytes = decodeBase64Secret(secret);
|
|
26
|
+
const key = await globalThis.crypto.subtle.importKey("raw", keyBytes, {
|
|
27
|
+
name: "HMAC",
|
|
28
|
+
hash: "SHA-256"
|
|
29
|
+
}, false, ["sign"]);
|
|
30
|
+
const sigBuffer = await globalThis.crypto.subtle.sign("HMAC", key, new TextEncoder().encode(message));
|
|
31
|
+
const sigBytes = new Uint8Array(sigBuffer);
|
|
32
|
+
let binary = "";
|
|
33
|
+
for (let i = 0; i < sigBytes.length; i++) binary += String.fromCharCode(sigBytes[i]);
|
|
34
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { buildPolyHmacSignature };
|
|
39
|
+
//# sourceMappingURL=hmac.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac.js","names":[],"sources":["../../src/signing/hmac.ts"],"sourcesContent":["const decodeBase64Secret = (secret: string): Uint8Array<ArrayBuffer> => {\n\tconst normalized = secret.replace(/-/g, \"+\").replace(/_/g, \"/\");\n\tconst padded = normalized + \"=\".repeat((4 - (normalized.length % 4)) % 4);\n\tconst binary = atob(padded);\n\tconst buffer = new ArrayBuffer(binary.length);\n\tconst bytes = new Uint8Array(buffer);\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tbytes[i] = binary.charCodeAt(i);\n\t}\n\treturn bytes;\n};\n\n/**\n * Builds the canonical Polymarket CLOB HMAC signature\n * @param secret\n * @param timestamp\n * @param method\n * @param requestPath\n * @param body\n * @returns string\n */\nexport const buildPolyHmacSignature = async (\n\tsecret: string,\n\ttimestamp: number,\n\tmethod: string,\n\trequestPath: string,\n\tbody?: string,\n): Promise<string> => {\n\tif (!secret) {\n\t\tthrow new Error(\"buildPolyHmacSignature: secret is empty\");\n\t}\n\tif (!globalThis.crypto?.subtle) {\n\t\tthrow new Error(\n\t\t\t\"buildPolyHmacSignature: globalThis.crypto.subtle is unavailable. Requires Node >=20 or a secure browser context (HTTPS or localhost).\",\n\t\t);\n\t}\n\n\tlet message = timestamp + method + requestPath;\n\tif (body !== undefined) {\n\t\tmessage += body;\n\t}\n\n\tconst keyBytes = decodeBase64Secret(secret);\n\n\tconst key = await globalThis.crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tkeyBytes,\n\t\t{ name: \"HMAC\", hash: \"SHA-256\" },\n\t\tfalse,\n\t\t[\"sign\"],\n\t);\n\n\tconst sigBuffer = await globalThis.crypto.subtle.sign(\n\t\t\"HMAC\",\n\t\tkey,\n\t\tnew TextEncoder().encode(message),\n\t);\n\n\tconst sigBytes = new Uint8Array(sigBuffer);\n\tlet binary = \"\";\n\tfor (let i = 0; i < sigBytes.length; i++) {\n\t\tbinary += String.fromCharCode(sigBytes[i]);\n\t}\n\t// NOTE: Must be url safe base64 encoding, but keep base64 \"=\" suffix\n\t// Convert '+' to '-'\n\t// Convert '/' to '_'\n\treturn btoa(binary).replace(/\\+/g, \"-\").replace(/\\//g, \"_\");\n};\n"],"mappings":";AAAA,MAAM,sBAAsB,WAA4C;CACvE,MAAM,aAAa,OAAO,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,IAAI;CAC/D,MAAM,SAAS,aAAa,IAAI,QAAQ,IAAK,WAAW,SAAS,KAAM,EAAE;CACzE,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,SAAS,IAAI,YAAY,OAAO,OAAO;CAC7C,MAAM,QAAQ,IAAI,WAAW,OAAO;AACpC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IAClC,OAAM,KAAK,OAAO,WAAW,EAAE;AAEhC,QAAO;;;;;;;;;;;AAYR,MAAa,yBAAyB,OACrC,QACA,WACA,QACA,aACA,SACqB;AACrB,KAAI,CAAC,OACJ,OAAM,IAAI,MAAM,0CAA0C;AAE3D,KAAI,CAAC,WAAW,QAAQ,OACvB,OAAM,IAAI,MACT,wIACA;CAGF,IAAI,UAAU,YAAY,SAAS;AACnC,KAAI,SAAS,OACZ,YAAW;CAGZ,MAAM,WAAW,mBAAmB,OAAO;CAE3C,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO,UAC1C,OACA,UACA;EAAE,MAAM;EAAQ,MAAM;EAAW,EACjC,OACA,CAAC,OAAO,CACR;CAED,MAAM,YAAY,MAAM,WAAW,OAAO,OAAO,KAChD,QACA,KACA,IAAI,aAAa,CAAC,OAAO,QAAQ,CACjC;CAED,MAAM,WAAW,IAAI,WAAW,UAAU;CAC1C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IACpC,WAAU,OAAO,aAAa,SAAS,GAAG;AAK3C,QAAO,KAAK,OAAO,CAAC,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/signing/signer.ts
|
|
3
|
+
const isEthersTypedDataSigner = (signer) => typeof signer._signTypedData === "function";
|
|
4
|
+
const isWalletClientSigner = (signer) => typeof signer.signTypedData === "function";
|
|
5
|
+
const getWalletClientAddress = async (walletClient) => {
|
|
6
|
+
const accountAddress = walletClient.account?.address;
|
|
7
|
+
if (typeof accountAddress === "string" && accountAddress.length > 0) return accountAddress;
|
|
8
|
+
if (typeof walletClient.requestAddresses === "function") {
|
|
9
|
+
const [address] = await walletClient.requestAddresses();
|
|
10
|
+
if (typeof address === "string" && address.length > 0) return address;
|
|
11
|
+
}
|
|
12
|
+
if (typeof walletClient.getAddresses === "function") {
|
|
13
|
+
const [address] = await walletClient.getAddresses();
|
|
14
|
+
if (typeof address === "string" && address.length > 0) return address;
|
|
15
|
+
}
|
|
16
|
+
throw new Error("wallet client is missing account address");
|
|
17
|
+
};
|
|
18
|
+
const getSignerAddress = async (signer) => {
|
|
19
|
+
if (isEthersTypedDataSigner(signer)) return signer.getAddress();
|
|
20
|
+
if (isWalletClientSigner(signer)) return getWalletClientAddress(signer);
|
|
21
|
+
throw new Error("unsupported signer type");
|
|
22
|
+
};
|
|
23
|
+
const signTypedDataWithSigner = async ({ signer, domain, types, value, primaryType }) => {
|
|
24
|
+
if (isEthersTypedDataSigner(signer)) return signer._signTypedData(domain, types, value);
|
|
25
|
+
if (isWalletClientSigner(signer)) {
|
|
26
|
+
const account = signer.account ?? await getWalletClientAddress(signer);
|
|
27
|
+
return signer.signTypedData({
|
|
28
|
+
account,
|
|
29
|
+
domain,
|
|
30
|
+
types,
|
|
31
|
+
primaryType,
|
|
32
|
+
message: value
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
throw new Error("unsupported signer type");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.getSignerAddress = getSignerAddress;
|
|
40
|
+
exports.signTypedDataWithSigner = signTypedDataWithSigner;
|
|
41
|
+
//# sourceMappingURL=signer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.cjs","names":["account: Account | Address"],"sources":["../../src/signing/signer.ts"],"sourcesContent":["import type { Account, Address, WalletClient } from \"viem\";\n\ntype TypedDataDomain = Record<string, unknown>;\ntype TypedDataTypes = Record<string, Array<{ name: string; type: string }>>;\ntype TypedDataValue = Record<string, unknown>;\n\ninterface EthersSigner {\n\t_signTypedData(\n\t\tdomain: TypedDataDomain,\n\t\ttypes: TypedDataTypes,\n\t\tvalue: TypedDataValue,\n\t): Promise<string>;\n\tgetAddress(): Promise<string>;\n}\n\nexport type ClobSigner = EthersSigner | WalletClient;\n\nconst isEthersTypedDataSigner = (signer: ClobSigner): signer is EthersSigner =>\n\t// eslint-disable-next-line no-underscore-dangle\n\ttypeof (signer as EthersSigner)._signTypedData === \"function\";\n\nconst isWalletClientSigner = (signer: ClobSigner): signer is WalletClient =>\n\ttypeof (signer as WalletClient).signTypedData === \"function\";\n\nexport const getWalletClientAddress = async (walletClient: WalletClient): Promise<Address> => {\n\tconst accountAddress = walletClient.account?.address;\n\tif (typeof accountAddress === \"string\" && accountAddress.length > 0) {\n\t\treturn accountAddress as Address;\n\t}\n\n\tif (typeof walletClient.requestAddresses === \"function\") {\n\t\tconst [address] = await walletClient.requestAddresses();\n\t\tif (typeof address === \"string\" && address.length > 0) {\n\t\t\treturn address as Address;\n\t\t}\n\t}\n\n\tif (typeof walletClient.getAddresses === \"function\") {\n\t\tconst [address] = await walletClient.getAddresses();\n\t\tif (typeof address === \"string\" && address.length > 0) {\n\t\t\treturn address as Address;\n\t\t}\n\t}\n\n\tthrow new Error(\"wallet client is missing account address\");\n};\n\nexport const getSignerAddress = async (signer: ClobSigner): Promise<string> => {\n\tif (isEthersTypedDataSigner(signer)) {\n\t\treturn signer.getAddress();\n\t}\n\n\tif (isWalletClientSigner(signer)) {\n\t\treturn getWalletClientAddress(signer);\n\t}\n\n\tthrow new Error(\"unsupported signer type\");\n};\n\nexport const signTypedDataWithSigner = async ({\n\tsigner,\n\tdomain,\n\ttypes,\n\tvalue,\n\tprimaryType,\n}: {\n\tsigner: ClobSigner;\n\tdomain: TypedDataDomain;\n\ttypes: TypedDataTypes;\n\tvalue: TypedDataValue;\n\tprimaryType?: string;\n}): Promise<string> => {\n\tif (isEthersTypedDataSigner(signer)) {\n\t\t// eslint-disable-next-line no-underscore-dangle\n\t\treturn signer._signTypedData(domain, types, value);\n\t}\n\n\tif (isWalletClientSigner(signer)) {\n\t\tconst account: Account | Address = signer.account ?? (await getWalletClientAddress(signer));\n\t\treturn signer.signTypedData({\n\t\t\taccount,\n\t\t\tdomain,\n\t\t\ttypes,\n\t\t\tprimaryType,\n\t\t\tmessage: value,\n\t\t} as Parameters<WalletClient[\"signTypedData\"]>[0]);\n\t}\n\n\tthrow new Error(\"unsupported signer type\");\n};\n"],"mappings":";;AAiBA,MAAM,2BAA2B,WAEhC,OAAQ,OAAwB,mBAAmB;AAEpD,MAAM,wBAAwB,WAC7B,OAAQ,OAAwB,kBAAkB;AAEnD,MAAa,yBAAyB,OAAO,iBAAiD;CAC7F,MAAM,iBAAiB,aAAa,SAAS;AAC7C,KAAI,OAAO,mBAAmB,YAAY,eAAe,SAAS,EACjE,QAAO;AAGR,KAAI,OAAO,aAAa,qBAAqB,YAAY;EACxD,MAAM,CAAC,WAAW,MAAM,aAAa,kBAAkB;AACvD,MAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,EACnD,QAAO;;AAIT,KAAI,OAAO,aAAa,iBAAiB,YAAY;EACpD,MAAM,CAAC,WAAW,MAAM,aAAa,cAAc;AACnD,MAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,EACnD,QAAO;;AAIT,OAAM,IAAI,MAAM,2CAA2C;;AAG5D,MAAa,mBAAmB,OAAO,WAAwC;AAC9E,KAAI,wBAAwB,OAAO,CAClC,QAAO,OAAO,YAAY;AAG3B,KAAI,qBAAqB,OAAO,CAC/B,QAAO,uBAAuB,OAAO;AAGtC,OAAM,IAAI,MAAM,0BAA0B;;AAG3C,MAAa,0BAA0B,OAAO,EAC7C,QACA,QACA,OACA,OACA,kBAOsB;AACtB,KAAI,wBAAwB,OAAO,CAElC,QAAO,OAAO,eAAe,QAAQ,OAAO,MAAM;AAGnD,KAAI,qBAAqB,OAAO,EAAE;EACjC,MAAMA,UAA6B,OAAO,WAAY,MAAM,uBAAuB,OAAO;AAC1F,SAAO,OAAO,cAAc;GAC3B;GACA;GACA;GACA;GACA,SAAS;GACT,CAAiD;;AAGnD,OAAM,IAAI,MAAM,0BAA0B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WalletClient } from "viem";
|
|
2
|
+
|
|
3
|
+
//#region src/signing/signer.d.ts
|
|
4
|
+
type TypedDataDomain = Record<string, unknown>;
|
|
5
|
+
type TypedDataTypes = Record<string, Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
}>>;
|
|
9
|
+
type TypedDataValue = Record<string, unknown>;
|
|
10
|
+
interface EthersSigner {
|
|
11
|
+
_signTypedData(domain: TypedDataDomain, types: TypedDataTypes, value: TypedDataValue): Promise<string>;
|
|
12
|
+
getAddress(): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
type ClobSigner = EthersSigner | WalletClient;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ClobSigner };
|
|
17
|
+
//# sourceMappingURL=signer.d.cts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WalletClient } from "viem";
|
|
2
|
+
|
|
3
|
+
//#region src/signing/signer.d.ts
|
|
4
|
+
type TypedDataDomain = Record<string, unknown>;
|
|
5
|
+
type TypedDataTypes = Record<string, Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
}>>;
|
|
9
|
+
type TypedDataValue = Record<string, unknown>;
|
|
10
|
+
interface EthersSigner {
|
|
11
|
+
_signTypedData(domain: TypedDataDomain, types: TypedDataTypes, value: TypedDataValue): Promise<string>;
|
|
12
|
+
getAddress(): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
type ClobSigner = EthersSigner | WalletClient;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ClobSigner };
|
|
17
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/signing/signer.ts
|
|
2
|
+
const isEthersTypedDataSigner = (signer) => typeof signer._signTypedData === "function";
|
|
3
|
+
const isWalletClientSigner = (signer) => typeof signer.signTypedData === "function";
|
|
4
|
+
const getWalletClientAddress = async (walletClient) => {
|
|
5
|
+
const accountAddress = walletClient.account?.address;
|
|
6
|
+
if (typeof accountAddress === "string" && accountAddress.length > 0) return accountAddress;
|
|
7
|
+
if (typeof walletClient.requestAddresses === "function") {
|
|
8
|
+
const [address] = await walletClient.requestAddresses();
|
|
9
|
+
if (typeof address === "string" && address.length > 0) return address;
|
|
10
|
+
}
|
|
11
|
+
if (typeof walletClient.getAddresses === "function") {
|
|
12
|
+
const [address] = await walletClient.getAddresses();
|
|
13
|
+
if (typeof address === "string" && address.length > 0) return address;
|
|
14
|
+
}
|
|
15
|
+
throw new Error("wallet client is missing account address");
|
|
16
|
+
};
|
|
17
|
+
const getSignerAddress = async (signer) => {
|
|
18
|
+
if (isEthersTypedDataSigner(signer)) return signer.getAddress();
|
|
19
|
+
if (isWalletClientSigner(signer)) return getWalletClientAddress(signer);
|
|
20
|
+
throw new Error("unsupported signer type");
|
|
21
|
+
};
|
|
22
|
+
const signTypedDataWithSigner = async ({ signer, domain, types, value, primaryType }) => {
|
|
23
|
+
if (isEthersTypedDataSigner(signer)) return signer._signTypedData(domain, types, value);
|
|
24
|
+
if (isWalletClientSigner(signer)) {
|
|
25
|
+
const account = signer.account ?? await getWalletClientAddress(signer);
|
|
26
|
+
return signer.signTypedData({
|
|
27
|
+
account,
|
|
28
|
+
domain,
|
|
29
|
+
types,
|
|
30
|
+
primaryType,
|
|
31
|
+
message: value
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
throw new Error("unsupported signer type");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { getSignerAddress, signTypedDataWithSigner };
|
|
39
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","names":["account: Account | Address"],"sources":["../../src/signing/signer.ts"],"sourcesContent":["import type { Account, Address, WalletClient } from \"viem\";\n\ntype TypedDataDomain = Record<string, unknown>;\ntype TypedDataTypes = Record<string, Array<{ name: string; type: string }>>;\ntype TypedDataValue = Record<string, unknown>;\n\ninterface EthersSigner {\n\t_signTypedData(\n\t\tdomain: TypedDataDomain,\n\t\ttypes: TypedDataTypes,\n\t\tvalue: TypedDataValue,\n\t): Promise<string>;\n\tgetAddress(): Promise<string>;\n}\n\nexport type ClobSigner = EthersSigner | WalletClient;\n\nconst isEthersTypedDataSigner = (signer: ClobSigner): signer is EthersSigner =>\n\t// eslint-disable-next-line no-underscore-dangle\n\ttypeof (signer as EthersSigner)._signTypedData === \"function\";\n\nconst isWalletClientSigner = (signer: ClobSigner): signer is WalletClient =>\n\ttypeof (signer as WalletClient).signTypedData === \"function\";\n\nexport const getWalletClientAddress = async (walletClient: WalletClient): Promise<Address> => {\n\tconst accountAddress = walletClient.account?.address;\n\tif (typeof accountAddress === \"string\" && accountAddress.length > 0) {\n\t\treturn accountAddress as Address;\n\t}\n\n\tif (typeof walletClient.requestAddresses === \"function\") {\n\t\tconst [address] = await walletClient.requestAddresses();\n\t\tif (typeof address === \"string\" && address.length > 0) {\n\t\t\treturn address as Address;\n\t\t}\n\t}\n\n\tif (typeof walletClient.getAddresses === \"function\") {\n\t\tconst [address] = await walletClient.getAddresses();\n\t\tif (typeof address === \"string\" && address.length > 0) {\n\t\t\treturn address as Address;\n\t\t}\n\t}\n\n\tthrow new Error(\"wallet client is missing account address\");\n};\n\nexport const getSignerAddress = async (signer: ClobSigner): Promise<string> => {\n\tif (isEthersTypedDataSigner(signer)) {\n\t\treturn signer.getAddress();\n\t}\n\n\tif (isWalletClientSigner(signer)) {\n\t\treturn getWalletClientAddress(signer);\n\t}\n\n\tthrow new Error(\"unsupported signer type\");\n};\n\nexport const signTypedDataWithSigner = async ({\n\tsigner,\n\tdomain,\n\ttypes,\n\tvalue,\n\tprimaryType,\n}: {\n\tsigner: ClobSigner;\n\tdomain: TypedDataDomain;\n\ttypes: TypedDataTypes;\n\tvalue: TypedDataValue;\n\tprimaryType?: string;\n}): Promise<string> => {\n\tif (isEthersTypedDataSigner(signer)) {\n\t\t// eslint-disable-next-line no-underscore-dangle\n\t\treturn signer._signTypedData(domain, types, value);\n\t}\n\n\tif (isWalletClientSigner(signer)) {\n\t\tconst account: Account | Address = signer.account ?? (await getWalletClientAddress(signer));\n\t\treturn signer.signTypedData({\n\t\t\taccount,\n\t\t\tdomain,\n\t\t\ttypes,\n\t\t\tprimaryType,\n\t\t\tmessage: value,\n\t\t} as Parameters<WalletClient[\"signTypedData\"]>[0]);\n\t}\n\n\tthrow new Error(\"unsupported signer type\");\n};\n"],"mappings":";AAiBA,MAAM,2BAA2B,WAEhC,OAAQ,OAAwB,mBAAmB;AAEpD,MAAM,wBAAwB,WAC7B,OAAQ,OAAwB,kBAAkB;AAEnD,MAAa,yBAAyB,OAAO,iBAAiD;CAC7F,MAAM,iBAAiB,aAAa,SAAS;AAC7C,KAAI,OAAO,mBAAmB,YAAY,eAAe,SAAS,EACjE,QAAO;AAGR,KAAI,OAAO,aAAa,qBAAqB,YAAY;EACxD,MAAM,CAAC,WAAW,MAAM,aAAa,kBAAkB;AACvD,MAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,EACnD,QAAO;;AAIT,KAAI,OAAO,aAAa,iBAAiB,YAAY;EACpD,MAAM,CAAC,WAAW,MAAM,aAAa,cAAc;AACnD,MAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,EACnD,QAAO;;AAIT,OAAM,IAAI,MAAM,2CAA2C;;AAG5D,MAAa,mBAAmB,OAAO,WAAwC;AAC9E,KAAI,wBAAwB,OAAO,CAClC,QAAO,OAAO,YAAY;AAG3B,KAAI,qBAAqB,OAAO,CAC/B,QAAO,uBAAuB,OAAO;AAGtC,OAAM,IAAI,MAAM,0BAA0B;;AAG3C,MAAa,0BAA0B,OAAO,EAC7C,QACA,QACA,OACA,OACA,kBAOsB;AACtB,KAAI,wBAAwB,OAAO,CAElC,QAAO,OAAO,eAAe,QAAQ,OAAO,MAAM;AAGnD,KAAI,qBAAqB,OAAO,EAAE;EACjC,MAAMA,UAA6B,OAAO,WAAY,MAAM,uBAAuB,OAAO;AAC1F,SAAO,OAAO,cAAc;GAC3B;GACA;GACA;GACA;GACA,SAAS;GACT,CAAiD;;AAGnD,OAAM,IAAI,MAAM,0BAA0B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const require_side = require('../order-utils/model/side.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/types/clob.ts
|
|
4
|
+
let OrderType = /* @__PURE__ */ function(OrderType$1) {
|
|
5
|
+
OrderType$1["GTC"] = "GTC";
|
|
6
|
+
OrderType$1["FOK"] = "FOK";
|
|
7
|
+
OrderType$1["GTD"] = "GTD";
|
|
8
|
+
OrderType$1["FAK"] = "FAK";
|
|
9
|
+
return OrderType$1;
|
|
10
|
+
}({});
|
|
11
|
+
let Chain = /* @__PURE__ */ function(Chain$1) {
|
|
12
|
+
Chain$1[Chain$1["POLYGON"] = 137] = "POLYGON";
|
|
13
|
+
Chain$1[Chain$1["AMOY"] = 80002] = "AMOY";
|
|
14
|
+
return Chain$1;
|
|
15
|
+
}({});
|
|
16
|
+
let PriceHistoryInterval = /* @__PURE__ */ function(PriceHistoryInterval$1) {
|
|
17
|
+
PriceHistoryInterval$1["MAX"] = "max";
|
|
18
|
+
PriceHistoryInterval$1["ONE_WEEK"] = "1w";
|
|
19
|
+
PriceHistoryInterval$1["ONE_DAY"] = "1d";
|
|
20
|
+
PriceHistoryInterval$1["SIX_HOURS"] = "6h";
|
|
21
|
+
PriceHistoryInterval$1["ONE_HOUR"] = "1h";
|
|
22
|
+
return PriceHistoryInterval$1;
|
|
23
|
+
}({});
|
|
24
|
+
let AssetType = /* @__PURE__ */ function(AssetType$1) {
|
|
25
|
+
AssetType$1["COLLATERAL"] = "COLLATERAL";
|
|
26
|
+
AssetType$1["CONDITIONAL"] = "CONDITIONAL";
|
|
27
|
+
return AssetType$1;
|
|
28
|
+
}({});
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.AssetType = AssetType;
|
|
32
|
+
exports.Chain = Chain;
|
|
33
|
+
exports.OrderType = OrderType;
|
|
34
|
+
exports.PriceHistoryInterval = PriceHistoryInterval;
|
|
35
|
+
//# sourceMappingURL=clob.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clob.cjs","names":[],"sources":["../../src/types/clob.ts"],"sourcesContent":["import { Side } from \"../order-utils/model/side.js\";\n\nexport { Side };\n\nexport interface ApiKeyCreds {\n\tkey: string;\n\tsecret: string;\n\tpassphrase: string;\n}\n\nexport interface BuilderConfig {\n\tbuilderCode: string;\n}\n\nexport interface ApiKeyRaw {\n\tapiKey: string;\n\tsecret: string;\n\tpassphrase: string;\n}\n\nexport interface L2HeaderArgs {\n\tmethod: string;\n\trequestPath: string;\n\tbody?: string;\n}\n\nexport type SimpleHeaders = Record<string, string | number | boolean>;\n\n// EIP712 sig verification\nexport interface L1PolyHeader extends SimpleHeaders {\n\tPOLY_ADDRESS: string;\n\tPOLY_SIGNATURE: string;\n\tPOLY_TIMESTAMP: string;\n\tPOLY_NONCE: string;\n}\n\n// API key verification\nexport interface L2PolyHeader extends SimpleHeaders {\n\tPOLY_ADDRESS: string;\n\tPOLY_SIGNATURE: string;\n\tPOLY_TIMESTAMP: string;\n\tPOLY_API_KEY: string;\n\tPOLY_PASSPHRASE: string;\n}\n\nexport enum OrderType {\n\tGTC = \"GTC\",\n\tFOK = \"FOK\",\n\tGTD = \"GTD\",\n\tFAK = \"FAK\",\n}\n\nexport interface OrderPayload {\n\torderID: string;\n}\n\nexport interface OrderResponse {\n\tsuccess: boolean;\n\terrorMsg: string;\n\torderID: string;\n\ttransactionsHashes?: string[];\n\ttradeIDs?: string[];\n\tstatus: string;\n\ttakingAmount: string;\n\tmakingAmount: string;\n}\n\nexport interface OpenOrder {\n\tid: string;\n\tstatus: string;\n\towner: string;\n\tmaker_address: string;\n\tmarket: string;\n\tasset_id: string;\n\tside: string;\n\toriginal_size: string;\n\tsize_matched: string;\n\tprice: string;\n\tassociate_trades: string[];\n\toutcome: string;\n\tcreated_at: number;\n\texpiration: string;\n\torder_type: string;\n}\n\nexport type OpenOrdersResponse = OpenOrder[];\n\nexport type PreMigrationOrder = OpenOrder;\n\nexport type PreMigrationOrdersResponse = PreMigrationOrder[];\n\nexport interface MakerOrder {\n\torder_id: string;\n\towner: string;\n\tmaker_address: string;\n\tmatched_amount: string;\n\tprice: string;\n\tfee_rate_bps: string;\n\tasset_id: string;\n\toutcome: string;\n\tside?: Side;\n\tbuilder_fee?: string;\n\tbuilder_code?: string;\n}\n\nexport interface Trade {\n\tid: string;\n\ttaker_order_id: string;\n\tmarket: string;\n\tasset_id: string;\n\tside: Side;\n\tsize: string;\n\tfee_rate_bps: string;\n\tprice: string;\n\tstatus: string;\n\tmatch_time: string;\n\tmatch_time_nano?: string;\n\tlast_update: string;\n\toutcome: string;\n\tbucket_index: number;\n\towner: string;\n\tmaker_address: string;\n\tmaker_orders: MakerOrder[];\n\ttransaction_hash?: string;\n\terr_msg?: string | null;\n\ttrader_side: \"TAKER\" | \"MAKER\";\n}\n\nexport interface ApiKeysResponse {\n\tapiKeys: ApiKeyCreds[];\n}\n\nexport interface BanStatus {\n\tclosed_only: boolean;\n}\n\nexport interface TradeParams {\n\tid?: string;\n\tmaker_address?: string;\n\tmarket?: string;\n\tasset_id?: string;\n\tbefore?: string;\n\tafter?: string;\n}\n\nexport interface BuilderTradeParams extends TradeParams {\n\tbuilder_code: string;\n}\n\nexport interface OpenOrderParams {\n\tid?: string;\n\tmarket?: string;\n\tasset_id?: string;\n}\n\nexport enum Chain {\n\tPOLYGON = 137,\n\tAMOY = 80002,\n}\n\nexport interface MarketPrice {\n\tt: number; // timestamp\n\tp: number; // price\n}\n\nexport interface PriceHistoryFilterParams {\n\tmarket?: string;\n\tstartTs?: number;\n\tendTs?: number;\n\tfidelity?: number;\n\tinterval?: PriceHistoryInterval;\n}\n\nexport enum PriceHistoryInterval {\n\tMAX = \"max\",\n\tONE_WEEK = \"1w\",\n\tONE_DAY = \"1d\",\n\tSIX_HOURS = \"6h\",\n\tONE_HOUR = \"1h\",\n}\n\nexport interface DropNotificationParams {\n\tids: string[];\n}\n\nexport interface Notification {\n\ttype: number;\n\towner: string;\n\n\tpayload: any;\n}\n\nexport interface OrderMarketCancelParams {\n\tmarket?: string;\n\tasset_id?: string;\n}\n\nexport interface OrderBookSummary {\n\tmarket: string;\n\tasset_id: string;\n\ttimestamp: string;\n\tbids: OrderSummary[];\n\tasks: OrderSummary[];\n\tmin_order_size: string;\n\ttick_size: string;\n\tneg_risk: boolean;\n\thash: string;\n\tlast_trade_price: string;\n}\n\nexport interface OrderSummary {\n\tprice: string;\n\tsize: string;\n}\n\nexport enum AssetType {\n\tCOLLATERAL = \"COLLATERAL\",\n\tCONDITIONAL = \"CONDITIONAL\",\n}\n\nexport interface BalanceAllowanceParams {\n\tasset_type: AssetType;\n\ttoken_id?: string;\n}\n\nexport interface BalanceAllowanceResponse {\n\tbalance: string;\n\tallowances: Record<string, string>;\n}\n\nexport interface OrderScoringParams {\n\torder_id: string;\n}\n\nexport interface OrderScoring {\n\tscoring: boolean;\n}\n\nexport interface OrdersScoringParams {\n\torderIds: string[];\n}\n\nexport type OrdersScoring = { [orderId in string]: boolean };\n\nexport type OrderVersion = 1 | 2 | 3;\n\nexport type CreateOrderOptions = {\n\ttickSize: TickSize;\n\tnegRisk?: boolean;\n\tversion?: OrderVersion;\n};\n\nexport type TickSize = \"0.1\" | \"0.01\" | \"0.001\" | \"0.0001\";\n\nexport interface RoundConfig {\n\treadonly price: number;\n\treadonly size: number;\n\treadonly amount: number;\n}\n\nexport interface TickSizes {\n\t[tokenId: string]: TickSize;\n}\n\nexport interface FeeRates {\n\t[tokenId: string]: number;\n}\n\nexport interface NegRisk {\n\t[tokenId: string]: boolean;\n}\n\nexport interface FeeInfo {\n\trate: number;\n\texponent: number;\n}\n\nexport interface FeeInfos {\n\t[tokenId: string]: FeeInfo;\n}\n\nexport interface BuilderFeeRates {\n\t[builderCode: string]: { maker: number; taker: number };\n}\n\nexport type TokenConditionMap = Record<string, string>;\n\nexport interface FeeDetails {\n\tr?: number; // fee rate\n\te?: number; // fee exponent\n\tto?: boolean; // taker only (omitted when false)\n}\n\nexport interface ClobRewards {\n\tmi?: number; // min size\n\tma?: number; // max spread\n\te?: boolean; // enabled\n\tsmoa?: boolean; // skip min order age\n\tmoas?: number; // min order age seconds\n}\n\nexport interface ClobToken {\n\tt: string; // token ID\n\to: string; // outcome\n}\n\nexport interface MarketDetails {\n\tc: string; // condition ID\n\tt: [ClobToken, ClobToken]; // YES and NO tokens\n\tmts: number; // min tick size\n\tnr?: boolean; // neg risk (omitted when false)\n\tfd?: FeeDetails; // platform fee details\n\tmbf?: number; // maker base fee\n\ttbf?: number; // taker base fee\n\tr: ClobRewards | null; // rewards config (always present, null if unset)\n\tao?: boolean; // accepting orders\n\tmos?: number; // min order size\n\tsd?: number; // seconds delay\n\tgst?: string; // game start time (ISO 8601)\n\tcbos?: boolean; // clear book on start\n\taot?: string; // accepting orders timestamp (ISO 8601)\n\trfqe?: boolean; // RFQ enabled\n\titode?: boolean; // taker order delay enabled\n\tibce?: boolean; // blockaid check enabled\n}\n\nexport interface PaginationPayload {\n\treadonly limit: number;\n\treadonly count: number;\n\treadonly next_cursor: string;\n\treadonly data: any[];\n}\n\nexport interface BookParams {\n\ttoken_id: string;\n\tside: Side;\n}\n\nexport interface UserEarning {\n\tdate: string;\n\tcondition_id: string;\n\tasset_address: string;\n\tmaker_address: string;\n\tearnings: number;\n\tasset_rate: number;\n}\n\nexport interface TotalUserEarning {\n\tdate: string;\n\tasset_address: string;\n\tmaker_address: string;\n\tearnings: number;\n\tasset_rate: number;\n}\n\nexport interface RewardsPercentages {\n\t[market: string]: number;\n}\n\nexport interface Token {\n\ttoken_id: string;\n\toutcome: string;\n\tprice: number;\n}\n\nexport interface RewardsConfig {\n\tasset_address: string;\n\tstart_date: string;\n\tend_date: string;\n\trate_per_day: number;\n\ttotal_rewards: number;\n}\n\nexport interface MarketReward {\n\tcondition_id: string;\n\tquestion: string;\n\tmarket_slug: string;\n\tevent_slug: string;\n\timage: string;\n\trewards_max_spread: number;\n\trewards_min_size: number;\n\ttokens: Token[];\n\trewards_config: RewardsConfig[];\n}\n\nexport interface Earning {\n\tasset_address: string;\n\tearnings: number;\n\tasset_rate: number;\n}\n\nexport interface UserRewardsEarning {\n\tcondition_id: string;\n\tquestion: string;\n\tmarket_slug: string;\n\tevent_slug: string;\n\timage: string;\n\trewards_max_spread: number;\n\trewards_min_size: number;\n\tmarket_competitiveness: number;\n\ttokens: Token[];\n\trewards_config: RewardsConfig[];\n\tmaker_address: string;\n\tearning_percentage: number;\n\tearnings: Earning[];\n}\n\nexport interface BuilderTrade {\n\tid: string;\n\ttradeType: string;\n\ttakerOrderHash: string;\n\tbuilder: string;\n\tmarket: string;\n\tassetId: string;\n\tside: string;\n\tsize: string;\n\tsizeUsdc: string;\n\tprice: string;\n\tstatus: string;\n\toutcome: string;\n\toutcomeIndex: number;\n\towner: string;\n\tmaker: string;\n\ttransactionHash: string;\n\tmatchTime: string;\n\tbucketIndex: number;\n\tfee: string;\n\tfeeUsdc: string;\n\tbuilderFee: string;\n\tbuilderCode: string;\n\terr_msg?: string | null;\n\tcreatedAt: string | null;\n\tupdatedAt: string | null;\n}\n\nexport interface ReadonlyApiKeyResponse {\n\tapiKey: string;\n}\n\nexport interface MarketTradeEvent {\n\tevent_type: string;\n\tmarket: {\n\t\tcondition_id: string;\n\t\tasset_id: string;\n\t\tquestion: string;\n\t\ticon: string;\n\t\tslug: string;\n\t};\n\tuser: {\n\t\taddress: string;\n\t\tusername: string;\n\t\tprofile_picture: string;\n\t\toptimized_profile_picture: string;\n\t\tpseudonym: string;\n\t};\n\tside: Side;\n\tsize: string;\n\tfee_rate_bps: string;\n\tprice: string;\n\toutcome: string;\n\toutcome_index: number;\n\ttransaction_hash: string;\n\ttimestamp: string;\n}\n\nexport interface BuilderApiKey {\n\tkey: string;\n\tsecret: string;\n\tpassphrase: string;\n}\n\nexport interface BuilderApiKeyResponse {\n\tkey: string;\n\tcreatedAt?: string;\n\trevokedAt?: string;\n}\n\nexport type ClobErrorResponseBody = {\n\terror: string;\n};\n\nexport interface TradesPaginatedResponse {\n\ttrades: Trade[];\n\tnext_cursor: string;\n\tlimit: number;\n\tcount: number;\n}\n\nexport interface BuilderTradesResponse {\n\ttrades: BuilderTrade[];\n\tnext_cursor: string;\n\tlimit: number;\n\tcount: number;\n}\n"],"mappings":";;;AA6CA,IAAY,kDAAL;AACN;AACA;AACA;AACA;;;AA0GD,IAAY,0CAAL;AACN;AACA;;;AAgBD,IAAY,wEAAL;AACN;AACA;AACA;AACA;AACA;;;AAqCD,IAAY,kDAAL;AACN;AACA"}
|