swapkit-rs

Crates.ioswapkit-rs
lib.rsswapkit-rs
version0.0.9
sourcesrc
created_at2024-05-21 20:53:13.139015
updated_at2024-06-26 20:17:46.092243
descriptionUnofficial Swapkit API bindings for Rust
homepage
repositoryhttps://github.com/physics515/swapkit-rs
max_upload_size
id1247199
size182,877
Justin Icenhour (physics515)

documentation

README

SwapKit

Swapkit’s SDK gives developers API access to a powerful suite of non-custodial, permissionless DeFi tools to interact with 5,500+ crypto assets across 14+ blockchains including Bitcoin, Ethereum, BNB Chain via THORChain, Chainflip and Maya Protocol.

swapkit-rs

This is the Unofficial Rust bindings for the SwapKit API. It aims to provide a fully typeed client for the Swapkit API.

The client is rate limited to 1 request per second by default but this can be changed by creating a new Configuration object and passing it to the Config::set_rate_limit_ms() method.

Supported Endpoints

  • get_chains - Returns a list of all supported chains.

  • get_chains_with_details - Returns a list of all supported chains with details.

  • get_gas_prices - Returns a list of gas prices for all supported chains.

  • get_available_assets_for_pool - Errors (Thorswap endpoint does not return a value.)

  • get_available_lending_assets - Returns a list of all available lending assets.

  • get_loans - Returns a loan for a given address and asset.

  • get_supported_providers - Returns a list of all supported providers.

  • get_request_a_swap_quote - Returns a swap quote for a given swap request.

  • get_request_a_borrow_quote - Returns a borrow quote for a given borrow request.

  • get_request_a_repay_quote - Returns a repay quote for a given repay request.

  • get_minimum_amount_to_send_with_details - Returns the minimum amount to send with details.

  • get_gas_history - Returns the gas history for a given chain.

  • get_gas_rates - Returns the gas rates for all chains.

  • get_currencies_with_details - Returns a list of all supported currencies with details.

  • get_token_pair_exchange_rate - Returns the exchange rate for a given token pair.

  • get_cached_prices - Returns the cached prices for given tokens.

  • get_token_providers - Returns a list of all token providers.

  • get_transaction_details - *** Errors (Thorswap endpoint does not return a value.)***

Basic Usage

use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;

#[tokio::main]
async fn main() {
    let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
    let mut swapkit = Swapkit::new(swapkit_config);
    let supported_chains = swapkit.get_supported_chains().await.unwrap();

    assert_ne!(supported_chains.get_chains().len(), 0);
}
Commit count: 18

cargo fmt