[Fix Bug]: invalid amounts, the market buy orders maker amount supports a max accuracy of 2 decimals, taker amount a max of 4 decimals when post order with OrderType.GTC#266
Conversation
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.
…mt rounding In getMarketOrderRawAmounts function, the rawTakerAmt should be rounded using roundConfig.size instead of roundConfig.amount to ensure consistent precision handling with rawMakerAmt calculations.
|
Related issue |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| if (decimalPlaces(rawTakerAmt) > roundConfig.size) { | ||
| rawTakerAmt = roundUp(rawTakerAmt, roundConfig.size + 4); | ||
| if (decimalPlaces(rawTakerAmt) > roundConfig.size) { | ||
| rawTakerAmt = roundDown(rawTakerAmt, roundConfig.size); |
There was a problem hiding this comment.
SELL orders use wrong rounding config for collateral
High Severity
For SELL market orders, rawTakerAmt is calculated as rawMakerAmt * rawPrice, which represents a collateral amount (not token size). The change incorrectly uses roundConfig.size for collateral precision when it should use roundConfig.amount. This is inconsistent with getOrderRawAmounts where SELL orders correctly use roundConfig.amount for rawTakerAmt collateral. Using size (2 decimals) instead of amount (4+ decimals) causes premature rounding of collateral amounts.
Fix error:
invalid amounts, the market buy orders maker amount supports a max accuracy of 2 decimals, taker amount a max of 4 decimalswhen post order withOrderType.GTCFix 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.
Note
Fixes rounding precision for market orders to align taker amount with token size.
getMarketOrderRawAmountsto roundrawTakerAmtusingroundConfig.size(notroundConfig.amount) for both BUY and SELL pathsWritten by Cursor Bugbot for commit 1343aa9. This will update automatically on new commits. Configure here.