https://github.com/estavadormir/polymarket-proxy-recovery
Recover funds from Polymarket proxy wallets (Magic/Google login accounts) you've lost access to
https://github.com/estavadormir/polymarket-proxy-recovery
cryptocurrency etherscan magiclink polymarket usdc
Last synced: 2 months ago
JSON representation
Recover funds from Polymarket proxy wallets (Magic/Google login accounts) you've lost access to
- Host: GitHub
- URL: https://github.com/estavadormir/polymarket-proxy-recovery
- Owner: estavadormir
- License: mit
- Created: 2026-04-01T06:23:58.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-01T06:29:41.000Z (2 months ago)
- Last Synced: 2026-04-01T09:19:45.009Z (2 months ago)
- Topics: cryptocurrency, etherscan, magiclink, polymarket, usdc
- Language: TypeScript
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# polymarket-proxy-recovery
Got locked out of your Polymarket account (the one you logged into with Google/Magic.link) and have winning positions sitting there? This repo helps you get your money back.
## What's this about?
When you sign up for Polymarket with Google or email, Magic.link creates a **proxy wallet** for you. Your actual crypto lives in that proxy wallet, not in a regular wallet you control directly. If you lose access to your Polymarket account (banned, closed, two-Google-accounts issue, whatever), your funds are stuck in that proxy wallet.
**But here's the thing** — you still own the private key that controls that proxy wallet. Magic.link lets you export it. Once you have that key, you can:
1. **Recover USDC.e** (your cash balance) via Polymarket's built-in recovery tool
2. **Redeem winning ERC-1155 positions** (resolved bets that paid out) using this script
This repo handles step 2 — redeeming winning positions that are sitting in your proxy wallet.
## How the whole recovery flow works
### Step 1: Get your private key
1. Go to [reveal.magic.link/polymarket](https://reveal.magic.link/polymarket)
2. Log in with the **same Google/email** you used on Polymarket
3. It'll show you your private key — save it somewhere safe
4. This key controls your **EOA** (Externally Owned Account), which in turn owns your proxy wallet
### Step 2: Figure out your addresses
You have TWO addresses that matter:
- **EOA address** — derived from the private key you just got. This is the "owner" of your proxy wallet. You can paste your private key into a tool like [etherscan address converter](https://etherscan.io/address/) or just run this script and it'll print it.
- **Proxy wallet address** — this is where your Polymarket positions and USDC.e actually live. You can find it on [polygonscan](https://polygonscan.com) by looking at your EOA's transaction history, or check your Polymarket profile URL.
### Step 3: Recover your USDC.e balance
If you have USDC.e sitting in your proxy wallet:
1. Go to [matic-recovery.polymarket.com](https://matic-recovery.polymarket.com)
2. Connect with the private key from Step 1
3. Follow the prompts — it'll transfer your USDC.e to your EOA
4. From there you can send it wherever you want
### Step 4: Redeem winning positions (this script)
If you have **resolved, winning** ERC-1155 positions (bets that already settled in your favor), those tokens are still sitting in your proxy wallet. The recovery site doesn't handle these — you need to call `redeemPositions` on the CTF contract through the relayer.
That's what `redeem-proxy.ts` does.
## Prerequisites
- [Bun](https://bun.sh) runtime installed (`curl -fsSL https://bun.sh/install | bash`)
- Your Magic.link private key (Step 1 above)
- Builder API credentials from [polymarket.com/settings?tab=builder](https://polymarket.com/settings?tab=builder)
- The **condition ID** of the market you want to redeem (more on this below)
## Setup
```bash
# Clone the repo
git clone https://github.com/YOUR_USERNAME/polymarket-proxy-recovery.git
cd polymarket-proxy-recovery
# Install dependencies
bun install
# Copy the example env and fill in your values
cp .env.example .env
```
Edit `.env` with your actual values (see `.env.example` for descriptions of each variable).
## Usage
```bash
bun run redeem-proxy.ts
```
The script will:
1. Load your config from `.env`
2. Build the `redeemPositions` calldata
3. Send it through the Polymarket relayer as a PROXY transaction
4. Wait for the transaction to be mined
5. Print the transaction hash and Polygonscan link
Your USDC.e payout lands in your **proxy wallet**. From there, use the [recovery site](https://matic-recovery.polymarket.com) to move it to your EOA.
## How to find your Condition ID
The condition ID identifies which market you're redeeming. You can find it:
- **From the Polymarket subgraph** — query your proxy wallet's positions
- **From Polygonscan** — look at the ERC-1155 tokens held by your proxy wallet address, then trace back to the market
- **From the market page URL** — some tools map slugs to condition IDs
The condition ID is a `bytes32` value (0x + 64 hex chars), like:
```
0x45ad8b8e5d5df8721e5d0d12f7aef50d3f715702bf2ce2c0d04575d47411fc93
```
## Important gotchas
### Index Sets — pick the right side!
- `INDEX_SETS=1` → redeems the **Yes / Up** side
- `INDEX_SETS=2` → redeems the **No / Down** side
**You MUST only redeem the winning side.** If you try to redeem the losing side, the transaction will succeed but you'll get `payout = 0`. The contract doesn't revert — it just gives you nothing. So double-check which side won before running.
### The two-Google-accounts problem
Some people accidentally created two Polymarket accounts with different Google accounts (personal vs work, etc). Make sure you're revealing the private key for the **correct** Google account — the one that actually has the positions.
### Builder credentials
You need Builder API credentials even though your account might be closed. If you can still access [polymarket.com/settings?tab=builder](https://polymarket.com/settings?tab=builder), grab them from there. If you can't access the settings page at all, you might need to reach out to Polymarket support.
### Payout goes to the proxy wallet
When you redeem, the USDC.e lands in your **proxy wallet**, not your EOA. You'll need to use the [recovery site](https://matic-recovery.polymarket.com) one more time to sweep it out.
### Gas
The relayer covers gas fees for proxy transactions, so you don't need POL/MATIC in your EOA.
## How it works under the hood
Your Polymarket proxy wallet is an [ERC-1167 minimal proxy](https://eips.ethereum.org/EIPS/eip-1167) contract. The owner (your EOA from Magic.link) can execute arbitrary calls through it via the Polymarket relayer.
This script:
1. Encodes a `redeemPositions(collateralToken, parentCollectionId, conditionId, indexSets)` call targeting the CTF contract
2. Wraps it in a proxy transaction signed by your EOA
3. Sends it to the Polymarket relayer (`relayer-v2.polymarket.com`)
4. The relayer submits it on-chain, executing through your proxy wallet
Key contracts (Polygon mainnet):
- **CTF (Conditional Tokens Framework):** `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045`
- **USDC.e (collateral):** `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174`
- **Proxy Factory:** `0xaB45c5A4B0c941a2F231C04C3f49182e1A254052`
- **RelayHub:** `0xD216153c06E857cD7f72665E0aF1d7D82172F494`
## Running tests
```bash
bun test
```
## License
MIT