fix: cap market order taker at 4 decimals (API limit) - #92
Open
osr21 wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getMarketOrderRawAmountsrounds taker amounts usingROUNDING_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:This is reproducible on any fine-tick market — see #87 for a repro table and workaround.
Fix
Introduce
const API_TAKER_MAX_DECIMALS = 4and replaceroundConfig.amountin both BUY and SELL precision-capping logic ingetMarketOrderRawAmounts.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
getMarketOrderRawAmountsno longer followsroundConfig.amount(5–6 decimals on fine ticks). It now capsrawTakerAmtatAPI_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.