Skip to content

Add check-polymarket connectivity check; never follow redirects with credential headers - #3

Merged
markb-1 merged 2 commits into
mainfrom
claude/keen-allen-b8lq9q
Oct 31, 2026
Merged

markb-1 merged 2 commits into
mainfrom
claude/keen-allen-b8lq9q

Conversation

@markb-1

@markb-1 markb-1 commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • New npm run cli -- check-polymarket: tests whether this machine's IP can use every Polymarket endpoint BotLab needs, before you move to a VPS or new box.
    • What it reports: your public IP and country, Polymarket's geoblock status, and read-only checks on the CLOB (time and clock skew, a market, a book), Gamma and the Data API.
    • Options: --with-credentials adds authenticated read-only checks that print no keys; --binance adds Binance.
    • How it classifies results: country block vs datacenter/bot protection (Cloudflare challenges and error 1009 are recognised) vs rate limit vs network error.
    • Verdict and exit code: OK (0), BLOCKED (1) or DEGRADED (2); --json is available.
    • Safety: read-only, never creates API keys, can run while the server is running.
  • Security fix in the trading path: requests carrying credential headers no longer follow redirects.
    • Polymarket: clob-client goes through axios, which strips only Authorization/Cookie on a cross-host redirect. A redirect would therefore have sent POLY_API_KEY, POLY_PASSPHRASE and POLY_SIGNATURE to the other host. An axios interceptor now sets maxRedirects: 0 on any request with POLY_* headers.
    • Binance: signed requests use redirect: 'error'. A redirected order is treated as an unknown outcome, which the reconciler settles.
    • Proof: a test with two real local servers shows the leak without the fix and none with it.
  • README: new "Hosting on a VPS" section. It covers trialling an hourly instance with the check, the geo vs datacenter distinction, the terms-of-service warning against evading geo restrictions, Tailscale-only access, off-box backups, and falling back to a home connection.

Testing

  • 1,229 tests pass (SKIP_NETWORK_TESTS=1); typecheck, lint (0 errors) and build pass. Reviewed independently, and the findings are fixed.
  • Not verified against live endpoints: the sandbox has no outbound network. The geoblock endpoint's shape is marked VERIFY until the command is run on a real machine.

Decisions R205–R208 are in docs/PROGRESS.md.


Generated by Claude Code

`npm run cli -- check-polymarket [--prod] [--json] [--with-credentials] [--binance]`
checks, read-only, every Polymarket endpoint BotLab uses (CLOB, Gamma, data API,
geoblock endpoint, public IP / country) and optionally Binance, classifies each
request (ok, geo_blocked, bot_challenge, forbidden, rate_limited, network_error,
unexpected) and prints a verdict with exit code 0 ok / 1 blocked / 2 degraded.
With credentials it derives the wallet's existing CLOB API key and makes two L2
GETs (nothing created, no secrets printed). Logic in core with injectable fetch;
README "Hosting on a VPS"; PROGRESS R205-R207.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjwENrgG4j59smeu31MTHW
- Credentials never follow a redirect: authenticated connectivity probes use
  redirect 'manual' (3xx = unexpected, not followed) and refuse http CLOB URLs;
  axios request interceptor sets maxRedirects 0 for requests with POLY_*
  headers (trading path); Binance signed requests use redirect 'error'.
- Cloudflare 1009 country ban classified as geo_blocked.
- Read-only DB open reports the real error; proxy detection follows Node's
  order and no_proxy; "via proxy" only when fetch uses it.
- Tests for all of the above, checkPolymarket.ts and authHeaders.ts.
- PROGRESS: R205-R207 amended, R208, log entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjwENrgG4j59smeu31MTHW
@markb-1
markb-1 merged commit 435d834 into main Oct 31, 2026
7 checks passed
markb-1 added a commit that referenced this pull request Nov 1, 2026
Brings in PRs #2 and #3. Their README edits now live in the guides:
"Hosting on a VPS" in docs/guide/install.md, the min_liquidity_usd note in
operations.md, the executor / position manager / copy-trading changes in
strategies.md, and check-polymarket in development.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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