Skip to content

Add redeem_positions tool for claiming resolved market winnings#40

Merged
Royal-lobster merged 4 commits intomainfrom
feat/redeem-positions-tool
Jan 20, 2026
Merged

Add redeem_positions tool for claiming resolved market winnings#40
Royal-lobster merged 4 commits intomainfrom
feat/redeem-positions-tool

Conversation

@Royal-lobster
Copy link
Copy Markdown
Member

@Royal-lobster Royal-lobster commented Jan 20, 2026

Closes #39

Summary

  • Add a new redeem_positions tool to claim winnings from resolved Polymarket prediction markets
  • Support both regular CTF markets and negative risk markets via NegRiskAdapter
  • Add redemption service with balance verification, market resolution checks, and on-chain transaction execution

Changes

  • src/services/redemption.ts - New redemption service with:

    • CTF balance checking
    • Market resolution verification
    • Winning index set calculation
    • NegRiskAdapter approval checking
    • On-chain redemption transaction execution
  • src/tools/redeem-positions.ts - New MCP tool with parameters:

    • conditionId (required) - Market condition ID
    • tokenId (optional) - Position token ID, required for negRisk markets
    • outcomeIndex (optional) - 0 for Yes, 1 for No
    • negRisk (optional) - Boolean for negative risk markets

Test plan

  • Build succeeds with pnpm run build
  • Test redemption on a resolved regular market
  • Test redemption on a resolved negative risk market
  • Verify error handling for unresolved markets
  • Verify error handling for zero balance positions

🤖 Generated with Claude Code

Add a new tool to redeem (claim) winnings from resolved Polymarket
prediction markets. This enables users to collect USDC from positions
in markets that have been settled.

- Add redemption service with CTF and NegRiskAdapter support
- Add redeem_positions tool with conditionId, tokenId, outcomeIndex params
- Support both regular CTF markets and negative risk markets
- Verify market resolution and token balance before redemption

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @Royal-lobster, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial feature enabling users to redeem their winnings from settled Polymarket prediction markets. It provides a robust service to manage the complexities of on-chain redemption, ensuring that market resolution and token balances are correctly verified before transactions are executed. The new tool integrates seamlessly, offering a straightforward way to interact with both standard and negative risk market redemption processes.

Highlights

  • New Redemption Tool: A new redeem_positions tool has been added, allowing users to claim winnings from resolved Polymarket prediction markets.
  • Support for Market Types: The tool supports redemption for both regular Conditional Tokens Framework (CTF) markets and negative risk markets via the NegRiskAdapter.
  • Comprehensive Redemption Service: A dedicated redemption service (PolymarketRedemption) has been implemented, which includes functionalities for CTF balance verification, market resolution checks, calculation of winning index sets, and execution of on-chain redemption transactions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable redeem_positions tool for claiming winnings from resolved markets. The implementation is well-structured with a dedicated redemption service. My review focuses on enhancing the robustness of the error handling and improving input validation. I've identified several areas where errors are suppressed, which could lead to confusing behavior for the user. I've also highlighted a high-severity issue where a fallback mechanism could cause users to waste gas on transactions that are guaranteed to fail. Finally, I've suggested improvements to the tool's input schema to provide clearer and faster feedback. Addressing these points will make the new feature more reliable and user-friendly.

Comment thread src/services/redemption.ts Outdated
Comment thread src/services/redemption.ts Outdated
Comment thread src/services/redemption.ts Outdated
Comment thread src/services/redemption.ts Outdated
Comment thread src/tools/redeem-positions.ts Outdated
- Remove try/catch blocks that swallow errors and return misleading defaults
  in getCTFBalance, isMarketResolved, getWinningIndexSets, isNegRiskAdapterApproved
- Let errors propagate to main redeemPositions handler for accurate feedback
- Add schema validation requiring tokenId and outcomeIndex when negRisk=true
- Add default(false) to negRisk parameter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Royal-lobster Royal-lobster merged commit 6da4eed into main Jan 20, 2026
1 check passed
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.

Add logic to process claims in polymarket mcp

1 participant