Skip to content

feat(smart-money): 接受 V1 routers + V2 exchanges in mempool filter (Plan 11 §6) - #31

Merged
cyl19970726 merged 1 commit into
copy-tradingfrom
feat/plan11-smart-money-v2
May 5, 2026
Merged

cyl19970726 merged 1 commit into
copy-tradingfrom
feat/plan11-smart-money-v2

Conversation

@cyl19970726

Copy link
Copy Markdown
Owner

背景

V2 cutover 后,smart-money mempool monitor 仍仅接受 V1 ROUTER_ADDRESSES + V1 `MATCH_ORDERS_SELECTOR` (`0x2287e350`),导致所有 V2 settlement TX (走 V2 CTF Exchange direct, selector `0x3c2b4399`) 被滤掉。

参考: `earning-engine/.claude/skills/guide-polymarket-v2-migration/plans/11-safety-hardening.md` §6, p0-fix-log P0-11

修改方案

`smart-money/monitor.ts`:

  • 扩展 `SETTLEMENT_RECIPIENTS`: V1 routers + V2 CTF Exchange (`0xE111180000d2663C0091e4f400237545B87B996B`) + V2 NegRisk Exchange (`0xe2222d279d744050d28e00520010520000310F59`)
  • 双 selector 检查: V1 `0x2287e350` + V2 `0x3c2b4399`
  • 通过 `MATCH_ORDERS_SELECTOR_V1` / `MATCH_ORDERS_SELECTOR_V2` 从 `utils/calldata-decoder` re-export
  • index.ts 顶层导出新 selector 名

数据流

修改后:
```
mempool tx → smart-money/monitor.ts.processTx()
├── recipient ∈ {V1 routers, V2 CTF Exchange, V2 NegRisk Exchange} ?
│ └── if no → 跳过 (filter)
├── selector ∈ {V1 0x2287e350, V2 0x3c2b4399} ?
│ └── if no → 跳过
└── decodeMatchOrdersCalldata() 自动 V2-first / V1-fallback (已在 PR #29 实施)
```

测试

新单元测试 `v2-smart-money-monitor-filter.test.ts` (6 cases): V2 CTF Exchange + V2 NegRisk Exchange + V1 router-legacy paths + EOA/non-matchOrders rejection 都覆盖。

156/156 tests pass, tsc clean。

风险与回滚

低风险:仅扩大允许集 (V2 settlement 之前被滤掉,现在被接受)。回滚 = revert 单 commit。

🤖 Generated with Claude Code

…er (Plan 11 §6)

Earning-engine plan 11 batch 2 §6 — extend TradeMonitor mempool filter to
recognize V2 settlement TXs (post-2026-04-28 cutover).

Changes:
- monitor.ts: add SETTLEMENT_RECIPIENTS = V1 routers + V2 CTF Exchange +
  V2 NegRisk Exchange. Replace ROUTER_ADDRESSES + MATCH_ORDERS_SELECTOR
  (V1-only) with SETTLEMENT_RECIPIENTS + hasMatchOrdersSelector helper
  that accepts both V1 (0x2287e350) and V2 (0x3c2b4399) selectors.
- index.ts: re-export MATCH_ORDERS_SELECTOR_V1 / _V2 + the V1/V2-specific
  decoder entry points so consumers (earning-engine copy-trading) can
  filter without reaching into utils/.
- new test: v2-smart-money-monitor-filter.test.ts — 6 cases covering
  V2 calldata @ V2 CTF Exchange, V2 calldata @ V2 NegRisk Exchange,
  V1 calldata @ V1 router (legacy mempool tail), and rejection paths
  (random EOA recipient, non-matchOrders selector).

V1 path remains live for the cutover overlap window — pre-cutover TXs may
still be mempool-pending when V2 goes live; we don't want to silently drop
them while the historical-replay analytics catch up.

Test: 6/6 new + 156/156 full poly-sdk suite pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cyl19970726
cyl19970726 merged commit 31059df into copy-trading May 5, 2026
1 of 2 checks passed
@cyl19970726
cyl19970726 deleted the feat/plan11-smart-money-v2 branch May 5, 2026 15:49
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