Expand description
Rust client for the KyberSwap Aggregator API
KyberSwap is a multi-chain DEX aggregator that provides optimal swap routes.
§Quick Start
use kybr::{Client, Chain, RouteRequest};
#[tokio::main]
async fn main() -> Result<(), kybr::Error> {
let client = Client::new()?;
let request = RouteRequest::new(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
"1000000000000000000", // 1 WETH
);
let route = client.get_routes(Chain::Ethereum, &request).await?;
println!("Output: {} USDC", route.amount_out);
Ok(())
}Re-exports§
pub use client::Client;pub use error::Error;pub use error::Result;pub use types::BuildRouteRequest;pub use types::BuildRouteResponse;pub use types::Chain;pub use types::RouteRequest;pub use types::RouteSummary;pub use types::RoutesResponse;pub use types::SwapStep;pub use types::TokenInfo;
Modules§
- client
- HTTP client for the
KyberSwapAggregator API - error
- Error types for the
KyberSwapAPI client - types
- Types for the
KyberSwapAPI responses
Structs§
- ApiConfig
- Generic API configuration
- Base
Client - A base HTTP client that handles common request/response patterns.
- Retry
Config - Configuration for retry behavior
- Retry
Error - Error wrapper that includes retry information
Constants§
- DEFAULT_
BASE_ URL - Default base URL for the
KyberSwapAPI
Traits§
- Retryable
Error - Determines if an error should be retried
Functions§
- default_
config - Create a default Kyber 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
KyberSwapAPI client