Skip to content

feat(gamma): add typed Gamma API client - #38

Merged
SebastianBoehler merged 7 commits into
SebastianBoehler:mainfrom
yluoc:typed-gamma-API
Oct 17, 2026
Merged

SebastianBoehler merged 7 commits into
SebastianBoehler:mainfrom
yluoc:typed-gamma-API

Conversation

@yluoc

@yluoc yluoc commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Summary

The SDK had no typed Gamma client. Gamma was parsed ad hoc in three places, so there was no SDK API for market discovery.

  • Adds GammaClient, matching the official Python SDK's Gamma calls: markets and events (by ID, slug or URL, plus filtered lists), tags, series, sports, teams, search, comments and public profiles.
  • Typed results with a raw JSON copy of each object. Lists skip non-binary markets, as the Python SDK does.
  • Paginator gains the paging styles Gamma needs: keyset, page-numbered, and offset pages that count only some rows (top-level comments).
  • PositionClient::resolve_market now looks markets up through GammaClient, using /markets/keyset instead of /markets. Its checks and error messages are unchanged.
  • Adds scripts/ci_local.sh, which runs this workflow's checks locally, and the missing <cstddef> include in src/evm_rlp.cpp.

Verification

Commands run and their actual results:

  • scripts/ci_local.sh --title "feat(gamma): add typed Gamma API client" (WSL Ubuntu, GCC 12, Clang 18):
    • Release, Debug and ASan+UBSan builds: all tests pass.
    • Lint: pass.
    • Clang 18 build: pass.
    • Fuzzers, 60 s each: websocket_messages 440,922 runs, rest_responses 36,331 runs, no crashes.
    • PR title check: pass.
  • Mutation checks: each key Gamma rule was broken on purpose (non-binary skip, page-size caps, comment routing, top-level counting, 404 profile), and each made its test fail.

Checks not run and the reason (or none):

  • GCC 11 (the ubuntu-22.04 runners): not installed locally, so CI covers it.
  • macOS jobs: not possible locally; the Clang 18 build is the closest stand-in.
  • test_clob_rate_limit failed intermittently under WSL, passing on every rerun. It checks wall-clock timestamps and isn't touched by this PR.

Compatibility and evidence

Public API, binary compatibility, or release implications (or none):

  • New public headers: gamma_client.hpp, gamma_types.hpp, gamma_catalog_types.hpp, gamma_social_types.hpp and gamma_requests.hpp.
  • Rebuild required: PageRequest gains page and exhausted, and Page<T> gains counted and has_more.
  • Paginator behavior:
    • Cursor paging now reports done() right after its last page.
    • A resume token from a finished keyset or numbered paginator doesn't fetch again.
  • PositionClient:
    • It validates gamma_api_url (http or https) when constructed, instead of on the first lookup.
    • Its market parsing is now strict, as elsewhere in GammaClient.

Protocol source: py-sdk 72297f05d6d8 (_internal/actions/gamma.py, models/gamma/*).

Live checks (read-only GETs to the public Gamma API, 2026-10-16):

  • Response shapes: these were recorded and became the trimmed test fixtures. Personal data in comment and profile responses is replaced with synthetic values.
  • Observed behavior:
    • Gamma caps page sizes: /tags at 100 and /series at 50.
    • It rejects comment offsets above 200 with a 422.
    • /markets/keyset returns the same markets as /markets for open markets, and for closed markets both with and without closed=true.
  • Everything else is covered only by local fixture tests. No orders or transactions were sent.

@SebastianBoehler

Copy link
Copy Markdown
Owner

Thanks for keeping contributing! Looks good

@SebastianBoehler
SebastianBoehler merged commit a4ba07d into SebastianBoehler:main Oct 17, 2026
8 checks passed
@yluoc
yluoc deleted the typed-gamma-API branch October 17, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants