Supported DEXs
Uniswap V3
Concentrated liquidity with four fee tiers. Uses the UniversalRouter for optimal gas efficiency. Best for major pairs like ETH/USDC and WBTC/ETH.
Camelot
Arbitrum-native V2-style AMM with volatile and stable pool types. Best for ARB ecosystem tokens, newer pairs, and long-tail assets.
How It Works
The agent follows a quote-then-execute flow to ensure you always see expected output before committing funds.Step 1: Quote
When you request a swap, the agent fetches off-chain quotes from both DEXs. Quoting is a read-only operation with zero gas cost.- Uniswap V3 — calls
QuoterV2.quoteExactInputSingle()to simulate the swap through the pool and return the expectedamountOutplus price impact. - Camelot — calls
CamelotRouter.getAmountsOut()to calculate the output along the swap path.
Step 2: Approve
If the router does not already have sufficient token allowance, the agent sends an ERC-20approve transaction before the swap.
Step 3: Execute
The swap transaction is submitted with a computedminAmountOut based on your slippage tolerance. The transaction reverts on-chain if the output falls below this threshold.
Uniswap V3 Fee Tiers
TheUniswapV3Adapter automatically selects the 0.30% fee tier by default. You can request a specific tier in your prompt.
| Fee Tier | Rate | Best For |
|---|---|---|
| LOWEST | 0.01% | Stable-to-stable (USDC/USDT) |
| LOW | 0.05% | Stable/major pairs |
| MEDIUM | 0.30% | Most trading pairs |
| HIGH | 1.00% | Exotic or low-liquidity pairs |
Slippage Protection
Every swap includes configurable slippage protection.- Default: 0.50% (50 basis points)
- Custom: specify in your prompt, e.g. “swap with 0.1% slippage”
minAmountOut is calculated as:
Price Impact Estimation
For Uniswap V3 swaps, the adapter estimates price impact by comparing the pool’ssqrtPriceX96 before and after the simulated swap. This uses fixed-point arithmetic to avoid floating-point precision issues:
Price impact above 100 bps (1%) triggers a warning in the agent response. Trades above 500 bps require explicit confirmation.
Route Optimizer Contract
For high-value swaps, the agent can query the RouteOptimizer Stylus contract deployed on Arbitrum. Written in Rust, it provides 10-100x gas savings over equivalent Solidity for multi-path computation. The RouteOptimizer maintains a dynamic registry of DEX quoters:- Indexed mappings with a counter (
dex_count) for enumeration - Soft-delete via an
activeflag so DEXs can be removed without reindexing - Two dispatch types:
UniV3(concentrated liquidity quoter) andAmmV2(standard getAmountsOut)
Example Prompts
Try these natural language commands with the agent:SDK Reference
The trading adapters are in the@arb-agent/adapters package:
UniswapV3Adapter
quote(params) — fetch off-chain quote via QuoterV2swap(params) — execute via UniversalRouterCamelotAdapter
quote(params) — fetch off-chain quote via getAmountsOutswap(params) — execute via CamelotRouter with referrer supportSwapParams with these fields:
| Field | Type | Required | Description |
|---|---|---|---|
tokenIn | Address | Yes | Token to sell |
tokenOut | Address | Yes | Token to buy |
amountIn | bigint | Yes | Amount of tokenIn (in token decimals) |
slippageBps | number | No | Slippage tolerance (default: 50) |
deadline | bigint | No | Unix timestamp deadline (default: 5 min) |
recipient | Address | No | Receiver address (default: sender) |
The Uniswap adapter also accepts a
feeTier parameter to override automatic fee tier selection. Valid values are 100, 500, 3000, and 10000.