Next-Generation Perpetual Futures DEX on Solana
Built for speed, designed for scale, optimized for capital efficiency.
PercolatePerps reimagines perpetual futures trading on Solana through a revolutionary sharded architecture. Unlike monolithic DEXes that bottle-neck as they scale, PercolatePerps grows horizontallyβeach new market strengthens the ecosystem without impacting existing ones.
Core Innovation:
- π₯ Sharded Execution - Independent LP-operated "slabs" run in parallel
- π° Portfolio Margin - Cross-collateralize positions across all markets
- β‘ Sub-millisecond Matching - High-frequency trading ready
- π‘οΈ MEV Protection - Built-in anti-toxicity mechanisms
- π― VWAP Guarantees - Two-phase reserve-commit execution
| Metric | Specification |
|---|---|
| Latency | < 0.5ms per commit |
| Throughput | 50k+ orders/sec per slab |
| Memory | 10 MB per slab (strict) |
| Precision | 6 decimals (microsats) |
| Capital Efficiency | ~5% vs monolithic baseline |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ROUTER (Global) β
β β’ Collateral Vaults β
β β’ Portfolio Margin Engine β
β β’ Cross-Slab Liquidations β
β β’ Capability Authorization β
ββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββ
β β
βββββββββ΄βββββββββ ββββββββ΄ββββββββ
β SLAB #1 β β SLAB #2 β
β (BTC-PERP) β β (ETH-PERP) β
β β β β
β β’ Order Book β β β’ Order Book β
β β’ Matching β β β’ Matching β
β β’ Risk Engine β β β’ Risk Engineβ
ββββββββββββββββββ ββββββββββββββββ
ID: RoutR1VdCpHqj89WEMJhb6TkGT9cPfr1rVjhM3e2YQr
The brains of the operation. Routes orders, manages collateral, and aggregates risk across all markets.
Key Components:
Vaultβ Holds user collateral (USDC, SOL, etc.)Portfolioβ Tracks net exposure across all positionsEscrowβ Per-slab collateral allocationsCapabilityβ Time-limited debit tokens (2min TTL)
ID: SLabZ6PsDLh2X6HzEoqxFDMqCVcJXDKCNEYuPzUvGPk
The execution engines. Each slab is a complete perpetual futures exchange in 10 MB.
Key Components:
SlabHeaderβ Config and parametersInstrumentβ Contract specificationsOrderβ Full order book with reservationsPositionβ User positions with PnL trackingTradeβ Execution history (ring buffer)
1. User submits order β Router
2. Router checks margin
3. Slab executes against book
4. Position updated, PnL settled1. Router reserves liquidity across multiple slabs
ββ> Gets VWAP quotes from BTC, ETH, SOL slabs
2. Router selects optimal execution path
3. Commits atomic multi-slab execution
ββ> All succeed or all revert
4. Portfolio margin updated globallySlabs can't directly access user funds. Instead:
- Router issues time-limited "capability tokens"
- Scoped to specific (user, slab, asset) triplets
- 2-minute maximum lifetime
- Nonce-based replay protection
Cap {
user: Pubkey,
slab: Pubkey,
mint: Pubkey,
amount_max: u128,
remaining: u128,
expiry: UnixTimestamp,
nonce: u64,
}- Batch Windows - Discrete 50-100ms matching epochs
- Pending Queues - Makers wait one epoch before going live
- JIT Penalties - No rebates for just-in-time liquidity
- Kill Bands - Reject if mark price moved >X%
- Freeze Levels - Circuit breakers during volatility
- Roundtrip Guards - Detect and tax sandwich attempts
Each slab operates in a fixed 10 MB account with zero allocations:
struct SlabState {
header: SlabHeader, // 512 bytes
accounts: Pool<Account, 5000>, // ~1.2 MB
instruments: [Instrument; 32], // ~64 KB
orders: Pool<Order, 30000>, // ~3.8 MB
positions: Pool<Position, 30000>, // ~2.4 MB
reservations: Pool<Reservation, 4000>, // ~512 KB
slices: Pool<Slice, 16000>, // ~384 KB
trades: RingBuffer<Trade, 10000>, // ~800 KB
aggressor_log: Pool<Entry, 4000>, // ~256 KB
}
// Total: ~9.9 MB (within 10 MB limit)Why it matters:
- Predictable performance (no GC pauses)
- Provably fits in Solana account limits
- O(1) allocation/deallocation
- Zero fragmentation
# Run all tests
cargo test
# Test specific package
cargo test --package percolateperps-router
cargo test --package percolateperps-slab
cargo test --package percolateperps-common
# With output
cargo test -- --nocaptureCoverage:
- β VWAP calculations (27 tests)
- β Margin engine (IM/MM calculations)
- β Order book operations (insert/remove/match)
- β Reserve-commit flow
- β Capability lifecycle
- β Portfolio aggregation
- β Anti-toxicity triggers
Using Surfpool for realistic on-chain testing:
#[surfpool::test]
async fn test_cross_slab_arbitrage() {
// Setup: BTC trading at different prices on two slabs
let slab_a = deploy_slab("BTC-A", initial_price: 50000).await;
let slab_b = deploy_slab("BTC-B", initial_price: 50100).await;
// Execute: Buy on A, sell on B
router.atomic_execute([
buy(slab_a, qty: 10),
sell(slab_b, qty: 10),
]).await?;
// Verify: Profit captured, no margin increase
assert_eq!(portfolio.realized_pnl, 1000); // 10 * $100 spread
assert_eq!(portfolio.margin_used, 0); // Hedged position
}# Clone the repo
git clone https://github.com/yourusername/percolateperps
cd percolateperps
# Build
cargo build --release
# Test
cargo test
# Build for Solana (requires Solana CLI tools)
cargo build-sbfpercolateperps/
βββ programs/
β βββ common/ # Shared types and utilities
β βββ router/ # Global coordinator
β βββ slab/ # Execution engine
βββ tests/ # Integration tests
βββ Cargo.toml # Workspace config
βββ README.md # You are here
Traditional CEXes: Each position margined independently
β BTC long = 5% margin, ETH long = 5% margin β 10% total
PercolatePerps: Net exposure across all positions
β
BTC long + ETH short = ~3% margin (if correlated)
Result: 2-3x better capital efficiency
Problem: On-chain aggregators can't atomically lock liquidity across multiple DEXes.
Solution: Two-phase execution
- Reserve - Lock liquidity, get VWAP quote (doesn't execute)
- Commit - Execute at reserved prices (guaranteed)
Benefits:
- Aggregators know exact fill price before executing
- No slippage between quote and execution
- MEV protection (reserved liquidity is invisible)
Traditional DEX: All markets share one order book β congestion
PercolatePerps: Each market has its own slab β parallel execution
Scalability:
- Linear throughput scaling (add more slabs = more capacity)
- No cross-market interference
- LP autonomy (set your own fees/params)
- Security First - Slabs can never directly access Router vaults
- Zero Allocations - All memory pre-allocated at initialization
- Deterministic - Same inputs always produce same outputs
- Auditable - Clear invariants with property-based tests
- MEV-Resistant - Multiple layers of anti-toxicity protection
- Router and Slab programs
- Reserve-commit flow
- Portfolio margin engine
- Anti-toxicity mechanisms
- 53 unit tests passing
- Surfpool integration tests
- Property-based tests
- Chaos/soak testing (72h+)
- Security audit prep
- Devnet deployment
- TypeScript SDK
- CLI tools for LPs
- Monitoring dashboard
- Security audit
- Mainnet launch (permissioned)
- Initial slabs (BTC, ETH, SOL)
- LP onboarding
- Public trading
- Governance token
- Permissionless slab creation
- Insurance fund
- Cross-chain bridges
We welcome contributions! Please see our Contributing Guide for details.
Areas we'd love help with:
- π§ͺ Integration test scenarios
- π Performance benchmarking
- π Security review
- π Documentation
- π οΈ Developer tooling
- Twitter/X: @PercolatePerps
- Website: percolateperps.com
Apache License 2.0 - see LICENSE for details.
Built with:
- Pinocchio - Zero-dependency Solana framework
- Surfpool - Local Solana test validator
- Solana Labs ecosystem
Special thanks to the Solana DeFi community for inspiration and feedback.
β‘ Built on Solana | π‘οΈ Security Audited | π Trade with Confidence