PredictFun Market Maker

repository·main·Indexed 41 days ago

https://github.com/ccjingeth/predict-fun-marketmaker

An automated market maker bot for Predict.fun and Polymarket designed to earn Maker Rebate points. It features a dynamic tiering strategy to minimize fill risk, supporting both a desktop application and a CLI. Version 3.1.0 includes a unified strategy with Tier 2 priority, orderbook filtering, and risk control modes (Conservative and Aggressive) to balance point accumulation against trading risk.

Tokens
43.1K
Snippets
122
Records
171
Agent score
50%

What's inside PredictFun Market Maker

  1. Understand the Market Recommendation V2 Algorithm

    main

    The Market Recommendation V2 algorithm evaluates Predict.fun markets to suggest optimal market-making opportunities. It focuses on 'Points Capital Efficiency' to ensure that the capital required to place orders (determined by min_shares) yields sufficient buffer space (cents) for points accumulation.

    Core Scoring Components

    1. Points Capital Efficiency (Core): Measures how much buffer space is gained per 1000 shares invested.

      • Formula: pointsEfficiency = (bufferPerSide / min_shares) * 1000
      • Scoring: score += Math.min(20, Math.floor(pointsEfficiency * 2))
    2. min_shares Threshold: Rewards markets with lower capital requirements.

      • <= 50: +15 points
      • <= 100: +10 points
      • <= 200: +5 points
      • > 200: -5 points
    3. Buffer Utilization (Order Book Crowding): Measures bookSpread / maxSpread.

      • < 30%: +10 points (Loose book, easy to place orders)
      • 30-70%: 0 points (Normal)
      • > 70%: -5 points (Crowded book, difficult to place orders)
    4. max_spread Reward: Rewards wider spreads for higher profit potential.

      • >= 8c: +8 points
      • >= 6c: +5 points
      • < 6c: 0 points
    5. Liquidity (24h Volume):

      • > $50K: +15 points
      • > $20K: +12 points
      • > $10K: +8 points
      • > $2K: +4 points
      • > $500: +1 point
      • <= $500: -10 points (Warning)
    6. Time Risk (Expiration):

      • > 30 days: +8 points
      • 14-30 days: +10 points (Optimal)
      • 7-14 days: +5 points
      • 3-7 days: +2 points (Warning)
      • 1-3 days: -10 points (Critical)
      • < 1 day: -30 points (Extreme Risk)
    7. Price Quality (Mid-price):

      • 0.1 - 0.9: +3 points
      • < 0.05 or > 0.95: -5 points (High risk)
    8. Polymarket Daily Rate:

      • > $0.05: +8 points
      • > $0.01: +4 points
      • > 0: +2 points
    // Points Efficiency Calculation Example
    // Market A: buffer=3c, min_shares=50
    // efficiency = (3 / 50) * 1000 = 60
    // score += Math.min(20, Math.floor(60 * 2)) -> +12 points
    
    // Market B: buffer=3c, min_shares=500
    // efficiency = (3 / 500) * 1000 = 6
    // score += Math.min(20, Math.floor(6 * 2)) -> +1 point
  2. How the dynamic tiering strategy works

    main

    To avoid being 'eaten' (filled by takers) while still earning Maker Rebate points, the tool does not place orders at the Best Bid/Offer (BBO). Instead, it places orders at the $N^{th}$ tier of the order book.

    Example (Conservative Mode - 4th Tier): If the BBO (1st tier) is at 51.5c (ask) and 47.5c (bid), the tool will place orders at the 4th tier (e.g., 50.0c ask and 49.0c bid). The 2-3 layers of orders in front of yours act as a buffer. As long as those layers aren't exhausted, your order remains on the book, earning points without being filled.

  3. Unified Market Making Strategy Overview

    main

    The Lite version uses a unified strategy designed to optimize liquidity and minimize risk. By default, the following settings are enabled:

    • ENABLE_TRADING=true
    • AUTO_CONFIRM=true
    • UNIFIED_STRATEGY_ENABLED=true

    Core Strategy Features:

    • Tier 2 Priority (二档优先): Places orders at safer levels to avoid being immediately hit at Tier 1.
    • Orderbook Filtering (盘口筛选): Prioritizes markets with better liquidity and sufficient Tier 2 capacity.
    • Risk Control (风险控制): Automatically cancels orders or shrinks positions during abnormal volatility or high execution risk.
    • Graceful Shutdown (优雅停止): Automatically cancels all active orders when market making is stopped.
  4. Understand Market Making Trading Modes

    main

    The tool uses two primary modes to balance between earning Maker Rebates (points) and the risk of being 'hit' (having orders filled by takers):

    1. Conservative Mode (MM_TRADING_MODE=conservative):

      • Places orders at the 4th level of the order book (away from the Best Bid/Offer).
      • Minimizes the risk of being filled.
      • Best for users focused purely on earning points without significant trading risk.
    2. Aggressive Mode (MM_TRADING_MODE=aggressive):

      • Places orders at the 3rd level of the order book (closer to the BBO).
      • Higher potential for points, but higher risk of orders being filled.
      • Best for users who want more points and can tolerate occasional fills.
  5. Quickstart guide for PredictFun Market Maker

    main

    To start using the PredictFun Market Maker desktop application, follow these steps:

    1. Launch the application: Double-click the application file for your platform.
    2. Configure parameters: Click on 【配置参数】 (Configure Parameters) in the top bar and enter your API Key and Private Key.
    3. Start market making: Click the 【启动做市商】 (Start Market Maker) button.
  6. Install and prepare PredictFun Market Maker

    main

    To set up the environment, ensure you have the following prerequisites installed:

    • Node.js (version 18 or higher recommended)
    • Python3 (required if using Dependency Arbitrage / Opinion)

    Follow these steps to initialize the project:

    1. Navigate to the project directory.
    2. Run the installation command to install dependencies.

    If you plan to use Dependency Arbitrage, you must also install ortools via pip.

    # Install Node dependencies
    npm install
    
    # Install Python dependency for advanced arbitrage
    pip install ortools
  7. Install PredictFun Market Maker Desktop App

    main

    Download the appropriate installation package from the GitHub Releases page based on your operating system:

    SystemFileInstallation
    Mac (M-series)PredictFun.Market.Maker-x.x.x-arm64.dmgDouble-click and drag to Applications
    Mac (Intel)PredictFun.Market.Maker-x.x.x-x64.dmgDouble-click and drag to Applications
    WindowsPredictFun.Market.Maker-x.x.x-x64.exeRun the executable (portable version)
    Linux (Debian/Ubuntu)PredictFun.Market.Maker-x.x.x-amd64.debsudo dpkg -i *.deb && sudo apt-get install -f
    Linux (Universal)PredictFun.Market.Maker-x.x.x-x86_64.AppImagechmod +x *.AppImage && ./*.AppImage
    Linux (ARM)PredictFun.Market.Maker-x.x.x-arm64.AppImagechmod +x *.AppImage && ./*.AppImage

    Security Note: Since the app is not digitally signed, your system may block it initially:

    • Mac: Go to System Settings → Privacy & Security → General → Click "Allow Anyway", or run xattr -cr /Applications/PredictFun\ Market\ Maker.app in the terminal.
    • Windows: Click "More info" → "Run anyway".
    • Linux AppImage: Ensure libfuse2 is installed: sudo apt install libfuse2.
    sudo dpkg -i *.deb && sudo apt-get install -f
  8. Use the CLI for Advanced Market Making

    main

    Advanced users can run the market maker via the command line. Navigate to lite-release/predict-fun-market-maker-lite and follow these steps:

    # 1. Install dependencies
    npm install
    
    # 2. Apply a template
    npm run template:predict    # or template:polymarket
    
    # 3. Edit .env with required fields (API_KEY, PRIVATE_KEY, etc.)
    
    # 4. Get JWT (Predict only)
    npm run auth:jwt
    
    # 5. Authorize contract (Predict first-time only)
    npm run setup:approvals
    
    # 6. Scan recommended markets
    npm run market:recommend -- --venue predict --top 10
    
    # 7. Recommend and automatically apply markets
    npm run market:apply -- --venue predict --top 10
    
    # 8. Start market making
    npm run start:mm
    # 1. Install dependencies
    npm install
    
    # 2. Apply a template
    npm run template:predict    # or template:polymarket
    
    # 3. Edit .env with required fields (API_KEY, PRIVATE_KEY, etc.)
    
    # 4. Get JWT (Predict only)
    npm run auth:jwt
    
    # 5. Authorize contract (Predict first-time only)
    npm run setup:approvals
    
    # 6. Scan recommended markets
    npm run market:recommend -- --venue predict --top 10
    
    # 7. Recommend and automatically apply markets
    npm run market:apply -- --venue predict --top 10
    
    # 8. Start market making
    npm run start:mm
  9. Run the arbitrage bot in simulation mode

    main

    Before enabling real trading, it is highly recommended to run the bot in Simulation Mode. This allows you to scan for opportunities and view logs without placing actual orders.

    Set the following in your .env:

    • ENABLE_TRADING=false
    • ARB_AUTO_EXECUTE=false

    Start the bot using: npm run start:arb

    # Ensure .env has ENABLE_TRADING=false
    npm run start:arb
  10. How to start market making in the Desktop App

    main

    Follow these steps to begin automated market making:

    1. Configure: Complete the platform configuration (see Configure Predict.fun and Polymarket).
    2. Get JWT (Predict only): Click "获取JWT Token" (Get JWT Token). Wait for the log to show success.
    3. Select Markets: Click "自动推荐市场" (Auto-recommend markets). Review the spread, depth, and capacity for each. Click "一键应用推荐" (One-click apply recommendation) or manually select markets and click "应用手动勾选" (Apply manual selection).
    4. Start: Click "启动做市" (Start Market Making).

    To stop, click "停止做市" (Stop Market Making). This will automatically cancel all active orders before exiting.

  11. Configure Predict.fun and Polymarket in the Desktop App

    main

    After launching the App, select your platform (Predict or Polymarket) at the top and click the "套用xxx模板" (Apply Template) button. You must then fill in the following required environment variables in the editor:

    Predict.fun Required Fields:

    • API_KEY: Your API Key
    • PRIVATE_KEY: Your wallet private key (without the 0x prefix)
    • PREDICT_ACCOUNT_ADDRESS: Your account address (starting with 0x)

    Polymarket Required Fields:

    • POLYMARKET_PRIVATE_KEY: Your Polymarket private key
    • POLYMARKET_FUNDER_ADDRESS: Your Funder address

    Note: For Polymarket, it is recommended to use the "检查Polymarket预检" (Check Polymarket Pre-check) button in the App to derive the API Key automatically instead of manual entry.

    Once configured, click "保存配置" (Save Configuration).