DeFi Components
White Rabbit includes native Uniswap V3 integration for token swaps — get a live quote, then build and broadcast the swap transaction.
White Rabbit runs on shared infrastructure with a shared outbound IP pool. Public RPC URLs enforce rate limits per IP — under load this can cause errors across all workspaces sharing that IP. Use a private endpoint (Alchemy, Infura, QuickNode, or self-hosted). See Connecting to any chain.
GET_UNISWAP_SWAP_QUOTE​
GET_UNISWAP_SWAP_QUOTE DeFi Workflow ComponentFetch a live swap quote from Uniswap. Returns the best output amount across the configured protocol versions.
Config​
| Field | Type | Default | Description |
|---|---|---|---|
version | 'v2' | 'v3' | 'v4' | 'all' | 'all' | Uniswap version(s) to query. 'all' returns the best quote across all supported versions |
Inputs​
| Field | Type | Description |
|---|---|---|
jsonRpcUrl | string | JSON-RPC endpoint for the target chain |
tokenIn | string | Input token contract address |
tokenOut | string | Output token contract address |
amountIn | string | Input token amount in smallest unit (bigint string, e.g. "1000000000000000000" for 1 ETH) |
Outputs​
| Field | Type | Description |
|---|---|---|
amountOut | string | Best estimated output amount (bigint string) |
totalFee | number | Total pool fee in basis points (e.g. 30 = 0.3%) |
gasEstimate | string | Estimated gas cost for the swap (bigint string) |
SDK example​
import { WorkspaceClient, ComponentModule } from 'caller-sdk';
const workspace = new WorkspaceClient({ apiKey: process.env.WR_API_KEY! });
const quote = await workspace.call(ComponentModule.GET_UNISWAP_SWAP_QUOTE, {
jsonRpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/KEY',
chainId: 1,
tokenIn: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
tokenOut: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
amountIn: '1000000000000000000', // 1 ETH in wei
}).promise();
console.log(quote.amountOut); // "1850000000" (1,850 USDC)
console.log(quote.totalFee); // 30 (0.3%)
BUILD_EVM_UNISWAP_SWAP_CALLDATA​
BUILD_EVM_UNISWAP_SWAP_CALLDATA DeFi Workflow ComponentBuild the encoded calldata for a Uniswap swap. Pipe the output into BUILD_EVM_TRANSACTION to produce an unsigned transaction ready for signing and broadcast.
Config​
None.
Inputs​
| Field | Type | Description |
|---|---|---|
jsonRpcUrl | string | JSON-RPC endpoint |
chainId | number | Chain ID |
tokenIn | string | Input token address |
tokenOut | string | Output token address |
recipient | string | Address to receive the output tokens |
amountIn | number | Exact input amount |
amountOutMinimum | number? | Minimum output (slippage protection). Defaults to 0 — always set this in production |
Outputs​
| Field | Type | Description |
|---|---|---|
unsignedTransaction | string | Unsigned swap transaction |
SDK example​
const swapTx = await workspace.call(ComponentModule.BUILD_EVM_UNISWAP_SWAP_CALLDATA, {
jsonRpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/KEY',
chainId: 1,
tokenIn: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
tokenOut: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
recipient: '0xMyWalletAddress',
amountIn: 1_000_000_000_000_000_000,
amountOutMinimum: 1_840_000_000, // min 1,840 USDC (1% slippage)
}).promise();
Complete swap workflow​
STRING_CONSTANT (RPC URL)
│
├──▶ GET_EVM_CHAIN_ID
│ │
│ └──▶ GET_UNISWAP_SWAP_QUOTE
│ │ amountOut
│ ▼
│ (compute amountOutMinimum with slippage)
│
└──▶ BUILD_EVM_UNISWAP_SWAP_CALLDATA
│ unsignedTransaction
â–¼
SIGN_WITH_KEY_SHARE ──▶ SIGN_EVM_TRANSACTION
│
â–¼
BROADCAST_EVM_TRANSACTION
│
â–¼
WAIT_FOR_EVM_TRANSACTION
Always set amountOutMinimum based on the quoted amountOut minus your acceptable slippage (e.g. 0.5–1%). Setting it to 0 exposes the transaction to sandwich attacks.