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

fix: use round_down for price in market orders (closes #323)#330

Open
Sertug17 wants to merge 1 commit into
Polymarket:mainfrom
Sertug17:fix/market-order-price-round-down
Open

fix: use round_down for price in market orders (closes #323)#330
Sertug17 wants to merge 1 commit into
Polymarket:mainfrom
Sertug17:fix/market-order-price-round-down

Conversation

@Sertug17
Copy link
Copy Markdown

@Sertug17 Sertug17 commented Apr 14, 2026

Problem

get_market_order_amounts uses round_normal for raw_price, which can
round the price up when the fractional part is >= 0.5. This causes the
computed maker/taker amounts to diverge from the TypeScript client, which
consistently uses round_down for price in market orders.

Fix

Replace round_normal with round_down for raw_price inside
get_market_order_amounts only. The get_order_amounts (limit orders)
function is intentionally left unchanged.

References

Closes #323


Note

Medium Risk
Changes rounding behavior for raw_price in market orders, which can alter computed maker/taker amounts and downstream order signing/execution. Risk is limited in scope but affects trading amount calculations.

Overview
Market-order amount calculation now always rounds price down (replacing round_normal with round_down) in get_market_order_amounts, preventing price rounding up from shifting computed maker/taker amounts.

Limit-order pricing via get_order_amounts is unchanged, keeping prior rounding behavior there.

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

Market orders should use round_down (not round_normal) when computing
raw_price to match TypeScript client behavior and avoid over-paying.

Closes Polymarket#323
@Sertug17 Sertug17 requested a review from a team as a code owner April 14, 2026 20:16
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.

bug: market order price uses round_normal instead of round_down (inconsistent with TS client)

1 participant