Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

[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

Open
GDdark wants to merge 2 commits into
Polymarket:mainfrom
GDdark:bugfix

Conversation

@GDdark
Copy link
Copy Markdown

@GDdark GDdark commented Jan 18, 2026

Fix error: 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

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.


Note

Fixes rounding precision for market orders to align taker amount with token size.

  • Updates getMarketOrderRawAmounts to round rawTakerAmt using roundConfig.size (not roundConfig.amount) for both BUY and SELL paths
  • Prevents precision/validation errors when posting market orders

Written by Cursor Bugbot for commit 1343aa9. This will update automatically on new commits. Configure here.

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.
@GDdark GDdark requested a review from a team as a code owner January 18, 2026 08:03
@GDdark GDdark changed the title fix: use roundConfig.size for rawTakerAmt decimal places in BUY orders [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 Jan 18, 2026
@GDdark
Copy link
Copy Markdown
Author

GDdark commented Jan 18, 2026

Related issue
Polymarket/py-clob-client#121

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in Cursor Fix in Web

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant