The Uniswap routing-api repository deploys an API to AWS that uses @uniswap/smart-order-router to search for the most efficient way to swap token A for token B. The architecture is built around AWS services:
- AWS Lambda - For serverless function execution
- API Gateway - For HTTP endpoint routing
- DynamoDB - For caching
- AWS CDK - For infrastructure deployment
While there isn't a ready-made Docker solution, you can create one by:
The routing API uses Lambda handlers that process HTTP requests. You'll need to wrap these handlers in an Express.js server for local deployment.
The core functionality relies on:
@uniswap/smart-order-router- The main routing logic- Environment variables for RPC providers for each chain
- DynamoDB (which you can replace with an in-memory cache or Redis)
You'll need to set RPC providers for chains like MAINNET = 1, OPTIMISM = 10, ARBITRUM_ONE = 42161, POLYGON = 137, etc.
Option A: Create an Express wrapper
- Extract the Lambda handler functions from the routing-api
- Create an Express.js server that calls these handlers
- Replace DynamoDB with a local caching solution
- Package everything in a Dockerfile
Option B: Use AWS Lambda Web Adapter AWS Lambda Adapters can help convert Lambda functions to run in containers with minimal changes. This approach would involve:
- Using the AWS Lambda Web Adapter to run the Lambda code locally
- Creating a Dockerfile that includes the adapter
- Running the container with proper environment variables
If you only need the routing functionality and not the full API, you could:
- Use
@uniswap/smart-order-routerdirectly in your application - Build a minimal Express API around it
- This would be simpler than converting the entire routing-api
Since no one seems to have published a Docker version yet, I'd recommend:
- Start with the smart-order-router package directly rather than trying to convert the entire AWS-based routing-api
- Create a simple Express.js API that exposes the routing functionality
- Containerize that simpler application
This would give you the core routing functionality without the complexity of converting all the AWS-specific code.
Would you like me to search for more specific information about implementing a solution using the smart-order-router directly, or would you prefer guidance on converting the Lambda functions to run locally?