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
Open
fix: use round_down for price in market orders (closes #323)#330Sertug17 wants to merge 1 commit into
Sertug17 wants to merge 1 commit into
Conversation
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
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
get_market_order_amountsusesround_normalforraw_price, which canround 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_downfor price in market orders.Fix
Replace
round_normalwithround_downforraw_priceinsideget_market_order_amountsonly. Theget_order_amounts(limit orders)function is intentionally left unchanged.
References
Closes #323
Note
Medium Risk
Changes rounding behavior for
raw_pricein 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
pricedown (replacinground_normalwithround_down) inget_market_order_amounts, preventing price rounding up from shifting computed maker/taker amounts.Limit-order pricing via
get_order_amountsis 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.