fix: Cap market order taker amount at 4 decimals to match API limit (#87) - #88
Open
lushan888 wants to merge 1 commit into
Open
fix: Cap market order taker amount at 4 decimals to match API limit (#87)#88lushan888 wants to merge 1 commit into
lushan888 wants to merge 1 commit into
Conversation
…olymarket#87) The Polymarket CLOB API accepts market-order taker amounts with at most 4 decimal places, but getMarketOrderRawAmounts uses the tick-size rounding config (amount: 5 for 0.001-tick, amount: 6 for 0.0001-tick), which can produce amounts with 5-6 decimals. Fix: after the existing tick-size rounding logic, cap rawTakerAmt at 4 decimals (roundDown) for both BUY and SELL branches. This ensures the parsed takerAmount never exceeds the API's limit. 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.
Fix for #87 — Market orders rejected due to taker amount precision
Problem
getMarketOrderRawAmountsrounds the taker amount usingROUNDING_CONFIG.amount(5-6 decimals for 0.001/0.0001 tick markets), but the CLOB API accepts at most 4 decimals for the taker amount. Result: orders are rejected server-side.Fix
After the existing tick-size rounding logic, cap
rawTakerAmtat 4 decimals usingroundDownfor both BUY and SELL branches. This is a 4-line change with a named constant.Verification
Impact
Wallet (Base): 0xaa9e4971e0973065513b18dEF9eC06Eb1F39D7A2
Note
Low Risk
Localized rounding change in market order amount calculation with no API or signature changes; slight downward bias on taker size only when capping applies.
Overview
Fixes CLOB rejections when market orders compute a taker amount with more than four decimal places (common on 0.001/0.0001 tick markets where
roundConfig.amountallows 5–6 decimals).getMarketOrderRawAmountsnow definesMAX_TAKER_DECIMALS = 4and, after the existing tick-size rounding on both BUY and SELL, appliesroundDownonrawTakerAmtwhen precision exceeds that cap. Maker-side rounding and the function signature are unchanged; only the final taker value sent throughbuildMarketOrderCreationArgsis adjusted to match the API limit.Reviewed by Cursor Bugbot for commit 4902e88. Bugbot is set up for automated code reviews on this repo. Configure here.