Skip to content

fix: cap market order taker at 4 decimals (API limit) - #92

Open
osr21 wants to merge 1 commit into
Polymarket:mainfrom
osr21:fix/market-order-precision
Open

fix: cap market order taker at 4 decimals (API limit)#92
osr21 wants to merge 1 commit into
Polymarket:mainfrom
osr21:fix/market-order-precision

Conversation

@osr21

@osr21 osr21 commented Jul 24, 2026

Copy link
Copy Markdown

Problem

getMarketOrderRawAmounts rounds taker amounts using ROUNDING_CONFIG.amount (5 for tick 0.001, 6 for 0.0001). The CLOB API caps market-order taker amounts at 4 decimal places; orders with more precision are rejected:

invalid amounts, the market bu…

This is reproducible on any fine-tick market — see #87 for a repro table and workaround.

Fix

Introduce const API_TAKER_MAX_DECIMALS = 4 and replace roundConfig.amount in both BUY and SELL precision-capping logic in getMarketOrderRawAmounts.ts.

Testing

Verified against the precision matrix from #87 across all tick sizes (0.1 → 0.0001).

Fixes #87


Note

Low Risk
Localized rounding change in order amount calculation; reduces rejected orders without touching auth or broader order flow.

Overview
Market order taker sizing in getMarketOrderRawAmounts no longer follows roundConfig.amount (5–6 decimals on fine ticks). It now caps rawTakerAmt at API_TAKER_MAX_DECIMALS (4) for both BUY and SELL, matching the CLOB rule that rejects higher-precision taker amounts.

A short comment documents the API limit and links to issue #87. Return shapes are unchanged; only the precision gate and minor formatting differ.

Reviewed by Cursor Bugbot for commit fcba536. Bugbot is set up for automated code reviews on this repo. Configure here.

getMarketOrderRawAmounts uses ROUNDING_CONFIG.amount (5 or 6 for fine tick
sizes) to cap rawTakerAmt. The CLOB API enforces taker ≤ 4 decimals;
orders with more are rejected: "invalid amounts, the market bu…".

Introduce API_TAKER_MAX_DECIMALS = 4 and replace roundConfig.amount in
both BUY and SELL precision-capping logic.

Fixes: Polymarket#87
@osr21
osr21 requested a review from a team as a code owner July 24, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Market orders: taker amount rounded to tick precision (5-6 decimals) but API caps it at 4 — orders rejected

1 participant