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:

  1. Shielded → public — unshield directly to DEX router as recipient.
  2. Public → shielded — DEX output immediately shielded back.

Both steps atomic in a single tx.

Fee Structure

ComponentAmountNotes
Protocol fee0.25%On swap output
Broadcaster gasVariableETH cost + 1% markup in B20
DEX feePer poolStandard 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

Slippage & MEV Protection

RAIL20 provides built-in MEV protection. Swap details are hidden inside the ZK proof — sandwich attackers cannot front-run your transaction.