{"version":3,"file":"getMarketOrderRawAmounts.cjs","names":["roundDown","Side","decimalPlaces","roundUp"],"sources":["../../../src/order-builder/helpers/getMarketOrderRawAmounts.ts"],"sourcesContent":["import { type RoundConfig, Side } from \"../../types/index.js\";\nimport { decimalPlaces, roundDown, roundUp } from \"../../utilities.js\";\n\nexport const getMarketOrderRawAmounts = (\n\tside: Side,\n\tamount: number,\n\tprice: number,\n\troundConfig: RoundConfig,\n): { side: Side; rawMakerAmt: number; rawTakerAmt: number } => {\n\t// force 2 decimals places\n\tconst rawPrice = roundDown(price, roundConfig.price);\n\n\tif (side === Side.BUY) {\n\t\tconst rawMakerAmt = roundDown(amount, roundConfig.size);\n\t\tlet rawTakerAmt = rawMakerAmt / rawPrice;\n\t\tif (decimalPlaces(rawTakerAmt) > roundConfig.amount) {\n\t\t\trawTakerAmt = roundUp(rawTakerAmt, roundConfig.amount + 4);\n\t\t\tif (decimalPlaces(rawTakerAmt) > roundConfig.amount) {\n\t\t\t\trawTakerAmt = roundDown(rawTakerAmt, roundConfig.amount);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tside: Side.BUY,\n\t\t\trawMakerAmt,\n\t\t\trawTakerAmt,\n\t\t};\n\t} else {\n\t\tconst rawMakerAmt = roundDown(amount, roundConfig.size);\n\t\tlet rawTakerAmt = rawMakerAmt * rawPrice;\n\t\tif (decimalPlaces(rawTakerAmt) > roundConfig.amount) {\n\t\t\trawTakerAmt = roundUp(rawTakerAmt, roundConfig.amount + 4);\n\t\t\tif (decimalPlaces(rawTakerAmt) > roundConfig.amount) {\n\t\t\t\trawTakerAmt = roundDown(rawTakerAmt, roundConfig.amount);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tside: Side.SELL,\n\t\t\trawMakerAmt,\n\t\t\trawTakerAmt,\n\t\t};\n\t}\n};\n"],"mappings":";;;;AAGA,MAAa,4BACZ,MACA,QACA,OACA,gBAC8D;CAE9D,MAAM,WAAWA,4BAAU,OAAO,YAAY,MAAM;AAEpD,KAAI,SAASC,kBAAK,KAAK;EACtB,MAAM,cAAcD,4BAAU,QAAQ,YAAY,KAAK;EACvD,IAAI,cAAc,cAAc;AAChC,MAAIE,gCAAc,YAAY,GAAG,YAAY,QAAQ;AACpD,iBAAcC,0BAAQ,aAAa,YAAY,SAAS,EAAE;AAC1D,OAAID,gCAAc,YAAY,GAAG,YAAY,OAC5C,eAAcF,4BAAU,aAAa,YAAY,OAAO;;AAG1D,SAAO;GACN,MAAMC,kBAAK;GACX;GACA;GACA;QACK;EACN,MAAM,cAAcD,4BAAU,QAAQ,YAAY,KAAK;EACvD,IAAI,cAAc,cAAc;AAChC,MAAIE,gCAAc,YAAY,GAAG,YAAY,QAAQ;AACpD,iBAAcC,0BAAQ,aAAa,YAAY,SAAS,EAAE;AAC1D,OAAID,gCAAc,YAAY,GAAG,YAAY,OAC5C,eAAcF,4BAAU,aAAa,YAAY,OAAO;;AAI1D,SAAO;GACN,MAAMC,kBAAK;GACX;GACA;GACA"}