Calibrator is a TypeScript/Node.js API service using Fastify that facilitates cross-chain token swaps using The Compact protocol. It acts as a price discovery and parameter calculation service, helping users prepare valid Compact messages for cross-chain token exchanges.
-
Price Discovery and Validation
- Retrieve spot prices from multiple sources (Uniswap API, CoinGecko)
- Compare and validate prices across sources
- Select optimal price for user benefit
-
Arbiter Selection
- Maintain configuration of valid arbiters
- Select appropriate arbiter based on chains involved
- Verify arbiter availability and capability
-
Fee Calculation
- Calculate message relay fees (dispensation)
- Estimate gas costs for settlement
- Determine total transaction costs
-
Parameter Calculation
- Calculate minimum output based on user slippage tolerance
- Generate complete Compact message parameters
- Validate all parameters meet protocol requirements
- Framework: React with TypeScript
- Build Tool: Vite
- Key Features:
- Interactive UI for token swap parameter configuration
- Real-time price and fee displays
- Chain and token selection interfaces
- Transaction parameter visualization
- Components:
- Styling: TailwindCSS for modern, responsive design
- State Management: React Query for API integration
- Development: Hot module replacement (HMR)
- Framework: Fastify
- Endpoints:
- GET /health - Service health check
- POST /quote - Main endpoint for parameter calculation
- GET /arbiters - View supported arbiters
- GET /chains - View supported chains
- Static File Serving:
- Serves compiled React application
- Handles SPA routing
- Integrates with Uniswap V3 API
- Integrates with CoinGecko API
- Implements price comparison and selection logic
- Handles caching of recent price data
- Manages arbiter configuration
- Implements arbiter selection logic
- Monitors arbiter health/status
- Calculates message relay fees
- Estimates gas costs
- Maintains gas price oracle connections
- Calculates minimum output
- Generates Compact message parameters
- Validates parameter bounds
- TypeScript/Node.js runtime
- Configuration management
- Logging and monitoring
- Error handling and reporting
- Health checks and metrics
- Review complete Compact protocol documentation
- Document specific requirements for arbiter selection
- Define price deviation tolerance thresholds
- Document gas estimation methodology
- Define API response formats and error codes
- Set up TypeScript project with proper configuration
- Configure Fastify server with basic middleware
- Set up logging infrastructure
- Configure monitoring and alerting
- Set up CI/CD pipeline
- Set up React application with Vite
- Configure TailwindCSS for styling
- Set up development environment with HMR
- Implement token selection interface
- Create price display components
- Build transaction parameter form
- Add real-time validation
- Implement responsive design
- Add error handling and user feedback
- Implement Uniswap V3 API client
- Implement CoinGecko API client
- Set up price comparison logic
- Implement gas price oracle integration
- Create mock integrations for testing
- Implement Price Service
- Price fetching logic
- Price comparison algorithm
- Caching layer
- Implement Arbiter Service
- Configuration management
- Selection logic
- Health checking
- Implement Fee Calculator
- Gas estimation logic
- Dispensation calculation
- Implement Parameter Service
- Minimum output calculation
- Message parameter generation
- Validation logic
- Implement health endpoint
- Implement main quote endpoint
- Implement support endpoints
- Add request validation
- Add rate limiting
- Add authentication/authorization
- Write unit tests for all services
- Write integration tests
- Set up end-to-end testing
- Create performance tests
- Document testing strategy
- Create API documentation
- Write deployment guide
- Create monitoring guide
- Document troubleshooting procedures
- What are the specific criteria for arbiter selection?
- What is the acceptable price deviation threshold between sources?
- How should gas estimation account for different network conditions?
- What are the required response times for the API?
- What monitoring metrics should be tracked?
- Prioritize implementation checklist
- Create detailed technical specifications for each component
- Begin implementation of core services in TypeScript with Node.js and Fastify (small steps at a time with frequent commits and writing tests as we go)
- Start building the frontend interface components in parallel with the API development