The Secondary Market for Kalshi on Solana
Trade Kalshi prediction markets with up to 40x leverage on Solana. A decentralized secondary market bringing real-world prediction markets on-chain on Solana.
Why perpX • Kalshi Integration • Features • Getting Started • How It Works
Kalshi is the first CFTC-regulated prediction market exchange in the US, offering markets on elections, economics, crypto, weather, and more. However, Kalshi has limitations:
| Limitation | perpX Solution |
|---|---|
| No leverage trading | Up to 40x leverage on any market |
| US-only access | Permissionless - anyone with a Solana wallet |
| Centralized custody | Non-custodial - your keys, your funds |
| Limited trading hours | 24/7 trading on Solana |
| No short selling (limited) | Full long/short on any outcome |
perpX creates a decentralized secondary market where anyone can trade Kalshi market outcomes with leverage, bringing the world's most liquid prediction markets to DeFi.
perpX mirrors Kalshi markets on-chain with a 1:1 mapping:
Kalshi Market (KXBTC-25MAR28-B100000)
↓
perpX Syncs
↓
On-Chain Market (Solana)
↓
Trade with Leverage
- Mark prices are derived from Kalshi's live market prices
- Settlement prices are determined by Kalshi market outcomes
- Markets expire and settle based on Kalshi's official resolution
| Category | Kalshi Series | Example Markets |
|---|---|---|
| Federal Reserve | KXFED |
Will the Fed raise rates? |
| Inflation | KXCPI |
CPI above 3%? |
| Employment | KXJOBS |
Unemployment rate predictions |
| GDP | KXGDP |
Q4 GDP growth above 2%? |
| Bitcoin | KXBTC |
BTC above $100k by March? |
| Ethereum | KXETH |
ETH price milestones |
| S&P 500 | INX |
Index price targets |
| Nasdaq | NASDAQ100 |
Tech index predictions |
Every Kalshi market is mapped to an on-chain market via the Market Registry:
{
"KXBTC-25MAR28-B100000": {
"marketIndex": 52,
"marketPda": "7xK2...",
"title": "Bitcoin above $100,000?",
"expiryTimestamp": 1743148800
}
}This ensures:
- Consistent market identification across platforms
- Automatic expiry matching with Kalshi
- Proper settlement based on Kalshi outcomes
- Trade with 1x to 40x leverage on any Kalshi market
- Amplify your conviction on prediction market outcomes
- Capital-efficient trading with isolated margin
- Go Long (YES): Profit when the outcome probability increases
- Go Short (NO): Profit when the outcome probability decreases
- Full flexibility to trade either direction
- Non-custodial: Smart contract holds funds, not a centralized exchange
- Permissionless: No KYC, no geographic restrictions
- Transparent: All trades and positions visible on-chain
- Composable: Built on Solana for future DeFi integrations
- Isolated Margin: Each position has dedicated collateral
- Liquidation Engine: Automated liquidations protect the protocol
- Insurance Fund: Backstop for under-collateralized positions
- No Funding Rates: Unlike perps, no ongoing funding payments
- All positions settle at Kalshi market expiration
- No indefinite holding - markets have defined end dates
- Settlement based on real-world Kalshi outcomes
Kalshi publishes market → perpX syncs to Solana → On-chain market created
User deposits USDC → Opens leveraged position → PnL tracks Kalshi price
Kalshi market expires → Outcome determined → perpX settles all positions
If you believe Bitcoin will be above $100,000 by March 28th:
| Kalshi Price | Your Position | Leverage | Collateral | Potential PnL |
|---|---|---|---|---|
| 45¢ (45% YES) | Long 100 contracts | 10x | $4.50 USDC | +$55 if YES wins |
If the market moves to 60¢:
- Without leverage: +$15 profit (33% return)
- With 10x leverage: +$150 profit (333% return)
perpX/
├── programs/ # Solana smart contracts (Anchor)
│ └── prediction-perps/
│ ├── instructions/ # open_position, close_position, liquidate, settle
│ ├── state/ # Market, Position, Config accounts
│ └── utils/ # Price calculations, margin checks
│
├── app/ # Next.js frontend
│ ├── components/ # Trading UI, charts, position management
│ ├── lib/
│ │ ├── kalshi.ts # Kalshi API integration
│ │ └── market-registry.json # Kalshi → On-chain mapping
│ └── hooks/ # useTrading, usePositions, useKalshiMarkets
│
├── keeper/ # Automated bot service
│ ├── liquidator.ts # Monitors and liquidates risky positions
│ ├── settler.ts # Settles expired markets
│ └── priceUpdater.ts # Syncs Kalshi prices on-chain
│
└── scripts/
├── sync-kalshi-markets.ts # Bulk sync Kalshi markets
└── create-new-market.ts # Create individual market
- Node.js 18+
- Solana wallet (Phantom, Solflare, etc.)
- Devnet USDC from Circle Faucet
-
Clone and install
git clone https://github.com/e-man07/kalshi.git cd kalshi/prediction-perps yarn install cd app && npm install
-
Run the frontend
npm run dev
-
Get test USDC
- Visit faucet.circle.com
- Select Solana Devnet
- Enter your wallet address
-
Start trading
- Connect wallet at localhost:3000
- Browse Kalshi markets
- Open a leveraged position
To add new Kalshi markets to perpX:
# Sync all markets from supported categories
npx ts-node scripts/sync-kalshi-markets.ts
# Or add a specific market
npx ts-node scripts/create-new-market.ts KXBTC-25MAR28-B100000Program ID: C5aeAdDofqXDwf39wPz21DXajvgu993UeghATenu9xyN
| Instruction | Description |
|---|---|
create_market |
Create on-chain market linked to Kalshi ticker |
open_position |
Open leveraged long/short position |
close_position |
Close position at current mark price |
add_margin |
Add collateral to reduce liquidation risk |
liquidate |
Liquidate undercollateralized position |
settle_market |
Settle market based on Kalshi outcome |
claim_settlement |
Withdraw funds from settled position |
- Core trading engine (open/close positions)
- Kalshi market sync
- Liquidation system
- Settlement system
- Cross-margin mode
- Stop-loss / take-profit orders
- More Kalshi market categories
- Mainnet deployment
| Component | Technology |
|---|---|
| Smart Contracts | Rust, Anchor Framework |
| Frontend | Next.js 14, React, TypeScript |
| Styling | Tailwind CSS |
| Charts | TradingView Lightweight Charts |
| Blockchain | Solana |
| Collateral | USDC |
| Data Source | Kalshi API |
- Kalshi: kalshi.com - Source prediction market exchange
- Solana: solana.com - Blockchain platform
- Circle Faucet: faucet.circle.com - Get devnet USDC
perpX is an experimental DeFi protocol on Solana devnet. It is not affiliated with Kalshi Inc. Trading leveraged positions carries significant risk. Use at your own risk.
Bringing Kalshi to DeFi
Built on Solana
