Rust Crate

Introduction to the Rust Crate

The Carbium Rust crate is a powerful and efficient Rust library for integrating Carbium's decentralized exchange aggregator directly into your applications. Designed for developers building on the Solana blockchain, Spiderswap provides streamlined access to the most competitive token swap rates, liquidity management, and advanced trading features. With its lightweight architecture and robust functionality, the Spiderswap crate is ideal for building scalable and high-performance DeFi applications.


Why Use the Carbium Crate?

  • Access to Carbium’s Liquidity Aggregation: Tap into Carbium’s efficient routing across multiple liquidity providers to secure the best rates.
  • Seamless API Integration: Build custom applications, bots, or trading tools with minimal setup.
  • Performance-Focused: Optimize your operations with low-latency and high-reliability infrastructure.
  • Open Source and Community-Driven: Benefit from active development, documentation, and support.

Getting Started with the Carbium Crate

Installation

To include the Carbium crate in your Rust project, add it to your Cargo.toml dependencies:

[dependencies]
spiderswap = "latest_version"

Replace latest_version with the most recent version from Spiderswap on crates.io.

Example Usage

Below is a basic example of how to use the Spiderswap crate in your Rust project:

use spiderswap::api::CarbiumClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the Carbium Client
    let client = CarbiumClient::new("https://api.carbium.exchange");

    // Example: Fetch token pair price
    let pair_price = client.get_swap_quote("SOL", "USDC", 1.0).await?;
    println!("Price for 1 SOL to USDC: {:?}", pair_price);

    // Example: Execute a token swap
    let swap_result = client.execute_swap("SOL", "USDC", 1.0, "your_wallet_address").await?;
    println!("Swap completed: {:?}", swap_result);

    Ok(())
}

Key Features

  1. Retrieve Quotes: Access real-time swap quotes for any token pair.
  2. Execute Trades: Easily perform token swaps within the Solana ecosystem.
  3. Custom Routing: Fine-tune transaction parameters for optimized performance.

Comprehensive Documentation

Explore the full functionality of the crate by visiting the official documentation. You’ll find detailed guides, examples, and advanced configurations to make the most of Carbium in your projects.


What’s Next