Skip to content

kapesgit/bagsbet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BagsMarket

BagsMarket

Prediction markets for every token launch on Bags.fm

Auto-generated PUMP/DUMP markets. Bet with SOL. Win if you're right.

Live AppHow It WorksFeaturesTech StackQuick StartRoadmap


The Problem

Bags.fm launches hundreds of tokens daily. Traders speculate on them but there's no structured way to put conviction behind a prediction. You either buy the token or sit on the sidelines.

The Solution

BagsMarket auto-generates prediction markets from every Bags.fm token launch. A new token launches, PUMP and DUMP markets appear instantly with dynamic targets based on current market cap, and anyone can bet YES or NO.

Think Polymarket, but for Bags.fm token launches on Solana.


Architecture

graph TB
    subgraph User["User Flow"]
        REG[Sign Up / Login]
        DEP[Deposit SOL]
        BET[Place YES/NO Bet]
        WIN[Collect Winnings]
        WD[Withdraw SOL]
    end

    subgraph Engine["BagsMarket Engine"]
        GEN["Market Generator\n(every 10 min)"]
        RES["Market Resolver\n(every 1 min)"]
        CLEAN["Cleanup\n(every 30 min)"]
    end

    subgraph Oracle["4-Tier Price Oracle"]
        DS[DexScreener]
        BAGS[Bags.fm API]
        HEL[Helius DAS]
        JUP[Jupiter]
    end

    subgraph Data["Backend"]
        API[Express API]
        AUTH[JWT Auth]
        CRYPT[AES-256-GCM\nWallet Encryption]
        DB[(SQLite WAL)]
    end

    REG --> AUTH
    DEP --> CRYPT
    BET --> API
    API --> DB
    GEN -->|Scan Bags.fm +\nDexScreener Trending| DB
    RES -->|Check prices| Oracle
    DS -->|Primary| RES
    BAGS -->|Fallback 1| RES
    HEL -->|Fallback 2| RES
    JUP -->|Fallback 3| RES
    RES -->|Resolve + Payout| DB
    DB --> WIN
    WIN --> WD

    style REG fill:#f59e0b,color:#000
    style DEP fill:#f59e0b,color:#000
    style BET fill:#22c55e,color:#000
    style WIN fill:#22c55e,color:#000
    style WD fill:#f59e0b,color:#000
    style DS fill:#1a1a2e,color:#fff
    style BAGS fill:#ff6b35,color:#fff
    style HEL fill:#9945FF,color:#fff
    style JUP fill:#9945FF,color:#fff
    style API fill:#0984e3,color:#fff
    style DB fill:#636e72,color:#fff
Loading

How It Works

  1. Markets auto-generate — Every 10 minutes, the engine scans Bags.fm new launches + DexScreener trending tokens. Live tokens (>$8K mcap) get PUMP and DUMP markets with dynamic targets.

  2. Users bet — Sign up, deposit SOL to your custodial wallet, pick a market, choose YES or NO. Odds shift in real-time based on the pool.

  3. Oracle resolves — When the deadline hits, a 4-tier price oracle (DexScreener > Bags API > Helius > Jupiter) checks the actual market cap. Winners split the pool (minus 2% platform fee).


Features

Feature Description
Auto-Generated Markets PUMP/DUMP markets created from Bags.fm feed + DexScreener trending
4-Tier Price Oracle DexScreener, Bags API, Helius DAS, Jupiter — cascading fallback
Dynamic Targets Targets scale with mcap and timeframe (10m to 24h)
Custodial Wallets No wallet connection needed. Sign up, deposit, bet
AES-256-GCM Encryption All private keys encrypted at rest
Parimutuel Betting Peer-to-peer pools with 2% platform fee
Real-Time Resolution Resolver checks every 60 seconds
Leaderboard Top predictors ranked by profit
Portfolio Full bet history, payouts, and P&L
Glassmorphism UI Premium dark design, mobile-optimized

Tech Stack

Layer Tech
Frontend React 18, Vite 5, Tailwind CSS, TypeScript
Backend Node.js, Express, TypeScript
Database SQLite (WAL mode, better-sqlite3)
Auth JWT + bcrypt
Encryption AES-256-GCM (custodial wallet keys)
Price Feeds DexScreener, Bags.fm API, Helius DAS, Jupiter
Blockchain Solana (web3.js)
Process PM2, Nginx, Certbot SSL

Quick Start

Prerequisites: Node.js 20+, a Bags.fm API key

Clone the repo, install deps, copy .env.example to .env, add your API keys, then run with npm run dev. Frontend lives in /frontend — install and build separately.


API

Method Endpoint Description
POST /api/auth/register Sign up (username + password)
POST /api/auth/login Log in (returns JWT)
GET /api/auth/me Current user info
GET /api/wallet/deposit Deposit address + balances
POST /api/wallet/sync Sweep on-chain SOL to balance
POST /api/wallet/withdraw Withdraw to any Solana address
GET /api/markets All open markets
GET /api/markets/:id Single market + bets
GET /api/markets/resolved Resolved markets
POST /api/bet Place a bet (auth required)
GET /api/portfolio User bet history (auth required)
GET /api/leaderboard Top predictors

Roadmap

  • Auto-generated PUMP/DUMP markets
  • 4-tier price oracle (DexScreener > Bags > Helius > Jupiter)
  • Dynamic targets scaled by mcap + timeframe
  • Glassmorphism frontend (mobile-optimized)
  • User auth (register/login with JWT)
  • Custodial wallets (AES-256-GCM encrypted)
  • SOL deposit, sync, and withdraw
  • Live betting with balance validation
  • Portfolio tracking
  • Leaderboard with usernames
  • $BAGSMARKET token launch on Bags.fm
  • Fee sharing via Bags API
  • X/Twitter social predictions
  • Trading bot integration
  • On-chain PDA escrow (Anchor)
  • Shareable bet cards for X
  • Community-created custom markets

Built For


License

MIT


Built by @kapesgit

About

Prediction markets that auto-generate from Bags.fm token launches. Bet on outcomes, win if you're right.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors