Skip to content

heliusdevlabs/jito-shared-infrastructure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Shared Infrastructure

A comprehensive shared infrastructure library for Solana trading bots, providing common components, utilities, and services that can be used across multiple bot implementations.

πŸ“ž Contact & Support

Telegram

πŸ’¬ Get in touch for support, questions, or collaboration

πŸš€ Features

  • Jito Client: Unified Jito bundle submission and confirmation
  • Monitoring Service: Prometheus metrics and structured logging
  • Configuration Management: Centralized configuration handling
  • Common Types: Shared data structures and enums
  • Utility Functions: Common helper functions and utilities
  • Error Handling: Standardized error types and handling
  • Performance Optimization: Optimized common operations

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Jito Client   β”‚    β”‚   Monitoring    β”‚    β”‚   Configuration β”‚
β”‚   Service       β”‚    β”‚   Service       β”‚    β”‚   Manager       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Common Types  β”‚    β”‚   Utility       β”‚    β”‚   Error         β”‚
β”‚   & Structs     β”‚    β”‚   Functions     β”‚    β”‚   Handling      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Installation

Prerequisites

  • Rust 1.70+
  • Solana CLI tools
  • Jito bundle access

Build

cd shared-infrastructure
cargo build --release

βš™οΈ Configuration

The shared infrastructure uses a centralized configuration system:

[rpc]
mainnet = "https://api.mainnet-beta.solana.com"
devnet = "https://api.devnet.solana.com"

[jito]
endpoint = "https://mainnet.block-engine.jito.wtf"
bundle_endpoint = "https://mainnet.block-engine.jito.wtf/api/v1/bundles"
tip_account = "96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5"

[monitoring]
prometheus_port = 9090
log_level = "info"
metrics_enabled = true

[performance]
max_concurrent_requests = 100
request_timeout = 30
retry_attempts = 3

πŸš€ Usage

Adding as Dependency

Add to your Cargo.toml:

[dependencies]
shared-infrastructure = { path = "../shared-infrastructure" }

Basic Usage

use shared_infrastructure::{
    JitoClient, MonitoringService, Config, Error,
};

// Initialize shared components
let config = Config::load("config.toml")?;
let jito_client = JitoClient::new(&config.jito)?;
let monitoring = MonitoringService::new(&config.monitoring)?;

// Use in your bot
let bundle_result = jito_client.submit_bundle(transactions).await?;
monitoring.record_transaction("arbitrage", bundle_result.profit);

πŸ“Š Components

Jito Client

Unified interface for Jito bundle operations:

use shared_infrastructure::JitoClient;

let client = JitoClient::new(&config.jito)?;

// Submit bundle
let result = client.submit_bundle(transactions).await?;

// Confirm bundle
let confirmation = client.confirm_bundle(&result.bundle_id).await?;

Monitoring Service

Comprehensive monitoring and metrics:

use shared_infrastructure::MonitoringService;

let monitoring = MonitoringService::new(&config.monitoring)?;

// Record metrics
monitoring.record_transaction("strategy_name", profit);
monitoring.record_error("error_type", error_count);

// Get metrics
let metrics = monitoring.get_metrics().await?;

Configuration Manager

Centralized configuration handling:

use shared_infrastructure::Config;

let config = Config::load("config.toml")?;
let rpc_url = config.rpc.mainnet;
let jito_config = &config.jito;

Common Types

Shared data structures:

use shared_infrastructure::{
    TransactionResult, BundleResult, MevOpportunity,
    ArbitrageOpportunity, CopyTradeSignal
};

let opportunity = ArbitrageOpportunity {
    dex_a: "raydium".to_string(),
    dex_b: "orca".to_string(),
    token_pair: "SOL/USDC".to_string(),
    price_difference: 0.02,
    estimated_profit: 100.0,
};

πŸ”§ API Reference

Jito Client

impl JitoClient {
    pub fn new(config: &JitoConfig) -> Result<Self, Error>;
    pub async fn submit_bundle(&self, transactions: Vec<Transaction>) -> Result<BundleResult, Error>;
    pub async fn confirm_bundle(&self, bundle_id: &str) -> Result<ConfirmationResult, Error>;
    pub async fn get_bundle_status(&self, bundle_id: &str) -> Result<BundleStatus, Error>;
}

Monitoring Service

impl MonitoringService {
    pub fn new(config: &MonitoringConfig) -> Result<Self, Error>;
    pub fn record_transaction(&self, strategy: &str, profit: f64);
    pub fn record_error(&self, error_type: &str, count: u64);
    pub async fn get_metrics(&self) -> Result<Metrics, Error>;
    pub fn start_server(&self) -> Result<(), Error>;
}

Configuration

impl Config {
    pub fn load(path: &str) -> Result<Self, Error>;
    pub fn validate(&self) -> Result<(), Error>;
    pub fn get_rpc_url(&self, network: &str) -> Option<&String>;
}

πŸ›‘οΈ Security

  • Private Key Protection: Secure key handling and storage
  • Transaction Validation: Comprehensive transaction verification
  • Rate Limiting: Protection against API abuse
  • Error Handling: Robust error recovery mechanisms

πŸ“ˆ Performance

  • Optimized Operations: High-performance common functions
  • Connection Pooling: Efficient resource management
  • Async Operations: Non-blocking I/O operations
  • Memory Efficient: Minimal memory footprint

πŸ§ͺ Testing

Run the test suite:

cargo test

Run with coverage:

cargo test --features coverage

πŸ“š Examples

Basic Integration

use shared_infrastructure::{
    JitoClient, MonitoringService, Config
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::load("config.toml")?;
    let jito_client = JitoClient::new(&config.jito)?;
    let monitoring = MonitoringService::new(&config.monitoring)?;
    
    // Your bot logic here
    
    Ok(())
}

Advanced Usage

use shared_infrastructure::{
    JitoClient, MonitoringService, Config, Error
};

async fn execute_strategy(
    jito_client: &JitoClient,
    monitoring: &MonitoringService,
    transactions: Vec<Transaction>
) -> Result<f64, Error> {
    let start_time = std::time::Instant::now();
    
    let bundle_result = jito_client.submit_bundle(transactions).await?;
    let confirmation = jito_client.confirm_bundle(&bundle_result.bundle_id).await?;
    
    let execution_time = start_time.elapsed();
    monitoring.record_transaction("strategy_name", bundle_result.profit);
    monitoring.record_execution_time("strategy_name", execution_time);
    
    Ok(bundle_result.profit)
}

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

For issues and questions:

  • Open an issue on GitHub
  • Check the documentation
  • Review the examples

πŸ”— Related Projects

About

Jito Shredstream Infrastructure, Fastest Way

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages