symbiosis_api/lib.rs
1//! A high-level binding for Symbiosis API, written in Rust.
2//!
3//! Symbiosis API allows you to integrate the functionalities of the Symbiosis Protocol into your
4//! application, platform or protocol.
5//!
6//! By integrating the Symbiosis API, you can quickly and effectively enable decentralized
7//! cross-chain swaps and cross-chain liquidity management for your users.
8//!
9//! This crate uses the [reqwest] crate for a convenient, higher-level HTTP Client, for request and
10//! response, to and from Symbiosis, and [serde] for serialize and deserialize from and to
11//! appropriate data format.
12//!
13//! # Examples
14//!
15//! Let's start out swapping from ETH on Ethereum to MNT on Mantle network.
16//!
17//! ```no_run
18//! use ethers_core::types::Chain;
19//! use ethers_core::utils::parse_ether;
20//! use symbiosis_api::cores::query::Query;
21//! use symbiosis_api::{
22//! api::swapping,
23//! api::swapping::SwapResponse,
24//! symbiosis::Symbiosis,
25//! types::token::{Token, TokenAmount},
26//! };
27//!
28//! #[tokio::main]
29//! async fn main() -> Result<(), anyhow::Error> {
30//! // Create the client.
31//! let client = Symbiosis::new("");
32//!
33//! // Create a simple endpoint.
34//! let eth = Token::builder().build()?;
35//! let mnt = Token::builder().chain_id(Chain::Mantle).build()?;
36//! let token_amount_in = TokenAmount::builder()
37//! .token(eth)
38//! .amount(parse_ether(1)?)
39//! .build()?;
40//! let endpoint = swapping::SwappingExactIn::builder()
41//! .token_amount_in(token_amount_in)
42//! .token_out(mnt)
43//! .from(
44//! "0xe99E80EE4792395b2F639eE0661150D2b6B1996d"
45//! .parse()
46//! .unwrap(),
47//! )
48//! .to("0xe99E80EE4792395b2F639eE0661150D2b6B1996d"
49//! .parse()
50//! .unwrap())
51//! .build()?;
52//!
53//! // Call the endpoint. The return type decides how to represent the value.
54//! let swapping: SwapResponse = endpoint.query(&client).await?;
55//!
56//! println!("{:?}", swapping);
57//!
58//! anyhow::Ok(())
59//! }
60//! ```
61//!
62//! For more examples, take a look at the `examples/` directory.
63//!
64//! This crate design based on https://plume.benboeckel.net/~/JustAnotherBlog/designing-rust-bindings-for-rest-ap-is
65
66#![deny(missing_docs)]
67#![warn(missing_debug_implementations, rust_2018_idioms, rustdoc::all)]
68#![allow(rustdoc::missing_doc_code_examples, rustdoc::private_doc_tests)]
69#![cfg_attr(docsrs, feature(doc_cfg))]
70#![allow(unused)]
71
72/// API module, contains list of API supported by Symbiosis.
73pub mod api;
74/// Core module, contains some helpful generic traits for endpoint and request.
75pub mod cores;
76/// Symbiosis client module, contains information about symbiosis connection.
77pub mod symbiosis;
78/// Types module, contains some helpers type associated with the data Symbiosis provided.
79pub mod types;