Routing & Simulation
The routing API allows you to simulate deposits before sending real funds. This helps you show users exact fees, output amounts, and verify that a route exists for their desired token pair.Simulate Deposit
Preview a cross-chain route without moving funds. Uses the user’s stored Deposit Intent to determine the destination, or allows you to override it for testing. Endpoint:POST /api/routing/simulate-deposit
Authentication: Required (API Key)
Request
Headers:| Field | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | User identifier (must have a Deposit Intent) |
fromChainId | number | Yes | Source chain ID (e.g., 8453 for Base) |
fromTokenSymbol | string | Yes | Token symbol on source chain (e.g., “USDC”) |
amountInAtomic | string | Yes | Deposit amount in atomic units (as string) |
overrideTargetChainId | number | No | Temporarily override destination chain |
overrideTargetTokenAddress | string | No | Temporarily override destination token |
overrideTargetAddress | string | No | Temporarily override recipient address |
- Always use the smallest unit of the token (like “wei” for ETH)
- Pass as a string to preserve precision
- Examples:
- 10 USDC (6 decimals) =
"10000000" - 0.5 ETH (18 decimals) =
"500000000000000000" - 100 MATIC (18 decimals) =
"100000000000000000000"
- 10 USDC (6 decimals) =
Response
Status:200 OK
| Field | Type | Description |
|---|---|---|
userId | string | User identifier |
hasIntent | boolean | Whether user has a Deposit Intent configured |
fromChainId | number | Source chain ID |
fromChainKey | string | Source chain key (human-readable) |
fromTokenSymbol | string | Source token symbol |
amountInAtomic | string | Input amount in atomic units |
targetChainId | number | Destination chain ID |
targetChainKey | string | Destination chain key |
targetTokenSymbol | string | Destination token symbol |
targetAddress | string | Recipient address on destination chain |
amountOutExpectedAtomic | string | Expected output after all fees (atomic units) |
gasFeeRaw | string | Gas fee in source token atomic units (0 if sponsored) |
gasFeeSkipReason | string | Why gas fee wasn’t charged (if sponsored) |
amountForSwapAtomic | string | Amount after protocol/gas fees, before bridging |
provider | string | Routing provider used (e.g., “lifi”) |
policy | object | Routing policy applied |
| Field | Type | Description |
|---|---|---|
slippageBps | number | Maximum slippage tolerance in basis points |
minOutputBps | number | Minimum output percentage (10000 = 100%) |
maxDurationSeconds | number | Maximum estimated completion time |
maxHops | number | Maximum number of bridge/swap hops |
requiresSponsoredGas | boolean | Whether gas sponsorship is required |
Example
Basic Simulation:Error Responses
No Deposit Intent Status:404 Not Found
400 Bad Request
400 Bad Request
400 Bad Request
400 Bad Request
Understanding Simulation Results
Fee Breakdown
The simulation shows exactly what fees will be charged: Protocol Fee:- If
sponsoredGas: true:gasFeeRaw = "0",gasFeeSkipReasonexplains why - If
sponsoredGas: false:gasFeeRawis the estimated gas cost in source token
Gas Fee Skip Reasons
WhengasFeeRaw = "0", the gasFeeSkipReason field explains why:
| Reason | Description |
|---|---|
SPONSORED | Gas is sponsored by the platform (API key setting) |
AA_ESTIMATION_FAILED | Gas estimation failed, falling back to sponsored mode |
GAS_MANAGER_REQUIRED | Gas Manager is required for this execution |
NONE | Gas fee is being charged (not skipped) |
Route Viability
A successful simulation means:- ✅ A route exists for the token pair
- ✅ Fees can be covered by the deposit amount
- ✅ The routing provider supports this transfer
- ✅ Expected output meets minimum thresholds
Use Cases
1. Calculate Minimum Deposit
Use simulation to find the minimum viable deposit amount:2. Show Expected Output
Display to users how much they’ll receive:3. Test Different Routes
Try different destination chains to find the best rate:4. Verify Route Availability
Before creating a Deposit Intent, verify the route exists:Best Practices
Always Simulate First
Before showing a deposit address to users:- Simulate the deposit with a typical amount
- Verify route exists (simulation succeeds)
- Calculate minimums based on fee structure
- Show expected output to users
Handle All Error Cases
Use Overrides for Testing
Test different scenarios without affecting user’s intent:Cache Simulation Results
Simulation results are valid for a short time (typically 1-2 minutes):Next Steps
- Create Deposit Intents after verifying routes
- Track Executions to monitor actual transfers
- Review Error Codes for handling failures
- Learn about Fees and Gas calculation details