- Update RPC endpoint from llamarpc to polygon-rpc.com for better reliability - Improve .env file loading to check both local and parent directory - Update README example to use proper condition_id format (0x...) instead of numeric - Clarify that condition_id should be hex format in documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Poly-Merger
A utility for merging Polymarket positions efficiently. This tool helps in consolidating opposite positions in the same market, allowing you to:
- Reduce gas costs
- Free up capital
- Simplify position management
How It Works
The merger tool interacts with Polymarket's smart contracts to combine opposite positions in binary markets. When you hold both YES and NO shares in the same market, this tool will merge them to recover your USDC.
Usage
The merger is invoked through the main Poly-Maker bot when position merging conditions are met, but you can also use it independently:
node merge.js [amount_to_merge] [condition_id] [is_neg_risk_market]
Example:
node merge.js 1000000 0xasdasda true
This would merge 1 USDC worth of opposing positions in market 0xasdasda, which is a negative risk market. 0xasdasda should be condition_id
Prerequisites
- Node.js
- ethers.js v5.x
- A .env file with your Polygon network private key
Notes
This implementation is based on open-source Polymarket code but has been optimized for automated market making operations.