Overview
The Route API is the most critical endpoint for the Earn integration. It provides optimal transaction routes for deposits while ensuring proper attribution to distributors. Every deposit must use this endpoint to be tracked and assigned correctly.Depositors must be members before they can deposit. See the Membership API for more information.
Critical: Always include the
distributor_id parameter when requesting routes. This is essential for tracking deposits and proper attribution to your distributor account.Endpoint
Get Route
Request an optimal trading route that will be tracked and attributed to your distributor.The user’s EOA (Externally Owned Account) address that will execute the transaction
The chain ID where the transaction will be executed (e.g.,
1 for Ethereum Mainnet, 137 for Polygon)Acceptable slippage tolerance as a decimal (min:
0.001 = 0.1%, max: 0.5 = 50%)Input token address or
native for the chain’s native token (e.g., ETH on Ethereum)Output token address (opportunity’s receipt token address)
Amount to trade in the smallest unit (wei for ETH, base units for tokens)
CRITICAL: Your unique distributor identifier for tracking and attribution
Response Fields
The route response contains one or more steps, each with a ready-to-sign transaction (tx field) that should be executed sequentially. The substeps array provides detailed information about what each transaction will do (swap, deposit, etc.).
Contains the route data with steps and execution details
Array of steps required to execute the route. Each step represents an action (e.g., approval, swap, deposit)
Expected output amount in the smallest unit of the output token
Expected price impact as a decimal (e.g.,
0.0007 = 0.07%)Whether the approval step failed
Unix timestamp when this route expires. Routes should be executed before this time
Step Object
The type of step (e.g., “enso” for Enso protocol operations)
The output amount for this specific step
Information about the asset/protocol being used in this step
Detailed substeps showing the token flow and operations
The transaction object to execute for this step
Transaction Object (tx)
The user’s address (same as the
user parameter)The contract address to send the transaction to
Encoded transaction data (calldata)
Amount of native token to send with the transaction (in wei)
Estimated gas limit for the transaction
Substep Object
The type of operation (e.g., “deposit”, “swap”, “approve”)
The amount being processed in this substep
The protocol identifier handling this operation
The vault contract address receiving the deposit
Array of token(s) being sent, including address, chain, decimals, symbol, price, and logos
Array of token(s) being received, including address, chain, decimals, symbol, and logos
Price impact for this specific substep (if applicable)
Slippage Guidelines
Low Slippage
0.1% - 0.5%Stablecoin swaps and low volatility pairs
Medium Slippage
0.5% - 2%Normal market conditions for most tokens
High Slippage
2% - 5%High volatility or low liquidity pairs
Important Notes
Routes have an expiration time (
exp field). Execute transactions before this timestamp to ensure the route is still valid and prices haven’t changed significantly.Distributor ID is mandatory! Without it, deposits will not be tracked or attributed to your account. Always include
distributor_id in every route request.Routes may contain multiple steps (e.g., approval, swap, deposit). Each step contains a transaction object (
tx) that must be executed sequentially in the order provided.Error Handling
Common Errors
Invalid Slippage
Invalid Slippage
Status Code: 400 Bad RequestResponse:Solution: Use a slippage value between 0.001 and 0.5
Missing Distributor ID
Missing Distributor ID
Status Code: 400 Bad RequestResponse:Solution: Always include your distributor ID in the request
Invalid Chain ID
Invalid Chain ID
Status Code: 400 Bad RequestResponse:Solution: Use a supported chain ID. Check the opportunities endpoint for available chains
Invalid Token Address
Invalid Token Address
Status Code: 400 Bad RequestResponse:Solution: Verify token addresses are valid for the specified chain. Use
native for native tokensRoute Not Found
Route Not Found
Status Code: 404 Not FoundResponse:Solution: The requested swap is not possible. Verify the token addresses and chain.
Amount Too Low
Amount Too Low
Status Code: 400 Bad RequestResponse:Solution: Increase the deposit amount. Very small amounts may not be economical due to gas costs
Related Endpoints
- Opportunities API - Discover available earning opportunities
- Deposits API - Track and query deposits through your distributor
- Membership API - Connect wallets and create user memberships

