immortal-bnb/POLYMARKET_QUICKSTART.md
Claude 8636b46ade
security: Remove exposed API keys from documentation
Fixed GitGuardian security alert:
- Removed hardcoded OpenRouter API key from POLYMARKET_QUICKSTART.md
- Replaced with placeholder: sk-or-v1-YOUR_API_KEY_HERE
- Also removed test wallet private key
- Added instructions to generate own keys
- .env file is properly gitignored (not committed)

Users should:
1. Get their own OpenRouter API key from https://openrouter.ai/
2. Generate their own wallet private key
3. Add to .env file (never commit .env)
2025-11-09 19:41:06 +00:00

10 KiB

๐Ÿš€ Polymarket Quick Start Guide

Get started with Polymarket prediction market trading in 10 minutes.


โšก Super Quick Start (3 Commands)

# 1. Get testnet MATIC (takes 2 min)
# Visit: https://faucet.polygon.technology/
# Enter your address: 0xa5A4781aB598E841dc31F8437a3fef82278a0ee5

# 2. Run the live demo
npm run polymarket:demo

# 3. That's it! You're trading on Polymarket ๐ŸŽ‰

๐Ÿ“‹ Prerequisites (Already Done!)

โœ… Polymarket CLOB Client - Installed โœ… Multi-Chain Wallet - Configured โœ… Polygon Network - Set up โœ… AI Analysis - Ready (OpenRouter)

Your Wallet Address: 0xa5A4781aB598E841dc31F8437a3fef82278a0ee5


๐ŸŽฏ Step-by-Step Guide

Step 1: Get Polygon Testnet Tokens

MATIC (for gas fees):

  1. Visit: https://faucet.polygon.technology/
  2. Select "Mumbai Testnet"
  3. Paste address: 0xa5A4781aB598E841dc31F8437a3fef82278a0ee5
  4. Request 0.5 MATIC
  5. Wait 1-2 minutes

USDC (for trading) - OPTIONAL for demo:

  1. Visit: https://faucet.circle.com/
  2. Select "Polygon Mumbai"
  3. Request test USDC
  4. OR bridge from another testnet

Note: The demo works even without USDC - it will show you markets and let you analyze them!


Step 2: Run the Live Demo

npm run polymarket:demo

What the demo does:

  1. โœ… Checks your MATIC and USDC balances
  2. โœ… Fetches top 10 trending markets from Polymarket
  3. โœ… Analyzes the #1 market with AI
  4. โœ… Shows orderbook (bid/ask/spread)
  5. โœ… Displays your open positions
  6. โœ… Lists your active orders

Expected Output:

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     POLYMARKET LIVE END-TO-END TRADING DEMO            โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘   STEP 1: CHECK WALLET BALANCES        โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ’Ž MATIC Balance: 0.5000 MATIC
๐Ÿ’ต USDC Balance: $0.00 USDC

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘   STEP 2: DISCOVER TRENDING MARKETS    โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ” Fetching active markets from Polymarket...
โœ… Found 10 active markets

๐Ÿ“Š Top 10 Markets by Volume:

1. Will Donald Trump win the 2024 election?
   Volume: $50,234,567
   Market ID: 0x123...

2. Will Bitcoin reach $100,000 by end of 2024?
   Volume: $12,456,789
   Market ID: 0x456...

... and more ...

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘   STEP 3: AI MARKET ANALYSIS           โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿค– Analyzing: Will Donald Trump win the 2024 election?

๐Ÿ“ˆ Market Data:
   Best Bid: 52.3%
   Best Ask: 52.8%
   Mid Price: 52.6%
   Spread: 0.50%
   Volume: $50,234,567

๐Ÿง  Running AI Analysis...

๐Ÿ’ก AI Analysis:
The market is highly liquid with a tight spread, suggesting efficient pricing.
The current probability of 52.6% reflects a very close race with high uncertainty.
I would recommend staying neutral and waiting for clearer signals.

โœ… DEMO COMPLETE

Step 3: Place Your First Order (Optional)

If you have USDC, you can place real orders!

Modify the demo script:

// Add after Step 3 in polymarket-live-demo.ts

// Approve USDC (one-time setup)
await demo.approveUSDC('100'); // Approve $100 USDC

// Place a buy order
await demo.placeLimitOrder(
  topMarket.condition_id,
  'BUY',
  0.50, // Buy at 50% probability
  10    // $10 USDC size
);

// Check your order
await demo.getOpenOrders();

Then run:

npm run polymarket:demo

๐Ÿ“š Advanced Usage

Analyze Specific Markets

import { PolymarketLiveDemo } from './polymarket-live-demo';

const demo = new PolymarketLiveDemo(process.env.WALLET_PRIVATE_KEY!);

// Get all markets
const markets = await demo.discoverMarkets();

// Analyze each one
for (const market of markets) {
  const analysis = await demo.analyzeMarket(market);
  console.log(analysis);
}

Automated Trading Loop

// Run analysis every 5 minutes
setInterval(async () => {
  const markets = await demo.discoverMarkets();
  const analysis = await demo.analyzeMarket(markets[0]);

  // If AI confidence > 80%, place order
  if (analysis.aiAnalysis.includes('strong buy')) {
    await demo.placeLimitOrder(
      markets[0].condition_id,
      'BUY',
      analysis.bestAsk,
      10
    );
  }
}, 5 * 60 * 1000);

Monitor Positions

// Check positions every minute
setInterval(async () => {
  await demo.viewPositions();
  await demo.getOpenOrders();
}, 60 * 1000);

๐Ÿ”ง Configuration

All settings are in .env:

# Enable/disable Polymarket
POLYMARKET_ENABLED=true

# Polymarket API
POLYMARKET_HOST=https://clob.polymarket.com
POLYMARKET_CHAIN_ID=137  # 137 = Polygon Mainnet, 80001 = Mumbai Testnet

# Polygon RPC
POLYGON_RPC=https://polygon-rpc.com

# Your wallet (generate your own!)
WALLET_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE

# AI Analysis (get your own from https://openrouter.ai/)
OPENROUTER_API_KEY=sk-or-v1-YOUR_API_KEY_HERE

๐Ÿ’ฐ Cost Estimate

Testnet (FREE!)

Action Gas (MATIC) Cost
Approve USDC ~0.0001 $0.00
Place Order ~0.0003 $0.00
Cancel Order ~0.00006 $0.00

Total: All testnet tokens are free!

Mainnet (Real Money)

Action Gas (MATIC) USD Cost
Approve USDC ~0.0001 ~$0.00009
Place Order ~0.0003 ~$0.00027
Cancel Order ~0.00006 ~$0.00005

Note: Polygon is 1000x cheaper than Ethereum!


๐ŸŽฏ Common Use Cases

1. Market Sentiment Analysis

# Run demo to see what markets are trending
npm run polymarket:demo

# AI will tell you if markets are fairly priced

2. Find Mispriced Markets

# The AI analyzer detects mispricing
# Look for markets where AI confidence is high but spread is wide

3. Hedge Crypto Positions

# If you're long BTC on DEX, hedge with:
# "Will Bitcoin crash?" prediction market

4. Event Arbitrage

# Find related markets with price discrepancies
# Example: "BTC > $100k" should be โ‰ค "BTC > $95k"

๐Ÿ› Troubleshooting

"Insufficient MATIC for gas"

Solution:

# Get more MATIC from faucet
Visit: https://faucet.polygon.technology/
Address: 0xa5A4781aB598E841dc31F8437a3fef82278a0ee5

"No markets found"

Solution:

# Check internet connection
# Try different RPC endpoint in .env:
POLYGON_RPC=https://rpc-mainnet.maticvigil.com

"USDC approval failed"

Solution:

# Make sure you have USDC first
# Then run approval with higher gas:
await demo.approveUSDC('100');

"AI analysis not working"

Solution:

# Check OpenRouter API key in .env
OPENROUTER_API_KEY=sk-or-v1-YOUR_KEY_HERE

# Verify it's correct:
echo $OPENROUTER_API_KEY

๐Ÿ“Š What Each File Does

File Purpose
polymarket-live-demo.ts Main demo script - Run this!
test-polymarket.ts Test suite - Verify integration
src/polymarket/polymarketClient.ts Core client - Low-level API
src/polymarket/marketDataFetcher.ts Market discovery - Find opportunities
src/polymarket/aiPredictionAnalyzer.ts AI analysis - Smart decisions
src/polymarket/crossPlatformStrategy.ts Multi-chain trading - Advanced strategies
src/blockchain/multiChainWalletManager.ts Wallet management - Handle 3 chains

๐ŸŽ“ Learning Path

Day 1: Setup & Explore

  1. โœ… Get testnet MATIC
  2. โœ… Run npm run polymarket:demo
  3. โœ… Explore trending markets
  4. โœ… Understand AI analysis

Day 2: First Trade

  1. Get testnet USDC
  2. Approve USDC spending
  3. Place first limit order
  4. Cancel and re-place

Day 3: Analysis

  1. Analyze 10+ markets
  2. Compare AI recommendations
  3. Track your accuracy
  4. Learn patterns

Week 2: Automation

  1. Build automated scanner
  2. Set up alerts
  3. Create trading bot
  4. Monitor performance

Month 1: Advanced

  1. Cross-platform arbitrage
  2. Correlation trading
  3. Hedging strategies
  4. Risk management

๐Ÿš€ Next Steps

Immediate (Today):

# 1. Get testnet MATIC (5 min)
https://faucet.polygon.technology/

# 2. Run demo (2 min)
npm run polymarket:demo

# 3. Read the AI analysis
# Understand how it evaluates markets

This Week:

  • Get testnet USDC
  • Place first test order
  • Cancel an order
  • Track a position
  • Run automated analysis

This Month:

  • Analyze 100+ markets
  • Build trading strategy
  • Test on mainnet (small amounts)
  • Scale up gradually

๐Ÿ“– Additional Resources


โœ… Quick Checklist

Before running the demo:

  • Polymarket client installed
  • Wallet configured in .env
  • OpenRouter API key set
  • Get testnet MATIC โ† Do this now!
  • Run npm run polymarket:demo

๐ŸŽ‰ You're Ready!

Everything is set up. Just get testnet MATIC and run:

npm run polymarket:demo

Welcome to prediction market trading! ๐ŸŽฏ


Questions?

  • Check POLYMARKET_INTEGRATION.md for detailed docs
  • Run npm run test:polymarket to test all features
  • Review example code in polymarket-live-demo.ts

Happy Trading! ๐Ÿš€