Skip to content

haotianli24/LevM

Repository files navigation

LevM - Leverage Trading on Polymarket

A platform for leveraged trading on Polymarket prediction markets with SOL bridging to Polygon.

Features

  • Connect Polymarket account to view positions
  • Bridge SOL from Solana to USDC on Polygon
  • Analyze Polymarket markets with PLV scoring
  • View real-time market data from Polymarket Gamma API
  • Track your positions and portfolio

Setup

Prerequisites

  • Node.js 18+ installed
  • A Polymarket API key

Installation

  1. Install dependencies:
npm install
  1. Create .env.local file in the project root:
POLYMARKET_API_KEY=your_api_key_here
# Optional: Custom Solana RPC endpoint (recommended for production)
# NEXT_PUBLIC_SOLANA_RPC_URL=https://api.devnet.solana.com
# For mainnet, use a service like Helius, QuickNode, or Alchemy
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000

Architecture

Backend API Routes

  • /api/polymarket/parse-url - Parse Polymarket URLs
  • /api/polymarket/market - Fetch individual market data
  • /api/polymarket/markets - List active markets
  • /api/polymarket/positions - Fetch user positions from CLOB
  • /api/bridge/quote - Get bridge quote for SOL to Polygon
  • /api/bridge/sol-to-polygon - Initiate bridge transaction

Frontend Features

  • Markets Page: Browse and analyze active Polymarket markets
  • Portfolio Page: View your Polymarket positions
  • Settings Page: Bridge SOL to Polygon for trading

PLV Score Calculation

PLV (Price, Liquidity, Volume) score is calculated using:

  • Price Score (30%): Based on distance from 0.5 (more directional = higher score)
  • Volume Score (30%): Normalized to $1M cap
  • Liquidity Score (40%): Normalized to $100k cap

Formula:

priceScore = min(|price - 0.5| * 2 * 100, 100)
volumeScore = min((volume / 1,000,000) * 100, 100)
liquidityScore = min((liquidity / 100,000) * 100, 100)
plvScore = round(priceScore * 0.3 + volumeScore * 0.3 + liquidityScore * 0.4)

Bridge Flow

  1. User enters SOL amount to deposit
  2. System fetches real-time bridge quote from Wormhole
  3. User signs Solana transaction in wallet
  4. Transaction submitted to Wormhole guardian network
  5. VAA attestation generated (10-15 minutes)
  6. USDC redeemable on Polygon for Polymarket trading

See BRIDGE_IMPLEMENTATION.md for technical details.

Tech Stack

  • Next.js 16 (App Router)
  • React 19
  • TypeScript
  • Solana Wallet Adapter
  • Polymarket Gamma API
  • TailwindCSS
  • shadcn/ui components

License

MIT

About

Leveraging prediction markets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors