@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,116 @@
|
|
|
1
|
+
import { Side } from "../order-utils/model/side.js";
|
|
2
|
+
import { OrderType } from "./clob.js";
|
|
3
|
+
import { SignatureTypeV1 } from "../order-utils/model/signatureTypeV1.js";
|
|
4
|
+
import { SignedOrderV1 } from "../order-utils/model/orderDataV1.js";
|
|
5
|
+
import "../order-utils/index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/types/ordersV1.d.ts
|
|
8
|
+
declare function orderToJsonV1<T extends OrderType>(order: SignedOrderV1, owner: string, orderType: T, postOnly?: boolean, deferExec?: boolean): NewOrderV1<T>;
|
|
9
|
+
interface PostOrdersV1Args {
|
|
10
|
+
order: SignedOrderV1;
|
|
11
|
+
orderType: OrderType;
|
|
12
|
+
}
|
|
13
|
+
interface NewOrderV1<T extends OrderType> {
|
|
14
|
+
readonly order: {
|
|
15
|
+
readonly salt: number;
|
|
16
|
+
readonly maker: string;
|
|
17
|
+
readonly signer: string;
|
|
18
|
+
readonly taker: string;
|
|
19
|
+
readonly tokenId: string;
|
|
20
|
+
readonly makerAmount: string;
|
|
21
|
+
readonly takerAmount: string;
|
|
22
|
+
readonly expiration: string;
|
|
23
|
+
readonly nonce: string;
|
|
24
|
+
readonly feeRateBps: string;
|
|
25
|
+
readonly side: string;
|
|
26
|
+
readonly signatureType: SignatureTypeV1;
|
|
27
|
+
readonly signature: string;
|
|
28
|
+
};
|
|
29
|
+
readonly owner: string;
|
|
30
|
+
readonly orderType: T;
|
|
31
|
+
readonly deferExec: boolean;
|
|
32
|
+
readonly postOnly: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface UserOrderV1 {
|
|
35
|
+
/**
|
|
36
|
+
* TokenID of the Conditional token asset being traded
|
|
37
|
+
*/
|
|
38
|
+
tokenID: string;
|
|
39
|
+
/**
|
|
40
|
+
* Price used to create the order
|
|
41
|
+
*/
|
|
42
|
+
price: number;
|
|
43
|
+
/**
|
|
44
|
+
* Size in terms of the ConditionalToken
|
|
45
|
+
*/
|
|
46
|
+
size: number;
|
|
47
|
+
/**
|
|
48
|
+
* Side of the order
|
|
49
|
+
*/
|
|
50
|
+
side: Side;
|
|
51
|
+
/**
|
|
52
|
+
* Fee rate, in basis points, charged to the order maker, charged on proceeds
|
|
53
|
+
*/
|
|
54
|
+
feeRateBps?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Nonce used for onchain cancellations
|
|
57
|
+
*/
|
|
58
|
+
nonce?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Timestamp after which the order is expired.
|
|
61
|
+
*/
|
|
62
|
+
expiration?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Address of the order taker. The zero address is used to indicate a public order
|
|
65
|
+
*/
|
|
66
|
+
taker?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Builder code (bytes32)
|
|
69
|
+
*/
|
|
70
|
+
builderCode?: string;
|
|
71
|
+
}
|
|
72
|
+
interface UserMarketOrderV1 {
|
|
73
|
+
/**
|
|
74
|
+
* TokenID of the Conditional token asset being traded
|
|
75
|
+
*/
|
|
76
|
+
tokenID: string;
|
|
77
|
+
/**
|
|
78
|
+
* Price used to create the order
|
|
79
|
+
* If it is not present the market price will be used.
|
|
80
|
+
*/
|
|
81
|
+
price?: number;
|
|
82
|
+
/**
|
|
83
|
+
* BUY orders: $$$ Amount to buy
|
|
84
|
+
* SELL orders: Shares to sell
|
|
85
|
+
*/
|
|
86
|
+
amount: number;
|
|
87
|
+
/**
|
|
88
|
+
* Side of the order
|
|
89
|
+
*/
|
|
90
|
+
side: Side;
|
|
91
|
+
/**
|
|
92
|
+
* Fee rate, in basis points, charged to the order maker, charged on proceeds
|
|
93
|
+
*/
|
|
94
|
+
feeRateBps?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Nonce used for onchain cancellations
|
|
97
|
+
*/
|
|
98
|
+
nonce?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Address of the order taker. The zero address is used to indicate a public order
|
|
101
|
+
*/
|
|
102
|
+
taker?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Specifies the type of order execution:
|
|
105
|
+
* - FOK (Fill or Kill): The order must be filled entirely or not at all.
|
|
106
|
+
* - FAK (Fill and Kill): The order can be partially filled, and any unfilled portion is canceled.
|
|
107
|
+
*/
|
|
108
|
+
orderType?: OrderType.FOK | OrderType.FAK;
|
|
109
|
+
/**
|
|
110
|
+
* Builder code (bytes32)
|
|
111
|
+
*/
|
|
112
|
+
builderCode?: string;
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { NewOrderV1, PostOrdersV1Args, UserMarketOrderV1, UserOrderV1, orderToJsonV1 };
|
|
116
|
+
//# sourceMappingURL=ordersV1.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/types/ordersV1.ts
|
|
2
|
+
function orderToJsonV1(order, owner, orderType, postOnly = false, deferExec = false) {
|
|
3
|
+
return {
|
|
4
|
+
deferExec,
|
|
5
|
+
postOnly,
|
|
6
|
+
order: {
|
|
7
|
+
salt: parseInt(order.salt, 10),
|
|
8
|
+
maker: order.maker,
|
|
9
|
+
signer: order.signer,
|
|
10
|
+
taker: order.taker,
|
|
11
|
+
tokenId: order.tokenId,
|
|
12
|
+
makerAmount: order.makerAmount,
|
|
13
|
+
takerAmount: order.takerAmount,
|
|
14
|
+
side: order.side,
|
|
15
|
+
expiration: order.expiration,
|
|
16
|
+
nonce: order.nonce,
|
|
17
|
+
feeRateBps: order.feeRateBps,
|
|
18
|
+
signatureType: order.signatureType,
|
|
19
|
+
signature: order.signature
|
|
20
|
+
},
|
|
21
|
+
owner,
|
|
22
|
+
orderType
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { orderToJsonV1 };
|
|
28
|
+
//# sourceMappingURL=ordersV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordersV1.js","names":[],"sources":["../../src/types/ordersV1.ts"],"sourcesContent":["import type { SignatureTypeV1, SignedOrderV1 } from \"../order-utils/index.js\";\n\nimport type { OrderType, Side } from \"./clob.js\";\n\nexport function orderToJsonV1<T extends OrderType>(\n\torder: SignedOrderV1,\n\towner: string,\n\torderType: T,\n\tpostOnly = false,\n\tdeferExec = false,\n): NewOrderV1<T> {\n\treturn {\n\t\tdeferExec,\n\t\tpostOnly,\n\t\torder: {\n\t\t\tsalt: parseInt(order.salt, 10),\n\t\t\tmaker: order.maker,\n\t\t\tsigner: order.signer,\n\t\t\ttaker: order.taker,\n\t\t\ttokenId: order.tokenId,\n\t\t\tmakerAmount: order.makerAmount,\n\t\t\ttakerAmount: order.takerAmount,\n\t\t\tside: order.side,\n\t\t\texpiration: order.expiration,\n\t\t\tnonce: order.nonce,\n\t\t\tfeeRateBps: order.feeRateBps,\n\t\t\tsignatureType: order.signatureType,\n\t\t\tsignature: order.signature,\n\t\t},\n\t\towner,\n\t\torderType,\n\t} as NewOrderV1<T>;\n}\n\nexport interface PostOrdersV1Args {\n\torder: SignedOrderV1;\n\torderType: OrderType;\n}\n\nexport interface NewOrderV1<T extends OrderType> {\n\treadonly order: {\n\t\treadonly salt: number;\n\t\treadonly maker: string;\n\t\treadonly signer: string;\n\t\treadonly taker: string;\n\t\treadonly tokenId: string;\n\t\treadonly makerAmount: string;\n\t\treadonly takerAmount: string;\n\t\treadonly expiration: string;\n\t\treadonly nonce: string;\n\t\treadonly feeRateBps: string;\n\t\treadonly side: string;\n\t\treadonly signatureType: SignatureTypeV1;\n\t\treadonly signature: string;\n\t};\n\treadonly owner: string;\n\treadonly orderType: T;\n\treadonly deferExec: boolean;\n\treadonly postOnly: boolean;\n}\n\n// Simplified order for users\nexport interface UserOrderV1 {\n\t/**\n\t * TokenID of the Conditional token asset being traded\n\t */\n\ttokenID: string;\n\n\t/**\n\t * Price used to create the order\n\t */\n\tprice: number;\n\n\t/**\n\t * Size in terms of the ConditionalToken\n\t */\n\tsize: number;\n\n\t/**\n\t * Side of the order\n\t */\n\tside: Side;\n\n\t/**\n\t * Fee rate, in basis points, charged to the order maker, charged on proceeds\n\t */\n\tfeeRateBps?: number;\n\n\t/**\n\t * Nonce used for onchain cancellations\n\t */\n\tnonce?: number;\n\n\t/**\n\t * Timestamp after which the order is expired.\n\t */\n\texpiration?: number;\n\n\t/**\n\t * Address of the order taker. The zero address is used to indicate a public order\n\t */\n\ttaker?: string;\n\n\t/**\n\t * Builder code (bytes32)\n\t */\n\tbuilderCode?: string;\n}\n\n// Simplified market order for users\nexport interface UserMarketOrderV1 {\n\t/**\n\t * TokenID of the Conditional token asset being traded\n\t */\n\ttokenID: string;\n\n\t/**\n\t * Price used to create the order\n\t * If it is not present the market price will be used.\n\t */\n\tprice?: number;\n\n\t/**\n\t * BUY orders: $$$ Amount to buy\n\t * SELL orders: Shares to sell\n\t */\n\tamount: number;\n\n\t/**\n\t * Side of the order\n\t */\n\tside: Side;\n\n\t/**\n\t * Fee rate, in basis points, charged to the order maker, charged on proceeds\n\t */\n\tfeeRateBps?: number;\n\n\t/**\n\t * Nonce used for onchain cancellations\n\t */\n\tnonce?: number;\n\n\t/**\n\t * Address of the order taker. The zero address is used to indicate a public order\n\t */\n\ttaker?: string;\n\n\t/**\n\t * Specifies the type of order execution:\n\t * - FOK (Fill or Kill): The order must be filled entirely or not at all.\n\t * - FAK (Fill and Kill): The order can be partially filled, and any unfilled portion is canceled.\n\t */\n\torderType?: OrderType.FOK | OrderType.FAK;\n\n\t/**\n\t * Builder code (bytes32)\n\t */\n\tbuilderCode?: string;\n}\n"],"mappings":";AAIA,SAAgB,cACf,OACA,OACA,WACA,WAAW,OACX,YAAY,OACI;AAChB,QAAO;EACN;EACA;EACA,OAAO;GACN,MAAM,SAAS,MAAM,MAAM,GAAG;GAC9B,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,SAAS,MAAM;GACf,aAAa,MAAM;GACnB,aAAa,MAAM;GACnB,MAAM,MAAM;GACZ,YAAY,MAAM;GAClB,OAAO,MAAM;GACb,YAAY,MAAM;GAClB,eAAe,MAAM;GACrB,WAAW,MAAM;GACjB;EACD;EACA;EACA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/types/ordersV2.ts
|
|
3
|
+
function orderToJsonV2(order, owner, orderType, postOnly = false, deferExec = false) {
|
|
4
|
+
return {
|
|
5
|
+
deferExec,
|
|
6
|
+
postOnly,
|
|
7
|
+
order: {
|
|
8
|
+
salt: parseInt(order.salt, 10),
|
|
9
|
+
maker: order.maker,
|
|
10
|
+
signer: order.signer,
|
|
11
|
+
taker: order.taker,
|
|
12
|
+
tokenId: order.tokenId,
|
|
13
|
+
makerAmount: order.makerAmount,
|
|
14
|
+
takerAmount: order.takerAmount,
|
|
15
|
+
side: order.side,
|
|
16
|
+
signatureType: order.signatureType,
|
|
17
|
+
timestamp: order.timestamp,
|
|
18
|
+
expiration: order.expiration,
|
|
19
|
+
metadata: order.metadata,
|
|
20
|
+
builder: order.builder,
|
|
21
|
+
signature: order.signature
|
|
22
|
+
},
|
|
23
|
+
owner,
|
|
24
|
+
orderType
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.orderToJsonV2 = orderToJsonV2;
|
|
30
|
+
//# sourceMappingURL=ordersV2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordersV2.cjs","names":[],"sources":["../../src/types/ordersV2.ts"],"sourcesContent":["import type { SignatureTypeV2, SignedOrderV2 } from \"../order-utils/index.js\";\n\nimport type { OrderType, Side } from \"./clob.js\";\n\nexport function orderToJsonV2<T extends OrderType>(\n\torder: SignedOrderV2,\n\towner: string,\n\torderType: T,\n\tpostOnly = false,\n\tdeferExec = false,\n): NewOrderV2<T> {\n\treturn {\n\t\tdeferExec,\n\t\tpostOnly,\n\t\torder: {\n\t\t\tsalt: parseInt(order.salt, 10),\n\t\t\tmaker: order.maker,\n\t\t\tsigner: order.signer,\n\t\t\ttaker: order.taker,\n\t\t\ttokenId: order.tokenId,\n\t\t\tmakerAmount: order.makerAmount,\n\t\t\ttakerAmount: order.takerAmount,\n\t\t\tside: order.side,\n\t\t\tsignatureType: order.signatureType,\n\t\t\ttimestamp: order.timestamp,\n\t\t\texpiration: order.expiration,\n\t\t\tmetadata: order.metadata,\n\t\t\tbuilder: order.builder,\n\t\t\tsignature: order.signature,\n\t\t},\n\t\towner,\n\t\torderType,\n\t} as NewOrderV2<T>;\n}\n\nexport interface PostOrdersV2Args {\n\torder: SignedOrderV2;\n\torderType: OrderType;\n}\n\nexport interface NewOrderV2<T extends OrderType> {\n\treadonly order: {\n\t\treadonly salt: number;\n\t\treadonly maker: string;\n\t\treadonly signer: string;\n\t\treadonly taker: string;\n\t\treadonly tokenId: string;\n\t\treadonly makerAmount: string;\n\t\treadonly takerAmount: string;\n\t\treadonly side: string;\n\t\treadonly signatureType: SignatureTypeV2;\n\t\treadonly timestamp: string;\n\t\treadonly expiration: string;\n\t\treadonly metadata: string;\n\t\treadonly builder: string;\n\t\treadonly signature: string;\n\t};\n\treadonly owner: string;\n\treadonly orderType: T;\n\treadonly deferExec: boolean;\n\treadonly postOnly: boolean;\n}\n\n// Simplified order for users\nexport interface UserOrderV2 {\n\t/**\n\t * TokenID of the Conditional token asset being traded\n\t */\n\ttokenID: string;\n\n\t/**\n\t * Price used to create the order\n\t */\n\tprice: number;\n\n\t/**\n\t * Size in terms of the ConditionalToken\n\t */\n\tsize: number;\n\n\t/**\n\t * Side of the order\n\t */\n\tside: Side;\n\n\t/**\n\t * Metadata (bytes32)\n\t */\n\tmetadata?: string;\n\n\t/**\n\t * Builder code (bytes32)\n\t */\n\tbuilderCode?: string;\n\n\t/**\n\t * Expiration timestamp (unix seconds). Defaults to 0 (no expiration).\n\t */\n\texpiration?: number;\n\n\t/**\n\t * User's USDC balance. If provided and sufficient to cover amount + fees, the order\n\t * size is used as-is. Otherwise fees are deducted from the order notional and size is reduced.\n\t * If this field is left empty, the default flow is to use the order size as-is.\n\t * This is used for marketable limit orders\n\t */\n\tuserUSDCBalance?: number;\n}\n\n// Simplified market order for users\nexport interface UserMarketOrderV2 {\n\t/**\n\t * TokenID of the Conditional token asset being traded\n\t */\n\ttokenID: string;\n\n\t/**\n\t * Price used to create the order\n\t * If it is not present the market price will be used.\n\t */\n\tprice?: number;\n\n\t/**\n\t * BUY orders: $$$ Amount to buy\n\t * SELL orders: Shares to sell\n\t */\n\tamount: number;\n\n\t/**\n\t * Side of the order\n\t */\n\tside: Side;\n\n\t/**\n\t * Specifies the type of order execution:\n\t * - FOK (Fill or Kill): The order must be filled entirely or not at all.\n\t * - FAK (Fill and Kill): The order can be partially filled, and any unfilled portion is canceled.\n\t */\n\torderType?: OrderType.FOK | OrderType.FAK;\n\n\t/**\n\t * User's USDC balance. If provided and sufficient to cover amount + fees, the order\n\t * amount is used as-is. Otherwise fees are deducted from the amount.\n\t * If this field is left empty, the default flow is to use the order amount as-is\n\t */\n\tuserUSDCBalance?: number;\n\n\t/**\n\t * Metadata (bytes32)\n\t */\n\tmetadata?: string;\n\n\t/**\n\t * Builder code (bytes32)\n\t */\n\tbuilderCode?: string;\n}\n"],"mappings":";;AAIA,SAAgB,cACf,OACA,OACA,WACA,WAAW,OACX,YAAY,OACI;AAChB,QAAO;EACN;EACA;EACA,OAAO;GACN,MAAM,SAAS,MAAM,MAAM,GAAG;GAC9B,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,SAAS,MAAM;GACf,aAAa,MAAM;GACnB,aAAa,MAAM;GACnB,MAAM,MAAM;GACZ,eAAe,MAAM;GACrB,WAAW,MAAM;GACjB,YAAY,MAAM;GAClB,UAAU,MAAM;GAChB,SAAS,MAAM;GACf,WAAW,MAAM;GACjB;EACD;EACA;EACA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Side } from "../order-utils/model/side.cjs";
|
|
2
|
+
import { OrderType } from "./clob.cjs";
|
|
3
|
+
import { SignatureTypeV2 } from "../order-utils/model/signatureTypeV2.cjs";
|
|
4
|
+
import { SignedOrderV2 } from "../order-utils/model/orderDataV2.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/types/ordersV2.d.ts
|
|
7
|
+
declare function orderToJsonV2<T extends OrderType>(order: SignedOrderV2, owner: string, orderType: T, postOnly?: boolean, deferExec?: boolean): NewOrderV2<T>;
|
|
8
|
+
interface PostOrdersV2Args {
|
|
9
|
+
order: SignedOrderV2;
|
|
10
|
+
orderType: OrderType;
|
|
11
|
+
}
|
|
12
|
+
interface NewOrderV2<T extends OrderType> {
|
|
13
|
+
readonly order: {
|
|
14
|
+
readonly salt: number;
|
|
15
|
+
readonly maker: string;
|
|
16
|
+
readonly signer: string;
|
|
17
|
+
readonly taker: string;
|
|
18
|
+
readonly tokenId: string;
|
|
19
|
+
readonly makerAmount: string;
|
|
20
|
+
readonly takerAmount: string;
|
|
21
|
+
readonly side: string;
|
|
22
|
+
readonly signatureType: SignatureTypeV2;
|
|
23
|
+
readonly timestamp: string;
|
|
24
|
+
readonly expiration: string;
|
|
25
|
+
readonly metadata: string;
|
|
26
|
+
readonly builder: string;
|
|
27
|
+
readonly signature: string;
|
|
28
|
+
};
|
|
29
|
+
readonly owner: string;
|
|
30
|
+
readonly orderType: T;
|
|
31
|
+
readonly deferExec: boolean;
|
|
32
|
+
readonly postOnly: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface UserOrderV2 {
|
|
35
|
+
/**
|
|
36
|
+
* TokenID of the Conditional token asset being traded
|
|
37
|
+
*/
|
|
38
|
+
tokenID: string;
|
|
39
|
+
/**
|
|
40
|
+
* Price used to create the order
|
|
41
|
+
*/
|
|
42
|
+
price: number;
|
|
43
|
+
/**
|
|
44
|
+
* Size in terms of the ConditionalToken
|
|
45
|
+
*/
|
|
46
|
+
size: number;
|
|
47
|
+
/**
|
|
48
|
+
* Side of the order
|
|
49
|
+
*/
|
|
50
|
+
side: Side;
|
|
51
|
+
/**
|
|
52
|
+
* Metadata (bytes32)
|
|
53
|
+
*/
|
|
54
|
+
metadata?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Builder code (bytes32)
|
|
57
|
+
*/
|
|
58
|
+
builderCode?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Expiration timestamp (unix seconds). Defaults to 0 (no expiration).
|
|
61
|
+
*/
|
|
62
|
+
expiration?: number;
|
|
63
|
+
/**
|
|
64
|
+
* User's USDC balance. If provided and sufficient to cover amount + fees, the order
|
|
65
|
+
* size is used as-is. Otherwise fees are deducted from the order notional and size is reduced.
|
|
66
|
+
* If this field is left empty, the default flow is to use the order size as-is.
|
|
67
|
+
* This is used for marketable limit orders
|
|
68
|
+
*/
|
|
69
|
+
userUSDCBalance?: number;
|
|
70
|
+
}
|
|
71
|
+
interface UserMarketOrderV2 {
|
|
72
|
+
/**
|
|
73
|
+
* TokenID of the Conditional token asset being traded
|
|
74
|
+
*/
|
|
75
|
+
tokenID: string;
|
|
76
|
+
/**
|
|
77
|
+
* Price used to create the order
|
|
78
|
+
* If it is not present the market price will be used.
|
|
79
|
+
*/
|
|
80
|
+
price?: number;
|
|
81
|
+
/**
|
|
82
|
+
* BUY orders: $$$ Amount to buy
|
|
83
|
+
* SELL orders: Shares to sell
|
|
84
|
+
*/
|
|
85
|
+
amount: number;
|
|
86
|
+
/**
|
|
87
|
+
* Side of the order
|
|
88
|
+
*/
|
|
89
|
+
side: Side;
|
|
90
|
+
/**
|
|
91
|
+
* Specifies the type of order execution:
|
|
92
|
+
* - FOK (Fill or Kill): The order must be filled entirely or not at all.
|
|
93
|
+
* - FAK (Fill and Kill): The order can be partially filled, and any unfilled portion is canceled.
|
|
94
|
+
*/
|
|
95
|
+
orderType?: OrderType.FOK | OrderType.FAK;
|
|
96
|
+
/**
|
|
97
|
+
* User's USDC balance. If provided and sufficient to cover amount + fees, the order
|
|
98
|
+
* amount is used as-is. Otherwise fees are deducted from the amount.
|
|
99
|
+
* If this field is left empty, the default flow is to use the order amount as-is
|
|
100
|
+
*/
|
|
101
|
+
userUSDCBalance?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Metadata (bytes32)
|
|
104
|
+
*/
|
|
105
|
+
metadata?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Builder code (bytes32)
|
|
108
|
+
*/
|
|
109
|
+
builderCode?: string;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { NewOrderV2, PostOrdersV2Args, UserMarketOrderV2, UserOrderV2, orderToJsonV2 };
|
|
113
|
+
//# sourceMappingURL=ordersV2.d.cts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Side } from "../order-utils/model/side.js";
|
|
2
|
+
import { OrderType } from "./clob.js";
|
|
3
|
+
import { SignatureTypeV2 } from "../order-utils/model/signatureTypeV2.js";
|
|
4
|
+
import { SignedOrderV2 } from "../order-utils/model/orderDataV2.js";
|
|
5
|
+
import "../order-utils/index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/types/ordersV2.d.ts
|
|
8
|
+
declare function orderToJsonV2<T extends OrderType>(order: SignedOrderV2, owner: string, orderType: T, postOnly?: boolean, deferExec?: boolean): NewOrderV2<T>;
|
|
9
|
+
interface PostOrdersV2Args {
|
|
10
|
+
order: SignedOrderV2;
|
|
11
|
+
orderType: OrderType;
|
|
12
|
+
}
|
|
13
|
+
interface NewOrderV2<T extends OrderType> {
|
|
14
|
+
readonly order: {
|
|
15
|
+
readonly salt: number;
|
|
16
|
+
readonly maker: string;
|
|
17
|
+
readonly signer: string;
|
|
18
|
+
readonly taker: string;
|
|
19
|
+
readonly tokenId: string;
|
|
20
|
+
readonly makerAmount: string;
|
|
21
|
+
readonly takerAmount: string;
|
|
22
|
+
readonly side: string;
|
|
23
|
+
readonly signatureType: SignatureTypeV2;
|
|
24
|
+
readonly timestamp: string;
|
|
25
|
+
readonly expiration: string;
|
|
26
|
+
readonly metadata: string;
|
|
27
|
+
readonly builder: string;
|
|
28
|
+
readonly signature: string;
|
|
29
|
+
};
|
|
30
|
+
readonly owner: string;
|
|
31
|
+
readonly orderType: T;
|
|
32
|
+
readonly deferExec: boolean;
|
|
33
|
+
readonly postOnly: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface UserOrderV2 {
|
|
36
|
+
/**
|
|
37
|
+
* TokenID of the Conditional token asset being traded
|
|
38
|
+
*/
|
|
39
|
+
tokenID: string;
|
|
40
|
+
/**
|
|
41
|
+
* Price used to create the order
|
|
42
|
+
*/
|
|
43
|
+
price: number;
|
|
44
|
+
/**
|
|
45
|
+
* Size in terms of the ConditionalToken
|
|
46
|
+
*/
|
|
47
|
+
size: number;
|
|
48
|
+
/**
|
|
49
|
+
* Side of the order
|
|
50
|
+
*/
|
|
51
|
+
side: Side;
|
|
52
|
+
/**
|
|
53
|
+
* Metadata (bytes32)
|
|
54
|
+
*/
|
|
55
|
+
metadata?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Builder code (bytes32)
|
|
58
|
+
*/
|
|
59
|
+
builderCode?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Expiration timestamp (unix seconds). Defaults to 0 (no expiration).
|
|
62
|
+
*/
|
|
63
|
+
expiration?: number;
|
|
64
|
+
/**
|
|
65
|
+
* User's USDC balance. If provided and sufficient to cover amount + fees, the order
|
|
66
|
+
* size is used as-is. Otherwise fees are deducted from the order notional and size is reduced.
|
|
67
|
+
* If this field is left empty, the default flow is to use the order size as-is.
|
|
68
|
+
* This is used for marketable limit orders
|
|
69
|
+
*/
|
|
70
|
+
userUSDCBalance?: number;
|
|
71
|
+
}
|
|
72
|
+
interface UserMarketOrderV2 {
|
|
73
|
+
/**
|
|
74
|
+
* TokenID of the Conditional token asset being traded
|
|
75
|
+
*/
|
|
76
|
+
tokenID: string;
|
|
77
|
+
/**
|
|
78
|
+
* Price used to create the order
|
|
79
|
+
* If it is not present the market price will be used.
|
|
80
|
+
*/
|
|
81
|
+
price?: number;
|
|
82
|
+
/**
|
|
83
|
+
* BUY orders: $$$ Amount to buy
|
|
84
|
+
* SELL orders: Shares to sell
|
|
85
|
+
*/
|
|
86
|
+
amount: number;
|
|
87
|
+
/**
|
|
88
|
+
* Side of the order
|
|
89
|
+
*/
|
|
90
|
+
side: Side;
|
|
91
|
+
/**
|
|
92
|
+
* Specifies the type of order execution:
|
|
93
|
+
* - FOK (Fill or Kill): The order must be filled entirely or not at all.
|
|
94
|
+
* - FAK (Fill and Kill): The order can be partially filled, and any unfilled portion is canceled.
|
|
95
|
+
*/
|
|
96
|
+
orderType?: OrderType.FOK | OrderType.FAK;
|
|
97
|
+
/**
|
|
98
|
+
* User's USDC balance. If provided and sufficient to cover amount + fees, the order
|
|
99
|
+
* amount is used as-is. Otherwise fees are deducted from the amount.
|
|
100
|
+
* If this field is left empty, the default flow is to use the order amount as-is
|
|
101
|
+
*/
|
|
102
|
+
userUSDCBalance?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Metadata (bytes32)
|
|
105
|
+
*/
|
|
106
|
+
metadata?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Builder code (bytes32)
|
|
109
|
+
*/
|
|
110
|
+
builderCode?: string;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { NewOrderV2, PostOrdersV2Args, UserMarketOrderV2, UserOrderV2, orderToJsonV2 };
|
|
114
|
+
//# sourceMappingURL=ordersV2.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/types/ordersV2.ts
|
|
2
|
+
function orderToJsonV2(order, owner, orderType, postOnly = false, deferExec = false) {
|
|
3
|
+
return {
|
|
4
|
+
deferExec,
|
|
5
|
+
postOnly,
|
|
6
|
+
order: {
|
|
7
|
+
salt: parseInt(order.salt, 10),
|
|
8
|
+
maker: order.maker,
|
|
9
|
+
signer: order.signer,
|
|
10
|
+
taker: order.taker,
|
|
11
|
+
tokenId: order.tokenId,
|
|
12
|
+
makerAmount: order.makerAmount,
|
|
13
|
+
takerAmount: order.takerAmount,
|
|
14
|
+
side: order.side,
|
|
15
|
+
signatureType: order.signatureType,
|
|
16
|
+
timestamp: order.timestamp,
|
|
17
|
+
expiration: order.expiration,
|
|
18
|
+
metadata: order.metadata,
|
|
19
|
+
builder: order.builder,
|
|
20
|
+
signature: order.signature
|
|
21
|
+
},
|
|
22
|
+
owner,
|
|
23
|
+
orderType
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { orderToJsonV2 };
|
|
29
|
+
//# sourceMappingURL=ordersV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordersV2.js","names":[],"sources":["../../src/types/ordersV2.ts"],"sourcesContent":["import type { SignatureTypeV2, SignedOrderV2 } from \"../order-utils/index.js\";\n\nimport type { OrderType, Side } from \"./clob.js\";\n\nexport function orderToJsonV2<T extends OrderType>(\n\torder: SignedOrderV2,\n\towner: string,\n\torderType: T,\n\tpostOnly = false,\n\tdeferExec = false,\n): NewOrderV2<T> {\n\treturn {\n\t\tdeferExec,\n\t\tpostOnly,\n\t\torder: {\n\t\t\tsalt: parseInt(order.salt, 10),\n\t\t\tmaker: order.maker,\n\t\t\tsigner: order.signer,\n\t\t\ttaker: order.taker,\n\t\t\ttokenId: order.tokenId,\n\t\t\tmakerAmount: order.makerAmount,\n\t\t\ttakerAmount: order.takerAmount,\n\t\t\tside: order.side,\n\t\t\tsignatureType: order.signatureType,\n\t\t\ttimestamp: order.timestamp,\n\t\t\texpiration: order.expiration,\n\t\t\tmetadata: order.metadata,\n\t\t\tbuilder: order.builder,\n\t\t\tsignature: order.signature,\n\t\t},\n\t\towner,\n\t\torderType,\n\t} as NewOrderV2<T>;\n}\n\nexport interface PostOrdersV2Args {\n\torder: SignedOrderV2;\n\torderType: OrderType;\n}\n\nexport interface NewOrderV2<T extends OrderType> {\n\treadonly order: {\n\t\treadonly salt: number;\n\t\treadonly maker: string;\n\t\treadonly signer: string;\n\t\treadonly taker: string;\n\t\treadonly tokenId: string;\n\t\treadonly makerAmount: string;\n\t\treadonly takerAmount: string;\n\t\treadonly side: string;\n\t\treadonly signatureType: SignatureTypeV2;\n\t\treadonly timestamp: string;\n\t\treadonly expiration: string;\n\t\treadonly metadata: string;\n\t\treadonly builder: string;\n\t\treadonly signature: string;\n\t};\n\treadonly owner: string;\n\treadonly orderType: T;\n\treadonly deferExec: boolean;\n\treadonly postOnly: boolean;\n}\n\n// Simplified order for users\nexport interface UserOrderV2 {\n\t/**\n\t * TokenID of the Conditional token asset being traded\n\t */\n\ttokenID: string;\n\n\t/**\n\t * Price used to create the order\n\t */\n\tprice: number;\n\n\t/**\n\t * Size in terms of the ConditionalToken\n\t */\n\tsize: number;\n\n\t/**\n\t * Side of the order\n\t */\n\tside: Side;\n\n\t/**\n\t * Metadata (bytes32)\n\t */\n\tmetadata?: string;\n\n\t/**\n\t * Builder code (bytes32)\n\t */\n\tbuilderCode?: string;\n\n\t/**\n\t * Expiration timestamp (unix seconds). Defaults to 0 (no expiration).\n\t */\n\texpiration?: number;\n\n\t/**\n\t * User's USDC balance. If provided and sufficient to cover amount + fees, the order\n\t * size is used as-is. Otherwise fees are deducted from the order notional and size is reduced.\n\t * If this field is left empty, the default flow is to use the order size as-is.\n\t * This is used for marketable limit orders\n\t */\n\tuserUSDCBalance?: number;\n}\n\n// Simplified market order for users\nexport interface UserMarketOrderV2 {\n\t/**\n\t * TokenID of the Conditional token asset being traded\n\t */\n\ttokenID: string;\n\n\t/**\n\t * Price used to create the order\n\t * If it is not present the market price will be used.\n\t */\n\tprice?: number;\n\n\t/**\n\t * BUY orders: $$$ Amount to buy\n\t * SELL orders: Shares to sell\n\t */\n\tamount: number;\n\n\t/**\n\t * Side of the order\n\t */\n\tside: Side;\n\n\t/**\n\t * Specifies the type of order execution:\n\t * - FOK (Fill or Kill): The order must be filled entirely or not at all.\n\t * - FAK (Fill and Kill): The order can be partially filled, and any unfilled portion is canceled.\n\t */\n\torderType?: OrderType.FOK | OrderType.FAK;\n\n\t/**\n\t * User's USDC balance. If provided and sufficient to cover amount + fees, the order\n\t * amount is used as-is. Otherwise fees are deducted from the amount.\n\t * If this field is left empty, the default flow is to use the order amount as-is\n\t */\n\tuserUSDCBalance?: number;\n\n\t/**\n\t * Metadata (bytes32)\n\t */\n\tmetadata?: string;\n\n\t/**\n\t * Builder code (bytes32)\n\t */\n\tbuilderCode?: string;\n}\n"],"mappings":";AAIA,SAAgB,cACf,OACA,OACA,WACA,WAAW,OACX,YAAY,OACI;AAChB,QAAO;EACN;EACA;EACA,OAAO;GACN,MAAM,SAAS,MAAM,MAAM,GAAG;GAC9B,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,SAAS,MAAM;GACf,aAAa,MAAM;GACnB,aAAa,MAAM;GACnB,MAAM,MAAM;GACZ,eAAe,MAAM;GACrB,WAAW,MAAM;GACjB,YAAY,MAAM;GAClB,UAAU,MAAM;GAChB,SAAS,MAAM;GACf,WAAW,MAAM;GACjB;EACD;EACA;EACA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/types/unifiedOrder.ts
|
|
3
|
+
function isV2Order(order) {
|
|
4
|
+
if ("version" in order && "order" in order) return order.version === 2 || order.version === 3;
|
|
5
|
+
return "timestamp" in order && "metadata" in order && "builder" in order;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.isV2Order = isV2Order;
|
|
10
|
+
//# sourceMappingURL=unifiedOrder.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unifiedOrder.cjs","names":[],"sources":["../../src/types/unifiedOrder.ts"],"sourcesContent":["import type { SignedOrderV1, SignedOrderV2 } from \"../order-utils/index.js\";\nimport type { OrderType } from \"./clob.js\";\nimport type { PostOrdersV1Args, UserMarketOrderV1, UserOrderV1 } from \"./ordersV1.js\";\nimport type { PostOrdersV2Args, UserMarketOrderV2, UserOrderV2 } from \"./ordersV2.js\";\n\nexport type SignedOrder = SignedOrderV1 | SignedOrderV2;\n\nexport type PostOrdersArgs = { order: SignedOrder; orderType: OrderType };\n\nexport type VersionedSignedOrder =\n\t| { version: 1; order: SignedOrderV1 }\n\t| { version: 2; order: SignedOrderV2 }\n\t| { version: 3; order: SignedOrderV2 };\n\nexport type VersionedUserOrder =\n\t| { version: 1; order: UserOrderV1 }\n\t| { version: 2; order: UserOrderV2 }\n\t| { version: 3; order: UserOrderV2 };\n\nexport type VersionedUserMarketOrder =\n\t| { version: 1; order: UserMarketOrderV1 }\n\t| { version: 2; order: UserMarketOrderV2 }\n\t| { version: 3; order: UserMarketOrderV2 };\n\nexport type VersionedPostOrdersArgs =\n\t| { version: 1; args: PostOrdersV1Args }\n\t| { version: 2; args: PostOrdersV2Args }\n\t| { version: 3; args: PostOrdersV2Args };\n\nexport function isV2Order(order: SignedOrder | VersionedSignedOrder): order is SignedOrderV2 {\n\tif (\"version\" in order && \"order\" in order) {\n\t\t// VersionedSignedOrder type\n\t\treturn order.version === 2 || order.version === 3;\n\t}\n\t// Check for V2-specific fields\n\treturn \"timestamp\" in order && \"metadata\" in order && \"builder\" in order;\n}\n"],"mappings":";;AA6BA,SAAgB,UAAU,OAAmE;AAC5F,KAAI,aAAa,SAAS,WAAW,MAEpC,QAAO,MAAM,YAAY,KAAK,MAAM,YAAY;AAGjD,QAAO,eAAe,SAAS,cAAc,SAAS,aAAa"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { OrderType } from "./clob.cjs";
|
|
2
|
+
import { PostOrdersV1Args, UserMarketOrderV1, UserOrderV1 } from "./ordersV1.cjs";
|
|
3
|
+
import { PostOrdersV2Args, UserMarketOrderV2, UserOrderV2 } from "./ordersV2.cjs";
|
|
4
|
+
import { SignedOrderV1 } from "../order-utils/model/orderDataV1.cjs";
|
|
5
|
+
import { SignedOrderV2 } from "../order-utils/model/orderDataV2.cjs";
|
|
6
|
+
|
|
7
|
+
//#region src/types/unifiedOrder.d.ts
|
|
8
|
+
type SignedOrder = SignedOrderV1 | SignedOrderV2;
|
|
9
|
+
type PostOrdersArgs = {
|
|
10
|
+
order: SignedOrder;
|
|
11
|
+
orderType: OrderType;
|
|
12
|
+
};
|
|
13
|
+
type VersionedSignedOrder = {
|
|
14
|
+
version: 1;
|
|
15
|
+
order: SignedOrderV1;
|
|
16
|
+
} | {
|
|
17
|
+
version: 2;
|
|
18
|
+
order: SignedOrderV2;
|
|
19
|
+
} | {
|
|
20
|
+
version: 3;
|
|
21
|
+
order: SignedOrderV2;
|
|
22
|
+
};
|
|
23
|
+
type VersionedUserOrder = {
|
|
24
|
+
version: 1;
|
|
25
|
+
order: UserOrderV1;
|
|
26
|
+
} | {
|
|
27
|
+
version: 2;
|
|
28
|
+
order: UserOrderV2;
|
|
29
|
+
} | {
|
|
30
|
+
version: 3;
|
|
31
|
+
order: UserOrderV2;
|
|
32
|
+
};
|
|
33
|
+
type VersionedUserMarketOrder = {
|
|
34
|
+
version: 1;
|
|
35
|
+
order: UserMarketOrderV1;
|
|
36
|
+
} | {
|
|
37
|
+
version: 2;
|
|
38
|
+
order: UserMarketOrderV2;
|
|
39
|
+
} | {
|
|
40
|
+
version: 3;
|
|
41
|
+
order: UserMarketOrderV2;
|
|
42
|
+
};
|
|
43
|
+
type VersionedPostOrdersArgs = {
|
|
44
|
+
version: 1;
|
|
45
|
+
args: PostOrdersV1Args;
|
|
46
|
+
} | {
|
|
47
|
+
version: 2;
|
|
48
|
+
args: PostOrdersV2Args;
|
|
49
|
+
} | {
|
|
50
|
+
version: 3;
|
|
51
|
+
args: PostOrdersV2Args;
|
|
52
|
+
};
|
|
53
|
+
declare function isV2Order(order: SignedOrder | VersionedSignedOrder): order is SignedOrderV2;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { PostOrdersArgs, SignedOrder, VersionedPostOrdersArgs, VersionedSignedOrder, VersionedUserMarketOrder, VersionedUserOrder, isV2Order };
|
|
56
|
+
//# sourceMappingURL=unifiedOrder.d.cts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { OrderType } from "./clob.js";
|
|
2
|
+
import { PostOrdersV1Args, UserMarketOrderV1, UserOrderV1 } from "./ordersV1.js";
|
|
3
|
+
import { PostOrdersV2Args, UserMarketOrderV2, UserOrderV2 } from "./ordersV2.js";
|
|
4
|
+
import { SignedOrderV1 } from "../order-utils/model/orderDataV1.js";
|
|
5
|
+
import { SignedOrderV2 } from "../order-utils/model/orderDataV2.js";
|
|
6
|
+
import "../order-utils/index.js";
|
|
7
|
+
|
|
8
|
+
//#region src/types/unifiedOrder.d.ts
|
|
9
|
+
type SignedOrder = SignedOrderV1 | SignedOrderV2;
|
|
10
|
+
type PostOrdersArgs = {
|
|
11
|
+
order: SignedOrder;
|
|
12
|
+
orderType: OrderType;
|
|
13
|
+
};
|
|
14
|
+
type VersionedSignedOrder = {
|
|
15
|
+
version: 1;
|
|
16
|
+
order: SignedOrderV1;
|
|
17
|
+
} | {
|
|
18
|
+
version: 2;
|
|
19
|
+
order: SignedOrderV2;
|
|
20
|
+
} | {
|
|
21
|
+
version: 3;
|
|
22
|
+
order: SignedOrderV2;
|
|
23
|
+
};
|
|
24
|
+
type VersionedUserOrder = {
|
|
25
|
+
version: 1;
|
|
26
|
+
order: UserOrderV1;
|
|
27
|
+
} | {
|
|
28
|
+
version: 2;
|
|
29
|
+
order: UserOrderV2;
|
|
30
|
+
} | {
|
|
31
|
+
version: 3;
|
|
32
|
+
order: UserOrderV2;
|
|
33
|
+
};
|
|
34
|
+
type VersionedUserMarketOrder = {
|
|
35
|
+
version: 1;
|
|
36
|
+
order: UserMarketOrderV1;
|
|
37
|
+
} | {
|
|
38
|
+
version: 2;
|
|
39
|
+
order: UserMarketOrderV2;
|
|
40
|
+
} | {
|
|
41
|
+
version: 3;
|
|
42
|
+
order: UserMarketOrderV2;
|
|
43
|
+
};
|
|
44
|
+
type VersionedPostOrdersArgs = {
|
|
45
|
+
version: 1;
|
|
46
|
+
args: PostOrdersV1Args;
|
|
47
|
+
} | {
|
|
48
|
+
version: 2;
|
|
49
|
+
args: PostOrdersV2Args;
|
|
50
|
+
} | {
|
|
51
|
+
version: 3;
|
|
52
|
+
args: PostOrdersV2Args;
|
|
53
|
+
};
|
|
54
|
+
declare function isV2Order(order: SignedOrder | VersionedSignedOrder): order is SignedOrderV2;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { PostOrdersArgs, SignedOrder, VersionedPostOrdersArgs, VersionedSignedOrder, VersionedUserMarketOrder, VersionedUserOrder, isV2Order };
|
|
57
|
+
//# sourceMappingURL=unifiedOrder.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/types/unifiedOrder.ts
|
|
2
|
+
function isV2Order(order) {
|
|
3
|
+
if ("version" in order && "order" in order) return order.version === 2 || order.version === 3;
|
|
4
|
+
return "timestamp" in order && "metadata" in order && "builder" in order;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isV2Order };
|
|
9
|
+
//# sourceMappingURL=unifiedOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unifiedOrder.js","names":[],"sources":["../../src/types/unifiedOrder.ts"],"sourcesContent":["import type { SignedOrderV1, SignedOrderV2 } from \"../order-utils/index.js\";\nimport type { OrderType } from \"./clob.js\";\nimport type { PostOrdersV1Args, UserMarketOrderV1, UserOrderV1 } from \"./ordersV1.js\";\nimport type { PostOrdersV2Args, UserMarketOrderV2, UserOrderV2 } from \"./ordersV2.js\";\n\nexport type SignedOrder = SignedOrderV1 | SignedOrderV2;\n\nexport type PostOrdersArgs = { order: SignedOrder; orderType: OrderType };\n\nexport type VersionedSignedOrder =\n\t| { version: 1; order: SignedOrderV1 }\n\t| { version: 2; order: SignedOrderV2 }\n\t| { version: 3; order: SignedOrderV2 };\n\nexport type VersionedUserOrder =\n\t| { version: 1; order: UserOrderV1 }\n\t| { version: 2; order: UserOrderV2 }\n\t| { version: 3; order: UserOrderV2 };\n\nexport type VersionedUserMarketOrder =\n\t| { version: 1; order: UserMarketOrderV1 }\n\t| { version: 2; order: UserMarketOrderV2 }\n\t| { version: 3; order: UserMarketOrderV2 };\n\nexport type VersionedPostOrdersArgs =\n\t| { version: 1; args: PostOrdersV1Args }\n\t| { version: 2; args: PostOrdersV2Args }\n\t| { version: 3; args: PostOrdersV2Args };\n\nexport function isV2Order(order: SignedOrder | VersionedSignedOrder): order is SignedOrderV2 {\n\tif (\"version\" in order && \"order\" in order) {\n\t\t// VersionedSignedOrder type\n\t\treturn order.version === 2 || order.version === 3;\n\t}\n\t// Check for V2-specific fields\n\treturn \"timestamp\" in order && \"metadata\" in order && \"builder\" in order;\n}\n"],"mappings":";AA6BA,SAAgB,UAAU,OAAmE;AAC5F,KAAI,aAAa,SAAS,WAAW,MAEpC,QAAO,MAAM,YAAY,KAAK,MAAM,YAAY;AAGjD,QAAO,eAAe,SAAS,cAAc,SAAS,aAAa"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utilities.ts
|
|
3
|
+
const roundNormal = (num, decimals) => {
|
|
4
|
+
if (decimalPlaces(num) <= decimals) return num;
|
|
5
|
+
return Math.round((num + Number.EPSILON) * 10 ** decimals) / 10 ** decimals;
|
|
6
|
+
};
|
|
7
|
+
const roundDown = (num, decimals) => {
|
|
8
|
+
if (decimalPlaces(num) <= decimals) return num;
|
|
9
|
+
return Math.floor(num * 10 ** decimals) / 10 ** decimals;
|
|
10
|
+
};
|
|
11
|
+
const roundUp = (num, decimals) => {
|
|
12
|
+
if (decimalPlaces(num) <= decimals) return num;
|
|
13
|
+
return Math.ceil(num * 10 ** decimals) / 10 ** decimals;
|
|
14
|
+
};
|
|
15
|
+
const decimalPlaces = (num) => {
|
|
16
|
+
if (Number.isInteger(num)) return 0;
|
|
17
|
+
const arr = num.toString().split(".");
|
|
18
|
+
if (arr.length <= 1) return 0;
|
|
19
|
+
return arr[1].length;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Calculates the hash for the given orderbook
|
|
23
|
+
* @param orderbook
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
const generateOrderBookSummaryHash = async (orderbook) => {
|
|
27
|
+
if (!globalThis.crypto?.subtle) throw new Error("generateOrderBookSummaryHash: globalThis.crypto.subtle is unavailable. Requires Node >=20 or a secure browser context (HTTPS or localhost).");
|
|
28
|
+
orderbook.hash = "";
|
|
29
|
+
const data = new TextEncoder().encode(JSON.stringify(orderbook));
|
|
30
|
+
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-1", data);
|
|
31
|
+
const hash = Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
32
|
+
orderbook.hash = hash;
|
|
33
|
+
return hash;
|
|
34
|
+
};
|
|
35
|
+
const isTickSizeSmaller = (a, b) => {
|
|
36
|
+
return parseFloat(a) < parseFloat(b);
|
|
37
|
+
};
|
|
38
|
+
const priceValid = (price, tickSize) => {
|
|
39
|
+
return price >= parseFloat(tickSize) && price <= 1 - parseFloat(tickSize);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.decimalPlaces = decimalPlaces;
|
|
44
|
+
exports.generateOrderBookSummaryHash = generateOrderBookSummaryHash;
|
|
45
|
+
exports.isTickSizeSmaller = isTickSizeSmaller;
|
|
46
|
+
exports.priceValid = priceValid;
|
|
47
|
+
exports.roundDown = roundDown;
|
|
48
|
+
exports.roundNormal = roundNormal;
|
|
49
|
+
exports.roundUp = roundUp;
|
|
50
|
+
//# sourceMappingURL=utilities.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.cjs","names":[],"sources":["../src/utilities.ts"],"sourcesContent":["import type { OrderBookSummary, TickSize } from \"./types/index.js\";\n\nexport const roundNormal = (num: number, decimals: number): number => {\n\tif (decimalPlaces(num) <= decimals) {\n\t\treturn num;\n\t}\n\treturn Math.round((num + Number.EPSILON) * 10 ** decimals) / 10 ** decimals;\n};\n\nexport const roundDown = (num: number, decimals: number): number => {\n\tif (decimalPlaces(num) <= decimals) {\n\t\treturn num;\n\t}\n\treturn Math.floor(num * 10 ** decimals) / 10 ** decimals;\n};\n\nexport const roundUp = (num: number, decimals: number): number => {\n\tif (decimalPlaces(num) <= decimals) {\n\t\treturn num;\n\t}\n\treturn Math.ceil(num * 10 ** decimals) / 10 ** decimals;\n};\n\nexport const decimalPlaces = (num: number): number => {\n\tif (Number.isInteger(num)) {\n\t\treturn 0;\n\t}\n\n\tconst arr = num.toString().split(\".\");\n\tif (arr.length <= 1) {\n\t\treturn 0;\n\t}\n\n\treturn arr[1].length;\n};\n\n/**\n * Calculates the hash for the given orderbook\n * @param orderbook\n * @returns\n */\nexport const generateOrderBookSummaryHash = async (\n\torderbook: OrderBookSummary,\n): Promise<string> => {\n\tif (!globalThis.crypto?.subtle) {\n\t\tthrow new Error(\n\t\t\t\"generateOrderBookSummaryHash: globalThis.crypto.subtle is unavailable. Requires Node >=20 or a secure browser context (HTTPS or localhost).\",\n\t\t);\n\t}\n\torderbook.hash = \"\";\n\tconst data = new TextEncoder().encode(JSON.stringify(orderbook));\n\tconst hashBuffer = await globalThis.crypto.subtle.digest(\"SHA-1\", data);\n\tconst hashArray = Array.from(new Uint8Array(hashBuffer));\n\tconst hash = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n\torderbook.hash = hash;\n\treturn hash;\n};\n\nexport const isTickSizeSmaller = (a: TickSize, b: TickSize): boolean => {\n\treturn parseFloat(a) < parseFloat(b);\n};\n\nexport const priceValid = (price: number, tickSize: TickSize): boolean => {\n\treturn price >= parseFloat(tickSize) && price <= 1 - parseFloat(tickSize);\n};\n"],"mappings":";;AAEA,MAAa,eAAe,KAAa,aAA6B;AACrE,KAAI,cAAc,IAAI,IAAI,SACzB,QAAO;AAER,QAAO,KAAK,OAAO,MAAM,OAAO,WAAW,MAAM,SAAS,GAAG,MAAM;;AAGpE,MAAa,aAAa,KAAa,aAA6B;AACnE,KAAI,cAAc,IAAI,IAAI,SACzB,QAAO;AAER,QAAO,KAAK,MAAM,MAAM,MAAM,SAAS,GAAG,MAAM;;AAGjD,MAAa,WAAW,KAAa,aAA6B;AACjE,KAAI,cAAc,IAAI,IAAI,SACzB,QAAO;AAER,QAAO,KAAK,KAAK,MAAM,MAAM,SAAS,GAAG,MAAM;;AAGhD,MAAa,iBAAiB,QAAwB;AACrD,KAAI,OAAO,UAAU,IAAI,CACxB,QAAO;CAGR,MAAM,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI;AACrC,KAAI,IAAI,UAAU,EACjB,QAAO;AAGR,QAAO,IAAI,GAAG;;;;;;;AAQf,MAAa,+BAA+B,OAC3C,cACqB;AACrB,KAAI,CAAC,WAAW,QAAQ,OACvB,OAAM,IAAI,MACT,8IACA;AAEF,WAAU,OAAO;CACjB,MAAM,OAAO,IAAI,aAAa,CAAC,OAAO,KAAK,UAAU,UAAU,CAAC;CAChE,MAAM,aAAa,MAAM,WAAW,OAAO,OAAO,OAAO,SAAS,KAAK;CAEvE,MAAM,OADY,MAAM,KAAK,IAAI,WAAW,WAAW,CAAC,CACjC,KAAI,MAAK,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG;AACzE,WAAU,OAAO;AACjB,QAAO;;AAGR,MAAa,qBAAqB,GAAa,MAAyB;AACvE,QAAO,WAAW,EAAE,GAAG,WAAW,EAAE;;AAGrC,MAAa,cAAc,OAAe,aAAgC;AACzE,QAAO,SAAS,WAAW,SAAS,IAAI,SAAS,IAAI,WAAW,SAAS"}
|