$ show Uniswap/routing-api
The Uniswap Routing API is a serverless AWS Lambda service that provides swap quotes across Uniswap V2, V3, V4, and mixed protocols on 20+ EVM chains. It is deployed via AWS CDK with API Gateway, DynamoDB for route/pool caching, S3 for token lists and pool snapshots, and CloudWatch for monitoring. The core quote handler (`lib/handlers/quote/quote.ts`) validates inputs, selects protocols, and delegates to the `@uniswap/smart-order-router` engine. A sophisticated RPC provider layer (`UniJsonRpcProvider`, `SingleJsonRpcProvider`) manages multi-provider failover, health checks, and latency-based selection. Traffic switching experiments (`TrafficSwitcher`) enable gradual rollouts of new implementations with shadow sampling. The system also includes cron-based pool caching, GraphQL-based token fee fetching, and extensive CloudWatch dashboards. While primarily an application, it incorporates data pipeline elements for caching and token list management. The codebase shows signs of deprecation (DECOMMISSION_FAILURE_RATE = 1 in the quote handler) and contains several hardcoded configurations and temporary workarounds, but overall demonstrates solid engineering with reusable abstractions.
The LLM identified 4 files worth highlighting for reuse:
Generic base class for gradual rollouts with shadow sampling. Supports per-chain percentage configuration, synchronous execution of current and target implementations, and metric emission for comparison. Can be extracted and reused for any feature flag or A/B testing scenario requiring parallel execution and result comparison.
Multi-provider RPC gateway that manages a set of JSON-RPC providers with health tracking, latency evaluation, session stickiness, and cross-provider response comparison. Implements weighted random selection based on health scores and latency. Reusable for any application requiring resilient multi-endpoint RPC communication.
Abstract DynamoDB cache implementation with configurable TTL, batch writes, and key construction. Provides a clean interface for caching arbitrary data with expiration. Can be extracted and reused for any DynamoDB-backed caching need.
Decorator for JSON-RPC providers that wraps each call with CloudWatch metric emission (success, failure, latency). Demonstrates a clean instrumentation pattern that can be applied to any provider or service call without modifying the underlying implementation.