{"version":3,"file":"getOrderRawAmounts.cjs","names":["roundNormal","Side","roundDown","decimalPlaces","roundUp"],"sources":["../../../src/order-builder/helpers/getOrderRawAmounts.ts"],"sourcesContent":["import { type RoundConfig, Side } from \"../../types/index.js\";\nimport { decimalPlaces, roundDown, roundNormal, roundUp } from \"../../utilities.js\";\n\nexport const getOrderRawAmounts = (\n\tside: Side,\n\tsize: number,\n\tprice: number,\n\troundConfig: RoundConfig,\n): { side: Side; rawMakerAmt: number; rawTakerAmt: number } => {\n\tconst rawPrice = roundNormal(price, roundConfig.price);\n\n\tif (side === Side.BUY) {\n\t\t// force 2 decimals places\n\t\tconst rawTakerAmt = roundDown(size, roundConfig.size);\n\n\t\tlet rawMakerAmt = rawTakerAmt * rawPrice;\n\t\tif (decimalPlaces(rawMakerAmt) > roundConfig.amount) {\n\t\t\trawMakerAmt = roundUp(rawMakerAmt, roundConfig.amount + 4);\n\t\t\tif (decimalPlaces(rawMakerAmt) > roundConfig.amount) {\n\t\t\t\trawMakerAmt = roundDown(rawMakerAmt, roundConfig.amount);\n\t\t\t}\n\t\t}\n\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(size, roundConfig.size);\n\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,sBACZ,MACA,MACA,OACA,gBAC8D;CAC9D,MAAM,WAAWA,8BAAY,OAAO,YAAY,MAAM;AAEtD,KAAI,SAASC,kBAAK,KAAK;EAEtB,MAAM,cAAcC,4BAAU,MAAM,YAAY,KAAK;EAErD,IAAI,cAAc,cAAc;AAChC,MAAIC,gCAAc,YAAY,GAAG,YAAY,QAAQ;AACpD,iBAAcC,0BAAQ,aAAa,YAAY,SAAS,EAAE;AAC1D,OAAID,gCAAc,YAAY,GAAG,YAAY,OAC5C,eAAcD,4BAAU,aAAa,YAAY,OAAO;;AAI1D,SAAO;GACN,MAAMD,kBAAK;GACX;GACA;GACA;QACK;EACN,MAAM,cAAcC,4BAAU,MAAM,YAAY,KAAK;EAErD,IAAI,cAAc,cAAc;AAChC,MAAIC,gCAAc,YAAY,GAAG,YAAY,QAAQ;AACpD,iBAAcC,0BAAQ,aAAa,YAAY,SAAS,EAAE;AAC1D,OAAID,gCAAc,YAAY,GAAG,YAAY,OAC5C,eAAcD,4BAAU,aAAa,YAAY,OAAO;;AAI1D,SAAO;GACN,MAAMD,kBAAK;GACX;GACA;GACA"}