Skip to main content

Crate vlra

Crate vlra 

Source
Expand description

Rust client for the Velora (ParaSwap) DEX aggregator API

Velora (formerly ParaSwap) is a leading DEX aggregator that provides optimal swap routes across multiple DEXs. It offers advanced features like MEV protection, gas optimization, and multi-path routing.

§Features

  • Multi-chain support (Ethereum, BSC, Polygon, Arbitrum, Optimism, etc.)
  • MEV protection through private transactions
  • Advanced routing with multi-path swaps
  • Gas optimization
  • Delta pricing algorithm

§Quick Start

use vlra::{Client, Chain, PriceRequest};

#[tokio::main]
async fn main() -> Result<(), vlra::Error> {
    let client = Client::new()?;

    // Get price for swapping 1 ETH to USDC
    let request = PriceRequest::sell(
        "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // Native ETH
        "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
        "1000000000000000000", // 1 ETH in wei
    );

    let response = client.get_price(Chain::Ethereum, &request).await?;
    println!("You would receive: {} USDC (in minimal units)", response.price_route.dest_amount);

    Ok(())
}

Re-exports§

pub use error::Error;
pub use error::Result;
pub use types::ApiErrorResponse;
pub use types::Chain;
pub use types::PriceRequest;
pub use types::PriceResponse;
pub use types::PriceRoute;
pub use types::Route;
pub use types::Side;
pub use types::Swap;
pub use types::SwapExchange;
pub use types::Token;
pub use types::TokenListResponse;
pub use types::TransactionRequest;
pub use types::TransactionResponse;

Modules§

error
Error types for the Velora (ParaSwap) API client
types
Types for the Velora (ParaSwap) API

Structs§

ApiConfig
Generic API configuration
BaseClient
A base HTTP client that handles common request/response patterns.
Client
Client for interacting with the Velora (ParaSwap) API
RetryConfig
Configuration for retry behavior
RetryError
Error wrapper that includes retry information

Constants§

DEFAULT_BASE_URL
Default base URL for the Velora API
NATIVE_TOKEN_ADDRESS
Native token address (used for ETH and other native tokens)

Traits§

RetryableError
Determines if an error should be retried

Functions§

config_with_api_key
Create a config with an API key
default_config
Create a default Velora config
with_retry
Execute an async operation with retries
with_simple_retry
Simple retry wrapper for operations that return Result with any error type

Type Aliases§

Config
Configuration for the Velora API client