Repository navigation
feat: route WebSockets through proxies, speed up hot paths, refresh docs - #29
Merged
Merged
Conversation
IXWebSocket cannot use proxies, so market, user, and JSON-RPC WebSockets connected directly even when REST used a proxy. A routed WebSocketClient now connects through a loopback relay that forwards each connection over a libcurl CONNECT_ONLY session, so WebSockets get the same HTTP, HTTPS, and SOCKS proxy support and TLS verification as REST. - Add NetworkRoute and set_default_network_route() to route every SDK transport, including the ones PositionClient, OrderbookManager, UserStream, and the JSON-RPC clients create internally. - Add interface binding (HttpClientOptions/WebSocketOptions interface_name) for VPN tunnel interfaces. - Routes fail closed: an unreachable or rejecting proxy fails the connection instead of falling back to a direct route. - Drop the dead CURLOPT_PROXYTYPE branch: a socks5:// scheme already selects local DNS, contrary to its comment. Docs recommend socks5h://. - Add check_geoblock() and ClobClient::get_geoblock_status(), which query Polymarket's eligibility endpoint through the configured route. HttpClientOptions and WebSocketOptions gained trailing fields; consumers must rebuild against the new headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Market data: - Parse each frame once without deep-copying the JSON DOM. - Read price and size strings by reference instead of copying them before conversion; strtod keeps std::stod's grammar and range errors. - Emit snapshots already in book order and detect duplicate prices with a sort instead of a hash set per side. - Gate the arbitrage check on prices before copying market identifiers. Order path: - Encode decimal uint256 values without per-digit allocations. - Hex-encode with a lookup table instead of stringstream. - Compute the constant POLY_1271 type hashes and suffix once. - Cache neg-risk metadata for the client's lifetime. A token's neg-risk flag is fixed at market creation, so the 5-minute TTL only added a round trip to the order path. Benchmarks now use real-length IDs and price_change traffic. Best of 7, Release, Apple M4 Max: 100-level book 53.7 to 28.7 us, price_change 5.8 to 3.4 us, V2 signing 27.1 to 15.6 us. New tests cover malformed numbers and changes, unsorted duplicate prices, 77-digit and uint256-boundary token IDs against their hex forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rewrite the README with a centered header, badges, a compiling quick start, feature and example tables, performance numbers, and a docs index. Move migration notes and Polygon indexing details into docs/migration.md and docs/polygon-indexing.md. - Add a repository map and networking and benchmark references to AGENTS.md, and CLAUDE.md that imports it for Claude Code. - Add SECURITY.md, CODEOWNERS, and a network route field in the bug report template. - Turn build.sh into a one-command configure, build, and offline test run that works with the bash 3.2 shipped on macOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
set_proxy. Market, user, and JSON-RPC WebSockets always connected directly, because IXWebSocket has no proxy support.build.sh) was stale.Changes
Networking (
feat(network))WebSocketClientconnects through a loopback relay that forwards each connection over a libcurlCONNECT_ONLYsession. WebSockets get the same HTTP, HTTPS, and SOCKS proxies and TLS verification as REST.set_default_network_route()routes every SDK transport, including internal ones.interface_nameoption binds to VPN interfaces.check_geoblock()/ClobClient::get_geoblock_status()query Polymarket's eligibility endpoint through the configured route.Performance (
perf), best of 7, Release, Apple M4 Max:price_changeNeg-risk metadata is now cached for the client's lifetime, which removes a periodic round trip from the order path.
Docs (
docs)docs/networking.md,docs/migration.md,docs/polygon-indexing.md.build.shis now a one-command build and offline test run.Compatibility
HttpClientOptionsandWebSocketOptionsgained trailing fields, so consumers must rebuild. This suggests v3.1.0. No source changes are needed.Validation
test_network_routingandtest_package_consumer.scripts/quality.py origin/mainpasses: clang-format, clang-tidy, Prettier.wss://market subscription through a local CONNECT proxy received real book data, and the geoblock check went through the proxy.Follow-ups worth considering:
HttpClienthandle pool, since requests on one client are serialized.🤖 Generated with Claude Code