Auto-redeem resolved Polymarket positions back to USDC.
The #1 most-requested feature in the Polymarket ecosystem -- 56 comments across 2 issues on py-clob-client, and still no official solution:
This bot solves it. One script. No dependencies on py-clob-client. Just direct on-chain redemption.
- Fetches all your positions from the Polymarket data API
- Checks each position's condition on-chain to see if it's resolved (payoutDenominator > 0)
- For resolved positions with a remaining token balance, calls
redeemPositionson the Conditional Tokens Framework contract - Executes the redemption through your Gnosis Safe proxy wallet (the same pattern Polymarket uses internally)
- Reports USDC balance before and after
git clone https://github.com/LuciferForge/polymarket-settlement-bot.git
cd polymarket-settlement-bot
pip install -r requirements.txtSet your environment variables:
export POLY_PROXY_ADDRESS="0xYourPolymarketProxyAddress"
export POLY_PRIVATE_KEY="your_private_key_hex"Run once:
python3 redeem.pyRun continuously (checks every 5 minutes):
python3 redeem.py --monitorAll configuration is through environment variables. No hardcoded secrets.
| Variable | Required | Default | Description |
|---|---|---|---|
POLY_PROXY_ADDRESS |
Yes | -- | Your Polymarket proxy wallet address (Gnosis Safe) |
POLY_PRIVATE_KEY |
Yes | -- | Private key of the EOA that owns the proxy |
POLYGON_RPC_URL |
No | https://polygon-rpc.com |
Polygon RPC endpoint |
POLL_INTERVAL |
No | 300 |
Seconds between checks in monitor mode |
Polymarket uses Gnosis Safe proxy wallets for all users. When you trade on Polymarket, your positions are held in conditional tokens (ERC-1155) inside this proxy wallet. When a market resolves, the conditional tokens can be redeemed for USDC -- but there's no "claim" button in the API.
The redemption flow:
-
Find resolved positions: Query the Polymarket data API for your positions, then check each condition's
payoutDenominatoron the CTF contract. If it's greater than 0, the market has resolved. -
Build the redemption call: The CTF contract's
redeemPositionsfunction takes the collateral token (USDC), a parent collection ID (zero for root markets), the condition ID, and index sets ([1, 2]for binary YES/NO markets). -
Execute through the Safe: Since your tokens live in a Gnosis Safe proxy, you can't call
redeemPositionsdirectly. Instead:- Get the Safe's internal nonce
- Build the
redeemPositionscalldata - Get the Safe's transaction hash via
getTransactionHash - Sign that hash with your EOA private key
- Submit the signed transaction via
execTransaction
-
Verify: Check USDC balance before and after to confirm the redemption worked.
- Python 3.8+
- web3
- requests
- eth-abi
- eth-keys
| Contract | Address |
|---|---|
| Conditional Tokens Framework (CTF) | 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 |
| USDC (PoS) | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
MIT -- see LICENSE.
Copyright 2026 LuciferForge.