Skip to content

Normalize taker and maker amounts in orders - #68

Open
gmoutsin wants to merge 1 commit into
Polymarket:mainfrom
gmoutsin:main
Open

Normalize taker and maker amounts in orders#68
gmoutsin wants to merge 1 commit into
Polymarket:mainfrom
gmoutsin:main

Conversation

@gmoutsin

@gmoutsin gmoutsin commented Jun 10, 2026

Copy link
Copy Markdown

When creating an order, the price is multiplied by the size. Often rust overestimates the scale of the product. This can lead to decimal number such as 156730010^(-5) instead of 1567310^(-3) and subsequently this may be rejected by the server. Normalizing the amounts before creating the order solves this problem.


Note

Low Risk
Two-line normalization in limit order build only; intended numeric values unchanged, reduces spurious server rejections.

Overview
Limit order construction now canonicalizes taker_amount and maker_amount with normalize_assign() right after size * price is truncated, and before those values are passed through to_fixed_u128 into the order payload.

That addresses cases where rust_decimal keeps an inflated scale on the product (same value, different representation), which the CLOB server can reject even though to_fixed_u128 already normalizes at encode time.

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

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.

1 participant