@polymarket/clob-client-v2 1.0.8 → 1.2.0-canary.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 +16 -0
- package/dist/client.cjs +61 -16
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +15 -5
- package/dist/client.d.ts +15 -5
- package/dist/client.js +61 -16
- package/dist/client.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.cjs +3 -2
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.cjs.map +1 -1
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js +3 -2
- package/dist/order-builder/helpers/buildMarketOrderCreationArgs.js.map +1 -1
- package/dist/order-builder/helpers/buildOrderCreationArgs.cjs +3 -2
- package/dist/order-builder/helpers/buildOrderCreationArgs.cjs.map +1 -1
- package/dist/order-builder/helpers/buildOrderCreationArgs.js +3 -2
- package/dist/order-builder/helpers/buildOrderCreationArgs.js.map +1 -1
- package/dist/order-builder/helpers/createMarketOrder.cjs +6 -4
- package/dist/order-builder/helpers/createMarketOrder.cjs.map +1 -1
- package/dist/order-builder/helpers/createMarketOrder.js +6 -4
- package/dist/order-builder/helpers/createMarketOrder.js.map +1 -1
- package/dist/order-builder/helpers/createOrder.cjs +6 -4
- package/dist/order-builder/helpers/createOrder.cjs.map +1 -1
- package/dist/order-builder/helpers/createOrder.js +6 -4
- package/dist/order-builder/helpers/createOrder.js.map +1 -1
- package/dist/order-builder/helpers/orderAsset.cjs +16 -0
- package/dist/order-builder/helpers/orderAsset.cjs.map +1 -0
- package/dist/order-builder/helpers/orderAsset.js +14 -0
- package/dist/order-builder/helpers/orderAsset.js.map +1 -0
- package/dist/order-builder/orderBuilder.cjs +2 -2
- package/dist/order-builder/orderBuilder.cjs.map +1 -1
- package/dist/order-builder/orderBuilder.d.cts +2 -2
- package/dist/order-builder/orderBuilder.d.ts +2 -2
- package/dist/order-builder/orderBuilder.js +2 -2
- package/dist/order-builder/orderBuilder.js.map +1 -1
- package/dist/types/clob.cjs.map +1 -1
- package/dist/types/clob.d.cts +5 -0
- package/dist/types/clob.d.ts +5 -0
- package/dist/types/clob.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ordersV1.cjs.map +1 -1
- package/dist/types/ordersV1.d.cts +2 -0
- package/dist/types/ordersV1.d.ts +2 -0
- package/dist/types/ordersV1.js.map +1 -1
- package/dist/types/ordersV2.cjs.map +1 -1
- package/dist/types/ordersV2.d.cts +17 -13
- package/dist/types/ordersV2.d.ts +17 -13
- package/dist/types/ordersV2.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildMarketOrderCreationArgs.js","names":[],"sources":["../../../src/order-builder/helpers/buildMarketOrderCreationArgs.ts"],"sourcesContent":["import { parseUnits, zeroAddress } from \"viem\";\n\nimport { COLLATERAL_TOKEN_DECIMALS } from \"../../config.js\";\nimport { bytes32Zero } from \"../../constants.js\";\nimport type {\n\tOrderDataV1,\n\tOrderDataV2,\n\tSignatureTypeV1,\n\tSignatureTypeV2,\n} from \"../../order-utils/index.js\";\nimport type { RoundConfig, UserMarketOrderV1, UserMarketOrderV2 } from \"../../types/index.js\";\n\nimport { getMarketOrderRawAmounts } from \"./index.js\";\n\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 1,\n): Promise<OrderDataV1>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion?: 2,\n): Promise<OrderDataV2>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 3,\n): Promise<OrderDataV2>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number,\n): Promise<OrderDataV1 | OrderDataV2>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number = 2,\n): Promise<OrderDataV1 | OrderDataV2> {\n\tconst { side, rawMakerAmt, rawTakerAmt } = getMarketOrderRawAmounts(\n\t\tuserMarketOrder.side,\n\t\tuserMarketOrder.amount,\n\t\tuserMarketOrder.price || 1,\n\t\troundConfig,\n\t);\n\n\tconst makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\tconst takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\n\tif (version === 1) {\n\t\tconst v1Order = userMarketOrder as UserMarketOrderV1;\n\t\treturn {\n\t\t\tmaker,\n\t\t\ttaker: v1Order.taker ?? zeroAddress,\n\t\t\ttokenId: userMarketOrder
|
|
1
|
+
{"version":3,"file":"buildMarketOrderCreationArgs.js","names":[],"sources":["../../../src/order-builder/helpers/buildMarketOrderCreationArgs.ts"],"sourcesContent":["import { parseUnits, zeroAddress } from \"viem\";\n\nimport { COLLATERAL_TOKEN_DECIMALS } from \"../../config.js\";\nimport { bytes32Zero } from \"../../constants.js\";\nimport type {\n\tOrderDataV1,\n\tOrderDataV2,\n\tSignatureTypeV1,\n\tSignatureTypeV2,\n} from \"../../order-utils/index.js\";\nimport type { RoundConfig, UserMarketOrderV1, UserMarketOrderV2 } from \"../../types/index.js\";\n\nimport { getMarketOrderRawAmounts } from \"./index.js\";\nimport { resolveOrderAssetID } from \"./orderAsset.js\";\n\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 1,\n): Promise<OrderDataV1>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion?: 2,\n): Promise<OrderDataV2>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 3,\n): Promise<OrderDataV2>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number,\n): Promise<OrderDataV1 | OrderDataV2>;\nexport async function buildMarketOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number = 2,\n): Promise<OrderDataV1 | OrderDataV2> {\n\tconst { side, rawMakerAmt, rawTakerAmt } = getMarketOrderRawAmounts(\n\t\tuserMarketOrder.side,\n\t\tuserMarketOrder.amount,\n\t\tuserMarketOrder.price || 1,\n\t\troundConfig,\n\t);\n\n\tconst makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\tconst takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\n\tif (version === 1) {\n\t\tconst v1Order = userMarketOrder as UserMarketOrderV1;\n\t\treturn {\n\t\t\tmaker,\n\t\t\ttaker: v1Order.taker ?? zeroAddress,\n\t\t\ttokenId: resolveOrderAssetID(userMarketOrder),\n\t\t\tmakerAmount,\n\t\t\ttakerAmount,\n\t\t\tside,\n\t\t\tsigner,\n\t\t\tsignatureType: signatureType as unknown as SignatureTypeV1,\n\t\t\tfeeRateBps: v1Order.feeRateBps?.toString() ?? \"0\",\n\t\t\tnonce: v1Order.nonce?.toString() ?? \"0\",\n\t\t};\n\t}\n\n\treturn {\n\t\tmaker,\n\t\ttokenId: resolveOrderAssetID(userMarketOrder),\n\t\tmakerAmount,\n\t\ttakerAmount,\n\t\tside,\n\t\tsigner,\n\t\tsignatureType,\n\t\ttimestamp: Date.now().toString(),\n\t\tmetadata:\n\t\t\t\"metadata\" in userMarketOrder ? (userMarketOrder.metadata ?? bytes32Zero) : bytes32Zero,\n\t\tbuilder: userMarketOrder.builderCode ?? bytes32Zero,\n\t};\n}\n"],"mappings":";;;;;;;AA+CA,eAAsB,6BACrB,QACA,OACA,eACA,iBACA,aACA,UAAkB,GACmB;CACrC,MAAM,EAAE,MAAM,aAAa,gBAAgB,yBAC1C,gBAAgB,MAChB,gBAAgB,QAChB,gBAAgB,SAAS,GACzB,YACA;CAED,MAAM,cAAc,WAAW,YAAY,UAAU,EAAE,0BAA0B,CAAC,UAAU;CAC5F,MAAM,cAAc,WAAW,YAAY,UAAU,EAAE,0BAA0B,CAAC,UAAU;AAE5F,KAAI,YAAY,GAAG;EAClB,MAAM,UAAU;AAChB,SAAO;GACN;GACA,OAAO,QAAQ,SAAS;GACxB,SAAS,oBAAoB,gBAAgB;GAC7C;GACA;GACA;GACA;GACe;GACf,YAAY,QAAQ,YAAY,UAAU,IAAI;GAC9C,OAAO,QAAQ,OAAO,UAAU,IAAI;GACpC;;AAGF,QAAO;EACN;EACA,SAAS,oBAAoB,gBAAgB;EAC7C;EACA;EACA;EACA;EACA;EACA,WAAW,KAAK,KAAK,CAAC,UAAU;EAChC,UACC,cAAc,kBAAmB,gBAAgB,YAAY,cAAe;EAC7E,SAAS,gBAAgB,eAAe;EACxC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_constants = require('../../constants.cjs');
|
|
3
3
|
const require_config = require('../../config.cjs');
|
|
4
|
+
const require_orderAsset = require('./orderAsset.cjs');
|
|
4
5
|
const require_getOrderRawAmounts = require('./getOrderRawAmounts.cjs');
|
|
5
6
|
let viem = require("viem");
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ async function buildOrderCreationArgs(signer, maker, signatureType, userOrder, r
|
|
|
14
15
|
return {
|
|
15
16
|
maker,
|
|
16
17
|
taker: v1Order.taker ?? viem.zeroAddress,
|
|
17
|
-
tokenId: userOrder
|
|
18
|
+
tokenId: require_orderAsset.resolveOrderAssetID(userOrder),
|
|
18
19
|
makerAmount,
|
|
19
20
|
takerAmount,
|
|
20
21
|
side,
|
|
@@ -27,7 +28,7 @@ async function buildOrderCreationArgs(signer, maker, signatureType, userOrder, r
|
|
|
27
28
|
}
|
|
28
29
|
return {
|
|
29
30
|
maker,
|
|
30
|
-
tokenId: userOrder
|
|
31
|
+
tokenId: require_orderAsset.resolveOrderAssetID(userOrder),
|
|
31
32
|
makerAmount,
|
|
32
33
|
takerAmount,
|
|
33
34
|
side,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildOrderCreationArgs.cjs","names":["getOrderRawAmounts","COLLATERAL_TOKEN_DECIMALS","zeroAddress","bytes32Zero"],"sources":["../../../src/order-builder/helpers/buildOrderCreationArgs.ts"],"sourcesContent":["import { parseUnits, zeroAddress } from \"viem\";\n\nimport { COLLATERAL_TOKEN_DECIMALS } from \"../../config.js\";\nimport { bytes32Zero } from \"../../constants.js\";\nimport type {\n\tOrderDataV1,\n\tOrderDataV2,\n\tSignatureTypeV1,\n\tSignatureTypeV2,\n} from \"../../order-utils/index.js\";\nimport type { RoundConfig, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\n\nimport { getOrderRawAmounts } from \"./getOrderRawAmounts.js\";\n\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 1,\n): Promise<OrderDataV1>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion?: 2,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 3,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number,\n): Promise<OrderDataV1 | OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number = 2,\n): Promise<OrderDataV1 | OrderDataV2> {\n\tconst { side, rawMakerAmt, rawTakerAmt } = getOrderRawAmounts(\n\t\tuserOrder.side,\n\t\tuserOrder.size,\n\t\tuserOrder.price,\n\t\troundConfig,\n\t);\n\n\tconst makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\tconst takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\n\tif (version === 1) {\n\t\tconst v1Order = userOrder as UserOrderV1;\n\t\treturn {\n\t\t\tmaker,\n\t\t\ttaker: v1Order.taker ?? zeroAddress,\n\t\t\ttokenId: userOrder
|
|
1
|
+
{"version":3,"file":"buildOrderCreationArgs.cjs","names":["getOrderRawAmounts","COLLATERAL_TOKEN_DECIMALS","zeroAddress","resolveOrderAssetID","bytes32Zero"],"sources":["../../../src/order-builder/helpers/buildOrderCreationArgs.ts"],"sourcesContent":["import { parseUnits, zeroAddress } from \"viem\";\n\nimport { COLLATERAL_TOKEN_DECIMALS } from \"../../config.js\";\nimport { bytes32Zero } from \"../../constants.js\";\nimport type {\n\tOrderDataV1,\n\tOrderDataV2,\n\tSignatureTypeV1,\n\tSignatureTypeV2,\n} from \"../../order-utils/index.js\";\nimport type { RoundConfig, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\n\nimport { getOrderRawAmounts } from \"./getOrderRawAmounts.js\";\nimport { resolveOrderAssetID } from \"./orderAsset.js\";\n\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 1,\n): Promise<OrderDataV1>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion?: 2,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 3,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number,\n): Promise<OrderDataV1 | OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number = 2,\n): Promise<OrderDataV1 | OrderDataV2> {\n\tconst { side, rawMakerAmt, rawTakerAmt } = getOrderRawAmounts(\n\t\tuserOrder.side,\n\t\tuserOrder.size,\n\t\tuserOrder.price,\n\t\troundConfig,\n\t);\n\n\tconst makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\tconst takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\n\tif (version === 1) {\n\t\tconst v1Order = userOrder as UserOrderV1;\n\t\treturn {\n\t\t\tmaker,\n\t\t\ttaker: v1Order.taker ?? zeroAddress,\n\t\t\ttokenId: resolveOrderAssetID(userOrder),\n\t\t\tmakerAmount,\n\t\t\ttakerAmount,\n\t\t\tside,\n\t\t\tsigner,\n\t\t\tsignatureType: signatureType as unknown as SignatureTypeV1,\n\t\t\tfeeRateBps: v1Order.feeRateBps?.toString() ?? \"0\",\n\t\t\tnonce: v1Order.nonce?.toString() ?? \"0\",\n\t\t\texpiration: userOrder.expiration !== undefined ? userOrder.expiration.toString() : \"0\",\n\t\t};\n\t}\n\n\treturn {\n\t\tmaker,\n\t\ttokenId: resolveOrderAssetID(userOrder),\n\t\tmakerAmount,\n\t\ttakerAmount,\n\t\tside,\n\t\tsigner,\n\t\tsignatureType,\n\t\ttimestamp: Date.now().toString(),\n\t\tmetadata: \"metadata\" in userOrder ? (userOrder.metadata ?? bytes32Zero) : bytes32Zero,\n\t\tbuilder: userOrder.builderCode ?? bytes32Zero,\n\t\texpiration: userOrder.expiration !== undefined ? userOrder.expiration.toString() : \"0\",\n\t};\n}\n"],"mappings":";;;;;;;;AA+CA,eAAsB,uBACrB,QACA,OACA,eACA,WACA,aACA,UAAkB,GACmB;CACrC,MAAM,EAAE,MAAM,aAAa,gBAAgBA,8CAC1C,UAAU,MACV,UAAU,MACV,UAAU,OACV,YACA;CAED,MAAM,mCAAyB,YAAY,UAAU,EAAEC,yCAA0B,CAAC,UAAU;CAC5F,MAAM,mCAAyB,YAAY,UAAU,EAAEA,yCAA0B,CAAC,UAAU;AAE5F,KAAI,YAAY,GAAG;EAClB,MAAM,UAAU;AAChB,SAAO;GACN;GACA,OAAO,QAAQ,SAASC;GACxB,SAASC,uCAAoB,UAAU;GACvC;GACA;GACA;GACA;GACe;GACf,YAAY,QAAQ,YAAY,UAAU,IAAI;GAC9C,OAAO,QAAQ,OAAO,UAAU,IAAI;GACpC,YAAY,UAAU,eAAe,SAAY,UAAU,WAAW,UAAU,GAAG;GACnF;;AAGF,QAAO;EACN;EACA,SAASA,uCAAoB,UAAU;EACvC;EACA;EACA;EACA;EACA;EACA,WAAW,KAAK,KAAK,CAAC,UAAU;EAChC,UAAU,cAAc,YAAa,UAAU,YAAYC,gCAAeA;EAC1E,SAAS,UAAU,eAAeA;EAClC,YAAY,UAAU,eAAe,SAAY,UAAU,WAAW,UAAU,GAAG;EACnF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bytes32Zero } from "../../constants.js";
|
|
2
2
|
import { COLLATERAL_TOKEN_DECIMALS } from "../../config.js";
|
|
3
|
+
import { resolveOrderAssetID } from "./orderAsset.js";
|
|
3
4
|
import { getOrderRawAmounts } from "./getOrderRawAmounts.js";
|
|
4
5
|
import { parseUnits, zeroAddress } from "viem";
|
|
5
6
|
|
|
@@ -13,7 +14,7 @@ async function buildOrderCreationArgs(signer, maker, signatureType, userOrder, r
|
|
|
13
14
|
return {
|
|
14
15
|
maker,
|
|
15
16
|
taker: v1Order.taker ?? zeroAddress,
|
|
16
|
-
tokenId: userOrder
|
|
17
|
+
tokenId: resolveOrderAssetID(userOrder),
|
|
17
18
|
makerAmount,
|
|
18
19
|
takerAmount,
|
|
19
20
|
side,
|
|
@@ -26,7 +27,7 @@ async function buildOrderCreationArgs(signer, maker, signatureType, userOrder, r
|
|
|
26
27
|
}
|
|
27
28
|
return {
|
|
28
29
|
maker,
|
|
29
|
-
tokenId: userOrder
|
|
30
|
+
tokenId: resolveOrderAssetID(userOrder),
|
|
30
31
|
makerAmount,
|
|
31
32
|
takerAmount,
|
|
32
33
|
side,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildOrderCreationArgs.js","names":[],"sources":["../../../src/order-builder/helpers/buildOrderCreationArgs.ts"],"sourcesContent":["import { parseUnits, zeroAddress } from \"viem\";\n\nimport { COLLATERAL_TOKEN_DECIMALS } from \"../../config.js\";\nimport { bytes32Zero } from \"../../constants.js\";\nimport type {\n\tOrderDataV1,\n\tOrderDataV2,\n\tSignatureTypeV1,\n\tSignatureTypeV2,\n} from \"../../order-utils/index.js\";\nimport type { RoundConfig, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\n\nimport { getOrderRawAmounts } from \"./getOrderRawAmounts.js\";\n\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 1,\n): Promise<OrderDataV1>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion?: 2,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 3,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number,\n): Promise<OrderDataV1 | OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number = 2,\n): Promise<OrderDataV1 | OrderDataV2> {\n\tconst { side, rawMakerAmt, rawTakerAmt } = getOrderRawAmounts(\n\t\tuserOrder.side,\n\t\tuserOrder.size,\n\t\tuserOrder.price,\n\t\troundConfig,\n\t);\n\n\tconst makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\tconst takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\n\tif (version === 1) {\n\t\tconst v1Order = userOrder as UserOrderV1;\n\t\treturn {\n\t\t\tmaker,\n\t\t\ttaker: v1Order.taker ?? zeroAddress,\n\t\t\ttokenId: userOrder
|
|
1
|
+
{"version":3,"file":"buildOrderCreationArgs.js","names":[],"sources":["../../../src/order-builder/helpers/buildOrderCreationArgs.ts"],"sourcesContent":["import { parseUnits, zeroAddress } from \"viem\";\n\nimport { COLLATERAL_TOKEN_DECIMALS } from \"../../config.js\";\nimport { bytes32Zero } from \"../../constants.js\";\nimport type {\n\tOrderDataV1,\n\tOrderDataV2,\n\tSignatureTypeV1,\n\tSignatureTypeV2,\n} from \"../../order-utils/index.js\";\nimport type { RoundConfig, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\n\nimport { getOrderRawAmounts } from \"./getOrderRawAmounts.js\";\nimport { resolveOrderAssetID } from \"./orderAsset.js\";\n\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 1,\n): Promise<OrderDataV1>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion?: 2,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: 3,\n): Promise<OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number,\n): Promise<OrderDataV1 | OrderDataV2>;\nexport async function buildOrderCreationArgs(\n\tsigner: string,\n\tmaker: string,\n\tsignatureType: SignatureTypeV2,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\troundConfig: RoundConfig,\n\tversion: number = 2,\n): Promise<OrderDataV1 | OrderDataV2> {\n\tconst { side, rawMakerAmt, rawTakerAmt } = getOrderRawAmounts(\n\t\tuserOrder.side,\n\t\tuserOrder.size,\n\t\tuserOrder.price,\n\t\troundConfig,\n\t);\n\n\tconst makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\tconst takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();\n\n\tif (version === 1) {\n\t\tconst v1Order = userOrder as UserOrderV1;\n\t\treturn {\n\t\t\tmaker,\n\t\t\ttaker: v1Order.taker ?? zeroAddress,\n\t\t\ttokenId: resolveOrderAssetID(userOrder),\n\t\t\tmakerAmount,\n\t\t\ttakerAmount,\n\t\t\tside,\n\t\t\tsigner,\n\t\t\tsignatureType: signatureType as unknown as SignatureTypeV1,\n\t\t\tfeeRateBps: v1Order.feeRateBps?.toString() ?? \"0\",\n\t\t\tnonce: v1Order.nonce?.toString() ?? \"0\",\n\t\t\texpiration: userOrder.expiration !== undefined ? userOrder.expiration.toString() : \"0\",\n\t\t};\n\t}\n\n\treturn {\n\t\tmaker,\n\t\ttokenId: resolveOrderAssetID(userOrder),\n\t\tmakerAmount,\n\t\ttakerAmount,\n\t\tside,\n\t\tsigner,\n\t\tsignatureType,\n\t\ttimestamp: Date.now().toString(),\n\t\tmetadata: \"metadata\" in userOrder ? (userOrder.metadata ?? bytes32Zero) : bytes32Zero,\n\t\tbuilder: userOrder.builderCode ?? bytes32Zero,\n\t\texpiration: userOrder.expiration !== undefined ? userOrder.expiration.toString() : \"0\",\n\t};\n}\n"],"mappings":";;;;;;;AA+CA,eAAsB,uBACrB,QACA,OACA,eACA,WACA,aACA,UAAkB,GACmB;CACrC,MAAM,EAAE,MAAM,aAAa,gBAAgB,mBAC1C,UAAU,MACV,UAAU,MACV,UAAU,OACV,YACA;CAED,MAAM,cAAc,WAAW,YAAY,UAAU,EAAE,0BAA0B,CAAC,UAAU;CAC5F,MAAM,cAAc,WAAW,YAAY,UAAU,EAAE,0BAA0B,CAAC,UAAU;AAE5F,KAAI,YAAY,GAAG;EAClB,MAAM,UAAU;AAChB,SAAO;GACN;GACA,OAAO,QAAQ,SAAS;GACxB,SAAS,oBAAoB,UAAU;GACvC;GACA;GACA;GACA;GACe;GACf,YAAY,QAAQ,YAAY,UAAU,IAAI;GAC9C,OAAO,QAAQ,OAAO,UAAU,IAAI;GACpC,YAAY,UAAU,eAAe,SAAY,UAAU,WAAW,UAAU,GAAG;GACnF;;AAGF,QAAO;EACN;EACA,SAAS,oBAAoB,UAAU;EACvC;EACA;EACA;EACA;EACA;EACA,WAAW,KAAK,KAAK,CAAC,UAAU;EAChC,UAAU,cAAc,YAAa,UAAU,YAAY,cAAe;EAC1E,SAAS,UAAU,eAAe;EAClC,YAAY,UAAU,eAAe,SAAY,UAAU,WAAW,UAAU,GAAG;EACnF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_signer = require('../../signing/signer.cjs');
|
|
2
2
|
const require_config = require('../../config.cjs');
|
|
3
|
+
const require_orderAsset = require('./orderAsset.cjs');
|
|
3
4
|
const require_buildMarketOrderCreationArgs = require('./buildMarketOrderCreationArgs.cjs');
|
|
4
5
|
const require_signatureTypeV2 = require('../../order-utils/model/signatureTypeV2.cjs');
|
|
5
6
|
const require_buildOrder = require('./buildOrder.cjs');
|
|
@@ -11,9 +12,10 @@ const createMarketOrder = async (eoaSigner, chainId, signatureType, funderAddres
|
|
|
11
12
|
const maker = funderAddress === void 0 ? eoaSignerAddress : funderAddress;
|
|
12
13
|
const signerForOrder = signatureType === require_signatureTypeV2.SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;
|
|
13
14
|
const contractConfig = require_config.getContractConfig(chainId);
|
|
14
|
-
const
|
|
15
|
+
const orderVersion = require_orderAsset.resolveOrderRouting(userMarketOrder, version).exchangeVersion ?? version;
|
|
16
|
+
const orderData = await require_buildMarketOrderCreationArgs.buildMarketOrderCreationArgs(signerForOrder, maker, signatureType, userMarketOrder, require_roundingConfig.ROUNDING_CONFIG[options.tickSize], orderVersion);
|
|
15
17
|
let exchangeContract;
|
|
16
|
-
switch (
|
|
18
|
+
switch (orderVersion) {
|
|
17
19
|
case 1:
|
|
18
20
|
if (signatureType === require_signatureTypeV2.SignatureTypeV2.POLY_1271) throw new Error(`signature type POLY_1271 is not supported for v1 orders`);
|
|
19
21
|
exchangeContract = options.negRisk ? contractConfig.negRiskExchange : contractConfig.exchange;
|
|
@@ -24,9 +26,9 @@ const createMarketOrder = async (eoaSigner, chainId, signatureType, funderAddres
|
|
|
24
26
|
case 3:
|
|
25
27
|
exchangeContract = contractConfig.exchangeV3;
|
|
26
28
|
break;
|
|
27
|
-
default: throw new Error(`unsupported order version ${
|
|
29
|
+
default: throw new Error(`unsupported order version ${orderVersion}`);
|
|
28
30
|
}
|
|
29
|
-
return require_buildOrder.buildOrder(eoaSigner, exchangeContract, chainId, orderData,
|
|
31
|
+
return require_buildOrder.buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMarketOrder.cjs","names":["getSignerAddress","SignatureTypeV2","getContractConfig","buildMarketOrderCreationArgs","ROUNDING_CONFIG","exchangeContract: string","buildOrder"],"sources":["../../../src/order-builder/helpers/createMarketOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n} from \"../../types/index.js\";\nimport { buildMarketOrderCreationArgs } from \"./buildMarketOrderCreationArgs.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createMarketOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\n\tconst orderData = await buildMarketOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserMarketOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\
|
|
1
|
+
{"version":3,"file":"createMarketOrder.cjs","names":["getSignerAddress","SignatureTypeV2","getContractConfig","resolveOrderRouting","buildMarketOrderCreationArgs","ROUNDING_CONFIG","exchangeContract: string","buildOrder"],"sources":["../../../src/order-builder/helpers/createMarketOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n} from \"../../types/index.js\";\nimport { buildMarketOrderCreationArgs } from \"./buildMarketOrderCreationArgs.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { resolveOrderRouting } from \"./orderAsset.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createMarketOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\tconst orderVersion = resolveOrderRouting(userMarketOrder, version).exchangeVersion ?? version;\n\n\tconst orderData = await buildMarketOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserMarketOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\torderVersion,\n\t);\n\n\tlet exchangeContract: string;\n\tswitch (orderVersion) {\n\t\tcase 1:\n\t\t\tif (signatureType === SignatureTypeV2.POLY_1271) {\n\t\t\t\tthrow new Error(`signature type POLY_1271 is not supported for v1 orders`);\n\t\t\t}\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchange\n\t\t\t\t: contractConfig.exchange;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchangeV2\n\t\t\t\t: contractConfig.exchangeV2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\texchangeContract = contractConfig.exchangeV3;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`unsupported order version ${orderVersion}`);\n\t}\n\n\treturn buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,oBAAoB,OAChC,WACA,SACA,eACA,eACA,iBACA,SACA,YAC4C;CAC5C,MAAM,mBAAmB,MAAMA,gCAAiB,UAAU;CAG1D,MAAM,QAAQ,kBAAkB,SAAY,mBAAmB;CAG/D,MAAM,iBAAiB,kBAAkBC,wCAAgB,YAAY,QAAQ;CAC7E,MAAM,iBAAiBC,iCAAkB,QAAQ;CACjD,MAAM,eAAeC,uCAAoB,iBAAiB,QAAQ,CAAC,mBAAmB;CAEtF,MAAM,YAAY,MAAMC,kEACvB,gBACA,OACA,eACA,iBACAC,uCAAgB,QAAQ,WACxB,aACA;CAED,IAAIC;AACJ,SAAQ,cAAR;EACC,KAAK;AACJ,OAAI,kBAAkBL,wCAAgB,UACrC,OAAM,IAAI,MAAM,0DAA0D;AAE3E,sBAAmB,QAAQ,UACxB,eAAe,kBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,QAAQ,UACxB,eAAe,oBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,eAAe;AAClC;EACD,QACC,OAAM,IAAI,MAAM,6BAA6B,eAAe;;AAG9D,QAAOM,8BAAW,WAAW,kBAAkB,SAAS,WAAW,aAAa"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSignerAddress } from "../../signing/signer.js";
|
|
2
2
|
import { getContractConfig } from "../../config.js";
|
|
3
|
+
import { resolveOrderRouting } from "./orderAsset.js";
|
|
3
4
|
import { buildMarketOrderCreationArgs } from "./buildMarketOrderCreationArgs.js";
|
|
4
5
|
import { SignatureTypeV2 } from "../../order-utils/model/signatureTypeV2.js";
|
|
5
6
|
import { buildOrder } from "./buildOrder.js";
|
|
@@ -11,9 +12,10 @@ const createMarketOrder = async (eoaSigner, chainId, signatureType, funderAddres
|
|
|
11
12
|
const maker = funderAddress === void 0 ? eoaSignerAddress : funderAddress;
|
|
12
13
|
const signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;
|
|
13
14
|
const contractConfig = getContractConfig(chainId);
|
|
14
|
-
const
|
|
15
|
+
const orderVersion = resolveOrderRouting(userMarketOrder, version).exchangeVersion ?? version;
|
|
16
|
+
const orderData = await buildMarketOrderCreationArgs(signerForOrder, maker, signatureType, userMarketOrder, ROUNDING_CONFIG[options.tickSize], orderVersion);
|
|
15
17
|
let exchangeContract;
|
|
16
|
-
switch (
|
|
18
|
+
switch (orderVersion) {
|
|
17
19
|
case 1:
|
|
18
20
|
if (signatureType === SignatureTypeV2.POLY_1271) throw new Error(`signature type POLY_1271 is not supported for v1 orders`);
|
|
19
21
|
exchangeContract = options.negRisk ? contractConfig.negRiskExchange : contractConfig.exchange;
|
|
@@ -24,9 +26,9 @@ const createMarketOrder = async (eoaSigner, chainId, signatureType, funderAddres
|
|
|
24
26
|
case 3:
|
|
25
27
|
exchangeContract = contractConfig.exchangeV3;
|
|
26
28
|
break;
|
|
27
|
-
default: throw new Error(`unsupported order version ${
|
|
29
|
+
default: throw new Error(`unsupported order version ${orderVersion}`);
|
|
28
30
|
}
|
|
29
|
-
return buildOrder(eoaSigner, exchangeContract, chainId, orderData,
|
|
31
|
+
return buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMarketOrder.js","names":["exchangeContract: string"],"sources":["../../../src/order-builder/helpers/createMarketOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n} from \"../../types/index.js\";\nimport { buildMarketOrderCreationArgs } from \"./buildMarketOrderCreationArgs.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createMarketOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\n\tconst orderData = await buildMarketOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserMarketOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\
|
|
1
|
+
{"version":3,"file":"createMarketOrder.js","names":["exchangeContract: string"],"sources":["../../../src/order-builder/helpers/createMarketOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n} from \"../../types/index.js\";\nimport { buildMarketOrderCreationArgs } from \"./buildMarketOrderCreationArgs.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { resolveOrderRouting } from \"./orderAsset.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createMarketOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\tconst orderVersion = resolveOrderRouting(userMarketOrder, version).exchangeVersion ?? version;\n\n\tconst orderData = await buildMarketOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserMarketOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\torderVersion,\n\t);\n\n\tlet exchangeContract: string;\n\tswitch (orderVersion) {\n\t\tcase 1:\n\t\t\tif (signatureType === SignatureTypeV2.POLY_1271) {\n\t\t\t\tthrow new Error(`signature type POLY_1271 is not supported for v1 orders`);\n\t\t\t}\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchange\n\t\t\t\t: contractConfig.exchange;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchangeV2\n\t\t\t\t: contractConfig.exchangeV2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\texchangeContract = contractConfig.exchangeV3;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`unsupported order version ${orderVersion}`);\n\t}\n\n\treturn buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,oBAAoB,OAChC,WACA,SACA,eACA,eACA,iBACA,SACA,YAC4C;CAC5C,MAAM,mBAAmB,MAAM,iBAAiB,UAAU;CAG1D,MAAM,QAAQ,kBAAkB,SAAY,mBAAmB;CAG/D,MAAM,iBAAiB,kBAAkB,gBAAgB,YAAY,QAAQ;CAC7E,MAAM,iBAAiB,kBAAkB,QAAQ;CACjD,MAAM,eAAe,oBAAoB,iBAAiB,QAAQ,CAAC,mBAAmB;CAEtF,MAAM,YAAY,MAAM,6BACvB,gBACA,OACA,eACA,iBACA,gBAAgB,QAAQ,WACxB,aACA;CAED,IAAIA;AACJ,SAAQ,cAAR;EACC,KAAK;AACJ,OAAI,kBAAkB,gBAAgB,UACrC,OAAM,IAAI,MAAM,0DAA0D;AAE3E,sBAAmB,QAAQ,UACxB,eAAe,kBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,QAAQ,UACxB,eAAe,oBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,eAAe;AAClC;EACD,QACC,OAAM,IAAI,MAAM,6BAA6B,eAAe;;AAG9D,QAAO,WAAW,WAAW,kBAAkB,SAAS,WAAW,aAAa"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_signer = require('../../signing/signer.cjs');
|
|
2
2
|
const require_config = require('../../config.cjs');
|
|
3
|
+
const require_orderAsset = require('./orderAsset.cjs');
|
|
3
4
|
const require_signatureTypeV2 = require('../../order-utils/model/signatureTypeV2.cjs');
|
|
4
5
|
const require_buildOrder = require('./buildOrder.cjs');
|
|
5
6
|
const require_buildOrderCreationArgs = require('./buildOrderCreationArgs.cjs');
|
|
@@ -11,9 +12,10 @@ const createOrder = async (eoaSigner, chainId, signatureType, funderAddress, use
|
|
|
11
12
|
const maker = funderAddress === void 0 ? eoaSignerAddress : funderAddress;
|
|
12
13
|
const signerForOrder = signatureType === require_signatureTypeV2.SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;
|
|
13
14
|
const contractConfig = require_config.getContractConfig(chainId);
|
|
14
|
-
const
|
|
15
|
+
const orderVersion = require_orderAsset.resolveOrderRouting(userOrder, version).exchangeVersion ?? version;
|
|
16
|
+
const orderData = await require_buildOrderCreationArgs.buildOrderCreationArgs(signerForOrder, maker, signatureType, userOrder, require_roundingConfig.ROUNDING_CONFIG[options.tickSize], orderVersion);
|
|
15
17
|
let exchangeContract;
|
|
16
|
-
switch (
|
|
18
|
+
switch (orderVersion) {
|
|
17
19
|
case 1:
|
|
18
20
|
if (signatureType === require_signatureTypeV2.SignatureTypeV2.POLY_1271) throw new Error(`signature type POLY_1271 is not supported for v1 orders`);
|
|
19
21
|
exchangeContract = options.negRisk ? contractConfig.negRiskExchange : contractConfig.exchange;
|
|
@@ -24,9 +26,9 @@ const createOrder = async (eoaSigner, chainId, signatureType, funderAddress, use
|
|
|
24
26
|
case 3:
|
|
25
27
|
exchangeContract = contractConfig.exchangeV3;
|
|
26
28
|
break;
|
|
27
|
-
default: throw new Error(`unsupported order version ${
|
|
29
|
+
default: throw new Error(`unsupported order version ${orderVersion}`);
|
|
28
30
|
}
|
|
29
|
-
return require_buildOrder.buildOrder(eoaSigner, exchangeContract, chainId, orderData,
|
|
31
|
+
return require_buildOrder.buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOrder.cjs","names":["getSignerAddress","SignatureTypeV2","getContractConfig","buildOrderCreationArgs","ROUNDING_CONFIG","exchangeContract: string","buildOrder"],"sources":["../../../src/order-builder/helpers/createOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type { Chain, CreateOrderOptions, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { buildOrderCreationArgs } from \"./buildOrderCreationArgs.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\n\tconst orderData = await buildOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\
|
|
1
|
+
{"version":3,"file":"createOrder.cjs","names":["getSignerAddress","SignatureTypeV2","getContractConfig","resolveOrderRouting","buildOrderCreationArgs","ROUNDING_CONFIG","exchangeContract: string","buildOrder"],"sources":["../../../src/order-builder/helpers/createOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type { Chain, CreateOrderOptions, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { buildOrderCreationArgs } from \"./buildOrderCreationArgs.js\";\nimport { resolveOrderRouting } from \"./orderAsset.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\tconst orderVersion = resolveOrderRouting(userOrder, version).exchangeVersion ?? version;\n\n\tconst orderData = await buildOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\torderVersion,\n\t);\n\tlet exchangeContract: string;\n\tswitch (orderVersion) {\n\t\tcase 1:\n\t\t\tif (signatureType === SignatureTypeV2.POLY_1271) {\n\t\t\t\tthrow new Error(`signature type POLY_1271 is not supported for v1 orders`);\n\t\t\t}\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchange\n\t\t\t\t: contractConfig.exchange;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchangeV2\n\t\t\t\t: contractConfig.exchangeV2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\texchangeContract = contractConfig.exchangeV3;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`unsupported order version ${orderVersion}`);\n\t}\n\treturn buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,cAAc,OAC1B,WACA,SACA,eACA,eACA,WACA,SACA,YAC4C;CAC5C,MAAM,mBAAmB,MAAMA,gCAAiB,UAAU;CAG1D,MAAM,QAAQ,kBAAkB,SAAY,mBAAmB;CAG/D,MAAM,iBAAiB,kBAAkBC,wCAAgB,YAAY,QAAQ;CAC7E,MAAM,iBAAiBC,iCAAkB,QAAQ;CACjD,MAAM,eAAeC,uCAAoB,WAAW,QAAQ,CAAC,mBAAmB;CAEhF,MAAM,YAAY,MAAMC,sDACvB,gBACA,OACA,eACA,WACAC,uCAAgB,QAAQ,WACxB,aACA;CACD,IAAIC;AACJ,SAAQ,cAAR;EACC,KAAK;AACJ,OAAI,kBAAkBL,wCAAgB,UACrC,OAAM,IAAI,MAAM,0DAA0D;AAE3E,sBAAmB,QAAQ,UACxB,eAAe,kBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,QAAQ,UACxB,eAAe,oBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,eAAe;AAClC;EACD,QACC,OAAM,IAAI,MAAM,6BAA6B,eAAe;;AAE9D,QAAOM,8BAAW,WAAW,kBAAkB,SAAS,WAAW,aAAa"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSignerAddress } from "../../signing/signer.js";
|
|
2
2
|
import { getContractConfig } from "../../config.js";
|
|
3
|
+
import { resolveOrderRouting } from "./orderAsset.js";
|
|
3
4
|
import { SignatureTypeV2 } from "../../order-utils/model/signatureTypeV2.js";
|
|
4
5
|
import { buildOrder } from "./buildOrder.js";
|
|
5
6
|
import { buildOrderCreationArgs } from "./buildOrderCreationArgs.js";
|
|
@@ -11,9 +12,10 @@ const createOrder = async (eoaSigner, chainId, signatureType, funderAddress, use
|
|
|
11
12
|
const maker = funderAddress === void 0 ? eoaSignerAddress : funderAddress;
|
|
12
13
|
const signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;
|
|
13
14
|
const contractConfig = getContractConfig(chainId);
|
|
14
|
-
const
|
|
15
|
+
const orderVersion = resolveOrderRouting(userOrder, version).exchangeVersion ?? version;
|
|
16
|
+
const orderData = await buildOrderCreationArgs(signerForOrder, maker, signatureType, userOrder, ROUNDING_CONFIG[options.tickSize], orderVersion);
|
|
15
17
|
let exchangeContract;
|
|
16
|
-
switch (
|
|
18
|
+
switch (orderVersion) {
|
|
17
19
|
case 1:
|
|
18
20
|
if (signatureType === SignatureTypeV2.POLY_1271) throw new Error(`signature type POLY_1271 is not supported for v1 orders`);
|
|
19
21
|
exchangeContract = options.negRisk ? contractConfig.negRiskExchange : contractConfig.exchange;
|
|
@@ -24,9 +26,9 @@ const createOrder = async (eoaSigner, chainId, signatureType, funderAddress, use
|
|
|
24
26
|
case 3:
|
|
25
27
|
exchangeContract = contractConfig.exchangeV3;
|
|
26
28
|
break;
|
|
27
|
-
default: throw new Error(`unsupported order version ${
|
|
29
|
+
default: throw new Error(`unsupported order version ${orderVersion}`);
|
|
28
30
|
}
|
|
29
|
-
return buildOrder(eoaSigner, exchangeContract, chainId, orderData,
|
|
31
|
+
return buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOrder.js","names":["exchangeContract: string"],"sources":["../../../src/order-builder/helpers/createOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type { Chain, CreateOrderOptions, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { buildOrderCreationArgs } from \"./buildOrderCreationArgs.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\n\tconst orderData = await buildOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\
|
|
1
|
+
{"version":3,"file":"createOrder.js","names":["exchangeContract: string"],"sources":["../../../src/order-builder/helpers/createOrder.ts"],"sourcesContent":["import { getContractConfig } from \"../../config.js\";\nimport type { SignedOrderV1, SignedOrderV2 } from \"../../order-utils/index.js\";\nimport { SignatureTypeV2 } from \"../../order-utils/index.js\";\nimport { type ClobSigner, getSignerAddress } from \"../../signing/signer.js\";\nimport type { Chain, CreateOrderOptions, UserOrderV1, UserOrderV2 } from \"../../types/index.js\";\nimport { buildOrder } from \"./buildOrder.js\";\nimport { buildOrderCreationArgs } from \"./buildOrderCreationArgs.js\";\nimport { resolveOrderRouting } from \"./orderAsset.js\";\nimport { ROUNDING_CONFIG } from \"./roundingConfig.js\";\n\nexport const createOrder = async (\n\teoaSigner: ClobSigner,\n\tchainId: Chain,\n\tsignatureType: SignatureTypeV2,\n\tfunderAddress: string | undefined,\n\tuserOrder: UserOrderV1 | UserOrderV2,\n\toptions: CreateOrderOptions,\n\tversion: number,\n): Promise<SignedOrderV1 | SignedOrderV2> => {\n\tconst eoaSignerAddress = await getSignerAddress(eoaSigner);\n\n\t// If funder address is not given, use the signer address\n\tconst maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;\n\n\t// For POLY_1271, both maker and signer in the order are the wallet address\n\tconst signerForOrder = signatureType === SignatureTypeV2.POLY_1271 ? maker : eoaSignerAddress;\n\tconst contractConfig = getContractConfig(chainId);\n\tconst orderVersion = resolveOrderRouting(userOrder, version).exchangeVersion ?? version;\n\n\tconst orderData = await buildOrderCreationArgs(\n\t\tsignerForOrder,\n\t\tmaker,\n\t\tsignatureType,\n\t\tuserOrder,\n\t\tROUNDING_CONFIG[options.tickSize],\n\t\torderVersion,\n\t);\n\tlet exchangeContract: string;\n\tswitch (orderVersion) {\n\t\tcase 1:\n\t\t\tif (signatureType === SignatureTypeV2.POLY_1271) {\n\t\t\t\tthrow new Error(`signature type POLY_1271 is not supported for v1 orders`);\n\t\t\t}\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchange\n\t\t\t\t: contractConfig.exchange;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\texchangeContract = options.negRisk\n\t\t\t\t? contractConfig.negRiskExchangeV2\n\t\t\t\t: contractConfig.exchangeV2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\texchangeContract = contractConfig.exchangeV3;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`unsupported order version ${orderVersion}`);\n\t}\n\treturn buildOrder(eoaSigner, exchangeContract, chainId, orderData, orderVersion);\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,cAAc,OAC1B,WACA,SACA,eACA,eACA,WACA,SACA,YAC4C;CAC5C,MAAM,mBAAmB,MAAM,iBAAiB,UAAU;CAG1D,MAAM,QAAQ,kBAAkB,SAAY,mBAAmB;CAG/D,MAAM,iBAAiB,kBAAkB,gBAAgB,YAAY,QAAQ;CAC7E,MAAM,iBAAiB,kBAAkB,QAAQ;CACjD,MAAM,eAAe,oBAAoB,WAAW,QAAQ,CAAC,mBAAmB;CAEhF,MAAM,YAAY,MAAM,uBACvB,gBACA,OACA,eACA,WACA,gBAAgB,QAAQ,WACxB,aACA;CACD,IAAIA;AACJ,SAAQ,cAAR;EACC,KAAK;AACJ,OAAI,kBAAkB,gBAAgB,UACrC,OAAM,IAAI,MAAM,0DAA0D;AAE3E,sBAAmB,QAAQ,UACxB,eAAe,kBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,QAAQ,UACxB,eAAe,oBACf,eAAe;AAClB;EACD,KAAK;AACJ,sBAAmB,eAAe;AAClC;EACD,QACC,OAAM,IAAI,MAAM,6BAA6B,eAAe;;AAE9D,QAAO,WAAW,WAAW,kBAAkB,SAAS,WAAW,aAAa"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/order-builder/helpers/orderAsset.ts
|
|
3
|
+
function resolveOrderAssetID(asset) {
|
|
4
|
+
return asset.positionID ?? asset.tokenID;
|
|
5
|
+
}
|
|
6
|
+
function resolveOrderRouting(asset, requestedVersion) {
|
|
7
|
+
return {
|
|
8
|
+
assetID: resolveOrderAssetID(asset),
|
|
9
|
+
exchangeVersion: asset.positionID === void 0 ? requestedVersion : 3
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.resolveOrderAssetID = resolveOrderAssetID;
|
|
15
|
+
exports.resolveOrderRouting = resolveOrderRouting;
|
|
16
|
+
//# sourceMappingURL=orderAsset.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderAsset.cjs","names":[],"sources":["../../../src/order-builder/helpers/orderAsset.ts"],"sourcesContent":["import type { OrderAsset } from \"../../types/index.js\";\n\nexport type OrderRouting = {\n\tassetID: string;\n\texchangeVersion: number | undefined;\n};\n\nexport function resolveOrderAssetID(asset: OrderAsset): string {\n\treturn asset.positionID ?? asset.tokenID;\n}\n\nexport function resolveOrderRouting(asset: OrderAsset, requestedVersion?: number): OrderRouting {\n\treturn {\n\t\tassetID: resolveOrderAssetID(asset),\n\t\texchangeVersion: asset.positionID === undefined ? requestedVersion : 3,\n\t};\n}\n"],"mappings":";;AAOA,SAAgB,oBAAoB,OAA2B;AAC9D,QAAO,MAAM,cAAc,MAAM;;AAGlC,SAAgB,oBAAoB,OAAmB,kBAAyC;AAC/F,QAAO;EACN,SAAS,oBAAoB,MAAM;EACnC,iBAAiB,MAAM,eAAe,SAAY,mBAAmB;EACrE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/order-builder/helpers/orderAsset.ts
|
|
2
|
+
function resolveOrderAssetID(asset) {
|
|
3
|
+
return asset.positionID ?? asset.tokenID;
|
|
4
|
+
}
|
|
5
|
+
function resolveOrderRouting(asset, requestedVersion) {
|
|
6
|
+
return {
|
|
7
|
+
assetID: resolveOrderAssetID(asset),
|
|
8
|
+
exchangeVersion: asset.positionID === void 0 ? requestedVersion : 3
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { resolveOrderAssetID, resolveOrderRouting };
|
|
14
|
+
//# sourceMappingURL=orderAsset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderAsset.js","names":[],"sources":["../../../src/order-builder/helpers/orderAsset.ts"],"sourcesContent":["import type { OrderAsset } from \"../../types/index.js\";\n\nexport type OrderRouting = {\n\tassetID: string;\n\texchangeVersion: number | undefined;\n};\n\nexport function resolveOrderAssetID(asset: OrderAsset): string {\n\treturn asset.positionID ?? asset.tokenID;\n}\n\nexport function resolveOrderRouting(asset: OrderAsset, requestedVersion?: number): OrderRouting {\n\treturn {\n\t\tassetID: resolveOrderAssetID(asset),\n\t\texchangeVersion: asset.positionID === undefined ? requestedVersion : 3,\n\t};\n}\n"],"mappings":";AAOA,SAAgB,oBAAoB,OAA2B;AAC9D,QAAO,MAAM,cAAc,MAAM;;AAGlC,SAAgB,oBAAoB,OAAmB,kBAAyC;AAC/F,QAAO;EACN,SAAS,oBAAoB,MAAM;EACnC,iBAAiB,MAAM,eAAe,SAAY,mBAAmB;EACrE"}
|
|
@@ -27,13 +27,13 @@ var OrderBuilder = class {
|
|
|
27
27
|
/**
|
|
28
28
|
* Generate and sign a order
|
|
29
29
|
*/
|
|
30
|
-
async buildOrder(userOrder, options, version) {
|
|
30
|
+
async buildOrder(userOrder, options, version = 2) {
|
|
31
31
|
return require_createOrder.createOrder(await this.resolveSigner(), this.chainId, this.signatureType, this.funderAddress, userOrder, options, version);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Generate and sign a market order
|
|
35
35
|
*/
|
|
36
|
-
async buildMarketOrder(userMarketOrder, options, version) {
|
|
36
|
+
async buildMarketOrder(userMarketOrder, options, version = 2) {
|
|
37
37
|
return require_createMarketOrder.createMarketOrder(await this.resolveSigner(), this.chainId, this.signatureType, this.funderAddress, userMarketOrder, options, version);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderBuilder.cjs","names":["SignatureTypeV2","createOrder","createMarketOrder","createExchangeV3OrderFromAmounts"],"sources":["../../src/order-builder/orderBuilder.ts"],"sourcesContent":["import { SignatureTypeV2, type SignedOrderV1, type SignedOrderV2 } from \"../order-utils/index.js\";\nimport type { ClobSigner } from \"../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tExchangeV3OrderAmounts,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n\tUserOrderV1,\n\tUserOrderV2,\n} from \"../types/index.js\";\n\nimport { createExchangeV3OrderFromAmounts } from \"./helpers/createExchangeV3OrderFromAmounts.js\";\nimport { createMarketOrder, createOrder } from \"./helpers/index.js\";\n\nexport class OrderBuilder {\n\treadonly signer: ClobSigner;\n\n\treadonly chainId: Chain;\n\n\t// Signature type used sign orders, defaults to EOA type\n\treadonly signatureType: SignatureTypeV2;\n\n\t// Address which holds funds to be used.\n\t// Used for Polymarket proxy wallets and other smart contract wallets\n\t// If not provided, funderAddress is the signer address\n\treadonly funderAddress?: string;\n\n\t/**\n\t * Optional function to dynamically resolve the signer.\n\t * If provided, this function will be called to obtain a fresh signer instance\n\t * (e.g., for smart contract wallets or when the signer may change).\n\t * Should return a Wallet or JsonRpcSigner, or a Promise resolving to one.\n\t * If not provided, the static `signer` property is used.\n\t */\n\tprivate getSigner?: () => Promise<ClobSigner> | ClobSigner;\n\n\tconstructor(\n\t\tsigner: ClobSigner,\n\t\tchainId: Chain,\n\t\tsignatureType?: SignatureTypeV2,\n\t\tfunderAddress?: string,\n\t\tgetSigner?: () => Promise<ClobSigner> | ClobSigner,\n\t) {\n\t\tthis.signer = signer;\n\t\tthis.chainId = chainId;\n\t\tthis.signatureType = signatureType === undefined ? SignatureTypeV2.EOA : signatureType;\n\t\tthis.funderAddress = funderAddress;\n\t\tthis.getSigner = getSigner;\n\t}\n\n\t/**\n\t * Generate and sign a order\n\t */\n\tpublic async buildOrder(\n\t\tuserOrder: UserOrderV1 | UserOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign a market order\n\t */\n\tpublic async buildMarketOrder(\n\t\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createMarketOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserMarketOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign an ExchangeV3 order using exact base-unit amounts.\n\t */\n\tpublic async buildExchangeV3OrderFromAmounts(\n\t\tuserOrder: ExchangeV3OrderAmounts,\n\t): Promise<SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createExchangeV3OrderFromAmounts(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t);\n\t}\n\n\t/** Unified getter: use fresh signer if available */\n\tprivate async resolveSigner(): Promise<ClobSigner> {\n\t\tif (this.getSigner) {\n\t\t\tconst s = await this.getSigner();\n\t\t\tif (!s) throw new Error(\"getSigner() function returned undefined or null\");\n\t\t\treturn s;\n\t\t}\n\t\treturn this.signer;\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,eAAb,MAA0B;CACzB,AAAS;CAET,AAAS;CAGT,AAAS;CAKT,AAAS;;;;;;;;CAST,AAAQ;CAER,YACC,QACA,SACA,eACA,eACA,WACC;AACD,OAAK,SAAS;AACd,OAAK,UAAU;AACf,OAAK,gBAAgB,kBAAkB,SAAYA,wCAAgB,MAAM;AACzE,OAAK,gBAAgB;AACrB,OAAK,YAAY;;;;;CAMlB,MAAa,WACZ,WACA,SACA,
|
|
1
|
+
{"version":3,"file":"orderBuilder.cjs","names":["SignatureTypeV2","createOrder","createMarketOrder","createExchangeV3OrderFromAmounts"],"sources":["../../src/order-builder/orderBuilder.ts"],"sourcesContent":["import { SignatureTypeV2, type SignedOrderV1, type SignedOrderV2 } from \"../order-utils/index.js\";\nimport type { ClobSigner } from \"../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tExchangeV3OrderAmounts,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n\tUserOrderV1,\n\tUserOrderV2,\n} from \"../types/index.js\";\n\nimport { createExchangeV3OrderFromAmounts } from \"./helpers/createExchangeV3OrderFromAmounts.js\";\nimport { createMarketOrder, createOrder } from \"./helpers/index.js\";\n\nexport class OrderBuilder {\n\treadonly signer: ClobSigner;\n\n\treadonly chainId: Chain;\n\n\t// Signature type used sign orders, defaults to EOA type\n\treadonly signatureType: SignatureTypeV2;\n\n\t// Address which holds funds to be used.\n\t// Used for Polymarket proxy wallets and other smart contract wallets\n\t// If not provided, funderAddress is the signer address\n\treadonly funderAddress?: string;\n\n\t/**\n\t * Optional function to dynamically resolve the signer.\n\t * If provided, this function will be called to obtain a fresh signer instance\n\t * (e.g., for smart contract wallets or when the signer may change).\n\t * Should return a Wallet or JsonRpcSigner, or a Promise resolving to one.\n\t * If not provided, the static `signer` property is used.\n\t */\n\tprivate getSigner?: () => Promise<ClobSigner> | ClobSigner;\n\n\tconstructor(\n\t\tsigner: ClobSigner,\n\t\tchainId: Chain,\n\t\tsignatureType?: SignatureTypeV2,\n\t\tfunderAddress?: string,\n\t\tgetSigner?: () => Promise<ClobSigner> | ClobSigner,\n\t) {\n\t\tthis.signer = signer;\n\t\tthis.chainId = chainId;\n\t\tthis.signatureType = signatureType === undefined ? SignatureTypeV2.EOA : signatureType;\n\t\tthis.funderAddress = funderAddress;\n\t\tthis.getSigner = getSigner;\n\t}\n\n\t/**\n\t * Generate and sign a order\n\t */\n\tpublic async buildOrder(\n\t\tuserOrder: UserOrderV1 | UserOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number = 2,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign a market order\n\t */\n\tpublic async buildMarketOrder(\n\t\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number = 2,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createMarketOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserMarketOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign an ExchangeV3 order using exact base-unit amounts.\n\t */\n\tpublic async buildExchangeV3OrderFromAmounts(\n\t\tuserOrder: ExchangeV3OrderAmounts,\n\t): Promise<SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createExchangeV3OrderFromAmounts(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t);\n\t}\n\n\t/** Unified getter: use fresh signer if available */\n\tprivate async resolveSigner(): Promise<ClobSigner> {\n\t\tif (this.getSigner) {\n\t\t\tconst s = await this.getSigner();\n\t\t\tif (!s) throw new Error(\"getSigner() function returned undefined or null\");\n\t\t\treturn s;\n\t\t}\n\t\treturn this.signer;\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,eAAb,MAA0B;CACzB,AAAS;CAET,AAAS;CAGT,AAAS;CAKT,AAAS;;;;;;;;CAST,AAAQ;CAER,YACC,QACA,SACA,eACA,eACA,WACC;AACD,OAAK,SAAS;AACd,OAAK,UAAU;AACf,OAAK,gBAAgB,kBAAkB,SAAYA,wCAAgB,MAAM;AACzE,OAAK,gBAAgB;AACrB,OAAK,YAAY;;;;;CAMlB,MAAa,WACZ,WACA,SACA,UAAkB,GACuB;AAEzC,SAAOC,gCADQ,MAAM,KAAK,eAAe,EAGxC,KAAK,SACL,KAAK,eACL,KAAK,eACL,WACA,SACA,QACA;;;;;CAMF,MAAa,iBACZ,iBACA,SACA,UAAkB,GACuB;AAEzC,SAAOC,4CADQ,MAAM,KAAK,eAAe,EAGxC,KAAK,SACL,KAAK,eACL,KAAK,eACL,iBACA,SACA,QACA;;;;;CAMF,MAAa,gCACZ,WACyB;AAEzB,SAAOC,0EADQ,MAAM,KAAK,eAAe,EAGxC,KAAK,SACL,KAAK,eACL,KAAK,eACL,UACA;;;CAIF,MAAc,gBAAqC;AAClD,MAAI,KAAK,WAAW;GACnB,MAAM,IAAI,MAAM,KAAK,WAAW;AAChC,OAAI,CAAC,EAAG,OAAM,IAAI,MAAM,kDAAkD;AAC1E,UAAO;;AAER,SAAO,KAAK"}
|
|
@@ -25,11 +25,11 @@ declare class OrderBuilder {
|
|
|
25
25
|
/**
|
|
26
26
|
* Generate and sign a order
|
|
27
27
|
*/
|
|
28
|
-
buildOrder(userOrder: UserOrderV1 | UserOrderV2, options: CreateOrderOptions, version
|
|
28
|
+
buildOrder(userOrder: UserOrderV1 | UserOrderV2, options: CreateOrderOptions, version?: number): Promise<SignedOrderV1 | SignedOrderV2>;
|
|
29
29
|
/**
|
|
30
30
|
* Generate and sign a market order
|
|
31
31
|
*/
|
|
32
|
-
buildMarketOrder(userMarketOrder: UserMarketOrderV1 | UserMarketOrderV2, options: CreateOrderOptions, version
|
|
32
|
+
buildMarketOrder(userMarketOrder: UserMarketOrderV1 | UserMarketOrderV2, options: CreateOrderOptions, version?: number): Promise<SignedOrderV1 | SignedOrderV2>;
|
|
33
33
|
/**
|
|
34
34
|
* Generate and sign an ExchangeV3 order using exact base-unit amounts.
|
|
35
35
|
*/
|
|
@@ -27,11 +27,11 @@ declare class OrderBuilder {
|
|
|
27
27
|
/**
|
|
28
28
|
* Generate and sign a order
|
|
29
29
|
*/
|
|
30
|
-
buildOrder(userOrder: UserOrderV1 | UserOrderV2, options: CreateOrderOptions, version
|
|
30
|
+
buildOrder(userOrder: UserOrderV1 | UserOrderV2, options: CreateOrderOptions, version?: number): Promise<SignedOrderV1 | SignedOrderV2>;
|
|
31
31
|
/**
|
|
32
32
|
* Generate and sign a market order
|
|
33
33
|
*/
|
|
34
|
-
buildMarketOrder(userMarketOrder: UserMarketOrderV1 | UserMarketOrderV2, options: CreateOrderOptions, version
|
|
34
|
+
buildMarketOrder(userMarketOrder: UserMarketOrderV1 | UserMarketOrderV2, options: CreateOrderOptions, version?: number): Promise<SignedOrderV1 | SignedOrderV2>;
|
|
35
35
|
/**
|
|
36
36
|
* Generate and sign an ExchangeV3 order using exact base-unit amounts.
|
|
37
37
|
*/
|
|
@@ -27,13 +27,13 @@ var OrderBuilder = class {
|
|
|
27
27
|
/**
|
|
28
28
|
* Generate and sign a order
|
|
29
29
|
*/
|
|
30
|
-
async buildOrder(userOrder, options, version) {
|
|
30
|
+
async buildOrder(userOrder, options, version = 2) {
|
|
31
31
|
return createOrder(await this.resolveSigner(), this.chainId, this.signatureType, this.funderAddress, userOrder, options, version);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Generate and sign a market order
|
|
35
35
|
*/
|
|
36
|
-
async buildMarketOrder(userMarketOrder, options, version) {
|
|
36
|
+
async buildMarketOrder(userMarketOrder, options, version = 2) {
|
|
37
37
|
return createMarketOrder(await this.resolveSigner(), this.chainId, this.signatureType, this.funderAddress, userMarketOrder, options, version);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderBuilder.js","names":[],"sources":["../../src/order-builder/orderBuilder.ts"],"sourcesContent":["import { SignatureTypeV2, type SignedOrderV1, type SignedOrderV2 } from \"../order-utils/index.js\";\nimport type { ClobSigner } from \"../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tExchangeV3OrderAmounts,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n\tUserOrderV1,\n\tUserOrderV2,\n} from \"../types/index.js\";\n\nimport { createExchangeV3OrderFromAmounts } from \"./helpers/createExchangeV3OrderFromAmounts.js\";\nimport { createMarketOrder, createOrder } from \"./helpers/index.js\";\n\nexport class OrderBuilder {\n\treadonly signer: ClobSigner;\n\n\treadonly chainId: Chain;\n\n\t// Signature type used sign orders, defaults to EOA type\n\treadonly signatureType: SignatureTypeV2;\n\n\t// Address which holds funds to be used.\n\t// Used for Polymarket proxy wallets and other smart contract wallets\n\t// If not provided, funderAddress is the signer address\n\treadonly funderAddress?: string;\n\n\t/**\n\t * Optional function to dynamically resolve the signer.\n\t * If provided, this function will be called to obtain a fresh signer instance\n\t * (e.g., for smart contract wallets or when the signer may change).\n\t * Should return a Wallet or JsonRpcSigner, or a Promise resolving to one.\n\t * If not provided, the static `signer` property is used.\n\t */\n\tprivate getSigner?: () => Promise<ClobSigner> | ClobSigner;\n\n\tconstructor(\n\t\tsigner: ClobSigner,\n\t\tchainId: Chain,\n\t\tsignatureType?: SignatureTypeV2,\n\t\tfunderAddress?: string,\n\t\tgetSigner?: () => Promise<ClobSigner> | ClobSigner,\n\t) {\n\t\tthis.signer = signer;\n\t\tthis.chainId = chainId;\n\t\tthis.signatureType = signatureType === undefined ? SignatureTypeV2.EOA : signatureType;\n\t\tthis.funderAddress = funderAddress;\n\t\tthis.getSigner = getSigner;\n\t}\n\n\t/**\n\t * Generate and sign a order\n\t */\n\tpublic async buildOrder(\n\t\tuserOrder: UserOrderV1 | UserOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign a market order\n\t */\n\tpublic async buildMarketOrder(\n\t\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createMarketOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserMarketOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign an ExchangeV3 order using exact base-unit amounts.\n\t */\n\tpublic async buildExchangeV3OrderFromAmounts(\n\t\tuserOrder: ExchangeV3OrderAmounts,\n\t): Promise<SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createExchangeV3OrderFromAmounts(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t);\n\t}\n\n\t/** Unified getter: use fresh signer if available */\n\tprivate async resolveSigner(): Promise<ClobSigner> {\n\t\tif (this.getSigner) {\n\t\t\tconst s = await this.getSigner();\n\t\t\tif (!s) throw new Error(\"getSigner() function returned undefined or null\");\n\t\t\treturn s;\n\t\t}\n\t\treturn this.signer;\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,eAAb,MAA0B;CACzB,AAAS;CAET,AAAS;CAGT,AAAS;CAKT,AAAS;;;;;;;;CAST,AAAQ;CAER,YACC,QACA,SACA,eACA,eACA,WACC;AACD,OAAK,SAAS;AACd,OAAK,UAAU;AACf,OAAK,gBAAgB,kBAAkB,SAAY,gBAAgB,MAAM;AACzE,OAAK,gBAAgB;AACrB,OAAK,YAAY;;;;;CAMlB,MAAa,WACZ,WACA,SACA,
|
|
1
|
+
{"version":3,"file":"orderBuilder.js","names":[],"sources":["../../src/order-builder/orderBuilder.ts"],"sourcesContent":["import { SignatureTypeV2, type SignedOrderV1, type SignedOrderV2 } from \"../order-utils/index.js\";\nimport type { ClobSigner } from \"../signing/signer.js\";\nimport type {\n\tChain,\n\tCreateOrderOptions,\n\tExchangeV3OrderAmounts,\n\tUserMarketOrderV1,\n\tUserMarketOrderV2,\n\tUserOrderV1,\n\tUserOrderV2,\n} from \"../types/index.js\";\n\nimport { createExchangeV3OrderFromAmounts } from \"./helpers/createExchangeV3OrderFromAmounts.js\";\nimport { createMarketOrder, createOrder } from \"./helpers/index.js\";\n\nexport class OrderBuilder {\n\treadonly signer: ClobSigner;\n\n\treadonly chainId: Chain;\n\n\t// Signature type used sign orders, defaults to EOA type\n\treadonly signatureType: SignatureTypeV2;\n\n\t// Address which holds funds to be used.\n\t// Used for Polymarket proxy wallets and other smart contract wallets\n\t// If not provided, funderAddress is the signer address\n\treadonly funderAddress?: string;\n\n\t/**\n\t * Optional function to dynamically resolve the signer.\n\t * If provided, this function will be called to obtain a fresh signer instance\n\t * (e.g., for smart contract wallets or when the signer may change).\n\t * Should return a Wallet or JsonRpcSigner, or a Promise resolving to one.\n\t * If not provided, the static `signer` property is used.\n\t */\n\tprivate getSigner?: () => Promise<ClobSigner> | ClobSigner;\n\n\tconstructor(\n\t\tsigner: ClobSigner,\n\t\tchainId: Chain,\n\t\tsignatureType?: SignatureTypeV2,\n\t\tfunderAddress?: string,\n\t\tgetSigner?: () => Promise<ClobSigner> | ClobSigner,\n\t) {\n\t\tthis.signer = signer;\n\t\tthis.chainId = chainId;\n\t\tthis.signatureType = signatureType === undefined ? SignatureTypeV2.EOA : signatureType;\n\t\tthis.funderAddress = funderAddress;\n\t\tthis.getSigner = getSigner;\n\t}\n\n\t/**\n\t * Generate and sign a order\n\t */\n\tpublic async buildOrder(\n\t\tuserOrder: UserOrderV1 | UserOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number = 2,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign a market order\n\t */\n\tpublic async buildMarketOrder(\n\t\tuserMarketOrder: UserMarketOrderV1 | UserMarketOrderV2,\n\t\toptions: CreateOrderOptions,\n\t\tversion: number = 2,\n\t): Promise<SignedOrderV1 | SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createMarketOrder(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserMarketOrder,\n\t\t\toptions,\n\t\t\tversion,\n\t\t);\n\t}\n\n\t/**\n\t * Generate and sign an ExchangeV3 order using exact base-unit amounts.\n\t */\n\tpublic async buildExchangeV3OrderFromAmounts(\n\t\tuserOrder: ExchangeV3OrderAmounts,\n\t): Promise<SignedOrderV2> {\n\t\tconst signer = await this.resolveSigner();\n\t\treturn createExchangeV3OrderFromAmounts(\n\t\t\tsigner,\n\t\t\tthis.chainId,\n\t\t\tthis.signatureType,\n\t\t\tthis.funderAddress,\n\t\t\tuserOrder,\n\t\t);\n\t}\n\n\t/** Unified getter: use fresh signer if available */\n\tprivate async resolveSigner(): Promise<ClobSigner> {\n\t\tif (this.getSigner) {\n\t\t\tconst s = await this.getSigner();\n\t\t\tif (!s) throw new Error(\"getSigner() function returned undefined or null\");\n\t\t\treturn s;\n\t\t}\n\t\treturn this.signer;\n\t}\n}\n"],"mappings":";;;;;;AAeA,IAAa,eAAb,MAA0B;CACzB,AAAS;CAET,AAAS;CAGT,AAAS;CAKT,AAAS;;;;;;;;CAST,AAAQ;CAER,YACC,QACA,SACA,eACA,eACA,WACC;AACD,OAAK,SAAS;AACd,OAAK,UAAU;AACf,OAAK,gBAAgB,kBAAkB,SAAY,gBAAgB,MAAM;AACzE,OAAK,gBAAgB;AACrB,OAAK,YAAY;;;;;CAMlB,MAAa,WACZ,WACA,SACA,UAAkB,GACuB;AAEzC,SAAO,YADQ,MAAM,KAAK,eAAe,EAGxC,KAAK,SACL,KAAK,eACL,KAAK,eACL,WACA,SACA,QACA;;;;;CAMF,MAAa,iBACZ,iBACA,SACA,UAAkB,GACuB;AAEzC,SAAO,kBADQ,MAAM,KAAK,eAAe,EAGxC,KAAK,SACL,KAAK,eACL,KAAK,eACL,iBACA,SACA,QACA;;;;;CAMF,MAAa,gCACZ,WACyB;AAEzB,SAAO,iCADQ,MAAM,KAAK,eAAe,EAGxC,KAAK,SACL,KAAK,eACL,KAAK,eACL,UACA;;;CAIF,MAAc,gBAAqC;AAClD,MAAI,KAAK,WAAW;GACnB,MAAM,IAAI,MAAM,KAAK,WAAW;AAChC,OAAI,CAAC,EAAG,OAAM,IAAI,MAAM,kDAAkD;AAC1E,UAAO;;AAER,SAAO,KAAK"}
|
package/dist/types/clob.cjs.map
CHANGED
|
@@ -1 +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.005\" | \"0.0025\" | \"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"}
|
|
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\t/**\n\t * Settlement transaction hashes for the order's trades, returned on a\n\t * best-effort basis when the order matched.\n\t */\n\ttransactionsHashes?: string[];\n\t/** IDs of the trades created when the order matched. */\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.005\" | \"0.0025\" | \"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;;;AA+GD,IAAY,0CAAL;AACN;AACA;;;AAgBD,IAAY,wEAAL;AACN;AACA;AACA;AACA;AACA;;;AAqCD,IAAY,kDAAL;AACN;AACA"}
|
package/dist/types/clob.d.cts
CHANGED
|
@@ -46,7 +46,12 @@ interface OrderResponse {
|
|
|
46
46
|
success: boolean;
|
|
47
47
|
errorMsg: string;
|
|
48
48
|
orderID: string;
|
|
49
|
+
/**
|
|
50
|
+
* Settlement transaction hashes for the order's trades, returned on a
|
|
51
|
+
* best-effort basis when the order matched.
|
|
52
|
+
*/
|
|
49
53
|
transactionsHashes?: string[];
|
|
54
|
+
/** IDs of the trades created when the order matched. */
|
|
50
55
|
tradeIDs?: string[];
|
|
51
56
|
status: string;
|
|
52
57
|
takingAmount: string;
|
package/dist/types/clob.d.ts
CHANGED
|
@@ -46,7 +46,12 @@ interface OrderResponse {
|
|
|
46
46
|
success: boolean;
|
|
47
47
|
errorMsg: string;
|
|
48
48
|
orderID: string;
|
|
49
|
+
/**
|
|
50
|
+
* Settlement transaction hashes for the order's trades, returned on a
|
|
51
|
+
* best-effort basis when the order matched.
|
|
52
|
+
*/
|
|
49
53
|
transactionsHashes?: string[];
|
|
54
|
+
/** IDs of the trades created when the order matched. */
|
|
50
55
|
tradeIDs?: string[];
|
|
51
56
|
status: string;
|
|
52
57
|
takingAmount: string;
|