PRISM MEV Platform - Complete Documentation
π Overview
The PRISM MEV Platform is a high-performance MEV arbitrage system with integrated observability and counter-MEV protection, designed for deployment on Solana. This documentation provides comprehensive guidance for deployment, configuration, and operation.
π Table of Contents
- Quick Start
- Architecture Overview
- Observability Integration
- API Documentation
- Deployment Guides
- Configuration Reference
- Operational Procedures
- Troubleshooting
π Quick Start
Prerequisites
- Rust 1.70+ with Cargo
- Docker and Docker Compose
- Node.js 18+ (for Swagger UI)
- Access to Solana RPC endpoints
- HelioHost VPS or compatible hosting
Local Development Setup
# Clone the repository
git clone <repository-url>
cd prism-rust
# Build the workspace
cargo build --workspace
# Run tests
cargo test --workspace
# Start the main platform
cargo run --bin prism-mev-platform
# Start the arbitrage engine
cargo run --bin mev-arbitrage-engine
# Generate API documentation
make openapi-spec
# or: cargo run --bin generate_frontend_clients -- --write-spec-only
ποΈ Architecture Overview
Core Components
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRISM MEV Platform β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ β
β β Arbitrage β β Counter-MEV β β Observabilityβ β
β β Engine β β Protection β β & Metrics β β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ β
β β DEX Providers β β Transaction β β RPC Client β β
β β (Jupiter/Orca) β β Builder β β (Solana) β β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Observability Stack β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ β
β β OpenTelemetry β β Coroot β β Grafana β β
β β (OTLP Export) β β (Observability β β (Optional) β β
β β β β Backend) β β β β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Features
- Sub-100ms Arbitrage Detection: Real-time cross-DEX opportunity identification
- Counter-MEV Protection: Sandwich attack detection and disruption
- Multi-DEX Integration: Jupiter, Orca, Meteora support
- Comprehensive Observability: OpenTelemetry + Coroot integration
- Production-Ready: Full error handling, circuit breakers, rate limiting
π Observability Integration
OpenTelemetry + Coroot Stack
The platform includes comprehensive observability with:
- Structured Logging: JSON-formatted logs with correlation IDs
- Distributed Tracing: End-to-end request tracing with business context
- Metrics Collection: Real-time performance and business metrics
- OTLP Export: Direct integration with Coroot observability backend
Key Metrics Tracked
#![allow(unused)] fn main() { // Business Metrics - arbitrage_opportunities_found_total - arbitrage_opportunities_executed_total - arbitrage_profit_total_lamports - arbitrage_success_rate_percent // Performance Metrics - dex_quote_fetch_duration_ms - transaction_build_duration_ms - rpc_call_duration_ms - circuit_breaker_state // Error Metrics - provider_errors_total - transaction_errors_total - rpc_errors_total - counter_mev_detections_total }
Tracing Context
All operations include structured tracing spans with:
#![allow(unused)] fn main() { // Arbitrage Operations - cycle_id: UUID - dex_path: Vec<DexType> - input_amount: u64 - expected_profit: f64 - execution_time_ms: u64 // Counter-MEV Operations - detection_type: String - confidence_score: f64 - mitigation_strategy: String - response_time_ms: u64 }
π API Documentation
OpenAPI/Swagger Generation
Generate comprehensive API documentation:
# Generate OpenAPI specification
make openapi-spec
# Serve Swagger UI locally
npm install -g swagger-ui-serve
swagger-ui-serve docs/api/openapi.yaml
# Access at http://localhost:3000
Core API Endpoints
Health & Metrics
GET /health
GET /metrics
GET /api/v1/system/health
GET /api/v1/system/metrics
GET /api/v1/providers/health
Arbitrage Operations
POST /api/v1/arbitrage/analyze
GET /api/v1/arbitrage/opportunities
POST /api/v1/arbitrage/execute
GET /api/v1/arbitrage/history
Counter-MEV Protection
POST /api/v1/counter-mev/analyze
GET /api/v1/counter-mev/detections
POST /api/v1/counter-mev/mitigate
Authentication
API endpoints use API key authentication:
x-api-key: your-api-key-here
π¦ Documentation Automation & CI
- Build system: mdBook configured via
book.tomlwith link checking enabled. - Local commands:
make docs-install-toolsmake docs-servemake docs-buildmake docs-validate
- Scripts:
scripts/build-docs.sh,scripts/validate-docs.sh - CI:
.github/workflows/docs.ymlbuilds, validates, and deploys documentation to GitHub Pages on pushes tomain.
π Deployment Guides
Deployment Overview
Choose the method that fits your environment.
Docker Compose Deployment
For local development and testing.
Kubernetes Deployment
For cluster and production deployments.
βοΈ Configuration Reference
Environment Variables
# Core Configuration
RUST_LOG=info
RUST_BACKTRACE=1
# RPC Configuration
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
SOLANA_RPC_TIMEOUT_MS=30000
# Observability Configuration
OTEL_EXPORTER_OTLP_ENDPOINT=http://coroot:8080/v1/traces
OTEL_SERVICE_NAME=prism-mev-platform
OTEL_SERVICE_VERSION=0.1.0
DEPLOYMENT_ENVIRONMENT=production
# DEX Provider Configuration
JUPITER_API_URL=https://quote-api.jup.ag/v6
ORCA_API_URL=https://api.orca.so
METEORA_API_URL=https://api.meteora.ag
# Security Configuration
API_KEY=your-secure-api-key
WALLET_PRIVATE_KEY_PATH=/secrets/wallet.key
Configuration Files
π§ Operational Procedures
Monitoring & Alerting
Key Metrics to Monitor
-
Arbitrage Performance
- Opportunity detection rate
- Execution success rate
- Profit margins and totals
- Latency percentiles
-
System Health
- RPC endpoint availability
- DEX provider response times
- Circuit breaker states
- Memory and CPU usage
-
Error Rates
- Transaction failures
- Provider timeouts
- Network connectivity issues
Alert Thresholds
# Critical Alerts
- arbitrage_success_rate < 90%
- rpc_error_rate > 5%
- memory_usage > 85%
- profit_margin < 0.1%
# Warning Alerts
- dex_response_time > 500ms
- circuit_breaker_open = true
- queue_depth > 1000
Maintenance Procedures
Daily Operations
-
Health Checks
curl http://localhost:8080/health curl http://localhost:9090/metrics -
Log Review
# Check error logs grep "ERROR" /var/log/prism-mev/*.log # Monitor profit/loss grep "profit" /var/log/prism-mev/*.log | tail -100 -
Performance Review
- Review Coroot dashboards
- Check arbitrage success rates
- Validate counter-MEV effectiveness
Weekly Operations
- Configuration Updates
- Security Patches
- Performance Optimization
- Backup Verification
π Troubleshooting
Common Issues
High Latency
- Check RPC endpoint performance
- Verify network connectivity
- Review DEX provider response times
- Check system resource usage
Transaction Failures
- Validate wallet balance
- Check priority fee settings
- Review slippage tolerance
- Verify DEX liquidity
Observability Issues
- Confirm OTLP endpoint accessibility
- Check Coroot backend status
- Validate environment variables
- Review log output for errors
β View Troubleshooting in Operator Manual
π Additional Resources
π Support
For technical support and questions:
- Documentation: Check this comprehensive guide first
- Issues: Create GitHub issues for bugs and feature requests
- Discussions: Use GitHub Discussions for general questions
- Security: Report security issues privately
Last Updated: 2025-01-06
Version: 0.1.0
Platform: Solana MEV Arbitrage System