From 4c113496b7629d5139ff816e6b0af04d0f334cc1 Mon Sep 17 00:00:00 2001 From: GDdark Date: Sun, 18 Jan 2026 16:01:20 +0800 Subject: [PATCH 1/2] fix: use roundConfig.size for rawTakerAmt decimal places in BUY orders Fix incorrect rounding config in getMarketOrderRawAmounts function. rawTakerAmt represents token size, not price amount, so it should use roundConfig.size instead of roundConfig.amount for decimal precision. --- src/order-builder/helpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/order-builder/helpers.ts b/src/order-builder/helpers.ts index a823852a..e8424868 100644 --- a/src/order-builder/helpers.ts +++ b/src/order-builder/helpers.ts @@ -203,10 +203,10 @@ export const getMarketOrderRawAmounts = ( if (side === Side.BUY) { const rawMakerAmt = roundDown(amount, roundConfig.size); let rawTakerAmt = rawMakerAmt / rawPrice; - if (decimalPlaces(rawTakerAmt) > roundConfig.amount) { - rawTakerAmt = roundUp(rawTakerAmt, roundConfig.amount + 4); - if (decimalPlaces(rawTakerAmt) > roundConfig.amount) { - rawTakerAmt = roundDown(rawTakerAmt, roundConfig.amount); + if (decimalPlaces(rawTakerAmt) > roundConfig.size) { + rawTakerAmt = roundUp(rawTakerAmt, roundConfig.size + 4); + if (decimalPlaces(rawTakerAmt) > roundConfig.size) { + rawTakerAmt = roundDown(rawTakerAmt, roundConfig.size); } } return { From 1343aa940716645a8e4f020ff8bcaab379bb682a Mon Sep 17 00:00:00 2001 From: GDdark Date: Sun, 18 Jan 2026 16:02:31 +0800 Subject: [PATCH 2/2] fix: use roundConfig.size instead of roundConfig.amount for rawTakerAmt rounding In getMarketOrderRawAmounts function, the rawTakerAmt should be rounded using roundConfig.size instead of roundConfig.amount to ensure consistent precision handling with rawMakerAmt calculations. --- src/order-builder/helpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/order-builder/helpers.ts b/src/order-builder/helpers.ts index e8424868..150b3e88 100644 --- a/src/order-builder/helpers.ts +++ b/src/order-builder/helpers.ts @@ -217,10 +217,10 @@ export const getMarketOrderRawAmounts = ( } else { const rawMakerAmt = roundDown(amount, roundConfig.size); let rawTakerAmt = rawMakerAmt * rawPrice; - if (decimalPlaces(rawTakerAmt) > roundConfig.amount) { - rawTakerAmt = roundUp(rawTakerAmt, roundConfig.amount + 4); - if (decimalPlaces(rawTakerAmt) > roundConfig.amount) { - rawTakerAmt = roundDown(rawTakerAmt, roundConfig.amount); + if (decimalPlaces(rawTakerAmt) > roundConfig.size) { + rawTakerAmt = roundUp(rawTakerAmt, roundConfig.size + 4); + if (decimalPlaces(rawTakerAmt) > roundConfig.size) { + rawTakerAmt = roundDown(rawTakerAmt, roundConfig.size); } }