Conversation
Phase 2 of the V1 retirement plan, scheduled to merge at the 2026-04-28 11:00 UTC Polymarket cutover. After cutover the V1 endpoints stop accepting orders, so V2 becomes the only path that actually trades. The flag still works for explicit V1 opt-in (`POLYMARKET_V2_ENABLED=false`) during the soak window — the V1 code itself is removed in v2.0 / #37 ~2026-05-05. Changes: - feature_flags.v2_enabled() defaults to "true" when the env var is unset - v1 fixture in both test files now setenv("false") instead of delenv - v2 fixture switches to delenv (default-on) for symmetry - TestFeatureFlag covers the new defaults - .env.example now documents the V2 default + the V1 opt-out path 42/42 tests pass on the new defaults. Behavior at runtime: - Existing operators with POLYMARKET_V2_ENABLED=true: unchanged - Operators who set =false explicitly: still on V1 (until v2.0 deletes V1) - Operators with no flag set: now on V2 (was V1) DO NOT MERGE BEFORE 2026-04-28 11:00 UTC. Pre-cutover this would route trades to V2 endpoints with no liquidity. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe pull request inverts the default behavior of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
So a fresh Claude Code session starting tomorrow can pick up the cutover plan from this file alone. Adds: - Cutover timestamp + Phase 2 PR #49 pointer + DO-NOT-MERGE-EARLY warning - Single-source feature_flags.v2_enabled() reference - Operator post-flip steps (set_approvals, wrap) - v1-final tag pointer for legacy reference - Missing API routes (/positions/{id}/exit, /wallet/generate|import|unlock|lock|approve-contracts) - POLYMARKET_V2_ENABLED in env list Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
V1 endpoints stopped accepting orders at 2026-04-28 11:00 UTC. The POLYMARKET_V2_ENABLED flag flipped default in PR #49 (commit 306cbcb); this PR removes the V1 code path entirely. Backend: - Delete core/feature_flags.py and the V2_CONTRACTS namespace; merge V2 addresses into CONTRACTS (CTF_EXCHANGE / NEG_RISK_CTF_EXCHANGE now hold V2 addresses, plus PUSD / onramp / offramp). - core/wallet/manager.py: drop _collateral_address/_exchange_addresses helpers, drop NEG_RISK_ADAPTER approvals (dead allowance after #45), rename WalletBalances.usdc_e -> pusd. - core/trading/clob_client.py: delete _get_clob_client_v1 and the V1 endpoint; CLOB client is V2 only. - core/trading/clob.py: drop V1 import branch. - core/trading/executor.py and core/positions/manager.py: drop V1 collateral helpers and the vestigial neg_risk parameter on _split_position / _merge_tokens (Gamma's negRisk is a UI hint, not on-chain routing — see #45). - pyproject.toml: drop py-clob-client dep, keep py-clob-client-v2. Tests: - Delete test_v2_collateral.py (V1/V2 branch tests no longer meaningful). - Strip V1 fixtures from test_v2_order_struct.py. Routers / frontend: cascade rename usdc_e -> pusd through server/routers/wallet.py, server/routers/trading.py, hooks/useWallet.tsx, components/PortfolioModal.tsx, components/terminal/WalletDropdown.tsx (label updated to "pUSD"). Experiments: remove duplicated _v2_enabled() in 01_setup_wallet.py, 03_buy_position.py, 04_transfer_tokens.py; hardcode V2 paths. Docs: drop the V2 cutover banner from README.md and the cutover section in CLAUDE.md; drop POLYMARKET_V2_ENABLED line from .env.example. Operator post-merge step (not code): revoke V1 USDC.e approvals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(v2): scaffold V1 retirement (Phase 3) Empty marker commit so the draft PR can exist. Real changes will be pushed when this branch is picked up post-soak. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(v2): retire V1 paths post-cutover (closes #37) V1 endpoints stopped accepting orders at 2026-04-28 11:00 UTC. The POLYMARKET_V2_ENABLED flag flipped default in PR #49 (commit 306cbcb); this PR removes the V1 code path entirely. Backend: - Delete core/feature_flags.py and the V2_CONTRACTS namespace; merge V2 addresses into CONTRACTS (CTF_EXCHANGE / NEG_RISK_CTF_EXCHANGE now hold V2 addresses, plus PUSD / onramp / offramp). - core/wallet/manager.py: drop _collateral_address/_exchange_addresses helpers, drop NEG_RISK_ADAPTER approvals (dead allowance after #45), rename WalletBalances.usdc_e -> pusd. - core/trading/clob_client.py: delete _get_clob_client_v1 and the V1 endpoint; CLOB client is V2 only. - core/trading/clob.py: drop V1 import branch. - core/trading/executor.py and core/positions/manager.py: drop V1 collateral helpers and the vestigial neg_risk parameter on _split_position / _merge_tokens (Gamma's negRisk is a UI hint, not on-chain routing — see #45). - pyproject.toml: drop py-clob-client dep, keep py-clob-client-v2. Tests: - Delete test_v2_collateral.py (V1/V2 branch tests no longer meaningful). - Strip V1 fixtures from test_v2_order_struct.py. Routers / frontend: cascade rename usdc_e -> pusd through server/routers/wallet.py, server/routers/trading.py, hooks/useWallet.tsx, components/PortfolioModal.tsx, components/terminal/WalletDropdown.tsx (label updated to "pUSD"). Experiments: remove duplicated _v2_enabled() in 01_setup_wallet.py, 03_buy_position.py, 04_transfer_tokens.py; hardcode V2 paths. Docs: drop the V2 cutover banner from README.md and the cutover section in CLAUDE.md; drop POLYMARKET_V2_ENABLED line from .env.example. Operator post-merge step (not code): revoke V1 USDC.e approvals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(skills): drop USDC.e from enter/exit-position skills Update collateral terminology to match V2: rename `usdc_e` -> `pusd` in example wallet/balance JSON, swap "USDC.e" -> "pUSD" in instructional prose. The other four alphapoly skills (feature, experiment, pipeline, portfolios) had no V1 references and were left alone. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(v2): keep V2 CLOB URL aligned with main fix Main got a fix at c189a3c — Polymarket consolidated clob-v2.polymarket.com into clob.polymarket.com post-cutover. This branch was rewriting the same file with the old URL, which would have re-introduced the bug at squash-merge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(v2): estimate gas live for split + merge Hardcoded gas: 300000 was rejected by Chainstack RPC under stricter post-cutover limits ('INTERNAL_ERROR: gas limit is too high'). Actual usage is ~135k for split and ~90k for merge. Estimate live and apply 25% headroom. Verified live during V2 validation: a stuck $3 merge that failed under the old hardcoded limit went through cleanly with the estimate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This is Phase 2 of the V1 retirement plan, prepared in advance so the cutover is a one-click merge — not a scramble.
Pre-cutover (now), V1 endpoints still hold all the liquidity. Merging this PR before 11:00 UTC would route trades to V2 endpoints with empty books, causing slippage / no-fill failures across the bot.
The right merge moment: at or shortly after 11:00 UTC tomorrow, when Polymarket's V1 endpoints stop accepting orders and V2 becomes the live trading path.
Summary
Flips the default of `POLYMARKET_V2_ENABLED` from off-when-unset to on-when-unset. The flag itself still exists; explicit `POLYMARKET_V2_ENABLED=false` keeps the V1 code path during the soak window. V1 is fully removed in v2.0 (~2026-05-05) — see #37.
Changes
Behavior matrix
Test plan
Out of scope
Roadmap
🤖 Generated with Claude Code
Summary by CodeRabbit