Core Features
Swap
Trade between B20 tokens with full privacy. Same liquidity, same rates, zero exposure.
How Private Swaps Work
RAIL20 swaps combine shielded transactions with existing DEX liquidity on Base:
- Shielded → public — unshield directly to DEX router as recipient.
- Public → shielded — DEX output immediately shielded back.
Both steps atomic in a single tx.
Fee Structure
| Component | Amount | Notes |
|---|---|---|
| Protocol fee | 0.25% | On swap output |
| Broadcaster gas | Variable | ETH cost + 1% markup in B20 |
| DEX fee | Per pool | Standard LP fee |
Swap Example
javascript
// Swap 500 shielded B20 for shielded USDC
const swapProof = await generateSwapProof({
inputNote: aliceNote, // 500 B20 (shielded)
swapPath: [b20Token, usdcToken],
minOutput: parseUSDC("498"), // slippage
dexRouter: uniswapRouter,
merkleRoot: await getMerkleRoot(),
});
await broadcaster.submitSwap(swapProof);Supported DEXs
- Uniswap V3 — concentrated liquidity
- Uniswap V2 — constant product
- Meteora — dynamic pools on Base
Slippage & MEV Protection
RAIL20 provides built-in MEV protection. Swap details are hidden inside the ZK proof — sandwich attackers cannot front-run your transaction.
Was this page helpful?