feat: prime order metadata caches through the public getters - #107
Merged
Merged
Conversation
getVersion adopts the fetched order version for the orders that follow and no longer caches error responses. getClobMarketInfo shares one in-flight request per condition. Concurrent orders share a version request, and a forced refresh after an order version mismatch supersedes pending requests so every waiting caller receives the newer version. Order creation rechecks the fee cache after resolving a token so a market fetch that landed meanwhile is not repeated.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a260eb1. Configure here.
Create-and-post retries only when the CLOB rejected the order for a version mismatch, so a version change observed after a placed order no longer posts it a second time. getVersion joins a pending version request instead of superseding it, every version request adopts its result when it settles, and an error response adopts the default version 2 as before. Under throwOnError the mismatch retry now runs once before the ApiError is surfaced.
WingsDevelopment
approved these changes
Sep 22, 2026
rahul-polymarket
approved these changes
Sep 23, 2026
kartojal
force-pushed
the
feat/prime-order-metadata-caches
branch
from
September 23, 2026 11:43
a24bc4f to
cd4ae08
Compare
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.

Alternative to #106 that adds no new public method. #106 stays open for comparison.
getVersion()adopts the fetched order version for later orders on the client and joins a version request that is already in flight. An error response adopts the default version 2 as before.getClobMarketInfo()shares one in-flight request per condition. It already primes the tick size, neg-risk, and fee caches for both outcomes.createAndPostOrderandcreateAndPostMarketOrderretry once only when the CLOB rejected the order for a version mismatch, instead of when a version snapshot changed. This closes a double-post path and also retries underthrowOnErrorbefore surfacing theApiError.Release notes: calling
getVersion()now also sets the version used to sign later orders on that client. UnderthrowOnError, a version mismatch is retried once before it throws.No version bump. The release commit sets it.
Note
Medium Risk
Changes order-post retry semantics and version/market metadata caching on the trading path; incorrect retry logic could duplicate posts or leave orders on wrong exchange versions.
Overview
getVersion()andgetClobMarketInfo()now prime per-client caches used when signing orders: version is stored on success (default 2 on soft failure), and market fetches refresh tick size, neg-risk, and fees for both outcomes. Concurrent callers share one in-flight/versionor per-condition CLOB market request instead of duplicating GETs.Create-and-post flows change how migration recovery works:
createAndPostOrder/createAndPostMarketOrderretry once only when the CLOB returns an order version mismatch, including underthrowOnError, instead of re-posting whenever a version snapshot changed between attempts (closing a double-post path). Forced refreshes after mismatch clear stale in-flight version requests. Token resolution skips a redundant market fetch if warm-up filled fee caches meanwhile.The README documents a two-call warm-up (
getVersion+getClobMarketInfo) before the first trade. NeworderMetadataCache.test.tscovers cache priming, refresh, deduplication, failure modes, and mismatch retries.Reviewed by Cursor Bugbot for commit a24bc4f. Bugbot is set up for automated code reviews on this repo. Configure here.