bitcoin trading at the speed of the ⚡️ powered by state channels - erc7824
Bitcoin-native perpetual futures DEX built on both Citrea (Bitcoin L2) and Rootstock (Bitcoin sidechain) using state channels for instant, gasless trading. Our protocol enables sub-second perpetual trades with zero fees per trade while maintaining full self-custody and cryptographic exit guarantees.
Key innovations:
Traders deposit cBTC (on Citrea) or rBTC (on Rootstock) collateral once, then trade instantly without gas fees. Settlement happens on-chain when users withdraw, with Pyth verifying all historical prices for trustless verification.
The protocol leverages Nitrolite (ERC-7824) state channels where traders open bilateral channels with an automated broker/custodian EOA (EIP-7702). All trades execute off-chain at ~10ms latency with position states containing balances for ETH/cBTC, SOL/cBTC, and BNB/cBTC pairs on Citrea (or ETH/rBTC, SOL/rBTC, and BNB/rBTC on Rootstock). Each state update is cryptographically signed and includes Pyth oracle price references for the exact trade timestamp, making historical price manipulation impossible. The trading interface integrates Pyth Trading View charts for real-time market visualization across all supported pairs.
Built by forking Nitrolite state channels and extensively modifying for perpetuals trading. The architecture uses:
Core Stack:
Technical Implementation:
We replaced Nitrolite's generic asset ledger with a position-based state structure storing int256[3]
balances for three trading pairs. The custody contract validates state transitions by checking Pyth Historical Price Feed data using the Benchmarks API - if a trader claims they closed a position profitably, Pyth verifies the exact price at that specific timestamp through cryptographic proof verification.
Cross-Rate Price Derivation: Since SOL/BTC and BNB/BTC price feeds don't exist natively, we implement the Derive Cross Rate method (SOL/BTC = SOL/USD ÷ BTC/USD) to calculate these pairs from existing Pyth price feeds, ensuring accurate pricing for all trading pairs.
Real-time Execution: LAZER provides sub-second price data for state channel execution, enabling ultra-fast trade execution while Pyth handles settlement verification. The trading interface integrates Pyth Trading View for comprehensive chart analysis across all supported pairs.
Secure Infrastructure: We use a single EOA as both broker AND custodian through EIP-7702 delegation, eliminating coordination complexity.
State updates include a changedIndex
field indicating which asset was traded, so we only verify one Pyth price per trade (gas optimization). Liquidations are signed by the automated custodian and batch-submitted to save gas.
Each blockchain (Citrea and Rootstock) runs its own isolated clearnode instance, configured via environment variables. The UI fetches data directly from the respective clearnode and smart contracts, displaying real-time positions and trade history without additional indexing layers.