feat: add 'watchAddress' and 'unwatchAddress' for a real-time address watching system#55
Merged
realfishsam merged 24 commits intopmxt-dev:mainfrom Mar 13, 2026
Merged
Conversation
- Fix SubscribedAddressSnapshot type bugs (positions/balances typed as list[Trade]) - Rewrite track_whale scripts to use actual SDKs instead of raw generated client - Fix Python SDK watch_address/unwatch_address serialization (bypass broken generated model) - Fix Python SDK _convert_subscription_snapshot to convert nested objects - Fix TS example runtime errors (rank type cast, missing paren, null safety) - Fix truncated apiKey JSDoc and mislabeled @param in watcher
Contributor
Author
|
@realfishsam Thanks for your fixes and merging this PR. I will continue watching issues to look for more I can contribute :) |
Contributor
Thanks. I'm super grateful. Please write me on discord so I can give you the contributor role! |
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.
What this PR adds (Close Issue #50 )
A real-time address watching system for prediction market wallets - the equivalent of CCXT Pro's
watchOrderBookbut for user's positions, trades, and balances.New abstractions (core/src/subscriber)
subscriber/base.ts - Core interfaces:
subscriber/watcher.ts -
AddressWatcherorchestrates the CCXT Pro pattern:watch()call returns the initial snapshot immediately; subsequent calls block until something changes (same pattern aswatchOrderBook)getChanged()computes incremental diffs — only new trade IDs, positions whose size changed, balances whose total changed are dispatched; empty diffs are suppressedunwatch()/close()for lifecycle managementsubscriber/external/goldsky.ts — Goldsky subgraph subscriber:
GoldSkySubscriber— polls one or more Goldsky GraphQL endpoints on a configurable interval, with per-addressAbortControllerto cancel stale in-flight requestsPOLYMARKET_DEFAULT_SUBSCRIPTION— orchestrates three parallel + one sequential subgraph query:maker+taker) merged by ID to avoid the or filter statement timeoutuserPositions) → extract tokenIds →tokenIdConditionsfor market metadata (avoids the unindexeduser + asset_injoin that causes timeouts onuserBalances)LIMITLESS_DEFAULT_SUBSCRIPTION— two parallelfrom/toqueries for USDC transfers, same or-split patternbuildPolymarketActivity,buildPolymarketPositionsActivity,buildLimitlessBalanceActivity— activity builders that decode subgraph payloads into typedTrade[],Position[],Balance[]Exchange changes
Polymarket (
watchAddress+unwatchAddress)OrderFilledeventstokenIdConditions0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174ensureAuth()when offeredKey design
BaseSubscriberoffers basic interfaces to be plugable intoAddressWatcherso users can easily replaceGoldSkySubscriberwith others.goldskyis integrated. Butgoldskyis HTTP-only GraphQL; no Websocket subscription protocol available. (The graph supports websocket subscription with more complicated customized setup)Testing (core/examples/social)
pytestunit tests passedtrack_whale.tsandtrack_whale.pytwo testing examples