Overview
The relayer API enables privacy-preserving withdrawals from shielded pools by submitting zero-knowledge proofs on behalf of users. Users never need to expose their Starknet wallet addresses.POST /api/relayer/withdraw
Submits a Groth16 withdrawal proof to a shielded pool. The relayer broadcasts the transaction and deducts a fee from the withdrawn amount.Request Body
Shielded pool contract address (V4 pool)
Groth16 proof calldata from
generateVerifyCalldata(). Array of felt252 hex strings including proof points, public inputs, and verification hints.Response
Starknet transaction hash
Transaction execution status:
SUCCEEDED, REVERTED, or UNKNOWNRevert reason if transaction failed
Example Request
Gas Configuration
Source:/home/daytona/workspace/source/src/app/api/relayer/withdraw/route.ts:50
Withdrawal transactions use generous gas bounds due to Groth16 verification (~34M L2 gas):
- L2 gas: 1.2B units with 3x price multiplier
- L1 gas: 256 units
- L1 data gas: 20,480 units
POST /api/relayer/deploy-batch
Deploys a batch of pending deposits from a shielded pool to the underlying vault. This makes deposits active and eligible for yield.Request Body
Shielded pool contract address
Number of deposits to deploy (typically 3 for V4 pools)
If true, calls
deploy_partial_batch instead of deploy_batchResponse
Transaction hash of the batch deployment
Execution status
Example Request
GET /api/relayer/pool-status
Fetches the current state of a shielded pool including denomination, undeployed deposits, and fee configuration.Query Parameters
Pool contract address
Response
Fixed deposit size in WBTC sats (for V4) or USDC cents (for stablecoin pools)
Number of deposits awaiting batch deployment
Number of deposits currently deployed in vault
Total lifetime deposits
Total WBTC/USDC currently in pool (includes yield)
Maximum relayer fee in basis points (e.g., 500 = 5%)
Maximum relayer fee in sats
Next leaf index for new deposits
Example Request
Example Response
GET /api/relayer/fee-estimate
Estimates the relayer fee for a complete deposit-withdraw cycle. Fee is calculated based on current gas prices and includes a 20% margin.Query Parameters
Pool address to check contract max_fee (fee will be capped at this value)
Response
Recommended relayer fee in WBTC sats (includes 20% margin)
Detailed gas cost breakdown:
depositGasStrk: Deposit gas cost in STRKdeployBatchGasStrk: Batch deployment cost per deposit (amortized)withdrawGasStrk: Withdrawal gas cost in STRKtotalGasStrk: Total gas cost in STRKtotalGasUsd: Total gas cost in USDmarginPercent: Margin percentage (20%)
Current gas prices:
l2GasPriceFri: L2 gas price in fril1DataGasPriceFri: L1 data gas price in fri
Market prices used:
strkUsd: STRK price in USDbtcUsd: BTC price in USD
Pool’s max_fee if pool parameter was provided
Pool denomination if pool parameter was provided
Example Request
Example Response
POST /api/relayer/private-swap
Execute a private token swap by withdrawing from a WBTC pool and swapping to another token via AVNU. Source:/home/daytona/workspace/source/src/app/api/relayer/private-swap/route.ts
Request Body
Address of the WBTC input pool to withdraw from
Groth16 proof calldata array for withdrawal verification
New commitment for the output token pool
Address of the token to receive (ETH, USDC, STRK, etc.)
Maximum slippage tolerance (e.g., 0.02 = 2%)
Response
StarkNet transaction hash
Transaction status (SUCCEEDED, REVERTED, or UNKNOWN)
Revert reason if execution failed
Merkle tree leaf index of the new commitment (-1 if failed)
Hex-encoded amount of output token received
Example Request
Gas Estimates
Source:/home/daytona/workspace/source/src/app/api/relayer/fee-estimate/route.ts:16
| Operation | L2 Gas | Description |
|---|---|---|
| deposit | 800,000 | Merkle tree insert + transferFrom |
| deploy_batch | 1,200,000 | Vault deposit + share accounting (per batch) |
| withdraw | 35,000,000 | Groth16 verification + vault redemption |
| private_swap | 40,000,000 | Groth16 + AVNU swap + Merkle insert |
Withdrawal and private swap are the most expensive operations due to on-chain Groth16 proof verification via Garaga.