Repository navigation
feat(clob): add order-flow helpers for fill estimates, one-call orders, and settlement - #32
Conversation
…gnostic book walk
|
This PR adds the order-flow helpers our C++ SDK was missing compared with the official Python and TypeScript SDKs: a fill-price estimate, one-call limit and market orders, and a wait until fills settle. Why we need it. A bot using this SDK had to build orders by hand, couldn't preview what a market order would cost, and had no way to know when a fill was final. After a match, a trade can still fail on-chain, so a bot that updates its position right after posting can think it holds shares it doesn't. wait_for_order_fill_settlement fixes that by waiting until each fill is CONFIRMED or FAILED. Where it goes further than the official SDKs: Full fill preview: the estimate returns the average price, shares, collateral and levels touched, not just the worst price. That's what you need for a slippage check. |
|
Thanks Bill, these helpers are useful, especially the offline estimate, corrected REST/stream book ordering, and exact signed price bound. I reviewed Behavior findings
Error handling and smaller follow-ups
Validation: all four CI jobs pass. Independently, the macOS Release build completed for the affected targets and The documented restriction to the initial |
…placement helpers
|
@SebastianBoehler all issues are fixed. Let me know if you have other concerns. Thanks. |
|
@yluoc Thanks Bill. I double-checked current head [P2] Metadata errors are still lost inside delegated order creation. Initial tick/book lookups now preserve their errors, but these placement branches still use the legacy optional lookups:
I reproduced all 12 combinations: both placement helpers, all three branches, and both failure responses. Each returns: The placement helpers delegate to Could you preserve the original I would hold the merge for this follow-up. |
Summary
Adds the order-flow helpers from the official SDKs:
estimate_market_price: walks the book and returns the worst and average price, simulated fill, andfully_fillable. Also works offline on a book you already hold.place_limit_order: GTC, or GTD whenexpirationis set (at least 180 s ahead), withpost_only.place_market_order: FAK/FOK. Withworst_priceit signs at that bound; without it, it prices from the book and fails a shallow FOK withInsufficientLiquiditybefore signing.get_tradeandwait_for_order_fill_settlement: poll fills untilCONFIRMEDorFAILEDand return the settlement hashes.Also fixes the book walk starting at the worst level for best-first (
OrderbookManager) books. Addsdocs/order-flow.md, README usage, andorder_flow_example. Existingcreate_*/post_orderAPIs are unchanged.Verification
Commands run and their actual results:
ctest -LE live: 60/60 passed, includingtest_package_consumerand 4 new test executables.scripts/quality.py origin/main: clang-format and clang-tidy passed.POLYMARKET_RUN_LIVE_SMOKE=1 ctest -L live: both live tests passed.Checks not run and the reason:
Compatibility and evidence
Public API, binary compatibility, or release implications:
market_price.hpp, new param and result types, and newClobClientmethods. Not breaking; minor release.SdkErrorCodegainsInsufficientLiquidity,TimeoutandTransactionFailed(appended), so exhaustiveswitchstatements will warn.Protocol evidence:
Polymarket/py-sdk@ed8d04c(orders/estimate.py,limit.py,market.py,settlement.py).Live outcomes observed were read-only. Everything that signs or posts an order is covered by fake-server fixtures only.