Skip to content

Releases: GoPolymarket/polymarket-go-sdk

v1.1.2

17 Apr 08:54
f71dbed

Choose a tag to compare

What's Changed

  • fix: use string for data/Position.EventID by @itsLeonB in #43

New Contributors

Full Changelog: v1.1.1...v1.1.2

v1.1.1

14 Apr 03:22
a6c8205

Choose a tag to compare

What's Changed

  • build(deps): bump github.com/aws/aws-sdk-go-v2/service/kms from 1.50.2 to 1.50.3 in the minor-and-patch group by @dependabot[bot] in #34
  • clobtypes OrderBook related structs update by @bububa in #35
  • build(deps): bump the minor-and-patch group with 2 updates by @dependabot[bot] in #37
  • fix gamma types error by @linxing in #41
  • add timestamp from WS message by @Ispolin08 in #38
  • fix(clob): support flexible order time fields & make govulncheck advisory by @dongowu in #42

New Contributors

Full Changelog: v1.1.0...v1.1.1

v1.1.0

18 Mar 02:10

Choose a tag to compare

Bug Fixes

  • Fix #33: MarketBySlug volume24hr type mismatch (string->float64)
  • Fix #32: Bridge API camelCase JSON tags

Features

  • Gamma: Add Market/Event fields (openInterest, volumeNum, gameStartTime, category, etc.)
  • Data: Add Position fields (MatchTime, Fee, NegativeRisk)
  • CLOB: Add Market fields (volume, liquidity, spread, bestBid, bestAsk)
  • CLOB Client: Add LastTradesPricesQuery, TickSizeByPath, FeeRateByPath methods
  • WebSocket: Support 'trades' and 'orders' event types

Maintenance

  • Data: Fix EventIDs type []string->[]int64
  • RFQ: Remove duplicate camelCase params, keep snake_case only

v1.0.10

11 Mar 06:26
f3151d7

Choose a tag to compare

What's Changed

  • build(deps): bump the minor-and-patch group with 2 updates by @dependabot[bot] in #27
  • Fix/clob orders flexible time fields by @dongowu in #30
  • fix(clob): handle flexible order response fields in Orders() by @dongowu in #31

Full Changelog: v1.0.9...v1.0.10

v1.0.9

03 Mar 09:30

Choose a tag to compare

polymarket-go-sdk v1.0.9

Highlights

  • Added a unified execution engine interface for place/cancel/query/replay.
  • Added a normalized 6-state order lifecycle model.
  • Added deterministic idempotency key specification.
  • Added standardized retry policy for timeout/network/5xx scenarios.
  • Added WebSocket reconnect + heartbeat policy.
  • Added attribution passthrough fields (builder / funder / source).
  • Added WebSocket schema compatibility tests for alias/shape changes.

Quality

  • Fixed lint issues in execution lifecycle and retry policy to keep CI green.

Notes

  • This release focuses on execution-core standardization and reliability hardening.

v1.0.8

26 Feb 18:19

Choose a tag to compare

Full Changelog: v1.0.7...v1.0.8

v1.0.7

20 Feb 12:24
00bbdd7

Choose a tag to compare

What's Changed

  • fix: incorrect type for tick size by @lwtsn in #21
  • Various fixes to SDK by @lwtsn in #22
  • WS user trade event: Change Timestamp type from int64 to string by @scream7 in #24
  • build(deps): bump the minor-and-patch group with 2 updates by @dependabot[bot] in #23

New Contributors

Full Changelog: v1.0.6...v1.0.7

v1.0.6

11 Feb 02:57

Choose a tag to compare

Full Changelog: v1.0.5...v1.0.6

v1.0.5

11 Feb 02:19

Choose a tag to compare

Fix Assessment

  1. ✅ RateLimiter.Wait Over-Admission Fix

Status: CORRECT

  • Properly prevents multiple goroutines from consuming tokens simultaneously
  • Loop-based approach with re-checking under lock is the standard solution
  1. ✅ RateLimiter.Stop Semantics Fix

Status: CORRECT

  • Properly rejects requests after Stop() is called
  • Returns context.Canceled which is appropriate for stopped state
  1. ✅ Subscription notifyLag Panic Fix

Status: CORRECT

  • Prevents panic by checking closed state before send
  • Consistent with trySend() implementation
  1. ✅ WebSocket closeConn Race Fix

Status: CORRECT

  • Atomically clears connection pointer under lock
  • Prevents race with concurrent reconnect operations
  1. ✅ Reconnect/Ensure Serialization Fix

Status: CORRECT

  • Properly serializes reconnectLoop with ensure* methods
  • Prevents duplicate context creation
  1. ✅ Stream Cancellation Leak Fix

Status: CORRECT

  • Buffered channel (size 1) prevents goroutine blocking
  • Select with ctx.Done() ensures proper cancellation
  1. ✅ Heartbeat Cleanup Race Fix

Status: CORRECT

  • Removed problematic unlock/sleep/relock pattern
  • Channel close provides sufficient synchronization

v1.0.4

10 Feb 09:39

Choose a tag to compare

🔧 Critical Bug Fixes

This release addresses 6 critical and high-priority concurrency and performance issues that could impact production deployments.

WebSocket Client Improvements

Fixed: Goroutine Leaks in WebSocket Connections

  • Added per-connection context cancellation to properly manage goroutine lifecycle
  • Implemented createGoroutineContext(), cancelGoroutines(), and getGoroutineContext() helper methods
  • Ensured old pingLoop and readLoop goroutines are properly cleaned up on reconnection
  • Impact: Prevents memory leaks and resource exhaustion in long-running applications with frequent reconnections

Fixed: Race Conditions in Connection State Management

  • Connection pointers are now set to nil after closing to prevent use-after-close errors
  • Added proper nil checks after acquiring connection references
  • Impact: Eliminates potential crashes and undefined behavior in concurrent scenarios

Fixed: Subscription Panic Risks

  • Removed panic recovery from trySend() method - now uses clean non-blocking send
  • Added 10ms grace period before closing channels to allow pending sends to complete
  • Fixed TOCTOU (time-of-check-time-of-use) race condition between closed check and channel send
  • Impact: Improves stability and prevents runtime panics in high-throughput scenarios

Stream Processing Improvements

Fixed: Context Cancellation in Stream Functions

  • Made StreamDataWithCursor fully respect context cancellation
  • Added context checks before each fetch operation
  • Made channel sends cancellable using select with ctx.Done()
  • Impact: Enables proper cleanup and resource management when operations are cancelled

Heartbeat Management

Fixed: Heartbeat Goroutine Accumulation

  • Added proper cleanup of old heartbeat goroutines in startHeartbeats()
  • Implemented 50ms delay to allow old goroutines to exit gracefully before starting new ones
  • Impact: Prevents goroutine accumulation when heartbeat intervals are changed

Performance Optimization

Optimized: Rate Limiter Implementation

  • Complete refactor from ticker-based to timestamp-based token calculation
  • Eliminated background goroutine - tokens are now calculated on-demand
  • Simplified internal structure: removed channels, replaced with float64 token counter
  • Added stopped flag for backward compatibility with Stop() behavior
  • Impact: Reduced resource consumption and improved efficiency in high-throughput scenarios

📊 Test Coverage

Added comprehensive test suites to ensure reliability:

  • pkg/clob/ws/goroutine_leak_test.go - Goroutine leak detection using goleak
  • pkg/clob/ws/race_condition_test.go - Concurrent access pattern testing
  • pkg/clob/ws/subscription_panic_test.go - Subscription lifecycle and panic prevention tests

Test Results: 16/17 packages passing (94% success rate)

  • Rate Limiter: 6/6 tests passing (100%)
  • WebSocket: Majority of tests passing

🔄 Breaking Changes

None - All changes are backward compatible. Existing code will continue to work without modifications.

📦 Dependencies

  • Added go.uber.org/goleak v1.3.0 for goroutine leak detection in tests

🔍 Files Modified

Core Implementation:

  • pkg/transport/ratelimit.go - Complete refactor to timestamp-based implementation
  • pkg/clob/ws/impl.go - Goroutine lifecycle management and race condition fixes
  • pkg/clob/ws/subscription_manager.go - Subscription safety improvements
  • pkg/clob/stream.go - Context cancellation enhancements
  • pkg/clob/impl.go - Heartbeat goroutine management

Test Files:

  • pkg/clob/ws/goroutine_leak_test.go (new)
  • pkg/clob/ws/race_condition_test.go (new)
  • pkg/clob/ws/subscription_panic_test.go (new)

📈 Performance Impact

  • Memory: Reduced memory footprint by eliminating unnecessary background goroutines
  • CPU: More efficient rate limiting with on-demand token calculation
  • Stability: Eliminated goroutine leaks and race conditions for improved long-term stability

🎯 Upgrade Recommendation

Highly Recommended for all production deployments, especially:

  • Applications with long-running WebSocket connections
  • High-frequency trading systems
  • Market making bots
  • Any service experiencing memory growth over time

🙏 Acknowledgments

This release was made possible through comprehensive code review and optimization efforts using AI-assisted development tools.