Docs

How polymargin works: leveraged Polymarket exposure, Solana custody, and an onchain liquidity vault.

Overview

Polymargin is a trading terminal for Polymarket outcome markets. You deposit USDC on Solana as collateral and can open YES or NO positions with up to 2× or 3× leverage depending on event volume. When leverage is above 1×, the protocol borrows USDC from the Earn vault. Liquidity providers supply that vault and earn borrow interest plus a share of closing fees.

Market prices and event metadata come from Jupiter Predict (Polymarket provider). Order execution runs server-side against the Polymarket CLOB on Polygon by default. Your wallet still signs Solana deposits, withdrawals, and vault actions.

Architecture

Browser (polymargin.fi)
  │
  ├─ /trade          Browse markets, open & close positions
  ├─ /portfolio      Open positions, PnL, health
  └─ /earn           LP vault deposit / withdraw
        │
        ▼
Next.js API routes
  │
  ├─ /api/predict/*       Events, markets, price history (Jupiter Predict)
  ├─ /api/solana/open     Open leveraged position
  ├─ /api/solana/close    Close position, settle PnL
  ├─ /api/solana/quote    Size, fees, max leverage preview
  ├─ /api/solana/vault/*  LP deposits, TVL, share price
  └─ /api/solana/trading-balance/*  Optional pre-funded USDC balance
        │
        ├──────────────────────────────┐
        ▼                              ▼
Supabase (state)              Execution layer
  • vault_state                 Default: Polymarket CLOB (Polygon)
  • leveraged_positions         Alt: Jupiter Predict (Solana)
  • lp_deposits / trade_ledger
        │
        ▼
Solana custody
  • User USDC deposits (SPL)
  • Protocol vault ATA
  • Payouts on close / withdraw
  • Market data: Jupiter Predict API surfaces Polymarket events, outcomes, and live prices to the frontend.
  • Execution: With EXECUTION_BACKEND=polymarket, the server buys and sells outcome tokens on Polymarket via CLOB. Collateral and PnL still settle in USDC on Solana.
  • Ledger: Positions, vault shares, borrow index, and balances are tracked in Supabase. On-chain Solana transfers move USDC for deposits, vault funding, and user payouts.

Trading flow

  1. Select an event and outcome on Trade.
  2. Choose YES or NO, collateral amount, and leverage (1× to max tier).
  3. Fund the trade with a Solana USDC deposit or spend from your pre-funded trading balance if enabled.
  4. The server validates risk limits, borrows from the vault if leveraged, and executes the outcome buy on Polymarket.
  5. Close from the terminal or portfolio. Debt is repaid, a closing fee is applied, and remaining equity is paid out in USDC.

Leverage and fees

  • Events under $100K volume: max 2× leverage
  • Events at $100K+ volume: max 3× leverage
  • Minimum collateral: $5 USDC (configurable server-side)
  • No opening fee: full collateral counts toward position size
  • Closing fee: 5% of equity after debt is repaid
  • Borrow APR on vault principal: 10% (accrues via borrow index)
  • Max vault utilization for new borrows: 80%
  • Per-wallet borrow cap: 20% of vault TVL

Earn vault

LPs deposit USDC on Solana and receive vault shares. Deposited assets fund trader borrows. Yield comes from borrow interest accruing on outstanding principal and from closing fees allocated to LPs. Withdrawals are limited by vault liquidity: if most USDC is deployed to open positions, only the liquid portion is immediately withdrawable.

Risk

Leveraged positions can be liquidated if mark-to-market value falls below the debt threshold. Prediction markets can resolve to $0 or $1; you can lose your full collateral. Smart contract, bridge, CLOB, and oracle risks apply. This is experimental software, not financial advice.

Read full risk disclosure

External resources

Back to trade