Skip to main content

DeFi Components

White Rabbit includes native Uniswap V3 integration for token swaps — get a live quote, then build and broadcast the swap transaction.

Avoid public RPC endpoints

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 Component

Fetch a live swap quote from Uniswap. Returns the best output amount across the configured protocol versions.

Config​

FieldTypeDefaultDescription
version'v2' | 'v3' | 'v4' | 'all''all'Uniswap version(s) to query. 'all' returns the best quote across all supported versions

Inputs​

FieldTypeDescription
jsonRpcUrlstringJSON-RPC endpoint for the target chain
tokenInstringInput token contract address
tokenOutstringOutput token contract address
amountInstringInput token amount in smallest unit (bigint string, e.g. "1000000000000000000" for 1 ETH)

Outputs​

FieldTypeDescription
amountOutstringBest estimated output amount (bigint string)
totalFeenumberTotal pool fee in basis points (e.g. 30 = 0.3%)
gasEstimatestringEstimated 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 Component

Build 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​

FieldTypeDescription
jsonRpcUrlstringJSON-RPC endpoint
chainIdnumberChain ID
tokenInstringInput token address
tokenOutstringOutput token address
recipientstringAddress to receive the output tokens
amountInnumberExact input amount
amountOutMinimumnumber?Minimum output (slippage protection). Defaults to 0 — always set this in production

Outputs​

FieldTypeDescription
unsignedTransactionstringUnsigned 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
Slippage protection

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.