@polymarket/clob-client-v2 0.0.3 → 0.2.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/dist/client.d.ts +15 -29
- package/dist/client.js +723 -862
- package/dist/client.js.map +1 -1
- package/dist/config.js +5 -10
- package/dist/config.js.map +1 -1
- package/dist/constants.js +6 -9
- package/dist/constants.js.map +1 -1
- package/dist/endpoints.d.ts +1 -0
- package/dist/endpoints.js +54 -56
- package/dist/endpoints.js.map +1 -1
- package/dist/errors.js +2 -5
- package/dist/errors.js.map +1 -1
- package/dist/headers/index.d.ts +4 -5
- package/dist/headers/index.js +10 -15
- package/dist/headers/index.js.map +1 -1
- package/dist/http-helpers/index.d.ts +1 -1
- package/dist/http-helpers/index.js +41 -53
- package/dist/http-helpers/index.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.d.ts +2 -2
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js +12 -19
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js.map +1 -1
- package/dist/order-builder/helpers/buildOrder.d.ts +5 -6
- package/dist/order-builder/helpers/buildOrder.js +11 -18
- package/dist/order-builder/helpers/buildOrder.js.map +1 -1
- package/dist/order-builder/helpers/buildOrderCreationArgs.d.ts +2 -2
- package/dist/order-builder/helpers/buildOrderCreationArgs.js +13 -19
- package/dist/order-builder/helpers/buildOrderCreationArgs.js.map +1 -1
- package/dist/order-builder/helpers/calculateBuyMarketPrice.d.ts +1 -1
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js +3 -7
- package/dist/order-builder/helpers/calculateBuyMarketPrice.js.map +1 -1
- package/dist/order-builder/helpers/calculateSellMarketPrice.d.ts +1 -1
- package/dist/order-builder/helpers/calculateSellMarketPrice.js +3 -7
- package/dist/order-builder/helpers/calculateSellMarketPrice.js.map +1 -1
- package/dist/order-builder/helpers/createMarketOrder.d.ts +5 -6
- package/dist/order-builder/helpers/createMarketOrder.js +15 -19
- package/dist/order-builder/helpers/createMarketOrder.js.map +1 -1
- package/dist/order-builder/helpers/createOrder.d.ts +5 -6
- package/dist/order-builder/helpers/createOrder.js +15 -19
- package/dist/order-builder/helpers/createOrder.js.map +1 -1
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.d.ts +1 -1
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js +17 -21
- package/dist/order-builder/helpers/getMarketOrderRawAmounts.js.map +1 -1
- package/dist/order-builder/helpers/getOrderRawAmounts.d.ts +1 -1
- package/dist/order-builder/helpers/getOrderRawAmounts.js +17 -21
- package/dist/order-builder/helpers/getOrderRawAmounts.js.map +1 -1
- package/dist/order-builder/helpers/index.d.ts +10 -10
- package/dist/order-builder/helpers/index.js +10 -23
- package/dist/order-builder/helpers/index.js.map +1 -1
- package/dist/order-builder/helpers/roundingConfig.d.ts +1 -1
- package/dist/order-builder/helpers/roundingConfig.js +1 -4
- package/dist/order-builder/helpers/roundingConfig.js.map +1 -1
- package/dist/order-builder/index.d.ts +1 -1
- package/dist/order-builder/index.js +1 -4
- package/dist/order-builder/index.js.map +1 -1
- package/dist/order-builder/orderBuilder.d.ts +5 -6
- package/dist/order-builder/orderBuilder.js +34 -29
- package/dist/order-builder/orderBuilder.js.map +1 -1
- package/dist/order-utils/abi/ExchangeV1.js +1 -4
- package/dist/order-utils/abi/ExchangeV1.js.map +1 -1
- package/dist/order-utils/abi/ExchangeV2.d.ts +186 -43
- package/dist/order-utils/abi/ExchangeV2.js +234 -53
- package/dist/order-utils/abi/ExchangeV2.js.map +1 -1
- package/dist/order-utils/exchangeOrderBuilderV1.d.ts +5 -6
- package/dist/order-utils/exchangeOrderBuilderV1.js +82 -77
- package/dist/order-utils/exchangeOrderBuilderV1.js.map +1 -1
- package/dist/order-utils/exchangeOrderBuilderV2.d.ts +6 -7
- package/dist/order-utils/exchangeOrderBuilderV2.js +55 -50
- package/dist/order-utils/exchangeOrderBuilderV2.js.map +1 -1
- package/dist/order-utils/index.d.ts +2703 -0
- package/dist/order-utils/index.js +11 -11
- package/dist/order-utils/index.js.map +1 -1
- package/dist/order-utils/model/abi.js +1 -2
- package/dist/order-utils/model/ctfExchangeV1TypedData.js +3 -6
- package/dist/order-utils/model/ctfExchangeV1TypedData.js.map +1 -1
- package/dist/order-utils/model/ctfExchangeV2TypedData.js +3 -6
- package/dist/order-utils/model/ctfExchangeV2TypedData.js.map +1 -1
- package/dist/order-utils/model/eip712.js +1 -4
- package/dist/order-utils/model/eip712.js.map +1 -1
- package/dist/order-utils/model/order.js +1 -2
- package/dist/order-utils/model/orderDataV1.d.ts +4 -4
- package/dist/order-utils/model/orderDataV1.js +1 -2
- package/dist/order-utils/model/orderDataV2.d.ts +12 -13
- package/dist/order-utils/model/orderDataV2.js +1 -2
- package/dist/order-utils/model/side.js +2 -5
- package/dist/order-utils/model/side.js.map +1 -1
- package/dist/order-utils/model/signatureTypeV1.js +2 -5
- package/dist/order-utils/model/signatureTypeV1.js.map +1 -1
- package/dist/order-utils/model/signatureTypeV2.js +2 -5
- package/dist/order-utils/model/signatureTypeV2.js.map +1 -1
- package/dist/order-utils/utils.js +1 -4
- package/dist/order-utils/utils.js.map +1 -1
- package/dist/signing/constants.js +7 -10
- package/dist/signing/constants.js.map +1 -1
- package/dist/signing/eip712.d.ts +3 -4
- package/dist/signing/eip712.js +13 -12
- package/dist/signing/eip712.js.map +1 -1
- package/dist/signing/hmac.js +3 -8
- package/dist/signing/hmac.js.map +1 -1
- package/dist/signing/index.d.ts +3 -2
- package/dist/signing/index.js +3 -5
- package/dist/signing/index.js.map +1 -1
- package/dist/signing/signer.d.ts +22 -0
- package/dist/signing/signer.js +50 -0
- package/dist/signing/signer.js.map +1 -0
- package/dist/types/clob.d.ts +19 -6
- package/dist/types/clob.js +10 -13
- package/dist/types/clob.js.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +4 -7
- package/dist/types/index.js.map +1 -1
- package/dist/types/ordersV1.d.ts +3 -2
- package/dist/types/ordersV1.js +22 -2
- package/dist/types/ordersV1.js.map +1 -1
- package/dist/types/ordersV2.d.ts +14 -5
- package/dist/types/ordersV2.js +23 -2
- package/dist/types/ordersV2.js.map +1 -1
- package/dist/types/unifiedOrder.d.ts +4 -4
- package/dist/types/unifiedOrder.js +1 -4
- package/dist/types/unifiedOrder.js.map +1 -1
- package/dist/utilities.d.ts +1 -5
- package/dist/utilities.js +15 -72
- package/dist/utilities.js.map +1 -1
- package/package.json +24 -18
package/dist/types/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./ordersV1"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./ordersV2"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./unifiedOrder"), exports);
|
|
1
|
+
export * from "./clob.js";
|
|
2
|
+
export * from "./ordersV1.js";
|
|
3
|
+
export * from "./ordersV2.js";
|
|
4
|
+
export * from "./unifiedOrder.js";
|
|
8
5
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/dist/types/ordersV1.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { SignatureTypeV1, SignedOrderV1 } from "../order-utils";
|
|
2
|
-
import type { OrderType, Side } from "./clob";
|
|
1
|
+
import type { SignatureTypeV1, SignedOrderV1 } from "../order-utils/index.js";
|
|
2
|
+
import type { OrderType, Side } from "./clob.js";
|
|
3
|
+
export declare function orderToJsonV1<T extends OrderType>(order: SignedOrderV1, owner: string, orderType: T, deferExec?: boolean): NewOrderV1<T>;
|
|
3
4
|
export interface PostOrdersV1Args {
|
|
4
5
|
order: SignedOrderV1;
|
|
5
6
|
orderType: OrderType;
|
package/dist/types/ordersV1.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export function orderToJsonV1(order, owner, orderType, deferExec = false) {
|
|
2
|
+
return {
|
|
3
|
+
deferExec,
|
|
4
|
+
order: {
|
|
5
|
+
salt: parseInt(order.salt, 10),
|
|
6
|
+
maker: order.maker,
|
|
7
|
+
signer: order.signer,
|
|
8
|
+
taker: order.taker,
|
|
9
|
+
tokenId: order.tokenId,
|
|
10
|
+
makerAmount: order.makerAmount,
|
|
11
|
+
takerAmount: order.takerAmount,
|
|
12
|
+
side: order.side,
|
|
13
|
+
expiration: order.expiration,
|
|
14
|
+
nonce: order.nonce,
|
|
15
|
+
feeRateBps: order.feeRateBps,
|
|
16
|
+
signatureType: order.signatureType,
|
|
17
|
+
signature: order.signature,
|
|
18
|
+
},
|
|
19
|
+
owner,
|
|
20
|
+
orderType,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
3
23
|
//# sourceMappingURL=ordersV1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ordersV1.js","sourceRoot":"","sources":["../../src/types/ordersV1.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ordersV1.js","sourceRoot":"","sources":["../../src/types/ordersV1.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,aAAa,CAC5B,KAAoB,EACpB,KAAa,EACb,SAAY,EACZ,SAAS,GAAG,KAAK;IAEjB,OAAO;QACN,SAAS;QACT,KAAK,EAAE;YACN,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,SAAS,EAAE,KAAK,CAAC,SAAS;SAC1B;QACD,KAAK;QACL,SAAS;KACQ,CAAC;AACpB,CAAC"}
|
package/dist/types/ordersV2.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { SignatureTypeV2, SignedOrderV2 } from "../order-utils";
|
|
2
|
-
import type { OrderType, Side } from "./clob";
|
|
1
|
+
import type { SignatureTypeV2, SignedOrderV2 } from "../order-utils/index.js";
|
|
2
|
+
import type { OrderType, Side } from "./clob.js";
|
|
3
|
+
export declare function orderToJsonV2<T extends OrderType>(order: SignedOrderV2, owner: string, orderType: T, deferExec?: boolean): NewOrderV2<T>;
|
|
3
4
|
export interface PostOrdersV2Args {
|
|
4
5
|
order: SignedOrderV2;
|
|
5
6
|
orderType: OrderType;
|
|
@@ -13,10 +14,10 @@ export interface NewOrderV2<T extends OrderType> {
|
|
|
13
14
|
readonly tokenId: string;
|
|
14
15
|
readonly makerAmount: string;
|
|
15
16
|
readonly takerAmount: string;
|
|
16
|
-
readonly expiration: string;
|
|
17
17
|
readonly side: string;
|
|
18
18
|
readonly signatureType: SignatureTypeV2;
|
|
19
19
|
readonly timestamp: string;
|
|
20
|
+
readonly expiration: string;
|
|
20
21
|
readonly metadata: string;
|
|
21
22
|
readonly builder: string;
|
|
22
23
|
readonly signature: string;
|
|
@@ -43,13 +44,17 @@ export interface UserOrderV2 {
|
|
|
43
44
|
*/
|
|
44
45
|
side: Side;
|
|
45
46
|
/**
|
|
46
|
-
*
|
|
47
|
+
* Metadata (bytes32)
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
metadata?: string;
|
|
49
50
|
/**
|
|
50
51
|
* Builder code (bytes32)
|
|
51
52
|
*/
|
|
52
53
|
builderCode?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Expiration timestamp (unix seconds). Defaults to 0 (no expiration).
|
|
56
|
+
*/
|
|
57
|
+
expiration?: number;
|
|
53
58
|
}
|
|
54
59
|
export interface UserMarketOrderV2 {
|
|
55
60
|
/**
|
|
@@ -82,6 +87,10 @@ export interface UserMarketOrderV2 {
|
|
|
82
87
|
* If this field is left empty, the default flow is to use the order amount as-is
|
|
83
88
|
*/
|
|
84
89
|
userUSDCBalance?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Metadata (bytes32)
|
|
92
|
+
*/
|
|
93
|
+
metadata?: string;
|
|
85
94
|
/**
|
|
86
95
|
* Builder code (bytes32)
|
|
87
96
|
*/
|
package/dist/types/ordersV2.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export function orderToJsonV2(order, owner, orderType, deferExec = false) {
|
|
2
|
+
return {
|
|
3
|
+
deferExec,
|
|
4
|
+
order: {
|
|
5
|
+
salt: parseInt(order.salt, 10),
|
|
6
|
+
maker: order.maker,
|
|
7
|
+
signer: order.signer,
|
|
8
|
+
taker: order.taker,
|
|
9
|
+
tokenId: order.tokenId,
|
|
10
|
+
makerAmount: order.makerAmount,
|
|
11
|
+
takerAmount: order.takerAmount,
|
|
12
|
+
side: order.side,
|
|
13
|
+
signatureType: order.signatureType,
|
|
14
|
+
timestamp: order.timestamp,
|
|
15
|
+
expiration: order.expiration,
|
|
16
|
+
metadata: order.metadata,
|
|
17
|
+
builder: order.builder,
|
|
18
|
+
signature: order.signature,
|
|
19
|
+
},
|
|
20
|
+
owner,
|
|
21
|
+
orderType,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
3
24
|
//# sourceMappingURL=ordersV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ordersV2.js","sourceRoot":"","sources":["../../src/types/ordersV2.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ordersV2.js","sourceRoot":"","sources":["../../src/types/ordersV2.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,aAAa,CAC5B,KAAoB,EACpB,KAAa,EACb,SAAY,EACZ,SAAS,GAAG,KAAK;IAEjB,OAAO;QACN,SAAS;QACT,KAAK,EAAE;YACN,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC1B;QACD,KAAK;QACL,SAAS;KACQ,CAAC;AACpB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SignedOrderV1, SignedOrderV2 } from "../order-utils";
|
|
2
|
-
import type { OrderType } from "./clob";
|
|
3
|
-
import type { PostOrdersV1Args, UserMarketOrderV1, UserOrderV1 } from "./ordersV1";
|
|
4
|
-
import type { PostOrdersV2Args, UserMarketOrderV2, UserOrderV2 } from "./ordersV2";
|
|
1
|
+
import type { SignedOrderV1, SignedOrderV2 } from "../order-utils/index.js";
|
|
2
|
+
import type { OrderType } from "./clob.js";
|
|
3
|
+
import type { PostOrdersV1Args, UserMarketOrderV1, UserOrderV1 } from "./ordersV1.js";
|
|
4
|
+
import type { PostOrdersV2Args, UserMarketOrderV2, UserOrderV2 } from "./ordersV2.js";
|
|
5
5
|
export type SignedOrder = SignedOrderV1 | SignedOrderV2;
|
|
6
6
|
export type PostOrdersArgs = {
|
|
7
7
|
order: SignedOrder;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isV2Order = isV2Order;
|
|
4
|
-
function isV2Order(order) {
|
|
1
|
+
export function isV2Order(order) {
|
|
5
2
|
if ("version" in order && "order" in order) {
|
|
6
3
|
// VersionedSignedOrder type
|
|
7
4
|
return order.version === 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unifiedOrder.js","sourceRoot":"","sources":["../../src/types/unifiedOrder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unifiedOrder.js","sourceRoot":"","sources":["../../src/types/unifiedOrder.ts"],"names":[],"mappings":"AAyBA,MAAM,UAAU,SAAS,CAAC,KAAyC;IAClE,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;QAC5C,4BAA4B;QAC5B,OAAO,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,+BAA+B;IAC/B,OAAO,WAAW,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,CAAC;AAC1E,CAAC"}
|
package/dist/utilities.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { SignedOrderV1 } from "./order-utils/model/orderDataV1";
|
|
3
|
-
import type { NewOrderV1, NewOrderV2, OrderBookSummary, OrderType, TickSize } from "./types";
|
|
4
|
-
export declare function orderToJsonV1<T extends OrderType>(order: SignedOrderV1, owner: string, orderType: T, deferExec?: boolean): NewOrderV1<T>;
|
|
5
|
-
export declare function orderToJsonV2<T extends OrderType>(order: SignedOrderV2, owner: string, orderType: T, deferExec?: boolean): NewOrderV2<T>;
|
|
1
|
+
import type { OrderBookSummary, TickSize } from "./types/index.js";
|
|
6
2
|
export declare const roundNormal: (num: number, decimals: number) => number;
|
|
7
3
|
export declare const roundDown: (num: number, decimals: number) => number;
|
|
8
4
|
export declare const roundUp: (num: number, decimals: number) => number;
|
package/dist/utilities.js
CHANGED
|
@@ -1,76 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.orderToJsonV1 = orderToJsonV1;
|
|
5
|
-
exports.orderToJsonV2 = orderToJsonV2;
|
|
6
|
-
const node_crypto_1 = require("node:crypto");
|
|
7
|
-
function orderToJsonV1(order, owner, orderType, deferExec = false) {
|
|
8
|
-
return {
|
|
9
|
-
deferExec,
|
|
10
|
-
order: {
|
|
11
|
-
salt: parseInt(order.salt, 10),
|
|
12
|
-
maker: order.maker,
|
|
13
|
-
signer: order.signer,
|
|
14
|
-
taker: order.taker,
|
|
15
|
-
tokenId: order.tokenId,
|
|
16
|
-
makerAmount: order.makerAmount,
|
|
17
|
-
takerAmount: order.takerAmount,
|
|
18
|
-
side: order.side,
|
|
19
|
-
expiration: order.expiration,
|
|
20
|
-
nonce: order.nonce,
|
|
21
|
-
feeRateBps: order.feeRateBps,
|
|
22
|
-
signatureType: order.signatureType,
|
|
23
|
-
signature: order.signature,
|
|
24
|
-
},
|
|
25
|
-
owner,
|
|
26
|
-
orderType,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function orderToJsonV2(order, owner, orderType, deferExec = false) {
|
|
30
|
-
return {
|
|
31
|
-
deferExec,
|
|
32
|
-
order: {
|
|
33
|
-
salt: parseInt(order.salt, 10),
|
|
34
|
-
maker: order.maker,
|
|
35
|
-
signer: order.signer,
|
|
36
|
-
taker: order.taker,
|
|
37
|
-
tokenId: order.tokenId,
|
|
38
|
-
makerAmount: order.makerAmount,
|
|
39
|
-
takerAmount: order.takerAmount,
|
|
40
|
-
side: order.side,
|
|
41
|
-
expiration: order.expiration,
|
|
42
|
-
signatureType: order.signatureType,
|
|
43
|
-
timestamp: order.timestamp,
|
|
44
|
-
metadata: order.metadata,
|
|
45
|
-
builder: order.builder,
|
|
46
|
-
signature: order.signature,
|
|
47
|
-
},
|
|
48
|
-
owner,
|
|
49
|
-
orderType,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const roundNormal = (num, decimals) => {
|
|
53
|
-
if ((0, exports.decimalPlaces)(num) <= decimals) {
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const roundNormal = (num, decimals) => {
|
|
3
|
+
if (decimalPlaces(num) <= decimals) {
|
|
54
4
|
return num;
|
|
55
5
|
}
|
|
56
|
-
return Math.round((num + Number.EPSILON) *
|
|
6
|
+
return Math.round((num + Number.EPSILON) * 10 ** decimals) / 10 ** decimals;
|
|
57
7
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if ((0, exports.decimalPlaces)(num) <= decimals) {
|
|
8
|
+
export const roundDown = (num, decimals) => {
|
|
9
|
+
if (decimalPlaces(num) <= decimals) {
|
|
61
10
|
return num;
|
|
62
11
|
}
|
|
63
|
-
return Math.floor(num *
|
|
12
|
+
return Math.floor(num * 10 ** decimals) / 10 ** decimals;
|
|
64
13
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if ((0, exports.decimalPlaces)(num) <= decimals) {
|
|
14
|
+
export const roundUp = (num, decimals) => {
|
|
15
|
+
if (decimalPlaces(num) <= decimals) {
|
|
68
16
|
return num;
|
|
69
17
|
}
|
|
70
|
-
return Math.ceil(num *
|
|
18
|
+
return Math.ceil(num * 10 ** decimals) / 10 ** decimals;
|
|
71
19
|
};
|
|
72
|
-
|
|
73
|
-
const decimalPlaces = (num) => {
|
|
20
|
+
export const decimalPlaces = (num) => {
|
|
74
21
|
if (Number.isInteger(num)) {
|
|
75
22
|
return 0;
|
|
76
23
|
}
|
|
@@ -80,25 +27,21 @@ const decimalPlaces = (num) => {
|
|
|
80
27
|
}
|
|
81
28
|
return arr[1].length;
|
|
82
29
|
};
|
|
83
|
-
exports.decimalPlaces = decimalPlaces;
|
|
84
30
|
/**
|
|
85
31
|
* Calculates the hash for the given orderbook
|
|
86
32
|
* @param orderbook
|
|
87
33
|
* @returns
|
|
88
34
|
*/
|
|
89
|
-
const generateOrderBookSummaryHash = (orderbook) => {
|
|
35
|
+
export const generateOrderBookSummaryHash = (orderbook) => {
|
|
90
36
|
orderbook.hash = "";
|
|
91
|
-
const hash =
|
|
37
|
+
const hash = createHash("sha1").update(JSON.stringify(orderbook)).digest("hex");
|
|
92
38
|
orderbook.hash = hash;
|
|
93
39
|
return hash;
|
|
94
40
|
};
|
|
95
|
-
|
|
96
|
-
const isTickSizeSmaller = (a, b) => {
|
|
41
|
+
export const isTickSizeSmaller = (a, b) => {
|
|
97
42
|
return parseFloat(a) < parseFloat(b);
|
|
98
43
|
};
|
|
99
|
-
|
|
100
|
-
const priceValid = (price, tickSize) => {
|
|
44
|
+
export const priceValid = (price, tickSize) => {
|
|
101
45
|
return price >= parseFloat(tickSize) && price <= 1 - parseFloat(tickSize);
|
|
102
46
|
};
|
|
103
|
-
exports.priceValid = priceValid;
|
|
104
47
|
//# sourceMappingURL=utilities.js.map
|
package/dist/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAU,EAAE;IACpE,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpC,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;AAC7E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAU,EAAE;IAClE,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpC,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAU,EAAE;IAChE,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpC,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACtB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,SAA2B,EAAU,EAAE;IACnF,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC;IACpB,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;IACtB,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAW,EAAE,CAAW,EAAW,EAAE;IACtE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,QAAkB,EAAW,EAAE;IACxE,OAAO,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarket/clob-client-v2",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.0
|
|
3
|
+
"description": "TypeScript client for Polymarket's CLOB",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
7
15
|
"files": [
|
|
8
16
|
"/dist"
|
|
9
17
|
],
|
|
@@ -13,30 +21,28 @@
|
|
|
13
21
|
],
|
|
14
22
|
"license": "MIT",
|
|
15
23
|
"dependencies": {
|
|
16
|
-
"@ethersproject/providers": "^5.
|
|
17
|
-
"@ethersproject/
|
|
18
|
-
"@ethersproject/wallet": "^5.7.0",
|
|
24
|
+
"@ethersproject/providers": "^5.8.0",
|
|
25
|
+
"@ethersproject/wallet": "^5.8.0",
|
|
19
26
|
"axios": "^1.0.0",
|
|
20
|
-
"browser-or-node": "^
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"viem": "^2.41.2"
|
|
27
|
+
"browser-or-node": "^3.0.0",
|
|
28
|
+
"tslib": "^2.8.1",
|
|
29
|
+
"viem": "^2.46.3"
|
|
24
30
|
},
|
|
25
31
|
"devDependencies": {
|
|
26
|
-
"@biomejs/biome": "^2.
|
|
27
|
-
"@types/node": "^
|
|
28
|
-
"
|
|
29
|
-
"
|
|
32
|
+
"@biomejs/biome": "^2.4.5",
|
|
33
|
+
"@types/node": "^22.19.11",
|
|
34
|
+
"dotenv": "^17.3.1",
|
|
35
|
+
"ethers": "^5.8.0",
|
|
30
36
|
"husky": "^9.1.7",
|
|
31
|
-
"
|
|
32
|
-
"typescript": "^5.9.3",
|
|
37
|
+
"typescript": "^6.0.2",
|
|
33
38
|
"vitest": "^4.0.15",
|
|
34
39
|
"ws": "^8.18.3"
|
|
35
40
|
},
|
|
36
41
|
"scripts": {
|
|
37
|
-
"build": "
|
|
38
|
-
"lint": "
|
|
42
|
+
"build": "rm -rf dist && tsc",
|
|
43
|
+
"lint": "biome check ./src ./tests",
|
|
44
|
+
"format": "biome check --write ./src ./tests",
|
|
39
45
|
"deploy": "pnpm build && npm publish",
|
|
40
|
-
"test": "
|
|
46
|
+
"test": "vitest run"
|
|
41
47
|
}
|
|
42
48
|
}
|