{"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: 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.tokenID,\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: userOrder.tokenID,\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":";;;;;;;AAsCA,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,SAAS,UAAU;GACnB;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,UAAU;EACnB;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"}