SkillPedia Skills Encyclopedia
中文 EN

技能 2026-04-28 09:30 UTC

polyclaw

由提交人 smypmsa 提交,主要更新类型为:问题缺陷修复与稳定性提升。提交说明:Add 'polyclaw redeem' to claim collateral on resolved positions (#10)。解决了已知运行时异常与边界错误,提升系统稳定性。

smypmsa 1f5a8ab chainstacklabs/polyclaw

Commit提交信息原文

Add 'polyclaw redeem' to claim collateral on resolved positions (#10)

* Add 'polyclaw redeem' to claim collateral on resolved positions

Positions opened via direct contract calls (split + CLOB sell) don't
appear in the polymarket.com UI, so users have no in-UI way to claim
winnings after a market resolves. This adds an explicit redeem flow.

Subcommands:
- redeem list           — show resolved positions awaiting redemption,
                          including which side won and an estimated
                          payout from payoutNumerators/payoutDenominator
- redeem <position_id>  — claim one position
- redeem all            — sweep every redeemable position

The flow per position:
1. Backfill condition_id from Gamma if the position was written before
   #9 (the prep PR)
2. Read payoutDenominator on the CTF; skip if 0 (not resolved)
3. Read payoutNumerators[outcome_index] for this side; skip if 0
   (losing side — calling redeemPositions would still work but return
   nothing; we surface the skip explicitly so users aren't surprised)
4. Build redeemPositions(pUSD, 0x00..00, conditionId, [indexSet]) where
   indexSet = 1 for YES, 2 for NO (matching the splitPosition partition)
5. Persist redeem_tx and flip status to "resolved"

Also surfaces the redemption hint in `positions list` ("N resolved
position(s) pending redemption — run `polyclaw redeem list`") so users
notice without polling redeem list manually.

Closes #4
Closes #2

* Address review feedback on #10

- Route diagnostic prints in cmd_list to stderr so --json output stays
  parseable (CHAINSTACK_NODE error, market-fetch failures, CTF query
  failures all go to stderr; --json with no candidates emits [])
- Note the binary-market assumption next to SIDE_TO_OUTCOME_INDEX
- Drop the '#4' reference from set_condition_id docstring